<template>
  <!-- 定投计划查询 -->
  <div class="platinum_fixed_investment_plan_query">
    <Filter @search="updateColumn" />
    <contextMenu :contextMenuList="firstBtn">
      <a-table :columns="columns"
               class="srcollYTable"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :pagination="false"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               rowKey="key"
               :data-source="tableList">
        <template #userinfotype="{ record }">
          <a>{{ record.userinfotype === 1 ? '个人' : '企业'}}</a>
        </template>

        <template #regularlymode="{ record }">
          <a>{{ record.regularlymode === 1 ? '按数量' : '按金额'}}</a>
        </template>
        <template #regularlystrategystatus="{ record }">
          <a>{{ getRegularStateName(record.regularlystrategystatus)}}</a>
        </template>

          <template #regularlycycle="{ record }">
              <a>{{ record.regularlycycle === 1 ?  "每周" + getWeekName(record.regularlycyclevalue) : "每月" + record.regularlycyclevalue + "日"}}</a>
          </template>
      </a-table>
    </contextMenu>
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, queryTableList, contextMenu, BtnList, _getBtnList } from '@/common/export/table';
import { QhjRStrategy } from '@/services/go/ermcp/qhj/interface';
import Filter from './compoments/filter/index.vue';
import {getRegularStateName, getWeekName} from '@/common/constants/enumsName';
import { queryRStrategy } from '@/services/go/ermcp/qhj';

export default defineComponent({
    name: 'platinum_fixed_investment_plan_query',
    components: { Filter, contextMenu, BtnList },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick, btnClick } = getTableEvent<QhjRStrategy>({});
        // 表格操作按钮列表
        const [firstBtn] = _getBtnList('platinum_fixed_investment_plan_query', false).value;
        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList<QhjRStrategy>();
        initData(() => {
            // 获取列表数据
            queryTable(queryRStrategy);
            // 注册表头信息 过滤
            registerColumn('table_pcweb_qhj_fixed_investment_plan_query', ['goodsid', 'regularlystrategystatus', 'accountid', 'nexttriggerdate']);
        });

        return {
            columns,

            expandedRowKeys,
            selectedRow,
            Rowclick,
            firstBtn,
            loading,
            getRegularStateName,
            getWeekName,
            tableList,
            updateColumn,
            queryTable,
            btnClick,
        };
    },
});
</script>