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 | 2 pages/modal/3018.vue | 42 ++-- pages/modal/5601.vue | 175 ++++++++----------- manifest.json | 4 pages/modal/form/index.vue | 263 ++++++++++++---------------- 5 files changed, 212 insertions(+), 274 deletions(-) diff --git a/manifest.json b/manifest.json index 93a9130..ef45b9f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "MoboxPDA", "appid" : "__UNI__56D451E", "description" : "", - "versionName" : "1.1.42", - "versionCode" : 1142, + "versionName" : "1.1.43", + "versionCode" : 1143, "transformPx" : false, /* 5+App鐗规湁鐩稿叧 */ "app-plus" : { diff --git a/pages/modal/3018.vue b/pages/modal/3018.vue index e11dc14..50986af 100644 --- a/pages/modal/3018.vue +++ b/pages/modal/3018.vue @@ -327,7 +327,7 @@ }, data() { return { - title: this.translateSys('add2'), + title: this.translateSys('ok'), editMode: false, objAttr: {}, param: {}, @@ -523,40 +523,40 @@ } }, async loadFormData(objAttr) { - let formData + let attrs = [] if (this.param.objid) { let info = await dataObjInfo({ class_id: this.param.clsid, obj_id: this.param.objid, }); - formData = {}; - formData["id"] = info.id; - formData["state"] = info.state; + attrs = [{ + attr: "id", + value: info.id + }, { + attr: "state", + value: info.state + }] info.attr_list.forEach(({ name, value }) => { - formData[name] = value; + attrs.push({ + attr: name, + value: value + }) }); + this.setFormValues(attrs) } else if (objAttr) { - formData = {}; Object.keys(objAttr).forEach((attr) => { - let value = objAttr[attr]; - formData[attr] = value; + attrs.push({ + attr: attr, + value: objAttr[attr] + }) }); + this.setFormValues(attrs) } - //浼犲叆鍙傛暟鍊�- if (formData) { - var attrlist = this.$data.classAttrList; - for (var i = 0; i < attrlist.length; i++) { - var attr = attrlist[i].Attr; - for (var j = 0; j < attr.length; j++) { - var ar = attr[j]; - ar.Value = formData[ar.Name] || "" - } - } - this.$data.classAttrList = attrlist; - } + + }, async viewParam() { //灏唌obox3灏忓啓鍙傛暟杞崲涓簃obox2澶у啓鍙傛暟 try { diff --git a/pages/modal/3018_2.vue b/pages/modal/3018_2.vue index ab196d0..ac66596 100644 --- a/pages/modal/3018_2.vue +++ b/pages/modal/3018_2.vue @@ -902,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) { diff --git a/pages/modal/5601.vue b/pages/modal/5601.vue index c8553f1..a6024ec 100644 --- a/pages/modal/5601.vue +++ b/pages/modal/5601.vue @@ -7,7 +7,7 @@ <uni-forms-item v-if="item.name != 'Layout'" :label="item.label ?item.label +'锛�:'' " :label-width="item.labelWidth+'px'"> <uni-data-picker v-if="item.name=='Select'" :class="item.disabled?'input-disabled':''" - v-model="item.value" :localdata="item.dict" @change="onEnterChange(item)" + v-model="item.value" :localdata="item.useDict ? item.dict : item.selections" @change="onEnterChange(item)" :readonly="item.disabled" :clear-icon="false" :popup-title="item.label"></uni-data-picker> <view class="input-wrapper" v-if="item.name=='Input' || item.name=='InputNumber'"> <text v-if="item.setting.prefix" class="uni-icon" :class="[item.setting.prefix]" @@ -48,9 +48,9 @@ <uni-col :span=" item.setting.spanList && item.setting.spanList[key]? item.setting.spanList[key] : 24 / item.setting.col" v-for="(col,key) in item.setting.colList"> - <uni-forms-item :label="col.label ? col.label +'锛�:''" :label-width="col.labelWidth+'px'"> + <uni-forms-item v-if="col!=null" :label="col.label ? col.label +'锛�:''" :label-width="col.labelWidth+'px'"> <uni-data-picker v-if="col.name=='Select'" :class="col.disabled?'input-disabled':''" - v-model="col.value" :localdata="col.dict" @change="onEnterChange(col)" + v-model="col.value" :localdata="col.useDict ? col.dict : col.selections" @change="onEnterChange(col)" :readonly="col.disabled" :clear-icon="false" :popup-title="col.label"></uni-data-picker> <view class="input-wrapper" v-if="col.name=='Input' || col.name=='InputNumber'"> <text v-if="col.setting.prefix" class="uni-icon" :class="[col.setting.prefix]" @@ -536,7 +536,8 @@ styledefHead.form .model[ele.fieldId] = itemName; } - ele.dict = selections.map((a) => { + + ele.selections = selections.map((a) => { return { value: a.value, text: a.label @@ -573,7 +574,7 @@ styledefHead.form .model[col.fieldId] = itemName; } - col.dict = selections.map((a) => { + col.selections = selections.map((a) => { return { value: a.value, text: a.label @@ -645,6 +646,13 @@ detailstyledef.form .model, ele); } + else + { + if (ele?.name === "Select") { + ele.selections =[] + } + } + } else { for (let j in ele.setting.colList) { const col = ele.setting.colList[j] @@ -653,6 +661,12 @@ .bind.dict, detailstyledef.form .model, col); + } + else + { + if (col?.name === "Select") { + col.selections =[] + } } } } @@ -905,7 +919,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); }, @@ -1029,7 +1043,6 @@ }; runCustomEvent(dataInfo).then(result => { console.log(result); - if (result.ret != 0) { var tip = result.err_info ? typeof result .err_info == 'string' ? result @@ -1718,109 +1731,74 @@ } }, - setFormValues(data) { + setFormValues(attrs) { const head_styledef = this.head_styledef - if (JSON.stringify(data) == '{}') { + if (JSON.stringify(attrs) == '{}') { return; } - head_styledef.form.items.forEach(async (ele, index) => { - if (ele.name != "Layout") { - let curIndex = data.findIndex((attr, index2, arr) => { - return attr.attr == ele.fieldId; - }) - if (curIndex > -1) { - const attr = data[curIndex] - if (ele.name == - 'Select' && - attr - .choice_list - ) { - const - dictItemList = []; - const - choiceList = - attr - .choice_list || []; - for (let d in - choiceList) { - const - val = - choiceList[ - d - ]; - dictItemList - .push({ - text: val, - value: val - }); + console.log(attrs) + attrs.forEach(async (attr, key) => { + if (attr.choice_list) { + var dictItemList = []; + attr.choice_list.forEach(async (val, index) => { + dictItemList.push({ + text: val, + value: val + }); + }); + + head_styledef.form.items.forEach(async (attr_item, index) => { + if (attr_item.name != "Layout") { + if (attr_item.fieldId == attr.attr) { + if (attr_item.useDict) { + attr_item.dict = dictItemList; + } else { + attr_item.selections = dictItemList; + } } - ele.dict = - dictItemList; - } - - ele.value = - attr - .value; - } - } else { - ele.setting - .colList - .forEach( - async ( - col - ) => { - if ( - col) { - let curIndex = data.findIndex(( - attr, index2, arr) => { - return attr.attr == col.fieldId; - }) - if (curIndex > -1) { - const attr = data[curIndex] - if (col.name == - 'Select' && - attr - .choice_list - ) { - const - dictItemList = []; - const - choiceList = - attr - .choice_list || []; - for (let d in - choiceList) { - const - val = - choiceList[ - d - ]; - dictItemList - .push({ - text: val, - value: val - }); - } - col.dict = - dictItemList; + } else if (attr_item.name == "Layout") { + attr_item.setting.colList.forEach((col) => { + if (col) { + if (col.fieldId == attr.attr) { + if (col.useDict) { + col.dict = dictItemList; + } else { + col.selections = dictItemList; } - - col.value = - attr - .value; } } - - }) - + }); + } + }); } - }) + if (!head_styledef.form.model[attr.attr]) { + head_styledef.form.model[attr.attr] = attr.value; + } + head_styledef.form.items.forEach(async (ele) => { + if (ele.name != "Layout") { + if (ele.fieldId == attr.attr) { + ele.value = attr.value; + ele.oldvalue = attr.value; + } + } else if (ele.name == "Layout") { + ele.setting.colList.forEach((col) => { + if (col) { + if (col.fieldId == attr.attr) { + col.value = attr.value; + col.oldvalue = attr.value; + } + } + }); + } + }) + //鍒ゆ柇琛ㄥ崟閲屾槸鍚︽湁杩斿洖瀛楁锛屾病鏈夊氨瑁呰浇鍒癿odel閲岋紝鐐瑰嚮纭畾鎻愪氦鐨勬椂鍊欏甫涓婅繖浜涙暟鎹�+ }) + console.log(head_styledef) this.setData({ head_styledef: head_styledef }) }, - onClickItem(e) { //閫夋嫨椤电 // console.log(e); this.current = e.currentIndex @@ -2728,8 +2706,7 @@ objAttr[item.fieldId] = item.value; }); - const url = `../modal/form/index?param=${JSON.stringify(btn)}&titlename=${btn.Edit_dlg - .Name}&editMode=1&objAttr=${JSON.stringify(objAttr)}&type=updateDataObj` + const url = `../modal/form/index?param=${JSON.stringify(btn)}&titlename=${btn.ShowName}&editMode=1&objAttr=${JSON.stringify(objAttr)}&type=updateDataObj` var $this = this; uni.navigateTo({ url: url, diff --git a/pages/modal/form/index.vue b/pages/modal/form/index.vue index 2e3cda5..d2c24d3 100644 --- a/pages/modal/form/index.vue +++ b/pages/modal/form/index.vue @@ -8,7 +8,7 @@ <uni-forms-item v-if="item.name != 'Layout'" :label="item.label ?item.label +'锛�:'' " :label-width="item.labelWidth+'px'"> <uni-data-picker v-if="item.name=='Select'" :class="item.disabled?'input-disabled':''" - v-model="item.value" :localdata="item.dict" @change="onEnterChange(item)" + v-model="item.value" :localdata="item.useDict ? item.dict : item.selections" @change="onEnterChange(item)" :readonly="item.disabled" :clear-icon="false" :popup-title="item.label"></uni-data-picker> <view class="input-wrapper" v-if="item.name=='Input' || item.name=='InputNumber'"> <text v-if="item.setting.prefix" class="uni-icon" :class="[item.setting.prefix]" @@ -50,9 +50,9 @@ <uni-col :span=" item.setting.spanList && item.setting.spanList[key]? item.setting.spanList[key] : 24 / item.setting.col" v-for="(col,key) in item.setting.colList"> - <uni-forms-item :label="col.label ? col.label +'锛�:''" :label-width="col.labelWidth+'px'"> + <uni-forms-item v-if="col!=null" :label="col.label ? col.label +'锛�:''" :label-width="col.labelWidth+'px'"> <uni-data-picker v-if="col.name=='Select'" :class="col.disabled?'input-disabled':''" - v-model="col.value" :localdata="col.dict" @change="onEnterChange(col)" + v-model="col.value" :localdata="col.useDict ? col.dict : col.selections" @change="onEnterChange(col)" :readonly="col.disabled" :clear-icon="false" :popup-title="col.label"></uni-data-picker> <view class="input-wrapper" v-if="col.name=='Input' || col.name=='InputNumber'"> @@ -147,7 +147,7 @@ }, data() { return { - okLoading:false, + okLoading: false, title: this.translateSys('add2'), type: '', editMode: false, @@ -158,7 +158,8 @@ focusOldFieldId: "", head_styledef: { form: { - items: [] + items: [], + model: {} } }, global_attr: [], @@ -230,7 +231,7 @@ this.ext_info = JSON.parse(options.extInfo); if (options.dataJson) this.data_json = JSON.parse(options.dataJson); - this.title = this.param.ShowName? this.param.ShowName : options.titlename; //璁剧疆鎸夐挳鏂囧瓧 + this.title = options.titlename ? options.titlename : this.param.ShowName; //璁剧疆鎸夐挳鏂囧瓧 // console.log(options) uni.setNavigationBarTitle({ title: this.title @@ -318,7 +319,7 @@ styledefHead.form .model[ele.fieldId] = itemName; } - ele.dict = selections.map((a) => { + ele.selections = selections.map((a) => { return { value: a.value, text: a.label @@ -355,7 +356,7 @@ styledefHead.form .model[col.fieldId] = itemName; } - col.dict = selections.map((a) => { + col.selections = selections.map((a) => { return { value: a.value, text: a.label @@ -437,54 +438,42 @@ }, async loadFormData(objAttr) { - let formData + let attrs = [] + if (this.objId) { let info = await dataObjInfo({ class_id: this.clsId, obj_id: this.objId, }); - formData = {}; - formData["id"] = info.id; - formData["state"] = info.state; + + attrs = [{ + attr: "id", + value: info.id + }, { + attr: "state", + value: info.state + }] info.attr_list.forEach(({ name, value }) => { - formData[name] = value; - }); - } else if (objAttr) { - formData = {}; - Object.keys(objAttr).forEach((attr) => { - let value = objAttr[attr]; - formData[attr] = value; - }); - } - //浼犲叆鍙傛暟鍊�- if (formData) { - if (this.head_styledef?.form) { - const items = this.head_styledef?.form?.items || [] - const model = this.head_styledef?.form?.model || {} - Object.assign(model, formData); - items.forEach(async (ele, index) => { - if (ele.name != "Layout") { - let value = formData[ele.fieldId] - if (value) - ele.value = value - - } else { - ele.setting.colList.forEach(async (col) => { - if (col) { - let value = formData[col.fieldId] - if (value) - col.value = value - } - }); - } + attrs.push({ + attr: name, + value: value }) - this.$data.head_styledef.form.model = model - this.$data.head_styledef.form.items = items - } + }); + this.setFormValues(attrs) + } else if (objAttr) { + Object.keys(objAttr).forEach((attr) => { + attrs.push({ + attr: attr, + value: objAttr[attr] + }) + }); + this.setFormValues(attrs) } + + }, async loadInitialEvent() { try { @@ -810,7 +799,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); }, @@ -983,110 +972,72 @@ } }, - setFormValues(data) { + setFormValues(attrs) { + console.log(attrs) const head_styledef = this.head_styledef - if (JSON.stringify(data) == '{}') { + if (JSON.stringify(attrs) == '{}') { return; } - head_styledef.form.items.forEach(async (ele, index) => { - if (ele.name != "Layout") { - let curIndex = data.findIndex((attr, index2, arr) => { - return attr.attr == ele.fieldId; - }) - if (curIndex > -1) { - const attr = data[curIndex] - if (ele.name == - 'Select' && - attr - .choice_list - ) { - const - dictItemList = []; - const - choiceList = - attr - .choice_list || []; - for (let d in - choiceList) { - const - val = - choiceList[ - d - ]; - dictItemList - .push({ - text: val, - value: val - }); + attrs.forEach(async (attr, key) => { + if (attr.choice_list) { + var dictItemList = []; + attr.choice_list.forEach(async (val, index) => { + dictItemList.push({ + text: val, + value: val + }); + }); + head_styledef.form.items.forEach(async (attr_item, index) => { + if (attr_item.name != "Layout") { + if (attr_item.fieldId == attr.attr) { + if (attr_item.useDict) { + attr_item.dict = dictItemList; + } else { + attr_item.selections = dictItemList; + } } - ele.dict = - dictItemList; - } - - ele.value = - attr - .value; - } - } else { - ele.setting - .colList - .forEach( - async ( - col - ) => { - if ( - col) { - let curIndex = data.findIndex(( - attr, index2, arr) => { - return attr.attr == col.fieldId; - }) - if (curIndex > -1) { - const attr = data[curIndex] - if (col.name == - 'Select' && - attr - .choice_list - ) { - const - dictItemList = []; - const - choiceList = - attr - .choice_list || []; - for (let d in - choiceList) { - const - val = - choiceList[ - d - ]; - dictItemList - .push({ - text: val, - value: val - }); - } - col.dict = - dictItemList; + } else if (attr_item.name == "Layout") { + attr_item.setting.colList.forEach((col) => { + if (col) { + if (col.fieldId == attr.attr) { + if (col.useDict) { + col.dict = dictItemList; + } else { + col.selections = dictItemList; } - - col.value = - attr - .value; } } - - }) - + }); + } + }); } - }) + head_styledef.form.model[attr.attr] = attr.value; + head_styledef.form.items.forEach(async (ele, index) => { + if (ele.name != "Layout") { + if (ele.fieldId == attr.attr) { + ele.value = attr.value; + ele.oldvalue = attr.value; + } + } else if (ele.name == "Layout") { + ele.setting.colList.forEach((col) => { + if (col) { + if (col.fieldId == attr.attr) { + col.value = attr.value; + col.oldvalue = attr.value; + } + } + }); + } + }) + + //鍒ゆ柇琛ㄥ崟閲屾槸鍚︽湁杩斿洖瀛楁锛屾病鏈夊氨瑁呰浇鍒癿odel閲岋紝鐐瑰嚮纭畾鎻愪氦鐨勬椂鍊欏甫涓婅繖浜涙暟鎹�+ }) + console.log(head_styledef) this.setData({ head_styledef: head_styledef }) }, - - popupChange(e) { console.log('褰撳墠妯″紡锛� + e.type + ',鐘舵�锛� + e.show); }, @@ -1718,7 +1669,7 @@ }); this.okLoading = true var obj_attr = this.head_styledef.form.model || {}; - console.log(obj_attr) + console.log(obj_attr) let ret = await this.sava(); this.okLoading = false uni.hideLoading(); @@ -1881,7 +1832,7 @@ async afterOK() { try { - var obj_attr = this.head_styledef.form.model ||{} + var obj_attr = this.head_styledef.form.model || {} // console.log(obj_attr); var input_param = { id: "", @@ -1930,7 +1881,7 @@ }, - async cancel(e) { //鍙栨秷 + async cancel(e) { //鍙栨秷 try { if (!this.objId) { if (this.editMode) { @@ -1962,9 +1913,12 @@ value: obj_attr[a], })), }; - let input_param = Base64.encode(JSON.stringify(inputParam)); - let global_attr = Base64.encode(JSON.stringify(this.global_attr)) - let data_json = Base64.encode(JSON.stringify(this.data_json)) + let input_param = Base64.encode(JSON.stringify( + inputParam)); + let global_attr = Base64.encode(JSON.stringify(this + .global_attr)) + let data_json = Base64.encode(JSON.stringify(this + .data_json)) let ext_info = Base64.encode(JSON.stringify(this.ext_info)) await runCustomEvent({ @@ -2005,10 +1959,14 @@ value: obj_attr[a], })), }; - let input_param = Base64.encode(JSON.stringify(inputParam)); - let global_attr = Base64.encode(JSON.stringify(this.global_attr)) - let data_json = Base64.encode(JSON.stringify(this.data_json)) - let ext_info = Base64.encode(JSON.stringify(this.ext_info)) + let input_param = Base64.encode(JSON.stringify( + inputParam)); + let global_attr = Base64.encode(JSON.stringify(this + .global_attr)) + let data_json = Base64.encode(JSON.stringify(this + .data_json)) + let ext_info = Base64.encode(JSON.stringify(this + .ext_info)) await runCustomEvent({ ed_type: 0, @@ -2027,7 +1985,8 @@ let exStr = JSON.stringify(ex) if (exStr == "{}") exStr = ex - let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr + let tip = typeof ex.errMsg == "string" ? ex.errMsg : + exStr uni.showModal({ title: this.translateSys("tip") + "8.2", content: tip, @@ -2038,11 +1997,13 @@ } }, translate(t) { - if (typeof this.$t == "function") return this.$t(`page.${t}`) + if (typeof this.$t == "function") return this.$t( + `page.${t}`) else return t; }, translateSys(t) { - if (typeof this.$t == "function") return this.$t(`sys.${t}`) + if (typeof this.$t == "function") return this.$t( + `sys.${t}`) else return t; }, }, @@ -2119,7 +2080,7 @@ margin: 0 10rpx; // padding: 5rpx 10rpx; background: #4D6AF4; - font-size: 38rpx; + font-size: 38rpx; border: none; color: #fff; float: left; -- Gitblit v1.9.1