linwenxin 4 bulan lalu
induk
melakukan
0cf587b34e

+ 8 - 0
src/api/goodsPurchasedStored.js

@@ -56,6 +56,14 @@ export function goodsPurchaseAdd(data) {
   })
 }
 
+export function goodsPurchaseUpdate(data) {
+  return request({
+    url: `/goods/purchase/update`,
+    method: 'post',
+    data
+  })
+}
+
 export function goodsPurchaseItemAddCode(data) {
   return request({
     url: `/goods/purchase/item/add/code`,

+ 41 - 1
src/views/salesPurchasing/goodsPurchasedStored/index.vue

@@ -53,6 +53,7 @@
           </zj-page-fill>
           <div v-if="activeName == 'goodsInfo'" style="text-align: right; box-sizing: border-box; padding: 16px 20px">
             <el-button v-if="formDialogType == 0" size="mini" type="primary" @click="save">保存</el-button>
+            <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="update">保存</el-button>
             <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="submit">提交</el-button>
             <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('OK')">审核通过</el-button>
             <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('FAIL')"
@@ -97,7 +98,8 @@ import {
   goodsPurchaseDetail,
   goodsPurchaseSubmit,
   goodsPurchaseConfirm,
-  goodsPurchaseDel
+  goodsPurchaseDel,
+  goodsPurchaseUpdate
 } from '@/api/goodsPurchasedStored.js'
 import { goodsPlanItemList } from '@/api/purchaseSchedule.js'
 import form_ty from '../mixins/common_form'
@@ -546,6 +548,44 @@ export default {
         }
       })
     },
+    update() {
+      this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
+        if (valid && this.eidtItems()) {
+          if (!this.formData.storageId && JSON.parse(localStorage.getItem('greemall_user')).joinCode != 'NO') {
+            return this.$message({
+              type: 'warning',
+              message: '仓库不能为空'
+            })
+          }
+          if (this.formData.isPlan) {
+            try {
+              this.formData.planItems.map((item, index) => {
+                if (!item.recQty || item.recQty == 0) {
+                  throw new Error('')
+                }
+              })
+            } catch (error) {
+              this.$message.warning('到货数量必须填写并且大于0')
+              return false
+            }
+          }
+
+          goodsPurchaseUpdate({
+            ...this.formData,
+            items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
+            fileUrl: this.formData.fileUrl.map(item => item.url).join(','),
+            codeInfoList: undefined
+          }).then(res => {
+            this.$message({
+              type: 'success',
+              message: '保存成功'
+            })
+            this.$refs.pageRef.refreshList()
+            this.handleClose()
+          })
+        }
+      })
+    },
     // 提交
     submit() {
       goodsPurchaseSubmit({