Commit de9dd982 by jianshuqin

优化:组件功能

parent b8f5bba6
......@@ -28,7 +28,7 @@
v-bind:clearable="item.clearable == null || item.clearable"
v-bind:disabled="disabled != null ? disabled :(item.disabled == true || javaScript.call(this,item.disabled))"
v-bind:placeholder="item.placeholder != null ? item.placeholder :('请选择' + (item.label || item.name || ''))"
v-bind:loading="$root.loading"
v-bind:loading="loading"
v-bind:size="item.size || 'small'"
v-bind:multiple="item.multiple"
v-bind:filterable="item.filterable == null || item.filterable"
......@@ -132,6 +132,7 @@
<el-button v-bind:icon="item.icon"
v-bind:size="item.size || 'small'"
v-bind:type="item.buttonType"
v-bind:loading="$root.loading"
v-bind:disabled="disabled != null ? disabled :(item.disabled == true || javaScript.call(this,item.disabled))">
{{ item.name || '浏览' }}
</el-button>
......
......@@ -87,6 +87,7 @@
visibleChange(visible, item) {
var that = this
if (visible && item.api && (!item.listOption || item.listOption.length <= 1 || (that.form && item.prop && that.form[item.prop] && Array.isArray(that.form[item.prop]) && that.form[item.prop].length == item.listOption.length))) {
that.$set(that, "loading", true)
var params = {}
if (item.params) {
var form = that.form
......@@ -110,6 +111,7 @@
var method = item.apiMethod && item.apiMethod.toLocaleLowerCase() == "post" ? item.apiMethod : 'get';
that.$http({
method: method,
control: "select",
url: item.api,
params: method == "get" ? params : null,
body: method == "post" ? params : null,
......@@ -134,8 +136,10 @@
that.$set(that, "item_value", that.form[item.prop])
}
}
that.$set(that, "loading", false)
}, function (error) {
this.$message(error.statusText || " 未知错误!");
that.$set(that, "loading", false)
});
}
},
......
Vue.http.interceptors.push(function (request, next, a) {
this.$root.loadCount = (this.$root.loadCount || 0) + 1;
if (this.$root.loading != true) {
//打开loading
Vue.set(this.$root, "loading", true);
if (request.control != "select") {
this.$root.loadCount = (this.$root.loadCount || 0) + 1;
if (this.$root.loading != true) {
//打开loading
Vue.set(this.$root, "loading", true);
}
}
next(function (response) {
//调用完一个接口就进行-1
this.$root.loadCount--;
//当接口都调用完时关闭loading
if (this.$root.loadCount <= 0) {
this.$root.loadCount = 0;
if (this.$root.loading == true) {
Vue.set(this.$root, "loading", false);
if (request.control != "select") {
//调用完一个接口就进行-1
this.$root.loadCount--;
//当接口都调用完时关闭loading
if (this.$root.loadCount <= 0) {
this.$root.loadCount = 0;
if (this.$root.loading == true) {
Vue.set(this.$root, "loading", false);
}
}
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment