<template>
  <a-card
    title="提现管理"
    class="main-card"
    v-authority="'financeWithdrawList'">
    <gridToolbar
			:query.sync="query"
			@refresh="refresh"
			:selectOptions="selectOptions"
			addAuthority="financeWithdrawAdd"
			@add="add"/>
    <data-grid
			:api="request_api.finance_withdraw"
			:query="requestQuery"
			ref="dataGrid"
			@change="handleChange">
			<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="payee">
        <template slot-scope="text, record">
					<bank-info
						:payee="text"
						:code="record.bank_info_code"
						:open_bank="record.open_bank_info"
						:account="record.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="amount"
				:sorter="true"
				:sortOrder="sortedInfo.columnKey === 'amount' && sortedInfo.order">
        <template slot-scope="text">{{ text | setZero }}</template>
      </a-table-column>
      <a-table-column
				title="客户端IP"
				dataIndex="client_ip"
				:filterIcon="filterSearchIcon"
				:filterDropdown="filterSearchDropdown" />
      <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', 'pink'][value - 1 >= 0 ? value - 1 : value]">{{ 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('financeWithdrawReview') && record.status === 3">审核</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>
  </a-card>
</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: 'withdraw',
        modalWidth: 900
      }
    }
	},
  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 || []
		},
		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: '请输入完整的手机号' }
			]
		}
	},
	methods: {
		add(){
			this._fnModal.withdrawAdd({
				title: '添加提现订单',
				done: () => this.refresh()
			})
		}
	}
}
</script>
