<template>
  <div class="makeInventoryDetail-wrap">
    <a-page-header :ghost="false" @back="handleBack" class="makeInventoryDetail-back">
      <!-- 自定义的二级文字标题 -->
      <template slot="subTitle">
        <a id="makeInventoryDetail-back-btn" href="javascript:;" @click="handleBack">返回列表</a>
      </template>
      <!-- 操作区，位于 title 行的行尾 -->
      <template slot="extra">
        <a-button key="1" type="primary" id="makeInventoryDetail-print-btn">快速打印</a-button>
      </template>
    </a-page-header>
    <!-- 基础信息 -->
    <a-card size="small" :bordered="false" class="makeInventoryDetail-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>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
    <!-- 详情 -->
    <a-card size="small" :bordered="false" class="makeInventoryDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="详情">
          <!-- 总计 -->
          <a-alert type="info" showIcon style="margin-bottom:10px">
            <div slot="message">库存总数量： <strong>6</strong> ，盈亏总数量： <strong>6</strong></div>
          </a-alert>
          <!-- 筛选条件 -->
          <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
              <a-row :gutter="15">
                <a-col :md="6" :sm="24">
                  <a-form-item label="类型">
                    <a-select placeholder="请选择" id="makeInventoryDetail-type" allowClear v-model="queryParam.dataSourceNo">
                      <a-select-option v-for="item in brandData" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :md="6" :sm="24" style="margin-bottom: 24px;">
                  <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="makeInventoryDetail-refresh">查询</a-button>
                  <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="makeInventoryDetail-reset">重置</a-button>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <!-- 列表 -->
          <s-table
            class="sTable"
            ref="table"
            size="small"
            :rowKey="(record) => record.id"
            :columns="columns"
            :data="loadData"
            bordered>
            <!-- 采购数量 -->
            <template slot="purchaseNum" slot-scope="text, record">
              <span>{{record.purchaseNum}}</span>
            </template>
            <!-- 缺货数量 -->
            <template slot="outOfStockNum" slot-scope="text, record">
              <span>{{record.outOfStockNum}}</span>
            </template>
          </s-table>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
  </div>
</template>

<script>
  import { STable, VSelect } from '@/components'
  export default{
    components: { STable, VSelect },
    data(){
      return{
        queryParam: {
          dataSourceNo: undefined
        },
        disabled: false, //  查询、重置按钮是否可操作
        // 表头
        columns: [
          { title: '序号', dataIndex: 'no', align: 'center' },
          { title: '产品编码', dataIndex: 'creatDate', align: 'center', customRender: function (text) { return text || '--' } },
          { title: '产品名称', dataIndex: 'custName', align: 'center', customRender: function (text) { return text || '--' } },
          { title: '单位', dataIndex: 'mementPay', align: 'center', customRender: function (text) { return text || '--' } },
          { title: '库存数量', scopedSlots: { customRender: 'outOfStockNum' }, align: 'center' },
          { title: '盘点数量', dataIndex: 'tostalP', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
          { title: '盈亏数量', dataIndex: 'totalNums', align: 'center', customRender: function (text) { return ((text || text == 0) ? 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', 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)
          })
        },
        brandData: []
      }
    },
    methods: {
      //  重置
      resetSearchForm(){},
      //  返回列表
      handleBack(){
        this.$router.push({ path: '/inventoryManagement/inventoryChecking/list', query: { closeLastOldTab: true }})
      },
    }
  }
</script>

<style lang="less">
  .makeInventoryDetail-cont, .makeInventoryDetail-back{
    margin-bottom: 15px;
  }
</style>
