From f85708dcab378fe8d12fbf95933d00883c36fe3d Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期四, 27 二月 2025 16:20:12 +0800
Subject: [PATCH] 5601 button

---
 pages/modal/5601.vue |  340 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 271 insertions(+), 69 deletions(-)

diff --git a/pages/modal/5601.vue b/pages/modal/5601.vue
index d019952..e1d05fc 100644
--- a/pages/modal/5601.vue
+++ b/pages/modal/5601.vue
@@ -144,25 +144,42 @@
 												</uni-row>
 											</div>
 										</div>
-										<div class="dv-panel-button">
+										<div class="dv-panel-button"
+											v-if="pageData.Select_Button==true || pageData.Row_Button.length > 0">
 
 											<checkbox v-if="pageData.Select_Button==true" :model="ii"
 												:checked="style.SelBut_Checked" />
 											<!-- <text></text> -->
-
 											<!-- <button type="primary" @click="savaItem(ii)" v-if="param.Sub_Page[0].OK_Button==true">淇濆瓨</Button> -->
-											<button type="warn" @tap="delItem(pageData,ii)"
-												v-if="pageData.Del_Button==true">{{translateSys('delete')}}</button>
+											<button size="mini" v-for="(btn,btnIndex) in pageData.Row_Button"
+												:key="btnIndex" :type="btn.FunCode == 'Delete' ? 'warn' : 'primary'"
+												@click="onRowBtnClick(btn, pageData,ii)">
+												<Icon v-if="btn.Style == 'img' || btn.Style == 'img_text'"
+													class="Img" />
+												{{(btn.Style == 'text'|| btn.Style == 'img_text') ? btn.ShowName :""}}
+											</button>
 										</div>
 									</div>
 								</checkbox-group>
 							</view>
-							<view class="view-bottom" v-if="pageData.OK_Button==true">
-								<button type="default" @tap="cancel"
-									class="btn_cancel">{{translateSys('cancel')}}</button>
-								<button type="primary" @tap="ok(pageData)" class="btn_add"
-									:class="pageData.okLoading?'btn_disabled':''"
-									:disabled="pageData.okLoading? true:false">{{translateSys('ok')}}</button>
+							<view class="view-bottom" v-if="pageData.Button.length >0 ">
+								<button v-for="(btn,btnIndex) in pageData.Button" :key="btnIndex"
+									:type="btn.FunCode == 'Cancel' ? 'default' : 'primary'"
+									:class="{'btn-disabled':(btn.FunCode != 'Cancel' && pageData.okLoading),
+													'btn-one':pageData.Button.length == 1,
+													'btn-left':(btnIndex < pageData.Button.length - 1),
+													'btn-right': btnIndex > 0 && btnIndex == pageData.Button.length - 1 ,
+													'width-50':(pageData.Button.length == 2),'width-32':(pageData.Button.length == 3),'width-30':(pageData.DropDownButton.length> 0)}"
+									:disabled="(btn.FunCode != 'Cancel' && pageData.okLoading)? true:false"
+									@click="onBtnClick(btn, pageData)">
+									<Icon v-if="btn.Style == 'img' || btn.Style == 'img_text'" class="Img" />
+									{{(btn.Style == 'text'|| btn.Style == 'img_text') ? btn.ShowName :""}}
+								</button>
+								<view class="btn-right" v-if="pageData.DropDownButton.length >0 ">
+									<a @click="clickDropdownBtns(pageData)">
+										<Icon class="mobox-normal-more" />
+									</a>
+								</view>
 							</view>
 						</view>
 					</swiper-item>
@@ -236,11 +253,7 @@
 				pageDetail: [], //{StyleDef{}:,DefList:[],ExtData:{}}
 				// 鍒嗘鍣ㄦ暟鎹� 				current: 0,
-				Before_OK_Event: {},
 				After_OK_Event: {},
-				Before_Del_Event: {},
-				After_Del_Event: {},
-
 				active_id: '',
 				selectAttrObj: {},
 
@@ -308,7 +321,6 @@
 				});
 			},
 			async loadData(paramValue) {
-
 				//鑾峰彇鏁版嵁绫荤殑鑷畾涔夎〃鍗曞弬鏁� 				await this.Head_UIStyleGetInfo(this.ClsID, this.param.Input_UI_Style.ID);
 				//浼犲叆鍙傛暟鍊�@@ -351,6 +363,33 @@
 						this.ClsID,
 						page.UI_Style.ID
 					);
+					const buttons = this.pageButtonList(page)
+					page.Button = buttons
+					page.DropDownButton = []
+					if (buttons.length > 3) {
+						let cancelBtn = undefined
+						const btns = []
+						buttons.forEach((btn) => {
+							if (btn.FunCode == "Cancel") {
+								cancelBtn = btn
+							} else {
+								btns.push(btn)
+							}
+						})
+						if (cancelBtn) {
+							if (btns.length > 2) {
+								page.DropDownButton = btns.splice(2)
+								page.Button = btns
+							}
+							page.Button.push(cancelBtn)
+						} else {
+							if (btns.length > 3) {
+								page.DropDownButton = btns.splice(3)
+								page.Button = btns
+							}
+						}
+					}
+					page.Row_Button = this.rowButtonList(page)
 				}
 
 				this.setData({
@@ -365,6 +404,89 @@
 					current: index
 				})
 			},
+			pageButtonList(page) {
+				if (this.param?.ver == "2.0") {
+					return page?.Button || []
+
+				} else {
+					if (page?.OK_Button) {
+						let evt = {};
+						if (page.Before_ok?.ID) {
+							evt = {
+								ID: page.Before_ok?.ID,
+								Name: page.Before_ok?.Name
+							};
+						} else if (page.After_ok?.ID) {
+							evt = {
+								ID: page.After_ok?.ID,
+								Name: page.After_ok?.Name
+							};
+						}
+						let btnCancel = {
+							Cls_Name: this.param?.master_cls?.name || "",
+							Cls_ID: this.param?.master_cls?.id || "",
+							FunCode: "Cancel",
+							ShowName: this.$t("sys.cancel"),
+							Style: "text",
+							Prompt: false,
+						};
+						if (evt.ID) {
+							let btn = {
+								Cls_Name: this.param?.master_cls?.name || "",
+								Cls_ID: this.param?.master_cls?.id || "",
+								FunCode: "TriggerEvent",
+								ShowName: this.$t("sys.ok"),
+								Style: "text",
+								Prompt: false,
+								NotTriggerSYSEvent: false,
+								DataStateVerify: false,
+								AttrVerify: false,
+								Event: evt,
+							};
+							return [btn, btnCancel];
+						} else return [btnCancel];
+					} else {
+						return [];
+					}
+				}
+			},
+			rowButtonList(page) {
+				if (this.param?.ver == "2.0") {
+					return page?.Row_Button || [];
+				} else {
+					if (page?.Del_Button) {
+						let evt = {};
+						if (page.Before_Delete?.ID) {
+							evt = {
+								ID: page.Before_Delete?.ID,
+								Name: page.Before_Delete?.Name,
+							};
+						} else if (page.After_Delete?.ID) {
+							evt = {
+								ID: page.After_Delete?.ID,
+								Name: page.After_Delete?.Name
+							};
+						}
+
+						if (evt.ID) {
+							return [{
+								Cls_Name: this.param?.master_cls?.name || "",
+								Cls_ID: this.param?.master_cls?.id || "",
+								FunCode: "Delete",
+								ShowName: this.$t("sys.delete"),
+								Style: "text",
+								Prompt: false,
+								NotTriggerSYSEvent: false,
+								DataStateVerify: false,
+								AttrVerify: false,
+								AfterProcess_Event: evt,
+							}];
+						}
+					}
+					return [];
+				}
+			},
+
 			checkboxChange(e) {
 
 				var items = this.pageDetail[this.current]?.DefList || []
@@ -477,6 +599,8 @@
 					this.setData({
 						head_styledef: styledefHead
 					})
+					console.log("Head_UIStyleGetInfo", this.head_styledef)
+
 				} catch (ex) {
 					// console.log(ex);
 					uni.showModal({
@@ -1704,21 +1828,6 @@
 			onDetail1EnterChange(item) { //鐮佺洏涓牱寮忓洖杞︿簨浠� 				console.log(item);
 			},
-			delItem(pageData, index) { //鍒犻櫎鐮佺洏涓牱寮忛潰鏉�-
-				//鍒犻櫎鐮佺洏涓牱寮忛潰鏉�-				this.Before_Del_Event = pageData.Before_Delete;
-				this.After_Del_Event = pageData.After_Delete;
-				const style = pageData.DefList[index];
-				//鍒犻櫎鐮佺洏涓牱寮忛潰鏉�-				pageData.DefList.splice(index, 1);
-				if (this.Before_Del_Event?.ID)
-					//鏄惁鏈夊垹闄ゅ墠浜嬩欢
-					this.del(pageData, style, this.Before_Del_Event);
-				else if (this.After_Del_Event?.ID)
-					//鏄惁鏈夊垹闄ゅ悗浜嬩欢
-					this.del(pageData, style, this.After_Del_Event);
-			},
 			async del(pageData, style, event) {
 				//鑾峰彇琛ㄥご灞炴�
 				var head_attr = {};
@@ -2442,6 +2551,82 @@
 				// console.log(value);
 				this.active_id = id;
 			},
+			//鐐瑰嚮鎸夐挳鍒楄〃
+			clickDropdownBtns(pageData) {
+				const that = this
+				const itemlist = [];
+				const btnList = pageData.DropDownButton || []
+
+				for (let i in btnList) {
+					itemlist.push(btnList[i].ShowName || "");
+				}
+				uni.showActionSheet({
+					// title: '鎸夐挳鍒楄〃',
+					itemList: itemlist,
+					success: (e) => {
+						console.log(e.tapIndex);
+						var btn = btnList[e.tapIndex];
+						that.onBtnClick(btn, pageData);
+					}
+				})
+			},
+			onBtnClick(btn, pageData) {
+				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);
+						},
+					})
+
+				} else {
+					this.onButtonClicked(btn, pageData, -1);
+				}
+			},
+			onRowBtnClick(btn, pageData, index) {
+				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);
+						},
+					})
+
+				} else {
+					this.onButtonClicked(btn, pageData, index);
+				}
+			},
+			onButtonClicked(btn, pageData, index) {
+				this.After_OK_Event = {}
+				let enviroment = {
+					button: "top",
+					button_name: btn.ShowName,
+					cls_id: btn.Cls_ID,
+					function: "3018",
+					master: {},
+				};
+				if (btn.FunCode == "TriggerEvent") {
+					this.After_OK_Event = btn?.After_Event || {};
+					this.sava(pageData, btn.Event);
+				} else if (btn.FunCode == "Cancel") {
+					this.cancel();
+				} else if (btn.FunCode == "Delete") {
+					if (index > -1) {
+						const style = pageData.DefList[index];
+						//鍒犻櫎鐮佺洏涓牱寮忛潰鏉�+						pageData.DefList.splice(index, 1);
+						this.del(pageData, style, btn.AfterProcess_Event);
+					}
+				} else {
+					this.$Message.warning(this.$t("sys.unrealized"));
+				}
+			},
 			//纭畾
 			ok(pageData) {
 				this.Before_OK_Event = pageData.Before_ok;
@@ -3044,10 +3229,58 @@
 			flex-direction: row;
 			width: calc(100% - 30rpx);
 			padding: 10rpx 15rpx 30rpx 15rpx;
+
+			.btn-disabled {
+				background-color: #ddd;
+				color: #888;
+			}
+
+			.btn-left {
+				padding: 20rpx;
+				line-height: 1.5;
+				border: none;
+				font-size: 38rpx;
+				font-weight: bold;
+				float: left;
+				display: inline-block;
+			}
+
+			.btn-one {
+				padding: 20rpx;
+				line-height: 1.5;
+				border: none;
+				font-size: 38rpx;
+				font-weight: bold;
+				float: left;
+				display: inline-block;
+				width: 50%;
+				margin-left: 25%;
+			}
+
+			.btn-right {
+				padding: 20rpx;
+				line-height: 1.5;
+				border: none;
+				font-size: 38rpx;
+				font-weight: bold;
+				float: right;
+				display: inline-block;
+			}
+
+			.width-50 {
+				width: 49%;
+			}
+
+			.width-32 {
+				width: 32%;
+				margin-left: 1%;
+			}
+
+			.width-30 {
+				width: 30%;
+				margin-left: 1%;
+			}
 		}
-
-
-
 
 		[nvue] uni-view {
 			position: relative;
@@ -3073,7 +3306,7 @@
 
 		.dv-panel {
 			background-color: #efefef;
-			padding: 20rpx 20rpx 4rpx 0px;
+			padding: 20rpx 20rpx 10rpx 0px;
 			border-radius: 12rpx;
 			margin: 10rpx 0 20rpx 0;
 			text-align: right;
@@ -3118,7 +3351,8 @@
 			.dv-panel-button {
 				width: 100%;
 				text-align: left;
-				padding-bottom: 20rpx;
+				min-height: 30rpx;
+				padding-bottom: 10rpx;
 
 				checkbox {
 					padding-left: 20px;
@@ -3127,44 +3361,12 @@
 
 				button {
 					text-align: left;
-					line-height: 1.8;
+					line-height: 1.5;
 					border: none;
-					font-size: 34rpx;
-					width: 180rpx;
+					font-size: 30rpx;
 					display: inline-block;
 					float: right;
 					text-align: center;
-
-					.btn_cancel {
-						width: 49.5%;
-						padding: 20rpx;
-						line-height: 1.5;
-						border: none;
-						font-size: 38rpx;
-						font-weight: bold;
-						float: left;
-						display: inline-block;
-					}
-
-					.btn_add {
-						width: 49.5%;
-
-						padding: 20rpx;
-						line-height: 1.5;
-						border: none;
-						font-size: 38rpx;
-						font-weight: bold;
-						float: right;
-						color: #fff;
-						display: inline-block;
-					}
-
-					.btn_disabled {
-						background-color: #ddd;
-						color: #888;
-					}
-
-
 				}
 			}
 

--
Gitblit v1.9.1