/** * 主数据引擎 * @author weidy * @date 2022-2-23 */ layui.define(['layer','element','form','table','dynamicCondition' ,'tree','transfer','mdm/MdmEngineForm'],function(exports){ var webUtil = $webUtil; var Class = function(){ this.MODELNAME = "mdm/MdmEngine"; this.moduleKey = "MdmEngine"; this.backPath = configData.compatibility? path:configData.mdmService; this.url = { classifyController: 'codeClassifyController/', classifyTree:'referTree', controller:'mdmEngineController/', tableUI:'getUIInfoByClassifyOid', formUI:'getFormDefineByTemplateOid', tableData:'gridTableDataByClassifyOid', getDataByOid:'getDataByOid', export:'exportCode', downloadImportExcel:'downloadImportExcel', downloadImportExcelHistory:'downloadImportExcelHistory', batchImportCode:'batchImportCode', importHistoryData:'batchImportHistoryData', processTemplateController:'codeClsProcessTempController/', listProcessTemplate:'listProcessTemplate' }; this.getContent = function (){ var that = this; return '
'; }; this.showContent=function(){ var html = ""; var that = this; html = [ '
', '
', '
', '
      ', '
', '
', '
', '
', '
', '
', that.getToolbarHtml(), '
', '
', '
', '
', '
', '
', '
', '
', '
', '
', '
', '', '', '
刷新
' ].join(""); $("#UIContent_" + that.id).html(html); }; this.getWestToolbarHtml = function(){ var that = this; var html = [ '
', '' ]; html.push('
'); return html.join(""); }; this.createWestSearchHtml = function () { var that = this; webUtil.bindDefultButtonLisenter(that,"west_" + that.id); }; this.getToolbarHtml =function(){ var that = this; var html = [ '
', '
']; return html.join(''); }; this.createSearchHtml = function (queryColumns) { var that = this; var queryD = {}; layui.each(queryColumns,function (i,item){ var type = item.fieldType || item.type || "text"; if(type == 'text'){ queryD[(item.queryField||item.field)]=item.title } }) //要移除以前的 var toolbarDiv =$("[layui-filter='toolbar_" + that.id + "']"); var search = toolbarDiv.find("select[name='fast_search_select']"); if(search && search.length>0){ var div = $(search[0]).parent(); div.next().remove(); div.remove(); } webUtil.createSearchHtml(queryD ,toolbarDiv, "table_" + that.id); }; this.buttonIconMap = { CODEADD:'layui-icon-add-1', CODEBATCHADD:'layui-icon-list', CODEEDIT:'layui-icon-edit', CODEDELETE:'layui-icon-delete', CODEIMPORTHISTORY:'layui-icon-up', CODEEXPORT:'layui-icon-export', CODESTARTPROCESS:'layui-icon-read', CODEQUERY:'layui-icon-search', UPLOADFILE:'layui-icon-upload-circle', DOWNLOADFILE:'layui-icon-download-circle', revisefile:'layui-icon-edit', DELETEFILE:'layui-icon-delete', refreshTable:'layui-icon-refresh', refreshAttachTable:'layui-icon-refresh' }; this.config={} this.init = function(){ var that = this; webUtil.copyConfig(that,that.moduleKey); this.config[that.id] = { executeJsMap:{}, sourceData:that.sourceData }; that.MdmEngineForm = layui['mdm/MdmEngineForm']; setTimeout(function () { that.showContent(); var easyuiLayout = $('#easyuiLayout_' + that.id) easyuiLayout.css({height: $('#portal_body').height() - 43, width: $('#portal_body').width() - 15}) $('#easyuiLayoutCenter_'+that.id).layout(); easyuiLayout.layout(); that.initTree(); that.createWestSearchHtml(); $('#refresh_tree_' + that.id).click(function (){ var id=$(this).attr('id').replace('refresh_tree_','') that.refresh(id); }); that.initAttachTable(that.id) },1); }; this.initTree = function () { var that = this; var tree = layui.tree; var scrollHeight = window.innerHeight; var treeUL = $('[layui-filter="tree_' + that.id + '"]'); var treeHeight = scrollHeight - 160; treeUL.parent().height(treeHeight); var rootParams = {}; if(that.config[that.id].sourceData){ for(var key in that.config[that.id].sourceData){ rootParams["conditionMap['" + key + "']"] = that.config[that.id].sourceData[key]; } } tree.init("tree_" + that.id, treeUL, { url: that.url.classifyController + that.url.classifyTree, backPath: that.backPath, extraParams: { isMuti: false, isQueryAllColumn: true }, rootParams:rootParams, showSearch:true, click: function (item, elem, options) { that.config[options.rootParams["conditionMap['functionId']"]].currentItemOid = item.oid; that.config[options.rootParams["conditionMap['functionId']"]].currentItemAttributes = item.attributes; that.showTableByClassifyOid(item.oid,options.rootParams["conditionMap['functionId']"]); }, done:function (filter,children,elem) { var options=tree.getConfig(filter).options that.config[options.rootParams["conditionMap['functionId']"]].rootItemName= children[0].attributes.name; that.config[options.rootParams["conditionMap['functionId']"]].rootItemAttributes= children[0].attributes; } }); }; this.showTableByClassifyOid = function (codeClassifyOid,functionId){ var that = this; that.config[functionId].componentVO = null; webUtil.get(that.url.controller + that.url.tableUI,{codeClassifyOid:codeClassifyOid,functionId:functionId},function (result){ if(!result.success){ $webUtil.showAutoMsg(result.msg); that.config[functionId].componentVO = null; var table = layui.table; if(that.config[functionId].currentTableId){ table.destory(that.config[functionId].currentTableId); } $("[layui-filter='toolbar_" + functionId + "']").html(''); }else{ //显示表格和快速查询 that.showTableByDefine(result.obj,functionId); that.config[functionId].componentVO = result.obj; } }); }; this.showTableByDefine = function (componentVO,configId){ var that = this; var table = layui.table; if(that.config[configId].currentTableId){ table.destory(that.config[configId].currentTableId); } that.initButtonByComponent(componentVO,configId); //处理列表 var cols = []; var filter = 'table_' + configId; var eventMap = {}; for (var i = 0; i < componentVO.tableDefineVO.cols.length; i++) { if (i == 0) { componentVO.tableDefineVO.cols[i].unshift({ field: table.config.indexName, type: 'numbers', title: '序号', rowspan: componentVO.tableDefineVO.cols.length, width: 40 }, { field: table.config.checkName, type: 'checkbox', rowspan: componentVO.tableDefineVO.cols.length, width: 30 }) } //每个字段都需要扫描一下是否有事件 for (var j = 0; j < componentVO.tableDefineVO.cols[i].length; j++) { var record = componentVO.tableDefineVO.cols[i][j]; if(record.optionJsMap){ for(var key in record.optionJsMap){ eventMap[key] = record.optionJsMap[key]; } } if(record.field == 'id' && $webUtil.isNull(record.templet)){ //企业编码的默认添加超链接 record.templet = '
{{d.id}}
'; }else { if (record.templet && typeof (record.templet) == 'string' && $webUtil.isNotNull(record.templet) && record.templet.indexOf("function(d)")>-1) { record.templet = eval("(" + record.templet + ")"); } } } cols.push(componentVO.tableDefineVO.cols[i]); } //找分页的数量 var centerHeight = $("#border_" + configId).height()-100; var limit = (centerHeight-centerHeight%28)/28; var tableParams={ templateOid:componentVO.templateVO.oid, codeClassifyOid: that.config[configId].currentItemOid, queryTemplate:that.config[configId].sourceData['queryTemplate'] } that.config[configId].currentTableLoad = false; that.config[configId].componentVO = componentVO; table.render({ elem: '#' + filter, id: filter, url:that.url.controller + that.url.tableData, backPath: that.backPath, page: { limit: limit, page: 1 }, limits: limit, where: tableParams, selectMode: table.selectMode.muti, cols: cols, done: function (res, cur, total) { table.on('tool(' + filter + ')', function (obj) { var data = obj.data;//当前选择行的数据 var layEvent = obj.event;//点的是什么按钮 if (layEvent == 'VIEWDETAIL') { that.MdmEngineForm.VIEWDETAIL(data.oid,data.codetemplateoid,that.config[configId].currentItemOid); } else { if (layEvent in eventMap) { that.callEvent(eventMap[layEvent], data); } } }); that.config[configId].currentTableId = filter; }, rowClick: function (tablefifter, record, options) { table.reload("table_attach_" + configId, { extraParams: { ownbizOid: record.oid, ownbizBtm: record.btmname } }) } }); if (componentVO.tableDefineVO.queryColumns && componentVO.tableDefineVO.queryColumns.length > 0) { that.createSearchHtml(componentVO.tableDefineVO.queryColumns) } }; this.initButtonByComponent = function (componentVO,configId){ var that = this; var toolbar = $("[layui-filter='toolbar_" + configId + "']"); var toolbarSouth=$("[layui-filter='toolbar_south_" + configId + "']"); toolbarSouth.empty(); var buttons= toolbar.find('button'); if(buttons){ layui.each(buttons,function (_index,_item){ _item.remove(); }); } var buttonInfos = componentVO.buttons; if(!buttonInfos){ buttonInfos = []; } buttonInfos.push({ uniqueFlag: 'refreshTable', alias: '刷新' }); var buttonHtml = []; that.config[configId].executeJsMap = {}; layui.each(buttonInfos,function (_index,_item) { var filter = _item.uniqueFlag; if ($webUtil.endWith(filter, "VIEW")){ return; } if ($webUtil.endWith(filter, "CODEQUERY") || $webUtil.endWith(filter, "refreshTable") || $webUtil.endWith(filter, "CODEIMPORTHISTORY") || $webUtil.endWith(filter, "CODEEXPORT") || componentVO.leaf) { if($webUtil.isNotNull(_item.iconCls)){ that.buttonIconMap[_item.uniqueFlag] = _item.iconCls; } if($webUtil.endWith(filter, "FILE") || $webUtil.endWith(filter, "file")){ toolbarSouth.append($webUtil.getButtonHtmlFromBtnObject(_item, configId, that.buttonIconMap)); }else { buttonHtml.push($webUtil.getButtonHtmlFromBtnObject(_item, configId, that.buttonIconMap)); } } }); $(buttonHtml.join('')).prependTo(toolbar) toolbarSouth.append($webUtil.getButtonHtmlFromBtnObject({ uniqueFlag: 'refreshAttachTable', alias: '刷新' }, configId, that.buttonIconMap)); webUtil.bindDefultButtonLisenter(that, configId); webUtil.bindDefultButtonLisenter(that, 'south_'+configId); }; this.initAttachTable=function (configId){ var that = this; var table=layui.table; var cols=[table.getIndexColumn(), table.getCheckColumn(),{ field: 'name', title: '名称', width: 260, templet: function (d) { return ''+d.name+''; } },{ field: 'fileSize', title: '文件大小', width: 100 },{ field: 'creator', title: '创建者', width: 100 },{ field: 'createTime', title: '创建时间', width: 200 }] table.render({ elem: '#table_attach_' + configId, id: 'table_attach_'+configId, url:'vciFileQueryController/gridFiles', backPath: that.backPath, page: { limit: 10, page: 1 }, extraParams: { ownbizOid:'1', ownbizBtm: '1', fileDocClassify:'!=processAuditSuggest' }, selectMode: table.selectMode.muti, cols: [cols], done: function (res, cur, total) { table.on('tool(table_attach_' + configId + ')', function (obj) { var data = obj.data;//当前选择行的数据 var layEvent = obj.event;//点的是什么按钮 if (layEvent == 'VIEWFILE') { that.VIEWFILE(data,configId); } }); } }); } this.refresh = function (configId) { var that=this; var tree = layui.tree; tree.reload("tree_" + configId,{rootNodeLoaded:false}); }; this.refreshTable = function (type,button){ var that = this; var configId=$(button).attr('layui-filter').split('_')[1] layui.table.reload('table_' + configId); }; this.refreshAttachTable = function (type,button){ var that = this; var configId=$(button).attr('layui-filter').split('_')[1] layui.table.reload('table_attach_' + configId); }; this.checkComponentVO = function (configId){ var that = this; if(!that.config[configId].componentVO || that.config[configId].componentVO == null){ $webUtil.showErrorMsg("请先选择主题库分类,并且保证分类有关联的模板"); return false; } return true; }; this.CODEQUERY = function (type,button) { var that = this; var configId=$(button).attr('layui-filter').split('_')[1] if(!that.checkComponentVO(configId)){ return false; } if(!that.config[configId].serinorQueryInstance && that.config[configId].componentVO.tableDefineVO.seniorQueryColumns) { var dynamicCondition = layui.dynamicCondition; $('[layui-filter="toolbar_' + configId + '"]').append('
'); that.config[configId].serinorQueryInstance = dynamicCondition.create({ fields: that.config[configId].componentVO.tableDefineVO.seniorQueryColumns//查询字段 , tableId: "table_" + configId//需要查询的表格 , type: "complex" //type:"simple"/"complex" 查询的方法 暂时写死为 complex , queryCallBack: function (requestData) {//查询之后的callback } }); } that.config[configId].serinorQueryInstance.open(); }; this.callEvent = function (jsPath,data){ var that = this; if(jsPath && data){ if($webUtil.startWith(jsPath.toLowerCase(),"usejs:")||$webUtil.startWith(jsPath.toLowerCase(),"js:")){ //是执行js if($webUtil.startWith(jsPath.toLowerCase(),"usejs:")){ jsPath = jsPath.substr(6); }else { jsPath = jsPath.substr(3); } layui.use(jsPath,function (){ layui[jsPath].doEvent(data,that); }); }else if($webUtil.startWith(jsPath.toLowerCase(),"https://") || $webUtil.startWith(jsPath.toLowerCase(),"http://")){ var tabId = (data.oid || jsPath) + "_link"; portal.showTabByMenu(data.oid || jsPath,{ id:data.oid || jsPath, text:'查看链接', url:jsPath }); }else if(that[jsPath]){ that[jsPath](data); }else{ //直接是js的暂时还不支持 } } }; this.CODEADD = function (type,button){ var that = this; var configId=$(button).attr('layui-filter').split('_')[1] that.codeAddOrEdit(button,configId,true); }; this.codeAddOrEdit = function (button,configId,add,oid,up){ var that = this; if(!that.checkComponentVO(configId)){ return false; } that.MdmEngineForm.getFormDefine(that.config[configId].componentVO.templateVO.oid,that.config[configId].currentItemOid,function (componentVO){ var formDefineVO= componentVO.formDefineVO; if(formDefineVO) { var filter = (oid||configId) + "_add_form"; var form = layui.form; var colCount = that.MdmEngineForm.getFormCol(formDefineVO); var items = that.MdmEngineForm.getFormItemsByVO(formDefineVO, false,colCount,add); var html = [ '
', '
', '
', '
', '
', '
', '
    ', '
  • 码值申请
  • ', '
  • 相似项查询
  • ', '
', '
    ', '
  • ', '
    ', '
  • ', '
  • ', '
    ', '
  • ', '
', '
', '
', '
' ] var hasResemble = (componentVO.resembleTableVO && componentVO.resembleTableVO.cols && componentVO.resembleTableVO.cols.length > 0); var dialogIndex = webUtil.dialog({ title: (add ? "编码申请" : (up?"数据更改":'修改编码信息')), btn: !hasResemble?['保存', '取消']:['保存', '取消', '相似项查询'], fullScreen: true, content: html.join(''), resizing: function (layero) { form.doResize(filter); }, success: function (layero) { var easyuiLayout = $('#easyuiLayout_' + filter) easyuiLayout.css({height: easyuiLayout.parents('.layui-layer-content').height()-10, width: easyuiLayout.parents('.layui-layer-content').width()-10}) easyuiLayout.parent().parent().css({padding: '5px'}) easyuiLayout.layout(); that.MdmEngineForm.initResembleTable(componentVO,filter); form.addItems(filter, items, function () { //只传递了数据的主键,所以我们需要从后台获取一下 if (!add) { form.load(filter, { backPath: that.backPath, url: that.url.controller + that.url.getDataByOid, method: 'get', params: { oid: oid, templateOid: that.config[configId].componentVO.templateVO.oid } }); } if(add){ webUtil.get(that.url.controller + 'getCodeRuleByClassifyOid', {codeClassifyOid: that.config[configId].currentItemOid}, function (result) { if (!result.success) { $webUtil.showErrorMsg(result.msg); } else { that.config[configId].codeRuleOid=result.obj.oid; var codeValueItems=that.MdmEngineForm.getCodeValueItems(result.obj.secVOList,'form_codevlaue_'+filter); if(codeValueItems.length==0 && !hasResemble){ easyuiLayout.layout('remove','south'); return; } if(codeValueItems.length == 0 && hasResemble){ //隐藏当前的选项卡 layui.element.tabDelete("tab_" + filter, "codeorder"); return; } var height=Math.ceil(codeValueItems.length/colCount)*53+70; if(hasResemble && height<270){ height =270; } var top=easyuiLayout.height()-height-5; $('#border_'+ filter).height(height-5).parent().css({top:top+'px'}).prev().find('.layout-body').height(top-12); form.addItems('form_codevlaue_'+filter, codeValueItems,function (){}, {}, {defaultColumnOneRow: colCount, labelWidth: 160}); } }); }else{ if(!hasResemble){ easyuiLayout.layout('remove','south'); return; }else{ //隐藏码值申请选项卡 layui.element.tabDelete("tab_" + filter, "codeorder"); return; } } }, {}, {defaultColumnOneRow: colCount, labelWidth: 160}); }, yes: function (layero) { if (form.validata(filter) && form.validata("form_codevlaue_" + filter)) { var values = form.getDefaultValues(filter, true); if(up){ values.defaultValues['copyfromversion'] = values.defaultValues.oid; values.defaultValues.oid = ''; } var codevalues = form.getValues("form_codevlaue_" + filter, true); var secDTOList=[]; layui.each(codevalues,function (i,item){ secDTOList.push({secOid:i,secValue:item}) }) var datas = { codeClassifyOid:that.config[configId].currentItemOid, templateOid:that.config[configId].componentVO.templateVO.oid, codeRuleOid:that.config[configId].codeRuleOid, data: values.otherValue, secDTOList:secDTOList } $.extend(datas, values.defaultValues); webUtil.manualAjax((add||up)?'post':'put', that.url.controller+(add?'addSaveCode':(up?'upSaveCode':'editSaveCode')), JSON.stringify(datas), function (result) { if (result.success) { webUtil.showMsgFromResult(result, (add?"添加成功":(up?'数据更改成功':"修改成功"))); layer.close(dialogIndex); that.refreshTable(null,button) } else { webUtil.showErrorMsg(result.msg); } }, function (xhr, err) { webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); }, that.backPath); } }, btn3:function (layero){ if(form.validata(filter)){ var values = form.getDefaultValues(filter, true); if(up){ values.defaultValues['copyfromversion'] = values.defaultValues.oid; values.defaultValues.oid = ''; } var datas = { codeClassifyOid:that.config[configId].currentItemOid, templateOid:that.config[configId].componentVO.templateVO.oid, codeRuleOid:that.config[configId].codeRuleOid, data: values.otherValue } $.extend(datas, values.defaultValues); webUtil.manualAjax('post', that.url.controller+'resembleQuery', JSON.stringify(datas), function (result) { if (result.success) { layui.table.reload("resemble_" + filter, { data: result.data }); layui.element.tabChange("tab_" + filter, 'resemble'); } else { webUtil.showErrorMsg(result.msg); } }, function (xhr, err) { webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); }, that.backPath); } return false; }, btn2: function (layero) { layer.close(dialogIndex); } }); } }); }; this.CODEEDIT=function (type,button){ var that = this; var configId=$(button).attr('layui-filter').split('_')[1] var oid = webUtil.getOidFromGrid('table_' + configId,true,true); if(!oid){ return; } var lcStatus = webUtil.getOidFromGrid('table_' + configId,true,true,'lcstatus'); if (lcStatus != 'Editing') { webUtil.showErrorMsg('编码状态不是“编辑中”,不可编辑'); return false; } that.codeAddOrEdit(button,configId,false,oid,null); } this.CODEDELETE=function (type,button){ var that = this; var configId=$(button).attr('layui-filter').split('_')[1] if(!that.checkComponentVO(configId)){ return false; } var oid = webUtil.getOidFromGrid('table_' + configId,true,false); if(!oid){ return false; } webUtil.showConfirmMsg("是否删除选中数据?",function () { var submitData = { oidList:oid.split(","), codeClassifyOid:that.config[configId].currentItemOid } webUtil.manualAjax("delete",that.url.controller + 'deleteCode',JSON.stringify(submitData),function(result){ if(result.success){ webUtil.showMsgFromResult(result,"删除成功"); that.refreshTable(null,button); }else{ webUtil.showErrorMsg(result.msg); } },function(xhr,err){ webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); },that.backPath); }); } this.CODEEXPORT = function (type,button){ //导出 var that = this; var configId=$(button).attr('layui-filter').split('_')[1] var form=layui.form; var filter = "codeexport_" + configId; var content =['
', '
', '
', '
', '', '', '
', '
']; var dialogndex = $webUtil.dialog({ title: '数据导出属性选择窗口', btn: ['确定', '取消'], content: content.join(''), area: ['800px', '670px'], success: function (layero) { form.addItems(filter, [{ field: 'type', title: '导出方式', textWidth: 275, textStyle: 'margin-bottom: 5px;', type: 'radio', comboxKey: 'type', data: [{key: 'check', value: '选择    '}, {key: 'all', value: '全部    '}, {key: 'page', value: '页码'}] }], function () { form.on('radio(type)', function (data) { var parentDiv = data.othis.parents('.layui-form-item'); if (this.value != 'page') { parentDiv.find('.layui-form-mid').remove(); } else { if (parentDiv.find('.layui-form-mid').length == 0) { var inputDiv = $('
(输入页码或者页面范围,如:1-10)
'); inputDiv.appendTo(parentDiv); } } }); }, {}, {}); var datas=[]; for (var i = 0; i < that.config[configId].componentVO.templateVO.attributes.length; i++) { if(that.config[configId].componentVO.templateVO.attributes[i].formdisplayflag=='true' || that.config[configId].componentVO.templateVO.attributes[i].tabledisplayflag=='true'){ datas.push(that.config[configId].componentVO.templateVO.attributes[i]) } } layui.transfer.render({ elem: '#transfer_'+filter ,data: datas ,width:310 ,height:500 ,id:'transfer_'+filter//索引 ,parseData: function(res){ return { "value": res.id //数据值 ,"title": res.name//数据标题 } } ,title: ['未选属性', '已选属性'] ,showSearch: true ,done:function (d,laybox) { laybox.eq(1).on('click', 'input[lay-filter="layTransferCheckbox"]+', function () { var checkbox = laybox.eq(1).find('input[name="layTransferLeftCheck"]:checked'); if (checkbox.length > 0) { $('.toolbar_' + filter + '_UPSELECT').removeAttr('disabled').removeClass('layui-btn-disabled') $('.toolbar_' + filter + '_DOWNSELECT').removeAttr('disabled').removeClass('layui-btn-disabled') } else { $('.toolbar_' + filter + '_UPSELECT').attr('disabled', 'disabled').addClass('layui-btn-disabled') $('.toolbar_' + filter + '_DOWNSELECT').attr('disabled', 'disabled').addClass('layui-btn-disabled') } }) $('.toolbar_' + filter + '_UPSELECT').click(function () { var checkbox = laybox.eq(1).find('input[name="layTransferLeftCheck"]:checked'); if (checkbox.length > 1) { $webUtil.showErrorMsg("请选择一条需要移动的数据"); return; } var index=checkbox.eq(0).parent().index() index!=0 && layui.transfer.moveData('transfer_' + filter,1,index,index-1); }) $('.toolbar_' + filter + '_DOWNSELECT').click(function () { var data = layui.transfer.getData('transfer_' + filter); var checkbox = laybox.eq(1).find('input[name="layTransferLeftCheck"]:checked'); if (checkbox.length > 1) { $webUtil.showErrorMsg("请选择一条需要移动的数据"); return; } var index=checkbox.eq(0).parent().index() index!=data.length-1 && layui.transfer.moveData('transfer_' + filter,1,index,index+1); }) } }) }, yes: function (layero) { var data={ codeClassifyOid:that.config[configId].currentItemOid } var getData = layui.transfer.getData('transfer_'+filter); $.each(getData,function (i,item){ data['attrIdIndexMap["' + i + '"]']=item.value }) var requestData={}; var queryValue = $('[layui-filter="toolbar_' + configId + '"] input[name="fast_search_select_value"]').val(); var queryKey = $('[layui-filter="toolbar_' + configId + '"] select[name="fast_search_select"]').val(); if($webUtil.isNotNull(queryKey)){ requestData['conditionMap["' + queryKey + '"]'] = ($webUtil.isNull(queryValue)?"":("*" + queryValue + "*")); var lastQueryKeyInput = $('[layui-filter="toolbar_' + configId + '"] input[name="fast_search_select_value"]').next(); var lastQueryKey =lastQueryKeyInput.val(); if($webUtil.isNotNull(lastQueryKey) && lastQueryKey != queryKey){ requestData['conditionMap["' + lastQueryKey + '"]'] = ""; } } if(that.config[configId].serinorQueryInstance && that.config[configId].serinorQueryInstance.requestData){ $.extend(requestData,that.config[configId].serinorQueryInstance.requestData); } $.each(requestData,function (i,item){ data[i]=item }) var type = form.getValues(filter, true).type; if(type=='check'){ var selectData = layui.table.checkStatus("table_" +configId).data; if(selectData.length == 0){ $webUtil.showErrorMsg("请选择要导出的数据"); return false; } var oids=[]; layui.each(selectData,function (i,item){ oids.push(item.oid); }); data['conditionMap["oid"]']=oids.join(',') }else if (type=='page'){ data.limit=$("div.layui-table-view[lay-id='table_" +configId+"'] .layui-laypage-limits select").val(); var exportPage=$('input[name="exportPage"]').val(); if(webUtil.isNull(exportPage)){ $webUtil.showErrorMsg("请选择要导出的页码"); return false; } if(exportPage.indexOf('-')!=-1){ if(!/^[1-9]\d*$/.test(exportPage.split('-')[0]) || !/^[1-9]\d*$/.test(exportPage.split('-')[1])){ $webUtil.showErrorMsg("请输入正确的页面范围"); return false; } data.page=exportPage.split('-')[0]; data.endPage=exportPage.split('-')[1]; }else { if(!/^[1-9]\d*$/.test(exportPage)){ $webUtil.showErrorMsg("请输入正确的页码"); return false; } data.page=exportPage; data.endPage=exportPage; } }else{ data.limit=-1; } $webUtil.fileDownloadPost(that.backPath + that.url.controller + that.url.export, data,function (){ layer.close(dialogndex);}); }, btn2: function (layero) { layer.close(dialogndex); } }) }; this.CODEBATCHADD = function (type,button) { // 先把模板下载下来 var that = this; var configId=$(button).attr('layui-filter').split('_')[1] var filter = "batchAdd" + configId; var form = layui.form; var content = ['
' + '
', '' ].join(''); var addSaveIndex = $webUtil.dialog({ title: '批量申请编码', btn: ['下载导入模板', '关闭'], content: content, area: ['800px', '600px'], success: function (layero) { //添加编码规则的字段 webUtil.get(that.url.controller + 'getCodeRuleByClassifyOid', {codeClassifyOid: that.config[configId].currentItemOid}, function (result) { if (!result.success) { $webUtil.showErrorMsg(result.msg); } else { var items = [{ type:'line', field:'tips', text:'导入提示' },{ field: 'keyAttrTips', text:'1.标题带五角星的表示关键属性,带星号表示必输项', type: 'label', labelWidth:475, labelStyle:'margin-left:50px', useAllWidth:true },{ field: 'requiredTips', text:'2.请一定先选择/输入编码规则的码段值后再选择excel文件', type: 'label', labelWidth:475, labelStyle:'margin-left:50px', useAllWidth:true },{ field: 'totalTooltips', text:'3.每次仅能最多导入10000条数据,如果出错会返回错误的数据和原因,但是正确的数据会保存', type: 'label', labelWidth:475, labelStyle:'margin-left:50px', useAllWidth:true }, { field: 'classifyTips', text: '4.如果属性为参照,在参照配置中设置多个属性时,优先使用name属性的值,否则填写第一个属性的值。', type: 'label', labelWidth: 600, labelStyle: 'margin-left:50px', useAllWidth: true },{ type:'line', field:'codeValues', text:'编码规则的码段信息,请先选择后再导入' }]; var codeValueItems=that.MdmEngineForm.getCodeValueItems(result.obj.secVOList); //我们把提示的信息也加进去 if(codeValueItems){ layui.each(codeValueItems,function (_index,_item){ items.push(_item); }); } items.push({ type:'line', field:'excelFile', text:'excel文件,选择文件后会自动上传' }) form.addItems(filter, items,function (){}, {}, {defaultColumnOneRow: that.MdmEngineForm.getFormCol({items:[], labelWidth: 160}), labelWidth: 160}); var upload = layui.upload; //执行实例 var uploadInst = upload.render({ elem: '#upload_button_' + filter //绑定元素 ,accept:'file' ,acceptMime:'file/*' ,exts:'xls|xlsx' ,url: that.backPath+ that.url.controller + that.url.batchImportCode//上传接口 ,auto:true ,before:function(obj){ if(!form.validata(filter)){ return false; } var values = form.getValues(filter, true); var secDTOList=[]; layui.each(values,function (i,item){ secDTOList.push({secOid:i,secValue:item}) }) values['secDTOList'] = JSON.stringify(secDTOList); values['codeClassifyOid'] = that.config[configId].currentItemOid; obj.setData(values); return true; } ,done: function(result){//不需要输入内容,因此没有before if(result.success){ layer.close(addSaveIndex); $webUtil.showMsgFromResult(result,"批量申请成功!"); that.refreshTable(null,button); }else{ //需要去下载错误信息 $webUtil.fileDownload(that.backPath + that.url.controller + "downloadErrorFile?uuid=" + result.obj,null,'导入错误,请查看下载的【错误信息】文件'); } } ,error: function(){ //请求异常回调 $webUtil.showErrorMsg("上传异常,服务端出错了"); } }); } }); }, yes: function (layero) { $webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadImportExcel + "?codeClassifyOid=" + that.config[configId].currentItemOid); }, btn2: function (layero) { layer.close(addSaveIndex); } }); }; this.CODEIMPORTHISTORY = function (type,button){ // 先把模板下载下来 var that = this; var configId=$(button).attr('layui-filter').split('_')[1] var filter = "history" + configId; var form = layui.form; var content = ['
' + '
', '' ].join(''); var addSaveIndex = $webUtil.dialog({ title: '历史数据导入', btn: ['下载导入模板', '关闭'], content: content, area: ['800px', '600px'], success: function (layero) { //历史数据不导规则 var items = [{ type: 'line', field: 'tips', text: '导入提示' }, { field: 'keyAttrTips', text: '1.标题带五角星的表示关键属性,带星号表示必输项', type: 'label', labelWidth: 600, labelStyle: 'margin-left:50px', useAllWidth: true }, { field: 'requiredTips', text: '2.企业编码,集团码和状态都需要导入', type: 'label', labelWidth: 600, labelStyle: 'margin-left:50px', useAllWidth: true },{ field: 'requiredTips', text:'3.每次仅能最多导入10000条数据,如果出错会返回错误的数据和原因,但是正确的数据会保存', type: 'label', labelWidth:600, labelStyle:'margin-left:50px', useAllWidth:true }, { field: 'classifyTips', text: '4.分类的路径需要用#分隔。仅填写当前选的分类树上的下级分类的路径,如果当前分类已经是叶子节点,则不填写', type: 'label', labelWidth: 600, labelStyle: 'margin-left:50px', useAllWidth: true },{ field: 'classifyAttr', title: '分类的路径使用的属性', textWidth: 350, labelWidth: 200, textStyle: 'margin-bottom: 15px;', type: 'radio', comboxKey: 'classifyAttr', data: [{key: 'id', value: '分类编号'}, {key: 'name', value: '分类名称'}] }, { type: 'line', field: 'excelFile', text: 'excel文件,选择文件后会自动上传' }]; form.addItems(filter, items, function () { }, {}, {defaultColumnOneRow: that.MdmEngineForm.getFormCol({items: [], labelWidth: 160}), labelWidth: 160}); var upload = layui.upload; //执行实例 var uploadInst = upload.render({ elem: '#upload_button_' + filter //绑定元素 , accept: 'file' , acceptMime: 'file/*' , exts: 'xls|xlsx' , url: that.backPath + that.url.controller + that.url.importHistoryData//上传接口 , auto: true , before: function (obj) { if (!form.validata(filter)) { return false; } var values = form.getValues(filter, true); values['codeClassifyOid'] = that.config[configId].currentItemOid; obj.setData(values); return true; } , done: function (result) {//不需要输入内容,因此没有before if (result.success) { layer.close(addSaveIndex); $webUtil.showMsgFromResult(result, "导入历史数据成功!"); that.refreshTable(null,button); }else{ //需要去下载错误信息 $webUtil.fileDownload(that.backPath + that.url.controller + "downloadErrorFile?uuid=" + result.obj,null,'导入错误,请查看下载的【错误信息】文件'); } } , error: function () { //请求异常回调 $webUtil.showErrorMsg("上传异常,服务端出错了"); } }); }, yes: function (layero) { $webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadImportExcelHistory + "?codeClassifyOid=" + that.config[configId].currentItemOid); }, btn2: function (layero) { layer.close(addSaveIndex); } }); }; this.CODESTARTPROCESS = function (type,button){ var configId=$(button).attr('layui-filter').split('_')[1] var options = { processUse:'code_cls_flow_use_order', processUseText:'申请', allowStatus:'Editing', allowStatusText:'已编辑', startStatus:'Auditing', resetStatus:'Editing', batchTitle:'批量提交编码数据到流程审批', title:'提交编码数据到流程审批' } var that = this; that.checkStatusAndSubmitProcess(options,'Released',configId,button); }; this.CODEDISABLE = function (type,button){ var configId=$(button).attr('layui-filter').split('_')[1] var options = { processUse:'code_cls_flow_use_freeze', processUseText:'停用', allowStatus:'Released', allowStatusText:'已发布', resetStatus:'Released', batchTitle:'批量停用(冻结)的编码数据', title:'停用(冻结)编码数据', confirmMsg:'是否要停用这些数据', } var that = this; that.checkStatusAndSubmitProcess(options,'Disabled',configId,button); }; this.CODERECYCLE = function (type,button){ var configId=$(button).attr('layui-filter').split('_')[1] var options = { processUse:'code_cls_flow_use_delete', processUseText:'回收', allowStatus:'Released,Disabled', allowStatusText:'已发布,已停用', batchTitle:'批量回收的编码数据', title:'回收编码数据', confirmMsg:'是否要回收这些数据', } var that = this; that.checkStatusAndSubmitProcess(options,'TakeBack',configId,button); }; this.CODEENABLE = function (type,button){ var configId=$(button).attr('layui-filter').split('_')[1] var options = { processUse:'code_cls_flow_use_unfreeze', processUseText:'启用', allowStatus:'Disabled', allowStatusText:'已停用', resetStatus:'Disabled', batchTitle:'批量启用(解冻)的编码数据', title:'启用(解冻)编码数据', confirmMsg:'是否要启用(解冻)这些数据', } var that = this; that.checkStatusAndSubmitProcess(options,'Released',configId,button); }; this.CODEUPREVISION = function (type,button){ //升版 var that = this; var configId=$(button).attr('layui-filter').split('_')[1] var oid = webUtil.getOidFromGrid('table_' + configId,true,true); if(!oid){ return; } var lcstatus = webUtil.getOidFromGrid('table_' + configId,false,false,'lcstatus'); if(lcstatus != 'Released'){ $webUtil.showErrorMsg('只有状态为已发布的数据才能进行数据更改'); return false; } that.codeAddOrEdit(button,configId,false,oid,true); }; this.checkStatusAndSubmitProcess = function (options,targetLcstatus,configId,button){ var that = this; if(!that.checkComponentVO(configId)){ return false; } var oids = $webUtil.getOidFromGrid("table_" + configId,true,false); if(!oids){ return false; } var selectData = layui.table.checkStatus("table_" + configId).data; if(selectData.length > 1000){ $webUtil.showErrorMsg("每次提交到流程的数量请不要超过1000条"); return false; } //审批的数据的状态必须相同 var lcstatus = selectData[0].lcstatus; var same = true; layui.each(selectData,function (_index,_item){ if(_item.lcstatus != lcstatus){ same =false; return true; } }); if(!same){ $webUtil.showErrorMsg("您选择的数据的状态不相同"); return false; } var sameStatus = false; layui.each(selectData,function (_index,_item){ if(_item.lcstatus== targetLcstatus){ sameStatus =true; return true; } }); if(sameStatus){ $webUtil.showErrorMsg("选择的数据中状态无需再执行当前操作"); return false; } if(options.processUseText=='申请' && webUtil.isNotNull(selectData[0].copyfromversion)){ options.processUseText='修改' options.processUse='code_cls_flow_use_modify' } //去后台获取模板 $webUtil.get(that.url.processTemplateController + that.url.listProcessTemplate,{codeTemplateOid:that.config[configId].componentVO.templateVO.oid,processUse:options.processUse},function (result){ if(!result.success || !result.data || result.data.length == 0){ that.changeStatus(targetLcstatus,oids,selectData[0].btmname,configId); return false; }else{ var canUseTemplate = []; layui.each(result.data,function (_index,_item){ canUseTemplate.push(_item.id); }); //$webUtil.showConfirmMsg(options.confirmMsg || "是否将这些数据提交审批?",function (r){ //if(r){ layui.use(["process/vciWebStartProcess"], function () { var startProcess = layui['process/vciWebStartProcess']; startProcess.init(); startProcess.showStartWindow(that.config[configId].componentVO.templateVO.btmTypeId, selectData, { title: ((selectData.length>1?options.batchTitle:options.title) || '流程审批'), checkAllowAttributeValues:options.allowStatus, allowAttributesMsg:'只有状态是【' + options.allowStatusText + '】的数据才可以发起流程', startStatus: options.startStatus, resetStatus: (options.allowStatus.indexOf(",")>-1?lcstatus:options.resetStatus), isMutiProcess:false, canUseTemplate:canUseTemplate.join(","), variablesInfo:{ codeClassifyOid:that.config[configId].currentItemOid, processUse:options.processUse }, processName:webUtil.getSystemVar(webUtil.sessionInfoKey.userName)+'-'+options.processUseText+'['+that.config[configId].rootItemName+'-'+selectData[0].name+']', detailUrl:"USEJS:mdm/MdmEngineInProcess#", }, function (result) { that.refreshTable(null,button); }); }); //} //}); } },function (error,xhr){ $webUtil.showErrorMsg("获取可用的流程模板出错,可能是服务没有启动,可以一会再试") },that.backPath); } this.VIEWFILE=function (rowData,configId){ //文件预览 layui.use('BaseFileDownloadAction', function () { var vciWebFilePreview = layui['BaseFileDownloadAction']; vciWebFilePreview.PREVIEW(rowData.oid,{fileOid:rowData.oid},function (){ $webUtil.showErrorMsg("文件预览失败,请联系管理员") }) }) } this.UPLOADFILE=function (type,button){ var that=this; var configId=$(button).attr('layui-filter').split('_')[1] layui.use('BaseFileUploadAction', function () { var BaseAction = layui['BaseFileUploadAction']; var viewid = 'uploadfile_' + configId; var callback = function () { that.refreshAttachTable(null,button) } var sourceData = layui.table.checkStatus("table_" + configId).data; if(sourceData.length!=1){ $webUtil.showErrorMsg("请选择一条分类数据") return; } var dataStore = layui.table.checkStatus("table_attach_" + configId).data; BaseAction['doAction']({ paramVOS: { title: "上传附件列表", type: "fileobject" }, id: viewid, dataStore: dataStore, sourceData: sourceData[0], callback: callback }); }) } this.DOWNLOADFILE=function (type,button){ var that=this; var configId=$(button).attr('layui-filter').split('_')[1] layui.use('BaseFileDownloadAction', function () { var BaseAction = layui['BaseFileDownloadAction']; var viewid = 'downloadfile_' + configId; var callback = function () { that.refreshAttachTable(null,button) } var sourceData = layui.table.checkStatus("table_" + configId).data; var dataStore = layui.table.checkStatus("table_attach_" + configId).data; BaseAction['doAction']({ paramVOS: { title: "下载附件列表", type: "fileobject" }, id: viewid, dataStore: dataStore, sourceData: sourceData[0], callback: callback }); }) } this.revisefile=function (type,button){ var that=this; var configId=$(button).attr('layui-filter').split('_')[1] layui.use('BaseFileUploadAction', function () { var BaseAction = layui['BaseFileUploadAction']; var viewid = 'uploadfile_' + configId; var callback = function () { that.refreshAttachTable(null,button) } var sourceData = layui.table.checkStatus("table_" + configId).data; if(sourceData.length!=1){ $webUtil.showErrorMsg("请选择一条分类数据") return; } var dataStore = layui.table.checkStatus("table_attach_" + configId).data; if(dataStore.length!=1){ $webUtil.showErrorMsg("请选择一条需要修改的数据") return; } BaseAction['doAction']({ paramVOS: { title: "修改附件列表", type: "fileobject", updatefileflag:'true' }, id: viewid, dataStore: dataStore, sourceData: sourceData[0], callback: callback }); }) } this.DELETEFILE=function (type,button){ var that=this; var configId=$(button).attr('layui-filter').split('_')[1] layui.use('BaseDeleteAction', function () { var BaseAction = layui['BaseDeleteAction']; var viewid = 'uploadfile_' +configId; var callback = function () { that.refreshAttachTable(null,button) } var sourceData = layui.table.checkStatus("table_" + configId).data; var dataStore = layui.table.checkStatus("table_attach_" + configId).data; BaseAction['doAction']({ paramVOS: { owner: "true", title: "删除附件列表", type: "fileobject", multi:true }, id: viewid, dataStore: dataStore, sourceData: sourceData[0], callback: callback }); }) }; this.changeStatus = function (lcstatus,oids,btmname,configId){ var that = this; $webUtil.showConfirmMsg("当前分类没有添加流程模板,是否不用流程审批直接执行",function (r) { if (r) { $webUtil.post(that.url.controller + "/changeStatus", { oid: oids, btmname: btmname, lcStatus: lcstatus }, function (result) { if (result.success) { $webUtil.showMsgFromResult(result, "执行成功"); layui.table.reload('table_' + configId); } else { $webUtil.showErrorMsg(result.msg); } }, function (error, xhr) { $webUtil.showErrorMsg("链接有误,可以一会再试"); }, that.backPath); } }); } }; var cs = new Class(); exports(cs.MODELNAME,cs); });