<!--汽车衡计量合同管理-->
<template>
  <div class="systemBase">
    <div>
      <el-row>
        <el-col :span="24">
          <div style="margin-top: 10px; border-bottom: 1px solid #d5d5d5">
            <el-form
              ref="searchData"
              :inline="true"
              :model="search"
              :rules="ruleValidateSearch"
              style="padding-left: 12px"
            >
              <el-form-item prop="noticeNo" label="通知单号">
                <el-input
                  v-model="search.noticeNo"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
              <el-form-item prop="contractNo" label="合同号">
                <el-input
                  v-model="search.contractNo"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
              <el-form-item prop="batchNo" label="批次号">
                <el-input
                  v-model="search.batchNo"
                  clearable
                  size="small"
                  style="width: 120px"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
              <el-form-item prop="customerSupplierName" label="供应商">
                <el-select
                  v-model="search.customerSupplierName"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                  :filter-method="filterCust"
                >
                  <el-option
                    v-for="item in customerList"
                    :key="item.customerSupplierNo"
                    :label="item.customerSupplierName"
                    :value="item.customerSupplierName"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="receivingUintName" label="收货单位">
                <el-select
                  v-model="search.receivingUintName"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                  :filter-method="filterRcv"
                >
                  <el-option
                    v-for="item in receiverList"
                    :key="item.customerSupplierNo"
                    :label="item.customerSupplierName"
                    :value="item.customerSupplierName"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="meterTypeName" label="业务类型">
                <el-select
                  v-model="search.meterTypeName"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                >
                  <el-option
                    v-for="(item, index) in meterTypeNameItem"
                    :key="index"
                    :label="item.baseName"
                    :value="item.baseName"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="matterName" label="物料名称">
                <el-input
                  v-model="search.matterName"
                  clearable
                  size="small"
                  style="width: 150px"
                  placeholder="请输入"
                ></el-input>
              </el-form-item>
              <el-form-item prop="valueFlag" label="状态">
                <el-select
                  v-model="search.valueFlag"
                  clearable
                  filterable
                  collapse-tags
                  size="small"
                  style="width: 120px"
                >
                  <el-option
                    v-for="(item, index) in valueFlagItem"
                    :key="index"
                    :label="item.valueFlag"
                    :value="item.valueFlag"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label-width="20px">
                <el-button
                  icon="el-icon-refresh"
                  type="primary"
                  size="mini"
                  @click="resetData"
                  >重置</el-button
                >
              </el-form-item>
              <el-form-item label-width="20px">
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  size="mini"
                  @click="searchDatas"
                  v-privilege="activeMenu + 'SEARCH'"
                  >查询</el-button
                >
              </el-form-item>
            </el-form>
          </div>
          <div class="common-title-div">
            计量合同管理
            <div class="common-operation-button-div">
              <el-form :inline="true">
                <el-form-item label-width="20px">
                  <el-button
                    icon="el-icon-circle-plus-outline"
                    type="primary"
                    size="mini"
                    @click="addData"
                    v-privilege="activeMenu + 'ADD'"
                    >新增</el-button
                  >
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-button
                    icon="el-icon-edit"
                    type="primary"
                    size="mini"
                    @click="modifyData"
                    v-privilege="activeMenu + 'UPDATE'"
                    >修改</el-button
                  >
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-button
                    size="mini"
                    type="primary"
                    icon="el-icon-check"
                    @click="enableData"
                    v-privilege="activeMenu + 'RECOVERY'"
                    >启用</el-button
                  >
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-button
                    size="mini"
                    type="danger"
                    plain
                    icon="el-icon-remove-outline"
                    @click="discardData"
                    v-privilege="activeMenu + 'ABOLISH'"
                    >关闭</el-button
                  >
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-button
                    size="mini"
                    type="primary"
                    icon="el-icon-download"
                    @click="downloadData"
                    v-privilege="activeMenu + 'DOWNLOAD'"
                    >下载模板</el-button
                  >
                </el-form-item>
                <el-form-item label-width="20px">
                  <el-upload
                    class="upload"
                    action=""
                    :multiple="false"
                    :show-file-list="false"
                    accept="csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                    :http-request="httpRequest"
                  >
                    <el-button
                      size="mini"
                      type="primary"
                      icon="el-icon-upload2"
                      v-privilege="activeMenu + 'IMPORT'"
                      >导入</el-button
                    >
                  </el-upload>
                </el-form-item>
              </el-form>
            </div>
          </div>
          <div class="common-table-div">
            <el-table
              v-loading="dataLoading"
              @row-click="rowChange"
              ref="dataTable"
              highlight-current-row
              border
              :height="tableHeight"
              :data="table.list"
              :bigDataShow="groupList"
              :row-class-name="tableRowClassName"
              @selection-change="handleSelectionChange"
              :exchangeFilterMap="{ valueFlag: { '0': '可使用', '1': '关闭' } }"
              :icore-filter-flag="icoreFilterFlag"
              >>
              <el-table-column
                type="index"
                label="序号"
                fixed="left"
                align="center"
              ></el-table-column>
              <el-table-column
                type="selection"
                width="55"
                fixed="left"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="noticeNo"
                label="通知单号"
                min-width="110"
                align="center"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="indexCode"
                label="物资索引码"
                min-width="120"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="matterName"
                label="物资名称"
                min-width="120"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="contractNo"
                label="合同号"
                min-width="100"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="batchNo"
                min-width="110"
                label="批次号"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="customerSupplierName"
                min-width="160"
                label="供应商"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="sourceArea"
                min-width="160"
                label="原产地"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="forwardingUnitName"
                min-width="160"
                label="发货单位"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="receivingUintName"
                min-width="160"
                label="收货单位"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="materialName"
                min-width="100"
                label="材质"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="specName"
                min-width="100"
                label="规格"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="loadPointName"
                min-width="100"
                label="卸货地点"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="carrierUnitName"
                min-width="100"
                label="承运单位"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="meterTypeName"
                min-width="100"
                label="业务类型"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="transportTypeName"
                min-width="100"
                label="运输类型"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="total"
                min-width="100"
                label="总量(kg)"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="toleranceRatio"
                min-width="100"
                label="超差比例(%)"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="memo"
                min-width="100"
                label="备注"
                align="right"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="valueFlag"
                label="状态"
                width="60"
                min-width="100"
                align="center"
              >
                <template slot-scope="scope">
                  <span v-if="scope.row.valueFlag == 0">可使用</span>
                  <span v-else-if="scope.row.valueFlag == 1">关闭</span>
                </template>
              </el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="createManName"
                min-width="80"
                label="创建人"
                align="left"
              ></el-table-column>
              <el-table-column
                sortable
                :show-overflow-tooltip="true"
                prop="createTime"
                min-width="160"
                label="创建时间"
                align="left"
              ></el-table-column>
            </el-table>
          </div>
          <div class="common-foot-style">
            <el-pagination
              v-loading="dataLoading"
              @size-change="pageSizeChange"
              @current-change="pageCurrentChange"
              :current-page="page.pageNum"
              :page-sizes="[100, 500, 1000]"
              :page-size="page.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="page.totalPage"
            >
            </el-pagination>
          </div>
        </el-col>
      </el-row>
      <div ref="editDiv" class="commom-edit-div">
        <el-form
          ref="baseData"
          label-width="80px"
          :inline="true"
          :rules="ruleValidateTable"
          :model="baseData"
          @submit.native.prevent
        >
          <!-- <el-form-item prop="noticeNo" label="通知单号">
              <el-input v-model="baseData.noticeNo" clearable  size="small" style="width:120px" placeholder="请输入"></el-input>
             </el-form-item> -->
          <el-form-item prop="indexCode" label="物资索引码">
            <el-input
              v-model="baseData.indexCode"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
              @keyup.enter.native="getMatterName3"
            ></el-input>
          </el-form-item>
          <el-form-item prop="matterName" label="物资名称">
            <el-select
              v-model="baseData.matterName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
              :filter-method="getMatterName"
              @change="getIndexCode(baseData.matterName)"
            >
              <el-option
                v-for="item in matterNameItem"
                :key="item.id"
                :label="item.matterName"
                :value="item.matterName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="contractNo" label="合 同  号">
            <el-input
              v-model="baseData.contractNo"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="batchNo" label="批 次 号">
            <el-input
              v-model="baseData.batchNo"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="customerSupplierName" label="供应商">
            <el-select
              v-model="baseData.customerSupplierName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
              @change="customerChange"
              :filter-method="filterECust"
            >
              <el-option
                v-for="item in editCustList"
                :key="item.customerSupplierNo"
                :label="item.customerSupplierName"
                :value="item.customerSupplierName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="sourceArea" label="原产地">
            <el-input
              v-model="baseData.sourceArea"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item prop="forwardingUnitName" label="发货单位">
            <el-select
              v-model="baseData.forwardingUnitName"
              clearable
              filterable
              size="small"
              style="width: 120px"
              :filter-method="filterESdr"
              @change="editChange"
            >
              <el-option
                v-for="item in editProList"
                :key="item.customerSupplierNo"
                :label="item.customerSupplierName"
                :value="item.customerSupplierName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="receivingUintName" label="收货单位">
            <el-select
              v-model="baseData.receivingUintName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
              :filter-method="filterERcv"
              @change="editChange"
            >
              <el-option
                v-for="item in editReceList"
                :key="item.customerSupplierNo"
                :label="item.customerSupplierName"
                :value="item.customerSupplierName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="materialName" label="材       质">
            <el-select
              v-model="baseData.materialName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in materialNameItem"
                :key="index"
                :label="item.baseName"
                :value="item.baseName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="specName" label="规       格">
            <el-select
              v-model="baseData.specName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in specNameItem"
                :key="index"
                :label="item.baseName"
                :value="item.baseName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="carrierUnitName" label="承运单位">
            <el-select
              v-model="baseData.carrierUnitName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in carrierUnitNameItem"
                :key="index"
                :label="item.carrierUnitName"
                :value="item.carrierUnitName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="loadPointName" label="卸货地点">
            <el-select
              v-model="baseData.loadPointName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
            >
              <el-option
                v-for="(item, index) in loadPointNameItem"
                :key="index"
                :label="item.loadPointName"
                :value="item.loadPointName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="meterTypeName" label="业务类型">
            <el-select
              v-model="baseData.meterTypeName"
              clearable
              filterable
              collapse-tags
              size="small"
              style="width: 120px"
              @change="typeChange"
            >
              <el-option
                v-for="(item, index) in meterTypeNameItem"
                :key="index"
                :label="item.baseName"
                :value="item.baseName"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="total" label="总量(kg)">
            <el-input
              v-model="baseData.total"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item
            prop="toleranceRatio"
            label-width="90px"
            label="超差比例(%)"
            :rules="typeFlag ? numValidate.percentNum : []"
          >
            <el-input
              v-model="baseData.toleranceRatio"
              clearable
              size="small"
              type="number"
              style="width: 120px"
              placeholder="0-100"
            ></el-input>
          </el-form-item>
          <el-form-item prop="memo" label-width="70px" label="备注">
            <el-input
              v-model="baseData.memo"
              clearable
              size="small"
              style="width: 120px"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
import { formatDate, getCookie } from '@/utils/util.js';
import { cookieUserId, cookieUserName } from '@/config/config.js';
import { recordChange } from '../../../utils/utils'
import { MessageBox } from 'element-ui'
export default {
  data () {
    return {
      loadPointNameItem: [],//卸货地点
      materialNameItem: [],//材质
      forwardingUnitNameItem: [],//发货单位
      icoreFilterFlag: true,
      specNameItem: [],//规格
      receivingUintNameItem: [],//收货单位
      carrierUnitNameItem: [],//承运单位
      customerSupplierNameItem: [],//供应商
      sdrList: [], // 发货单位
      rcvList: [], // 收货单位
      loadList: [], // 厂内单位
      matterNameItem: [],
      matterNameItem2: [],
      meterTypeNameItem: [],
      multipleSelection: [],
      dataLoading: false,
      valueFlagItem: [
        { valueFlag: '可使用' },
        { valueFlag: '关闭' },
      ],
      page: {
        pageSize: 500,
        pageNum: 1,
        totalPage: 0
      },
      table: {
        list: [],
      },
      tableHeight: 0,
      activeMenu: '',
      ruleValidateSearch: {},
      ruleValidateTable: {
        matterName: [{ required: true, message: '该项不能为空', trigger: 'change' }],
        contractNo: [{ required: true, message: '该项不能为空', trigger: 'change' }],
        customerSupplierName: [{ required: true, message: '该项不能为空', trigger: 'change' }],
        forwardingUnitName: [{ required: true, message: '该项不能为空', trigger: 'change' }],
        meterTypeName: [{ required: true, message: '该项不能为空', trigger: 'change' }],
        total: [{ required: true, message: '该项不能为空', trigger: 'change' }],
        // toleranceRatio: [{ required: true, message: '该项不能为空', trigger: 'change' }, {
        //   required: true,
        //   validator: this.toleranceRatioEmpty,
        //   trigger: 'change'
        // }],
      },
      search: {
        noticeNo: '',
        contractNo: '',
        batchNo: '',
        matterName: '',
        valueFlag: '',
        customerSupplierName: '',
        receivingUintName: '',
        meterTypeName: ''
      },
      baseData: {
        noticeNo: '',
        matterName: '',
        contractNo: '',
        batchNo: '',
        customerSupplierName: '',
        sourceArea: '',
        forwardingUnitName: '',
        receivingUintName: '',
        materialName: '',
        specName: '',
        carrierUnitName: '',
        loadPointName: '',
        meterTypeName: '',
        toleranceRatio: '',
        total: '',
        memo: '',
        indexCode: ''
      },
      errorList: [],
      typeFlag: true, // true表示添加的是采购进厂的合同，false表示添加的是销售出厂的合同
      numValidate: {
        percentNum: [{ required: true, message: '该项不能为空', trigger: 'blur' }]
      },
      customerUnitNameItem: [],
      receivingSUnitNameItem: [],
      matList: [],
      groupList: [8, 1],
      userNo: '',
      userName: '',
      oldObj: {},
      newObj: {},
      provideList: [],
      customerList: [],
      receiverList: [],
      editCustList: [],
      editReceList: [],
      editProList: []
    }
  },
  created () {
    this.tableHeight = window.innerHeight - 370 > 300 ? window.innerHeight - 370 : 300
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
    this.userNo = getCookie(cookieUserId)
    this.userName = getCookie(cookieUserName)
  },
  mounted () {
    this.getLoadPointNameItem();
    this.getMatterNameItem();//物料
    this.getCarrierUnitNameItem();//承运单位
    // this.getCustomerSupplierNameItem();//供应商
    this.getMeterTypeNameItem();//业务类型
    this.getMaterialNameItem();//材质
    this.getSpecNameItem();//规格
    // this.getForwardingUnitNameItem();//发货单位
    // this.getReceivingUintNameItem();//收货单位
    this.getMeterbasecustomersupplier()
    this.getDataList()
  },
  methods: {
    getCode (code, arr, codeKey, nameKey) {
      if (!code) {
        return '';
      }
      let targetRow = arr.find(item => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : '';
    },
    toleranceRatioEmpty (rule, value, callback) {
      const age = /^[0-9]*$/
      if (this.baseData.toleranceRatio) {
        if (!age.test(this.baseData.toleranceRatio)) {
          return callback(new Error('请输入数字！'))
        } else if (Number(this.baseData.toleranceRatio > 100)) {
          return callback(new Error('请输入为0-100的数字！'))
        } else {
          return callback()
        }
      } else {
        return callback()
      }
    },
    numberValidate (val) {
      const age = /^[0-9]*$/
      if (this.baseData.toleranceRatio) {
        if (!age.test(this.baseData.toleranceRatio)) {
          this.$message.error('请输入数字！')
          return false
        } else if (Number(this.baseData.toleranceRatio > 100)) {
          this.$message.error('请输入为0-100的数字！')
          return false
        } else {
          return true
        }
      } else {
        return false
      }
    },
    getMatterName (val) {

      // this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterName=' + val)
      //   .then(res => {
      //     this.matterNameItem = res.data;
      //   })
      if (val) {
        this.matterNameItem = this.matList.filter(item => {
          if (item.matterName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.matterNameItem = [...this.matList].slice(0, 300)
      }
    },
    getMatterName2 (val) {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterName=' + val)
        .then(res => {
          this.matterNameItem2 = res.data;
        })
    },
    getMatterName3 () {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/' + '?validFlag=1&pageSize=10000000&pageNum=1' + '&indexCode=' + this.baseData.indexCode)
        .then(res => {
          this.matterNameItem = res.data.list;
          if (res.data.list.length > 0) {
            this.baseData.matterName = res.data.list[0].matterName
          }
        })
    },
    getIndexCode (val) {
      console.log(val)
      this.baseData.indexCode = this.getCode(val, this.matterNameItem, 'matterName', 'indexCode')
      console.log(this.baseData.indexCode)
    },
    refresh () {
      this.baseData = {
        noticeNo: '',
        matterName: '',
        contractNo: '',
        batchNo: '',
        customerSupplierName: '',
        sourceArea: '',
        forwardingUnitName: '',
        receivingUintName: '',
        materialName: '',
        specName: '',
        carrierUnitName: '',
        loadPointName: '',
        meterTypeName: '',
        toleranceRatio: '',
        total: '',
        memo: '',
        indexCode: ''
      }
      // this.baseData.loadPointName = this.loadPointNameItem[0].loadPointName ? this.loadPointNameItem[0].loadPointName : ''
      // this.baseData.matterName = this.matterNameItem[0].matterName//物料
      // this.baseData.carrierUnitName = this.carrierUnitNameItem[0].carrierUnitName//承运单位
      // this.baseData.customerSupplierName = this.customerSupplierNameItem[0].customerSupplierName//供应商
      // this.baseData.meterTypeName = this.meterTypeNameItem[0].baseName//
      // this.baseData.materialName = this.materialNameItem[0].baseName//材质
      // this.baseData.specName = this.specNameItem[0].baseName//规格
      // this.baseData.receivingUintName = this.receivingUintNameItem[0].companyName//收货单位
      // this.baseData.forwardingUnitName = this.forwardingUnitNameItem[0].companyName//发货单位
      this.$refs['baseData'].resetFields();
    },
    resetData () {
      this.$refs['searchData'].resetFields && this.$refs['searchData'].resetFields();
    },
    addData () {
      this.$refs['baseData'].validate((valid) => {
        if (valid) {
          // 如果业务类型是采购进厂，则验证超差比例格式正确性
          if (this.baseData.meterTypeName === '采购进厂') {
            if (!this.numberValidate(this.baseData.toleranceRatio)) {
              return false
            }
          }
          let baseDataAdd = {}
          // 业务类型编号
          baseDataAdd.meterTypeNo = this.getCode(this.baseData.meterTypeName, this.meterTypeNameItem, 'baseName', 'baseCode')
          // 物料编号
          baseDataAdd.matterNo = this.getCode(this.baseData.matterName, this.matList, 'matterName', 'matterNo')
          // 卸货地点
          baseDataAdd.loadPointNo = this.getCode(this.baseData.loadPointName, this.loadPointNameItem, 'loadPointName', 'loadPointNo')
          // 承运单位
          baseDataAdd.carrierUnitNo = this.getCode(this.baseData.carrierUnitName, this.carrierUnitNameItem, 'carrierUnitName', 'carrierUnitNo')
          // 供应商
          baseDataAdd.customerSupplierNo = this.getCode(this.baseData.customerSupplierName, this.allList, 'customerSupplierName', 'customerSupplierNo')
          // 材质
          baseDataAdd.materialNo = this.getCode(this.baseData.materialName, this.materialNameItem, 'baseName', 'baseCode')
          // 规格
          baseDataAdd.specNo = this.getCode(this.baseData.specName, this.specNameItem, 'baseName', 'baseCode')
          // 发货单位
          baseDataAdd.forwardingUnitNo = this.getCode(this.baseData.forwardingUnitName, this.allList, 'customerSupplierName', 'customerSupplierNo')
          // 收货单位
          baseDataAdd.receivingUintNo = this.getCode(this.baseData.receivingUintName, this.allList, 'customerSupplierName', 'customerSupplierNo')
          //  baseDataAdd.noticeNo = this.baseData.noticeNo
          baseDataAdd.sourceArea = this.baseData.sourceArea
          baseDataAdd.contractNo = this.baseData.contractNo
          baseDataAdd.batchNo = this.baseData.batchNo
          baseDataAdd.meterTypeName = this.baseData.meterTypeName
          baseDataAdd.matterName = this.baseData.matterName
          baseDataAdd.loadPointName = this.baseData.loadPointName
          baseDataAdd.carrierUnitName = this.baseData.carrierUnitName
          baseDataAdd.customerSupplierName = this.baseData.customerSupplierName
          baseDataAdd.materialName = this.baseData.materialName
          baseDataAdd.specName = this.baseData.specName
          baseDataAdd.forwardingUnitName = this.baseData.forwardingUnitName
          baseDataAdd.receivingUintName = this.baseData.receivingUintName
          baseDataAdd.transportTypeName = '汽车检斤'
          baseDataAdd.toleranceRatio = this.baseData.toleranceRatio
          baseDataAdd.total = this.baseData.total
          baseDataAdd.memo = this.baseData.memo
          baseDataAdd.createManNo = this.userNo
          baseDataAdd.createManName = this.userName
          baseDataAdd.indexCode = this.baseData.indexCode
          this.$confirm('确认新增?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.axios.post('pass/systemBase/v1/pretracknotices/add', baseDataAdd, { individualType: 'json' }).then(async res => {
              if (res.succeed) {
                // 记录新增日志
                await this.recordSingleData(this.userNo, this.userName, res.data, '汽车衡计量合同管理', '新增');
                this.$message.success('新增成功');
                this.refresh();
                this.setParam(baseDataAdd)
                // this.getDataList()
                this.searchData()
              }
            }).catch(e => {
              this.$message.error(e.message)
            })
          }).catch(() => { });
        }
      })
    },
    async recordSingleData (createManNo, createManName, operationId, operationPage, operationFunction, operationPredictionNo = '', operationCarnNo = '', operationBeforeFix = '', operationAfterFix = '') {
      const param = { createManNo, createManName, operationId, operationPage, operationFunction, operationPredictionNo, operationCarnNo, operationBeforeFix, operationAfterFix }
      const res = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
      if (!res.succeed) {
        this.$message.error(`保存${operationFunction.split('-')[1]}操作日志失败`)
      }
    },
    setParam (data) {
      this.search.contractNo = data.contractNo
      this.search.batchNo = data.batchNo
      this.search.customerSupplierName = data.customerSupplierName
      this.search.receivingUintName = data.receivingUintName
      this.search.meterTypeName = data.meterTypeName
      this.search.matterName = data.matterName
      this.search.valueFlag = data.valueFlag
    },
    modifyData () {
      this.$refs['baseData'].validate((valid) => {
        if (valid) {
          // 如果业务类型是采购进厂，则验证超差比例数据正确性
          if (this.baseData.meterTypeName === '采购进厂') {
            if (!this.numberValidate(this.baseData.toleranceRatio)) {
              return false
            }
          }
          this.baseData.createManNo = this.getCookie(cookieUserId)
          this.baseData.createManName = this.getCookie(cookieUserName)
          // 业务类型
          this.baseData.meterTypeNo = this.getCode(this.baseData.meterTypeName, this.meterTypeNameItem, 'baseName', 'baseCode')
          // 物资名称
          this.baseData.matterNo = this.getCode(this.baseData.matterName, this.matList, 'matterName', 'matterNo')
          // 卸货地点
          this.baseData.loadPointNo = this.getCode(this.baseData.loadPointName, this.loadPointNameItem, 'loadPointName', 'loadPointNo')
          // 承运单位
          this.baseData.carrierUnitNo = this.getCode(this.baseData.carrierUnitName, this.carrierUnitNameItem, 'carrierUnitName', 'carrierUnitNo')
          // 供应商
          this.baseData.customerSupplierNo = this.getCode(this.baseData.customerSupplierName, this.allList, 'customerSupplierName', 'customerSupplierNo')
          // 材质
          this.baseData.materialNo = this.getCode(this.baseData.materialName, this.materialNameItem, 'baseName', 'baseCode')
          // 规格
          this.baseData.specNo = this.getCode(this.baseData.specName, this.specNameItem, 'baseName', 'baseCode')
          // 发货单位
          this.baseData.forwardingUnitNo = this.getCode(this.baseData.forwardingUnitName, this.allList, 'customerSupplierName', 'customerSupplierNo')
          // 收货单位
          this.baseData.receivingUintNo = this.getCode(this.baseData.receivingUintName, this.allList, 'customerSupplierName', 'customerSupplierNo')
          this.$confirm('确认修改?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            // 记录修改内容
            const { oldStr, newStr } = recordChange(this.oldObj, this.baseData)
            const param = {
              createManNo: this.userNo,
              createManName: this.userName,
              operationPage: '汽车衡计量合同管理',
              operationFunction: "修改",
              operationId: this.baseData.id,
              operationPredictionNo: this.baseData.predictionNo,
              operationCarnNo: this.baseData.carNo,
              operationBeforeFix: oldStr,
              operationAfterFix: newStr
            }
            this.axios.post('pass/systemBase/v1/pretracknotices/update', this.baseData, { individualType: 'json' }).then(async res => {
              if (res.succeed) {
                const log = await this.axios.post('pass/systemBase/v1/meterbaseoperationlogs/addList', [param], { individualType: 'json' })
                if (!log.succeed) {
                  this.$message.error('修改日志保存失败');
                }
                this.$message.success('修改成功');
                this.oldObj = {}
                // this.getDataList();
                this.searchData()
                this.refresh();
              }
            }).catch(e => {
              this.$message.error(e.message)
            })
          }).catch(() => { });
        }
      })
    },
    enableData () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请选择您要启用的数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/pretracknotices/recover', this.multipleSelection, { individualType: 'json' }).then(async res => {
        if (res.succeed) {
          await this.recordSingleData(this.userNo, this.userName, this.multipleSelection[0].id, '汽车衡计量合同管理', '启用');
          this.$message.success('启用成功');
          this.searchData()
          // this.getDataList();
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    discardData () {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请选择您要停用的数据！');
        return;
      }
      this.axios.post('pass/systemBase/v1/pretracknotices/abolish', this.multipleSelection, { individualType: 'json' }).then(async res => {
        if (res.succeed) {

          await this.recordSingleData(this.userNo, this.userName, this.multipleSelection[0].id, '汽车衡计量合同管理', '停用');
          this.$message.success('废除成功');
          // this.getDataList();
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    typeChange (val) {
      if (val) {
        if (val === '采购进厂') {
          // this.forwardingUnitNameItem = [...this.sdrList]
          // this.receivingUintNameItem = [...this.rcvList]
          this.typeFlag = true
        } else if (val === '销售出厂') {
          // this.forwardingUnitNameItem = [...this.rcvList]
          // this.receivingUintNameItem = [...this.sdrList]
          this.typeFlag = false
          console.log(this.typeFlag, '是否必填')
        }
      }
    },
    filterCust (val) {
      console.log(val)
      if (val) {
        this.customerList = this.allList.filter(item => {
          if (item.customerSupplierName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.customerList = [...this.allList].slice(0, 300)
      }
    },
    filterRcv (val) {
      if (val) {
        this.receiverList = this.allList.filter(item => {
          if (item.customerSupplierName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.receiverList = [...this.allList].slice(0, 300)
      }
    },
    filterESdr (val) {
      if (val) {
        this.editProList = this.allList.filter(item => {
          if (item.customerSupplierName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.editProList = [...this.allList].slice(0, 300)
      }
    },
    filterERcv (val) {
      if (val) {
        this.editReceList = this.allList.filter(item => {
          if (item.customerSupplierName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.editReceList = [...this.allList].slice(0, 300)
      }
    },
    filterECust (val) {
      if (val) {
        this.editCustList = this.allList.filter(item => {
          if (item.customerSupplierName.indexOf(val) !== -1) {
            return true
          }
        }).slice(0, 300)
      } else {
        this.editCustList = [...this.allList].slice(0, 300)
      }
    },
    // 供应商下拉选择变化
    customerChange (val) {
      // 将选择值赋给供应商字段的同时赋给发货单位字段
      this.baseData.customerSupplierName = val
      this.baseData.forwardingUnitName = val
      this.editCustList = [...this.allList].slice(0, 300)
    },
    editChange () {
      this.editReceList = [...this.allList].slice(0, 300)
      this.editProList = [...this.allList].slice(0, 300)
    },
    // // 发货单位下拉选择
    // sdrChange (val) {
    //   // 将选择值赋给发货单位的同时赋给供应商字段
    //   this.baseData.customerSupplierName = val
    //   this.baseData.forwardingUnitName = val
    // },
    getCookie (name) {
      let start = document.cookie.indexOf(name + '=');
      if ((!start) && (name !== document.cookie.substring(0, name.length))) { return ''; }
      if (start === -1) { return ''; }
      let len = start + name.length + 1;
      let end = document.cookie.indexOf(';', len);
      if (end === -1) { end = document.cookie.length; }
      return decodeURIComponent(document.cookie.substring(len, end));
    },
    getDataList () {
      this.dataLoading = true;
      this.axios.get('pass/systemBase/v1/pretracknotices/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize)
        .then(res => {
          this.dataLoading = false;
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    rowChange (row, column, event) {
      this.oldObj = { ...row }
      this.baseData = Object.assign({}, row);
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1' + '&matterNo=' + this.baseData.matterNo)
        .then(res => {
          this.matterNameItem = res.data;
        })
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
      if (val.length > 0) {
        this.$refs.dataTable.setCurrentRow(this.multipleSelection[val.length - 1])
        this.rowChange(this.multipleSelection[val.length - 1])
      }
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.searchData()
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.searchData()
    },
    searchDatas () {
      this.page.pageNum = 1;
      this.searchData()
    },
    searchData () {
      this.$refs.dataTable.bodyWrapper.scrollTop = 0;
      this.dataLoading = true;
      this.search.valueFlag1 = this.search.valueFlag === '可使用' ? 0 : this.search.valueFlag === '关闭' ? 1 : ''
      let obj = {
        pageNum: this.page.pageNum,
        pageSize: this.page.pageSize,
        param: {
          valueFlag: this.search.valueFlag1,
          noticeNo: this.search.noticeNo,
          contractNo: this.search.contractNo,
          batchNo: this.search.batchNo,
          matterName: this.search.matterName,
          customerSupplierName: this.search.customerSupplierName,
          receivingUintName: this.search.receivingUintName,
          meterTypeName: this.search.meterTypeName
        }
      }
      this.axios.post('pass/systemBase/v1/pretracknotices/listLike', obj, { individualType: 'json' })
        .then(res => {
          this.dataLoading = false;
          if (res.data.list.length < 64) {
            this.groupList = [8]
          } else {
            this.groupList = [8, 1]
          }
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    downloadData () {
      // console.log('进来了，点击事件触发了')
      // var form = $('<form>'); // 定义一个form表单
      // form.attr('id', 'downloadform');
      // form.attr('style', 'display:none');
      // form.attr('target', '_parent');
      // form.attr('method', 'get');
      // form.attr('action', 'ftp://172.22.42.2/pub/file/合同录入模板.xlsx');
      // console.log(form)
      // var input1 = $('<input>');
      // input1.attr('type', 'hidden');
      // form.append(input1);
      // $('body').append(form); // 将表单放置在web中
      // // form.submit(); // 表单提交
      // $('#downloadform').remove();
      // console.log('进入了方法11111')
      // let a = document.createElement('a')
      // a.href = 'ftp://172.22.42.2/pub/file/合同录入模板.xlsx'
      // a.download = '合同录入模板'
      // a.click()
      window.open('ftp://172.22.42.2/pub/file/合同录入模板.xlsx')
    },
    numberValidate1 (val, name, flag) {
      const age = /^(([0-9]+)\.([0-9]{1,9})$)|^([0-9]+)$/;
      if (!age.test(val)) {
        if (flag) {

        }
        return false
      } else {
        return true
      }
    },
    httpRequest (e) {
      let file = e.file // 文件信息
      if (!file) {
        // 没有文件
        return false
      } else if (!/\.(xls|xlsx)$/.test(file.name.toLowerCase())) {
        // 格式根据自己需求定义
        this.$message.error('上传格式不正确，请上传xls或者xlsx格式')
        return false
      }
      const fileReader = new FileReader()
      fileReader.onload = (ev) => {
        let _this = this;
        _this.list = []
        try {
          const data = ev.target.result
          const workbook = XLSX.read(data, {
            type: 'binary' // 以字符编码的方式解析
          })
          const exlname = workbook.SheetNames[0] // 取第一张表
          _this.jsonData = XLSX.utils.sheet_to_json(workbook.Sheets[exlname]) // 生成json表格内容
          console.log(_this.jsonData, 'excel数据')
          if (_this.jsonData.length === 0) {
            return MessageBox.alert('导入的合同数据为空')
          }
          for (var j = 0; j < _this.jsonData.length; j++) {
            // 校验合同号
            if (!_this.jsonData[j]['合同号'] || _this.jsonData[j]['合同号'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据有合同号为空的数据，不允许导入')
              return
            }
            // 校验必填项 物料名称
            console.log(!_this.jsonData[j]['物资名称'] || _this.jsonData[j]['物资名称'].trim() === '')
            if (!_this.jsonData[j]['物资名称'] || _this.jsonData[j]['物资名称'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据中合同为' + _this.jsonData[j]['合同号'] + '对应的物资名称为空')
              return
            }

            // 校验供应商
            if (!_this.jsonData[j]['供应商名称'] || _this.jsonData[j]['供应商名称'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据合同号为' + _this.jsonData[j]['合同号'] + '对应的供应商名称为空')
              return
            }
            // 校验发货单位
            if (!_this.jsonData[j]['发货单位名称'] || _this.jsonData[j]['发货单位名称'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据合同号为' + _this.jsonData[j]['合同号'] + '对应的发货单位名称为空')
              return
            }
            // 校验业务类型
            if (!_this.jsonData[j]['业务类型'] || _this.jsonData[j]['业务类型'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据合同号为' + _this.jsonData[j]['合同号'] + '对应的业务类型为空')
              return
            }

            // 校验是否为数字
            // 校验总量
            if (!_this.jsonData[j]['总量(kg)'] || _this.jsonData[j]['总量(kg)'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据合同号为' + _this.jsonData[j]['合同号'] + '对应的总量为空')
              return
            } else {
              if (!_this.numberValidate1(_this.jsonData[j]['总量(kg)'].trim(), '上传的数据合同号为' + _this.jsonData[j]['合同号'] + '对应的', true)) {
                return false
              }
            }
            // 校验超差比例
            if (!_this.jsonData[j]['超差比例(%)'] || _this.jsonData[j]['超差比例(%)'].trim() === '') {
              _this.errorList.push(_this.jsonData[j])
              MessageBox.alert('上传的数据合同号为' + _this.jsonData[j]['合同号'] + '对应的超差比例为空')
              return
            }

            // 按照生成jsonData 的数据格式 处理 生成所需表格
            if (_this.jsonData[j]['状态'] === '可使用') {
              _this.valueFlag1 = 0
            } else if (_this.jsonData[j]['状态'] === '关闭') {
              _this.valueFlag1 = 1
            }
            let operateCode = ''
            switch (_this.jsonData[j]['业务类型']) {
              case '采购进厂':
                operateCode = '001006001'
                break;
              case '中控倒运':
                operateCode = '001006003'
                break;
              case '销售出厂':
                operateCode = '001006002'
                break;
            }
            _this.list.push({
              valueFlag: _this.valueFlag1,
              noticeNo: _this.jsonData[j]['通知单号'],
              matterNo: _this.jsonData[j]['物资编号'],
              matterName: _this.jsonData[j]['物资名称'],
              contractNo: _this.jsonData[j]['合同号'],
              batchNo: _this.jsonData[j]['批次号'],
              customerSupplierName: _this.jsonData[j]['供应商名称'],
              customerSupplierNo: _this.jsonData[j]['供应商编号'],
              sourceArea: _this.jsonData[j]['原产地'],
              transportTypeName: '汽车检斤',
              forwardingUnitName: _this.jsonData[j]['发货单位名称'],
              forwardingUnitNo: _this.jsonData[j]['发货单位编号'],
              receivingUintName: _this.jsonData[j]['收货单位名称'],
              receivingUintNo: _this.jsonData[j]['收货单位编号'],
              materialName: _this.jsonData[j]['材质'],
              materialNo: _this.jsonData[j]['材质编号'],
              specName: _this.jsonData[j]['规格'],
              specNo: _this.jsonData[j]['规格编号'],
              loadPointName: _this.jsonData[j]['卸货地点'],
              loadPointNo: _this.jsonData[j]['卸货地点编号'],
              carrierUnitName: _this.jsonData[j]['承运单位'],
              carrierUnitNo: _this.jsonData[j]['承运单位编号'],
              meterTypeName: _this.jsonData[j]['业务类型'],
              meterTypeNo: operateCode,
              transportTypeName: _this.jsonData[j]['运输类型'],
              indexCode: _this.jsonData[j]['物资索引码'],
              total: _this.jsonData[j]['总量(kg)'],
              toleranceRatio: _this.jsonData[j]['超差比例(%)']
            })
          }
          _this.operateLoading = true;
          _this.axios.post('pass/systemBase/v1/pretracknotices/addList', _this.list, { individualType: 'json' }).then(res => {
            if (res.code == '0') {
              _this.$message.success('导入成功')
              _this.searchData()
            } else {
              _this.$message.error('错了')
            }
          })
        } catch (e) {
          console.log(e)
          return false
        }
      }
      fileReader.readAsBinaryString(file)
    },
    tableRowClassName ({
      row,
      rowIndex
    }) {
      if (row.valueFlag == '1') {
        return 'error-row2';
      }
      return '';
    },
    // 卸货地点查询
    getLoadPointNameItem () {
      this.axios.get('pass/systemBase/v1/meterbaseloadpoints/noPage' + '?validFlag=1')
        .then(res => {
          this.loadList = [...res.data]
          this.loadPointNameItem = res.data;
          this.baseData.loadPointName = res.data.length > 0 ? res.data[0].loadPointName : '';
        })
    },
    // 物料数据查询
    getMatterNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasematterinfos/noPage' + '?validFlag=1')
        .then(res => {
          this.matList = [...res.data];
          this.matterNameItem = [...res.data].slice(0, 300);
          this.baseData.matterName = res.data[0].matterName;
        })
    },
    // 承运单位数据查询
    getCarrierUnitNameItem () {
      this.axios.get('pass/systemBase/v1/meterbasecarrierunits/noPage' + '?validFlag=1')
        .then(res => {
          this.carrierUnitNameItem = res.data;
          this.baseData.carrierUnitName = res.data[0].carrierUnitName;
        })
    },
    // 供应商数据查询
    getCustomerSupplierNameItem () {
      // 查询所有有效客商数据
      this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/noPage' + '?validFlag=1')
        .then(res => {
          this.customerSupplierNameItem = res.data;
          this.customerUnitNameItem = [...res.data].slice(0, 300)
          this.baseData.customerSupplierName = res.data[0].customerSupplierName;
        })
    },
    // 业务类型数据
    getMeterTypeNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001006' + '&validFlag=1')
        .then(res => {
          console.log('业务类型数据', res.data)
          this.meterTypeNameItem = res.data;
          this.baseData.meterTypeName = res.data[0].baseName;
        })
    },
    // 材质数据查询
    getMaterialNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001017' + '&validFlag=1')
        .then(res => {
          console.log('材质数据', res.data)
          this.materialNameItem = res.data;
          // this.baseData.materialName = res.data.length > 0 ? res.data[0].baseName : '';
        })
    },
    // 规格数据查询
    getSpecNameItem () {
      this.axios.get('pass/systemBase/v1/combaseinfos/noPage' + '?pBaseCode=001018' + '&validFlag=1')
        .then(res => {
          console.log('规格数据', res.data)
          this.specNameItem = res.data;
          // this.baseData.specName = res.data.length > 0 ? res.data[0].baseName : '';
        })
    },
    // 发货单位数据查询
    getForwardingUnitNameItem () {
      // 查询出了所有厂内单位以及类型为客户/供应商的单位数据
      this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/selectOut')
        .then(res => {
          this.sdrList = [...res.data]
          this.forwardingUnitNameItem = res.data;
          this.baseData.forwardingUnitName = this.customerSupplierNameItem.length > 0 ? this.customerSupplierNameItem[0].customerSupplierName : '';
        })
    },
    // 收货单位数据查询
    getReceivingUintNameItem () {
      // 查询出了所有厂内单位以及类型为客户/供应商的单位数据
      this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/selectIn')
        .then(res => {
          this.rcvList = [...res.data]
          this.receivingUintNameItem = res.data;
          this.receivingSUnitNameItem = [...res.data].slice(0, 300)
          this.baseData.receivingUintName = res.data.length > 0 ? res.data[0].companyName : '';
        })
    },
    // 查询客商表里面的所有有效数据
    async getMeterbasecustomersupplier () {
      const { data: res } = await this.axios.get('pass/systemBase/v1/meterbasecustomersuppliers/like/?pageNum=1&pageSize=100000&checkFlag=1&validFlag=1')
      // 给供应商，发货单位，收货单位赋值
      this.allList = [...res.list];
      this.provideList = [...res.list].slice(0, 300);
      this.customerList = [...res.list].slice(0, 300);
      this.receiverList = [...res.list].slice(0, 300);
      this.editCustList = [...res.list].slice(0, 300);
      this.editReceList = [...res.list].slice(0, 300);
      this.editProList = [...res.list].slice(0, 300);
    }
  }
}
</script>
<style>
</style>