From 3ef19c59f59bb1b5a43434b8d14ec12e06d505b0 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期二, 19 三月 2024 13:07:19 +0800
Subject: [PATCH] 检验下单-下发功能更新

---
 src/components/do/b1-ins-order/add.vue |  204 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 166 insertions(+), 38 deletions(-)

diff --git a/src/components/do/b1-ins-order/add.vue b/src/components/do/b1-ins-order/add.vue
index 23d27c7..fc68c15 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">
@@ -361,6 +361,35 @@
 				<el-button type="primary" @click="addTemplateDia" :loading="templateLoading">纭� 瀹�</el-button>
 			</span>
 		</el-dialog>
+    <el-dialog title="妫�楠屼笅鍙�" :visible.sync="issuedDialogVisible" width="400px">
+      <div class="body" style="max-height: 60vh;">
+        <el-row>
+          <el-col class="search_thing" :span="22">
+            <div class="search_label"><span class="required-span">* </span>绾﹀畾鏃堕棿锛�</div>
+            <div class="search_input">
+              <el-date-picker size="small" v-model="distributeData.appointed" type="date" placeholder="閫夋嫨鏃ユ湡"
+                value-format="yyyy-MM-dd" style="width: 100%;" format="yyyy-MM-dd">
+              </el-date-picker>
+            </div>
+          </el-col>
+          <el-col class="search_thing" :span="22">
+            <div class="search_label"><span class="required-span">* </span>鎸囨淳浜哄憳锛�</div>
+            <div class="search_input">
+              <el-select v-model="distributeData.userId" placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
+                <el-option v-for="item in personList" :key="item.value" :label="item.label" :value="item.value">
+                </el-option>
+              </el-select>
+            </div>
+          </el-col>
+        </el-row>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-row>
+          <el-button @click="issuedDialogVisible=false">鍙� 娑�</el-button>
+          <el-button type="primary" @click="submitForm2" :loading="upLoad">纭� 瀹�</el-button>
+        </el-row>
+      </span>
+    </el-dialog>
 	</div>
 </template>
 
@@ -383,12 +412,7 @@
 		data() {
 			return {
 				template: null,
-				templates: [
-          {
-            label:'0000',
-            value:1
-          }
-        ],
+				templates: [],
 				addObj: {
 					entrustCode: null,
 					custom: null,
@@ -455,13 +479,22 @@
 				saveLoad: false,
         templateDia:false,
         templateLoading:false,
-        templateName:''
+        templateName:'',
+        issuedDialogVisible:false,
+        distributeData:{
+          appointed:'',
+          userId:''
+        },
+        personList:[],
+        upLoad:false,
 			}
 		},
 		mounted() {
 			this.selectEnumByCategoryForType()
 			this.getUserNow()
 			this.selectStandardTreeList()
+      this.selectInsOrderTemplate()
+      this.getAuthorizedPerson();
       if(this.active==1){
         // 涓嬪崟娴佺▼
       }else {
@@ -480,6 +513,18 @@
       }
 		},
 		methods: {
+      getAuthorizedPerson() {
+				this.$axios.get(this.$api.user.getUserMenu).then(res => {
+					let data = []
+					res.data.forEach(a => {
+						data.push({
+							label: a.name,
+							value: a.id
+						})
+					})
+					this.personList = data
+				})
+      },
 			selectEnumByCategoryForType() {
 				this.$axios.post(this.$api.enums.selectEnumByCategory, {
 					category: "绱ф�ョ▼搴�"
@@ -503,20 +548,43 @@
 				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('宸叉彁浜�')
+            // 濡傛灉绱ф�ョ▼搴︿负绱ф�ワ紝闇�瑕佺洿鎺ヤ笅鍙戜汉鍛�
+            if(this.addObj.type==2){
+              this.issuedDialogVisible = true;
+              this.$axios.post(this.$api.insOrder.selectOrderManDay,{
+                id: res.data
+              }).then(ress=>{
+                // TODO 闇�瑕佸啀纭涓�涓嬭繑鍥炲��
+                this.distributeData.orderId = res.data
+                // this.distributeData.sampleId = res.data.sampleId
+                this.distributeData.appointed = ress.data
+              })
+            }else{
+              this.$parent.playOrder(0)
+            }
+          })
+        }
 			},
       upInsOrderOfState(state){
         this.saveLoad = true
@@ -532,6 +600,36 @@
 					if(res.code==201)return
 					this.$message.success('鎻愪氦鎴愬姛')
 					this.$parent.playOrder(0)
+				})
+      },
+      // 涓嬪彂
+      submitForm2(){
+        if(this.distributeData.appointed==null||this.distributeData.appointed==''){
+					this.$message.error('绾﹀畾鏃堕棿鏈~鍐�')
+					return
+				}
+        if(this.distributeData.userId==null||this.distributeData.userId==''){
+					this.$message.error('鎸囨淳浜哄憳鏈~鍐�')
+					return
+				}
+				this.upLoad = true;
+				this.$axios.post(this.$api.insOrder.upInsOrder, {
+					orderId: this.distributeData.orderId,
+					sampleId: this.distributeData.sampleId,
+					appointed: this.distributeData.appointed,
+					userId: this.distributeData.userId
+				}).then(res => {
+					if (res.code === 201) {
+						this.upLoad = false
+						return
+					}
+					this.$message.success('鎻愪氦鎴愬姛')
+					this.upLoad = false
+					this.issuedDialogVisible = false
+					this.$parent.playOrder(0)
+				}).catch(e => {
+					this.$message.error('淇敼澶辫触')
+					this.upLoad = false
 				})
       },
 			getUserNow() {
@@ -692,34 +790,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