<template>
  <a-card
    title="币种管理"
    class="main-card"
    v-authority="'financeCurrencyList'">
    <gridToolbar
			:query.sync="query"
			@refresh="refresh"
			@add="add"
			addAuthority="financeCurrencyAdd" />
    <data-grid
			:api="request_api.finance_currency"
			:query="requestQuery"
			ref="dataGrid"
			@change="handleChange">
      <!-- <a-table-column
				title="所属平台"
				dataIndex="platform_code"
				:filters="columnFilters(platform_code_options)"
				:filterMultiple="false">
        <template slot-scope="text">{{ text | platform_code }}</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_online_limit_count"
				:sorter="true"
				:sortOrder="sortedInfo.columnKey === 'recharge_online_limit_count' && sortedInfo.order" />
      <a-table-column
				title="是否主币"
				dataIndex="is_main"
				:filters="columnFilters(whether_options)"
				:filterMultiple="false">
        <template slot-scope="text">{{ text | whether }}</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="memo" class="memo" :customCell="cellTitle('memo')" />
      <a-table-column title="操作" v-if="allow.includes('financeCurrencyEdit') || allow.includes('financeCurrencyDel')">
				<div class="table-btn-group" slot-scope="text, record">
					<a-button @click="edit(record)" v-authority="'financeCurrencyEdit'">编辑</a-button>
          <a-popconfirm
            title="是否确定删除?"
            v-authority="'financeCurrencyDel'"
            @confirm="del(record)">
            <a-button :loading="record.deleting" type="danger">删除</a-button>
          </a-popconfirm>
				</div>
      </a-table-column>
    </data-grid>
  </a-card>
</template>
<script>
import DataGrid from '../components/DataGrid'
import gridToolbar from '../components/gridToolbar/default'

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

import store from '../store'
export default {
	mixins: [common, mix, tableFilter],
	components: {
		DataGrid, gridToolbar
	},
  data() {
    return {
      // 混入配置
      mixConofig: {
        addTitle: '新增产品价格',
        editTitle: '编辑产品价格',
        apiName: 'finance_currency',
        modalName: 'financeCurrency',
        modalWidth: 600
      }
    }
	},
  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 || []
		}
  }
}
</script>
