<template>
  <div style="page-break-after:always;padding: 0px 20px;box-sizing: border-box;" class="print-html-wrap" id="printDiv">
    <div class="print-title">{{dialogTitle}}</div>
    <table border="1px" class="table-write">
      <tr>
        <td class="keep">报价编号</td>
        <td class="tx-lf" colspan="5">{{infoForm.number}}</td>
      </tr>
      <tr>
        <td class="keep">金额</td>
        <td class="tx-lf" colspan="5">{{infoForm.money}}元</td>
      </tr>
      <tr>
        <td class="keep">类别</td>
        <td class="tx-lf">{{handleFilterStr(infoForm.purchasingCategoriesId)}}</td>
        <td class="keep">产品名称</td>
        <td class="tx-lf" colspan="3">{{infoForm.productName}}</td>
      </tr>
      <tr>
        <td class="keep">采购名称</td>
        <td class="tx-lf">{{infoForm.projectName}}</td>
        <td class="keep">报价截止时间</td>
        <td class="tx-lf max200">{{ dayjs(infoForm.cutoffTime).format('YYYY-MM-DD') }}
        </td>
      </tr>
      <tr>
        <td class="keep">供应商信息列表</td>
        <td colspan="5">
          <table class="bottom-table-write">
            <tr>
              <td>企业名称</td>
              <td>供应商编码</td>
              <td>企业性质</td>
              <td>法人代表</td>
              <td>联系方式</td>
              <td>统一社会信用代码</td>
              <td>银行户名</td>
              <td>创建时间</td>
            </tr>
            <tr v-for="(item,index) in infoForm.supplierList" :key="index">
              <td>{{item.companyAme}}</td>
              <td>{{item.companyNumber}}</td>
              <td>{{ getDictDataLabel(DICT_TYPE.BS_ENTERPRISEL_TYPE,item.companyType)}}</td>
              <td>{{ item.legalPerson }}</td>
              <td>{{ item.phone }}</td>
              <td>{{ item.creditCode }}</td>
              <td>{{ item.bankName }}</td>
              <td>{{  parseTime(item.createTime) }}</td>
            </tr>
          </table>
        </td>
      <tr>
        <td class="keep">物料信息列表</td>
        <td colspan="5">
          <table class="bottom-table-write">
            <tr>
              <td>物料名称</td>
              <td>物料编码</td>
              <td>规格描述</td>
              <td>单台用量</td>
              <td>单位</td>
              <td>材质</td>
              <td>备注</td>
            </tr>
            <tr v-for="(item,index) in infoForm.quotationDetails" :key="index">
              <td>{{item.materielName}}</td>
              <td>{{item.materielCode}}</td>
              <td>{{item.descStr}}</td>
              <td>{{ item.dosage }}</td>
              <td>{{ item.unit }}</td>
              <td>{{ item.quality }}</td>
              <td>{{ item.remark }}</td>
            </tr>
          </table>
        </td>
      </tr>

    </table>
  </div>
</template>
<script>
import dayjs from "dayjs";
import { findAreaIdName } from '@/utils';
import { getDictDataLabel } from '@/utils/dict';
export default {
  props: {
    userList: Array,
    quotationList: Array,
    infoForm: {
      type: Object
    },
    dialogTitle: {
      type: String
    },
    tasks: Object
  },
  computed: {
    cn() {
      return window.localStorage.getItem('cn')
    }
  },
  methods: {
    dayjs,
    getDictDataLabel,
    handleFilterStr(val) {
      const { label } = this.quotationList.find((item) => item.value == val) || {}
      return label
    },
    handleTripPartners(list) {
      let nameArr = this.userList.map((item) => {
        // item.id
        if (Array.isArray(list)) {
          if (list.includes(item.id)) {
            return item.username
          } else {
            return ''
          }
        }
      })
      return nameArr.filter((item => item !== '')).join('、')
    },
    handleFindTitle(val) {
      return (findAreaIdName(this.$store.getters.areaTree, val) || {}).name
      // return (findAreaIdName(this.$store.getters.areaTree, val) || {}).name
    },
  },
  data() {
    return {
      // defaultImg: require('@/assets/Images/defaultHeader.png')
    }
  },
  filters: {

  }
}
</script>
<style lang="scss" scoped>
@import '@/assets/styles/index.scss';
</style>
<style media="print" scoped>
/*去除页眉页脚*/
@page {
  size: auto; /* auto is the initial value */
  margin: 3mm; /* this affects the margin in the printer settings */
}
html {
  background-color: #ffffff;
  margin: 0; /* this affects the margin on the html before sending to printer */
}
body {
  border: solid 1px blue;
  margin: 10mm 15mm 10mm 15mm; /* margin you want for the content */
}
/*去除页眉页脚*/
</style>
