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/5602.vue |  158 +++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 131 insertions(+), 27 deletions(-)

diff --git a/pages/modal/5602.vue b/pages/modal/5602.vue
index d87a1e8..bb6d4d2 100644
--- a/pages/modal/5602.vue
+++ b/pages/modal/5602.vue
@@ -376,12 +376,26 @@
 							.style_def);
 					}
 					$this.$data.head_styledef = result.style_def ? JSON.parse(styledef) : {};
-					// this.form = this.head_styledef.form.model;
-					// console.log($this.$data.head_styledef);
 					if ($this.head_styledef.form?.items) {
 						$this.head_styledef.form.items.forEach(async (ele, index) => {
 							if (ele.useDict == true) { //鍒ゆ柇useDict鏄惁浣跨敤瀛楀吀
 								await this.DictGetInfo(ele.bind.dict, index, 'mast');
+							} else {
+								if (ele?.name === "Select") {
+									const selections = ele?.selections || []
+									//鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ�
+									let itemName = ele.value || "";
+									if (itemName) {
+										$this.head_styledef.form
+											.model[ele.fieldId] = itemName;
+									}
+									$this.head_styledef.form.items[index].dict = selections.map((a) => {
+										return {
+											value: a.value,
+											text: a.label
+										}
+									})
+								}
 							}
 							if ($this.focusFieldId == "") {
 								if (ele.name == 'Input' || ele.name == 'InputNumber') {
@@ -433,6 +447,23 @@
 						$this.detail1_styledef.form.items.forEach(async (ele, index) => {
 							if (ele.useDict == true) { //鍒ゆ柇useDict鏄惁浣跨敤瀛楀吀
 								await this.DictGetInfo(ele.bind.dict, index, 'sub');
+							} else {
+								if (ele?.name === "Select") {
+									const selections = ele?.selections || []
+									//鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ�
+									let itemName = ele.value || "";
+									if (itemName) {
+										$this.detail1_styledefform
+											.model[ele.fieldId] = itemName;
+									}
+									$this.detail1_styledef.form.items[index].dict = selections.map((a) => {
+										return {
+											value: a.value,
+											text: a.label
+										}
+									})
+								}
+
 							}
 						});
 					}
@@ -1054,6 +1085,9 @@
 					number1 = parseInt(value1)
 				if (value2)
 					number2 = parseInt(value2)
+				if (!operation) {
+					return value2;
+				}
 				if (operation == "+") {
 					return number1 + number2
 				} else if (operation == "-") {
@@ -1061,11 +1095,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;
+				}
 			},
 			//鏇存柊鍒嗛〉绛句腑鐨勫垪琛ㄩ」鍐呭
 			viewActionSetRow(value) {
@@ -1078,28 +1118,92 @@
 				}
 				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)
+													}
+												}
+											})
+										}
+									});
+								});
+
+							}
 						}
 					})
 				});

--
Gitblit v1.9.1