From 15dcf7158d4c5d66d4b196e4e0b2030e1070d448 Mon Sep 17 00:00:00 2001 From: cuiqian2004 <cuiqian2004@163.com> Date: 星期一, 03 三月 2025 16:46:24 +0800 Subject: [PATCH] 5601 form --- pages/modal/3018_2.vue | 341 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 289 insertions(+), 52 deletions(-) diff --git a/pages/modal/3018_2.vue b/pages/modal/3018_2.vue index f91a918..ac66596 100644 --- a/pages/modal/3018_2.vue +++ b/pages/modal/3018_2.vue @@ -5,7 +5,7 @@ <uni-forms ref="baseForm" label-align="right"> <view class="v-headStyle" v-for="(item,index) in head_styledef.form.items"> <!-- 鏅�甯冨眬 --> - <uni-forms-item v-if="item.name != 'Layout'&& item.show==true" :label="item.label +'锛� " + <uni-forms-item v-if="item.name != 'Layout'&& item.show==true" :label="item.label ? item.label +'锛�:'' " :label-width="item.labelWidth+'px'"> <!-- <text class="txt_title" :style="{'width':item.labelWidth+'px'}">{{item.label}}锛�/text> --> <!-- 涓嬫媺妗�鍗曢� item.useDict?item.dict:item.selections--> @@ -36,17 +36,17 @@ </view> <!-- 澶嶉�妗�--> <checkbox-group class="check_rememberPwd" v-if="item.name=='Checkbox'" - :class="item.disabled?'input-disabled':''" @change="onModelValue(item)" - :disabled="item.disabled" :data-ischeck="item.value"> - <label> - <checkbox :value="item.value" :checked="item.value" /> - <text>{{item.label}}</text> + :class="item.disabled?'input-disabled':''" :disabled="item.disabled" + @change="onCheckBoxValue" :data-attr="item.fieldId"> + <label v-for="(item2) in item.selections" :key="item2.value"> + <checkbox :value="item2.value" :checked="item.value.includes(item2.value)" /> + <text>{{item2.label}}</text> </label> </checkbox-group> <!-- 鍗曢�妗�--> <radio-group class="check_rememberPwd" v-if="item.name=='Radio'" :class="item.disabled?'input-disabled':''" :disabled="item.disabled" - @change="onModelValue(item)"> + @change="onRadioBoxValue" :data-attr="item.fieldId"> <label v-for="(item2) in item.selections" :key="item2.value"> <radio :value="item2.value" :checked="item2.value === item.value" /> <text>{{item2.label}}</text> @@ -68,7 +68,7 @@ <uni-row class="demo-uni-row" v-if="item.name=='Layout'"> <uni-col v-for="(cols,key) in item.setting.colList" :span="item.setting.spanList?item.setting.spanList[key]:24 / item.setting.col"> - <uni-forms-item v-if="cols!=null && cols.show==true" :label="cols.label +'锛�" + <uni-forms-item v-if="cols!=null && cols.show==true" :label="cols.label? cols.label +'锛�:''" :label-width="cols.labelWidth+'px'"> <view class="input-wrapper" v-if="(cols.name=='Input' || cols.name=='InputNumber') "> <text v-if="cols.setting.prefix" class="uni-icon" :class="[cols.setting.prefix]" @@ -98,17 +98,16 @@ <!-- 澶嶉�妗�--> <checkbox-group class="check_rememberPwd" v-if="cols.name=='Checkbox'" :class="cols.disabled?'input-disabled':''" :disabled="cols.disabled" - @change="onModelValue(cols)" :data-ischeck="cols.value" - :style="{'margin-left':'10rpx'}"> - <label> - <checkbox :value="cols.value" :checked="cols.value" /> - <text>{{cols.label}}</text> + @change="onCheckBoxValue" :data-attr="cols.fieldId"> + <label v-for="(cols2) in cols.selections" :key="cols2.value"> + <checkbox :value="cols2.value" :checked="cols.value.includes(cols2.value)" /> + <text>{{cols2.label}}</text> </label> </checkbox-group> <!-- 鍗曢�妗�--> <radio-group class="check_rememberPwd" v-if="cols.name=='Radio'" :class="cols.disabled?'input-disabled':''" :disabled="cols.disabled" - @change="onModelValue(cols)"> + @change="onRadioBoxValue" :data-attr="cols.fieldId"> <label v-for="(cols2) in cols.selections" :key="cols2.value"> <radio :value="cols2.value" :checked="cols2.value === cols.value" /> <text>{{cols2.label}}</text> @@ -239,7 +238,7 @@ $this.onScanValue(ele, res.result) break; } - } else if (ele.name == "Layot") { + } else if (ele.name == "Layout") { let curIndex = (ele.setting.colList || []).findIndex((col, index2, arr) => { return (col.name == 'Input' || col.name == 'InputNumber' || col @@ -388,6 +387,24 @@ await $this.DictGetInfo(ele.bind.dict, styledefHead.form.model, ele); + } else { + if (ele?.name === "Select") { + const selections = ele?.selections || [] + //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + let itemName = ele.value || ""; + if (itemName) { + styledefHead.form + .model[ele.fieldId] = itemName; + } + ele.dict = selections.map((a) => { + return { + value: a.value, + text: a.label + } + }) + + } + } if ($this.focusFieldId == "") { if (ele.name == 'Input' || ele.name == @@ -408,6 +425,25 @@ .dict, styledefHead.form .model, col); + } else { + if (col?.name === "Select") { + const selections = col?.selections || [] + //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + let itemName = col.value || ""; + if (itemName) { + styledefHead.form + .model[col.fieldId] = itemName; + } + col.dict = selections.map((a) => { + return { + value: a.value, + text: a.label + } + }) + + + } + } if ($this.focusFieldId == "") { if (col.name == 'Input' || col @@ -482,12 +518,19 @@ formItem.dict = list; } catch (ex) { // console.log(ex); + let exStr = JSON.stringify(ex) + if (exStr == "{}") + exStr = ex + let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr + uni.showModal({ title: this.translateSys("error") + "1.3", - content: ex.errMsg, + content: tip, showCancel: false, confirmText: this.translateSys("cancel") }); + + } }, @@ -546,11 +589,31 @@ if (action.action_type == 'set_dlg_attr') { var result = action.value; $this.setFormValues(result) - } else if (data.action[i].action_type == 'set_dlg_attr_show') { + } else if (action.action_type == 'set_dlg_attr_show') { var result = action.value; $this.hideFormItems(result) - // console.log($this.$data.head_styledef); + } else if (action.action_type == + "set_dlg_current_edit_attr" + ) { + if ($this + .focusOldFieldId == + action.value) { + $this.setData({ + focusFieldId: "" + }) + } else { + $this.setData({ + focusFieldId: $this + .focusOldFieldId + }) + } + $this.$nextTick(() => { + $this.setData({ + focusFieldId: action + .value + }) + }); } else { uni.showModal({ title: this.translateSys("tip"), @@ -668,6 +731,66 @@ } this.DataObjRunCustomEvent(info, ''); } + if (item.value) { //绗竴涓緭鍏ユ涓嶄负绌�+ //鍒濆鍖栵紝涓嬩釜杈撳叆妗唂ocus灞炴� + var findd = false + for (let i in $this.head_styledef.form.items) { + const ele = $this.head_styledef.form.items[i] + + if (ele.name != "Layout") { + if (ele.name == 'Input' || ele.name == 'InputNumber') { + if (attr == ele.fieldId) { + findd = true + } else { + if (findd) { + $this.setData({ + focusFieldId: ele.fieldId + }) + break + } + + } + + } + } else { + if (findd) { + let curIndex = ele.setting.colList.findIndex((col, index2, arr) => { + return (col.name == 'Input' || col.name == 'InputNumber'); + }) + if (curIndex > -1) { + $this.setData({ + focusFieldId: ele.setting.colList[curIndex] + .fieldId + }) + break + } + + } else { + let curIndex = ele.setting.colList.findIndex((col, index2, arr) => { + return attr == col.fieldId; + }) + if (curIndex > -1) { + findd = true + let curIndex2 = ele.setting.colList.findIndex((col, index2, arr) => { + return (col.name == 'Input' || col.name == + 'InputNumber') && + index2 > + curIndex; + }) + if (curIndex2 > -1) { + $this.setData({ + focusFieldId: ele.setting.colList[curIndex] + .fieldId + }) + break + } + } + } + + } + } + } + } }, onClick(item) { @@ -707,7 +830,7 @@ }, onchange(item) { - // console.log("onchange",item); + console.log("onchange", item); if (item.oldvalue != item.value && item.value.trim() != "") { item.oldvalue = item.value; var attr = item.fieldId; @@ -741,6 +864,17 @@ onModelValue(item) { //缁戝畾Model鍊� var attr = item.fieldId; this.head_styledef.form.model[attr] = item.value; + console.log(item.value) + }, + onCheckBoxValue(e) { //缁戝畾Model鍊�+ let values = e.detail.value || [] + let attr = e.currentTarget?.dataset?.attr || "" + this.head_styledef.form.model[attr] = values; + }, + onRadioBoxValue(e) { //缁戝畾Model鍊�+ let value = e.detail.value || "" + let attr = e.currentTarget?.dataset?.attr || "" + this.head_styledef.form.model[attr] = value; }, classAttr_extButton(item) { var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent; //鍚庡浘鏍囩偣鍑讳簨浠�@@ -768,7 +902,7 @@ // open 鏂规硶浼犲叆鍙傛暟 绛夊悓鍦�uni-popup 缁勪欢涓婄粦瀹�type灞炴� this.$refs.popup.open(this.popupType); - this.dataObjRunCustomEvent_Return(onSuffixClickCallbackEvent.id, '', onSuffixClickEvent.id, + this.dataObjRunCustomEvent_Return(onSuffixClickEvent.id, '', onSuffixClickCallbackEvent.id, item); }, popupChange(e) { @@ -961,6 +1095,27 @@ // console.log($this.$data.head_styledef); } else if (action.action_type == 'set_global_attr') { $this.$data.global_attr = action.value || []; + } else if (action.action_type == + "set_dlg_current_edit_attr" + ) { + if ($this + .focusOldFieldId == + action.value) { + $this.setData({ + focusFieldId: "" + }) + } else { + $this.setData({ + focusFieldId: $this + .focusOldFieldId + }) + } + $this.$nextTick(() => { + $this.setData({ + focusFieldId: action + .value + }) + }); } else { uni.showModal({ title: this.translateSys("tip"), @@ -1470,12 +1625,15 @@ showCancel: false, confirmText: this.translateSys("cancel") }); + else { - uni.showToast({ - title: this.translate('create_success'), - icon: "success", - duration: 3000 - }); + uni.showToast({ + title: this.translate('create_success'), + icon: "success", + duration: 3000 + }); + } + if (!this.$data.param.After_Btn_Not_Refresh) { //鍒锋柊 @@ -1492,28 +1650,50 @@ var action = actionlist[i]; if (action.action_type == 'set_dlg_attr') { $this.setFormValues(action.value) - } else if (data.action[i].action_type == 'set_dlg_attr_show') { + } else if (action.action_type == 'set_dlg_attr_show') { var result = action.value; $this.hideFormItems(result) + } else if (action.action_type == + "set_dlg_current_edit_attr" + ) { + if ($this + .focusOldFieldId == + action.value) { + $this.setData({ + focusFieldId: "" + }) + } else { + $this.setData({ + focusFieldId: $this + .focusOldFieldId + }) + } + $this.$nextTick(() => { + $this.setData({ + focusFieldId: action + .value + }) + }); } } } } } - - // this.class_attr_init(); this.saving = false }).catch(ex => { - console.log(ex); this.saving = false uni.hideLoading(); + let exStr = JSON.stringify(ex) + if (exStr == "{}") + exStr = ex + let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr uni.showModal({ title: this.translateSys("tip"), - content: ex.errMsg, + content: tip, showCancel: false, confirmText: this.translateSys("cancel") }); @@ -1762,10 +1942,32 @@ var action = actionlist[i]; if (action.action_type == 'set_dlg_attr') { $this.setFormValues(action.value) - } else if (data.action[i].action_type == 'set_dlg_attr_show') { + } else if (action.action_type == 'set_dlg_attr_show') { var result = action.value; $this.hideFormItems(result) + } else if (action.action_type == + "set_dlg_current_edit_attr" + ) { + if ($this + .focusOldFieldId == + action.value) { + $this.setData({ + focusFieldId: "" + }) + } else { + $this.setData({ + focusFieldId: $this + .focusOldFieldId + }) + } + $this.$nextTick(() => { + $this.setData({ + focusFieldId: action + .value + }) + }); } + } } } @@ -1775,9 +1977,13 @@ }).catch(ex => { // console.log(ex); this.saving = false + let exStr = JSON.stringify(ex) + if (exStr == "{}") + exStr = ex + let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr uni.showModal({ title: this.translateSys('tip') + "7.1", - content: ex.errMsg, + content: tip, showCancel: false, confirmText: this.translateSys("cancel") }); @@ -1893,28 +2099,61 @@ showCancel: false, confirmText: this.translateSys("cancel") }); + if (!this.$data.param.After_Btn_Not_Refresh) { + //鍒锋柊 + uni.redirectTo({ + url: '../modal/3018_2?param=' + JSON.stringify(this.$data + .param) + + "&titlename=" + this.$data.title + }); + } else { + var actionlist = data.action; + if (actionlist) { + console.log(actionlist); + for (var i = 0; i < actionlist.length; i++) { + var action = actionlist[i]; + if (action.action_type == 'set_dlg_attr') { + $this.setFormValues(action.value) + } else if (action.action_type == 'set_dlg_attr_show') { + var result = action.value; + $this.hideFormItems(result) + } else if (action.action_type == + "set_dlg_current_edit_attr" + ) { + if ($this + .focusOldFieldId == + action.value) { + $this.setData({ + focusFieldId: "" + }) + } else { + $this.setData({ + focusFieldId: $this + .focusOldFieldId + }) + } + $this.$nextTick(() => { + $this.setData({ + focusFieldId: action + .value + }) + }); + } - var actionlist = data.action; - if (actionlist) { - console.log(actionlist); - for (var i = 0; i < actionlist.length; i++) { - var action = actionlist[i]; - if (action.action_type == 'set_dlg_attr') { - $this.setFormValues(action.value) - } else if (data.action[i].action_type == 'set_dlg_attr_show') { - var result = action.value; - $this.hideFormItems(result) } } } - } }).catch(ex => { // console.log(ex); + let exStr = JSON.stringify(ex) + if (exStr == "{}") + exStr = ex + let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr uni.showModal({ title: this.translateSys('tip') + "7.1", - content: ex.errMsg, + content: tip, showCancel: false, confirmText: this.translateSys("cancel") }); @@ -1933,7 +2172,6 @@ const url = '../modal/3018?param=' + JSON.stringify(data) + "&titlename=" + btn.Edit_dlg .Name + "&type=addDataObj" - console.log("showAddSmallDialog", url); var $this = this; uni.navigateTo({ url: url, @@ -1942,13 +2180,12 @@ addDataObj: function(resData) { console.log(resData); //鍒锋柊 - if (!this.$data.param.After_Btn_Not_Refresh) { - uni.redirectTo({ - url: '../modal/3018_2?param=' + JSON.stringify(this - .$data.param) + - "&titlename=" + this.$data.title - }); - } + uni.redirectTo({ + url: '../modal/3018_2?param=' + JSON.stringify(this + .$data.param) + + "&titlename=" + this.$data.title + }); + }, } }); -- Gitblit v1.9.1