From 41e6159cfa12416155adcd6747e48fab28ffc534 Mon Sep 17 00:00:00 2001 From: cyy <cuiqian2004@163.com> Date: 星期一, 26 八月 2024 22:45:17 +0800 Subject: [PATCH] test --- pages/modal/3200.vue | 404 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 316 insertions(+), 88 deletions(-) diff --git a/pages/modal/3200.vue b/pages/modal/3200.vue index a8f7bac..d794f70 100644 --- a/pages/modal/3200.vue +++ b/pages/modal/3200.vue @@ -273,7 +273,40 @@ }); //璁剧疆椤堕儴鏍囬 this.$data.title = options.titlename; this.$data.param = JSON.parse(options.param); - this.initial(); + + + this.styledef = {}; + this.head_styledef = { + form: { + items: [] + } + }; + this.detail1_styledef = {}; + this.detail1StyleDefList = []; + this.detail2_styledef = {}; + this.detail2StyleDefList = []; + this.ListHtml_Panel = ""; + this.ListPageHtml_Show = { + name: "", + event: { + id: "", + name: "" + } + }; + this.items = []; + this.active_id = ''; + this.activelist = []; + + if (this.param.ListPage.ListItem_UIDef?.ui_type == "HTML椤甸潰") { + // HTML椤甸潰 + //鑾峰彇鏁版嵁绫荤殑HTML椤甸潰 + await this.Html_UIstyleGetInfo(this.param.DataCls.id, this.param.ListPage.ListItem_UIDef.id, options + .paramValue); + } else { + await this.Detail1_UIstyleGetInfo(this.param.DataCls.id, this.param.ListPage.ListItem_UIDef.id); + + await this.initial(options.paramValue); + } // this.isFilter=true; // if(this.param.ShowFilter) // this.isFilter=false; @@ -303,43 +336,61 @@ // this.focusMateria=true; }, methods: { - //鍒濆鍖�- async initial() { - this.styledef = {}; - this.head_styledef = { - form: { - items: [] - } - }; - this.detail1_styledef = {}; - this.detail1StyleDefList = []; - this.detail2_styledef = {}; - this.detail2StyleDefList = []; - this.items = []; - this.active_id = ''; - this.activelist = []; - this.ListHtml_Panel = ""; - this.ListPageHtml_Show = { - name: "", - event: { - id: "", - name: "" - } - }; + // + setData: function(obj) { + let that = this; + let keys = []; + let val, data; + Object.keys(obj).forEach(function(key) { + keys = key.split("."); + val = obj[key]; + data = that.$data; + keys.forEach(function(key2, index) { + if (index + 1 == keys.length) { + that.$set(data, key2, val); + } else { + if (!data[key2]) { + that.$set(data, key2, {}); + } + } + data = data[key2]; + }); + }); + }, + + //鍒濆鍖�+ async initial(paramValue) { this.isFilter = true; if (this.param.ShowFilter) this.isFilter = false; //鑾峰彇鏁版嵁绫荤殑鑷畾涔夎〃鍗曞弬鏁� if (this.param.Query_Panel) { - this.Head_UIStyleGetInfo(this.param.DataCls.id, this.param.Query_Panel.id); - } - if (this.param.ListPage.ListItem_UIDef?.ui_type == "HTML椤甸潰") { - // HTML椤甸潰 - //鑾峰彇鏁版嵁绫荤殑HTML椤甸潰 - await this.Html_UIstyleGetInfo(this.param.DataCls.id, this.param.ListPage.ListItem_UIDef.id); - } else { - await this.Detail1_UIstyleGetInfo(this.param.DataCls.id, this.param.ListPage.ListItem_UIDef.id); + await this.Head_UIStyleGetInfo(this.param.DataCls.id, this.param.Query_Panel.id); + //浼犲叆鍙傛暟鍊�+ if (paramValue) { + const attrs = paramValue.attrs || []; + (this.$data.head_styledef?.form?.items || []).forEach(async (ele, index) => { + if (ele.name != "Layout") { + attrs.forEach(async (ele2, index2) => { + if (ele.fieldId == ele2.name) { + ele.value = ele2.value; + } + }); + } else { + ele.setting.colList.forEach(async (col) => { + if (col) { + attrs.forEach(async (ele2, + index2) => { + if (col.fieldId == ele2.name) { + col.value = ele2.value; + } + }); + } + }); + } + }) + } } this.orderby = this.param.Order ? this.param.Order : 'T_CREATE Desc'; if (this.param.Query_Event) { @@ -349,8 +400,10 @@ this.pageindex = 1; this.page_size = 3; this.query_id = ""; + this.detail1StyleDefList = []; await this.loadDataGetList(); } + }, //婊氬姩鍒板簳閮ㄥ悗鎳掑姞杞芥暟鎹� async scrolltolower(e) { @@ -462,7 +515,7 @@ }); }, - async Html_UIstyleGetInfo(class_id, style_id) { //鑾峰彇鑷畾涔夎〃鍗曟牱寮�+ async Html_UIstyleGetInfo(class_id, style_id, paramValue) { //鑾峰彇鑷畾涔夎〃鍗曟牱寮� var $this = this; var dataInfo = { class_id: class_id, @@ -479,8 +532,11 @@ if (!ret.result.style_def.includes('"')) styledef = Base64.decode(ret.result .style_def); } + // console.log(styledef); $this.ListPageHtml_Show = ret.result.style_def ? JSON.parse(styledef) : {}; // console.log($this.ListPageHtml_Show); + + $this.initial(paramValue); } else { uni.showModal({ title: this.translateSys("error") + "10", @@ -507,45 +563,34 @@ dict_id: dict.id, dict_name: dict.name }; - // console.log(dataInfo); - this.$store.dispatch('DictGetInfo', dataInfo).then(async (success) => { - console.log(success); - if (success.err_code == 0) { - if (type == 'mast') { - var list = []; - var itemName = ''; - success.result.dict_item_list.forEach((item) => { - if (item.is_default == '1') - itemName = item.name; - list.push({ - text: item.value, - value: item.name, - }); + try { + const success = await this.getDictInfo(dataInfo) + if (type == 'mast') { + var list = []; + var itemName = ''; + success.result.dict_item_list.forEach((item) => { + if (item.is_default == '1') + itemName = item.name; + list.push({ + text: item.value, + value: item.name, }); - //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� - if (itemName) { - $this.head_styledef.form.items[index].value = itemName; - var attr = $this.head_styledef.form.items[index].fieldId; - $this.head_styledef.form.model[attr] = itemName; - } - $this.head_styledef.form.items[index].dict = list; - var head_styledef = JSON.parse(JSON.stringify($this.head_styledef)); - $this.head_styledef = []; - $this.head_styledef = head_styledef; - } else { - // $this.$data.subClassAttrList[index].attr_list[key].dictitem=success.result; - // this.$store.commit("subClassAttrList", $this.$data.subClassAttrList); - } - - } else { - uni.showModal({ - title: this.translateSys("error") + "3.1", - content: success.err_msg, - showCancel: false, - confirmText: this.translateSys("cancel") }); + //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + if (itemName) { + $this.head_styledef.form.items[index].value = itemName; + var attr = $this.head_styledef.form.items[index].fieldId; + $this.head_styledef.form.model[attr] = itemName; + } + $this.head_styledef.form.items[index].dict = list; + var head_styledef = JSON.parse(JSON.stringify($this.head_styledef)); + $this.head_styledef = []; + $this.head_styledef = head_styledef; + } else { + // $this.$data.subClassAttrList[index].attr_list[key].dictitem=success.result; + // this.$store.commit("subClassAttrList", $this.$data.subClassAttrList); } - }).catch(ex => { + } catch (ex) { // console.log(ex); uni.showModal({ title: this.translateSys("error") + "3", @@ -553,7 +598,66 @@ showCancel: false, confirmText: this.translateSys("cancel") }); - }); + } + }, + getDictInfo(info) { //Mobox3寰楀埌寰楀埌瀛楀吀淇℃伅瀛楀吀椤瑰垪琛�+ const loginInfo = this.$store.getters.loginid + const mobxoSApi = this.$store.getters.getMobxoSApi + return new Promise((resolve, reject) => { + uni.request({ + url: mobxoSApi + 'api/dict/GetInfo2?sessionid=' + loginInfo.result.session_id, + data: info, + method: 'POST', + dataType: "json", + success: (_res) => { + // console.log(_res); + const ret = _res.data + if (ret.err_code == 0) { + resolve(ret); + } else { + reject({ + "errMsg": ret.err_msg + }); + } + }, + fail: (err) => { + // console.log(err); + reject(err); + } + }) + + }) + + }, +getUIStyleInfo(info) { //Mobox3鏁版嵁绫荤晫闈㈡牱寮�+ const loginInfo = this.$store.getters.loginid + const dataSApi = this.$store.getters.getDataSApi + return new Promise((resolve, reject) => { + uni.request({ + url: dataSApi + 'api/class/uistyle/GetInfo?sessionid=' + loginInfo.result + .session_id, + data: info, + method: 'POST', + dataType: "json", + success: (_res) => { + // console.log(_res); + const ret = _res.data + if (ret.err_code == 0) { + resolve(ret); + } else { + reject({ + "errMsg": ret.err_msg + }); + } + }, + fail: (err) => { + // console.log(err); + reject(err); + } + }) + + }) + }, // 鎵ц鏌ヨ浜嬩欢 @@ -695,6 +799,7 @@ if (ret.result) { $this.page_count = ret.result.page_count; if (ret.result.page_count > 1) $this.query_id = ret.result.query_id; + // console.log($this.ListPageHtml_Show.event); if ($this.ListPageHtml_Show.event.id) { ret.result.obj_list.forEach((obj) => { var info = { @@ -938,6 +1043,13 @@ if (btn.FunCode == "Add" || btn.FunCode == "Modify") { if (btn.Edit_dlg.Model == "small") { this.showAddSmallDialog(btn, style, enviroment); + } else { + uni.showModal({ + title: this.translateSys("tip"), + content: this.translateSys("unrealized"), + showCancel: false, + confirmText: this.translateSys("cancel") + }); } } else if (btn.FunCode == "Delete") { this.DeleteObj(btn, style, enviroment); @@ -1053,34 +1165,142 @@ }, //鎵ц浜嬩欢 - TriggerEvent(btn, style, enviroment) {}, + async TriggerEvent(btn, style, enviroment) { //鎵ц瑙﹀彂浜嬩欢 + try { + let obj_attr = { + S_ID: this.styledef.form.objId + }; + style.form.attrs.forEach((attr) => { + obj_attr[attr.name] = attr.value; + }); + + if (!this.ListPageHtml_Show.event.id) { + //鍒ゆ柇娌℃湁HTML椤甸潰浜嬩欢 + // console.log(this.detail2_styledef); + this.detail2_styledef.form.items.forEach(async (ele, index) => { + if (ele.name != "Layout") { + if (!obj_attr[ele.fieldId]) { + obj_attr[ele.fieldId] = ele.value; + } + } else if (ele.name == "Layout") { + ele.setting.colList.forEach(async (col, key) => { + if (col) { + if (!obj_attr[col.fieldId]) { + obj_attr[col.fieldId] = col.value; + } + } + }); + } + }); + } + + const dataInfo = { + ed_type: 0, + start_transaction: true, + class_id: btn.clsId, + event_id: btn.event.id, + data_obj_id: this.styledef.form.objId, + obj_attr: obj_attr, + } + this.$store.dispatch('runCustomEvent', dataInfo).then(ret => { + // console.log(ret); + if (ret.err_code == 0) { + var result = ret.result; + if (result.ret != 0) { + var tip = result.err_info ? typeof result.err_info == + 'string' ? + result + .err_info : result.err_info.join('<br/>') : ''; + if (result.ret == 801) { + if (this.param.Only_Script_Error) { + let pos = tip.indexOf("锛�); + if (pos > -1) tip = tip.substring(pos + 1); + } + uni.showModal({ + title: this.translateSys("tip"), + content: tip, + showCancel: false, + confirmText: this.translateSys("cancel") + }); + } else uni.showModal({ + title: this.translateSys("tip"), + content: tip + ',' + this.translateSys('tip') + + ':' + + result + .ret, + showCancel: false, + confirmText: this.translateSys("cancel") + }); + return false; + } else { + var tip = result.info ? typeof result.info == 'string' ? result + .info : + result.info.join('<br/>') : ''; + if (tip) uni.showModal({ + title: this.translateSys("tip"), + content: tip, + showCancel: false, + confirmText: this.translateSys("cancel") + }); + + } + } else { + uni.showModal({ + title: this.translateSys("error") + "8", + content: ret.err_msg, + showCancel: false, + confirmText: this.translateSys("cancel") + }); + } + + }).catch(ex => { + // console.log(ex); + uni.showModal({ + title: this.translateSys("error") + "8.1", + content: ex.errMsg, + showCancel: false, + confirmText: this.translateSys("cancel") + }); + }); + } catch (ex) { + var tip = typeof ex == "string" ? ex : ex.message; + uni.showModal({ + title: this.translateSys("error"), + content: tip, + showCancel: false, + confirmText: this.translateSys("cancel") + }); + this.showError(ex); + } + }, //璺宠浆 async RelatedFunction(btn, style, enviroment) { - + const defCode = btn.Related_Function?.Def_Code + var $this = this; if ( - btn.Related_Function?.Def_Code == "3018" || - btn.Related_Function?.Def_Code == "3037" || - btn.Related_Function?.Def_Code == "3200" || - btn.Related_Function?.Def_Code == "3201" || - btn.Related_Function?.Def_Code == "5600" || - btn.Related_Function?.Def_Code == "5601" || - btn.Related_Function?.Def_Code == "5602" + defCode == "3018" || + defCode == "3037" || + defCode == "3200" || + defCode == "3201" || + defCode == "5600" || + defCode == "5601" || + defCode == "5602" ) { - let name = btn.Related_Function?.Def_Code - if (btn.Related_Function?.Def_Code == "3018" || btn.Related_Function?.Def_Code == "3037") - name = btn.Related_Function?.Def_Code + "_2" - var $this = this; + let name = defCode + if (defCode == "3018" || defCode == "3037") + name = defCode + "_2" var json = { - app_id: appId, + app_id: [btn.Related_Function.ID], }; + console.log("RelatedFunction2", json); this.$store.dispatch('appGetInfo', json).then(success => { - // console.log(success); + console.log(success); if (success.err_code == 0) { if ((success.result || []).length > 0) { const app = success.result[0] var param = ""; - var appName = app.name || app.list_name + var appName = app.list_name || app.name .Name; var paramStr = app.param if (paramStr) { @@ -1102,7 +1322,7 @@ uni.navigateTo({ url: '../modal/' + name + '?param=' + param + "&titlename=" + appName + - "&type=relatedFunction&attrValue=" + JSON.stringify(style + "&type=relatedFunction¶mValue=" + JSON.stringify(style .form), events: { relatedFunction: function(data) { @@ -1128,7 +1348,7 @@ }); } }).catch(ex => { - // console.log(ex); + console.log(ex); uni.showModal({ title: this.translateSys("error"), content: ex.errMsg, @@ -1136,6 +1356,14 @@ confirmText: this.translateSys("cancel") }); }); + } else { + uni.showModal({ + title: this.translateSys("error"), + content: this.translate("cannot_related_function"), + showCancel: false, + confirmText: this.translateSys("cancel") + }); + } }, //鎵ц鍚庡鐞嗕簨浠� -- Gitblit v1.9.1