<template>
  <div>
    <el-card>
      <el-form
        :model="searchForm"
        label-width="90px"
        @submit.prevent="fnResetPagination"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="报表时间" prop="YEAR">
              <el-date-picker
                v-model="searchForm.YEAR"
                type="year"
                placeholder="选择年"
                value-format="YYYY"
                format="YYYY"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPagination">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
        :data="list"
        @get-data="fnGetData"
        v-model:pagination="pagination"
      >
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="YEAR" label="报表时间" />
        <el-table-column prop="CREATTIME" label="报表生成时间" />
        <el-table-column prop="CREATOR_NAME" label="报表填写人" />
        <el-table-column prop="" label="操作" width="100">
          <template v-slot="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/dynamic_evaluation/risk_control_menu/view',
                  query: {
                    type: 'view',
                    REPORT_LOG_ID: row.REPORT_LOG_ID,
                  },
                })
              "
            >
              查看
            </el-button>
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/dynamic_evaluation/risk_control_menu/edit',
                  query: {
                    type: 'edit',
                    REPORT_LOG_ID: row.REPORT_LOG_ID,
                    YEAR: searchForm.YEAR,
                    currentPage: pagination.currentPage,
                    pageSize: pagination.pageSize,
                  },
                })
              "
            >
              编辑
            </el-button>
          </template>
        </el-table-column>
        <template #button>
          <el-button
            type="primary"
            @click="
              router.push({
                path: '/dynamic_evaluation/risk_control_menu/add',
                query: { type: 'add' },
              })
            "
          >
            新增
          </el-button>
        </template>
      </layout-table>
    </layout-card>
  </div>
</template>

<script setup>
import { serialNumber } from "@/assets/js/utils.js";
import useListData from "@/assets/js/useListData.js";
import { getRiskControlMenuList } from "@/request/dynamic_evaluation.js";
import dayjs from "dayjs";
import { useRouter } from "vue-router";

const router = useRouter();
const { list, searchForm, pagination, fnGetData, fnResetPagination } =
  useListData(getRiskControlMenuList, {
    defaultSearchForm: {
      YEAR: dayjs().format("YYYY"),
    },
    key: "list",
  });
</script>

<style scoped lang="scss"></style>
