/**
|
* 模板属性枚举注入
|
* @author wangting
|
* @date 2022-2-21
|
*/
|
layui.define(['layer','element','form','table','dynamicCondition'],function(exports){
|
var webUtil = $webUtil;
|
var Class = function(){
|
this.MODELNAME = "mdm/CodeClassifyEnumUse";
|
this.moduleKey = "CodeClassifyEnumUse";
|
this.id = "CodeClassifyEnumUse";
|
this.backPath = configData.compatibility? path:configData.mdmService;
|
this.url = {
|
controller:'codeClassifyController/'
|
};
|
this.getContent=function(){
|
var that = this;
|
var filter = "enumuse_" + that.id;
|
var html=[
|
'<div style="margin: 5px">',
|
'<button class="layui-btn layui-btn-sm toolbar_',filter,'_add"> 添加 </button>',
|
'<button class="layui-btn layui-btn-sm toolbar_',filter,'_del"> 删除 </button>',
|
'<table class="layui-table" lay-size="sm" lay-filter="table_' + filter + '" id="table_' + filter + '" ></table>',
|
'</div>'
|
]
|
return html.join('');
|
};
|
this.init=function(){
|
};
|
|
this.showReferDialog=function (options){
|
var that=this;
|
if(!options){
|
options={}
|
}
|
if(options.id){
|
that.id=options.id
|
}
|
that.fristButtonLoad=false;
|
var target = options.target;
|
var table = layui.table;
|
var filter = "enumuse_" + that.id;
|
var tableData=[];
|
if(webUtil.isNotNull(options.value)){
|
tableData=JSON.parse(options.value)
|
}else if(options.formValues && options.formValues.enumFlag) {
|
$.each(options.formValues.enumItemMap, function (i, item) {
|
tableData.push({key: i, value: item})
|
})
|
}
|
|
var classifyuseIndex = webUtil.dialog({
|
title: '枚举注入',
|
btn: ['保存', '取消'],
|
content: that.getContent(),
|
area:['600px','450px'],
|
resizing: function (layero) {
|
},
|
success: function (layero, layerIndex, classP) {
|
table.render({
|
elem: '#table_' + filter,
|
id: 'table_' + filter,
|
limit: -1,
|
cols: [[table.getIndexColumn(),table.getCheckColumn(),{
|
field: 'key',
|
title: '选项值',
|
edit:'text',
|
width: 150
|
}, {
|
field: 'value',
|
title: '选项中文标签',
|
edit:'text',
|
width: 240
|
}, {
|
field: 'options',
|
title: '操作',
|
width: 80,
|
templet: function (d) {
|
return '<a class="layui-btn layui-btn-intable" lay-event="REM">移除</a>';
|
}
|
}]],
|
data: tableData,
|
done: function (res, cur, total) {
|
if (!that.fristButtonLoad) {
|
table.on('tool(table_' + filter + ')', function (obj) {
|
var data = obj.data;//当前选择行的数据
|
var layEvent = obj.event;//点的是什么按钮
|
if (layEvent == 'REM') {
|
table.removeData('table_' + filter, data);
|
}
|
});
|
}
|
that.fristButtonLoad = true;
|
}
|
});
|
$('.toolbar_'+filter+'_add').click(function (){
|
table.addData('table_' + filter, {key:'',value:''});
|
})
|
$('.toolbar_'+filter+'_del').click(function (){
|
var checkData = layui.table.checkStatus("table_" + filter).data;
|
layui.each(checkData,function (i,item){
|
table.removeData('table_' + filter, item);
|
})
|
})
|
},
|
yes: function (layero) {
|
var datas = table.getData('table_' + filter,true);
|
for (var i=0;i<datas.length;i++){
|
if(webUtil.isNull(datas[i].key)){
|
webUtil.showErrorMsg("请输入选项值");
|
return false;
|
}
|
if(webUtil.isNull(datas[i].value)){
|
webUtil.showErrorMsg("请输入选项中文标签");
|
return false;
|
}
|
}
|
var values=''
|
if(datas.length>0){
|
values=JSON.stringify(datas);
|
}
|
target.setValue(options.filter,options.name,values,values,true);
|
layer.close(classifyuseIndex);
|
},
|
btn2: function (layero) {
|
layer.close(classifyuseIndex);
|
}
|
});
|
}
|
this.refresh = function (buttonid,ele) {
|
};
|
this.ADVQUERY = function () {
|
var that = this;
|
};
|
};
|
var cs = new Class();
|
exports(cs.MODELNAME,cs);
|
});
|