<template>
  <div>
    <card-table ref="table" :modalData="dataList" :searchParams="queryParams" @pagination="getList"
                :loading="loading" :tableSearch="true" @columnSearch="handleQuery"
                @resetList="resetQuery">
      <CustomColumn #default="{index}" label="No." :min-width="50">
        {{ ($refs.table.searchParams.pageSize) * ($refs.table.searchParams.pageNum - 1) + (index + 1) }}
      </CustomColumn>
      <Column :label="$t('todo.auditFlow')" dict-type="audit_flow" prop="auditFlow" :min-width="120"
              :searchDict="dict['audit_flow']" :searchParams="queryParams" :showSearch="true" searchType="select">
      </Column>
      <Column :label="$t('todo.businessDesc')" dict-type="audit_flow" prop="businessDesc" :min-width="120"
              :searchParams="queryParams" :showSearch="true" searchType="input">
      </Column>
      <Column :label="$t('todo.auditStatus')" dict-type="audit_status" prop="status" :min-width="120"
              :searchDict="dict['audit_status'].filter(item => isAuditing(item.value))" :searchParams="queryParams" :showSearch="true" searchType="select">
      </Column>
      <Column :label="$t('common.createTime')" :width="250" prop="startTime"
              :searchParams="queryParams" :showSearch="true" searchType="dateRange" />
      <Column :label="$t('common.operate')" align="center" min-width="100" fixed="right"
              :showSearch="true" searchType="operate">
        <template #default="{ row }">
            <el-button icon="el-icon-view" size="mini" type="text"
                @click="todoPage({auditFlow: row.auditFlow, businessNo: row.businessDesc})">{{ $t('common.view') }}
            </el-button>
        </template>
      </Column>
    </card-table>
  </div>
</template>

<script>

import SearchForm from "../../../components/CustomElement/CustomForm/SearchForm.vue";
import CustomTable from "../../../components/CustomElement/CustomTable/CustomTable.vue";
import CustomButton from "../../../components/CustomElement/CustomButton.vue";
import CustomColumn from "../../../components/CustomElement/CustomTable/CustomColumn.vue";
import CustomDictColumn from "../../../components/CustomElement/CustomTable/CustomDictColumn.vue";
import CustomDictSelect from "../../../components/CustomElement/CustomForm/items/CustomDictSelect.vue";
import CustomDatePicker from "../../../components/CustomElement/CustomForm/items/CustomDatePicker.vue";
import { getTodoList } from "@/api/audit/flow.js";
import Column from "../../../components/element/table/Column.vue";
import {parseTime} from "../../../utils/ruoyi";
import {mapGetters} from "vuex";
import CardTable from "../../../components/element/table/CardTable.vue";

export default {
  name: "Todo",
  components: {
    CardTable,
    Column,
    CustomDatePicker, CustomDictSelect, CustomDictColumn, CustomColumn, CustomButton, CustomTable, SearchForm
  },
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      readLoading: false,
      dataList: [],
      loading: false,
    };
  },
  computed: {
    ...mapGetters(["dict"]),
  },
  watch: {},
  methods: {
    parseTime,
    getList(param) {
      this.loading = true;
      getTodoList(param).then(response => {
        this.dataList = response.rows;
        this.queryParams.total = response.total;
        this.loading = false;
      });
    },
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      }
      this.handleQuery(this.queryParams);
    },
    handleQuery(param) {
      param.pageNum = 1;
      this.getList(param);
    },
  },
  mounted() {
    this.getList(this.queryParams);
  },


}


</script>

<style scoped>

</style>

