/**
|
* 集团码导入映射页面
|
* @author lihang
|
* @date 2022-03-10
|
*/
|
layui.define(['layer', 'element', 'form', 'table', 'dynamicCondition'], function (exports) {
|
var webUtil = $webUtil;
|
var Class = function () {
|
this.MODELNAME = "mdm/CodeGroupExportRule";
|
this.moduleKey = "CodeGroupExportRule";
|
this.backPath = configData.compatibility ? path : configData.mdmService;
|
this.url = {
|
map: {
|
controller: 'codeClassifyTempMapController/',
|
dataGrid: 'gridCodeClassifyTemplateMap',
|
addSave: 'addSave',
|
editSave: 'editSave',
|
deleteUrl: 'deleteData',
|
getObjectByOid: 'getObjectByOid',
|
listDataByOids: 'listDataByOids'
|
},
|
mapItem: {
|
controller: 'codeClsTempMapItemController/',
|
dataGrid: 'gridCodeClassifyTempMapItem',
|
addSave: 'addSave',
|
editSave: 'editSave',
|
deleteUrl: 'deleteData',
|
getObjectByOid: 'getObjectByOid',
|
listDataByOids: 'listDataByOids'
|
}
|
};
|
this.getContent = function () {
|
var that = this;
|
return '<div id="UIContent_' + that.id + '" style="overflow: auto;padding:0 5px"></div>';
|
};
|
this.showContent = function () {
|
var that = this;
|
var html = "";
|
html = [
|
'<div class="layui-layout easyui-layout UIContentLayout " id="easyuiLayout_', that.id, '" data-options="fit:true" style="display:block;overflow-y: hidden">',
|
'<div data-options="region:\'north\',split:true" title="映射规则" style="height:360px;display:block;margin-top:0px;padding:0 5px" id="border_', that.id, '">',
|
'<div style="">',
|
that.getToolbarHtml(),
|
'<table id="table_', that.id, '" lay-filter="', that.id, '" style="overflow-x:auto;"></table>',
|
'</div>',
|
'</div>',
|
'<div data-options="region:\'center\'" title="映射明细" style="display:block;margin-top:0px;padding:0 5px " >',
|
'<div style="overflow-y:auto;">',
|
that.getSecToolbarHtml(),
|
'<table id="sec_', that.id, '" lay-filter="sec_', that.id, '" style="overflow-x:auto;"></table>',
|
'</div>',
|
'</div>',
|
'</div>'
|
].join("");
|
$("#UIContent_" + that.id).html(html);
|
};
|
this.getToolbarHtml = function () {
|
var that = this;
|
var html = [
|
'<div layui-filter="toolbar_', that.id, '" class="layui-btn-container layui-buttons">',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_ADD"><i class="layui-icon layui-icon-add-1"></i>添加</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_EDIT"><i class="layui-icon layui-icon-edit"></i>修改</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_DEL"><i class="layui-icon layui-icon-delete"></i>删除</button>',
|
// '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_ENABLE"><i class="layui-icon layui-icon-ok-circle"></i>启用</button>',
|
// '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_DISABLE"><i class="layui-icon layui-icon-404"></i>停用</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_ADVQUERY"><i class="layui-icon layui-icon-search"></i>查询</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_', that.id, '_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.getSecToolbarHtml = function () {
|
var that = this;
|
var html = [
|
'<div layui-filter="toolbar_', that.id, '" class="layui-btn-container layui-buttons">',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_sec_', that.id, '_ADDSEC"><i class="layui-icon layui-icon-add-1"></i>添加</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_sec_', that.id, '_EDITSEC"><i class="layui-icon layui-icon-edit"></i>修改</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_sec_', that.id, '_DELSEC"><i class="layui-icon layui-icon-delete"></i>删除</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_sec_', that.id, '_refreshSEC"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_sec_', that.id, '_ADVQUERYSEC"><i class="layui-icon layui-icon-search"></i>查询</button>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.createSearchHtml = function () {
|
var that = this;
|
webUtil.bindDefultButtonLisenter(that, that.id);
|
webUtil.bindDefultButtonLisenter(that, "sec_" + that.id);
|
webUtil.createSearchHtml({
|
id: "编号",
|
name: "名称"
|
}, $("[layui-filter='toolbar_" + that.id + "']"), "table_" + that.id);
|
|
};
|
this.init = function () {
|
var that = this;
|
webUtil.copyConfig(that, that.moduleKey);
|
setTimeout(function () {
|
that.showContent();
|
var easyuiLayout = $('#easyuiLayout_' + that.id)
|
easyuiLayout.css({height: $('#portal_body').height() - 43, width: $('#portal_body').width() - 15})
|
easyuiLayout.layout();
|
|
that.initMainTable();
|
that.createSearchHtml();
|
that.initSecTable();
|
}, 1);
|
};
|
this.initMainTable = function (parentFieldName) {
|
var that = this;
|
var table = layui.table;
|
that.checkColumns();
|
var options = {
|
elem: '#table_' + that.id,
|
id: 'table_' + that.id,
|
backPath: that.backPath,
|
url: that.url.map.controller + that.url.map.dataGrid,
|
page: {
|
limit: 20,
|
page: 1
|
},
|
extraParams: {
|
"conditionMap['codeMapRuleType']": 'code_map_group_export'
|
},
|
selectMode: table.selectMode.muti,
|
cols: [that.columns],
|
method: 'get',
|
done: function (res, cur, total) {
|
if (!that.fristMainLoad) {
|
table.on('tool(' + that.id + ')', function (obj) {
|
var data = obj.data;//当前选择行的数据
|
var layEvent = obj.event;//点的是什么按钮
|
if (layEvent == 'EDIT') {
|
that.addOrEdit(false, data.oid);
|
}
|
});
|
} else {
|
if (total > 0) {
|
table.selectRecord('table_' + that.id, {index: 0});
|
}
|
}
|
that.fristMainLoad = true;
|
},
|
rowClick: function (thisTableFilter, record) {
|
table.reload("sec_" + that.id, {
|
extraParams: {
|
"conditionMap['classifyTemplateMapOid']": record.oid
|
}
|
});
|
}
|
};
|
if (parentFieldName) {
|
options.treeConfig = {
|
treepid: parentFieldName,
|
treeid: 'id',
|
showField: 'name'
|
};
|
}
|
table.render(options);
|
};
|
this.initSecTable = function () {
|
var that = this;
|
var table = layui.table;
|
that.checkSecColumns();
|
var tableWidth = $("#border_" + that.id).width();
|
var options = {
|
elem: '#sec_' + that.id,
|
id: 'sec_' + that.id,
|
backPath: that.backPath,
|
url: that.url.mapItem.controller + that.url.mapItem.dataGrid,
|
limit: -1,
|
width: tableWidth,
|
selectMode: table.selectMode.muti,
|
cols: [that.secColumns],
|
method: 'get',
|
done: function (res, cur, total) {
|
table.on('tool(sec_' + that.id + ')', function (obj) {
|
var data = obj.data;//当前选择行的数据
|
var layEvent = obj.event;//点的是什么按钮
|
if (layEvent == 'EDIT') {
|
that.addOrEditSec(false, data);
|
} else if (layEvent == 'UP') {
|
obj.index != 0 && layui.table.moveData('sec_' + that.id, obj.index, obj.index - 1)
|
} else if (layEvent == 'DOWN') {
|
obj.index != layui.table.getData('sec_' + that.id).length - 1 && layui.table.moveData(filter, obj.index, obj.index + 1)
|
} else if (layEvent == 'SECVALUE') {
|
that.SECVALUE(data)
|
}
|
});
|
}
|
};
|
table.render(options);
|
};
|
this.checkColumns = function () {
|
var that = this;
|
var table = layui.table;
|
if (that.columns == null || that.columns.length == 0) {
|
that.columns = [table.getIndexColumn(), table.getCheckColumn(), {
|
field: 'id',
|
title: '编号',
|
width: 150,
|
sort: true
|
}, {
|
field: 'name',
|
title: '名称',
|
width: 200,
|
sort: true
|
},{
|
field: 'classifyTemplateName',
|
title: '所属模板',
|
width: 160,
|
sort: true
|
}, {
|
field: 'description',
|
title: '描述',
|
width: 160,
|
sort: true
|
}, {
|
field: 'lcStatusText',
|
title: '状态',
|
width: 90,
|
sortField: 'lcstatus',
|
sort: true
|
},{
|
field: 'codemapruletypeText',
|
title: '映射类型',
|
width: 90
|
}, {
|
field: 'options',
|
title: '操作',
|
width: 80,
|
templet: function (d) {
|
return '<a class="layui-btn layui-btn-intable" lay-event="EDIT">编辑</a>';
|
}
|
}];
|
}
|
};
|
this.checkSecColumns = function () {
|
var that = this;
|
var table = layui.table;
|
if (that.secColumns == null || that.secColumns.length == 0) {
|
that.secColumns = [table.getIndexColumn(), table.getCheckColumn(),
|
{
|
field: 'groupcodeattrid',
|
title: '集团码属性key',
|
width: 200,
|
sort: true
|
}, {
|
field: 'groupcodeattrname',
|
title: '集团码属性key',
|
width: 200,
|
sort: true
|
}, {
|
field: 'classifyAttrId',
|
title: '分类模板属性key',
|
width: 200,
|
sort: true
|
}, {
|
field: 'classifyAttrName',
|
title: '分类模板属性名称',
|
width: 200,
|
sort: true
|
}, {
|
field: 'targetdateformat',
|
title: '时间格式',
|
width: 200,
|
sort: true
|
}, {
|
field: 'switcheval',
|
title: '转换公式',
|
width: 200,
|
sort: true
|
}, {
|
field: 'switchclassname',
|
title: '转换的自定义类',
|
width: 200,
|
sort: true
|
}, {
|
field: 'options',
|
title: '操作',
|
width: 150,
|
templet: function (d) {
|
if (d.sectype == 'codeclassifysec' || d.sectype == 'codefixedsec') {
|
return '<a class="layui-btn layui-btn-intable" lay-event="EDIT">编辑</a><a class="layui-btn layui-btn-intable" lay-event="SECVALUE">码值管理</a>';
|
} else {
|
return '<a class="layui-btn layui-btn-intable" lay-event="EDIT">编辑</a>';
|
}
|
|
}
|
}];
|
}
|
};
|
this.getFormItems = function (onlyShow) {
|
var that = this;
|
var table = layui.table;
|
return [
|
{
|
field: 'id',
|
title: '编号',
|
required: true
|
}, {
|
field: 'name',
|
title: '名称',
|
required: true
|
},{
|
field: 'classifyTemplateOid',
|
title: '所属模板',
|
width: 160,
|
type: 'refer',
|
showField:'classifyTemplateName',
|
referConfig: {
|
type:'mdm/refer/CodeClassTemplateRefer',
|
valueField: 'oid',
|
textField: 'name'
|
},
|
defaultValue: "",
|
readOnly: onlyShow
|
},
|
{
|
field: 'description',
|
title: '描述',
|
type: 'textarea',
|
inputWidth: 475
|
}
|
];
|
};
|
this.getSecFormItems = function (onlyShow,templateOid) {
|
var that = this;
|
var table = layui.table;
|
return [
|
{
|
field: 'classifytemplateattroid',
|
title: '分类模板属性',
|
required: true,
|
type: 'refer',
|
showField: 'classifyAttrName',
|
referConfig: {
|
type:'grid',
|
referBo:'codeclstempattr',
|
url: "codeClassifyTempAttrController/gridCodeClassifyTemplateAttr",
|
backPath:that.backPath,
|
textField:'name',
|
valueField:'oid',
|
extraParams:{
|
conditionMap:{classifyTemplateOid:templateOid}
|
},
|
isMuti:false,
|
tableConfig:{
|
page:{
|
limit:15,
|
page:1
|
},
|
cols:[table.getIndexColumn(),table.getCheckColumn(),{
|
field:'id',
|
title:'分类模板属性key',
|
},{
|
field:'name',
|
title:'分类模板属性名称',
|
}],
|
queryColumns:[{
|
field:'id',
|
title:'分类模板属性key'
|
}]
|
}
|
},
|
defaultValue:"",
|
readOnly:onlyShow
|
} , {
|
field: 'groupcodeattrid',
|
title: '集团码属性key',
|
type: 'text',
|
defaultValue:"",
|
required: true,
|
readOnly:onlyShow
|
} , {
|
field: 'groupcodeattrname',
|
title: '集团码属性名称',
|
type: 'text',
|
defaultValue:"",
|
required: true,
|
readOnly:onlyShow
|
} , {
|
field: 'switchclassname',
|
title: '转换的自定义类',
|
type: 'text',
|
defaultValue:"",
|
readOnly:onlyShow
|
} , {
|
field: 'switcheval',
|
title: '转换公式',
|
type: 'text',
|
defaultValue:"",
|
readOnly:onlyShow
|
} , {
|
field: 'targetdateformat',
|
title: '目标端的时间格式',
|
type: 'text',
|
defaultValue:"",
|
readOnly:onlyShow
|
} ];
|
};
|
this.ADD = function () {
|
var that = this;
|
that.addOrEdit(true);
|
};
|
this.EDIT = function () {
|
var that = this;
|
var oid = webUtil.getOidFromGrid("table_" + that.id, true, true);
|
if (!oid) {
|
return false;
|
}
|
that.addOrEdit(false, oid);
|
};
|
this.addOrEdit = function (add, oid) {
|
var that = this;
|
var form = layui.form;
|
var filter = "form_" + that.id;
|
var addSaveIndex = webUtil.dialog({
|
title: add ? "添加映射规则" : '修改映射规则',
|
btn: ['保存', '取消'],
|
content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
resizing: function (layero) {
|
form.doResize(filter);
|
},
|
success: function (layero, layerIndex, classP) {
|
form.addItems(filter, that.getFormItems(false),
|
function () {
|
if (add) {
|
var defaultValues = {};
|
//可以手动在此处添加默认值
|
form.setValues(defaultValues, filter);
|
} else {
|
form.load(filter, {
|
backPath: that.backPath,
|
url: that.url.map.controller + that.url.map.getObjectByOid,
|
method: 'get',
|
params: {
|
oid: oid
|
}
|
});
|
}
|
webUtil.relocationOpen(classP)
|
}, {}, {defaultColumnOneRow: 2});
|
},
|
yes: function (layero) {
|
if (form.validata(filter)) {
|
var values = form.getValues(filter, true);
|
if (!add){
|
values.oid = oid;
|
}else {
|
values.codeMapRuleType ='code_map_group_export';
|
}
|
var url = that.url.map.controller + (add ? that.url.map.addSave : that.url.map.editSave);
|
webUtil.manualAjax(add ? 'post' : 'put', url, JSON.stringify(values), function (result) {
|
if (result.success) {
|
webUtil.showMsgFromResult(result, (add ? "添加成功" : "修改成功"));
|
layer.close(addSaveIndex);
|
that.refresh();
|
} else {
|
webUtil.showErrorMsg(result.msg);
|
}
|
}, function (xhr, err) {
|
webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
|
}, that.backPath);
|
}
|
},
|
btn2: function (layero) {
|
layer.close(addSaveIndex);
|
}
|
});
|
};
|
this.DEL = function () {
|
var that = this;
|
var oid = webUtil.getOidFromGrid("table_" + that.id, true, true);
|
if (!oid) {
|
return false;
|
}
|
var ts = webUtil.getOidFromGrid("table_" + that.id, false, false, "ts");
|
webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!", function () {
|
webUtil.deleteRequest(that.url.map.controller + that.url.map.deleteUrl, {oid: oid, ts: ts}, function (result) {
|
if (result.success) {
|
webUtil.showMsgFromResult(result, "删除成功");
|
that.refresh();
|
} else {
|
webUtil.showErrorMsg(result.msg);
|
}
|
}, function (xhr, err) {
|
webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
|
}, that.backPath);
|
});
|
};
|
this.refresh = function () {
|
var that = this;
|
layui.table.reload("table_" + that.id);
|
};
|
this.ADVQUERY = function () {
|
var that = this;
|
if (!that.serinorQueryInstance) {
|
var dynamicCondition = layui.dynamicCondition;
|
$('[layui-filter="toolbar_' + that.id + '"]').append('<div id="toolbar' + that.id + '" class="layui-inline"></div>');
|
that.checkColumns();
|
var dataFields = [];
|
for (var i = 0; i < that.columns.length; i++) {
|
dataFields[i] = that.columns[i];
|
}
|
that.serinorQueryInstance = dynamicCondition.create({
|
fields: dataFields//查询字段
|
, tableId: "table_" + that.id//需要查询的表格
|
, type: "complex" //type:"simple"/"complex" 查询的方法 暂时写死为 complex
|
, queryCallBack: function (requestData) {//查询之后的callback
|
|
}
|
});
|
}
|
that.serinorQueryInstance.open();
|
};
|
this.ADDSEC = function () {
|
this.addOrEditSec(true)
|
};
|
this.EDITSEC = function () {
|
var that = this;
|
var secData = layui.table.checkStatus("sec_" + that.id).data;
|
if (secData.length != 1) {
|
webUtil.showErrorMsg('请选择一条映射明细数据');
|
return false;
|
}
|
this.addOrEditSec(false,secData[0])
|
};
|
this.DELSEC = function () {
|
var that = this;
|
var oid = webUtil.getOidFromGrid("sec_" + that.id, true, true);
|
if (!oid) {
|
return false;
|
}
|
var ts = webUtil.getOidFromGrid("sec_" + that.id, false, false, "ts");
|
webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!", function () {
|
webUtil.deleteRequest(that.url.mapItem.controller + that.url.mapItem.deleteUrl, {oid: oid, ts: ts}, function (result) {
|
if (result.success) {
|
webUtil.showMsgFromResult(result, "删除成功");
|
that.refresh();
|
} else {
|
webUtil.showErrorMsg(result.msg);
|
}
|
}, function (xhr, err) {
|
webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
|
}, that.backPath);
|
});
|
};
|
this.addOrEditSec = function (add,codeData) {
|
var that = this;
|
var checkData = layui.table.checkStatus("table_" + that.id).data;
|
if (checkData.length != 1) {
|
webUtil.showErrorMsg('请选择一条映射规则数据');
|
return false;
|
}
|
var oid=codeData?codeData.oid:'';
|
var templateOid = checkData[0].classifyTemplateOid? checkData[0].classifyTemplateOid : '';
|
var form = layui.form;
|
var filter = "form_" + that.id;
|
var addSaveIndex = webUtil.dialog({
|
title: add ? '添加映射明细' : '修改映射明细',
|
btn: ['保存', '取消'],
|
area:['500px','580px'],
|
content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
resizing: function (layero) {
|
form.doResize(filter);
|
},
|
success: function (layero, layerIndex, classP) {
|
form.addItems(filter, that.getSecFormItems(false,templateOid),
|
function () {
|
if (!add){
|
form.setValues(codeData)
|
}else {
|
var defaultValues = {};
|
form.setValues(defaultValues,filter);
|
}
|
}, {}, {defaultColumnOneRow: 1, labelWidth: 130});
|
|
},
|
yes: function (layero) {
|
if (form.validata(filter) && form.validata("sec_" + filter)) {
|
var values = form.getValues(filter, true);
|
console.log(values);
|
var secvalues = form.getValues("sec_" + filter, true);
|
console.log(secvalues);
|
var newvalues = $.extend({}, values, secvalues);
|
console.log(checkData[0].oid);
|
newvalues.classifytemplatemapoid = checkData[0].oid;
|
if (!add) {
|
newvalues.oid = codeData.oid;
|
}
|
var url = that.url.mapItem.controller + (add ? that.url.mapItem.addSave : that.url.mapItem.editSave);
|
webUtil.manualAjax(add ? 'post' : 'put', url, JSON.stringify(newvalues), function (result) {
|
if (result.success) {
|
webUtil.showMsgFromResult(result, (add ? "添加成功" : "修改成功"));
|
layer.close(addSaveIndex);
|
that.refreshSEC();
|
} else {
|
webUtil.showErrorMsg(result.msg);
|
}
|
}, function (xhr, err) {
|
webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
|
}, that.backPath);
|
}
|
},
|
btn2: function (layero) {
|
layer.close(addSaveIndex);
|
}
|
});
|
};
|
this.refreshSEC = function (){
|
var that = this;
|
layui.table.reload("sec_" + that.id);
|
}
|
};
|
var cs = new Class();
|
exports(cs.MODELNAME, cs);
|
});
|