<template>
  <div class="outboundOrderDetail-wrap">
    <a-page-header :ghost="false" @back="handleBack" class="outboundOrderDetail-cont">
      <template slot="subTitle">
        <a href="javascript:;" @click="handleBack">返回列表</a>
        <a-button size="small" id="outboundOrderDetail-ts-btn" style="margin-left:30px" key="0">订单推送</a-button>
        <a-button size="small" id="outboundOrderDetail-export-btn" type="danger" style="margin-left:20px" key="1">销售导出</a-button>
      </template>
      <template slot="extra">
        <span>打印字段：</span>
        <a-select key="2" style="width:150px" id="sales-pritKey" placeholder="请选择打印字段" allowClear>
          <a-select-option v-for="item in pritKey" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
        </a-select>
        <span><i style="color: red;">*</i>打印模板：</span>
        <a-select key="3" style="width:150px" id="sales-pritKey" placeholder="请选择打印模板" allowClear>
          <a-select-option v-for="item in pritModal" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
        </a-select>
        <a-button key="4" id="outboundOrderDetail-preview-btn">打印预览</a-button>
        <a-button key="5" type="primary" id="outboundOrderDetail-print-btn">快速打印</a-button>
      </template>
    </a-page-header>
    <!-- 基础信息 -->
    <a-card size="small" :bordered="false" class="outboundOrderDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="基础信息">
          <a-descriptions size="small" :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="联系手机">13709146191</a-descriptions-item>
            <a-descriptions-item label="联系电话">13709146191</a-descriptions-item>
            <a-descriptions-item label="备注">备注备注备注备注备注</a-descriptions-item>
            <a-descriptions-item label="销售单号">34242sdf234234</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="outboundOrderDetail-cont">
      <!-- alert -->
      <a-alert type="info" style="margin-bottom: 10px;">
        <div slot="message">
          总款数：<strong>12</strong>；总数量：<strong>12</strong>；总赠品数量：<strong>12</strong>；急件总款数：<strong>12</strong>；急件总数量：<strong>12</strong>；<br/>
          总售价：<strong>12</strong>；总成本：<strong>12</strong>；总毛利：<strong>12</strong>；折后总售价：<strong>12</strong>；折扣：<strong>12%</strong>；折扣金额：<strong>12</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="state" slot-scope="text, record">
          <a-tag :color="record.state==1?'green':'red'" >{{ record.state==1? '已出库': '未出库' }}</a-tag>
        </template>
      </s-table>
    </a-card>
  </div>
</template>

<script>
import { STable, VSelect } from '@/components'
export default {
  name: 'SalesDetail',
  components: {
    STable,
    VSelect
  },
  data () {
    return {
      disabled: false,
      pritKey: [
        { id: 0, name: '打印促销' },
        { id: 1, name: '打印支付方式' },
        { id: 2, name: '打印收款方式' }
      ],
      pritModal: [
        { id: 0, name: '普通模板一' },
        { id: 1, name: '普通模板二' },
        { id: 2, name: '仓库模板一' }
      ],
      // 表头
      columns: [
        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
        { title: '产品编码', dataIndex: 'salerNo', width: 140, align: 'center' },
        { title: '产品名称', dataIndex: 'storeNo', align: 'center' },
        { title: '原厂编码', dataIndex: 'custName', width: 140, align: 'center' },
        { title: '成本价', dataIndex: 'totalP', width: 100, align: 'center' },
        { title: '售价', dataIndex: 'totalNums', width: 100, align: 'center' },
        { title: '折后售价', dataIndex: 'totalPrice', width: 100, align: 'center' },
        { title: '销售数量', dataIndex: 'payType', width: 100, align: 'center' },
        { title: '单位', dataIndex: 'mementPay', width: 100, align: 'center' },
        { title: '辅助数量', dataIndex: 'shDate', width: 100, align: 'center' },
        { title: '售价小计', dataIndex: 'isJj', width: 100, align: 'center' },
        { title: '折后小计', dataIndex: 'status', width: 100, align: 'center' },
        { title: '仓库', dataIndex: 'status', width: 100, align: 'center' },
        { title: '仓位', dataIndex: 'status', width: 100, align: 'center' },
        { title: '销售类型', dataIndex: 'status', 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', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '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: {
    //  返回
    handleBack () {
      this.$router.push({ path: '/salesManagement/outboundOrder/list' })
    }
  }
}
</script>

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