Commit de9dd982 by jianshuqin

优化:组件功能

parent b8f5bba6
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
v-bind:clearable="item.clearable == null || item.clearable" v-bind:clearable="item.clearable == null || item.clearable"
v-bind:disabled="disabled != null ? disabled :(item.disabled == true || javaScript.call(this,item.disabled))" 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: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:size="item.size || 'small'"
v-bind:multiple="item.multiple" v-bind:multiple="item.multiple"
v-bind:filterable="item.filterable == null || item.filterable" v-bind:filterable="item.filterable == null || item.filterable"
...@@ -132,6 +132,7 @@ ...@@ -132,6 +132,7 @@
<el-button v-bind:icon="item.icon" <el-button v-bind:icon="item.icon"
v-bind:size="item.size || 'small'" v-bind:size="item.size || 'small'"
v-bind:type="item.buttonType" v-bind:type="item.buttonType"
v-bind:loading="$root.loading"
v-bind:disabled="disabled != null ? disabled :(item.disabled == true || javaScript.call(this,item.disabled))"> v-bind:disabled="disabled != null ? disabled :(item.disabled == true || javaScript.call(this,item.disabled))">
{{ item.name || '浏览' }} {{ item.name || '浏览' }}
</el-button> </el-button>
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
visibleChange(visible, item) { visibleChange(visible, item) {
var that = this 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))) { 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 = {} var params = {}
if (item.params) { if (item.params) {
var form = that.form var form = that.form
...@@ -110,6 +111,7 @@ ...@@ -110,6 +111,7 @@
var method = item.apiMethod && item.apiMethod.toLocaleLowerCase() == "post" ? item.apiMethod : 'get'; var method = item.apiMethod && item.apiMethod.toLocaleLowerCase() == "post" ? item.apiMethod : 'get';
that.$http({ that.$http({
method: method, method: method,
control: "select",
url: item.api, url: item.api,
params: method == "get" ? params : null, params: method == "get" ? params : null,
body: method == "post" ? params : null, body: method == "post" ? params : null,
...@@ -134,8 +136,10 @@ ...@@ -134,8 +136,10 @@
that.$set(that, "item_value", that.form[item.prop]) that.$set(that, "item_value", that.form[item.prop])
} }
} }
that.$set(that, "loading", false)
}, function (error) { }, function (error) {
this.$message(error.statusText || " 未知错误!"); this.$message(error.statusText || " 未知错误!");
that.$set(that, "loading", false)
}); });
} }
}, },
......
Vue.http.interceptors.push(function (request, next, a) { Vue.http.interceptors.push(function (request, next, a) {
if (request.control != "select") {
this.$root.loadCount = (this.$root.loadCount || 0) + 1; this.$root.loadCount = (this.$root.loadCount || 0) + 1;
if (this.$root.loading != true) { if (this.$root.loading != true) {
//打开loading //打开loading
Vue.set(this.$root, "loading", true); Vue.set(this.$root, "loading", true);
} }
}
next(function (response) { next(function (response) {
if (request.control != "select") {
//调用完一个接口就进行-1 //调用完一个接口就进行-1
this.$root.loadCount--; this.$root.loadCount--;
//当接口都调用完时关闭loading //当接口都调用完时关闭loading
...@@ -14,5 +17,6 @@ ...@@ -14,5 +17,6 @@
Vue.set(this.$root, "loading", false); Vue.set(this.$root, "loading", false);
} }
} }
}
}) })
}); });
\ No newline at end of file
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