Эх сурвалжийг харах

编辑出库(未完成)

chris 2 жил өмнө
parent
commit
be37a34787

+ 52 - 31
src/views/modules/warehouse/stock-order-outbound.vue

@@ -1,10 +1,5 @@
 <!-- 出库申请 -->
 <template>
-  <!-- <el-dialog
-    title="出库申请"
-    width="80%"
-    :close-on-click-modal="false"
-    :visible.sync="visible"> -->
     <div>
       <div class="my-title">出库申请</div>
       <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="auto">
@@ -70,13 +65,12 @@
         <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
       </span>
     </div>
-  <!-- </el-dialog> -->
 </template>
 
 <script>
   import UserComponent from '../common/user-component'
   import DictSelect from '../sys/dict-select'
-  import { outboundBatch } from '@/api/warehouse'
+  import {getBoundDetails, outboundBatch} from '@/api/warehouse'
   import {getUUID} from '../../../utils'
   import MaterialComponent from '../common/material-component'
   export default {
@@ -95,34 +89,61 @@
       onChose () {
         this.$emit('onChose')
       },
-      init () {
+      async init (id) {
         this.visible = true
+        this.id = id || 0
         this.dataForm = {}
         this.dataList = []
-        this.addOne()
+        if (id) {
+          // 获取详情
+          await getBoundDetails(id).then(({data}) => {
+            if (data && data.code === '200') {
+              if (data.data[0]) {
+                this.dataForm = {
+                  recordCode: data.data[0].recordCode,
+                  applicant: data.data[0].applicant,
+                  orgName: data.data[0].orgName
+                }
+              }
+              this.dataForm.recordType = 1
+              data.data.forEach((item) => {
+                item.buttonType = 1
+                this.addOne(item)
+              })
+            }
+          })
+        } else {
+          this.addOne()
+        }
       },
-      addOne () {
-        this.dataList.push({
-          id: '',
-          code: getUUID(),
-          amount: 0,
-          applicant: '',
-          approver: '',
-          batchNumber: '',
-          cnt: '',
-          materialId: '',
-          materialName: '',
-          notes: '',
-          orgId: '',
-          price: '',
-          recordType: '',
-          source: '',
-          state: 0,
-          templateItemPlanId: '',
-          usage: '',
-          userId: '',
-          orgName: ''
-        })
+      addOne (item) {
+        if (item) {
+          this.dataList.push({
+            ...item
+          })
+        } else {
+          this.dataList.push({
+            id: '',
+            code: getUUID(),
+            amount: 0,
+            applicant: '',
+            approver: '',
+            batchNumber: '',
+            cnt: '',
+            materialId: '',
+            materialName: '',
+            notes: '',
+            orgId: '',
+            price: '',
+            recordType: '',
+            source: '',
+            state: 0,
+            templateItemPlanId: '',
+            usage: '',
+            userId: '',
+            orgName: ''
+          })
+        }
       },
       removeOne (index) {
         this.dataList.splice(index, 1)

+ 20 - 4
src/views/modules/warehouse/stock-order.vue

@@ -4,7 +4,10 @@
     <template v-if="!inboundVisible && !outboundVisible && !detailVisible">
       <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
         <el-form-item label="出入库类型">
-          <el-select v-model="dataForm.recordType" placeholder="请选择">
+          <el-select
+            v-model="dataForm.recordType"
+            @change="recordTypeChanged"
+            placeholder="请选择">
             <el-option
               v-for="item in recordTypeOptions"
               :key="item.value"
@@ -119,7 +122,7 @@
           <template slot-scope="scope">
             <el-button v-if="isAuth('wh:inon:info')" type="text" size="small" @click="detailHandle(scope.row.id)">查看</el-button>
             <el-button v-if="false" type="text" size="small" @click="exportItem(scope.row.id)">导出</el-button>
-            <el-button v-if="isAuth('wh:in:editor') && (Number(scope.row.state) === 0 || Number(scope.row.state) === 4)" type="text" size="small" @click="inBound(scope.row.id, false)">编辑</el-button>
+            <el-button v-if="isAuth('wh:in:editor') && (Number(scope.row.state) === 0 || Number(scope.row.state) === 4)" type="text" size="small" @click="editBound(scope.row.id)">编辑</el-button>
             <el-button v-if="isAuth('wh:in:revoke') && (Number(scope.row.state) === 1 || Number(scope.row.state) === 2)" type="text" size="small" @click="cancelItem(scope.row)">撤回</el-button>
           </template>
         </el-table-column>
@@ -239,6 +242,16 @@
       selectionChangeHandle (val) {
         this.dataListSelections = val
       },
+      // 编辑
+      editBound (id) {
+        if (Number(this.dataForm.recordType) === 1) {
+          // 出库
+          this.outBound(id, false)
+        } else {
+          // 入库
+          this.inBound(id, false)
+        }
+      },
       // 入库申请
       inBound (id, display) {
         this.inboundVisible = true
@@ -246,10 +259,10 @@
           this.$refs.inbound.init(id, display)
         })
       },
-      outBound () {
+      outBound (id) {
         this.outboundVisible = true
         this.$nextTick(() => {
-          this.$refs.outbound.init()
+          this.$refs.outbound.init(id)
         })
       },
       // 申请单类型
@@ -296,6 +309,9 @@
         this.$nextTick(() => {
           this.$refs.details.init(id)
         })
+      },
+      recordTypeChanged () {
+        this.getDataList()
       }
     }
   }