From b0041cf10ba3ddf74b9edcfd340a7d1c9179d878 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期一, 03 三月 2025 18:48:19 +0800
Subject: [PATCH] 5601 form

---
 pages/modal/5601.vue |  394 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 269 insertions(+), 125 deletions(-)

diff --git a/pages/modal/5601.vue b/pages/modal/5601.vue
index e1d05fc..9657433 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]"
@@ -200,8 +200,8 @@
 			<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'}">
@@ -274,14 +274,11 @@
 			},
 		},
 		onLoad(options) {
-			console.log(options.titlename, options);
 			uni.setNavigationBarTitle({
 				title: options.titlename
 			}); //璁剧疆椤堕儴鏍囬 
 			this.title = options.titlename;
 			this.param = JSON.parse(options.param);
-
-
 			//鑾峰彇涓绘暟鎹被ID
 			this.ClsID = this.param.master_cls?.id;
 			if (this.ClsID) {
@@ -443,6 +440,9 @@
 								AttrVerify: false,
 								Event: evt,
 							};
+							if (page.After_ok?.ID) {
+								btn.After_Event = page.After_ok;
+							}
 							return [btn, btnCancel];
 						} else return [btnCancel];
 					} else {
@@ -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 =[]
+										}
 									}
 								}
 							}
@@ -733,7 +747,7 @@
 							.onSuffixClickEvent; //鍚庡浘鏍囩偣鍑诲洖璋� 						var isflag = false;
 
-						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent?.id) { //鍐呭鍙樺寲鍚庝簨浠� 							$this.onChange(onChangeEvent);
 						}
 						if (item.value) { //绗竴涓緭鍏ユ涓嶄负绌�@@ -816,7 +830,7 @@
 					this.head_styledef.form.model[attr] = item.value;
 					var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠� 
-					if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+					if (onChangeEvent?.id) { //鍐呭鍙樺寲鍚庝簨浠� 						this.onChange(onChangeEvent);
 					}
 
@@ -832,7 +846,7 @@
 						let attr = col.fieldId;
 						this.head_styledef.form.model[attr] = col.value;
 						var onChangeEvent = col.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�-						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent?.id) { //鍐呭鍙樺寲鍚庝簨浠� 							this.onChange(onChangeEvent);
 						}
 						return
@@ -843,7 +857,7 @@
 						let attr = item.fieldId;
 						this.head_styledef.form.model[attr] = item.value;
 						var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�-						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent?.id) { //鍐呭鍙樺寲鍚庝簨浠� 							this.onChange(onChangeEvent);
 						}
 					}
@@ -860,7 +874,7 @@
 						let attr = col.fieldId;
 						this.head_styledef.form.model[attr] = col.value;
 						var onChangeEvent = col.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�-						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent?.id) { //鍐呭鍙樺寲鍚庝簨浠� 							this.onChange(onChangeEvent);
 						}
 						return
@@ -871,7 +885,7 @@
 						let attr = item.fieldId;
 						this.head_styledef.form.model[attr] = item.value;
 						var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�-						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent?.id) { //鍐呭鍙樺寲鍚庝簨浠� 							this.onChange(onChangeEvent);
 						}
 					}
@@ -905,12 +919,13 @@
 				// 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);
 			},
 
 			getDetailAttrList(pageData) {
 				const detailAttrList = [];
+				  console.log(pageData)
 				if (pageData.DefList) {
 					pageData.DefList.forEach(style => {
 						var detail_attr = {};
@@ -953,6 +968,7 @@
 						});
 					});
 				}
+				  console.log(detailAttrList)
 				const jsonlist = [];
 				detailAttrList.forEach(attr => {
 					jsonlist.push({
@@ -984,6 +1000,7 @@
 						});
 						var obj_attr = this.head_styledef.form.model;
 						// console.log(obj_attr);
+						
 						var input_param = Base64.encode(
 							JSON.stringify(
 								Object.keys(head_attr).map((a) => ({
@@ -998,9 +1015,7 @@
 
 							jsonList.push({
 								page_name: page.Name,
-								item_list: $this.getDetailAttrList(page
-									.DefList, page
-									.Select_Button),
+								item_list: $this.getDetailAttrList(page),
 								ext_data: page.ExtData || {}
 							})
 
@@ -1008,6 +1023,7 @@
 						const data_json = Base64.encode(
 							JSON.stringify(jsonList)
 						);
+						  console.log(jsonList)
 						var dataInfo = {
 							ed_type: 0,
 							start_transaction: true,
@@ -1029,7 +1045,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 +1733,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
@@ -2421,6 +2401,7 @@
 											$this.setData({
 												check_list: val.config
 											})
+											console.log($this.check_list)
 											if (val.config.appear_style == 'sideslip') //鍒ゆ柇鏄惁鏄晶婊� 												$this.setData({
 													popupType: "right"
@@ -2571,14 +2552,17 @@
 				})
 			},
 			onBtnClick(btn, pageData) {
+				const $this = this
 				if (btn.Prompt) {
 					const sContent = btn.PromptContent || this.translate("confirm")
 					uni.showModal({
 						title: this.translateSys("tip"),
 						content: btn.PromptContent || this.translate("confirm"),
 						success: function(res) {
-							if (res.confirm) {}
-							this.onButtonClicked(btn, pageData, -1);
+							if (res.confirm) {
+								$this.onButtonClicked(btn, pageData, -1);
+							}
+
 						},
 					})
 
@@ -2587,14 +2571,17 @@
 				}
 			},
 			onRowBtnClick(btn, pageData, index) {
+				const $this = this
 				if (btn.Prompt) {
 					const sContent = btn.PromptContent || this.translate("confirm")
 					uni.showModal({
 						title: this.translateSys("tip"),
 						content: btn.PromptContent || this.translate("confirm"),
 						success: function(res) {
-							if (res.confirm) {}
-							this.onButtonClicked(btn, pageData, index);
+							if (res.confirm) {
+								$this.onButtonClicked(btn, pageData, index);
+							}
+
 						},
 					})
 
@@ -2608,7 +2595,7 @@
 					button: "top",
 					button_name: btn.ShowName,
 					cls_id: btn.Cls_ID,
-					function: "3018",
+					function: "5601",
 					master: {},
 				};
 				if (btn.FunCode == "TriggerEvent") {
@@ -2618,14 +2605,145 @@
 					this.cancel();
 				} else if (btn.FunCode == "Delete") {
 					if (index > -1) {
+						const pageIndex = this.pageDetail.findIndex((
+							page) => {
+							return pageData.Name == page.Name;
+						})
 						const style = pageData.DefList[index];
 						//鍒犻櫎鐮佺洏涓牱寮忛潰鏉� 						pageData.DefList.splice(index, 1);
 						this.del(pageData, style, btn.AfterProcess_Event);
+						this.$set(this.pageDetail, pageIndex, pageData)
 					}
+				} else if (btn.FunCode == "Modify") {
+					if (index > -1) {
+						const style = pageData.DefList[index];
+						if (btn.Edit_dlg.Model == "small") {
+							this.showSmallDialog(btn, style, enviroment, pageData);
+						} else if (btn.Edit_dlg.Model == "form") {
+							this.showFormDialog(btn, style, enviroment, pageData);
+						} else {
+							uni.showModal({
+								title: this.translateSys("tip"),
+								content: this.translateSys("unrealized"),
+								showCancel: false,
+								confirmText: this.translateSys("cancel")
+							});
+						}
+					}
+
 				} else {
 					this.$Message.warning(this.$t("sys.unrealized"));
 				}
+			},
+			//淇敼灏忕獥鍙f暟鎹�+			showSmallDialog(btn, row, enviroment, pageData) {
+				var data = {
+					Add_BtnName: btn.ShowName,
+					EditDlgMode: btn.Edit_dlg.Model,
+					clsid: btn.Cls_ID,
+					objid: "",
+					cls_name: btn.Cls_Name,
+					Edit_dlg: btn.Edit_dlg
+				};
+				const objAttr = {}
+				row.form.items.forEach(item => {
+					if (item.name == "Layout") { //鍒ゆ柇鏄惁鏄爡鏍忔牸寮�+						item.setting.colList.forEach(cols => {
+							if (cols != null) objAttr[cols
+								.fieldId] = cols.value;
+						});
+					} else
+						objAttr[item.fieldId] = item.value;
+				});
+				const url = `../modal/3018?param=${JSON.stringify(data)}&titlename=${btn.Edit_dlg
+					.Name}&editMode=1&objAttr=${JSON.stringify(objAttr)}&type=updateDataObj`
+
+				var $this = this;
+				uni.navigateTo({
+					url: url,
+					events: {
+						// 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�鍒板綋鍓嶉〉闈㈢殑鏁版嵁
+						updateDataObj: function(formData) {
+							const pageIndex = $this.pageDetail.findIndex((
+								page) => {
+								return pageData.Name == page.Name;
+							})
+							if (pageIndex < 0)
+								return
+							Object.assign(row.form.model, formData);
+							row.form.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
+										}
+									});
+								}
+							})
+							$this.$set($this.pageDetail, pageIndex, pageData)
+
+						},
+
+					}
+				});
+			},
+
+			//淇敼鑷畾涔夎〃鍗曟暟鎹�+			showFormDialog(btn, row, enviroment, pageData) {
+				const objAttr = {}
+				row.form.items.forEach(item => {
+					if (item.name == "Layout") { //鍒ゆ柇鏄惁鏄爡鏍忔牸寮�+						item.setting.colList.forEach(cols => {
+							if (cols != null) objAttr[cols
+								.fieldId] = cols.value;
+						});
+					} else
+						objAttr[item.fieldId] = item.value;
+				});
+
+				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,
+					events: {
+						// 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�鍒板綋鍓嶉〉闈㈢殑鏁版嵁
+						updateDataObj: function(formData) {
+							const pageIndex = $this.pageDetail.findIndex((
+								page) => {
+								return pageData.Name == page.Name;
+							})
+							if (pageIndex < 0)
+								return
+							Object.assign(row.form.model, formData);
+							row.form.items.forEach(async (ele) => {
+								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
+										}
+									});
+								}
+							})
+							$this.$set($this.pageDetail, pageIndex, pageData)
+
+						},
+					}
+				});
 			},
 			//纭畾
 			ok(pageData) {
@@ -3140,7 +3258,17 @@
 		},
 	};
 </script>
+<style>
+	.popup-content {
+		@include flex;
+	
+	}
 
+	.popup-height {
+		@include height;
+		/* width: 200px; */
+	}
+</style>
 <style lang="scss">
 	.uni-page-modal-5601 {
 
@@ -3364,6 +3492,7 @@
 					line-height: 1.5;
 					border: none;
 					font-size: 30rpx;
+					margin-right: 10rpx;
 					display: inline-block;
 					float: right;
 					text-align: center;
@@ -3475,15 +3604,6 @@
 			background-color: #f3f3f3 !important;
 		}
 
-		.demo-uni-row {
-			margin-bottom: 0px;
-			display: block;
-
-			.uni-input {
-				width: calc(100% - 120px);
-			}
-		}
-
 		::v-deep .uni-row {
 			margin-bottom: 0px;
 		}
@@ -3497,6 +3617,30 @@
 			border-radius: 5px;
 		}
 
+	.view-popup {
+			position: relative;
+		}
+
+		.popup-content {
+			// @include flex;
+			align-items: center;
+			justify-content: center;
+			padding: 30rpx;
+			background-color: #fff;
+			/* height: 150px; */
+			/* border: 1px solid red; */
+		}
+
+		.popup-cont {
+			overflow-y: auto;
+			/* border: 1px solid red; */
+		}
+
+		.popup-height {
+			// @include height;
+			/* width: 200px; */
+		}
+
 		.popup-header {
 			font-size: 42rpx;
 			font-weight: bold;

--
Gitblit v1.9.1