From fc15f2e904fade9e1505bad70b29829d7d99c124 Mon Sep 17 00:00:00 2001
From: lzhe <lzhe@example.com>
Date: 星期三, 05 六月 2024 12:04:59 +0800
Subject: [PATCH] 1

---
 src/views/console/basic-data/product.vue |  180 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 133 insertions(+), 47 deletions(-)

diff --git a/src/views/console/basic-data/product.vue b/src/views/console/basic-data/product.vue
index e816c93..86bbbb8 100644
--- a/src/views/console/basic-data/product.vue
+++ b/src/views/console/basic-data/product.vue
@@ -47,6 +47,44 @@
 							<el-icon @click="addDrawer" class="searchi-icon"><Setting /></el-icon>
 						</el-col>
 					</el-row>
+					<div class="product-type-table">
+						<el-table ref="multipleTableRef0" :data="productTableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange0" row-key="id" lazy :load="tableLoad" :tree-props="{ hasChildren: 'hasChild' }">
+							<el-table-column type="selection" width="55" />
+							<el-table-column prop="name" label="浜у搧鍚嶇О"></el-table-column>
+							<el-table-column prop="code" label="浜у搧缂栧彿"></el-table-column>
+							<el-table-column prop="typeName" label="浜у搧绫诲瀷"></el-table-column>
+							<el-table-column prop="unit" label="璁¢噺鍗曚綅"></el-table-column>
+							<el-table-column prop="standardModel" label="瑙勬牸鍨嬪彿"></el-table-column>
+							<el-table-column prop="description" label="浜у搧鎻忚堪"></el-table-column>
+							<el-table-column prop="remark" label="宸ヨ壓璺嚎">
+								<template #default="scope">
+					     			<span class="viewDetial">鏌ョ湅璇︽儏</span>
+					     		</template>
+							</el-table-column>
+							<el-table-column prop="remark" label="BOM娓呭崟">
+								<template #default="scope">
+					     			<span class="viewDetial">鏌ョ湅璇︽儏</span>
+					     		</template>
+							</el-table-column>
+							<el-table-column fixed="right" label="鎿嶄綔" width="200px">
+								<template #default="scope">
+									<el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">缂栬緫</el-button>
+									<el-button text type="primary" size="small" @click="refresh_product_type(scope.row, scope.$index)">鍒锋柊</el-button>
+									<el-button text type="primary" size="small" @click="del_product_type(scope.row, scope.$index,0)">鍒犻櫎</el-button>
+								</template>
+							</el-table-column>
+						</el-table>
+						<el-pagination
+							style="margin-top: 12px;"
+							@size-change="handleSizeChange0"
+							@current-change="handleCurrentChange0"
+							:current-page="currentPage4"
+							:page-sizes="[15, 50, 100]"
+							:page-size="15"
+							layout="total, sizes, prev, pager, next, jumper"
+							:total="total0">
+						</el-pagination>
+					</div>
 					<el-drawer title="鏌ヨ璁剧疆" v-model="drawer" :direction="direction" :before-close="handleClose" size="780" class="drawerClass">
 						<div class="drawer-form">
 							<div class="drawer-left">
@@ -92,7 +130,7 @@
 						</el-col>
 					</el-row>
 					<div class="product-type-table">
-						<el-table ref="multipleTableRef" :data="productTypeTableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
+						<el-table ref="multipleTableRef1" :data="productTypeTableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange1">
 							<el-table-column type="selection" width="55" />
 							<el-table-column prop="name" label="浜у搧绫诲瀷鍚嶇О"></el-table-column>
 							<el-table-column prop="remark" label="鎻忚堪"></el-table-column>
@@ -103,14 +141,14 @@
 							</el-table-column>
 							<el-table-column fixed="right" label="鎿嶄綔">
 								<template #default="scope">
-									<el-button text type="primary" size="small" @click="del_product_type(scope.row, scope.$index)">鍒犻櫎</el-button>
+									<el-button text type="primary" size="small" @click="del_product_type(scope.row, scope.$index,1)">鍒犻櫎</el-button>
 								</template>
 							</el-table-column>
 						</el-table>
 						<el-pagination
 							style="margin-top: 12px;"
-							@size-change="handleSizeChange"
-							@current-change="handleCurrentChange"
+							@size-change="handleSizeChange1"
+							@current-change="handleCurrentChange1"
 							:current-page="currentPage4"
 							:page-sizes="[15, 50, 100]"
 							:page-size="15"
@@ -150,6 +188,8 @@
 		name: "allocation",
 		data(){
 			return {
+				total0: 0,
+				productTableData: [],
 				checkData: [],
 				checkList: [],
 				id: "",
@@ -167,7 +207,8 @@
 				uploadUrl: "/api/blade-cps/employee/import-employee",
 				exportUrl: "/api/blade-cps/employee/export-template",
 				activeName: 'first',
-				selection: [],
+				selection0: [],
+				selection1: [],
 				total: 0,
 				searchData: {
 					keyWord: "",
@@ -180,14 +221,15 @@
 				dialog: {
 					save: false
 				},
-				tableData: []
+				tableData: [],
+				delTypeNum: ""
 			}
 		},
 		created(){
 			
 		},
 		mounted(){
-			//this.searchBtn();
+			this.searchBtn0();
 			this.getProductType();
 			this.getProductTypeSelect();
 			this.getFields();  //鏌ヨ璁剧疆
@@ -196,6 +238,14 @@
 			...ElementPlusIconsVue,saveDialog,importTable
 		},
 		methods: {
+			tableLoad(row,treeNode,resolve) {
+				this.searchData.parentId= row.id;
+				this.$HTTP.post(`/api/blade-cps/product/lazy/tree?current=1&size=-1&id=${row.id}`).then(res=> {
+					if(res.code == 200) {
+						resolve(res.data.records);
+					}
+				})
+			},
 			delIcon(index) {
 				this.checkData.splice(index,1);
 			},
@@ -210,8 +260,15 @@
 				})
 			},
 			delTypeDataSingle(type) {
+				if(this.delTypeNum == 0) {  //鍒犻櫎浜у搧
+					var url = "/api/blade-cps/product/remove";
+					var stopUrl = "/api/blade-cps/product/change-status";
+				}else if(this.delTypeNum == 1) {  //鍒犻櫎浜у搧绫诲瀷
+					var url = "/api/blade-cps/product-type/remove";
+					var stopUrl = "/api/blade-cps/product-type/change-status";
+				}
 				if(type == 0) {  //鍒犻櫎
-					this.$HTTP.delete(`/api/blade-cps/product-type/remove`,[this.id]).then(res=> {
+					this.$HTTP.delete(url,[this.id]).then(res=> {
 						if(res.code == 200) {
 							this.$message.success("鎿嶄綔鎴愬姛");
 							this.delTypeModel = false;
@@ -224,7 +281,7 @@
 						ids: [this.id],
 						status: 0
 					}
-					this.$HTTP.put(`/api/blade-cps/product-type/change-status`,obj).then(res=> {
+					this.$HTTP.put(stopUrl ,obj).then(res=> {
 						if(res.code == 200) {
 							this.$message.success("鎿嶄綔鎴愬姛");
 							this.delTypeModel = false;
@@ -261,7 +318,8 @@
 					}
 				})
 			},
-			del_product_type(row) {
+			del_product_type(row,index,type) {
+				this.delTypeNum = tyype;
 				this.id = row.id;
 				this.delTypeModel = true;
 			},
@@ -302,7 +360,7 @@
 		        done();
 		    },
 			getExport() {
-				this.$HTTP.get(`/api/blade-cps/employee/export-employee?` + this.$TOOL.qsStringify(this.searchData)).then(res => {
+				this.$HTTP.post(`/api/blade-cps/product/export-product`,this.searchData).then(res => {
 					if (res.code == 200) {
 						window.open(res.data.link);
 					}
@@ -322,23 +380,28 @@
 			},
 			searchClearBtn() {
 				this.searchData = {
-					code: "",
-					ProductValue: "",
+					keyWord: "",
+					standardModel: "",
+					status: "1",
+					typeId: [],
 					current: "1",
 					size: "15"
 				}
-				this.searchBtn();
+				this.searchBtn0();
+			},
+			refresh_product_type() {
+				this.searchClearBtn();
 			},
 			searchclick() {
 				this.searchData.current = "1";
 				this.searchData.size = "15";
-				this.searchBtn();
+				this.searchBtn0();
 			},
-			searchBtn() {
-				this.$HTTP.get("/api/blade-system/Product/parent-list",this.searchData).then(res=> {
+			searchBtn0() {
+				this.$HTTP.post("/api/blade-cps/product/lazy/tree?current=1&size=15&id=0",this.searchData).then(res=> {
 					if(res.code == 200) {
-						this.tableData = res.data.records;
-						this.total = res.data.total;
+						this.productTableData = res.data.records;
+						this.total0 = res.data.total;
 					}
 				})
 			},
@@ -358,7 +421,7 @@
 					this.$HTTP.post("/api/blade-system/Product/remove?ids="+row.id).then(res=> {
 						if(res.code == 200) {
 							that.$message.success("鎿嶄綔鎴愬姛");
-							that.searchBtn();
+							that.searchBtn1();
 						}
 					})
 				}).catch(() => {
@@ -369,16 +432,16 @@
 			addData(){
 				this.dialog.save = true
 				this.$nextTick(() => {
-					this.$refs.saveDialog.open()
+					this.$refs.saveDialog.open(this.typeIdList)
 				})
 			},
 			table_edit(row){
 				this.dialog.save = true
-				this.$HTTP.get("/api/blade-system/Product/detail?id="+row.id).then(res=> {
+				this.$HTTP.get(`/api/blade-cps/product/get/${row.id}`).then(res=> {
 					if(res.code == 200) {
 						this.dialog.save = true;
 						this.$nextTick(() => {
-							this.$refs.saveDialog.open('edit').setData(res.data);
+							this.$refs.saveDialog.open(this.typeIdList,'edit').setData(res.data);
 						})
 					}
 				})
@@ -390,46 +453,66 @@
 					this.$refs.saveDialog.open('show').setData(row)
 				})
 			},
-			handleSelectionChange(selection) {
-				this.selection = selection;
+			handleSelectionChange0(selection) {
+				this.selection0 = selection;
+			},
+			handleSelectionChange1(selection) {
+				this.selection1 = selection;
 			},
 			addTypeData() {
 				this.isAddType = true;
 			},
 			delTypeData() {
-
-			},
-			delData() {
-				if(this.selection.length == 0) {
+				if(this.selection1.length == 0) {
 					this.$message({
 			          message: '璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�',
 			          type: 'warning'
 			        });
 			        return;
 				}
-				var selStr = "";
-				this.selection.map(item=> {
-					selStr += item.id + ","
-				})
-				selStr = selStr.replace(/,$/, '');
-				var that = this;
-				this.$HTTP.post("/api/blade-system/Product/remove?ids="+selStr).then(res=> {
-					if(res.code == 200) {
-						that.$message.success("鎿嶄綔鎴愬姛");
-						that.searchclick();
-					}
-				})
 			},
-			handleSizeChange(val) {
+			delData() {
+				if(this.selection0.length == 0) {
+					this.$message({
+			          message: '璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�',
+			          type: 'warning'
+			        });
+			        return;
+				}
+				// var selStr = "";
+				// this.selection1.map(item=> {
+				// 	selStr += item.id + ","
+				// })
+				// selStr = selStr.replace(/,$/, '');
+				// var that = this;
+				// this.$HTTP.post("/api/blade-system/Product/remove?ids="+selStr).then(res=> {
+				// 	if(res.code == 200) {
+				// 		that.$message.success("鎿嶄綔鎴愬姛");
+				// 		that.searchclick();
+				// 	}
+				// })
+			},
+			handleSizeChange0(val) {
 				console.log(`姣忛〉 ${val} 鏉);
 				this.searchData.current = "1";
 				this.searchData.size = val;
-				this.searchBtn();
+				this.searchBtn0();
 			},
-			handleCurrentChange(val) {
+			handleCurrentChange0(val) {
 				console.log(`褰撳墠椤�: ${val}`);
 				this.searchData.current = val;
-				this.searchBtn();
+				this.searchBtn0();
+			},
+			handleSizeChange1(val) {
+				console.log(`姣忛〉 ${val} 鏉);
+				this.searchData.current = "1";
+				this.searchData.size = val;
+				this.searchBtn1();
+			},
+			handleCurrentChange1(val) {
+				console.log(`褰撳墠椤�: ${val}`);
+				this.searchData.current = val;
+				this.searchBtn1();
 			}
 		}
 	}
@@ -446,7 +529,7 @@
 		padding-right: 8px;
 		margin-bottom: 8px;
 	}
-	.multipleTableRef {
+	.multipleTableRef1,.multipleTableRef0 {
 		margin-bottom: 8px;
 	}
 	.search-condition {
@@ -498,7 +581,6 @@
 	.delBtn:nth-child(1) {
 		margin-right: 4px;
 	}
-
 	.delBtn:hover {
 		background-color: #f34d5b;
 		border-color: #f34d5b;
@@ -546,4 +628,8 @@
 		display: inline-block;
 		min-width: 80px;
 	}
+	.viewDetial {
+		color: #337ecc;
+		cursor: pointer;
+	}
 </style>

--
Gitblit v1.9.3