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/3037_2.vue | 287 +++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 209 insertions(+), 78 deletions(-) diff --git a/pages/modal/3037_2.vue b/pages/modal/3037_2.vue index da8388a..e6f824c 100644 --- a/pages/modal/3037_2.vue +++ b/pages/modal/3037_2.vue @@ -213,10 +213,10 @@ <view class="view-floor"> <button type="default" @tap="cancel" class="btn_cancel" v-if="param.Sub_Cls.Can_Add_Delete == true">{{translateSys('cancel')}}</button> - <button type="default" @tap="sava" class="btn_add" - v-if="param.Sub_Cls.Can_Add_Delete == true">{{title}}</button> - <button type="default" @tap="sava" class="btn_sava" - v-else-if="param.Sub_Cls.Can_Add_Delete == false">{{title}}</button> + <button type="default" @tap="sava" class="btn_add" v-if="param.Sub_Cls.Can_Add_Delete == true" + :class="saving?'btn_disabled':''" :disabled="saving">{{title}}</button> + <button type="default" @tap="sava" class="btn_sava" v-else-if="param.Sub_Cls.Can_Add_Delete == false" + :class="saving?'btn_disabled':''" :disabled="saving">{{title}}</button> </view> <!-- 鏅�寮圭獥 top bottom center left right --> <view> @@ -279,6 +279,7 @@ detail1_styledef: {}, detail1StyleDefList: [], activelist: [], + saving: false, }; }, onLoad(options) { @@ -288,15 +289,64 @@ }); //璁剧疆椤堕儴鏍囬 this.$data.title = options.titlename; this.$data.param = JSON.parse(options.param); - console.log(this.$data.param); - //鑾峰彇鏁版嵁绫荤殑鑷畾涔夎〃鍗曞弬鏁�- this.Head_UIStyleGetInfo(this.param.Master_Cls?.ID, this.param.Master_Cls?.UI_Style?.ID); - this.Detail1_UIstyleGetInfo(this.param.Sub_Cls?.ID, this.$data.param.Sub_Cls?.UI_Style?.ID); + this.loadData(options.paramValue) //椤甸潰鍒濆鍖栬幏鍙栫劍鐐� // this.focusMateria=true; }, methods: { + 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 loadData(paramValue) { + console.log(this.$data.param); + //鑾峰彇鏁版嵁绫荤殑鑷畾涔夎〃鍗曞弬鏁�+ await this.Head_UIStyleGetInfo(this.param.Master_Cls?.ID, this.param.Master_Cls?.UI_Style?.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; + } + }); + } + }); + } + }) + } + + await this.Detail1_UIstyleGetInfo(this.param.Sub_Cls?.ID, this.$data.param.Sub_Cls?.UI_Style?.ID); + }, async Head_UIStyleGetInfo(class_id, style_id) { //鑾峰彇鑷畾涔夎〃鍗曟牱寮� var $this = this; var dataInfo = { @@ -410,48 +460,38 @@ 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) { - 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) + 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 (type == 'mast') { //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� - 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; - // console.log($this.$data.detail1StyleDefList); - } else { - if (itemName) { - $this.detail1_styledef.form.items[index].value = itemName; - var attr = $this.detail1_styledef.form.items[index].fieldId; - $this.detail1_styledef.form.model[attr] = itemName; - } - $this.detail1_styledef.form.items[index].dict = list; - console.log($this.$data.detail1_styledef); + if (type == 'mast') { //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + 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; + // console.log($this.$data.detail1StyleDefList); } else { - uni.showModal({ - title: this.translateSys("error") + "1.2", - content: success.err_msg, - showCancel: false, - confirmText: this.translateSys("cancel") - }); + if (itemName) { + $this.detail1_styledef.form.items[index].value = itemName; + var attr = $this.detail1_styledef.form.items[index].fieldId; + $this.detail1_styledef.form.model[attr] = itemName; + } + $this.detail1_styledef.form.items[index].dict = list; + console.log($this.$data.detail1_styledef); } - }).catch(ex => { + + } catch (ex) { // console.log(ex); uni.showModal({ title: this.translateSys("error") + "1.3", @@ -459,8 +499,69 @@ 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); + } + }) + + }) + + }, + async loadInitEvent(eventid, type) { var $this = this; var styledef = type == 'head' ? this.head_styledef : this.detail1_styledef; @@ -480,13 +581,18 @@ if (data.ret != 0) { var tip = data.err_info ? typeof data.err_info == 'string' ? data.err_info : data .err_info.join('<br/>') : ''; - if (data.ret == 801) uni.showModal({ - title: this.translateSys("tip"), - content: tip, - showCancel: false, - confirmText: this.translateSys("cancel") - }); - else uni.showModal({ + if (data.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') + ':' + data.ret, showCancel: false, @@ -731,7 +837,7 @@ // console.log(e.target); var $this = this; console.log(item); - if (item.oldvalue != item.value) { + if (item.oldvalue != item.value && item.value.trim() != "") { item.oldvalue = item.value; var attr = item.fieldId; $this.head_styledef.form.model[attr] = item.value; @@ -770,7 +876,7 @@ console.log(item); var $this = this; console.log(item); - if (item.oldvalue != item.value) { + if (item.oldvalue != item.value && item.value.trim() != "") { item.oldvalue = item.value; var attr = item.fieldId; $this.head_styledef.form.model[attr] = item.value; @@ -1200,13 +1306,18 @@ if (data.ret != 0) { var tip = data.err_info ? typeof data.err_info == 'string' ? data.err_info : data .err_info.join('<br/>') : ''; - if (data.ret == 801) uni.showModal({ - title: this.translateSys("tip"), - content: tip, - showCancel: false, - confirmText: this.translateSys("cancel") - }); - else uni.showModal({ + if (data.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') + ':' + data.ret, showCancel: false, @@ -1488,15 +1599,21 @@ if (data.ret != 0) { var tip = data.err_info ? typeof data.err_info == 'string' ? data.err_info : data .err_info.join('<br/>') : ''; - if (data.ret == 801) uni.showModal({ + if (data.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, - showCancel: false, - confirmText: this.translateSys("cancel") - }); - else uni.showModal({ - title: this.translateSys("tip"), - content: tip + this.translateSys('comma') + this.translate('result') +this.translateSys('colon') + data.ret, + content: tip + this.translateSys('comma') + this.translate('result') + this + .translateSys('colon') + data.ret, showCancel: false, confirmText: this.translateSys("cancel") }); @@ -1528,7 +1645,7 @@ for (var j = 0; j < attr.length; j++) { if (attr[j].Name == result[i].attr) { if (utils.classUtils.attrTypeIsDict(attr[j] - .Type)) { + .Type)) { var dictItemList = []; for (var d in result[i].choice_list) { var val = result[i].choice_list[d]; @@ -1762,6 +1879,7 @@ }); //杩斿洖灞傛暟锛�鍒欎笂涓婇〉 }, scan_OKDataObjRunCustomEvent(eventID) { + this.saving = true uni.showLoading({ title: this.translateSys("loading"), mask: true @@ -1843,18 +1961,24 @@ if (data.ret != 0) { var tip = data.err_info ? typeof data.err_info == 'string' ? data.err_info : data .err_info.join('<br/>') : ''; - if (data.ret == 801) uni.showModal({ - title: this.translateSys("tip"), - content: tip, - showCancel: false, - confirmText: this.translateSys("cancel") - }); - else uni.showModal({ + if (data.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') + ':' + data.ret, showCancel: false, confirmText: this.translateSys("cancel") }); + this.saving =false return false } else { var tip = data.info ? typeof data.info == 'string' ? data.info : data.info.join( @@ -1885,8 +2009,10 @@ confirmText: this.translateSys("cancel") }); } + this.saving = false }).catch(ex => { // console.log(ex); + this.saving = false uni.hideLoading(); uni.showModal({ title: this.translateSys("error") + "8.1", @@ -2187,6 +2313,11 @@ display: inline-block; } + button.btn_disabled { + background-color: #ddd; + color: #888; + } + .class_attr_body .form-group { margin: 20rpx 30rpx; /* margin-left: -12px; -- Gitblit v1.9.1