<template>
  <!-- <ele-modal
    custom-class="ele-dialog-form long-dialog-form"
    :centered="true"
    v-if="visible"
    :visible.sync="visible"
    :title="title"
    :close-on-click-modal="false"
    width="80%"
    @close="cancel"
  > -->
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <headerTitle title="基本信息">
        <!-- <el-button
                  size="small"
                  type="primary"
                  icon="el-icon-s-grid"
                  class="ele-btn-icon"
                  @click="exportTable"
                >
                 导出
                </el-button> -->
      </headerTitle>
      <el-row>
        <el-col :span="12">
          <el-form-item
            label="关联商机名称"
            prop="opportunityName"
            style="margin-bottom: 22px"
          >
            {{ detailData.opportunityName }}
          </el-form-item>
          <el-form-item
            label="询价方名称"
            prop="contactName"
            style="margin-bottom: 22px"
          >
            {{ form.contactName }}
          </el-form-item>

          <el-form-item
            label="询价方联系人"
            prop="contactLinkName"
            style="margin-bottom: 22px"
          >
            {{ form.contactLinkName }}
          </el-form-item>

          <el-form-item
            label="询价方电话"
            prop="contactTel"
            style="margin-bottom: 22px"
          >
            {{ form.contactTel }}
          </el-form-item>
          <el-form-item
            label="询价方传真"
            prop="contactFax"
            style="margin-bottom: 22px"
          >
            {{ form.contactFax }}
          </el-form-item>
          <el-form-item
            label="询价方Email"
            prop="contactEmail"
            style="margin-bottom: 22px"
          >
            {{ form.contactEmail }}
          </el-form-item>
          <el-form-item
            label="询价方地址"
            prop="contactAddress"
            style="margin-bottom: 22px"
          >
            {{ form.contactAddress }}
          </el-form-item>
          <el-form-item prop="askFile" label="附件">
            <el-link
              v-if="form.askFile && form.askFile !== ''"
              type="primary"
              :underline="false"
              @click="downloadFile(form.askFile)"
            >
              {{ form.askFile.name }}</el-link
            >
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="报价方名称"
            prop="quoteName"
            style="margin-bottom: 22px"
          >
            {{ form.quoteName }}
          </el-form-item>

          <el-form-item
            label="报价方联系人"
            prop="quoteLinkName"
            style="margin-bottom: 22px"
          >
            {{ form.quoteLinkName }}
          </el-form-item>
          <el-form-item prop="quoteTel" label="报价方联系电话">
            {{ form.quoteTel }}
          </el-form-item>
          <el-form-item prop="quoteFax" label="报价方传真">
            {{ form.quoteFax }}
          </el-form-item>

          <el-form-item
            label="报价方Email"
            prop="quoteEmail"
            style="margin-bottom: 22px"
          >
            {{ form.quoteEmail }}
          </el-form-item>

          <el-form-item
            label="报价方地址"
            prop="quoteAddress"
            style="margin-bottom: 22px"
          >
            {{ form.quoteAddress }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px">
        <el-col :span="6">
          <el-form-item prop="taxRate" label="税率">
            {{ form.taxRate }}%
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item prop="deliveryDate" label="交货日期">
            {{ form.deliveryDate?.substr(0, 10) }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item
            label="结算方式"
            prop="settlementMode"
            style="margin-bottom: 22px"
          >
            {{ form.settlementModeName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item
            label="是否接受拆单"
            prop="acceptUnpack"
            style="margin-bottom: 22px"
          >
            {{ form.acceptUnpack == 1 ? '接受' : '不接受' }}
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <headerTitle title="报价单产品清单"></headerTitle>

    <inventoryTable
      ref="inventoryTable"
      :isCustomerMark="false"
      :isDeliveryDeadline="false"
      :isGuaranteePeriod="false"
      v-if="taskDefinitionKey === 'technicianApprove'"
    ></inventoryTable>
    <inventoryTabledetail
    :isCustomerMark="false"
      v-if="taskDefinitionKey != 'technicianApprove'"
      ref="inventoryTabledetailRef"
    ></inventoryTabledetail>
  </div>
  <!-- </ele-modal> -->
</template>

<script>
  import { getFile } from '@/api/system/file';
  import dictMixins from '@/mixins/dictMixins';
  import { copyObj } from '@/utils/util';
  import inventoryTable from '@/views/bpm/handleTask/components/contractBook/inventoryTable.vue';

  import inventoryTabledetail from '@/views/bpm/handleTask/components/contractBook/inventoryTabledetail.vue';

  import { getDetail } from '@/api/bpm/components/saleManage/quotation';
  export default {
    mixins: [dictMixins],
    props: {
      businessId: {
        default: ''
      },
      taskDefinitionKey: {
        default: ''
      }
    },
    components: {
      inventoryTable,
      inventoryTabledetail
    },
    data() {
      return {
        visible: false,
        detailId: '',
        title: '详情',
        row: {},
        activeName: 'base',
        form: {},
        rules: {},
        detailData: {},
        competAnalysisListcolumns: [
          {
            width: 45,
            type: 'index',
            columnKey: 'index',
            align: 'center',
            fixed: 'left'
          },
          {
            width: 200,
            prop: 'productName',
            label: '名称',
            slot: 'productName'
          },
          {
            width: 120,
            prop: 'productCode',
            label: '编码',
            slot: 'productCode'
          },
          {
            width: 200,
            prop: 'productCategoryName',
            label: '类型',
            slot: 'productCategoryName'
          },
          {
            width: 160,
            prop: 'productBrand',
            label: '牌号',
            slot: 'productBrand'
          },
          {
            width: 120,
            prop: 'modelType',
            label: '型号',
            slot: 'modelType'
          },
          {
            width: 120,
            prop: 'specification',
            label: '规格',
            slot: 'specification'
          },

          {
            width: 160,
            prop: 'singlePrice',
            label: '单价',
            slot: 'singlePrice'
          },
          {
            width: 120,
            prop: 'totalCount',
            label: '数量',
            slot: 'totalCount'
          },
          {
            width: 120,
            prop: 'totalPrice',
            label: '销售总金额',
            slot: 'totalPrice',
            formatter: (_row, _column, cellValue) => {
              return _row.totalPrice + '元';
            }
          },
          {
            width: 120,
            prop: 'measuringUnit',
            label: '计量单位',
            slot: 'measuringUnit'
          },
          {
            width: 120,
            prop: 'deliveryDays',
            label: '交期(天)',
            slot: 'deliveryDays'
          },
          {
            width: 200,
            prop: 'guaranteePeriod',
            label: '质保期',
            slot: 'guaranteePeriod',
            formatter: (_row, _column, cellValue) => {
              return (_row.guaranteePeriod||'') + _row.guaranteePeriodUnitName;
            }
          },
          // {
          //   width: 120,
          //   prop: 'guaranteePeriodUnitCode',
          //   label: '',
          //   slot: 'guaranteePeriodUnitCode'
          // },
          {
            width: 240,
            prop: 'customerReqFiles',
            label: '客户需求',
            slot: 'customerReqFiles'
          },
          {
            width: 120,
            prop: 'technicalAnswerName',
            label: '技术答疑人',
            slot: 'technicalAnswerName'
          },
          {
            width: 220,
            prop: 'technicalParams',
            label: '技术参数',
            slot: 'technicalParams'
          },
          {
            width: 240,
            prop: 'technicalDrawings',
            label: '技术图纸',
            slot: 'technicalDrawings'
          },
          {
            width: 220,
            prop: 'remark',
            label: '备注',
            slot: 'remark'
          }
        ]
      };
    },
    created() {
      this.getDetailData(this.businessId);
    },
    methods: {
      //导出
      // async exportTable() {
      //   this.loading = true;
      //   // const response = await getExport(this.detailId);
      // },

      cancel() {
        this.$nextTick(() => {
          // 关闭后，销毁所有的表单数据
          (this.form = copyObj(this.formDef)),
            (this.otherForm = copyObj(this.otherFormDef)),
            (this.tableBankData = []);
          this.tableLinkData = [];
          this.visible = false;
        });
      },
      downloadFile(file) {
        getFile({ objectName: file.storePath }, file.name);
      },
      async getDetailData(id) {
        this.loading = true;
        const data = await getDetail(id);
        this.loading = false;
        if (data) {
          this.$refs.inventoryTable &&
            this.$refs.inventoryTable.putTableValue(data);
          this.$refs.inventoryTabledetailRef &&
            this.$refs.inventoryTabledetailRef.putTableValue(data);
          this.detailData = data;
          this.form = data;
        }
      },
      getTableValue() {
        return this.$refs.inventoryTable.getTableValue();
      }
    }
  };
</script>

<style scoped lang="scss">
  .ele-dialog-form {
    .el-form-item {
      margin-bottom: 10px;
    }
  }

  .headbox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .amount {
      font-size: 14px;
      font-weight: bold;
    }
  }
</style>
@/api/bpm/components/saleManage/quotation
