/** * 主题库分类所需属性集页面 * @author weidy * @date 2022-01-24 */ layui.define(['layer','element','form','table','dynamicCondition' ],function(exports){ var webUtil = $webUtil; var Class = function(){ this.MODELNAME = "mdm/CodeClassifyAttribute"; this.moduleKey = "CodeClassifyAttribute"; this.backPath = configData.compatibility? path:configData.mdmService; this.url = { controller:'codeClassifyAttrController/', dataGrid:'gridCodeClassifyAttribute', addSave:'addSave', editSave:'editSave', deleteUrl:'deleteData', getObjectByOid:'getObjectByOid' }; this.getContent=function(){ var that = this; var html = ""; html = [ '
', '
', '
', that.getToolbarHtml(), '
', '
', '
', '
' ].join(""); return html; }; this.getToolbarHtml =function(){ var that = this; var html = [ '
', '', '', '', '', '', '
' ].join(""); return html; }; this.createSearchHtml = function () { var that = this; webUtil.bindDefultButtonLisenter(that, 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); that.initMainTable(); that.createSearchHtml(); }; this.initMainTable = function (parentFieldName) { var that = this; var table = layui.table; that.checkColumns(); var tableWidth = $("#border_" + that.id).width()-225; var options = { elem: '#table_' + that.id, id: 'table_' + that.id, backPath:that.backPath, url: that.url.controller + that.url.dataGrid, page: { limit: 20, page: 1 }, width:tableWidth, 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; } }; if(parentFieldName){ options.treeConfig = { treepid:parentFieldName, treeid:'id', showField:'name' }; } 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(), { title: '主题库分类主键', field: 'codeclassifyoidName', sort:true, sortField:'codeclassifyoid', type:'refer', referConfig: { referBo:'codeclassify' }, width: 150 }, { field:'options', title:'操作', templet:function(d){ return '编辑'; } }]; } }; this.getFormItems = function(onlyShow) { var that = this; var table = layui.table; return [ { field: 'codeclassifyoid', title: '主题库分类主键', required: true, type: 'refer', showField: 'codeclassifyoidName', referConfig: { referBo:'codeclassify' }, 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:['保存','取消'], skin:'layui-layer-lan', content:'
', resizing:function(layero){ form.doResize(filter); }, success:function(layero) { form.addItems(filter,that.getFormItems(false), function () { if(!add){ form.load(filter,{ backPath:that.backPath, url:that.url.controller + that.url.getObjectByOid, method:'get', params:{ oid:oid } }); }else{ var defaultValues = {}; //可以手动在此处添加默认值 form.setValues(defaultValues,filter); } }, {}, {defaultColumnOneRow: 2}); }, yes:function(layero){ if(form.validata(filter)){ var values = form.getValues(filter,true); var url = that.url.controller + (add?that.url.addSave:that.url.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.controller + that.url.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.checkReferColumns=function (){ var that = this; var table = layui.table; if (that.tempAttrColumns == null || that.tempAttrColumns.length == 0) { that.tempAttrColumns = [table.getIndexColumn(), table.getRadioColumn(), { field: 'id', title: '属性英文编号', sort: true, width: 100 }, { field: 'name', title: '属性中文名称', sort: true, width: 130 },{ title: '属性分组', field: 'attributegroup', sort: true, width: 90 },{ title: '类型', field: 'attributeDataTypeText', sort: true, width: 60 },{ title: '列表宽度', field: 'attrTableWidth', width: 80 }, { title: '关键属性', field: 'keyattrflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.keyattrflag) } }, { title: '查询属性', field: 'queryattrflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.queryattrflag) } }, { title: '高级查询属性', field: 'seniorqueryattrflag', width: 85, templet: function (d) { return webUtil.formateBoolean(d.seniorqueryattrflag) } }, { title: '相似查重属性', field: 'samerepeatattrflag', width: 85, templet: function (d) { return webUtil.formateBoolean(d.samerepeatattrflag) } }, { title: '一维码', field: 'barcodeflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.barcodeflag) } }, { title: '二维码', field: 'qrcodeflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.qrcodeflag) } }, { title: '必输', field: 'requireflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.requireflag) } }, { title: '表单显示', field: 'formdisplayflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.formdisplayflag) } }, { title: '列表显示', field: 'tabledisplayflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.tabledisplayflag) } }, { title: '只读', field: 'readonlyflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.readonlyflag) } }, { title: '列表排序', field: 'sortattrflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.sortattrflag) } }, { title: '多行文本', field: 'textareaflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.textareaflag) } }, { title: '预览图', field: 'imageflag', width: 65, templet: function (d) { return webUtil.formateBoolean(d.imageflag); } }, { title: '默认值', field: 'defaultvalue', sort: true, width: 150 }, { title: '前缀', field: 'prefixvalue', sort: true, width: 80 }, { title: '后缀', field: 'suffixvalue', sort: true, width: 80 }, { title: '组合规则', field: 'componentrule', sort: true, width: 180 }, { title: '验证规则', field: 'verifyrule', sort: true, width: 150 }, { title: '时间格式', field: 'codedateformat', sort: true, width: 150 }, { title: '分类注入(层级/名称)', field: 'classifyinvokelevel', width: 200, templet: function (d) { if(d.classifyinvokeattr){ var value='注入类型:'+d.classifyinvokeattr+';'; if(d.classifyinvokeattr=='id'){ value+='注入类型名称:分类代号;' }else{ value+='注入类型名称:分类名称;' } value+='层级设置:'+d.classifyinvokelevel+';'; value+='是否可修改:'+webUtil.formateBoolean(d.classifyinvokeeditflag); return value; }else{ return '' } } }, { title: '枚举注入', field: 'enumString', width: 150 }, { title: '上级属性', field: 'parentTempAttr', width: 150 }, { title: '参照配置', field: 'referConfig', width: 150 }, { title: '填写提示', field: 'prompt', width: 150 }, { title: '表单显示样式', field: 'formdisplaystyle', width: 150 }, { title: '表格显示样式', field: 'tabledisplaystyle', width: 150 }, { title: '表单超链接', field: 'formhref', width: 150 }, { title: '表格超链接', field: 'tablehref', width: 150 }, { title: '表格显示js', field: 'tabledisplayjs', width: 150 }, { title: '长度', field: 'controllength', width: 60 }, { title: '小数精度(刻度)', field: 'precisionlength', width: 100 }, { title: '取值范围', field: 'valuearea', sort: true, width: 150 }]; } } this.showReferDialog=function (options){ var that=this; if(!options){ options={} } if(options.id){ that.id=options.id } var target = options.target; var table = layui.table; that.checkReferColumns() var filter = "tempAttr_" + that.id; var html=[ '
', '
', '
' ] var dialogIndex = webUtil.dialog({ title: '选择级联属性', btn: ['确定', '清空内容','取消'], content: html.join(''), area:['1000px','500px'], resizing: function (layero) { form.doResize(filter); }, success: function (layero, layerIndex, classP) { table.render({ elem: '#table_' + filter, id: 'table_' + filter, url:'codeClassifyTempAttrController/gridCodeClassifyTemplateAttr', backPath: that.backPath, limit:-1, extraParams:{ "conditionMap['classifyTemplateOid']": options.formValues.classifytemplateoid, "conditionMap['oid']": '!='+options.formValues.oid }, cols: [that.tempAttrColumns] }); }, yes: function (layero) { var datas = table.checkStatus('table_' + filter,true).data; if(datas.length!=1){ webUtil.showErrorMsg("请选择1条级联属性数据"); return false; } options.formValues['parentCode']=datas[0].id; options.formValues['parentName']=datas[0].name; target.setValue(options.filter,options.name,'',options.formValues,true); layer.close(dialogIndex); }, btn2: function (layero) { options.formValues['parentCode']=''; options.formValues['parentName']=''; target.setValue(options.filter,options.name,'',options.formValues,true); layer.close(dialogIndex); }, btn3: function (layero) { layer.close(dialogIndex); } }); } 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('
'); 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(); }; }; var cs = new Class(); exports(cs.MODELNAME,cs); });