<template>
  <div class="examineVerifyDetail-page-wrapper">
    <!-- 操作 -->
    <a-page-header :ghost="false" @back="handleBack" class="examineVerifyDetail-operation-wrapper">
      <!-- 自定义的二级文字标题 -->
      <template slot="subTitle">
        <a id="examineVerifyDetail-btn-back" href="javascript:;" @click="handleBack">返回列表</a>
      </template>
      <!-- 操作区，位于 title 行的行尾 -->
      <template slot="extra">
        <a-button key="2" @click="handlePreview" id="examineVerifyDetail-btn-preview">打印预览</a-button>
        <a-button key="1" type="primary" @click="handlePrint" id="examineVerifyDetail-btn-print">快速打印</a-button>
      </template>
    </a-page-header>
    <!-- 急件单信息 -->
    <a-card size="small" :bordered="false" class="examineVerifyDetail-info-wrapper">
      <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="备注" span="2">名称思密达名称思密达名称思密达名称思密达名称思密达名称思密达名称思密达名称思密达名称思密达</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="examineVerifyDetail-table-wrapper">
      <!-- 合计 -->
      <a-alert type="info" showIcon style="margin-bottom:15px">
        <div slot="message">
          总款数：<strong>998</strong>；总数量：<strong>2009</strong>；总数量：<strong>2009</strong>；急件总款数：<strong>2009</strong>；急件总数量：<strong>2009</strong>。<br/>
          总售价：<strong>998</strong>；总成本：<strong>2009</strong>；总毛利：<strong>2009</strong>；折后总售价：<strong>2009</strong>；折扣：<strong>2009%</strong>；折扣金额：<strong>2009</strong>。
        </div>
      </a-alert>
      <s-table
        class="sTable"
        ref="table"
        size="default"
        :rowKey="(record) => record.id"
        :columns="columns"
        :data="loadData"
        :scroll="{ x: 1660 }"
        bordered>
        <!-- 库存数量 -->
        <template slot="inventoryQuantity" slot-scope="text, record">
          <span :class="[record.inventoryQuantity < record.quantityNotOffset ? 'red' : '']">{{ record.inventoryQuantity }}</span>
        </template>
      </s-table>
    </a-card>
  </div>

</template>

<script>
import { STable, VSelect } from '@/components'
export default {
  components: { STable, VSelect },
  data () {
    return {
      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: '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: 'discountedPrice', 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' },
        { title: '折后小计', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '折扣金额', dataIndex: 'discountAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center' },
        { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center' },
        { title: '销售类型', dataIndex: 'salesBillType', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
      ],
      // 加载数据方法 必须为 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', productNum: 'jgqp11111111111', inventoryQuantity: 0, quantityNotOffset: 3, productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
            ]
          }
          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: {
    //  返回
    handleBack () {
      this.$router.push({ path: '/salesManagement/examineVerify/list' })
    },
    //  冲减
    handleSubmit () {
      const _this = this
      this.$confirm({
        title: '提示',
        content: '确定要进行冲减吗？',
        okText: '确定',
        cancelText: '取消',
        centered: true,
        onOk () {
          // delectRolePower({
          //   id: row.id
          // }).then(res => {
          //   console.log(res, 'res1111')
          //   if (res.status == 200) {
          //     _this.$message.success(res.message)
          //     _this.$refs.table.refresh()
          //   }
          // })
        }
      })
    },
    //  快速打印
    handlePrint () {

    },
    //  打印预览
    handlePreview () {

    }
  }
}
</script>

<style lang="less">
  .examineVerifyDetail-page-wrapper{
    .examineVerifyDetail-info-wrapper{
      margin: 15px 0;
      .item-cont {
        margin-bottom: 15px;
        display: flex;
        .item-label {
          width: 115px;
          font-size: 14px;
          color: rgba(0, 0, 0, 0.85);
          flex-shrink: 0;
        }
        .item-main {
          flex-grow: 1;
          word-break: break-all;
        }
      }
    }
    .examineVerifyDetail-table-wrapper{
      .red{
        color: #ed1c24;
      }
    }
  }
</style>
