lizhenhao 2 лет назад
Родитель
Сommit
1b1a612c05
1 измененных файлов с 58 добавлено и 45 удалено
  1. 58 45
      src/views/modules/cw/reimbursementApproval/info/ReimbursementForm.vue

+ 58 - 45
src/views/modules/cw/reimbursementApproval/info/ReimbursementForm.vue

@@ -1,6 +1,6 @@
 <template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
   <div>
-    <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="formReadOnly"
+    <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="status === 'audit' || status === 'taskFormDetail'"
              label-width="100px" @submit.native.prevent>
 
       <el-divider content-position="left"><i class="el-icon-document"></i> 基础信息</el-divider>
@@ -106,7 +106,7 @@
       <div v-if="inputForm.sourceType === '1'">
         <el-divider content-position="left"><i class="el-icon-document"></i>
           项目报销详情
-          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || this.formReadOnly" size="mini" @click="insertEvent('detail')" plain>
+          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="mini" @click="insertEvent('detail')" plain>
             新增
           </el-button>
         </el-divider>
@@ -184,7 +184,7 @@
       <div v-if="inputForm.sourceType === '2'">
         <el-divider content-position="left"><i class="el-icon-document"></i>
           合同报销详情
-          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || this.formReadOnly" size="mini" @click="insertEvent('contract_detail')" plain>
+          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="mini" @click="insertEvent('contract_detail')" plain>
             新增
           </el-button>
         </el-divider>
@@ -262,7 +262,7 @@
       <div v-if="inputForm.sourceType === '3'">
         <el-divider content-position="left"><i class="el-icon-document"></i>
           报告报销详情
-          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || this.formReadOnly" size="mini" @click="insertEvent('report_detail')" plain>
+          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="mini" @click="insertEvent('report_detail')" plain>
             新增
           </el-button>
         </el-divider>
@@ -340,7 +340,7 @@
       <div v-if="inputForm.sourceType === '4'">
         <el-divider content-position="left"><i class="el-icon-document"></i>
           其他报销详情
-          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || this.formReadOnly" size="mini" @click="insertEvent('others')" plain>
+          <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail'" size="mini" @click="insertEvent('others')" plain>
             新增
           </el-button>
         </el-divider>
@@ -495,7 +495,7 @@
       </div>
       <el-divider content-position="left"><i class="el-icon-document"></i>
         专用发票信息
-        <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || this.formReadOnly " size="mini" @click="insertEvent('amount')" plain>
+        <el-button style="margin-left: 20px" type="primary" :disabled="method==='view' || status === 'audit' || status === 'taskFormDetail' " size="mini" @click="insertEvent('amount')" plain>
           新增
         </el-button>
       </el-divider>
@@ -596,6 +596,20 @@
   import MaterialManagementService from '@/api/materialManagement/MaterialManagementService'
   import MaterialManagementDialog from '../../../materialManagement/file/MaterialManagementDialog'
   export default {
+    props: {
+      businessId: {
+        type: String,
+        default: ''
+      },
+      formReadOnly: {
+        type: Boolean,
+        default: false
+      },
+      status: {
+        type: String,
+        default: ''
+      }
+    },
     data () {
       return {
         validRules: {
@@ -652,7 +666,8 @@
           tradeTotalPrice: '',
           purchaseId: '',
           departmentName: ''
-        }
+        },
+        keyWatch: ''
       }
     },
     ReimbursementApprovalService: null,
@@ -671,16 +686,6 @@
       this.commonApi = new CommonApi()
       this.materialManagementService = new MaterialManagementService()
     },
-    props: {
-      businessId: {
-        type: String,
-        default: ''
-      },
-      formReadOnly: {
-        type: Boolean,
-        default: false
-      }
-    },
     components: {
       UpLoadComponent,
       SelectUserTree,
@@ -697,6 +702,14 @@
       MaterialManagementDialog
     },
     computed: {
+      bus: {
+        get () {
+          return this.businessId
+        },
+        set (val) {
+          this.businessId = val
+        }
+      },
       name () {
         return JSON.parse(localStorage.getItem('user')).name
       },
@@ -708,19 +721,24 @@
       }
     },
     watch: {
-      'businessId': {
+      'keyWatch': {
         handler (newVal) {
-          if (this.businessId && this.businessId !== 'false') {
-            this.init('edit', this.businessId)
+          if (this.commonJS.isNotEmpty(this.bus)) {
+            this.init('', this.bus)
           } else {
-            this.init('clean', '')
+            this.$nextTick(() => {
+              this.$refs.inputForm.resetFields()
+            })
           }
-        },
-        immediate: true,
-        deep: false
+        }
       }
     },
     methods: {
+      getKeyWatch (keyWatch) {
+        this.keyWatch = keyWatch
+      },
+      getUpload () {
+      },
       init (method, id) {
         this.method = method
         this.inputForm = {
@@ -747,9 +765,9 @@
         if (method === 'add') {
           this.title = `新建报销类型`
         } else if (method === 'edit') {
-          this.inputForm.id = id
           this.title = '修改报销类型'
         }
+        this.inputForm.id = id
         this.visible = true
         this.loading = false
         this.$nextTick(() => {
@@ -766,28 +784,23 @@
           if (this.commonJS.isEmpty(this.inputForm.reimDate)) {
             this.inputForm.reimDate = new Date()
           }
-          if (this.formReadOnly === true && this.businessId !== 'false') {
+          console.log('this.status1', this.status)
+          console.log('id', this.inputForm.id)
+          if (this.status === 'audit' || this.status === 'taskFormDetail') {
+            console.log('this.status', this.status)
             method = 'view'
           }
-          if (method === 'edit' || method === 'view') { // 修改或者查看
-            this.loading = true
-            this.$refs.inputForm.resetFields()
-            this.reimbursementApprovalService.findById(this.inputForm.id).then(({data}) => {
-              this.inputForm = this.recover(this.inputForm, data)
-              this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'reimbursement')
-              this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
-              if (this.commonJS.isNotEmpty(this.inputForm.purchaseId)) {
-                this.startPur(this.inputForm.purchaseId)
-              }
-              this.loading = false
-            })
-            // this.reimbursementService.findById(this.inputForm.id).then(({data}) => {
-            //   this.inputForm = this.recover(this.inputForm, data)
-            //   this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'reimbursement')
-            //   this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
-            //   this.loading = false
-            // })
-          }
+          this.loading = true
+          this.$refs.inputForm.resetFields()
+          this.reimbursementApprovalService.findById(this.inputForm.id).then(({data}) => {
+            this.inputForm = this.recover(this.inputForm, data)
+            this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
+            this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'reimbursement')
+            if (this.commonJS.isNotEmpty(this.inputForm.purchaseId)) {
+              this.startPur(this.inputForm.purchaseId)
+            }
+            this.loading = false
+          })
           if (method !== 'edit' && method !== 'view') {
             this.$refs.uploadComponent.newUpload(method, [], 'reimbursement')
           }