/** * 系统集成基础信息页面 * @author lihang * @date 2022-03-07 */ layui.define(['layer', 'element', 'form', 'table', 'dynamicCondition'], function (exports) { var webUtil = $webUtil; var Class = function () { this.MODELNAME = "mdm/SysIntInfo"; this.moduleKey = "SysIntInfo"; this.backPath = configData.compatibility ? path : configData.mdmService; this.url = { controller: 'sysIntInfo/', dataGrid: 'gridSysIntInfo', addSave: 'addSave', editSave: 'editSave', deleteUrl: 'deleteData', getObjectByOid: 'getObjectByOid', authorityController: 'sysIntAuthority/', authorityDataGrid: 'gridSysIntAuthority' }; this.getContent = function () { var that = this; return '
'; }; this.showContent = function () { var that = this; var html = ""; html = [ '
', '
', '
', that.getToolbarHtml(), '
', '
', '
', '
' ].join(""); $("#UIContent_" + that.id).html(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); //需要加在定时中,否则样式不能正确展示,不知道原因 wangting 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(); }, 1) }; this.initMainTable = function (parentFieldName) { var that = this; var table = layui.table; that.checkColumns(); //var tableWidth = $("#border_" + that.id).width(); 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); } }); } 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: 'sourceSysName', sort: true, width: 150 }, { title: '来源系统标识', field: 'sourceSysId', sort: true, width: 150 }, { title: '目标系统名称', field: 'targetSysName', sort: true, width: 150 }, { title: '目标系统标识', field: 'targetSysId', sort: true, width: 150 }, { title: '接口类型', field: 'interfacetypeText', sort: true, sortField: 'interfacetype', type: 'combox', comboxKey: "sysIntegrationRequestType", width: 150 }, { title: '接口函数', field: 'interfaceFunction', sort: true, width: 150 }, { title: '请求地址', field: 'requesturl', sort: true, width: 150 }, { title: '请求方式', field: 'requestmethodText', sort: true, sortField: 'requestmethod', type: 'combox', comboxKey: "sysIntegrationRequestMethodType", width: 150 }, { title: '参数类型', field: 'paramtypeText', sort: true, sortField: 'paramtype', type: 'combox', comboxKey: "sysIntegrationParamAndReturnType", width: 150 }, { title: '返回值类型', field: 'returntypeText', sort: true, sortField: 'returntype', type: 'combox', comboxKey: "sysIntegrationParamAndReturnType", width: 150 }, { title: '认证方式', field: 'authorityTypeText', sort: true, sortField: 'authorityType', width: 150 },{ title: '数据流向方式', field: 'dataFlowTypeText', sort: true, sortField: 'dataFlowType', width: 90 }, { field: 'options', title: '操作', width: 150, templet: function (d) { return '编辑'; } }]; } }; this.getFormItems = function (onlyShow) { var that = this; var filter = this.filter; var table = layui.table; return [ { field: 'authorityoid', title: '认证方式', required: true, type: 'refer', showField: 'authorityType', referConfig: { type: 'grid', width: 680, isMuti: false, tableConfig: { page: { limit: 15, page: 1 }, cols: [layui.table.getIndexColumn(), layui.table.getCheckColumn(), { field: 'typeText', title: '认证方式', sort: true, width: 150 }, { field: 'useraccount', title: '验证用户', sort: true, width: 150 }, { field: 'usercode', title: '验证密码', width: 250 }, { field: 'token', title: '令牌', width: 250 }], queryColumns: [ { field: 'useraccount', title: '验证用户' }, { field: 'token', title: '令牌' } ] }, backPath: that.backPath, url: 'sysIntAuthority/gridSysIntAuthority', textField: 'typeText', valueFiled: 'oid' }, defaultValue: "", readOnly: onlyShow }, { field: 'interfacetype', title: '接口类型', type: 'combox', comboxKey: 'sysIntegrationRequestType', defaultValue: "", readOnly: onlyShow }, { field: 'paramtype', title: '参数类型', required: true, type: 'combox', comboxKey: 'sysIntegrationParamAndReturnType', defaultValue: "", readOnly: onlyShow }, { field: 'returntype', title: '返回值类型', required: true, type: 'combox', comboxKey: 'sysIntegrationParamAndReturnType', defaultValue: "", readOnly: onlyShow }, { field: 'sourcesystemoid', title: '来源系统', required: true, type: 'refer', showField: 'sourceSysName', referConfig: { type: 'default', referBo: 'sysintbase', textField: 'name', valueFiled: 'oid' }, defaultValue: "", readOnly: onlyShow }, { field: 'targetsystemoid', title: '目标系统', required: true, type: 'refer', showField: 'targetSysName', referConfig: { type: 'default', referBo: 'sysintbase', textField: 'name', valueFiled: 'oid' }, defaultValue: "", readOnly: onlyShow },{ field: 'dataFlowTypeText', title: '数据流向方式', type: 'combox', comboxKey: 'sysIntegrationDataFlowType', defaultValue: "", readOnly: onlyShow }, { field: 'description', title: '系统描述', type: 'textarea', inputWidth: 475 } ]; }; this.getFormSecItems = function (type, onlyShow, isHidden) { if (type == 'http') { return [ { field: 'requestmethod', title: '请求方式', type: 'combox', comboxKey: 'sysIntegrationRequestMethodType', defaultValue: "", required: true, readOnly: onlyShow }, { field: 'requesturl', title: '请求地址', type: 'text', defaultValue: "", required: true, readOnly: onlyShow }, ] } else if (type == 'webService') { return [ { field: 'interfaceFunction', title: '接口函数', type: 'text', defaultValue: "", required: true, readOnly: onlyShow },] } else if (type == 'classPath') { return [ { field: 'classPath', title: '类路径', type: 'text', defaultValue: "", required: true, readOnly: onlyShow } ] } } this.ADD = function () { var that = this; that.addOrEdit(true); }; this.EDIT = function () { var that = this; var data = layui.table.checkStatus("table_" + that.id).data; if (data.length != 1) { webUtil.showErrorMsg('请选择一条数据'); return false; } console.log(data[0]); that.addOrEdit(false, data[0]); }; this.addOrEdit = function (add, infoData) { var that = this; var form = layui.form; var filter = "form_" + that.id; var addSaveIndex = webUtil.dialog({ title: add ? '添加系统集成基础信息' : '修改系统集成基础信息', btn: ['保存', '取消'], content: '
' + '
', resizing: function (layero) { form.doResize(filter); }, success: function (layero) { form.addItems(filter, that.getFormItems(false), function () { if (!add) { form.setValues(infoData); } else { var defaultValues = {}; //可以手动在此处添加默认值 form.setValues(defaultValues, filter); } that.sectype = 'webService'; var hidden = true; if (!add) { that.sectype = infoData.interfacetype; } form.addItems("sec_" + filter, that.getFormSecItems(that.sectype, false, hidden), function () { if (!add) { form.setValues(infoData, "sec_" + filter); } else { var defaultValues = {}; form.setValues(defaultValues, "sec_" + filter); } }, {}, {defaultColumnOneRow: 1}); form.on('select(interfacetype)', function (data) { var datatype = data.value; var isHidden = true; form.removeItems("sec_" + filter, [], true); form.addItems("sec_" + filter, that.getFormSecItems(datatype, false, isHidden), function () { form.setValues(data, "sec_" + filter); }) }); }, {}, {defaultColumnOneRow: 1}); }, yes: function (layero) { if (form.validata(filter)) { var values = form.getValues(filter, true); console.log(values); var secvalues = form.getValues("sec_" + filter, true); var newvalues = $.extend({}, values, secvalues); console.log(newvalues); var url = that.url.controller + (add ? that.url.addSave : that.url.editSave); webUtil.manualAjax(add ? 'post' : 'put', url, JSON.stringify(newvalues), 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.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); });