util = window.top.util; FormatCenter = window.top.FormatCenter; Dictionary = window.top.Dictionary; Object.subClass = function(properties) { if (!properties) { return; } var clazz = properties.init; delete properties.init; if (!clazz) { clazz = new Function(); } prototyping = true; try { var prototype = new this(); } finally { prototyping = false; } for (var name in properties) { prototype[name] = properties[name]; } clazz.prototype = prototype; clazz.subClass = arguments.callee; return clazz; }; Config = Object.subClass({ init: function(config) { }, combine: function(obj, override) { if (!obj) { return; } override = (override == undefined) ? false : override; for (var name in obj) { if (override || this[name] === undefined) { this[name] = obj[name]; } } } }); Record = Object.subClass({ init: function(config) { this.vue = config; this.raw = {}; this.data = {}; this.prior = {}; this.face = {}; }, setData: function(raw) { this.raw = raw; var data = this.data = {}; var prior = this.prior = {}; var face = this.face = {}; for (var prop in raw) { var fieldMeta = this.getFieldMeta(prop); if (!fieldMeta) { continue; } var value = raw[prop]; data[prop] = value; prior[prop] = value; if (fieldMeta.formatter) { face[prop] = FormatCenter.format(value, fieldMeta.formatter); } else if (fieldMeta.dict) { face[prop] = Dictionary.getLabel(value, fieldMeta.dict); } else { face[prop] = value; } } }, getFace: function() { return this.face; }, getData: function() { return this.data; }, setEditData: function(data) { this.data = data; }, apply: function() { var data = this.data; var face = this.face; for (var prop in data) { var value = data[prop]; if (value == this.prior[prop]) { continue; } this.prior[prop] = value; var fieldMeta = this.getFieldMeta(prop); if (!fieldMeta) { continue; } if (fieldMeta.formatter) { value = FormatCenter.format(value, fieldMeta.formatter); } else if (fieldMeta.dict) { value = Dictionary.getLabel(value, fieldMeta.dict); } face[prop] = value; } }, getChanged: function() { var result = {}, raw = this.raw, data = this.data; for (var prop in data) { if (data[prop] == raw[prop]) { continue; } result[prop] = data[prop]; } if (raw.id && !result.id) { result.id = raw.id; } }, commit: function() { var raw = this.raw, data = this.data, prior = this.prior; for (var prop in data) { raw[prop] = prior[prop] = data[prop]; } }, cancel: function() { this.setData(this.raw); }, getFieldMeta: function(prop) { return this.vue.formFieldsObj[prop]; }, }); ListVue = Object.subClass({ init: function(config) { var default_ = { el: null, data: { //绑定的数据对象 dataname: null, //版本 currentVersion: { value: "1.0", label: "1.0" }, versionList: [ {value: "1.0", label: "1.0"}, {value: "2.0", label: "2.0"}, {value: "3.0", label: "3.0"} ], //查询功能 filterFields:[], filterFieldsObj: {}, filterObj: {}, filterList:[ //注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值) //{field: "", val: "", type: ""} ], filterAttr: { columnnumber: 4, labelwidth: "100px", labelposition: "right", size: "medium", border: "3px solid #c6c6c600" }, //列表功能 operationtype: "", isRefresh: true, tableAttr: {}, tableFields: [], tableFieldsObj: {}, tableData: [], tableHeight: 320, isEditTableData:false, pagesize: 10, pagenum: 1, total: 0, selectedrow: {}, selectCellField: {}, selectCellData: {}, orderby: "", }, watch: { }, methods: { //版本 versionSelect: function(obj) { this.currentVersion = obj; if (this.onVersionSelect) { this.onVersionSelect.call(this, obj); return } this.onInitQuery(); }, //功能 onDownload: function() { dealExportByPath("../../../template/area_tree.xlsx","测试数据"); }, onUpload: function() { Root.message('导入'); }, refreshData: function() { this.filterObj = {}; if (this.onRefreshData) { this.onRefreshData.call(this, arguments); return } this.onQuery(); }, approvalData: function(code) { //1. this.operationtype = "approval"; //2. get config and go var config = new Config(), go = true; if (this.onApproveData) { go = this.onApproveData.call(this, config, code); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "approval", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, //表格是否编辑 setEditTableData: function() { if (this.onSetEditTableData) { this.onSetEditTableData.call(this, arguments); return } this.isRefresh = false; this.isEditTableData = !this.isEditTableData; this.tableDataAfter(); }, getData: function(page) { this.pagesize = page.pagesize; this.pagenum = page.pagenum; this.doQuery(); }, //查询 onQuery: function() { //查询 this.pagenum = 1; this.doQuery(); }, onInitFilter: function() { //清空 this.filterObj = {}; this.onQuery(); }, onEditFilter: function() { //选择查询字段 }, doQuery: function() { let me = this; let filter_ = "1=1"; this.filterList = []; for(var k in this.filterObj) { let k_val = this.filterObj[k]; let fieldObj_ = this.filterFieldsObj[k]; let type_ = fieldObj_.type; let field_ = fieldObj_.field; let fieldtype_ = "equal"; if (fieldObj_.fieldname) { field_ = fieldObj_.fieldname } if (fieldObj_.fieldtype) { fieldtype_ = fieldObj_.fieldtype } //传条件数组由后端拼接筛选数据 /* let filterListObj_ = { field: field_, val: k_val, type: fieldtype_ } this.filterList.push(filterListObj_); */ //传条件数据有前端拼接 if (type_ == "daterange" && k_val.length) {//期间筛选 // var k_val_a = k_val[0]; var k_val_b = k_val[1]; if (fieldtype_ == "inScope") {//期间之内,不包含两端 filter_ += " and (" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "')"; } else if (fieldtype_ == "outScope") {//期间之外,不包含两端 filter_ += " and (" + field_ + "<'" + k_val_a + "' or " + field_ + ">'" + k_val_b + "')"; } else if (fieldtype_ == "inScopeInclude") {//期间之内,包含两端 filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))"; } } else if (type_ != "daterange") { //注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值) if (fieldtype_ == "like") { filter_ += " and " + field_ + " like '%" + k_val +"%'"; } else if (fieldtype_ == "in") { filter_ += " and " + field_ + " in ('" + k_val +"')"; } else if (fieldtype_ == "minval") { filter_ += " and " + field_ + " > '" + k_val +"'"; } else if (fieldtype_ == "maxval") { filter_ += " and " + field_ + " < '" + k_val +"'"; } else if (fieldtype_ == "mininclude") { filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') "; } else if (fieldtype_ == "maxinclude") { filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') "; } else { filter_ += " and " + field_ + " = '" + k_val +"'"; } } } let param_ = { isClientMode: false, dataname: this.dataname, filterList: this.filterList, filter: filter_, orderby: this.orderby, page: { no: this.pagenum, pagesize: this.pagesize }, //attachmeta: true } Server.call("root/data/getEntitySet", param_, function(result) { console.log(result); me.total = 0; me.tableData = []; if (result && result.data) { var data_ = result.data.entityset; me.total = result.data.page.recordcount; me.tableData = data_; } me.tableDataAfter(); }); }, tableDataAfter: function() { let me = this; if (this.onTableDataAfter) { this.onTableDataAfter.call(this, arguments); return } if (this.tableData.length > 0){ this.$nextTick(function(){ this.isRefresh = true; this.$nextTick(function(){ this.tableHeight = settableHeight(me.$refs.table1.$el, this.pagesize); }) }) } }, addData: function() { //1. this.operationtype = "add"; //this.selectedrow = {}; //2. get config and go var config = new Config(), go = true; if (this.onAddData) { go = this.onAddData.call(this, config); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "add", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, editData: function(scope) { //1. this.operationtype = "edit"; //this.selectedrow = scope.row; //2. get config and go var config = new Config(), go = true; if (this.onEditData) { go = this.onEditData.call(this, config, scope); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "edit", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, delData: function(scope) { let me = this; if (this.onDelData) { this.onDelData.call(this, scope); return } let row = scope.row; let index_ = scope.$index; let name_ = "该数据"; if (!this.dataname) { Root.message({ type: 'warning', message: '该事件需指定数据对象' }); return } if (!row.id) { Root.message({ type: 'warning', message: '该事件需存在数据ID' }); return } if (row.name) { name_ = "_" + row.name + "_"; } Root.confirm('确定删除' + name_ + '吗?', '删除提示', { confirmButtonText: '删除', cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { id: row.id, isClientMode: false, dataname: this.dataname, } Server.call("root/data/deleteEntity", param, function(result) { console.log(result); Root.message({ type: 'success', message: '删除成功!' }); me.doQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消删除' }); }); }, /*------------流程----------------*/ flow_Submit: function(status_,code_) { //status_:审批的字段 code_:提示语 let me = this; var row = this.selectedrow; if (!row || !row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }); return false; } else if (row[status_] != "input") { Root.message({ type: 'warning', message: '当前状态不可提交' }); return false; } Root.confirm('确定提交-' + row[code_] + '-吗?', '提示', { confirmButtonText: "提交", cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { orderId:row.id, eventType:"commit", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '提交成功' }); me.onQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, //审批通过 passApproval() { let param = { orderId:this.formData.id, eventType:"approvalSuccess", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '审批成功' }); Root.tab.removeItem(Root.tab.selected); }); }, //审批拒绝 refuseApproval() { let param = { orderId:this.formData.id, eventType:"approvalFail", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '拒绝审批成功' }); Root.tab.removeItem(Root.tab.selected); }); }, //作废 Cancel: function(status_,code_) { let me = this; var row = this.selectedrow; if (!row || !row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }); return false; } else if (row[status_] != "refuse") { Root.message({ type: 'warning', message: '当前状态不可作废' }); return false; } Root.confirm('确定作废-' + row[code_] + '-吗?', '提示', { confirmButtonText: "作废", cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { orderId:row.id, eventType:"cancellation", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '作废成功' }); me.onQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, //弹窗 showFilterPopup: function(obj) { if (this.onshowFilterPopup) { this.onshowFilterPopup.call(this, obj); return; } }, rowClick: function(obj) { this.selectedrow = obj.row; if (this.onRowClick) { this.onRowClick.call(this, obj); return; } }, cellClick: function(obj) { //1. get stlected if (!obj.column.property){ return; } this.selectCellField = this.tableFieldsObj[obj.column.property]; this.selectCellData = obj.column.property ? obj.row[obj.column.property] : {}; //2. get config and go var config = new Config(), go = true; //2. fire if (this.onCellClick) { go = this.onCellClick.call(this, config, obj); } else { if (this.selectCellField.clickContext && this.selectCellField.clickContext.type == "popup") { config.combine({ url: this.selectCellField.clickContext.url, sceneCode: this.selectCellField.clickContext.sceneCode, data: obj.row, delta: this.selectCellField.clickContext.delta ? this.selectCellField.clickContext.delta : {}, width: this.selectCellField.clickContext.width + "px" }) } else go = false; } //3. popup if (go) { this.doPopup(config); } }, h_procedure: function(field_, original_val, new_val, confirm_field, confirm_type, success_val, businessType) { let me = this; let row = this.selectedrow; if (!row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }) return; } if (this.selectedrow[field_] && this.selectedrow[field_] != original_val) { Root.message({ type: 'warning', message: this.selectedrow[field_] }) return; } Root.confirm('确定' + confirm_type + '-' + row[confirm_field] + '-吗?', confirm_type + '提示', { confirmButtonText: confirm_type, cancelButtonText: '取消', type: 'warning' }).then(() => { var key = "y32P59DT"; var param_act = { isClientMode: false, businessId: row.id, businessType: businessType, } Server.call("rootact/act/start/"+ key, param_act, function(result1) { console.log(result1); let paramObj = {}; for (var k in me.selectedrow) { paramObj[k] = me.selectedrow[k]; } paramObj[field_] = new_val; paramObj.flow_id = result1.data.activitiId; let param = paramObj; param.isClientMode = false; param.dataname = me.dataname; Server.call("root/data/updateEntity/"+ me.dataname, param, function(result) { console.log(result); me.onQuery(); }); Root.message({ type: 'success', message: success_val }); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, doPopup: function(popupObj) { var me = this; var callback_ = popupObj.callback; var width_ = popupObj.width ? popupObj.width : "900px"; var parames = { width: width_, // width: "900px", //height: "580px", url: popupObj.url, sceneCode: popupObj.sceneCode, data: popupObj.data, delta: popupObj.delta, disabled: popupObj.disabled, disabledone: popupObj.disabledone, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; Root.showPopup(parames); }, saveRowTable_popup: function(obj) { var me = this; var formData_ = obj.row; var operationtype_ = this.operationtype; if (operationtype_ == "edit") {//修改 var paramObj = {}; for (var k in formData_) { paramObj[k] = formData_[k]; } var param = paramObj; param.isClientMode = false; Server.call("root/data/updateEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); } else if (operationtype_ == "approval") {//审批 var paramObj = {}; for (var k in formData_) { paramObj[k] = formData_[k]; } var param = paramObj; param.isClientMode = false; Server.call("root/data/updateEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); //for (var k in formData_) { // this.selectedrow[k] = formData_[k]; //} } else {//新增 var param = formData_; param.isClientMode = false; Server.call("root/data/insertEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); } }, } } // config = util.combineObj(config, default_); Object.subClass.call(this); // var demand = { dataname: config.data.dataname, dataRequest: config.data.dataRequest, tabaleFieldsName: config.data.tabaleFieldsName, filterFieldsName: config.data.filterFieldsName } var meta = getMeta(demand); config.methods.onServerInitData.call(config, meta); config.vue = new Vue(config); /* var me = this; Server.call("root/data/getMeta/" + config.dataname, config.dataRequest, function(result) { if (result.success) { } config.onServerData.call(me, result.data); config.vue = new Vue(config); }) */ return config; }, }); TableVue = Object.subClass({ init: function(config) { var default_ = { el: null, data: { pageCode: "demo_table1", dataname: "", //版本 currentVersion: { value: "1.0", label: "1.0" }, versionList: [ {value: "1.0", label: "1.0"}, {value: "2.0", label: "2.0"}, {value: "3.0", label: "3.0"} ], //查询功能 filterObj: {}, filterList:[ //注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值) //{field: "", val: "", type: ""} ], filterAttr: {}, preinstallFilterAttr: { id: "123", columnnumber: 4, labelwidth: "100px", labelposition: "right", size: "medium", border: "3px solid #c6c6c600" }, //列表功能 operationtype: "", isRefresh: true, tableAttr: {}, tableHeight: 320, isEditTableData:false, selectedrow: {}, selectCellField: {}, selectCellData: {}, ////// //page ////// pageObj: {}, title: "", //窗口高度 clientHeight: 0, buttons: {}, filterFields: [], filterFieldsObj: {}, tableFields: [], tableFieldsObj: {}, tableData: [], tabMapPagesizeObj: {}, isPagination: true, preinstallPagesizeObj: { pagesize: 10, pagenum: 1, total: 0 }, pagesize: 10, pagenum: 1, total: 0, tabMapButton:{ page_id: {}, }, tabMapTable:{ page_id: {}, }, tabMapQuery:{ page_id: [], }, tabMapQueryField:{ page_id: [], }, tabMapField:{ page_id: [], }, tabMapPagesize:{ page_id: {}, }, tabMapTableData:{ page_id: [], }, tabMapFilterData:{ page_id: {}, }, //tables tableList: [], pageId: "", activeTable: {}, }, watch: { }, methods: { //版本 versionSelect: function(obj) { this.currentVersion = obj; if (this.onVersionSelect) { this.onVersionSelect.call(this, obj); return } this.onInitQuery(); }, //功能 onDownload: function() { dealExportByPath("../../../template/area_tree.xlsx","测试数据"); }, onUpload: function() { Root.message('导入'); }, refreshData: function() { this.filterObj = {}; if (this.onRefreshData) { this.onRefreshData.call(this, arguments); return } this.onQuery(); }, approvalData: function(code) { //1. this.operationtype = "approval"; //2. get config and go var config = new Config(), go = true; if (this.onApproveData) { go = this.onApproveData.call(this, config, code); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "approval", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, /////////////////// //获取资源 /////////////////// getResoures() { let me = this; this.getPageObj(); }, getPageObj() { var me = this; //页面信息 var params = { dataname: "page", isClientMode: false, filter: "code='" + this.pageCode + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { me.pageObj = result.data.entityset[0]; me.title = me.pageObj.name; me.pageId = me.pageObj.id; //获取ButtonsByPage me.getButtonsByPage(me.pageObj.id); //获取TablesByPage me.getTablesByPage(me.pageObj.id); me.$forceUpdate(); } }); }, getButtonsByPage(pageid) { var me = this; //按键 var params = { dataname: "buttonByPage",//buttonByPage/buttonByPanel isClientMode: false, filter: "resource_page.id='" + pageid + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { result.data.entityset.map(e=>{ if (!me.tabMapButton[e.page_id]) { me.tabMapButton[e.page_id] = {}; } me.tabMapButton[e.page_id][e.id_name]=e; }); me.getButtonByTabName(me.pageId); me.$forceUpdate(); } }); }, getTablesByPage(pageid) { var me = this; //table var params = { dataname: "tableByPage",//tableByPage//tableByPanel isClientMode: false, filter: "resource_page.id='" + pageid + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { me.tableList = result.data.entityset; result.data.entityset.map(e=>{ me.tabMapTable[e.page_id] = e; me.tabMapPagesize[e.page_id] = clone(me.preinstallPagesizeObj); }); me.getTableByTabName(me.pageId); //获取FieldByTable me.getFieldByTable(me.tableList); //获取QueryByTable me.getQueryByTable(me.tableList); //获取QueryByTable me.getQueryFieldByTable(me.tableList); me.$forceUpdate(); } }); }, getFieldByTable(tableList) { var me = this; if (tableList.length > 0) { var table_ = tableList[0]; //Field字段ByTable var params = { dataname: "tableField", isClientMode: false, filter: "table_id='" + table_.id + "'", orderby: "orderno" //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableField_ = result.data.entityset; me.tabMapField[table_.page_id] = tableField_; tableList.remove(table_); me.getFieldByTable(tableList); } }); } else { if (me.tabMapTable[me.pageId]) { me.activeTable = me.tabMapTable[me.pageId]; me.getTableFieldsByTabName(me.pageId); } } }, getQueryByTable(tableList) { var me = this; if (tableList.length > 0) { var table_ = tableList[0]; //Query字段ByTable var params = { dataname: "tableQuery", isClientMode: false, filter: "table_id='" + table_.id + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableQuery_ = result.data.entityset; me.tabMapQuery[table_.page_id] = tableQuery_[0]; tableList.remove(table_); me.getQueryByTable(tableList); } }); } else { me.getFilterByTabName(me.pageId); } }, getQueryFieldByTable(tableList) { var me = this; if (tableList.length > 0) { var table_ = tableList[0]; //Query字段ByTable var params = { dataname: "tableQueryField", isClientMode: false, filter: "table_id='" + table_.id + "'", orderby: "orderno" //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableQuery_ = result.data.entityset; me.tabMapQueryField[table_.page_id] = tableQuery_; me.tabMapFilterData[table_.page_id] = {}; tableList.remove(table_); me.getQueryFieldByTable(tableList); } }); } else { me.getFilterFieldsByTabName(me.pageId); } }, getTableByTabName(tab_name) { var me = this; me.activeTable = {}; if (me.tabMapTable[tab_name]) { me.activeTable = me.tabMapTable[tab_name]; me.dataname = me.activeTable.data_url; } }, getButtonByTabName(tab_name) { var me = this; me.buttons = {}; if (me.tabMapButton[tab_name]) { me.buttons = me.tabMapButton[tab_name]; } }, getFilterByTabName(tab_name) { var me = this; me.filterAttr = {}; if (me.tabMapQuery[tab_name]) { me.filterAttr = me.tabMapQuery[tab_name]; } else { me.filterAttr = me.preinstallFilterAttr; } }, getFilterFieldsByTabName(tab_name) { var me = this; me.filterFields = []; me.filterFieldsObj = {}; me.filterObj = {}; if (me.tabMapQueryField[tab_name]) { me.filterFields = me.tabMapQueryField[tab_name]; if(me.filterFields.length > 0) { for(var i=0; i < me.filterFields.length; i++) { let fieldObj_ = me.filterFields[i]; me.filterFieldsObj[fieldObj_.field] = fieldObj_; } } me.filterObj = me.tabMapFilterData[tab_name]; } me.$forceUpdate(); }, getTableFieldsByTabName(tab_name) { var me = this; me.tableFields = []; me.tableFieldsObj = {}; me.tabMapPagesizeObj ={}; me.tableData = []; if (me.tabMapField[tab_name]) { me.tableFields = me.tabMapField[tab_name]; if(me.tableFields.length > 0) { for(var i=0; i < me.tableFields.length; i++) { let fieldObj_ = me.tableFields[i]; me.tableFieldsObj[fieldObj_.field] = fieldObj_; } } this.getTableDataByTabName(tab_name); } me.$forceUpdate(); }, getTableDataByTabName(tab_name) { var me = this; me.tabMapPagesizeObj ={}; me.tableData = []; if (me.tabMapPagesize[tab_name]) { me.tabMapPagesizeObj = me.tabMapPagesize[tab_name]; } me.getDataByTable(me.activeTable); }, //表格是否编辑 setEditTableData() { if (this.onSetEditTableData) { this.onSetEditTableData.call(this, arguments); return } this.isRefresh = false; this.isEditTableData = !this.isEditTableData; this.tableDataAfter(); }, getData(page) { this.pagesize = page.pagesize; this.pagenum = page.pagenum; this.doQuery(); }, //查询 onQuery() { var me = this; //Tab中的查询 //1.获取当前Tab var tab_name = this.pageId; //2.设置当前Tab中的pagenum=1; if (me.tabMapPagesize[tab_name]) { me.tabMapPagesize[tab_name].pagenum = this.pagenum = 1; me.tabMapPagesize[tab_name].total = 0; me.tabMapPagesizeObj = me.tabMapPagesize[tab_name]; } //3.获取当前Tab的Table信息 me.activeTable = me.tabMapTable[tab_name]; //4.获取筛选条件 me.doQuery(); }, onInitFilter() { var me = this; //1.获取当前Page var tab_name = this.pageId; //清空 this.filterObj = this.tabMapFilterData[tab_name] = {}; var tab_name = this.pageId; me.tabMapPagesize[tab_name].pagenum = me.pagenum = 1; this.onQuery(); }, onEditFilter() { //选择查询字段 }, doQuery() { let me = this; let filter_ = "1=1"; this.filterList = []; for (var k in this.filterObj) { let k_val = this.filterObj[k]; let fieldObj_ = this.filterFieldsObj[k]; let type_ = fieldObj_.type; let field_ = fieldObj_.field; let fieldtype_ = "equal";//默认为= if (fieldObj_.fieldname) { field_ = fieldObj_.fieldname } if (fieldObj_.fieldtype) { fieldtype_ = fieldObj_.fieldtype } //传条件数组由后端拼接筛选数据 /* let filterListObj_ = { field: field_, val: k_val, type: fieldtype_ } this.filterList.push(filterListObj_); */ //传条件数据有前端拼接 if (type_ == "daterange" && k_val.length) {//期间筛选 // var k_val_a = k_val[0]; var k_val_b = k_val[1]; if (fieldtype_ == "inScope") {//期间之内,不包含两端 filter_ += " and (" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "')"; } else if (fieldtype_ == "outScope") {//期间之外,不包含两端 filter_ += " and (" + field_ + "<'" + k_val_a + "' or " + field_ + ">'" + k_val_b + "')"; } else if (fieldtype_ == "inScopeInclude") {//期间之内,包含两端 filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))"; } } else if (type_ != "daterange") { //注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值) if (fieldtype_ == "like") { filter_ += " and " + field_ + " like '%" + k_val +"%'"; } else if (fieldtype_ == "in") { filter_ += " and " + field_ + " in ('" + k_val +"')"; } else if (fieldtype_ == "minval") { filter_ += " and " + field_ + " > '" + k_val +"'"; } else if (fieldtype_ == "maxval") { filter_ += " and " + field_ + " < '" + k_val +"'"; } else if (fieldtype_ == "mininclude") { filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') "; } else if (fieldtype_ == "maxinclude") { filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') "; } else { filter_ += " and " + field_ + " = '" + k_val +"'"; } } } this.getDataByTable(me.activeTable, filter_); }, getDataByTable(tableObj, filter) { var me = this; if (!tableObj) { return } if (!filter) { filter = "1=1"; } var pagenum = me.tabMapPagesizeObj.pagenum = this.pagenum; var pagesize = me.tabMapPagesizeObj.pagesize = this.pagesize; var data_type = tableObj.data_type; var data_url = tableObj.data_url; me.tableData = []; //var tabcode = tableObj.tabcode; //'数据定义(sql(sql的name)/interface(后端接口)/dataobject(数据对象dataname))', if (data_type == "sql") { } else if (data_type == "interface") { } else if (data_type == "dataobject") { var params = { dataname: data_url, isClientMode: false, filter: filter, page: { no: pagenum, pagesize: pagesize }, //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data) { var data_ = result.data.entityset; var total_ = result.data.page.recordcount; me.tabMapPagesizeObj.total = me.total = total_; me.tableData = data_; } else { me.tableData = []; me.tabMapPagesizeObj.pagenum = me.pagenum = 1; me.tabMapPagesizeObj.total = me.total = 0; } me.$nextTick(function(){ let title_height = document.getElementsByClassName('topbar')[0].offsetHeight; let filter_height = me.$refs.form1.$el.offsetHeight; let pagination_height = 0; if (me.isPagination) { pagination_height = me.$refs.table1.$el.getElementsByClassName('z_table_pagination')[0].offsetHeight; } me.tabTableHeight = me.clientHeight - title_height - filter_height - pagination_height - 10; me.isRefresh = true; }); //me.tableDataAfter(); }); } }, tableDataAfter() { let me = this; if (this.onTableDataAfter) { this.onTableDataAfter.call(this, arguments); return } if (this.tableData.length > 0){ this.$nextTick(function(){ this.isRefresh = true; this.$nextTick(function(){ // let filter_height = me.$refs.form1.$el.getElementsByClassName('z_form')[0].offsetHeight; // me.tabTableHeight = me.tabTableHeight - filter_height; let header_height = me.$refs.table1.$el.getElementsByClassName('el-table__header-wrapper')[0].offsetHeight; me.$refs.table1.$el.getElementsByClassName('el-table__body-wrapper')[0].style['height'] = me.tabTableHeight - header_height + "px"; me.$refs.table1.$el.getElementsByClassName('el-table__body-wrapper')[0].style['min-height'] = me.tabTableHeight - header_height + "px"; //this.tableHeight = settableHeight(me.$refs.table1.$el, this.pagesize); }) }) } }, addData() { //1. this.operationtype = "add"; //this.selectedrow = {}; //2. get config and go var config = new Config(), go = true; if (this.onAddData) { go = this.onAddData.call(this, config); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "add", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, editData: function(scope) { //1. this.operationtype = "edit"; //this.selectedrow = scope.row; //2. get config and go var config = new Config(), go = true; if (this.onEditData) { go = this.onEditData.call(this, config, scope); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "edit", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, delData: function(scope) { let me = this; if (this.onDelData) { this.onDelData.call(this, scope); return } let row = scope.row; let index_ = scope.$index; let name_ = "该数据"; if (!this.dataname) { Root.message({ type: 'warning', message: '该事件需指定数据对象' }); return } if (!row.id) { Root.message({ type: 'warning', message: '该事件需存在数据ID' }); return } if (row.name) { name_ = "_" + row.name + "_"; } Root.confirm('确定删除' + name_ + '吗?', '删除提示', { confirmButtonText: '删除', cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { id: row.id, isClientMode: false, dataname: this.dataname, } Server.call("root/data/deleteEntity", param, function(result) { console.log(result); Root.message({ type: 'success', message: '删除成功!' }); me.doQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消删除' }); }); }, /*------------流程----------------*/ flow_Submit: function(status_,code_) { //status_:审批的字段 code_:提示语 let me = this; var row = this.selectedrow; if (!row || !row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }); return false; } else if (row[status_] != "input") { Root.message({ type: 'warning', message: '当前状态不可提交' }); return false; } Root.confirm('确定提交-' + row[code_] + '-吗?', '提示', { confirmButtonText: "提交", cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { orderId:row.id, eventType:"commit", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '提交成功' }); me.onQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, //审批通过 passApproval() { let param = { orderId:this.formData.id, eventType:"approvalSuccess", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '审批成功' }); Root.tab.removeItem(Root.tab.selected); }); }, //审批拒绝 refuseApproval() { let param = { orderId:this.formData.id, eventType:"approvalFail", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '拒绝审批成功' }); Root.tab.removeItem(Root.tab.selected); }); }, //作废 Cancel: function(status_,code_) { let me = this; var row = this.selectedrow; if (!row || !row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }); return false; } else if (row[status_] != "refuse") { Root.message({ type: 'warning', message: '当前状态不可作废' }); return false; } Root.confirm('确定作废-' + row[code_] + '-吗?', '提示', { confirmButtonText: "作废", cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { orderId:row.id, eventType:"cancellation", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '作废成功' }); me.onQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, //弹窗 showFilterPopup: function(obj) { if (this.onshowFilterPopup) { this.onshowFilterPopup.call(this, obj); return; } }, rowClick: function(obj) { this.selectedrow = obj.row; if (this.onRowClick) { this.onRowClick.call(this, obj); return; } }, cellClick: function(obj) { //1. get stlected if (!obj.column.property){ return; } this.selectCellField = this.tableFieldsObj[obj.column.property]; this.selectCellData = obj.column.property ? obj.row[obj.column.property] : {}; //2. get config and go var config = new Config(), go = true; //2. fire if (this.onCellClick) { go = this.onCellClick.call(this, config, obj); } else { if (this.selectCellField.clickContext && this.selectCellField.clickContext.type == "popup") { config.combine({ url: this.selectCellField.clickContext.url, sceneCode: this.selectCellField.clickContext.sceneCode, data: obj.row, delta: this.selectCellField.clickContext.delta ? this.selectCellField.clickContext.delta : {}, width: this.selectCellField.clickContext.width + "px" }) } else go = false; } //3. popup if (go) { this.doPopup(config); } }, h_procedure: function(field_, original_val, new_val, confirm_field, confirm_type, success_val, businessType) { let me = this; let row = this.selectedrow; if (!row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }) return; } if (this.selectedrow[field_] && this.selectedrow[field_] != original_val) { Root.message({ type: 'warning', message: this.selectedrow[field_] }) return; } Root.confirm('确定' + confirm_type + '-' + row[confirm_field] + '-吗?', confirm_type + '提示', { confirmButtonText: confirm_type, cancelButtonText: '取消', type: 'warning' }).then(() => { var key = "y32P59DT"; var param_act = { isClientMode: false, businessId: row.id, businessType: businessType, } Server.call("rootact/act/start/"+ key, param_act, function(result1) { console.log(result1); let paramObj = {}; for (var k in me.selectedrow) { paramObj[k] = me.selectedrow[k]; } paramObj[field_] = new_val; paramObj.flow_id = result1.data.activitiId; let param = paramObj; param.isClientMode = false; param.dataname = me.dataname; Server.call("root/data/updateEntity/"+ me.dataname, param, function(result) { console.log(result); me.onQuery(); }); Root.message({ type: 'success', message: success_val }); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, doPopup: function(popupObj) { var me = this; var callback_ = popupObj.callback; var width_ = popupObj.width ? popupObj.width : "900px"; var parames = { width: width_, // width: "900px", //height: "580px", url: popupObj.url, sceneCode: popupObj.sceneCode, data: popupObj.data, delta: popupObj.delta, disabled: popupObj.disabled, disabledone: popupObj.disabledone, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; Root.showPopup(parames); }, saveRowTable_popup: function(obj) { var me = this; var formData_ = obj.row; var operationtype_ = this.operationtype; if (operationtype_ == "edit") {//修改 var paramObj = {}; for (var k in formData_) { paramObj[k] = formData_[k]; } var param = paramObj; param.isClientMode = false; Server.call("root/data/updateEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); } else if (operationtype_ == "approval") {//审批 var paramObj = {}; for (var k in formData_) { paramObj[k] = formData_[k]; } var param = paramObj; param.isClientMode = false; Server.call("root/data/updateEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); //for (var k in formData_) { // this.selectedrow[k] = formData_[k]; //} } else {//新增 var param = formData_; param.isClientMode = false; Server.call("root/data/insertEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); } }, } } // config = util.combineObj(config, default_); Object.subClass.call(this); var dataRequestObj = {}; getDataRequest(config.data.dataRequest, dataRequestObj, function(result){ config.methods.onServerInitData.call(config, result); }); config.vue = new Vue(config); return config; }, }); TabVue = Object.subClass({ init: function(config) { var default_ = { el: null, data: { pageCode: "demo_tab1", dataname: "", //版本 currentVersion: { value: "1.0", label: "1.0" }, versionList: [ {value: "1.0", label: "1.0"}, {value: "2.0", label: "2.0"}, {value: "3.0", label: "3.0"} ], //查询功能 filterObj: {}, filterList:[ //注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值) //{field: "", val: "", type: ""} ], filterAttr: {}, preinstallFilterAttr: { id: "123", columnnumber: 4, labelwidth: "100px", labelposition: "right", size: "medium", border: "3px solid #c6c6c600" }, //列表功能 operationtype: "", isRefresh: true, tableAttr: {}, tableHeight: 320, isEditTableData:false, selectedrow: {}, selectCellField: {}, selectCellData: {}, ////// //Tab ////// pageObj: {}, title: "", //窗口高度 clientHeight: 0, tabs: {}, buttons: {}, filterFields: [], filterFieldsObj: {}, tableFields: [], tableFieldsObj: {}, tableData: [], tabMapPagesizeObj: {}, isPagination: true, preinstallPagesizeObj: { pagesize: 10, pagenum: 1, total: 0 }, pagesize: 10, pagenum: 1, total: 0, //Tab项 tabList: [ {id: "1", label: "Tab1", name: "tab1"}, {id: "2", label: "Tab2", name: "tab2"}, {id: "3", label: "Tab3", name: "tab3"} ], tabMapButton:{ tabcode: {}, }, tabMapTable:{ tabcode: {}, }, tabMapQuery:{ tabcode: [], }, tabMapQueryField:{ tabcode: [], }, tabMapField:{ tabcode: [], }, tabMapPagesize:{ tabcode: {}, }, tabMapTableData:{ tabcode: [], }, tabMapFilterData:{ tabcode: {}, }, //tables tableList: [], activeTab: 'tabcode', activeTable: {}, //tableMapTab tableObjByTab: { tabcode: { tableObj: {}, tableQuery: [], tableField: [] } }, }, watch: { }, methods: { //版本 versionSelect: function(obj) { this.currentVersion = obj; if (this.onVersionSelect) { this.onVersionSelect.call(this, obj); return } this.onInitQuery(); }, //功能 onDownload: function() { dealExportByPath("../../../template/area_tree.xlsx","测试数据"); }, onUpload: function() { Root.message('导入'); }, refreshData: function() { this.filterObj = {}; if (this.onRefreshData) { this.onRefreshData.call(this, arguments); return } this.onQuery(); }, approvalData: function(code) { //1. this.operationtype = "approval"; //2. get config and go var config = new Config(), go = true; if (this.onApproveData) { go = this.onApproveData.call(this, config, code); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "approval", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, /////////////////// /////////////////// getResoures() { let me = this; this.getPageObj(); }, getPageObj() { var me = this; //页面信息 var params = { dataname: "page", isClientMode: false, filter: "code='" + this.pageCode + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { me.pageObj = result.data.entityset[0]; me.title = me.pageObj.name; //获取TabsByPage me.getTabsByPage(me.pageObj.id); } }); }, getTabsByPage(pageid) { var me = this; //tab var params = { dataname: "tabs", isClientMode: false, filter: "page_id='" + pageid + "'", orderby: "orderno" //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { me.tabList = result.data.entityset; me.activeTab = me.tabList[0].id_name; result.data.entityset.map(e=>{ me.tabs[e.id_name] = e; }); //获取ButtonsByPage me.getButtonsByPage(me.pageObj.id); //获取TablesByPage me.getTablesByPage(me.pageObj.id); me.$forceUpdate(); } }); }, getButtonsByPage(pageid) { var me = this; //按键 var params = { dataname: "buttonByTab",//buttonByPage/buttonByPanel isClientMode: false, //page_id: pageid, filter: "resource_tab.page_id='" + pageid + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { //me.activeTab = me.tabList[0].id_name; result.data.entityset.map(e=>{ if (!me.tabMapButton[e.tabcode]) { me.tabMapButton[e.tabcode] = {}; } me.tabMapButton[e.tabcode][e.id_name]=e; }); me.getButtonByTabName(me.activeTab); me.$forceUpdate(); } }); }, getTablesByPage(pageid) { var me = this; //table var params = { dataname: "tableByTab",//tableByPage//tableByPanel isClientMode: false, //page_id: pageid, filter: "resource_tab.page_id='" + pageid + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { me.tableList = result.data.entityset; result.data.entityset.map(e=>{ me.tabMapTable[e.tabcode] = e; me.tabMapPagesize[e.tabcode] = clone(me.preinstallPagesizeObj); }); me.getTableByTabName(me.activeTab); //获取FieldByTable me.getFieldByTable(me.tableList); //获取QueryByTable me.getQueryByTable(me.tableList); //获取QueryByTable me.getQueryFieldByTable(me.tableList); me.$forceUpdate(); } }); }, getFieldByTable(tableList) { var me = this; if (tableList.length > 0) { var table_ = tableList[0]; //Field字段ByTable var params = { dataname: "tableField", isClientMode: false, filter: "table_id='" + table_.id + "'", orderby: "orderno" //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableField_ = result.data.entityset; me.tabMapField[table_.tabcode] = tableField_; tableList.remove(table_); me.getFieldByTable(tableList); } }); } else { if (me.tabMapTable[me.activeTab]) { me.activeTable = me.tabMapTable[me.activeTab]; me.getTableFieldsByTabName(me.activeTab); } } }, getQueryByTable(tableList) { var me = this; if (tableList.length > 0) { var table_ = tableList[0]; //Query字段ByTable var params = { dataname: "tableQuery", isClientMode: false, filter: "table_id='" + table_.id + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableQuery_ = result.data.entityset; me.tabMapQuery[table_.tabcode] = tableQuery_[0]; tableList.remove(table_); me.getQueryByTable(tableList); } }); } else { me.getFilterByTabName(me.activeTab); } }, getQueryFieldByTable(tableList) { var me = this; if (tableList.length > 0) { var table_ = tableList[0]; //Query字段ByTable var params = { dataname: "tableQueryField", isClientMode: false, filter: "table_id='" + table_.id + "'", orderby: "orderno" //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableQuery_ = result.data.entityset; me.tabMapQueryField[table_.tabcode] = tableQuery_; me.tabMapFilterData[table_.tabcode] = {}; tableList.remove(table_); me.getQueryFieldByTable(tableList); } }); } else { me.getFilterFieldsByTabName(me.activeTab); } }, handleClick(tab, event) { var tab_name = tab.name; this.getDataByTabName(tab_name); }, getDataByTabName(tab_name) { var me = this; me.activeTable = {}; me.dataname = ""; me.buttons = {}; me.filterFields = []; me.filterFieldsObj = {}; me.filterObj = {}; me.tableFields = []; me.tableFieldsObj = {}; me.tabMapPagesizeObj = {}; me.tableData = []; if (me.tabMapPagesize[tab_name]) { me.tabMapPagesizeObj = me.tabMapPagesize[tab_name]; me.pagenum = me.tabMapPagesizeObj.pagenum; me.total = me.tabMapPagesizeObj.total; me.pagesize = me.tabMapPagesizeObj.pagesize; } else { me.tabMapPagesizeObj = me.preinstallPagesizeObj; me.pagenum = me.tabMapPagesizeObj.pagenum; me.total = me.tabMapPagesizeObj.total; me.pagesize = me.tabMapPagesizeObj.pagesize; } //me.total = me.tabMapPagesizeObj.total = 0; //this.isRefresh = false; if (me.tabMapTable[tab_name]) { me.activeTable = me.tabMapTable[tab_name]; me.dataname = me.activeTable.data_url; this.getButtonByTabName(tab_name); this.getFilterByTabName(tab_name); this.getFilterFieldsByTabName(tab_name); this.getTableFieldsByTabName(tab_name); } }, getTableByTabName(tab_name) { var me = this; me.activeTable = {}; if (me.tabMapTable[tab_name]) { me.activeTable = me.tabMapTable[tab_name]; me.dataname = me.activeTable.data_url; } }, getButtonByTabName(tab_name) { var me = this; me.buttons = {}; if (me.tabMapButton[tab_name]) { me.buttons = me.tabMapButton[tab_name]; } }, getFilterByTabName(tab_name) { var me = this; me.filterAttr = {}; if (me.tabMapQuery[tab_name]) { me.filterAttr = me.tabMapQuery[tab_name]; } else { me.filterAttr = me.preinstallFilterAttr; } me.$forceUpdate(); }, getFilterFieldsByTabName(tab_name) { var me = this; me.filterFields = []; me.filterFieldsObj = {}; me.filterObj = {}; if (me.tabMapQueryField[tab_name]) { me.filterFields = me.tabMapQueryField[tab_name]; if(me.filterFields.length > 0) { for(var i=0; i < me.filterFields.length; i++) { let fieldObj_ = me.filterFields[i]; me.filterFieldsObj[fieldObj_.field] = fieldObj_; } } me.filterObj = me.tabMapFilterData[tab_name]; } me.$forceUpdate(); }, getTableFieldsByTabName(tab_name) { var me = this; me.tableFields = []; me.tableFieldsObj = {}; me.tabMapPagesizeObj ={}; me.tableData = []; if (me.tabMapField[tab_name]) { me.tableFields = me.tabMapField[tab_name]; if(me.tableFields.length > 0) { for(var i=0; i < me.tableFields.length; i++) { let fieldObj_ = me.tableFields[i]; me.tableFieldsObj[fieldObj_.field] = fieldObj_; } } this.getTableDataByTabName(tab_name); } me.$forceUpdate(); }, getTableDataByTabName(tab_name) { var me = this; me.tabMapPagesizeObj ={}; me.tableData = []; if (me.tabMapPagesize[tab_name]) { me.tabMapPagesizeObj = me.tabMapPagesize[tab_name]; } me.getDataByTable(me.activeTable); }, //表格是否编辑 setEditTableData() { if (this.onSetEditTableData) { this.onSetEditTableData.call(this, arguments); return } this.isRefresh = false; this.isEditTableData = !this.isEditTableData; this.tableDataAfter(); }, getData(page) { this.pagesize = page.pagesize; this.pagenum = page.pagenum; this.doQuery(); }, //查询 onQuery() { var me = this; //Tab中的查询 //1.获取当前Tab var tab_name = this.activeTab; //2.设置当前Tab中的pagenum=1; if (me.tabMapPagesize[tab_name]) { me.tabMapPagesize[tab_name].pagenum = me.pagenum = 1; me.tabMapPagesize[tab_name].total = 0; me.tabMapPagesizeObj = me.tabMapPagesize[tab_name]; } //3.获取当前Tab的Table信息 me.activeTable = me.tabMapTable[tab_name]; //4.获取筛选条件 me.doQuery(); }, onInitFilter() { var me = this; //1.获取当前Tab var tab_name = this.activeTab; //清空 this.filterObj = this.tabMapFilterData[tab_name] = {}; var tab_name = this.activeTab; me.tabMapPagesize[tab_name].pagenum = me.pagenum = 1; this.onQuery(); }, onEditFilter() { //选择查询字段 }, doQuery() { let me = this; let filter_ = "1=1"; this.filterList = []; for (var k in this.filterObj) { let k_val = this.filterObj[k]; let fieldObj_ = this.filterFieldsObj[k]; let type_ = fieldObj_.type; let field_ = fieldObj_.field; let fieldtype_ = "equal";//默认为= if (fieldObj_.fieldname) { field_ = fieldObj_.fieldname } if (fieldObj_.fieldtype) { fieldtype_ = fieldObj_.fieldtype } //传条件数组由后端拼接筛选数据 /* let filterListObj_ = { field: field_, val: k_val, type: fieldtype_ } this.filterList.push(filterListObj_); */ //传条件数据有前端拼接 if (type_ == "daterange" && k_val.length) {//期间筛选 // var k_val_a = k_val[0]; var k_val_b = k_val[1]; if (fieldtype_ == "inScope") {//期间之内,不包含两端 filter_ += " and (" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "')"; } else if (fieldtype_ == "outScope") {//期间之外,不包含两端 filter_ += " and (" + field_ + "<'" + k_val_a + "' or " + field_ + ">'" + k_val_b + "')"; } else if (fieldtype_ == "inScopeInclude") {//期间之内,包含两端 filter_ += " and ((" + field_ + ">'" + k_val_a + "' and " + field_ + "<'" + k_val_b + "') or (" + field_ + "='" + k_val_a + "' or " + field_ + "='" + k_val_b + "'))"; } } else if (type_ != "daterange") { //注释:type: equal(等于)/in(在多个数据中)/like(模糊)/minval(最小值)/maxval(最大值)/mininclude(最小且包含该值)/maxinclude(最大且包含该值) if (fieldtype_ == "like") { filter_ += " and " + field_ + " like '%" + k_val +"%'"; } else if (fieldtype_ == "in") { filter_ += " and " + field_ + " in ('" + k_val +"')"; } else if (fieldtype_ == "minval") { filter_ += " and " + field_ + " > '" + k_val +"'"; } else if (fieldtype_ == "maxval") { filter_ += " and " + field_ + " < '" + k_val +"'"; } else if (fieldtype_ == "mininclude") { filter_ += " and (" + field_ + " > '" + k_val +"' or " + field_ + " = '" + k_val +"') "; } else if (fieldtype_ == "maxinclude") { filter_ += " and (" + field_ + " < '" + k_val +"' or " + field_ + " = '" + k_val +"') "; } else { filter_ += " and " + field_ + " = '" + k_val +"'"; } } } this.getDataByTable(me.activeTable, filter_); }, getDataByTable(tableObj, filter) { var me = this; if (!tableObj) { return } if (!filter) { filter = "1=1"; } var pagenum = me.tabMapPagesizeObj.pagenum = me.pagenum; var pagesize = me.tabMapPagesizeObj.pagesize = me.pagesize; var data_type = tableObj.data_type; var data_url = tableObj.data_url; me.tableData = []; //var tabcode = tableObj.tabcode; //'数据定义(sql(sql的name)/interface(后端接口)/dataobject(数据对象dataname))', if (data_type == "sql") { } else if (data_type == "interface") { } else if (data_type == "dataobject") { var params = { dataname: data_url, isClientMode: false, filter: filter, page: { no: pagenum, pagesize: pagesize }, //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data) { var data_ = result.data.entityset; var total_ = result.data.page.recordcount; me.tabMapPagesizeObj.total = me.total = total_; me.tableData = data_; } else { me.tableData = []; me.tabMapPagesizeObj.pagenum = me.pagenum = 1; me.tabMapPagesizeObj.total = me.total = 0; } me.$nextTick(function(){ let title_height = document.getElementsByClassName('topbar')[0].offsetHeight; let tabs_height = document.getElementsByClassName('el-tabs')[0].offsetHeight; let filter_height = me.$refs.form1.$el.offsetHeight; let pagination_height = 0; if (me.isPagination) { pagination_height = me.$refs.table1.$el.getElementsByClassName('z_table_pagination')[0].offsetHeight; } me.tabTableHeight = me.clientHeight - title_height - tabs_height - filter_height - pagination_height - 10; me.isRefresh = true; }); //me.tableDataAfter(); }); } }, tableDataAfter() { let me = this; if (this.onTableDataAfter) { this.onTableDataAfter.call(this, arguments); return } if (this.tableData.length > 0){ this.$nextTick(function(){ this.isRefresh = true; this.$nextTick(function(){ let header_height = me.$refs.table1.$el.getElementsByClassName('el-table__header-wrapper')[0].offsetHeight; me.$refs.table1.$el.getElementsByClassName('el-table__body-wrapper')[0].style['height'] = me.tabTableHeight - header_height + "px"; me.$refs.table1.$el.getElementsByClassName('el-table__body-wrapper')[0].style['min-height'] = me.tabTableHeight - header_height + "px"; //this.tableHeight = settableHeight(me.$refs.table1.$el, this.pagesize); }) }) } }, addData() { //1. this.operationtype = "add"; //this.selectedrow = {}; //2. get config and go var config = new Config(), go = true; if (this.onAddData) { go = this.onAddData.call(this, config); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "add", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, editData: function(scope) { //1. this.operationtype = "edit"; //this.selectedrow = scope.row; //2. get config and go var config = new Config(), go = true; if (this.onEditData) { go = this.onEditData.call(this, config, scope); } //3. popup if (go) { config.title = clone(config.text); config.operationtype = clone(this.operationtype); if (config.totab) { if (config.url) { if (config.text.length > 4) { config.text = config.text.substr(0, 4) + "..."; } } var callback_ = config.callback; var parames = { totab: true, url: config.url, title: config.title, sceneCode: config.sceneCode, data: config.data, delta: config.delta, disabled: config.disabled, disabledone: config.disabledone, operationtype: "edit", parentOption: window.top.tab.selected.option, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; window.top.tab.open(config); } else { this.doPopup(config); } } }, delData: function(scope) { let me = this; if (this.onDelData) { this.onDelData.call(this, scope); return } let row = scope.row; let index_ = scope.$index; let name_ = "该数据"; if (!this.dataname) { Root.message({ type: 'warning', message: '该事件需指定数据对象' }); return } if (!row.id) { Root.message({ type: 'warning', message: '该事件需存在数据ID' }); return } if (row.name) { name_ = "_" + row.name + "_"; } Root.confirm('确定删除' + name_ + '吗?', '删除提示', { confirmButtonText: '删除', cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { id: row.id, isClientMode: false, dataname: this.dataname, } Server.call("root/data/deleteEntity", param, function(result) { console.log(result); Root.message({ type: 'success', message: '删除成功!' }); me.doQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消删除' }); }); }, /*------------流程----------------*/ flow_Submit: function(status_,code_) { //status_:审批的字段 code_:提示语 let me = this; var row = this.selectedrow; if (!row || !row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }); return false; } else if (row[status_] != "input") { Root.message({ type: 'warning', message: '当前状态不可提交' }); return false; } Root.confirm('确定提交-' + row[code_] + '-吗?', '提示', { confirmButtonText: "提交", cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { orderId:row.id, eventType:"commit", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '提交成功' }); me.onQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, //审批通过 passApproval() { let param = { orderId:this.formData.id, eventType:"approvalSuccess", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '审批成功' }); Root.tab.removeItem(Root.tab.selected); }); }, //审批拒绝 refuseApproval() { let param = { orderId:this.formData.id, eventType:"approvalFail", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '拒绝审批成功' }); Root.tab.removeItem(Root.tab.selected); }); }, //作废 Cancel: function(status_,code_) { let me = this; var row = this.selectedrow; if (!row || !row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }); return false; } else if (row[status_] != "refuse") { Root.message({ type: 'warning', message: '当前状态不可作废' }); return false; } Root.confirm('确定作废-' + row[code_] + '-吗?', '提示', { confirmButtonText: "作废", cancelButtonText: '取消', type: 'warning' }).then(() => { let param = { orderId:row.id, eventType:"cancellation", dataType:"sales", isClientMode: false, } Server.call("root/order/onEvent", param, function(result) { console.log(result); Root.message({ type: 'success', message: '作废成功' }); me.onQuery(); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, //弹窗 showFilterPopup: function(obj) { if (this.onshowFilterPopup) { this.onshowFilterPopup.call(this, obj); return; } }, rowClick: function(obj) { this.selectedrow = obj.row; if (this.onRowClick) { this.onRowClick.call(this, obj); return; } }, cellClick: function(obj) { //1. get stlected if (!obj.column.property){ return; } this.selectCellField = this.tableFieldsObj[obj.column.property]; this.selectCellData = obj.column.property ? obj.row[obj.column.property] : {}; //2. get config and go var config = new Config(), go = true; //2. fire if (this.onCellClick) { go = this.onCellClick.call(this, config, obj); } else { if (this.selectCellField.clickContext && this.selectCellField.clickContext.type == "popup") { config.combine({ url: this.selectCellField.clickContext.url, sceneCode: this.selectCellField.clickContext.sceneCode, data: obj.row, delta: this.selectCellField.clickContext.delta ? this.selectCellField.clickContext.delta : {}, width: this.selectCellField.clickContext.width + "px" }) } else go = false; } //3. popup if (go) { this.doPopup(config); } }, h_procedure: function(field_, original_val, new_val, confirm_field, confirm_type, success_val, businessType) { let me = this; let row = this.selectedrow; if (!row.id) { Root.message({ type: 'warning', message: '请先选择一条数据' }) return; } if (this.selectedrow[field_] && this.selectedrow[field_] != original_val) { Root.message({ type: 'warning', message: this.selectedrow[field_] }) return; } Root.confirm('确定' + confirm_type + '-' + row[confirm_field] + '-吗?', confirm_type + '提示', { confirmButtonText: confirm_type, cancelButtonText: '取消', type: 'warning' }).then(() => { var key = "y32P59DT"; var param_act = { isClientMode: false, businessId: row.id, businessType: businessType, } Server.call("rootact/act/start/"+ key, param_act, function(result1) { console.log(result1); let paramObj = {}; for (var k in me.selectedrow) { paramObj[k] = me.selectedrow[k]; } paramObj[field_] = new_val; paramObj.flow_id = result1.data.activitiId; let param = paramObj; param.isClientMode = false; param.dataname = me.dataname; Server.call("root/data/updateEntity/"+ me.dataname, param, function(result) { console.log(result); me.onQuery(); }); Root.message({ type: 'success', message: success_val }); }); }).catch(() => { Root.message({ type: 'info', message: '已取消' }); }); }, doPopup: function(popupObj) { var me = this; var callback_ = popupObj.callback; var width_ = popupObj.width ? popupObj.width : "900px"; var parames = { width: width_, // width: "900px", //height: "580px", url: popupObj.url, title: popupObj.title, sceneCode: popupObj.sceneCode, data: popupObj.data, delta: popupObj.delta, disabled: popupObj.disabled, disabledone: popupObj.disabledone, operationtype: popupObj.operationtype, callback: function(obj, callback) { if (callback_) { callback_(obj); } if (callback) { callback(); } } }; Root.popupParames = parames; Root.showPopup(parames); }, saveRowTable_popup: function(obj) { var me = this; var formData_ = obj.row; var operationtype_ = this.operationtype; if (operationtype_ == "edit") {//修改 var paramObj = {}; for (var k in formData_) { paramObj[k] = formData_[k]; } var param = paramObj; param.isClientMode = false; Server.call("root/data/updateEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); } else if (operationtype_ == "approval") {//审批 var paramObj = {}; for (var k in formData_) { paramObj[k] = formData_[k]; } var param = paramObj; param.isClientMode = false; Server.call("root/data/updateEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); //for (var k in formData_) { // this.selectedrow[k] = formData_[k]; //} } else {//新增 var param = formData_; param.isClientMode = false; Server.call("root/data/insertEntity/" + this.dataname, param, function(result) { console.log(result); me.onQuery(); }); } }, } } // config = util.combineObj(config, default_); Object.subClass.call(this); var dataRequestObj = {}; getDataRequest(config.data.dataRequest, dataRequestObj, function(result){ config.methods.onServerInitData.call(config, result); }); config.vue = new Vue(config); return config; }, }); function getDataRequest(dataRequest, dataRequestObj, callback) { if (dataRequest.length) { var dataName_ = dataRequest[0]; var params = { dataname: dataName_, isClientMode: false, //filter: "table_id='" + table_.id + "'", //userId: this.userId } Server.call("root/data/getEntitySet", params, function(result) { console.log(result); if (result && result.data.entityset) { var tableQuery_ = result.data.entityset; dataRequestObj[dataName_] = tableQuery_; dataRequest.remove(dataName_); getDataRequest(dataRequest, dataRequestObj, callback); } }); } else if (callback) { callback(dataRequestObj); } else { return dataRequestObj; } }; function getMeta(demand) { var result = { tableFields: dataRootFields.tableFields[demand.tabaleFieldsName], filterFields: dataRootFields.filterFields[demand.filterFieldsName] } if (demand.dataRequest && demand.dataRequest.length) { for (var i = 0; i < demand.dataRequest.length; i++) { var itemName = demand.dataRequest[i]; result[itemName] = dataRoot.database[itemName]; } } return result; }; function hideLoading() { document.getElementById('page_root').style.display = "block"; document.getElementById('page_loading').style.display = "none"; }; function getUrl(vue, url, params, callback, error_callback) { url = baseUrl + url; let lastUrl = url.substring(url.lastIndexOf("/") + 1); commonAxios.get(url, { params: params }).then(data_ => { if(typeof(data_.data) == "string"){ data_.data = JSON.parse(data_.data); } if (!data_.data.success) { vue.$message({ showClose: true, message: data_.data.errormessage, type: 'error' }); return; } var result = data_.data; if (!isEncoded) { var dataStr = JSON.stringify(data_.data); // dataStr = percent2percent25(dataStr); dataStr = decodeURI(dataStr); var result = eval('(' + dataStr + ')'); } if (callback) { if (lastUrl && lastUrl.startsWith("get")) { lastUrl = lastUrl.substring(3).toLowerCase(); if (result[lastUrl]) { callback(result[lastUrl]); } else { callback(result); } } else { callback(result); } } }) .catch(error => { vue.$message({ showClose: true, message: url + ':请求出现错误:' + error, type: 'error' }); console.error(error); if (error_callback) { error_callback(error); } }) }; function uploadFile(vue, formData, callback, error_callback) { uploadAxios.post(baseUrl +'file/exec', formData).then(data_ => { vue.$message({ showClose: true, message: '上传成功!', type: 'success' }); if (callback) { callback(data_); } }).catch(error => { vue.$message({ showClose: true, message: ':请求出现错误:' + error, type: 'error' }); console.error(error); if (error_callback) { error_callback(error); } }); } /* function uploadFileAnalysis(vue, formData, callback, error_callback) { uploadAxios.post(baseUrl +'client/parseLicense', formData).then(data_ => { vue.$message({ showClose: true, message: '上传成功!', type: 'success' }); if (callback) { callback(data_); } }).catch(error => { vue.$message({ showClose: true, message: ':请求出现错误:' + error, type: 'error' }); console.error(error); if (error_callback) { error_callback(error); } }); } */ function getDataList(me, dataName, params, callback, error_callback) { params.dataName = dataName; getUrl(me, "data/getEntitySet", params, callback, error_callback); }; function getOneData(me, dataName, params, callback, error_callback) { params.dataName = dataName; getUrl(me, "data/getEntity", params, callback, error_callback); }; function saveData(me, dataName, params, callback, error_callback) { for(let one in params) { let val = params[one]; if(val === "") { params[one] = undefined; } } params.dataName = dataName; getUrl(me, "data/saveEntity", params, callback, error_callback); }; function delData(me, dataName, id, callback, error_callback) { let params = { id:id, dataName: dataName }; getUrl(me, "data/deleteEntity", params, callback, error_callback); }; function percent2percent25(URI) { if (URI.indexOf('%') > -1) { return URI.replace(/%/g, '%25') } else { return URI; } } function postUrl(vue, url, params, callback, error_callback) { url = baseUrl + url; let lastUrl = url.substring(url.lastIndexOf("/") + 1); let formData = new FormData(); for(let name in params) { let val = params[name]; formData.append(name, val); } axios.post(url, formData) .then(data_ => { if (!data_.data.success) { vue.$message({ showClose: true, message: data_.data.errormessage, type: 'error' }); return; } if (callback) { if (lastUrl && lastUrl.startsWith("get")) { lastUrl = lastUrl.substring(3).toLowerCase(); if (data_.data[lastUrl]) { callback(data_.data[lastUrl]); } else { callback(data_.data.data); } } else { callback(data_.data.data); } } }) .catch(error => { vue.$message({ showClose: true, message: url + ':请求出现错误:' + error, type: 'error' }); console.info(error); if (error_callback) { error_callback(error); } }) }; function postCommonUrl(vue, url, params, callback, error_callback) { url = baseUrl + url; let lastUrl = url.substring(url.lastIndexOf("/") + 1); commonAxios.post(url, params) .then(data_ => { if (!data_.data.success) { vue.$message({ showClose: true, message: data_.data.errormessage, type: 'error' }); return; } if (callback) { if (lastUrl && lastUrl.startsWith("get")) { lastUrl = lastUrl.substring(3).toLowerCase(); if (data_.data[lastUrl]) { callback(data_.data[lastUrl]); } else { callback(data_.data.data); } } else { callback(data_.data.data); } } }) .catch(error => { vue.$message({ showClose: true, message: url + ':请求出现错误:' + error, type: 'error' }); console.info(error); if (error_callback) { error_callback(error); } }) }; function objectToURI(object) { if (!object) { return null; } if (typeof object == "String") { return encodeURI(object); } var param = null; for (var prop in object) { if (object[prop]) { if (param) { param = param + "&" + prop + "=" + encodeURI(object[prop]); } else { param = prop + "=" + encodeURI(object[prop]); } } } return param; } function getGetParams(url) { // var url = window.location.href; const search = url.split('?')[1] if (!search) { return {} } return JSON.parse( '{"' + decodeURIComponent(search) .replace(/"/g, '\\"') .replace(/&/g, '","') .replace(/=/g, '":"') + '"}' ) } function ArrayToTree(array_, name, parentId, parId, disabled_field, isencode) { if(!parentId) { parentId = "parent_id"; } if(!name) { name = "label"; } if(!parId) { parId = ""; } let obj = {}; let result = []; let list = JSON.parse(JSON.stringify(array_)); list.map(el => { obj[el.id] = el; }) let openId = ""; for (let i = 0, len = list.length; i < len; i++) { let parentId_ = list[i][parentId]; //如果存在判断只读字段,并且该字段有值则设置该节点为只读 if (disabled_field) { if(list[i][disabled_field]) { list[i].disabled = true; } } //设置显示字段 if (isencode) { list[i].label = decodeURI(encodeURI( list[i][name]));//数据如果带“%”的需要编码再解码,否则会存在格式错误 list[i].name = decodeURI(encodeURI( list[i][name])); } else { list[i].label = decodeURI(list[i][name]); list[i].name = decodeURI(list[i][name]); } if (parentId_ == parId || !parentId_ || parentId_ == "null") { if(!obj[list[i].id].children) { obj[list[i].id].children = null; } result.push(list[i]); continue; } else if (obj[parentId_]) { if (!obj[parentId_].children) { obj[parentId_].children = []; } obj[parentId_].children.push(list[i]); } } return result; } function listTOGroup(array_, id, parentId, label) { let parId = ""; let obj = {}; let result = []; let list = JSON.parse(JSON.stringify(array_)); list.map(el => { obj[el.id] = el; }) let openId = ""; for (let i = 0, len = list.length; i < len; i++) { let parentId_ = list[i][parentId]; //设置显示字段 list[i].value = list[i][id]; list[i].label = list[i][label]; if (parentId_ == parId || !parentId_) { obj[list[i].id].children = []; result.push(list[i]); continue; } else if (obj[parentId_]) { if (!obj[parentId_].children) { obj[parentId_].children = []; } obj[parentId_].children.push(list[i]); } } return result; } function list2Options(array_, value, label) { var result = array_.map(function(one) { return { value: one[value], label: one[label] } }); return result; } function clone(obj) { var result, oClass = isClass(obj); //确定result的类型 if (oClass === "Object") { result = {}; } else if (oClass === "Array") { result = []; } else { return obj; } for (var key in obj) { var copy = obj[key]; if (isClass(copy) == "Object") { result[key] = arguments.callee(copy); //递归调用 } else if (isClass(copy) == "Array") { result[key] = arguments.callee(copy); } else { result[key] = obj[key]; } } return result; }; function isClass(o) { if (o === null) return "Null"; if (o === undefined) return "Undefined"; return Object.prototype.toString.call(o).slice(8, -1); } function formatterRate(rate, fixed) { if (!fixed) { fixed = 1; } if (rate == "") { return ""; } if (rate == 0) { return 0; } if (isNaN(rate)) { return 0; } return (rate * 10000 / 100).toFixed(fixed); } function formatters(rate, fixed) { if (!fixed) { fixed = 1; } if (rate == "") { return ""; } if (isNaN(rate)) { return rate; } if (parseInt(rate) == rate) { return rate; } return (rate * 100 / 100).toFixed(fixed); } function sortNumber(a, b) { return a - b } function groupArr(list, field) { var obj = {}; for (var i = 0; i < list.length; i++) { var keys = Object.keys(list[i]); for (var j = 0; j < keys.length; j++) { var item = keys[j] if (item == field) { obj[list[i][item]] = { list: obj[list[i][field]] ? obj[list[i][field]].list : [], type: list[i][field] }; } } obj[list[i][field]].list.push(list[i]) } var att = []; for (item in obj) { att.push({ list: obj[item].list, type: obj[item].type, }) } return att; } function dealExportByBlob(res) { let fileName = decodeURI(res.headers['content-disposition'].split('filename=')[1]) // let fileName = decodeURI(res.headers['content-disposition'].match(/filename=(\S*)(?=(.xls|.xlsx))/)[1]) let blob = new Blob([res.data], { type: 'application/vnd.ms-excel;charset=UTF-8' }) if (window.navigator.msSaveBlob) { // 没有此判断的话,ie11下的导出没有效果 window.navigator.msSaveBlob(blob, fileName) } else { let downloadElement = document.createElement('a') let href = window.URL.createObjectURL(blob) // 创建下载的链接 downloadElement.href = href downloadElement.download = fileName // 下载后文件名 document.body.appendChild(downloadElement) downloadElement.click() // 点击下载 document.body.removeChild(downloadElement) // 下载完成移除元素 window.URL.revokeObjectURL(href) // 释放掉blob对象 } } function dealExportByPath(fileurl, fileName) { let downloadElement = document.createElement('a') downloadElement.href = fileurl downloadElement.download = fileName // 下载后文件名 document.body.appendChild(downloadElement) downloadElement.click() // 点击下载 document.body.removeChild(downloadElement) // 下载完成移除元素 } function randomData(length, multiple, fixed) { if (!length) { length = 1; } if (!multiple) { multiple = 1; } if (!fixed) { fixed = 0; } if (length == 1) { return getOneRandom(multiple, fixed); } var data = []; for (var i = 0; i < length; i++) { data[i] = getOneRandom(multiple, fixed); } return data; } function getOneRandom(multiple, fixed) { return parseFloat((Math.random() * multiple).toFixed(fixed)); } function uuid(len, radix) { var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); var uuid = [], i; radix = radix || chars.length; if (len) { // Compact form for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; } else { // rfc4122, version 4 form var r; // rfc4122 requires these characters uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; uuid[14] = '4'; // Fill in random data. At i==19 set the high bits of clock sequence as // per rfc4122, sec. 4.1.5 for (i = 0; i < 36; i++) { if (!uuid[i]) { r = 0 | Math.random() * 16; uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; } } } return uuid.join(''); } function uuid_short() { return uuid(32); } function isObject(obj) { return Object.prototype.toString.call(obj) === '[object Object]'; } function str2JSON(str) { if(str == ""|| str == undefined) { return null; } return JSON.parse(str); } function getArrDifference(array1, array2) { var result = []; for(var i = 0; i < array2.length; i++){ var obj = array2[i]; var num = obj.id; var isExist = false; for(var j = 0; j < array1.length; j++){ var aj = array1[j]; var n = aj.field_id; if(n == num){ isExist = true; break; } } if(!isExist){ result.push(obj); } } return result; } function groupBy( array , f ) { let groups = {}; array.forEach( function( o ) { let group = JSON.stringify( f(o) ); groups[group] = groups[group] || []; groups[group].push( o ); }); return Object.keys(groups).map( function( group ) { return groups[group]; }); } Array.prototype.contains = function (obj) { var i = this.length; while (i--) { if (this[i] === obj) { return true; } } return false; } function dateformatter(date, type){ if(!type) { type = 0; } if(0 == type) { return dateFormatCommon(date); } if(1 == type) { return dateFormatEn(date); } if(2 == type) { return dateFormatCn(date); } if(-1 == type) { return new Date(Date.parse(date.replace(/-/g, "/"))); } } function dateFormatCommon(date) { var nowdate = new Date(date).toLocaleDateString().replace(/\//g, '-') return nowdate } function dateFormatEn(date) { var nowdate = new Date(date).toLocaleDateString() return nowdate } function dateFormatCn(now) { y = now.getFullYear(), m = ("0" + (now.getMonth() + 1)).slice(-2), d = ("0" + now.getDate()).slice(-2); return y + "-" + m + "-" + d + " " + now.toTimeString().substr(0, 8); } function isAssetTypeAnImage(ext) { return [ 'png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff']. indexOf(ext.toLowerCase()) !== -1; } function logOut() { window.top.location.href = "login.html"; localStorage.removeItem('user'); localStorage.removeItem('emp'); localStorage.removeItem('menu'); } function quotedStr(val) { return "'" + val + "'"; } function handleDownload(fileId) { var elemIF = document.createElement('iframe') elemIF.src = getDownloadFileUrl(fileId); elemIF.style.display = 'none' document.body.appendChild(elemIF) } function getDownloadFileUrl(fileId) { return baseUrl + 'file/downloadFile?id=' + fileId; } /// 项目使用 function addNotice(me, to_id, content, callback) { let params = { to_id: to_id, content: content }; let url = "work/push2Msg"; getUrl(me, url, params, result => { if(callback) { callback(result); } }) } Array.prototype.remove = function(val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } }; let supplierId = "99008321972863334"; let materialCheckList = [ // '99008321972863325', //成本单价 // '99008321972863326',//成本数量 '99008321972863386',//采购填报单价/参数 '99008321972863330',//本次到货数量 '99008321972863332',//到货单价 '99008321972863329',//本次要料数量 '99008321972863334',//供应商 '99008321972863335',//供应商送货码单号 ]