zouyu
2023-12-08 8c7e2d98a4545968fce177f2dac00d94d4dea213
src/views/plan/customerorder/sample-customerorder-form.vue
@@ -51,25 +51,25 @@
              <el-input v-model="dataForm.entityName" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
          <!-- <el-col :span="6">
            <el-form-item label="事业部" prop="salesDepartment">
              <el-input
                v-model="dataForm.salesDepartment"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          </el-col> -->
          <el-col :span="6">
            <el-form-item label="省份" prop="province">
              <el-input v-model="dataForm.province" placeholder=""></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="业务员" prop="salesMan">
              <el-select v-model="dataForm.salesMan" style="width:100%">
                <el-option v-for="(item,index) in staffOptions" :key="index" :value="item.staff_no" :label="item.staffName"/>
              <el-select @change="selsctionSales" clearable filterable v-model="salesSelectData" style="width:100%">
                <el-option v-for="(item,index) in staffOptions" :key="index" :value="item.staffNo+','+item.staffName" :label="item.staffName"/>
              </el-select>
            </el-form-item>
          </el-col>
@@ -77,6 +77,14 @@
            <el-form-item label="正本状态" prop="originalContractStatus">
              <el-input
                v-model="dataForm.originalContractStatus"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="合同正本状态" prop="returnStatus">
              <el-input
                v-model="dataForm.returnStatus"
                placeholder=""
              ></el-input>
            </el-form-item>
@@ -91,14 +99,6 @@
          <el-col :span="6">
            <el-form-item label="客户编码" prop="customerNo">
              <el-input v-model="dataForm.customerNo" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="合同正本状态" prop="returnStatus">
              <el-input
                v-model="dataForm.returnStatus"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
@@ -123,8 +123,6 @@
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="交货日期" prop="deliveryDate">
              <el-date-picker
@@ -137,13 +135,47 @@
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="订单备注" prop="comment">
              <el-input
                v-model="dataForm.comment"
                style="width: 100%"
                type="textarea"
                :rows="1"
              >
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-divider
      ><span style="font-weight:bold;font-size:16px;">订单行</span></el-divider
    >
    <div class="l-mes normal-form">
    <el-divider>
      <span style="font-weight:bold;font-size:16px;">订单行</span>
    </el-divider>
    <div>
      <avue-crud ref="crud"
        show-hide="false"
        :option="option"
        :data="tableData">
          <template slot="partNo" slot-scope="scope">
            <el-input v-model="scope.row.partNo" placeholder="查询零件号" readonly>
                <el-button slot="append" icon="el-icon-search" @click="openPartDialog(scope.row.$index)"></el-button>
            </el-input>
          </template>
          <template slot="otcUnit" slot-scope="scope">
            <el-select v-model="scope.row.otcUnit" placeholder="请选择单位" style="width: 100%">
              <el-option
                v-for="item in units"
                :key="item.value"
                :label="item.label"
                :value="item.value" />
            </el-select>
          </template>
      </avue-crud>
    </div>
    <!-- <div class="l-mes normal-form">
      <el-row :gutter="20">
        <el-col :span="2">
          <span>零件号</span>
@@ -332,7 +364,7 @@
          ></el-input>
        </el-col>
      </el-row>
    </div>
    </div> -->
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
@@ -374,15 +406,53 @@
import { addObj } from '@/api/plan/customer'
import { remote } from '@/api/admin/dict'
import PartDialog from '@/views/common/part.vue'
import { validateSixDecimal } from '@/util/validate'
import {dateFormat} from '@/util/date'
import { chooseStaff } from '@/api/admin/productType'
import { tableOption } from '@/const/crud/customerOrder/customerOrderForm'
export default {
  components: {
    PartDialog
  },
  watch:{
    visible(newVal){
      if(!newVal){
        this.tableData = [{
          "$cellEdit": true,
          "$index": 0,
          "partNo": "",
          "customerPartSpec": "",
          "manufactureAttr": "",
          "productName": "",
          "productType": "",
          "otcUnit": "",
          "buyQtyDue": "",
          "shippingAddress": "",
          "remark": "",
          "isTrusted": true
        }]
      }
    }
  },
  data() {
    return {
      salesSelectData: null,
      currentSelectRow: 0,
      option: tableOption,
      tableData: [{
          "$cellEdit": true,
          "$index": 0,
          "partNo": "",
          "customerPartSpec": "",
          "manufactureAttr": "",
          "productName": "",
          "productType": "",
          "otcUnit": "",
          "buyQtyDue": "",
          "shippingAddress": "",
          "remark": "",
          "isTrusted": true
      }],
      staffOptions: [],
      title: '',
      isFullScreen: false,
@@ -390,41 +460,22 @@
      buttonDisable: false,
      showPart: false,
      dataForm: {
        id: 0,
        contractNo: null,
        customerName: null,
        entityName: null,
        salesDepartment: null,
        province: null,
        salesMan: null,
        originalContractStatus: null,
        isCp: null,
        customerNo: null,
        returnStatus: null,
        placeOrderDate: null,
        factoryPlaceOrderDate: null,
        customerOrderVOList: [],
        deliveryDate: null,
        customerOrder: {
          partNo: null,
          unit: null,
          buyQtyDue: null,
          voltAgeClass: null,
          productName: null,
          manufactureAttr: 'S',
          outerColor: null,
          customerPartSpec: null,
          printType: null,
          printingRequirements: null,
          packageRequire: null,
          qualityRequire: null,
          otherProductRequire: null,
          divisionSystem: null,
          shippingAddress: null,
          salesmanName: null,
          lengthRequirement: null,
          remark: null,
          productType: null
        }
        entityName: null,
        factoryPlaceOrderDate: null,
        salesDepartment: null,
        isCp: null,
        originalContractStatus: null,
        placeOrderDate: null,
        province: null,
        returnStatus: null,
        salesMan: null,
        salerWorkCode: null,
        comment: null
      },
      dataRule: {},
      units: [],
@@ -437,6 +488,13 @@
    this.getStaffOptions();
  },
  methods: {
    selsctionSales(data){
      if(data){
        let arr = data.split(",")
        this.dataForm.salesMan =  arr[1]
        this.dataForm.salerWorkCode = arr[0]
      }
    },
    getStaffOptions(){
      chooseStaff().then((response)=>{
        this.staffOptions = response.data.data
@@ -450,66 +508,84 @@
      })
    },
    initDataForm() {
      this.dataForm.id = 0
      this.dataForm.contractNo = null
      this.dataForm.customerName = null
      this.dataForm.entityName = null
      this.dataForm.salesDepartment = null
      this.dataForm.province = null
      this.dataForm.salesMan = null
      this.dataForm.originalContractStatus = null
      this.dataForm.isCp = null
      this.dataForm.customerNo = null
      this.dataForm.returnStatus = null
      this.dataForm.placeOrderDate = null
      this.dataForm.factoryPlaceOrderDate = null
      this.dataForm.placeOrderDate = dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss')
      this.dataForm.factoryPlaceOrderDate = dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss')
      this.dataForm.deliveryDate = null
      this.dataForm.customerOrder.partNo = null
      this.dataForm.customerOrder.unit = null
      this.dataForm.customerOrder.buyQtyDue = null
      this.dataForm.customerOrder.voltAgeClass = null
      this.dataForm.customerOrder.productName = null
      this.dataForm.customerOrder.manufactureAttr = 'S'
      this.dataForm.customerOrder.outerColor = null
      this.dataForm.customerOrder.customerPartSpec = null
      this.dataForm.customerOrder.printType = null
      this.dataForm.customerOrder.printingRequirements = null
      this.dataForm.customerOrder.packageRequire = null
      this.dataForm.customerOrder.qualityRequire = null
      this.dataForm.customerOrder.otherProductRequire = null
      this.dataForm.customerOrder.divisionSystem = null
      this.dataForm.customerOrder.shippingAddress = null
      this.dataForm.customerOrder.salesmanName = null
      this.dataForm.customerOrder.lengthRequirement = null
      this.dataForm.customerOrder.remark = null
      this.dataForm.comment = null
      this.dataForm.customerOrderVOList = [{
          "$cellEdit": true,
          "$index": 0,
          "partNo": "",
          "customerPartSpec": "",
          "manufactureAttr": "",
          "productName": "",
          "productType": "",
          "otcUnit": "",
          "buyQtyDue": "",
          "shippingAddress": "",
          "remark": "",
          "isTrusted": true
      }]
    },
    // 表单提交
    dataFormSubmit() {
      this.buttonDisable = true
      this.$refs.dataForm.validate((valid) => {
      const _than = this
      let isError = false
      _than.buttonDisable = true
      _than.tableData.forEach(ele=>{
        if(ele.buyQtyDue==null || ele.buyQtyDue=='' || ele.buyQtyDue==undefined){
          _than.$message.error("零件数量不能为空!")
          isError = true
        }else{
          var reg = /^\d+$/
          if(!reg.test(ele.buyQtyDue)){
            _than.$message.error("零件数量类型必须是数字!")
            isError = true
          }
        }
      })
      if(isError){
        _than.buttonDisable = false
        return
      }
      _than.$refs.dataForm.validate((valid) => {
        if (valid) {
          addObj(this.dataForm)
            .then((data) => {
              this.$message.success('添加成功')
              this.visible = false
              this.buttonDisable = false
              this.$emit('refreshDataList', 1)
            })
            .catch((error) => {
              this.buttonDisable = false
          _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)
            }).catch((error) => {
              _than.buttonDisable = false
            })
        } else {
          this.buttonDisable = false
          _than.buttonDisable = false
        }
      })
    },
    // 零件选择
    openPartDialog() {
    openPartDialog(index) {
      this.currentSelectRow = index
      this.showPart = true
    },
    selectPart(part) {
      console.log(part);
      const index = this.currentSelectRow
      if (part) {
        this.dataForm.customerOrder.partNo = part.partNo
        this.tableData[index].partNo = part.partNo
        this.tableData[index].customerPartSpec = part.specs
        this.tableData[index].productName = part.partName
      }
    },
    // 全屏