From bbc0f06f17c9c3c9ed325af581dfdfc9b9dcaa82 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期一, 18 三月 2024 15:16:03 +0800
Subject: [PATCH] 完成检验下单模板功能

---
 src/components/do/b1-ins-order/add.vue |  110 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 73 insertions(+), 37 deletions(-)

diff --git a/src/components/do/b1-ins-order/add.vue b/src/components/do/b1-ins-order/add.vue
index 23d27c7..063abfc 100644
--- a/src/components/do/b1-ins-order/add.vue
+++ b/src/components/do/b1-ins-order/add.vue
@@ -88,10 +88,10 @@
 			<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==1">
-						<el-option v-for="(a, ai) in templates" :key="ai" :value="a.value" :label="a.label">
-              <span style="float: left">{{ a.label }}</span>
-              <i class="el-icon-delete" style="float: right; color: #66b1ff; font-size: 16px" @click.stop="handleDelete"></i>
+					<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="templateDia=true" v-show="active==1">
@@ -383,12 +383,7 @@
 		data() {
 			return {
 				template: null,
-				templates: [
-          {
-            label:'0000',
-            value:1
-          }
-        ],
+				templates: [],
 				addObj: {
 					entrustCode: null,
 					custom: null,
@@ -462,6 +457,7 @@
 			this.selectEnumByCategoryForType()
 			this.getUserNow()
 			this.selectStandardTreeList()
+      this.selectInsOrderTemplate()
       if(this.active==1){
         // 涓嬪崟娴佺▼
       }else {
@@ -503,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
@@ -692,34 +698,64 @@
 				}
 				return '';
 			},
+      selectInsOrderTemplate(){
+        this.$axios.get(this.$api.insOrder.selectInsOrderTemplate).then(res=>{
+					if(res.code==201)return
+					this.templates = res.data
+				})
+      },
       // 鍒犻櫎妯℃澘--璋冪敤鎺ュ彛
-      handleDelete(){
+      handleDelete(row){
         this.$confirm('鏄惁鍒犻櫎褰撳墠鏁版嵁?', "璀﹀憡", {
 							confirmButtonText: "纭畾",
 							cancelButtonText: "鍙栨秷",
 							type: "warning"
 						}).then(() => {
-							// this.$axios.post(this.delUrl, {
-							// 	id: row.id
-							// }).then(res => {
-							// 	if (res.code === 201) {
-							// 		return
-							// 	}
-							// 	this.$message.success('鍒犻櫎鎴愬姛')
-							// 	this.selectList()
-							// }).catch(e => {
-							// 	this.$message.error('鍒犻櫎澶辫触')
-							// })
+							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;
+				})
+      },
 		}
 	}
 </script>

--
Gitblit v1.9.3