<template>
  <div id="card-1">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" style="margin: 0 0 10px 0">
          <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
        </el-col>
        <el-col :span="24" class="four">
          <data-table :fields="fields" @query="search" :data="list" :total="total"> </data-table>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const _ = require('lodash');
const moment = require('moment');
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('shopCashOut');
const { mapActions: dictData } = createNamespacedHelpers('dictData');
export default {
  name: 'card-1',
  props: {},
  components: {},
  data: function () {
    const that = this;
    return {
      list: [],
      total: 0,
      fields: [
        { label: '申请店铺', model: 'shop.name' },
        { label: '提现金额', model: 'money' },
        { label: '银行卡号', model: 'card', showTip: false },
        { label: '银行卡所属', model: 'card_name' },
        { label: '所属银行', model: 'card_bank' },
        { label: '申请时间', model: 'apply_time' },
        {
          label: '审核状态',
          model: 'status',
          format: (i) => {
            let data = this.statusList.find((f) => f.value == i);
            if (data) return data.label;
            else return '暂无';
          },
        },
        { label: '审核处理人', model: 'deal_person.name' },
        { label: '审核时间', model: 'exam_time' },
      ],
      statusList: [],
    };
  },
  async created() {
    await this.search();
    await this.searchOther();
  },
  methods: {
    ...dictData({ dictQuery: 'query' }),
    ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
    // 查询
    async search({ skip = 0, limit = this.$limit, ...info } = {}) {
      let condition = _.cloneDeep(this.searchForm);
      info.shop = this.user.shop._id;
      let res = await this.query({ skip, limit, ...condition, ...info });
      if (this.$checkRes(res)) {
        this.$set(this, 'list', res.data);
        this.$set(this, 'total', res.total);
      }
    },
    // 返回
    toBack() {
      this.$emit('toBack');
    },
    // 查询其他信息
    async searchOther() {
      let res;
      // 提现审核状态
      res = await this.dictQuery({ code: 'withdrawal_exam_status' });
      if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.one {
  margin: 0 0 10px 0;
}
.two {
  margin: 0 0 10px 0;
}
</style>
