Commit e7c62d23 by jianshuqin

优化:组件功能

parent 94e2bd0d
......@@ -30,7 +30,7 @@ namespace Bailun.DC.Models.Component.Enum
}
/// <summary>
/// 列名类型:1:Api,2:Sql,3:数据库表或视图,4:动态SQL,5:储存过程
/// 列名类型:1:Api,2:Sql,3:数据库表或视图,4:动态SQL,5:储存过程,6:储存过程名称
/// </summary>
public enum DataTypeEnum
{
......@@ -63,5 +63,11 @@ namespace Bailun.DC.Models.Component.Enum
/// </summary>
[Description("储存过程")]
ExecuteSql = 5,
/// <summary>
/// 储存过程名称
/// </summary>
[Description("储存过程名称")]
ExecuteName = 6
}
}
......@@ -164,7 +164,7 @@
type="success"
icon="el-icon-plus"
v-bind:size="item.size || 'small'"
v-on:click="setArrayValue({})">
v-on:click="setArrayValue({sortable: true})">
{{"新增"}}
</el-button>
<el-table-control ref="table"
......
<el-form ref="form-filter" label-width="auto" size="medium" class="el-form-filter">
<el-form ref="form-filter" label-width="auto" size="medium" class="el-form-filter" v-bind:model="filter" v-bind:show-message="false" v-on:validate="onValidate">
<el-row v-bind:gutter="10">
<el-col v-if="filter.listFilterControl && filter.listFilterControl.length" v-bind:span="item.colSpan || 24" v-bind:class="{'auto-width': item.colSpan == null || item.colSpan == 'auto'}" v-for="(item,index) in filter.listFilterControl" v-bind:key="index">
<el-form-item v-bind:label="item.name" v-if="item.type">
<el-form-item v-if="item.type"
v-bind:label="item.name"
v-bind:prop="'listFilterControl.' + index + '.value'"
v-bind:rules="item.rules || (item.required ? { required: true, message: item.message || ('请输入' + item.name)} : null)">
<el-form-control v-bind:item="item" v-model="item.value"></el-form-control>
</el-form-item>
</el-col>
......
......@@ -47,7 +47,7 @@
class="el-table-column-search"
v-bind:slot="setting.isShowColumnSearch ? 'header' : ''" slot-scope="scope">
</div>
<el-table-column v-if="setting.listOperateColumnControl && setting.listOperateColumnControl.length > 0"
<el-table-column v-if="setting.isShowColumnSearch"
header-align="center"
v-bind:label="setting.operateColumnName || '操作'"
v-bind:show-overflow-tooltip="setting.showTooltip"
......
......@@ -6,7 +6,7 @@
},
data: function () {
return {
formValidate: null
}
},
methods: {
......@@ -92,6 +92,19 @@
}
return listFilter;
},
//获取验证错误信息
getValidateMessage: function () {
return (this.formValidate || []).filter(function (l) { return !l.valid }).map(function (l) { return l.message });
},
//验证
validate: function () {
var that = this;
var isvalid = false;
that.$refs['form-filter'].validate(function (valid) {
isvalid = valid
})
return isvalid;
},
//查询
onSearch: function () {
this.$emit("search", this.getFilter());
......@@ -112,6 +125,20 @@
onClick: function (fn) {
this.$emit("click", fn);
},
//验证事件
onValidate: function (field, valid, message) {
var that = this;
if (!that.formValidate) {
that.formValidate = []
}
var index = that.formValidate.findIndex(function (l) { return l.field == field });
if (index >= 0) {
that.formValidate[index].valid = valid;
that.formValidate[index].message = message;
} else {
this.formValidate.push({ field: field, valid: valid, message: message });
}
}
},
mounted: function () {
this.onInitValue();
......
......@@ -93,14 +93,21 @@
onSearch: function (listFilter, firstPage) {
var that = this;
//设置当前第一页
if (firstPage == null || firstPage == true) {
Vue.set(that.filterParams, 'currentPage', 1);
if (that.$refs.formFilter.validate()) {
if (firstPage == null || firstPage == true) {
Vue.set(that.filterParams, 'currentPage', 1);
}
Vue.set(that.filterParams, 'code', that.code);
//获取过虑条件
this.getFilter(listFilter);
//查询
that.$refs.table.onSearch();
} else {
var message = that.$refs.formFilter.getValidateMessage();
if (message && message.length) {
that.$message({ dangerouslyUseHTMLString: true, message: message.join("<br/>") });
}
}
Vue.set(that.filterParams, 'code', that.code);
//获取过虑条件
this.getFilter(listFilter);
//查询
that.$refs.table.onSearch();
},
//重置
onReset: function (listFilter) {
......@@ -130,31 +137,38 @@
onExport: function () {
var that = this;
//异步请求
that.$http.post("/Component/Table/Export", that.filterParams, { emulateJSON: true }, {
responseType: 'arraybuffer',
headers: {
'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8'
}
}).then(function (respons) {
if (respons.bodyBlob.type == "application/json") {
that.$message(respons.body.message || " 未知错误!");
} else {
if (respons.headers && respons.headers.map && respons.headers.map["content-disposition"] && respons.headers.map["content-disposition"].length > 0) {
var exportName = null;
var fileInfo = respons.headers.map["content-disposition"][0].split(';');
if (fileInfo.length > 2) {
exportName = decodeURI(fileInfo[2].replace(" filename*=UTF-8''", ""));
} else if (fileInfo.length > 1) {
exportName = fileInfo[1].replace(" filename=", "");
} else {
exportName = (that.setting.listCrumb && that.setting.listCrumb.length > 0 ? that.setting.listCrumb.join("") : ('Export')) + "_" + (new Date().format("yyyyMMddhhmm")) + "xls";
if (that.$refs.formFilter.validate()) {
that.$http.post("/Component/Table/Export", that.filterParams, { emulateJSON: true }, {
responseType: 'arraybuffer',
headers: {
'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8'
}
}).then(function (respons) {
if (respons.bodyBlob.type == "application/json") {
that.$message(respons.body.message || " 未知错误!");
} else {
if (respons.headers && respons.headers.map && respons.headers.map["content-disposition"] && respons.headers.map["content-disposition"].length > 0) {
var exportName = null;
var fileInfo = respons.headers.map["content-disposition"][0].split(';');
if (fileInfo.length > 2) {
exportName = decodeURI(fileInfo[2].replace(" filename*=UTF-8''", ""));
} else if (fileInfo.length > 1) {
exportName = fileInfo[1].replace(" filename=", "");
} else {
exportName = (that.setting.listCrumb && that.setting.listCrumb.length > 0 ? that.setting.listCrumb.join("") : ('Export')) + "_" + (new Date().format("yyyyMMddhhmm")) + "xls";
}
saveAs(respons.bodyBlob, exportName);
}
saveAs(respons.bodyBlob, exportName);
}
}).catch(function (error) {
that.$message(error.message || " 未知错误!");
});
} else {
var message = that.$refs.formFilter.getValidateMessage();
if (message && message.length) {
that.$message({ dangerouslyUseHTMLString: true, message: message.join("<br/>") });
}
}).catch(function (error) {
that.$message(error.message || " 未知错误!");
});
}
},
//单击事件
onClick: function (fn) {
......
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