1、字典组件优化

Former-commit-id: b5b55fd8b27e2f8e40f12bd4e4e27f0c96a277b0
master
王兵 5 years ago
parent ac3f17b734
commit a9500e31b1

@ -23,7 +23,6 @@
<include refid="table"/>
WHERE
`IS_DELETED` = 0
</#if>
<#list table.fields as f>
<#if f.isQuery>
<#if f.fieldType.javaType() == "Boolean">

@ -47,7 +47,7 @@
.then(function (response) {
if (response.data.errors && response.data.errors.length == 0) {
nav.barFinish();
} else if(response.data.errors && response.data.errors.length > 0) {
} else if (response.data.errors && response.data.errors.length > 0) {
nav.barError();
} else {
response.data = {errors: [{message: '服务器响应错误'}]};
@ -186,10 +186,6 @@
this.mMethod = "create";
this.post(callback);
};
this.create = function (callback) {
this.mMethod = "create";
this.post(callback);
};
this.delete = function (callback) {
this.mMethod = "delete";
this.post(callback);
@ -290,7 +286,7 @@
new Ajax()
.module(this.module)
.target(this.target)
.data( this.vm)
.data(this.vm)
.exports(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
@ -502,23 +498,50 @@
onClose: callback
});
},
// 本标签打开
toOpen: function (url) {
this.tipShow();
var url = url.substring(0, 1) == "/" ? url.substring(1) : url;
$("body").append($("<a id='wb-open' href='" + this.context + "/" + url + "' target='_self' style='dispaly:none;'></a>"))
$("body").append($("<a id='wb-open' href='" + this.context + "/" + url + "' target='_self' style='display:none;'></a>"))
document.getElementById("wb-open").click();
$("#wb-open").remove();
},
// 新标签打开
toOpenNew: function (url) {
var url = url.substring(0, 1) == "/" ? url.substring(1) : url;
$("body").append($("<a id='wb-open' href='" + this.context + "/" + url + "' target='_blank' style='dispaly:none;'></a>"))
$("body").append($("<a id='wb-open' href='" + this.context + "/" + url + "' target='_blank' style='display:none;'></a>"))
document.getElementById("wb-open").click();
$("#wb-open").remove();
},
// 回到首页
toHome: function () {
this.tipShow();
location.href = this.context + "/"
},
// 打开一个新Tab
toOpenTab: function (tab) {
if (window.index) {
window.index.addTab(tab)
} else if (window.parent.index) {
window.parent.index.addTab(tab)
}
},
// 关闭Tab
toCloseTab: function (tabName) {
if (window.index) {
window.index.removeTab(tabName)
} else if (window.parent.index) {
window.parent.index.removeTab(tabName)
}
},
// 关闭当前Tab
toCloseCurTab: function () {
if (window.index) {
window.index.removeTab(window.index.activeTabName)
} else if (window.parent.index) {
window.parent.index.removeTab(window.parent.index.activeTabName)
}
},
// 滚动屏蔽至顶部
scrollToTop: function () {
var distance = document.documentElement.scrollTop || document.body.scrollTop;
@ -577,15 +600,15 @@
}
}
},
setCookie:function (name, value, expiretime) {
setCookie: function (name, value, expiretime) {
var exdate = new Date();
exdate.setDate(exdate.getTime() + expiretime);
document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + exdate.toGMTString() + ";path=/";
},
getCookie:function (name) {
getCookie: function (name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(name + "=")
if (c_start != -1){
if (c_start != -1) {
c_start = c_start + name.length + 1
c_end = document.cookie.indexOf(";", c_start)
if (c_end == -1)
@ -595,7 +618,7 @@
}
return ""
},
clearCookie:function (name) {
clearCookie: function (name) {
this.setCookie(name, "", -1);
}
}
@ -609,9 +632,20 @@
},
props: {
value: {
type: String,
type: String | Object,
default: ''
},
valueFor: {
type: String,
default: 'key',
validator: function (value) {
var r = (['key', 'value', 'item'].indexOf(value) !== -1);
if (!r) {
console.error("value-for的值只能是['key','value','item']中的一个.")
}
return r;
}
},
dictName: {
type: String,
default: ''
@ -624,31 +658,42 @@
type: String,
default: ''
},
change: {
type: Function,
default: function (item) {
}
}
},
methods: {
input: function (value) {
this.$emit('input', value);
input: function (item) {
switch (this.valueFor) {
case "key":
this.$emit('input', item.key);
break;
case "value":
this.$emit('input', item.value);
break;
case "item":
this.$emit('input', item);
break;
}
},
},
created: function () {
if (this.dictName) {
new Ajax()
.module("system")
.target("dict")
.method("load")
.data({dictName: this.dictName})
.post(function (response) {
new Ajax("system", "dict", "load").data({dictName: this.dictName}).post(function (response) {
if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {
this.options = response.dictItems;
}
}.bind(this))
}.bind(this));
}
},
template: '' +
'<el-select :value="value" @input="input" filterable clearable placeholder="请选择" :size="size" :placeholder="placeholder">' +
' <el-option v-for="item in options" :key="item.key" :label="item.value" :value="item.key">' +
'<el-select :value="value" @input="input" filterable clearable placeholder="请选择" :size="size" :placeholder="placeholder" @change="change">' +
' <el-option v-for="item in options" :key="item.key" :label="item.value" :value="item">' +
' <span style="float: left">{{ item.value }}</span>' +
' <span style="float: right; color: #8492a6; font-size: 12px">{{ item.key }}</span>' +
' </el-option>' +
@ -659,7 +704,7 @@
data: function () {
return {
options: [],
props:{
props: {
multiple: false,
checkStrictly: true
}
@ -689,12 +734,7 @@
}
},
created: function () {
new Ajax()
.module("system")
.target("dept")
.method("tree")
.data({dictName: this.dictName})
.post(function (response) {
new Ajax("system", "dept", "tree").data({dictName: this.dictName}).post(function (response) {
if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {

Loading…
Cancel
Save

Powered by TurnKey Linux.