chris hai 1 ano
pai
achega
2d9966e5f3

+ 3 - 3
src/views/modules/production/scheduling.vue

@@ -323,7 +323,7 @@
       outsourceHandle (row) {
         this.outsourceVisible = true
         let ids = []
-        ids.push(row.productId)
+        ids.push(row.id)
         this.$nextTick(() => {
           this.$refs.outsource.init(null, ids, row.id)
         })
@@ -332,9 +332,9 @@
       purchaseHandle (row) {
         this.purchaseVisible = true
         let ids = []
-        ids.push(row.productId)
+        ids.push(row.id)
         this.$nextTick(() => {
-          this.$refs.purchase.init(null, row.id)
+          this.$refs.purchase.init(null, ids, row.id)
         })
       },
       // 核料

+ 3 - 3
src/views/modules/sale/outsource-add-or-update.vue

@@ -242,9 +242,9 @@ export default {
       onChose () {
         this.$emit('onChose')
       },
-      async init (id, prodProductionIds, tableId) {
-        if (prodProductionIds) {
-          this.prodProductionIds = prodProductionIds
+      async init (id, scheduleIds, tableId) {
+        if (scheduleIds) {
+          this.prodProductionIds = scheduleIds
         }
         this.productDetails = []
         this.dataForm = {

+ 49 - 21
src/views/modules/sale/purchase-add-or-update.vue

@@ -142,7 +142,7 @@
 
 <script>
   import Add from './add-material'
-  import { getPurchaseDetail } from '@/api/sale'
+  import {getOutsourceDetailByScheduleId, getPurchaseDetail} from '@/api/sale'
   import { dealStepData, dealStepLogs } from '@/api/util'
   import UserComponent from '../common/user-component'
   import {getDictList} from '@/api/dict'
@@ -162,9 +162,9 @@
       return {
         visible: false,
         dataList: [],
+        thisOptionsType: this.optionsType,
         id: 0,
         dataForm: {},
-        // optionsType: [],
         materialDetails: [],
         addMaterialVisible: false,
         dataRule: {
@@ -172,14 +172,19 @@
           applierId: [{ required: true, message: '请选择申请人', trigger: 'change' }]
         },
         stepList: [],
-        logList: []
+        logList: [],
+        totalAmount: 0,
+        prodProductionIds: [] // 排产ID的集合
       }
     },
     methods: {
       onChose () {
         this.$emit('onChose')
       },
-      async init (id, tableId) {
+      async init (id, scheduleIds, tableId) {
+        if (scheduleIds) {
+          this.prodProductionIds = scheduleIds
+        }
         this.materialDetails = []
         this.dataForm = {
           payType: '0'
@@ -197,26 +202,40 @@
         if (!id) {
           this.getTypeList()
         }
-        if (!id) return
-        await getPurchaseDetail(this.id).then(({data}) => {
-          if (data && data.code === '200') {
-            this.dataForm = data.data
-            // 流程图展示
-            if (data.data.workFlowBusinessExt) {
-              dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
-              dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
-            }
-            // 获取采购物品明细
-            if (data.data.purchaseDetails) {
-              this.materialDetails = data.data.purchaseDetails
+        if (!id && !tableId) return
+        if (this.prodProductionIds.length > 0) {
+          await getOutsourceDetailByScheduleId({'prodProductionIds': this.prodProductionIds}).then(({data}) => {
+            if (data && data.code === '200' && data.data) {
+              this.materialDetails = data.data
               if (this.materialDetails && this.materialDetails.length > 0) {
                 this.materialDetails.forEach((item) => {
                   item.detailId = Math.round(Math.random() * 1000000)
                 })
+                this.calTotal()
               }
             }
-          }
-        })
+          })
+        } else {
+          await getPurchaseDetail(this.id).then(({data}) => {
+            if (data && data.code === '200') {
+              this.dataForm = data.data
+              // 流程图展示
+              if (data.data.workFlowBusinessExt) {
+                dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
+                dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
+              }
+              // 获取采购物品明细
+              if (data.data.purchaseDetails) {
+                this.materialDetails = data.data.purchaseDetails
+                if (this.materialDetails && this.materialDetails.length > 0) {
+                  this.materialDetails.forEach((item) => {
+                    item.detailId = Math.round(Math.random() * 1000000)
+                  })
+                }
+              }
+            }
+          })
+        }
       },
       validateField (type) {
         this.$refs.dataForm.validateField(type)
@@ -285,17 +304,26 @@
       },
       // 采购类型
       formatType (row) {
-        if (!row.purchaseType || !this.optionsType) return ''
-        const item1 = this.optionsType.find((item) => item.code === row.purchaseType.toString())
+        if (!row.purchaseType || !this.thisOptionsType) return ''
+        const item1 = this.thisOptionsType.find((item) => item.code === row.purchaseType.toString())
         return item1 ? item1.value : ''
       },
       // 获取采购类别字典
       getTypeList () {
         getDictList({type: 'purchase_type'}).then(({data}) => {
           if (data) {
-            this.optionsType = data
+            this.thisOptionsType = data
           }
         })
+      },
+      calTotal () {
+        let total = 0
+        if (this.materialDetails) {
+          this.materialDetails.forEach((item) => {
+            total += item.taxAmount ? Number(item.taxAmount) : 0
+          })
+        }
+        this.totalAmount = total
       }
     }
   }