<template>
  <div v-if="allow.includes('financeRechargeList')">
    <gridToolbar
			:query.sync="query"
			@refresh="refresh"
			:selectOptions="selectOptions"
			addAuthority="financeRechargeAdd"
			@add="add"/>
    <data-grid
			:api="request_api.finance_recharge"
			:query="requestQuery"
			ref="dataGrid"
			@change="handleChange">
      <!-- <a-table-column
				title="订单号"
				dataIndex="order_id"
				:filterIcon="filterSearchIcon"
				:filterDropdown="filterSearchDropdown" /> -->
			<a-table-column
				title="用户信息"
				align="left"
				dataIndex="real_name">
        <template slot-scope="text, record">
					<user-info
						:name="text"
						:user_id="record.login_id"
						:phone="record.phone"
						:email="record.email" />
        </template>
      </a-table-column>
			<a-table-column
				title="收款人信息"
				align="left"
				dataIndex="receiver_payee">
        <template slot-scope="text, record">
					<bank-info
						:payee="text"
						:code="record.receiver_bank_info_code"
						:open_bank="record.receiver_open_bank_name"
						:account="record.receiver_account" />
        </template>
      </a-table-column>
      <a-table-column
				title="资产类型"
				dataIndex="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.property_coin_type] }}</span>
				</div>
      </a-table-column>
      <a-table-column
				title="充值业务"
				dataIndex="recharge_business"
				:filters="columnFilters(recharge_business_options)"
				:filterMultiple="false">
        <template slot-scope="text">{{ text | recharge_business }}</template>
      </a-table-column>
      <a-table-column
				title="充值方式"
				dataIndex="bank_type"
				:filters="columnFilters(bank_type_options)"
				:filterMultiple="false">
        <template slot-scope="text, record">
					<span>{{ text | bank_type }}</span>
					<a-tag
						class="ml_5"
						:color="['green', 'orange'][record.type - 1 >= 0 ? record.type - 1 : record.type]">{{ record.type | apply_type }}</a-tag>
				</template>
      </a-table-column>
      <a-table-column
				title="充值金额"
				dataIndex="amount"
				:sorter="true"
				:sortOrder="sortedInfo.columnKey === 'amount' && sortedInfo.order">
        <template slot-scope="text">{{ text }}</template>
      </a-table-column>
      <a-table-column
				title="支付信息"
				dataIndex="post_total_amount"
				:sorter="true"
				:sortOrder="sortedInfo.columnKey === 'post_total_amount' && sortedInfo.order">
        <template slot-scope="text, record">
					<div class="multi_line">
						<span>币种：{{ record.post_currency }}</span>
						<span>汇率：{{ record.post_rate }}</span>
						<span>总金额：{{ text }}</span>
					</div>
				</template>
      </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="status"
				:filters="columnFilters(review_status_options)"
				:filterMultiple="false">
        <template slot-scope="value">
					<a-tag :color="['red', 'green', 'orange'][value - 1] || 'pink'">{{ value | review_status }}</a-tag>
				</template>
      </a-table-column>
      <!-- <a-table-column title="备注" dataIndex="memo" class="memo" :customCell="cellTitle('memo')" /> -->
      <a-table-column title="操作">
				<div class="table-btn-group" slot-scope="text, record">
					<a-button @click="edit(record)" v-if="allow.includes('financeRechargeReview') && [3, 4].includes(record.status)">审核</a-button>
					<a-button @click="edit(record)" v-else type="primary">查看</a-button>
					<a-button
						@click="propertyDetail(record, record.property_detail_uuid)"
						:loading="record.p_d_loading"
						type="link"
						v-if="allow.includes('financePropertyDetail') && record.property_detail_uuid">资产明细</a-button>
				</div>
      </a-table-column>
    </data-grid>
  </div>
</template>
<script>
import DataGrid from '../../components/DataGrid'
import gridToolbar from '../../components/gridToolbar/default'
import userInfo from '../../components/info/user'
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, userInfo, bankInfo
	},
  data() {
    return {
      // 混入配置
      mixConofig: {
        editTitle: '审核',
        modalName: 'recharge',
        modalWidth: 1000
      }
    }
	},
	computed: {
		property_type_cas() {
			return store.state.property_type_cas || []
		},
		property_type_cas_obj() {
			return store.getters.property_type_cas_obj || []
		},
		selectOptions () {
			return [
				{ label: '模糊搜索', value: 'keyword', placeholder: '关键词' },
				{ label: '用户ID', value: 'login_id', placeholder: '请输入完整的用户ID' },
				{ label: '用户名', value: 'real_name', placeholder: '请输入完整的用户名' },
				{ label: '邮箱', value: 'email', placeholder: '请输入完整的邮箱号' },
				{ label: '手机', value: 'phone', placeholder: '请输入完整的手机号' }
			]
		}
	},
  activated() {
		if (!this.property_type_cas || !this.property_type_cas.length) store.dispatch('getPropertyType')
  },
	methods: {
		add(){
			this._fnModal.rechargeAdd({
				title: '添加充值订单',
				done: () => this.refresh()
			})
		}
	}
}
</script>
