<template>
  <div class="goodsAllocationSet-page">
    <a-spin :spinning="spinning" tip="Loading...">
      <a-page-header :ghost="false" :backIcon="false" class="goodsAllocationSet-baseInfo" >
        <template slot="subTitle">
          <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
          <span style="margin: 0 15px;color: #666;">货架名称：{{ '西安车领主常青二路数字货架' }}</span>
        </template>
      </a-page-header>
      <a-card :bordered="false" size="small" class="goodsAllocationSet-baseInfo">
        <div ref="tableSearch" class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
            <a-row :gutter="15">
              <a-col :xl="6" :lg="6" :md="12" :sm="24">
                <a-form-item label="结算时间">
                  <a-range-picker v-model="time" :format="dateFormat" allowClear :disabledDate="disabledDate" format="YYYY-MM-DD"/>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="6" :md="12" :sm="24">
                <a-form-item label="支付方式">
                  <v-select code="ENABLE_FLAG" v-model="form.isEnable" allowClear placeholder="请选择支付方式"></v-select>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="6" :md="6" :sm="6" >
                <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="outboundOrderList-refresh" >查询</a-button>
                <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <a-alert type="info" style="margin:10px 0">
          <div slot="message" >
            结算资金可通过账户管理-提现管理功能提出至银行卡
          </div>
        </a-alert>
        <s-table
          class="sTable fixPagination"
          ref="table"
          size="small"
          rowKey="id"
          :showPagination="false"
          :columns="columns"
          :data="loadData"
          :defaultLoadData="false"
          bordered>
          <template slot="action" slot-scope="text, record">
            <a-button
              size="small"
              type="link"
              class="button-primary"
              @click="handleDetail(record)"
              id="shelfMonitoringList-warehousing-btn">查看详情</a-button>
          </template>
        </s-table>
      </a-card>
      <!-- 导入货位模板 -->
      <detailModal :openModal="openModal" @close="openModal=false"></detailModal>
    </a-spin>
  </div>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import { STable, VSelect } from '@/components'
import { getPowerUserList } from '@/api/power-user.js'
import detailModal from './detailModal.vue'
export default {
  components: { STable, VSelect, detailModal, commonMixin },
  data () {
    return {
      spinning: false,
      disabled: false,
      isEdit: false, // 货位号是否为编辑
      openModal: false, // 货位模板弹窗初始状态
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 16 }
      },
      time: [],
      form: {
        isEnable: '',
        name: '',
        phone: '',
        loginName: '',
        sex: undefined,
        loginFlag: '', // 状态
        roleNames: undefined, // 角色
        productMsg: '', // 图片
        remarks: ''
      },
      // 表头
      columns: [
        { title: '序号', dataIndex: 'no', width: '12.5%', align: 'center' },
        { title: '结算时间', dataIndex: 'name', width: '25%', align: 'center', scopedSlots: { customRender: 'name' } },
        { title: '结算金额', dataIndex: 'createDate', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '支付方式', dataIndex: '', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '操作', width: '12.5%', align: 'center', scopedSlots: { customRender: 'action' } }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.spinning = true
        return getPowerUserList(Object.assign(parameter)).then(res => {
          let data
          if (res.status == 200) {
            data = res.data
            const no = (data.pageNo - 1) * data.pageSize
            for (let i = 0; i < data.list.length; i++) {
              const _item = data.list[i]
              _item.no = no + i + 1
              _item.loginFlag = _item.loginFlag + '' === '1'
            }
          }
          this.spinning = false
          return data
        })
      }
    }
  },
  mounted () {
    this.$refs.table.refresh()
  },
  methods: {
    handleBack () {
      this.$router.go(-1)
    },
    // 重置
    resetSearchForm () {},
    // 查看详情
    handleDetail (row) {
      this.openModal = true
    }
  }
}
</script>

<style lang="less">
  .goodsAllocationSet-page{
    position: relative;
    height: 100%;
    padding-bottom: 51px;
    box-sizing: border-box;
    .goodsAllocationSet-baseInfo{
      margin-bottom: 10px;
    }
    .bzj-collapse{
      margin-top: 10px;
      .ant-collapse-content-box{
        padding: 10px !important;
      }
    }

  }
</style>
