Commit e7c62d23 by jianshuqin

优化:组件功能

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