<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      v-model="form"
      v-model:page="page"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
        <template #title="{row}">
            <span @click="hanleView(row)" style="color:#284c89;cursor:pointer">{{row.title}}</span>
        </template>
        <template #status="{row}">
            <el-tag v-if="row.status === 1" type="success">审核通过</el-tag>
            <el-tag v-if="row.status === 2" type="danger">审核拒绝</el-tag>
        </template>
    </avue-crud>
  </basic-container>
</template>

<script>
import { getList} from '@/api/desk/completedTasks';
export default {
  data() {
    return {
      form: {},
      selectionList: [],
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        columnSort: true,
        tip: false,
        height: "auto",
        align: "center",
        calcHeight: 32,
        simplePage: false,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: false,
        viewBtn: false,
        delBtn: true,
        editBtn: true,
        editBtnText: "修改",
        editBtnIcon: " ",
        delBtnIcon: " ",
        addBtn: false,
        labelWidth: 120,
        searchLabelWidth: 120,
        menu: true,
        menuWidth: 200,
        dialogWidth: 600,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: true,
        gridBtn: false,
        searchShowBtn: false,
        showOverflowTooltip: true,
        searchLabelPosition: "left",
        searchLabelPosition: "left",
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: "left",
        gridBtn: false,
        searchMenuPosition: "right",
        addBtnIcon: " ",
        viewBtnIcon: " ",
        delBtnIcon: " ",
        editBtnIcon: " ",
        menu:false,

        column: [
          {
            label: '类型',
            prop: 'bizType',
            sortable: false,
            type: 'select',
            filter: true,
            span: 12,
            search: true,
            searchLabelWidth: 90,
            dicData: [
              { label: '外协审批', value: 1 },
              { label: '仓管审批', value: 2 },
              { label: '槽液审批', value: 3 },
            ],
          },
          {
            label: '标题',
            prop: 'content',
            sortable: false,
            filter: true,
            span: 12,
            search: true,
            searchLabelWidth: 90,
          },
          {
            label: '创建人',
            prop: 'createUserName',
            sortable: false,
            filter: true,
            span: 12,
            search: false,
            searchLabelWidth: 90,
          },
          {
            label: '申请时间',
            prop: 'createTime',
            type: 'date',
            searchRange: true,
            sortable: false,
            filter: true,
            span: 12,
            search: true,
            hide:true,
            searchLabelWidth: 90,
          },
          {
            label: '创建时间',
            prop: 'createTime',
            sortable: false,
            filter: true,
            span: 12,
            search: false,
            searchLabelWidth: 90,
          },
          {
            label: '状态',
            prop: 'status',
            sortable: false,
            type:"select",
            dicData: [
              {
                label: '审批通过',
                value: '1',
              },
              {
                label: '审批驳回',
                value: '2',
              },
            ],
            filter: true,
            span: 12,
            search: true,
            searchLabelWidth: 90,
          },
          {
            label: '审批时间',
            prop: 'approvalTime',
            sortable: false,
            filter: true,
            span: 12,
            search: false,
            searchLabelWidth: 90,
          },
        ],
      },
      data: [],
    };
  },
  methods: {
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
        console.log('搜索参数:', params);
        this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page);
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad();
    },
    onLoad(page, params = {}) {
    
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        console.log(res,'00000001');
        
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
       
      });
    },
  },
};
</script>

<style></style>
