From 142ba3ed00220dcadf2a94e59664d5f1f027dbf4 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期三, 05 六月 2024 14:58:26 +0800
Subject: [PATCH] 新增附件上传

---
 src/components/do/b1-inspect-order-plan/Inspection.vue |  171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 167 insertions(+), 4 deletions(-)

diff --git a/src/components/do/b1-inspect-order-plan/Inspection.vue b/src/components/do/b1-inspect-order-plan/Inspection.vue
index 9b56e5b..ba5a5bb 100644
--- a/src/components/do/b1-inspect-order-plan/Inspection.vue
+++ b/src/components/do/b1-inspect-order-plan/Inspection.vue
@@ -320,6 +320,19 @@
           </tbody>
         </table>
       </div>
+      <el-upload :action="action"
+      :data="{
+        orderId:id
+      }"
+      v-show="state==1"
+      :on-success="handleSuccessUp" :show-file-list="false"
+        accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar' :headers="headers" :on-change="beforeUpload"
+        :on-error="onError" ref='upload'>
+        <el-button size="small" type="primary" :loading="upLoading">闄勪欢涓婁紶</el-button></el-upload>
+      <ValueTable class="value-table" ref="fileList" :url="$api.insOrderPlan.getFileList"
+        :componentData="componentData0"
+        :delUrl="$api.insOrderPlan.delfile"
+        :key="upIndex" style="height: 100%;margin-top: 16px;"/>
     </div>
     <el-drawer title="鍏夌氦鍒囨崲" :visible.sync="fiberOpticVisible" :size="500">
       <el-table class="el-table" ref="fiberOpticTable" :data="fiberOptic" height="100%" tooltip-effect="dark" border
@@ -422,6 +435,7 @@
 
 <script>
   import ValueTable from '../../tool/value-table.vue'
+  import file from '../../../util/file'
   export default {
     props: ['sonLaboratory', 'orderId', 'state'],
     components: {
@@ -457,6 +471,53 @@
             insState: {
               select: []
             },
+          },
+          currentId: '',
+          selectField: {},
+          requiredAdd: [],
+          requiredUp: []
+        },
+        componentData0: {
+          entity: {
+            insOrderId:''
+          },
+          isIndex: true,
+          showSelect: false,
+          select: false,
+          selectMethod: '',
+          sort: false,
+          init:false,
+          do: [
+          {
+						id: 'delete',
+						font: '鍒犻櫎',
+						type: 'text',
+						method: 'doDiy',
+            disabFun: (row, index) => {
+								return this.state!=1
+							}
+					}, {
+						id: 'handleDown',
+						font: '涓嬭浇',
+						type: 'text',
+						method: 'handleDown'
+					},
+          ],
+          isPage: false,
+          linkEvent: {},
+          tagField: {
+            type:{
+              select:[
+                {
+                  value: 1,
+                  label: '鍥剧墖'
+                },
+                {
+                  value: 2,
+                  label: '鏂囦欢'
+                }
+              ]
+            }
           },
           currentId: '',
           selectField: {},
@@ -499,8 +560,19 @@
         currentFiberOptic:null,//褰撳墠鍏夌氦
         currentBushing:null,//褰撳墠濂楃
         tableLoading:false,
+        upLoading:false
       }
     },
+    computed: {
+			headers() {
+				return {
+					'token': sessionStorage.getItem('token')
+				}
+			},
+			action() {
+				return this.javaApi + this.$api.insOrderPlan.uploadFile
+			}
+		},
     created() {
       this.componentData.entity.sonLaboratory = this.sonLaboratory;
       this.id = this.orderId;
@@ -521,6 +593,8 @@
           laboratory: this.sonLaboratory
         }).then(async res => {
           this.insOrder = res.data.insOrder;
+          this.componentData0.entity.insOrderId = val;
+          this.$refs.fileList.selectList()
           this.urgentList.forEach(m => {
             if (m.value == this.insOrder.type) {
               this.insOrder.typeName = m.label
@@ -1414,20 +1488,67 @@
         }
         this.addVerifyDia = false
         this.submitLoading = true;
-        this.$axios.post(this.$api.insOrderPlan.submitPlan, {
+        this.$axios.post(this.$api.insOrderPlan.checkSubmitPlan, {
           orderId: this.orderId,
           laboratory: this.sonLaboratory,
-          verifyUser: this.verifyUser
         }).then(res => {
           if (res.code === 200) {
-            this.$message.success("鎿嶄綔鎴愬姛")
-            this.$emit('goback')
+            console.log(res.data)
+            if(!res.data||res.data.length==0){
+              this.$axios.post(this.$api.insOrderPlan.submitPlan, {
+                orderId: this.orderId,
+                laboratory: this.sonLaboratory,
+                verifyUser: this.verifyUser
+              }).then(res => {
+                if (res.code === 200) {
+                  this.$message.success("鎿嶄綔鎴愬姛")
+                  this.$emit('goback')
+                }
+                this.submitLoading = false;
+              }).catch(error => {
+                console.error(error)
+                this.submitLoading = false;
+              })
+            }else{
+              let newData = []
+              const h = this.$createElement
+              for (let i in res.data) {
+                const lastChar = res.data[i].slice(-1);
+                if(lastChar=='-'){
+                  res.data[i] = res.data[i].slice(0, -1);
+                }
+                newData.push(h('p', {style: 'font-size: 12px;'}, (Number(i)+1)+'銆�'+res.data[i]))
+              }
+              newData.push(h('p',  { style: 'font-size: 16px;color:#000;margin-top:12px' },'浠ヤ笂椤圭洰涓嶅悎鏍硷紝纭畾鎻愪氦锛�'))
+              this.$confirm('鎻愮ず',{
+                title:'鎻愮ず',
+                message: h('div', null, newData),
+                confirmButtonText: "纭畾",
+                cancelButtonText: "鍙栨秷",
+                type: ""
+              }).then(() => {
+                this.$axios.post(this.$api.insOrderPlan.submitPlan, {
+                  orderId: this.orderId,
+                  laboratory: this.sonLaboratory,
+                  verifyUser: this.verifyUser
+                }).then(res => {
+                  if (res.code === 200) {
+                    this.$message.success("鎿嶄綔鎴愬姛")
+                    this.$emit('goback')
+                  }
+                }).catch(error => {
+                  console.error(error)
+                })
+              }).catch(() => {})
+            }
+
           }
           this.submitLoading = false;
         }).catch(error => {
           console.error(error)
           this.submitLoading = false;
         })
+        return
       },
       saveInsContext() {
         this.$axios.post(this.$api.insOrderPlan.saveInsContext, {
@@ -1515,6 +1636,48 @@
           }
         })
         this.getTableLists()
+      },
+      handleSuccessUp(response, ) {
+        this.upLoading = false;
+				if (response.code == 200) {
+          this.$message.success('涓婁紶鎴愬姛');
+          this.$refs.fileList.selectList()
+				}
+			},
+      beforeUpload(file) {
+				if (file.size > 1024 * 1024 * 10) {
+					this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
+					this.$refs.upload.clearFiles()
+					return false;
+				} else {
+          this.upLoading = true;
+					return true;
+				}
+			},
+      onError(err, file, fileList) {
+				this.$message.error('涓婁紶澶辫触')
+				this.$refs.upload.clearFiles()
+			},
+      handleDown(row){
+        this.$axios.post(this.$api.insOrderPlan.downFile, {
+          id: row.id,
+        }).then(res => {
+          if (res.code === 200) {
+            let url = '';
+            if(res.data.type==1){
+              url = this.javaApi+'/img/'+res.data.url
+              file.downloadIamge(url,row.fileName)
+            }else{
+              url = this.javaApi+'/word/'+res.data.url
+              const link = document.createElement('a');
+              link.href = url;
+              link.download = row.fileName;
+              link.click();
+            }
+          }
+        }).catch(error => {
+
+        })
       }
     }
   }

--
Gitblit v1.9.3