From 07506d995a2ecff9decc0b3545caf1052308a228 Mon Sep 17 00:00:00 2001
From: 李林 <z1292839451@163.com>
Date: 星期一, 18 三月 2024 15:21:53 +0800
Subject: [PATCH] 功能调整

---
 src/components/do/b1-ins-order/add.vue |  154 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 127 insertions(+), 27 deletions(-)

diff --git a/src/components/do/b1-ins-order/add.vue b/src/components/do/b1-ins-order/add.vue
index b1b4b22..050fbd9 100644
--- a/src/components/do/b1-ins-order/add.vue
+++ b/src/components/do/b1-ins-order/add.vue
@@ -41,6 +41,12 @@
 		font-size: 18px;
 	}
 
+  .el-select-dropdown__item {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+
 </style>
 <style>
 	.ins_order_add .el-input-group__append,
@@ -82,13 +88,16 @@
 			<el-row class="title">
 				<el-col :span="6" style="padding-left: 20px;">濮旀墭鍗曚俊鎭�</el-col>
 				<el-col :span="18" style="text-align: right;">
-					<el-select v-model="template" size="medium" placeholder="涓嬪崟妯℃澘" style="margin-right: 10px;" v-show="active<2">
-						<el-option v-for="(a, ai) in templates" :key="ai" :value="a.value" :label="a.label"></el-option>
+					<el-select v-model="template" size="medium" placeholder="涓嬪崟妯℃澘" style="margin-right: 10px;" v-show="active==1" @change="selectInsOrderTemplateById">
+						<el-option v-for="(a, ai) in templates" :key="ai" :value="a.id" :label="a.name">
+              <span style="float: left">{{ a.name }}</span>
+              <i class="el-icon-delete" style="float: right; color: #66b1ff; font-size: 16px" @click.stop="handleDelete(a)"></i>
+            </el-option>
 					</el-select>
-					<el-button size="medium" @click="" v-show="active<2">
+					<el-button size="medium" @click="templateDia=true" v-show="active==1">
 						<span style="color: #3A7BFA;">淇濆瓨妯℃澘</span>
 					</el-button>
-					<el-button size="medium" type="primary" @click="save" :loading="saveLoad" v-show="active<2">鎻愪氦</el-button>
+					<el-button size="medium" type="primary" @click="save" :loading="saveLoad" v-show="active==1">鎻愪氦</el-button>
           <el-button size="medium" @click="upInsOrderOfState(2)" :loading="saveLoad" v-show="active==3">瀹℃牳涓嶉�氳繃</el-button>
           <el-button size="medium" type="primary" @click="upInsOrderOfState(1)" :loading="saveLoad" v-show="active==3">瀹℃牳閫氳繃</el-button>
 					<el-button size="medium" @click="$parent.playOrder(0)">
@@ -160,14 +169,14 @@
 			</el-row>
 		</div>
 		<div>
-			<div style="text-align: right;line-height: 45px;">
-				<el-button type="primary" size="small" @click="addSampleDia = true" v-show="active<2">娣诲姞鏍峰搧</el-button>
+			<div style="text-align: right;line-height: 45px;" v-if="active<2">
+				<el-button type="primary" size="small" @click="addSampleDia = true"  >娣诲姞鏍峰搧</el-button>
 				<el-button size="small" @click="delSample">
-					<span style="color: #3A7BFA;" v-show="active<2">鍒犻櫎鏍峰搧</span>
+					<span style="color: #3A7BFA;">鍒犻櫎鏍峰搧</span>
 				</el-button>
 			</div>
-			<el-table class="el-table" ref="sampleTable" :data="sampleList" height="250px" tooltip-effect="dark" border
-				@selection-change="selectSample" highlight-current-row @row-click="rowClick">
+			<el-table class="el-table sampleTable" ref="sampleTable" :data="sampleList" height="250px" tooltip-effect="dark" border
+				@selection-change="selectSample" highlight-current-row @row-click="rowClick" style="margin-top: 10px;">
 				<el-table-column type="selection" width="60"></el-table-column>
 				<el-table-column type="index" label="搴忓彿" width="65" align="center"></el-table-column>
 				<el-table-column prop="sample" label="鏍峰搧鍚嶇О" align="center" show-overflow-tooltip
@@ -211,7 +220,7 @@
 				<el-table-column label="鎿嶄綔" width="65" align="center">
 					<template slot-scope="scope">
 						{{scope.index}}
-						<el-button type="text" size="small" @click="sampleList.splice(scope.$index, 1)" :disabled="active!=1">鍒犻櫎</el-button>
+						<el-button type="text" size="small" @click="delSampleAndProduct" :disabled="active!=1">鍒犻櫎</el-button>
 					</template>
 				</el-table-column>
 			</el-table>
@@ -340,6 +349,18 @@
 				<el-button type="primary" @click="onSample()" :loading="getProductLoad">纭� 瀹�</el-button>
 			</span>
 		</el-dialog>
+    <el-dialog title="淇濆瓨妯℃澘" :visible.sync="templateDia" width="30%">
+			<div class="body" style="height: 10vh;display: flex;align-items: center;" v-if="templateDia">
+        <div class="search_label"><span class="required-span">* </span>妯℃澘鍚嶇О锛�</div>
+        <div class="search_input">
+          <el-input size="small" clearable v-model="templateName"></el-input>
+        </div>
+			</div>
+			<span slot="footer" class="dialog-footer">
+				<el-button @click="templateDia = false">鍙� 娑�</el-button>
+				<el-button type="primary" @click="addTemplateDia" :loading="templateLoading">纭� 瀹�</el-button>
+			</span>
+		</el-dialog>
 	</div>
 </template>
 
@@ -426,13 +447,17 @@
 				productList: [],
 				productIds: [],
 				getProductLoad: false,
-				saveLoad: false
+				saveLoad: false,
+        templateDia:false,
+        templateLoading:false,
+        templateName:''
 			}
 		},
 		mounted() {
 			this.selectEnumByCategoryForType()
 			this.getUserNow()
 			this.selectStandardTreeList()
+      this.selectInsOrderTemplate()
       if(this.active==1){
         // 涓嬪崟娴佺▼
       }else {
@@ -443,7 +468,10 @@
 				}).then(res => {
           this.addObj = {...res.data.insOrder};
           this.addObj.type = String(this.addObj.type)
-          this.sampleList = res.data.sampleProduct
+          this.sampleList = this.HaveJson(res.data.sampleProduct);
+          this.$nextTick(()=>{
+            this.$refs.sampleTable.doLayout()
+          })
 				})
       }
 		},
@@ -471,20 +499,30 @@
 				this.selectUserDia = false
 			},
 			save() {
-				this.saveLoad = true
-				this.$axios.post(this.$api.insOrder.addInsOrder,{
-					insOrder: this.addObj,
-					list: this.sampleList
-				},{
-					headers: {
-						'Content-Type': 'application/json'
-					}
-				}).then(res=>{
-					this.saveLoad = false
-					if(res.code==201)return
-					this.$message.success('宸叉彁浜�')
-					this.$parent.playOrder(0)
-				})
+        if(!this.addObj.custom){
+          this.$message.error('鏈�夋嫨涓嬪崟瀹㈡埛')
+        }else if(!this.addObj.type){
+          this.$message.error('鏈�夋嫨绱ф�ョ▼搴�')
+        }else if(this.sampleList.length<1){
+          this.$message.error('璇锋坊鍔犱竴涓牱鍝�')
+        }else if(!this.sampleList.every(m=>m.sampleCode)){
+          this.$message.error('杈撳叆鏍峰搧缂栧彿')
+        }else{
+          this.saveLoad = true
+          this.$axios.post(this.$api.insOrder.addInsOrder,{
+            insOrder: this.addObj,
+            list: this.sampleList
+          },{
+            headers: {
+              'Content-Type': 'application/json'
+            }
+          }).then(res=>{
+            this.saveLoad = false
+            if(res.code==201)return
+            this.$message.success('宸叉彁浜�')
+            this.$parent.playOrder(0)
+          })
+        }
 			},
       upInsOrderOfState(state){
         this.saveLoad = true
@@ -659,7 +697,69 @@
 					return 'warning-row';
 				}
 				return '';
-			}
+			},
+      selectInsOrderTemplate(){
+        this.$axios.get(this.$api.insOrder.selectInsOrderTemplate).then(res=>{
+					if(res.code==201)return
+					this.templates = res.data
+				})
+      },
+      // 鍒犻櫎妯℃澘--璋冪敤鎺ュ彛
+      handleDelete(row){
+        this.$confirm('鏄惁鍒犻櫎褰撳墠鏁版嵁?', "璀﹀憡", {
+							confirmButtonText: "纭畾",
+							cancelButtonText: "鍙栨秷",
+							type: "warning"
+						}).then(() => {
+							this.$axios.post(this.$api.insOrder.delInsOrderTemplate, {
+								id: row.id
+							}).then(res => {
+								if (res.code === 201) {
+									return
+								}
+								this.$message.success('鍒犻櫎鎴愬姛')
+								this.selectInsOrderTemplate()
+							}).catch(e => {
+								this.$message.error('鍒犻櫎澶辫触')
+							})
+						}).catch(() => {})
+      },
+      // 淇濆瓨妯℃澘
+      addTemplateDia(){
+        if(this.templateName){
+          this.templateLoading = true;
+          this.$axios.post(this.$api.insOrder.addInsOrderTemplate,{
+            name:this.templateName,
+            thing:JSON.stringify({addObj:this.addObj,sampleList:this.sampleList})
+          },{
+					headers: {
+						'Content-Type': 'application/json'
+					}
+				}).then(res=>{
+					if(res.code==201)return
+          this.templateLoading = false;
+          this.templateDia = false;
+          this.$message.success('淇濆瓨鎴愬姛')
+          this.selectInsOrderTemplate()
+          this.templateName = ''
+				})
+        }else{
+          this.$message.error('璇峰~鍐欐ā鏉垮悕绉�')
+        }
+      },
+      // 鏌ヨ妯℃澘
+      selectInsOrderTemplateById(e){
+        this.$axios.post(this.$api.insOrder.selectInsOrderTemplateById+'?id='+e).then(res=>{
+					if(res.code==201)return
+          let obj = JSON.parse(res.data)
+          this.addObj = obj.addObj;
+          this.sampleList = obj.sampleList;
+				})
+      },
+      delSampleAndProduct(){
+        this.sampleList.splice(scope.$index, 1)
+        this.productList = []
+      }
 		}
 	}
 </script>

--
Gitblit v1.9.3