<script>
import {queryQuoteByInquiryNo} from "../../../../api/quotation/quote";

export default {
  name: "inquiryQuoteDetail",
  props:{
    inquiryNo:{
      type: String,
      required: true
    },
    site:{
      type: String,
      required: true
    },
    height:{
      type: [String,Number],
      default:"47vh",
    }
  },
  data(){
    return{
      queryLoading:false,
      dataList:[],
      columns:[
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10QuotationNo',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'quotationNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '报价单号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10QuotationDate',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'quotationDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '报价日期',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ProductNo',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'productNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '产品编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ProductDesc',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'productDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '产品名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10QuotationDetailQuantity',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'quotationDetailQuantity',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '报价数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ComputePartCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'computePartCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '计算后材料成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ComputeMachineCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'computeMachineCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '计算后机器成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ComputeLabourCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'computeLabourCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '计算后人工成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ComputeFabricateCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'computeFabricateCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '计算后制造费用',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10ComputeToolCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'computeToolCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '计算后工具成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10AdjustPartCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'adjustPartCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调整后材料成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10AdjustMachineCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'adjustMachineCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调整后机器成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10AdjustLabourCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'adjustLabourCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调整后人工成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
        {
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10AdjustFabricateCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'adjustFabricateCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调整后制造费用',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10AdjustToolCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'adjustToolCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '调整后工具成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10DetailOtherCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'detailOtherCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '其他成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10DetailManageCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'detailManageCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '管理成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10DetailTotalCost',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'detailTotalCost',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '总成本',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10DetailProfitRate',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'detailProfitRate',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '利润率%',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10DetailProfitAmount',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'detailProfitAmount',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '利润额',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10FinalUntaxedPrice',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'finalUntaxedPrice',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '未税单价',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10TaxRate',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'taxRate',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '税率%',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10FinalTaxedPrice',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'finalTaxedPrice',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '含税单价',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10SystemComputePrice',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'systemComputePrice',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '含税总价',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10QuotationDetailStatus',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'quotationDetailStatus',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '状态',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10Remark',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'remark',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },{
          userId: this.$store.state.user.name,
          functionId: 102001,
          serialNumber: '102001Table10InternalInquiryNo',
          tableId: '102001Table10',
          tableName: '报价详情信息表',
          columnProp: 'internalInquiryNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '询价单号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120
        },
      ],
    };
  },
  methods:{
    handleQuery(){
      let params = {
        internalInquiryNo: this.inquiryNo,
        site: this.site
      }
      this.queryLoading = true;
      queryQuoteByInquiryNo(params).then(({data})=>{
        if (data && data.code === 0){
          this.dataList = data.rows;
        }else {
          this.$message.warning(data.msg);
        }
        this.queryLoading = false;
      }).catch((error)=>{
        this.$message.error(error)
        this.queryLoading = false;
      })
    },
    handleClickDetail(row){
      if (this.$router.resolve('quotation-sellForQuotation').resolved.name === '404') {
        this.$alert('权限不足,访问失败', '警告', {confirmButtonText: '确定',})
      } else {
        this.$router.push({
          name: 'quotation-sellForQuotation',
          params:{
            quotationHeaderId:row.quotationHeaderId,
            from:'inquiry'
          }
        })
      }
    }
  },
  watch:{
    inquiryNo(newVal, oldVal){
      this.handleQuery();
    },
    site(newVal, oldVal){
      this.handleQuery();
    }
  }
}
</script>

<template>
  <el-table :height="height" :data="dataList" border v-loading="queryLoading" style="margin-top: 5px">
    <el-table-column label="操作" min-width="80px" fixed="left" align="center">
      <template slot-scope="scope">
        <a @click="handleClickDetail(scope.row)">详情</a>
      </template>
    </el-table-column>
    <el-table-column
      v-for="(item,index) in columns" :key="index"
      :sortable="item.columnSortable"
      :prop="item.columnProp"
      :header-align="item.headerAlign"
      :show-overflow-tooltip="item.showOverflowTooltip"
      :align="item.align"
      :fixed="item.fixed===''?false:item.fixed"
      :min-width="item.columnWidth"
      :label="item.columnLabel">
      <template slot-scope="scope" >
        <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp]}}</span>
        <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
      </template>
    </el-table-column>
  </el-table>
</template>

<style scoped>

</style>
