From 266c8c8490a8d82e18dfc8c51aa85c3067771640 Mon Sep 17 00:00:00 2001 From: cyy <cuiqian2004@163.com> Date: 星期六, 03 八月 2024 09:56:51 +0800 Subject: [PATCH] 3018_2 dict --- pages/modal/3018_2.vue | 94 +++++++++++++++++++++++++++++------------------ 1 files changed, 58 insertions(+), 36 deletions(-) diff --git a/pages/modal/3018_2.vue b/pages/modal/3018_2.vue index 2ddbb08..34ff757 100644 --- a/pages/modal/3018_2.vue +++ b/pages/modal/3018_2.vue @@ -332,23 +332,49 @@ .result .style_def); } - $this.$data.head_styledef = ret.result.style_def ? JSON.parse(styledef) : {}; - // console.log($this.$data.head_styledef); - $this.head_styledef.form.items.forEach(async (ele, index) => { - ele.show = true; - if (ele.useDict == true) { //鍒ゆ柇useDict鏄惁浣跨敤瀛楀吀 - await this.DictGetInfo(ele.bind.dict, index, 'mast'); - } - if ($this.focusFieldId == "") { - if (ele.name == 'Input' || ele.name == 'InputNumber' || ele.name == - 'Textarea') { - $this.setData({ - focusFieldId: ele.fieldId - }) + const styledefHead = styledef ? JSON.parse(styledef) : {}; + + styledefHead.form.items.forEach(async (ele) => { + if (ele.name != "Layout") { + if (ele?.useDict) { + //鍒ゆ柇useDict鏄惁浣跨敤瀛楀吀 + await this.DictGetInfo(ele.bind.dict, + styledefHead.form.model, + ele); } + if ($this.focusFieldId == "") { + if (ele.name == 'Input' || ele.name == + 'InputNumber') { + $this.setData({ + focusFieldId: ele.fieldId + }) + } + } + } else { + ele.setting.colList.forEach(async (col) => { + if (col?.useDict) { + //鍒ゆ柇useDict鏄惁浣跨敤瀛楀吀 + await this.DictGetInfo(col.bind + .dict, + styledefHead.form + .model, col); + } + if ($this.focusFieldId == "") { + if (col.name == 'Input' || col + .name == + 'InputNumber') { + $this.setData({ + focusFieldId: col + .fieldId + }) + } + } + }); } - }); + this.setData({ + head_styledef: styledefHead + }) if ($this.head_styledef.event?.length > 0) { $this.head_styledef.event.forEach(async (a) => { //鍒ゆ柇鏄惁鏄垵濮嬪寲浜嬩欢 if (a.event_id == "initial") { @@ -381,7 +407,7 @@ }); }, - async DictGetInfo(dict, index, type) { //Mobox3寰楀埌寰楀埌瀛楀吀淇℃伅瀛楀吀椤瑰垪琛�+ async DictGetInfo(dict, formModel, formItem) { //Mobox3寰楀埌寰楀埌瀛楀吀淇℃伅瀛楀吀椤瑰垪琛� this.data = []; var $this = this; var dataInfo = { @@ -392,30 +418,26 @@ 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, - }); + + 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; + }); + //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + if (itemName) { + formItem.value = itemName; + formModel[formItem.fieldId] = itemName; + } + formItem.dict = list; // $this.head_styledef.form.items[index].dictitem=success.result; // this.$store.commit("classAttrList", $this.$data.classAttrList); - } else { - // $this.$data.subClassAttrList[index].attr_list[key].dictitem=success.result; - // this.$store.commit("subClassAttrList", $this.$data.subClassAttrList); - } + } else { uni.showModal({ -- Gitblit v1.9.1