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

---
 src/views/console/product-process/process-route/workmanship.vue |  263 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 241 insertions(+), 22 deletions(-)

diff --git a/src/views/console/product-process/process-route/workmanship.vue b/src/views/console/product-process/process-route/workmanship.vue
index f3b847a..c34c8a8 100644
--- a/src/views/console/product-process/process-route/workmanship.vue
+++ b/src/views/console/product-process/process-route/workmanship.vue
@@ -2,7 +2,7 @@
  * @Author: lzhe lzhe@example.com
  * @Date: 2024-05-24 11:25:26
  * @LastEditors: lzhe lzhe@example.com
- * @LastEditTime: 2024-05-24 15:05:44
+ * @LastEditTime: 2024-05-28 11:09:17
  * @FilePath: /src/views/console/product-process/process-route/workmanship.vue
  * @Description: 杩欐槸榛樿璁剧疆,璇疯缃甡customMade`, 鎵撳紑koroFileHeader鏌ョ湅閰嶇疆 杩涜璁剧疆: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 -->
@@ -11,45 +11,89 @@
 		<div class="main-content-left">
 			<div class="info-top-title">宸ヨ壓璺嚎</div>
 			<div style="margin-bottom: 12px;">
-				<el-button type="primary">鏂板</el-button>
-				<el-button type="primary" v-if="isCustomization">瀹氱増</el-button>
-				<el-button disabled>骞跺簭</el-button>
+				<el-button type="primary" @click="table_open">鏂板</el-button>
+				<el-button type="primary" v-if="isCustomization" @click="determineVersion">瀹氱増</el-button>
+				<el-button :disabled="mergeDisabled" @click="mergeBtn">骞跺簭</el-button>
 			</div>
-			<el-table ref="multipleTableRef0" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="HandleSelectionChange">
-				<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 ref="multipleTableRef0" :data="tableData" row-key="id" border :tree-props="{ children: 'children', hasChildren: 'has' }" style="width: 100%" class="multipleTableRef" @selection-change="HandleSelectionChange" @row-click="rowClick" default-expand-all>
+				<el-table-column type="selection" :selectable="setSelectable" width="55" />
+				<el-table-column prop="index" label="宸ュ簭椤哄簭">
+					<template #default="scope">
+						<span>{{scope.row.index || "-"}}</span>
+					</template>
+				</el-table-column>
+				<el-table-column prop="processCode" label="宸ュ簭缂栧彿"></el-table-column>
+				<el-table-column prop="processName" label="宸ュ簭鍚嶇О"></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="table_edit(scope.row, scope.$index)">鍒锋柊</el-button>
-						<el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">鍒犻櫎</el-button> -->
+						<el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">缂栬緫</el-button>
+						<el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)" v-if="scope.row.index">鍒犻櫎</el-button>
+						<el-button text type="primary" size="small" @click="table_remove(scope.row, scope.$index)" v-if="!scope.row.index">绉婚櫎</el-button>
 					</template>
 				</el-table-column>
 			</el-table>
 		</div>
 		<div class="main-content-right">
 			<div class="main-info-title">宸ュ簭淇℃伅</div>
-			<div class="addWorking" @click="table_open">娣诲姞宸ュ簭</div>
-			<!-- <ul>
+			<div class="addWorking" @click="table_open" v-if="!isCustomization">娣诲姞宸ュ簭</div>
+			<ul v-if="isCustomization">
 				<li>宸ュ簭缂栧彿<span></span></li>
 				<li>宸ュ簭鍚嶇О<span></span></li>
 				<li>宸ュ簭椤哄簭<span></span></li>
-			</ul> -->
+			</ul>
 		</div>
 	</div>
 	<save-dialog v-if="dialog.save" ref="saveDialog" @success="addRouteSuccess" @closed="dialog.save=false"></save-dialog>
+	<el-drawer v-model="drawer" title="娣诲姞宸ュ簭" direction="rtl" :before-close="handleClose" size="60%" modal-class="viewData">
+		<!-- 鏂板璺嚎 -->
+		<div class="addworkmanship">
+			<add-workmanship ref="addworkmanship" @success="handleSuccess" :isClear="isClear" :craftId="craftId"></add-workmanship>
+		</div>
+	</el-drawer>
+	<!-- 骞跺簭寮圭獥 -->
+	<el-dialog title="骞跺簭" v-model="mergeVisible" :width="500" destroy-on-close>
+		<el-form :inline="true" ref="mergeVisibleData" :model="mergeVisibleData" :rules="mergeVisibleRules" label-width="80px">
+			<el-row>
+				<el-col :span="24">
+					<el-form-item label="宸ュ簭缂栧彿" prop="processCode" style="width: 100%">
+						<el-input v-model="mergeVisibleData.processCode" placeholder="璇疯緭鍏ュ伐搴忕紪鍙�" clearable></el-input>
+					</el-form-item>
+				</el-col>
+				<el-col :span="24">
+					<el-form-item label="宸ュ簭鍚嶇О" prop="processName" style="width: 100%">
+						<el-input v-model="mergeVisibleData.processName" placeholder="璇疯緭鍏ュ伐搴忓悕绉�" clearable></el-input>
+					</el-form-item>
+				</el-col>
+			</el-row>
+		</el-form>
+		<template #footer>
+			<el-button @click="cencelMerge" >鍙栨秷</el-button>
+			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="mergeSubmit">纭畾</el-button>
+		</template>
+	</el-dialog>
 </template>
 
 <script>
+	import addWorkmanship from './addWorkmanship'
 	import saveDialog from './addWorking'
 	export default {
 		name: 'workmanship',
-		components: {saveDialog},
-		props: ["isCustomization"],
+		components: {saveDialog,addWorkmanship},
+		props: ["isCustomization","craftId"],
 		data() {
 			return {
+				mergeVisibleData: {
+					processCode: "",
+					processName: ""
+				},
+				mergeVisibleRules: {
+					processCode:[{required: true, message: '璇疯緭鍏ュ伐搴忕紪鍙�'}],
+					processName:[{required: true, message: '璇疯緭鍏ュ伐搴忓悕绉�'}]
+				},
+				mergeVisible: false,
+				mergeDisabled: true,
+				isClear: false,
+				drawer: false,
 				tableData: [],
 				selection: [],
 				dialog: {
@@ -58,16 +102,188 @@
 			}
 		},
 		mounted(){
-			
+		},
+		watch: {
+			craftId(val) {
+				if(val) {
+					this.getcraftlList();
+				}
+			}
 		},
 		methods: {
+			setSelectable(row,rowIndex) {
+				return !row.children && row.index;
+			},
+			cencelMerge() {
+				this.mergeVisible=false;
+				this.mergeVisibleData = {
+					processCode: "",
+					processName: ""
+				};
+			},
+			mergeSubmit() {
+				var that = this;
+				this.selection.forEach(item=> {
+					item.versionProcessId = item.id;
+				});
+				var obj = {
+					parallelVO: this.selection,
+					processCode: this.mergeVisibleData.processCode,
+					processName: this.mergeVisibleData.processName,
+					sort: 1,
+					versionId: this.craftId
+				}
+				this.$refs.mergeVisibleData.validate(async (valid) => {
+					if (valid) {
+						that.$HTTP.post("/api/blade-cps/production-craft-process/save-parallel",obj).then(res=> {
+							if(res.code == 200) {
+								that.mergeVisible = false;
+								that.$message.success("鎿嶄綔鎴愬姛");
+								that.getcraftlList();
+
+							}else {
+								that.$alert(res.message, "鎻愮ず", {type: 'error'});
+							}
+						})
+					}else{
+						return false;
+					}
+				})
+			},
+			mergeBtn() {
+				this.mergeVisible = true;
+			},
+			handleSuccess(value) {
+				this.drawer = false;
+				this.isClear = false;
+				this.getcraftlList();
+			},
+			getcraftlList() {
+				// this.$HTTP.get(`/api/blade-cps/production-craft-version/detail/${this.craftId}`).then(res=> {
+				// 	if(res.code == 200) {
+				// 		res.data.processList.forEach((item,index)=> {
+				// 			item.index = index + 1;
+				// 		});
+				// 		this.tableData = res.data.processList;
+				// 	}
+				// })
+				this.$HTTP.get(`/api/blade-cps/production-craft-process/child-tree?versionId=${this.craftId}`).then(res=> {
+					if(res.code == 200) {
+						res.data.forEach((item,index)=> {
+							if(item.children && item.children.length > 0) {
+								item.disabled = true;
+							}
+							item.index = index + 1;
+						})
+						this.tableData = res.data;
+					}
+				})
+			},
+			handleClose(done) {
+				this.isClear = true;
+				done();
+			},
+			determineVersion() {
+				var that = this;
+				this.$confirm(`宸ヨ壓璺嚎瀹氱増鍚庯紝涓嶆敮鎸佺紪杈戙�佸垹闄ゃ�佹坊鍔犲伐搴忥紝璇风‘璁ゆ槸鍚﹀畾鐗�?`, '', {
+					type: 'warning'
+				}).then(() => {
+					this.$HTTP.put(`/api/blade-cps/production-craft-version/fix-version/${this.craftId}`).then(res=> {
+						if(res.code == 200) {
+							that.$message.success("鎿嶄綔鎴愬姛");
+						}else {
+							this.$message.error(res.msg);
+						}
+					})
+				}).catch(() => {
+
+				})
+			},
+			rowClick(row, column, event) {
+				// this.id = row.id;
+				// this.getWorkDetail();
+				// this.getPage1();
+			},
+			addRouteSuccess(selection) {
+				selection.forEach((item,i)=> {
+					item.index = i+1;
+				})
+				this.tableData = selection;
+			},
 			HandleSelectionChange(selection) {
 				this.selection = selection;
+				if(this.selection.length >= 2) {
+					this.mergeDisabled = false;
+				}else {
+					this.mergeDisabled = true;
+				}
 			},
 			table_open() {
-				this.dialog.save = true
-				this.$nextTick(() => {
-					this.$refs.saveDialog.open();
+				if(this.isCustomization) {  //棣栭〉鐨勬柊寤�
+					this.drawer = true;
+				}else {  //鐗堟湰姝ラ涓殑鏂板缓
+					this.dialog.save = true
+					this.$nextTick(() => {
+						this.$refs.saveDialog.open();
+					})
+				}
+			},
+			table_edit(row,index) {
+				this.drawer = true;
+				this.$nextTick(()=> {
+					this.$refs.addworkmanship.setData(row);
+				})
+			},
+			table_del(row,index) {
+				var that = this;
+				this.$confirm(`纭瑕佸垹闄ゆ宸ュ簭鍚�?`, '', {
+					type: 'warning'
+				}).then(() => {
+					var obj = {
+						mainProcess: [],
+						normalProcess: that.tableData,
+						removeIds: [row.id],
+						versionId: that.craftId
+					}
+					this.$HTTP.post(`/api/blade-cps/production-craft-process/child-process-update`,obj).then(res=> {
+						if(res.code == 200) {
+							that.$message.success("鎿嶄綔鎴愬姛");
+							that.getcraftlList();
+						}
+					})
+				}).catch(() => {
+
+				})
+			},
+			table_remove(row,index) {
+				var that = this;
+				var tableData = [];
+				this.tableData.forEach(item=> {
+					if(item.children && item.children.lenght !=0) {
+						item.children.forEach(item1=> {
+							tableData.push(item1);
+						})
+					}else {
+						tableData.push(item);
+					}
+				})
+				this.$confirm(`姝ゅ伐搴忕Щ闄ゅ悗锛屽師骞跺簭灏嗕細杞寲涓哄父瑙勫簭銆傜‘瀹氱Щ闄ゅ悧锛焋, '', {
+					type: 'warning'
+				}).then(() => {
+					var obj = {
+						mainProcess: [],
+						normalProcess: tableData,
+						removeIds: [row.parentId],
+						versionId: that.craftId
+					}
+					this.$HTTP.post(`/api/blade-cps/production-craft-process/child-process-update`,obj).then(res=> {
+						if(res.code == 200) {
+							that.$message.success("鎿嶄綔鎴愬姛");
+							that.getcraftlList();
+						}
+					})
+				}).catch(() => {
+
 				})
 			}
 		}
@@ -89,7 +305,7 @@
     color: #333;
 }
 .main-content-left {
-	width: 70%;
+	width: 60%;
 }
 .main-content-right {
 	flex: 1;
@@ -120,4 +336,7 @@
 	font-size: 14px;
 	cursor: pointer;
 }
+.addworkmanship {
+	padding: 0 40px;
+}
 </style>

--
Gitblit v1.9.3