<template>
  <div class="quotationDetail-wrap">
    <a-page-header :ghost="false" @back="handleBack" class="quotationDetail-back">
      <!-- 自定义的二级文字标题 -->
      <template slot="subTitle">
        <a id="quotationDetail-back-btn" href="javascript:;" @click="handleBack">返回列表</a>
      </template>
      <!-- 操作区，位于 title 行的行尾 -->
      <!-- <template slot="extra">
        <a-button key="3" type="danger" id="quotationDetail-export-btn">导出</a-button>
        <a-button key="2" id="quotationDetail-preview-btn">打印预览</a-button>
        <a-button key="1" type="primary" id="quotationDetail-print-btn">快速打印</a-button>
      </template> -->
    </a-page-header>
    <a-card size="small" :bordered="false" class="quotationDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="基础信息">
          <a-descriptions :column="3">
            <a-descriptions-item label="客户名称">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="客户地址">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="报价单号">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="联系电话">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="备注">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="业务员">箭冠营销中心</a-descriptions-item>
            <a-descriptions-item label="制单人">箭冠营销中心</a-descriptions-item>
          </a-descriptions>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
    <a-card size="small" :bordered="false" class="quotationDetail-cont">
      <!-- 总计 -->
      <a-alert type="info" style="margin-bottom:10px">
        <div slot="message">总款数：<strong>1</strong>，总数量：<strong>1</strong>，总赠品数量：<strong>0</strong>，总售价：<strong>14</strong>，总成本：<strong>6.33</strong>，总毛利： <strong>6</strong></div>
      </a-alert>
      <!-- 列表 -->
      <s-table
        class="sTable"
        ref="table"
        size="small"
        :rowKey="(record) => record.id"
        :columns="columns"
        :data="loadData"
        :scroll="{ x: 1160 }"
        bordered></s-table>
    </a-card>
  </div>
</template>

<script>
import { STable, VSelect } from '@/components'
export default {
  components: { STable, VSelect },
  data () {
    return {
      queryParam: {

      },
      disabled: false, //  查询、重置按钮是否可操作
      brandData: [], //  产品品牌  下拉数据
      typeData: [], //  产品类别  下拉数据
      // 表头
      columns: [
        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
        { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center' },
        { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '原厂编码', dataIndex: 'productOrigCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '品牌', dataIndex: 'producstOrigCode', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '成本价', dataIndex: 'costPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '销售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '单位', dataIndex: 'productOrigUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '售价小计', dataIndex: 'salePriceSubtotal', width: 100, align: 'center' }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.disabled = true
        // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
        //   const data = res.data
        //   const no = (data.pageNo - 1) * data.pageSize
        //   for (var i = 0; i < data.list.length; i++) {
        //     data.list[i].no = no + i + 1
        //   }
        //   this.disabled = false
        //   return data
        // })
        const _this = this
        return new Promise(function (resolve, reject) {
          const data = {
            pageNo: 1,
            pageSize: 10,
            list: [
              { id: '1', purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' }
            ],
            count: 10
          }
          const no = (data.pageNo - 1) * data.pageSize
          for (var i = 0; i < data.list.length; i++) {
            data.list[i].no = no + i + 1
          }
          _this.disabled = false
          resolve(data)
        })
      }
    }
  },
  methods: {
    //  重置
    resetSearchForm () {
      this.queryParam.orderBundleNo = ''
      this.queryParam.orderBundle.custMobile = ''
      this.queryParam.bundleName = ''
      this.queryParam.itemName = ''
      this.oldTime = undefined
      this.newTime = undefined
      this.$refs.table.refresh(true)
    },
    //  提交
    handleSubmit () {},
    //  返回列表
    handleBack () {
      this.$router.push({ path: '/salesManagement/quotation/list', query: { closeLastOldTab: true } })
    }
  }
}
</script>

<style lang="less">
  .quotationDetail-wrap{
    .quotationDetail-back{
      margin-bottom: 10px;
    }
    .quotationDetail-cont{
      margin-bottom: 10px;
    }
  }
</style>
