<template>
  <a-spin :spinning="loading">
    <JFormContainer :disabled="disabled">
      <template #detail>
        <a-form v-bind="formItemLayout" name="PuechaseQuotationFormForm" ref="formRef">
          <a-row>
            <a-col :span="12">
              <a-form-item label="报价单号(bill code)" v-bind="validateInfos.billCode" id="PuechaseQuotationFormForm-billCode" name="billCode">
                <a-input v-model:value="formData.billCode" placeholder="自动生成" disabled />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="单据日期(bill date)" v-bind="validateInfos.billDate" id="PuechaseQuotationFormForm-billDate" name="billDate">
                <a-date-picker
                  placeholder="请选择单据日期(bill date)"
                  v-model:value="formData.billDate"
                  value-format="YYYY-MM-DD"
                  style="width: 100%"
                  allow-clear
                />
              </a-form-item>
            </a-col>

            <a-col :span="12">
              <a-form-item
                label="报价项目(quotation project)"
                v-bind="validateInfos.projectName"
                id="PuechaseQuotationFormForm-projectName"
                name="projectName"
              >
                <a-input-search
                  v-model:value="formData.projectName"
                  placeholder="请输入报价项目(quotation project)"
                  readonly
                  :disabled="notAllowEdit"
                  allow-clear
                  enter-button="Search"
                  @search="onSearchProject"
                />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="报价供应商(quotation supplier)"
                v-bind="validateInfos.quotationSuppiler"
                id="PuechaseQuotationFormForm-quotationSuppiler"
                name="quotationSuppiler"
              >
              <JSelect   v-model:value="formData.quotationSuppiler" :get-option-url="supplierOption" :showField="showField" @change="changeSupplier" :param="{status:1}"></JSelect>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="报价截至日期(quotation deadline)"
                v-bind="validateInfos.quotationDeadline"
                id="PuechaseQuotationFormForm-quotationDeadline"
                name="quotationDeadline"
              >
                <a-date-picker
                  placeholder="请选择"
                  v-model:value="formData.quotationDeadline"
                  value-format="YYYY-MM-DD"
                  format="YYYY-MM-DD"
                  style="width: 100%"
                  allow-clear
                />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="优先级(priority)" v-bind="validateInfos.priority" id="PuechaseQuotationFormForm-priority" name="priority">
                <JDictSelectTag v-model:value="formData.priority" placeholder="请选择" dictCode="priority" />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="产品分类(production class)"
                v-bind="validateInfos.productionClass"
                id="PuechaseQuotationFormForm-productionClass"
                name="productionClass"
              >
                <ApiSelect
                  :api="ClassList"
                  showSearch
                  v-model:value="formData.productionClass"
                  optionFilterProp="label"
                  resultField="records"
                  labelField="name"
                  valueField="id"
                  disabled
                />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="机型(model)" v-bind="validateInfos.model" id="PuechaseQuotationFormForm-model" name="model">
                <JDictSelectTag v-model:value="formData.model" placeholder="请选择" dictCode="model_typer" disabled />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="厂家(maker)" v-bind="validateInfos.maker" id="PuechaseQuotationFormForm-maker" name="maker">
                <a-input v-model:value="formData.maker" placeholder="请输入厂家(maker)" allow-clear disabled />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="发货地址(place of delivery)"
                v-bind="validateInfos.placeDelivery"
                id="PuechaseQuotationFormForm-placeDelivery"
                name="placeDelivery"
              >
                <a-input v-model:value="formData.placeDelivery" placeholder="" allow-clear />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="付款条件(payment terms)"
                v-bind="validateInfos.paymentTerms"
                id="PuechaseQuotationFormForm-paymentTerms"
                name="paymentTerms"
                :labelCol="formItemLayout.labelCol1"
                :wrapperCol="formItemLayout.wrapperCol1"
              >
                <JDictSelectTag
                  v-model:value="formData.paymentTerms"
                  placeholder="请选择"
                  dictCode="payment_terms"
                  style="width: 49%; margin-right: 1%"
                />
                <a-input v-model:value="formData.paymentTermsInfo" placeholder="" allow-clear style="width: 49%" AutoComplete="off" />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="发货方式(delivery)" v-bind="validateInfos.delivery" id="PuechaseQuotationFormForm-delivery" name="delivery">
                <JDictSelectTag v-model:value="formData.delivery" placeholder="请选择" dictCode="delivery_methods" />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="交期(delivery day)"
                v-bind="validateInfos.deliveryDayHead"
                id="PuechaseQuotationFormForm-deliveryDayHead"
                name="deliveryDayHead"
              >
                <a-input-number v-model:value="formData.deliveryDayHead" placeholder="请输入" style="width: 100%" @change="changeFormDeliveryTime" />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="报价有效期(quotation validity period)"
                v-bind="validateInfos.quotationValidity"
                id="PuechaseQuotationFormForm-quotationValidity"
                name="quotationValidity"
              >
                <a-input v-model:value="formData.quotationValidity" placeholder="请输入" style="width: 40%; margin-right: 1%" />天(days)到
                <a-date-picker
                  v-model:value="formData.quotationValidityDate"
                  valueFormat="YYYY-MM-DD"
                  format="YYYY-MM-DD"
                  style="width: 40%; margin-left: 1%"
                />
              </a-form-item>
            </a-col>
            <a-col :span="12">
							<a-form-item label="质量等级(quality grade)" v-bind="validateInfos.inquiryTeam" id="SaleInquiryFormForm-inquiryTeam" name="inquiryTeam" :label-col="formItemLayout.labelCol1"  :wrapper-col="formItemLayout.wrapperCol1">
                <JDictSelectTag v-model:value="formData.qualityGradeHead" placeholder="请选择" dictCode="quality_grade" />
							</a-form-item>
						</a-col>
            <a-col :span="12">
              <a-form-item label="币种(currency)" v-bind="validateInfos.currency" id="PuechaseQuotationFormForm-currency" name="currency">
                <JDictSelectTag v-model:value="formData.currency" placeholder="请选择" dictCode="currency" disabled/>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="报价备注(quotation notes)"
                v-bind="validateInfos.quotationNotes"
                id="PuechaseQuotationFormForm-quotationNotes"
                name="quotationNotes"
              >
                <a-input v-model:value="formData.quotationNotes" placeholder="请输入报价备注(quotation notes)" allow-clear AutoComplete="off" />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="技术资料(technical information)"
                v-bind="validateInfos.technicalInformation"
                id="PuechaseQuotationFormForm-technicalInformation"
                name="technicalInformation"
              >
                <JUpload v-model:value="formData.technicalInformation" />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="报价资料(quotation information)"
                v-bind="validateInfos.quotationInformation"
                id="PuechaseQuotationFormForm-quotationInformation"
                name="quotationInformation"
              >
                <JUpload v-model:value="formData.quotationInfomation" />
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </template>
    </JFormContainer>

    <!-- 子表单区域 -->
    <a-tabs v-model:activeKey="activeKey" animated style="padding: 24px; padding-top: 0px">
      <a-tab-pane tab="采购报价单 - 产品明细(product details)" key="PuechaseQuotationFormProduct" :forceRender="true">
        <a-button type="primary" @click="SelectSupplierInquiry" style="margin-right: 1%; margin-bottom: 1%">
          选择供应商询价单(select supplier inquiry form)</a-button
        >
        <a-button type="primary" @click="selectProducts" style="margin-right: 1%; margin-bottom: 1%"> 选择产品(select product)</a-button>
        <a-button type="primary" @click="setDiscountForSonList" style="margin-right: 1%; margin-bottom: 1%"> 设置折扣(set discount)</a-button>
        <j-vxe-table
          :keep-source="true"
          resizable
          ref="PuechaseQuotationFormProductTableRef"
          :loading="PuechaseQuotationFormProductTable.loading"
          :columns="PuechaseQuotationFormProductTable.columns"
          :dataSource="PuechaseQuotationFormProductTable.dataSource"
          :maxHeight="340"
          :disabled="disabled"
          :rowNumber="true"
          :rowSelection="true"
          asyncRemove
          @value-change="changeValues"
        >
          <template #action="props">
            <a-popconfirm title="确定删除吗？" @confirm="handleDelete1(props)">
              <a>删除(delete)</a>
            </a-popconfirm>
          </template>
        </j-vxe-table>
      </a-tab-pane>
      <a-tab-pane tab="采购报价单 - 船明细(ship details)" key="PuechaseQuotationFormShip" :forceRender="true">
        <j-vxe-table
          :keep-source="true"
          resizable
          ref="PuechaseQuotationFormShipTableRef"
          :loading="PuechaseQuotationFormShipTable.loading"
          :columns="PuechaseQuotationFormShipTable.columns"
          :dataSource="PuechaseQuotationFormShipTable.dataSource"
          :maxHeight="340"
          :disabled="disabled"
          :rowNumber="true"
          :rowSelection="true"
        >
          <template #action="props">
            <a @click="viewAccessory(props)">查看配件信息(view accessory information)</a>
          </template>
        </j-vxe-table>
      </a-tab-pane>
    </a-tabs>
    <BaseShipArchiveAccessoriesModal ref="BaseShipArchiveAccessoriesListRef" />
    <SelectPrpductModal ref="SelectPrpductModalRef" @select-product="addProduct" />
    <SelectProjectModal ref="SelectProjectModalRef" @select-project="addProject" />
    <SelectSupplierInquiryModal ref="SelectSupplierInquiryModalRef" @select-customer-inquiry="addProductFromCustomer" />
    <SetSonList ref="SetSonListRef" @success="setSonListFiled"></SetSonList>
  </a-spin>
</template>

<script lang="ts">
  import { defineComponent, ref, reactive, computed, toRaw } from 'vue';
  import { defHttp } from '/@/utils/http/axios';
  import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
  import {
    PuechaseQuotationFormShippTable,
    queryPurcodeQuotationFormProductListByMainId,
    queryDataById,
    saveOrUpdate,
    ClassList,
    supplierOption,
  } from '../PurchaseQuotationForm.api';
  import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  import { PuechaseQuotationFormShipColumns, PuechaseQuotationFormProductColumns } from '../PurchaseQuotationForm.data';
  import BaseShipArchiveAccessoriesModal from '../../../publicComponents/BaseShipArchiveAccessoriesModal.vue';
  import SelectPrpductModal from '../../../publicComponents/SelectPrpductModal.vue';
  import SelectProjectModal from '../../../publicComponents/SelectProjectModal.vue';
  import SelectSupplierInquiryModal from './SelectSupplierInquiryModal.vue';
  import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  import { JDictSelectTag,ApiSelect,JSelect } from '/@/components/Form';
  import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  import SetSonList from './SetSonList.vue';
  import { Form, message } from 'ant-design-vue';
  import moment from 'moment';
  const useForm = Form.useForm;
  export default defineComponent({
    name: 'PuechaseQuotationFormForm',
    components: {
      JVxeTable,
      JFormContainer,
      BaseShipArchiveAccessoriesModal,
      SelectPrpductModal,
      JUpload,
      SelectProjectModal,
      JDictSelectTag,
      JSelectInput,
      SelectSupplierInquiryModal,
      ApiSelect,
      JSelect,
      SetSonList
    },
    props: {
      formDisabled: {
        type: Boolean,
        default: false,
      },
      formData: { type: Object, default: () => {} },
      formBpm: { type: Boolean, default: true },
    },
    emits: ['success'],
    setup(props, { emit }) {
      const loading = ref(false);
      const formRef = ref();
      var showField = ref('currency_dictText+name');
      var SetSonListRef =ref();
      var SelectPrpductModalRef = ref();
      var SelectProjectModalRef = ref();
      var SelectSupplierInquiryModalRef = ref();
      const PuechaseQuotationFormShipTableRef = ref();
      const PuechaseQuotationFormShipTable = reactive<Record<string, any>>({
        loading: false,
        columns: PuechaseQuotationFormShipColumns,
        dataSource: [],
      });
      const PuechaseQuotationFormProductTableRef = ref();
      const PuechaseQuotationFormProductTable = reactive<Record<string, any>>({
        loading: false,
        columns: PuechaseQuotationFormProductColumns,
        dataSource: [],
      });
      var BaseShipArchiveAccessoriesListRef = ref();
      const activeKey = ref('PuechaseQuotationFormProduct');
      var notAllowEdit = ref(false);
      const formData = reactive<Record<string, any>>({
        id: '',
        status: undefined,
        delFlag: undefined,
        otherStatus: '',
        submit: '',
        sourceCode: '',
        billDate: moment(new Date()).format('YYYY-MM-DD'),
        billCode: '',
        projectName: '',
        qutationProject: '',
        suppilerName: '',
        quotationSuppiler: '',
        quotationDeadline: '',
        priority: '',
        productionClass: '',
        model: '',
        maker: '',
        paymentTerms: '',
        placeDelivery: '',
        delivery: '',
        deliveryDayHead: '',
        quotationValidity: '',
        quotationValidityDate: '',
        currency: '',
        quotationNotes: '',
        technicalInformation: '',
        saleAttachs: '',
        paymentTermsInfo: '',
        quotationInfomation: '',
        qualityGradeHead:''
      });

      //表单验证
      const validatorRules = reactive({
        projectName: [
          { required: true, message: '请选择报价项目(select project)' }
        ],
        quotationSuppiler:[
          { required: true, message: '请选择报价供应商(select supplier)' }
        ],
        currency:[
          { required: true, message: '请选择币种(currency)' }
        ],
      });
      const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: false});
      const dbData = {};
      const formItemLayout = {
        labelCol: { xs: { span: 24 }, sm: { span: 5 } },
        wrapperCol: { xs: { span: 24 }, sm: { span: 16 } },
      };

      // 表单禁用
      const disabled = computed(() => {
        if (props.formBpm === true) {
          if (props.formData.disabled === false) {
            return false;
          } else {
            return true;
          }
        }
        return props.formDisabled;
      });

      function add() {
        resetFields();
        PuechaseQuotationFormShipTable.dataSource = [];
        PuechaseQuotationFormProductTable.dataSource = [];
        activeKey.value = 'PuechaseQuotationFormProduct';
        notAllowEdit.value = false;
      }

      async function edit(row) {
        //主表数据
        await queryMainData(row.id);
        //子表数据
        const PuechaseQuotationFormShipDataList = await PuechaseQuotationFormShippTable(row['id']);
        PuechaseQuotationFormShipTable.dataSource = [...PuechaseQuotationFormShipDataList];
        const PuechaseQuotationFormProductDataList = await queryPurcodeQuotationFormProductListByMainId(row['id']);
        PuechaseQuotationFormProductTable.dataSource = [...PuechaseQuotationFormProductDataList];
        notAllowEdit.value = true;
      }

      async function queryMainData(id) {
        const row = await queryDataById(id);
        resetFields();
        const tmpData = {};
        Object.keys(formData).forEach((key) => {
          if (row.hasOwnProperty(key)) {
            tmpData[key] = row[key];
          }
        });
        //赋值
        Object.assign(formData, tmpData);
      }

      const { getSubFormAndTableData, transformData } = useValidateAntFormAndTable(activeKey, {
        purPurchaseQuotationShip: PuechaseQuotationFormShipTableRef,
        purPurchaseQuotationProduct: PuechaseQuotationFormProductTableRef,
      });

      async function getFormData() {
        try {
          // 触发表单验证
          await validate();
        } catch ({ errorFields }) {
          if (errorFields) {
            const firstField = errorFields[0];
            if (firstField) {
              formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
            }
          }
          return Promise.reject(errorFields);
        }
        return transformData(toRaw(formData));
      }

      async function submitForm() {
        if (formData.sourceCode == '') {
          message.warning('请选择供应商询价单');
        } else {
          const mainData = await getFormData();
          PuechaseQuotationFormProductTableRef.value!.validateTable().then(async (errMap) =>  {
            if (errMap) {
              console.log('表单验证未通过：', { errMap });
            } else {
              const subData = await getSubFormAndTableData();
              const values = Object.assign({}, dbData, mainData, subData);
              console.log('表单提交数据', values)
              const isUpdate = values.id ? true : false
              await saveOrUpdate(values, isUpdate);
              //关闭弹窗
              emit('success');
            }
          });
        }
      }

      function setFieldsValue(values) {
        if (values) {
          Object.keys(values).map((k) => {
            formData[k] = values[k];
          });
        }
      }

      /**
       * 值改变事件触发-树控件回调
       * @param key
       * @param value
       */
      function handleFormChange(key, value) {
        formData[key] = value;
      }
      async function handleDelete(prop) {
        const xTable = PuechaseQuotationFormProductTableRef.value!.getXTable();
        var newArray = [...xTable.data];
        newArray.splice(prop.rowIndex, 1);
        PuechaseQuotationFormShipTable.dataSource = newArray;
      }
      async function handleDelete1(prop) {
        const xTable = PuechaseQuotationFormProductTableRef.value!.getXTable();
        var newArray = [...xTable.data];
        newArray.splice(prop.rowIndex, 1);
        PuechaseQuotationFormProductTable.dataSource = newArray;
        if (PuechaseQuotationFormProductTable.dataSource.length !== 0) {
          var arr = [];
          PuechaseQuotationFormProductTable.dataSource.map((item) => {
            if (item.sourceId) {
              arr.push(item.sourceId);
            }
          });
          if (arr.length == 0) {
            formData.sourceCode = '';
            notAllowEdit.value = false;
          }
        } else {
          notAllowEdit.value = false;
          formData.sourceCode = '';
          add();
        }
      }
      function addShip(data) {
        var arr = data.concat(PuechaseQuotationFormShipTable.dataSource);
        arr.map((item) => (item.shipowner = item.relateCustomer));
        PuechaseQuotationFormShipTable.dataSource = arr;
      }
      function addProduct(data) {
        data.map((item) => {
          item.productClass = item.classId_dictText;
          item.productCode = item.code;
          item.unit = item.measurementUnit;
          item.needShip = '0';
          item.shipInspection = '';
          item.productId = item.id;
          item.id = undefined
        });
        const xTable = PuechaseQuotationFormProductTableRef.value!.getXTable();
        var arrProduct = xTable.data.concat(data);
        PuechaseQuotationFormProductTable.dataSource = arrProduct;
      }
      function addProject(data) {
        if (data.length !== 0) {
          formData.qutationProject = data[0].id;
          formData.projectName = data[0].code;
        } else {
          formData.projectName = '';
          formData.qutationProject = '';
        }
      }
      function changeFormDeliveryTime() {
        const xTable = PuechaseQuotationFormProductTableRef.value!.getXTable();
        var arrProduct = [...xTable.data];
        arrProduct.map((item) => {
          item.deliveryDayChild = formData.deliveryDayHead;
        });
        PuechaseQuotationFormProductTable.dataSource = arrProduct;
      }
       function addProductFromCustomer(data) {
        data.map((item) => {
          item.productClass = item.productClass;
          item.productCode = item.productCode;
          item.unit = item.unit;
          item.sourceId = item.childId;
          item.model = item.childModel;
          item.deliveryDayChild = formData.deliveryDayHead;
        });
        const xTable = PuechaseQuotationFormProductTableRef.value!.getXTable();
        var arrProduct = xTable.data.concat(data);
        notAllowEdit.value = true;
        PuechaseQuotationFormProductTable.dataSource = arrProduct;
        formData.quotationProject = data[0].inquiryProject;
        formData.delivery = data[0].delivery;
        formData.paymentTerms = data[0].paymentTerms;
        formData.projectName = data[0].projectName;
        formData.quotationSuppiler = data[0].inquirySuppiler;
        formData.suppilerName = data[0].suppilerName;
        formData.sourceCode = data[0].billCode;
        formData.priority = data[0].priority;
        formData.model = data[0].headModel;
        formData.maker = data[0].maker;
        formData.placeDelivery = data[0].placeDelivery;
        // formData.inquiryTeam =  data[0].inquiryTeam
        formData.productionClass = data[0].productionClass;
        formData.productionClass_dictText = data[0].productionClass_dictText;
        formData.qualityGradeHead = data[0].qualityGradeHead;
        // formData.saleAttachs =data[0].attachs
        getShipList(data[0].headId);
        if(formData.quotationSuppiler&& formData.quotationSuppiler!==''){
          getSupplierCurreny(formData.quotationSuppiler)
        }
        
      }
      async function getSupplierCurreny(id){
        var obj = await supplierOption({id:id})
        formData.currency = obj.records[0].currency
      }
      function getShipList(id) {
        let params = { id: id };
        defHttp.get({ url: '/purCode/purInquiryForm/queryPurInquiryFormShipByMainId', params }, { isTransformResponse: false }).then((res) => {
          if (res) {
            PuechaseQuotationFormShipTable.dataSource = res.result;
          }
        });
      }
      function viewAccessory(prop) {
        BaseShipArchiveAccessoriesListRef.value.getTable(prop.row);
      }
      function selectProducts() {
        SelectPrpductModalRef.value.getTable();
      }
      function onSearchProject() {
        SelectProjectModalRef.value.getTable();
      }
      function SelectSupplierInquiry() {
        SelectSupplierInquiryModalRef.value.getTable(formData);
      }
      async function changeSupplier(prop){
          if(prop){
            var params={id:prop}
            var obj = await supplierOption(params)
            formData.suppilerName = obj.records[0].name
            formData.paymentTerms = obj.records[0].paymentTerms
            getSupplierCurreny(prop)
          }else{
            formData.quotationSuppiler = ''
            formData.suppilerName = ''
          }        
      }
      function changeValues(prop){
       if (prop.col.key == 'quantity'||prop.col.key == 'taxPriceOriginal') {
          if (prop.row.quantity||prop.row.taxPriceOriginal) {
            var num = Number(prop.row.quantity) * Number(prop.row.taxPriceOriginal)
            prop.row.taxAmountOriginal = isNaN(num) ? '' : num.toFixed(2);
            prop.row.discount = isNaN( prop.row.discount)?0:Number( prop.row.discount)
            prop.row.taxPrice =  (Number(prop.row.taxPriceOriginal)*(1-prop.row.discount/100)).toFixed(2)
            prop.row.taxAmount =  (Number(prop.row.taxPrice)*Number(prop.row.quantity)).toFixed(2)
          }
        }
        if (prop.col.key == 'discount') {
          if (prop.row.discount||prop.row.taxPriceOriginal||prop.row.quantity) {
            prop.row.taxPrice =  (Number(prop.row.taxPriceOriginal)*(1-prop.row.discount/100)).toFixed(2)
            prop.row.taxAmount =  (Number(prop.row.taxPrice)*Number(prop.row.quantity)).toFixed(2)
          } 
        }
      }
      function setDiscountForSonList(){
        SetSonListRef.value.getTable()
      }
      function setSonListFiled(value){
        var xTable = (PuechaseQuotationFormProductTableRef.value!.getXTable()).data
        if(xTable.length>0){
          xTable.map(item=>{
            item.discount = isNaN(value.numericalValue)?0:value.numericalValue
            if (item.taxAmountOriginal) {
              item.taxPrice =  (Number(item.taxPriceOriginal)*(1-item.discount/100)).toFixed(2)
              item.taxAmount =  (Number(item.taxPrice)*Number(item.quantity)).toFixed(2)

            }
          })
        }
        PuechaseQuotationFormProductTable.dataSource =[...xTable]
      }
      return {
        PuechaseQuotationFormShipTableRef,
        PuechaseQuotationFormShipTable,
        PuechaseQuotationFormProductTableRef,
        PuechaseQuotationFormProductTable,
        validatorRules,
        validateInfos,
        activeKey,
        loading,
        formData,
        setFieldsValue,
        handleFormChange,
        formItemLayout,
        disabled,
        getFormData,
        submitForm,
        add,
        edit,
        formRef,
        addShip,
        addProduct,
        BaseShipArchiveAccessoriesListRef,
        viewAccessory,
        handleDelete,
        handleDelete1,
        selectProducts,
        SelectPrpductModalRef,
        SelectProjectModalRef,
        SelectSupplierInquiryModalRef,
        onSearchProject,
        addProject,
        supplierOption,
        SelectSupplierInquiry,
        addProductFromCustomer,
        changeFormDeliveryTime,
        changeSupplier,
        notAllowEdit,
        ClassList,
        showField,
        changeValues,
        setDiscountForSonList,
        SetSonListRef,
        setSonListFiled,
        getSupplierCurreny
      };
    },
  });
</script>
<style lang="less" scoped>
  /** 时间和数字输入框样式 */
  :deep(.ant-input-number) {
    width: 100%;
  }

  :deep(.ant-calendar-picker) {
    width: 100%;
  }
  /deep/.vxe-table--body-wrapper {
    height: 100% !important;
  }
  /deep/.ant-modal-body {
    padding: 24px !important;
  }

  /deep/.ant-form-item {
    margin-bottom: 8px !important;
  }
  /deep/.vxe-cell--valid-error-msg{
    color:red !important;
    background-color: white !important;
  }  
</style>
