zouyu
2024-02-29 363678a54142e62fdd4ca39a0db5c54af1a704dc
src/views/plan/customerorder/sample-customerorder-form.vue
@@ -1,7 +1,7 @@
<template>
  <el-dialog
    width="75%"
    top="10vh"
    top="5vh"
    :fullscreen="isFullScreen"
    :close-on-click-modal="false"
    :visible.sync="visible"
@@ -230,7 +230,8 @@
}
</style>
<script>
import { addObj } from '@/api/plan/customer'
import { saveOrUpdate } from '@/api/plan/customer'
import { getCustomerMainAndOrderBycNo } from '@/api/plan/customerorder'
import { remote } from '@/api/admin/dict'
import PartDialog from '@/views/common/part.vue'
import {dateFormat} from '@/util/date'
@@ -267,18 +268,19 @@
      currentSelectRow: 0,
      option: tableOption,
      tableData: [{
          "$cellEdit": true,
          "$index": 0,
          "partNo": "",
          "customerPartSpec": "",
          "manufactureAttr": "",
          "productName": "",
          "productType": "",
          "otcUnit": "",
          "buyQtyDue": "",
          "shippingAddress": "",
          "remark": "",
          "isTrusted": true
          id: null,
          $cellEdit: true,
          $index: 0,
          partNo: "",
          customerPartSpec: "",
          manufactureAttr: "",
          productName: "",
          productType: "",
          otcUnit: "",
          buyQtyDue: "",
          shippingAddress: "",
          remark: "",
          isTrusted: true
      }],
      staffOptions: [],
      title: '',
@@ -287,6 +289,7 @@
      buttonDisable: false,
      showPart: false,
      dataForm: {
        id: null,
        contractNo: null,
        customerName: null,
        customerNo: null,
@@ -327,12 +330,46 @@
        this.staffOptions = response.data.data
      })
    },
    init(id) {
      this.initDataForm()
      this.visible = true
      this.$nextTick(() => {
        this.title = '新增'
      })
    init(contractNo) {
      if(contractNo){
        getCustomerMainAndOrderBycNo(contractNo).then(res=>{
            if(res.status===200){
                let data = res.data.data
                this.dataForm.id = data.id
                this.dataForm.contractNo = data.contractNo
                this.dataForm.customerName = data.customerName
                this.dataForm.entityName = data.entityName
                this.dataForm.province = data.province
                this.salesSelectData = data.salesMan
                this.dataForm.salesMan = data.salesMan
                this.dataForm.originalContractStatus = data.originalContractStatus
                this.dataForm.isCp = data.isCp
                this.dataForm.customerNo = data.customerNo
                this.dataForm.returnStatus = data.returnStatus
                this.dataForm.placeOrderDate = data.placeOrderDate
                this.dataForm.factoryPlaceOrderDate = data.factoryPlaceOrderDate
                this.dataForm.deliveryDate = data.deliveryDate
                this.dataForm.comment = data.comment
                data.customerOrderVOList.forEach(e=>{
                    e.$cellEdit = true
                })
                this.tableData = data.customerOrderVOList
                console.log(this.dataForm);
            }
        }).catch(error=>{
            console.error(error)
        })
        this.visible = true
        this.$nextTick(() => {
            this.title = '编辑'
        })
      }else{
        this.initDataForm()
        this.visible = true
        this.$nextTick(() => {
            this.title = '新增'
        })
      }
    },
    initDataForm() {
      this.dataForm.contractNo = null
@@ -349,18 +386,19 @@
      this.dataForm.deliveryDate = null
      this.dataForm.comment = null
      this.dataForm.customerOrderVOList = [{
          "$cellEdit": true,
          "$index": 0,
          "partNo": "",
          "customerPartSpec": "",
          "manufactureAttr": "",
          "productName": "",
          "productType": "",
          "otcUnit": "",
          "buyQtyDue": "",
          "shippingAddress": "",
          "remark": "",
          "isTrusted": true
          id: null,
          $cellEdit: true,
          $index: 0,
          partNo: "",
          customerPartSpec: "",
          manufactureAttr: "",
          productName: "",
          productType: "",
          otcUnit: "",
          buyQtyDue: "",
          shippingAddress: "",
          remark: "",
          isTrusted: true
      }]
    },
    // 表单提交
@@ -387,12 +425,18 @@
      _than.$refs.dataForm.validate((valid) => {
        if (valid) {
          _than.dataForm.customerOrderVOList = _than.tableData
          addObj(_than.dataForm).then((data) => {
              _than.$message.success('添加成功')
              _than.initDataForm();
              _than.visible = false
              _than.buttonDisable = false
              _than.$emit('refreshDataList', 1)
          saveOrUpdate(_than.dataForm).then((res) => {
            if(res.status===200){
                if(_than.dataForm.id){
                    _than.$message.success('更新成功')
                }else{
                    _than.$message.success('添加成功')
                }
                _than.initDataForm();
                _than.visible = false
                _than.buttonDisable = false
                _than.$emit('refreshDataList', 1)
            }
            }).catch((error) => {
              _than.buttonDisable = false
            })