From e8b665122cf256caae4993534c696d029883f0d5 Mon Sep 17 00:00:00 2001 From: cuiqian2004 <cuiqian2004@163.com> Date: 星期三, 05 三月 2025 10:52:03 +0800 Subject: [PATCH] showmodal cancal 改成 close --- pages/modal/form/index.vue | 354 ++++++++++++++++++++++++++-------------------------------- 1 files changed, 160 insertions(+), 194 deletions(-) diff --git a/pages/modal/form/index.vue b/pages/modal/form/index.vue index 2e3cda5..72ffda4 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'"> @@ -104,8 +104,9 @@ <uni-popup class="view-popup" ref="popup" background-color="#fff" @change="popupChange"> <view class="popup-header">{{check_list.title}}</view> <view class="popup-content" :class="{ 'popup-height': popupType === 'left' || popupType === 'right' }" - :style="{'width':check_list.width?check_list.width+'px':'200px','height':check_list.height?check_list.height+'px':'88%'}"> - <view class="popup-cont" :style="{'height':check_list.height?check_list.height-45+'px':'415px'}"> + :style="{'width':check_list.width?check_list.width+'px':'375rpx','height':check_list.height?check_list.height+'px':popupType =='center'?'60vh':'88vh'}"> + <view class="popup-cont" + :style="{'height':check_list.height?check_list.height-45+'px':popupType =='center'?'50vh':'80vh'}"> <view class="view_popup_CheckList" v-for="(item,index) in check_list.items"> <checkbox-group class="check_list" @change="checkChange" :data-ischeck="item.check" :data-index="index" :style="{'margin-left': '10rpx'}"> @@ -117,7 +118,7 @@ </view> </view> <view class="popup-footer"> - <button type="default" @tap="popup_sava" class="btn_popup_add">{{translateSys('ok')}}</button> + <button type="primary" @tap="popup_sava" class="btn_popup_add">{{translateSys('ok')}}</button> <button type="default" @tap="popup_cancel" class="btn_popup_cancel">{{translateSys('cancel')}}</button> </view> @@ -147,7 +148,7 @@ }, data() { return { - okLoading:false, + okLoading: false, title: this.translateSys('add2'), type: '', editMode: false, @@ -158,7 +159,8 @@ focusOldFieldId: "", head_styledef: { form: { - items: [] + items: [], + model: {} } }, global_attr: [], @@ -230,7 +232,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 @@ -243,7 +245,7 @@ title: this.translateSys("error"), content: this.translate("tip_no_master_class"), showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); } }, @@ -318,7 +320,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 +357,7 @@ styledefHead.form .model[col.fieldId] = itemName; } - col.dict = selections.map((a) => { + col.selections = selections.map((a) => { return { value: a.value, text: a.label @@ -393,7 +395,7 @@ title: $this.translateSys('tip') + "1", content: exStr, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); } @@ -431,60 +433,48 @@ title: this.translateSys("error") + "3", content: ex.errMsg, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); } }, 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 { @@ -529,7 +519,7 @@ content: tip, showCancel: false, confirmText: this.translateSys( - "cancel") + 'close') }); } else uni.showModal({ title: this.translateSys('tip'), @@ -539,7 +529,7 @@ .ret, showCancel: false, confirmText: this.translateSys( - "cancel") + 'close') }); return false; } else { @@ -551,7 +541,7 @@ content: tip, showCancel: false, confirmText: this.translateSys( - "cancel") + 'close') }); if (result.result_type == 0 && result.action) { @@ -595,7 +585,7 @@ content: result.info, showCancel: false, confirmText: this - .translateSys("cancel") + .translateSys('close') }); } } @@ -612,7 +602,7 @@ title: $this.translateSys('tip') + "2", content: exStr, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); } }, @@ -793,7 +783,7 @@ title: this.translateSys("tip"), content: this.translate('icon_click_callback_empty'), showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return; } @@ -802,7 +792,7 @@ title: this.translateSys("tip"), content: this.translate('icon_click_event_empty'), showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return; } @@ -810,7 +800,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); }, @@ -883,7 +873,7 @@ content: tip, showCancel: false, confirmText: this.translateSys( - "cancel") + 'close') }); } else uni.showModal({ title: this.translateSys('tip'), @@ -893,7 +883,7 @@ .ret, showCancel: false, confirmText: this.translateSys( - "cancel") + 'close') }); return false; } else { @@ -905,7 +895,7 @@ content: tip, showCancel: false, confirmText: this.translateSys( - "cancel") + 'close') }); if (result.result_type == 0 && result.action) { @@ -949,7 +939,7 @@ content: result.info, showCancel: false, confirmText: this - .translateSys("cancel") + .translateSys('close') }); } } @@ -963,7 +953,7 @@ title: this.translateSys("error") + "4.1", content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); }); } @@ -978,115 +968,77 @@ this.translate('reason') + this.translateSys("colon") + tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); } }, - 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); }, @@ -1129,7 +1081,7 @@ title: this.translateSys("tip"), content: "popupParam涓虹┖锛�, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return; } @@ -1138,7 +1090,7 @@ title: this.translateSys("tip"), content: this.translate("tip_no_select_data"), showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return; } @@ -1237,14 +1189,14 @@ title: this.translateSys("tip"), content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); } else uni.showModal({ title: this.translateSys("tip"), content: tip + ',' + this.translateSys('tip') + ':' + data .ret, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } else { @@ -1256,7 +1208,7 @@ title: this.translateSys("tip"), content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); var actionlist = data.action; @@ -1319,7 +1271,7 @@ .translate( "tip_action_unprocessed"), showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); } } @@ -1396,7 +1348,7 @@ title: this.translateSys("error") + "3.1", content: exStr, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); }); }, @@ -1484,14 +1436,14 @@ title: $this.translateSys("tip"), content: tip, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); } else uni.showModal({ title: $this.translateSys("tip"), content: tip + ',' + $this.translateSys('tip') + ':' + data .ret, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); return false } else { @@ -1503,7 +1455,7 @@ title: $this.translateSys("tip"), content: tip, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); if (data != "") { @@ -1677,7 +1629,7 @@ .translate( "tip_action_unprocessed"), showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); } } @@ -1690,7 +1642,7 @@ "quotation_mark_right") + $this.translateSys( "comma") + 'event_id' + eventid, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); } } @@ -1705,7 +1657,7 @@ title: $this.translateSys('tip') + "5.1", content: exStr, showCancel: false, - confirmText: $this.translateSys("cancel") + confirmText: $this.translateSys('close') }); }); }, @@ -1718,7 +1670,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(); @@ -1818,7 +1770,7 @@ title: this.translateSys('tip') + "7.1", content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } @@ -1845,7 +1797,7 @@ title: this.translateSys("tip") + "6.1", content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } @@ -1872,7 +1824,7 @@ title: this.translateSys("tip") + "6.2", content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } @@ -1881,7 +1833,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: "", @@ -1923,14 +1875,14 @@ title: this.translateSys('tip') + "7.2", content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } }, - async cancel(e) { //鍙栨秷 + async cancel(e) { //鍙栨秷 try { if (!this.objId) { if (this.editMode) { @@ -1962,9 +1914,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({ @@ -1989,7 +1944,7 @@ title: this.translateSys("tip") + "8.1", content: tip, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } @@ -2005,10 +1960,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,22 +1986,25 @@ 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, showCancel: false, - confirmText: this.translateSys("cancel") + confirmText: this.translateSys('close') }); return false } }, 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 +2081,7 @@ margin: 0 10rpx; // padding: 5rpx 10rpx; background: #4D6AF4; - font-size: 38rpx; + font-size: 38rpx; border: none; color: #fff; float: left; @@ -2134,8 +2096,10 @@ .btn_cancel { width: 45%; margin: 0 10rpx; + // background: #fff; + // border: none; + // color: #000; background: #fff; - border: none; color: #000; font-size: 38rpx; float: right; @@ -2193,7 +2157,7 @@ .popup-footer { float: right; position: absolute; - bottom: 0; + bottom:10rpx; right: 20rpx; } @@ -2217,9 +2181,11 @@ margin-top: 50rpx; padding: 15rpx; line-height: 1.5; - background: #27A6E1; - border: none; - color: #fff; + // background: #27A6E1; + // border: none; + // color: #fff; + background: #fff; + color: #000; font-size: 38rpx; font-weight: bold; /* float: right; */ -- Gitblit v1.9.1