From 625badef071d0931b3868b2ba672d51ce2cc5b91 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期三, 19 二月 2025 10:01:20 +0800
Subject: [PATCH] action set_subtable_page_row 处理 condition

---
 pages/modal/5601.vue |  342 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 286 insertions(+), 56 deletions(-)

diff --git a/pages/modal/5601.vue b/pages/modal/5601.vue
index 52a5dd6..d019952 100644
--- a/pages/modal/5601.vue
+++ b/pages/modal/5601.vue
@@ -4,7 +4,7 @@
 		<uni-forms ref="baseForm" label-align="right">
 			<view v-for="(item,index) in head_styledef.form.items" :key="index" class="v-head-style">
 				<!-- 鏅�甯冨眬 -->
-				<uni-forms-item v-if="item.name != 'Layout'" :label="item.label +'锛� "
+				<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)"
@@ -21,15 +21,36 @@
 						<text v-if="item.setting.suffix" class="uni-icon" :class="[item.setting.suffix]"
 							@click="classAttr_extButton(item)"></text>
 					</view>
+					<!-- 澶嶉�妗�-->
+					<checkbox-group v-if="item.name=='Checkbox'" :class="item.disabled?'input-disabled':''"
+						:disabled="item.disabled" @change="onCheckBoxValue" :data-attr="item.fieldId"
+						:data-index="index">
+						<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 v-if="item.name=='Radio'" :class="item.disabled?'input-disabled':''"
+						:disabled="item.disabled" @change="onRadioBoxValue" :data-attr="item.fieldId"
+						:data-index="index">
+						<label v-for="(item2) in item.selections" :key="item2.value">
+							<radio :value="item2.value" :checked="item2.value === item.value" />
+							<text>{{item2.label}}</text>
+						</label>
+					</radio-group>
+					<!-- Switch寮�叧 -->
+					<switch class="input-switch" v-if="item.name=='Switch'" :class="item.disabled?'input-disabled':''"
+						:disabled="item.disabled" v-model="item.value" @change="onEnterChange(item)" />
 				</uni-forms-item>
 				<!-- 鏍呮牸甯冨眬 -->
 				<uni-row v-else :gutter="item.setting.gutter">
 					<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 +'锛�" :label-width="col.labelWidth+'px'">
+						<uni-forms-item :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(item)"
+								v-model="col.value" :localdata="col.dict" @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]"
@@ -43,6 +64,27 @@
 								<text v-if="col.setting.suffix" class="uni-icon" :class="[col.setting.suffix]"
 									@click="classAttr_extButton(col)"></text>
 							</view>
+							<!-- 澶嶉�妗�-->
+							<checkbox-group v-if="col.name=='Checkbox'" :class="col.disabled?'input-disabled':''"
+								:disabled="col.disabled" @change="onCheckBoxValue" :data-attr="col.fieldId"
+								:data-index="index" :data-iindex="key">
+								<label v-for="(col2) in col.selections" :key="col2.value">
+									<checkbox :value="col2.value" :checked="col.value.includes(col2.value)" />
+									<text>{{col2.label}}</text>
+								</label>
+							</checkbox-group>
+							<!-- 鍗曢�妗�-->
+							<radio-group v-if="col.name=='Radio'" :class="col.disabled?'input-disabled':''"
+								:disabled="col.disabled" @change="onRadioBoxValue" :data-attr="col.fieldId"
+								:data-index="index" :data-iindex="key">
+								<label v-for="(col2) in col.selections" :key="col2.value">
+									<radio :value="col2.value" :checked="col2.value === col.value" />
+									<text>{{col2.label}}</text>
+								</label>
+							</radio-group>
+							<!-- Switch寮�叧 -->
+							<switch v-if="col.name=='Switch'" :class="col.disabled?'input-disabled':''"
+								:disabled="col.disabled" v-model="col.value" @change="onEnterChange(col)" />
 						</uni-forms-item>
 					</uni-col>
 				</uni-row>
@@ -363,7 +405,26 @@
 									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 ==
 										'InputNumber') {
@@ -381,6 +442,22 @@
 											.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
@@ -621,10 +698,67 @@
 
 				}
 			},
+			onCheckBoxValue(e) { //缁戝畾Model鍊�+				let values = e.detail.value || []
+				const item = this.head_styledef.form.items[e.currentTarget?.dataset?.index || 0]
+				if (item?.setting?.colList) {
+					const col = item.setting.colList[e.currentTarget?.dataset?.iindex || 0]
+					if (col) {
+						col.value = values
+						let attr = col.fieldId;
+						this.head_styledef.form.model[attr] = col.value;
+						var onChangeEvent = col.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+							this.onChange(onChangeEvent);
+						}
+						return
+					}
+				} else {
+					if (item) {
+						item.value = values
+						let attr = item.fieldId;
+						this.head_styledef.form.model[attr] = item.value;
+						var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+							this.onChange(onChangeEvent);
+						}
+					}
+				}
+
+			},
+			onRadioBoxValue(e) { //缁戝畾Model鍊�+				let values = e.detail.value || ""
+				const item = this.head_styledef.form.items[e.currentTarget?.dataset?.index || 0]
+				if (item?.setting?.colList) {
+					const col = item.setting.colList[e.currentTarget?.dataset?.iindex || 0]
+					if (col) {
+						col.value = values
+						let attr = col.fieldId;
+						this.head_styledef.form.model[attr] = col.value;
+						var onChangeEvent = col.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+							this.onChange(onChangeEvent);
+						}
+						return
+					}
+				} else {
+					if (item) {
+						item.value = values
+						let attr = item.fieldId;
+						this.head_styledef.form.model[attr] = item.value;
+						var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+						if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+							this.onChange(onChangeEvent);
+						}
+					}
+
+				}
+
+			},
 			classAttr_extButton(item) {
 				var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent; //鍚庡浘鏍囩偣鍑讳簨浠� 				var onSuffixClickEvent = item.bind.onSuffixClickEvent; //鍚庡浘鏍囩偣鍑诲洖璋�-			
+
 				if (!onSuffixClickCallbackEvent.id) {
 					uni.showModal({
 						title: this.translateSys("tip"),
@@ -1126,6 +1260,9 @@
 					number1 = parseInt(value1)
 				if (value2)
 					number2 = parseInt(value2)
+				if (!operation) {
+					return value2;
+				}
 				if (operation == "+") {
 					return number1 + number2
 				} else if (operation == "-") {
@@ -1133,11 +1270,17 @@
 				} else if (operation == "*") {
 					return number1 * number2
 				} else if (operation == "/") {
-					if (number2)
-						return number1 / number2
-					else
-						return number1
-				} else return number2
+					if (number2) return number1 / number2;
+					else {
+						throw new Error(`${this.translate("illegal_dividend")}'${value2}'`);
+						return 0;
+					}
+				} else if (operation == "=") {
+					return value2;
+				} else {
+					throw new Error(`${this.translate("unrecognized_operator")}'${operation}'`);
+					return 0;
+				}
 			},
 
 			//鏇存柊鍒嗛〉绛句腑鐨勫垪琛ㄩ」鍐呭
@@ -1153,54 +1296,141 @@
 				var detailStyleDefList = pageData.DefList || []
 				detailStyleDefList.forEach(ele => {
 					value.row.forEach((rowData) => {
-						if (ele.form.objId == rowData.id) {
-							rowData.attrs.forEach(attr => {
-								ele.form.items.forEach(ele2 => {
-									if (ele2.name !=
-										'Layout') {
-										if (ele2.fieldId ==
-											attr
-											.attr) {
-											ele2.value =
-												$this
-												.operationNumber(
-													ele2
-													.value,
-													attr
-													.value,
-													attr
-													.operation
-												)
-										}
-									} else if (ele2.name ==
-										'Layout') {
-										ele2.setting
-											.colList
-											.forEach(
-												col => {
-													if (
-														col) {
-														if (col
-															.fieldId ==
-															attr
-															.attr
-														) {
-															col.value =
-																$this
-																.operationNumber(
-																	col
-																	.value,
-																	attr
-																	.value,
-																	attr
-																	.operation
-																)
+						if (rowData.id) {
+							if (ele.form.objId == rowData.id) {
+								rowData.attrs.forEach(attr => {
+									ele.form.items.forEach(ele2 => {
+										if (ele2.name !=
+											'Layout') {
+											if (ele2.fieldId ==
+												attr
+												.attr) {
+												ele2.value =
+													$this
+													.operationNumber(
+														ele2
+														.value,
+														attr
+														.value,
+														attr
+														.operation
+													)
+											}
+										} else if (ele2.name ==
+											'Layout') {
+											ele2.setting
+												.colList
+												.forEach(
+													col => {
+														if (
+															col) {
+															if (col
+																.fieldId ==
+																attr
+																.attr
+															) {
+																col.value =
+																	$this
+																	.operationNumber(
+																		col
+																		.value,
+																		attr
+																		.value,
+																		attr
+																		.operation
+																	)
+															}
 														}
-													}
-												})
-									}
+													})
+										}
+									});
 								});
-							});
+							}
+						} else if (rowData.condition) {
+							const conditions = rowData.condition;
+							let bFindCondition = true;
+							for (let i in conditions) {
+								const condition = conditions[i];
+								let bFind = false;
+								for (let i2 in ele.form.items) {
+									const ele2 = ele.form.items[i2];
+									if (ele2.name != "Layout") {
+										if (ele2.fieldId == condition.attr) {
+											if (condition.value == ele2.value) {
+												bFind = true;
+											}
+											break;
+										}
+									} else {
+										const colList = ele2.setting.colList || [];
+										for (let i3 in colList) {
+											const col = colList[i3];
+											if (col.fieldId == condition.attr) {
+												if (condition.value == col.value) {
+													bFind = true;
+												}
+												break;
+											}
+										}
+										if (bFind) break;
+									}
+								}
+								if (!bFind) {
+									bFindCondition = false;
+									break;
+								}
+							}
+							if (bFindCondition) {
+
+								rowData.attrs.forEach(attr => {
+									ele.form.items.forEach(ele2 => {
+										if (ele2.name !=
+											'Layout') {
+											if (ele2.fieldId ==
+												attr
+												.attr) {
+												ele2.value =
+													$this
+													.operationNumber(
+														ele2
+														.value,
+														attr
+														.value,
+														attr
+														.operation
+													)
+											}
+										} else if (ele2.name ==
+											'Layout') {
+											ele2.setting
+												.colList
+												.forEach(
+													col => {
+														if (
+															col) {
+															if (col
+																.fieldId ==
+																attr
+																.attr
+															) {
+																col.value =
+																	$this
+																	.operationNumber(
+																		col
+																		.value,
+																		attr
+																		.value,
+																		attr
+																		.operation
+																	)
+															}
+														}
+													})
+										}
+									});
+								});
+
+							}
 						}
 					})
 				});
@@ -1889,7 +2119,7 @@
 				});
 			},
 			dataObjRunCustomEvent_Return(eventid, data_attr, button_callback, item) {
-				console.log("dataObjRunCustomEvent_Return",eventid,data_attr,button_callback)
+				console.log("dataObjRunCustomEvent_Return", eventid, data_attr, button_callback)
 				const $this = this
 				var enviroment = {
 					'function': '3000', // 鍔熻兘鐐圭紪鍙�
--
Gitblit v1.9.1