<template>
  <div v-if="allow.includes('financeRechargeMethodList')">
    <gridToolbar
			:query.sync="query"
			@refresh="refresh"
			@add="add"
			addAuthority="financeRechargeMethodAdd" />
    <data-grid
			:api="request_api.finance_recharge_method"
			:query="requestQuery"
			ref="dataGrid"
			@change="handleChange">
      <a-table-column
				title="充值方式logo"
				dataIndex="rec_method_logo"
				:filterIcon="filterSearchIcon"
				:filterDropdown="filterSearchDropdown" />
      <a-table-column
				title="编码"
				dataIndex="rec_method_code"
				:filterIcon="filterSearchIcon"
				:filterDropdown="filterSearchDropdown" />
      <a-table-column
				title="充值方式名称"
				dataIndex="rec_method_name"
				:filterIcon="filterSearchIcon"
				:filterDropdown="filterSearchDropdown" />
			<a-table-column
				title="收款人信息"
				align="left"
				dataIndex="payee">
        <template slot-scope="text, record">
					<bank-info
						:payee="text"
						:code="record.bank_info_code"
						:open_bank="record.open_bank_name"
						:account="record.account" />
        </template>
      </a-table-column>
      <a-table-column
				title="默认接口币种"
				dataIndex="default_property_type">
				<div class="multi_line" slot-scope="text, record" v-if="property_type_cas_obj[text]">
					<span>{{ property_type_cas_obj[text].name }}</span>
					<span>{{ property_type_cas_obj[text][record.default_property_coin_type] }}</span>
				</div>
      </a-table-column>
      <a-table-column
				title="排序值"
				dataIndex="sequence"
				:sorter="true"
				:sortOrder="sortedInfo.columnKey === 'sequence' && sortedInfo.order" />
      <a-table-column
				title="充值类型"
				dataIndex="type"
				:filters="columnFilters(recharge_mode_options)"
				:filterMultiple="false">
        <template slot-scope="value">{{ value | recharge_mode }}</template>
      </a-table-column>
      <a-table-column
				title="状态"
				dataIndex="is_enable"
				:filters="columnFilters(enable_options)"
				:filterMultiple="false">
        <div slot-scope="value">
          <a-tag :color="['#f50', '#52c41a'][value]">{{ value | enable }}</a-tag>
        </div>
      </a-table-column>
      <a-table-column title="创建/更新时间" dataIndex="created_date">
        <template slot-scope="text, record">
					<div class="multi_line">
						<span>{{ text | moment }}</span>
						<span>{{ record.updated_date | moment }}</span>
					</div>
        </template>
      </a-table-column>
      <!-- <a-table-column title="备注" dataIndex="memo" class="memo" :customCell="cellTitle('memo')" /> -->
      <a-table-column title="操作" v-if="allow.includes('financeRechargeMethodEdit') ||
				allow.includes('financeRechargeMethodDel') ||
				allow.includes('financeRechargeMethodThirdParty') ||
				allow.includes('financeRechargeMethodCurrency')">
				<div class="table-btn-group" slot-scope="text, record">
					<a-button @click="dispatchCurrency(record)" v-authority="'financeRechargeMethodCurrency'">配置币种</a-button>
					<a-button @click="rechargeMethodThirdParty(record)" v-authority="'financeRechargeMethodThirdParty'">修改第三方</a-button>
					<a-button @click="edit(record)" v-authority="'financeRechargeMethodEdit'">编辑</a-button>
          <a-popconfirm
            title="是否确定删除?"
            v-authority="'financeRechargeMethodDel'"
            @confirm="del(record)">
            <a-button :loading="record.deleting" type="danger">删除</a-button>
          </a-popconfirm>
				</div>
      </a-table-column>
    </data-grid>
  </div>
</template>
<script>
import DataGrid from '../../components/DataGrid'
import gridToolbar from '../../components/gridToolbar/default'
import bankInfo from '../../components/info/bank'

import mix from '../../mixins/mixins'
import tableFilter from '../../mixins/tableFilter'
import finance from '../../mixins/finance'
import common from '../../mixins/common'

import store from '../../store'
export default {
	mixins: [common, mix, tableFilter, finance()],
	components: {
		DataGrid, gridToolbar, bankInfo
	},
  data() {
    return {
      // 混入配置
      mixConofig: {
        addTitle: '添加充值方式',
        editTitle: '编辑充值方式',
        apiName: 'finance_recharge_method',
        modalName: 'rechargeMethod',
        modalWidth: 1000
			}
    }
	},
  activated () {
		if (!this.property_type_cas || !this.property_type_cas.length) store.dispatch('getPropertyType')
  },
	computed: {
		property_type_cas() {
			return store.state.property_type_cas || []
		},
		property_type_cas_obj() {
			return store.getters.property_type_cas_obj || []
		}
	},
	methods: {
		rechargeMethodThirdParty(v) {
			this._fnModal.rechargeMethodThirdParty({
        title: '修改第三方',
        width: 520,
        data: v,
        done: () => this.refresh()
      })
		},
		dispatchCurrency(v) {
			this._fnModal.dispatchCurrency({
        title: '配置币种',
        width: 520,
        data: v,
        done: () => this.refresh()
      })
		}
	}
}
</script>
