<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model="form"
      v-model:page="page"
      v-model:search="query"
      ref="crud"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu-left> </template>
      <template #menu-right> </template>
    </avue-crud>
  </basic-container>
</template>

<script>
import { getList, add, remove, update } from '@/api/safetyManagement/safetyInspectionTask';

export default {
  data() {
    return {
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      loading:false,
      data: [],
      query: {
        taskStatus: "2" // 初始查询条件
      },
      option: {
        height: "auto",
        calcHeight: 32,
        tip: false,
        size: "default",
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: true,
        viewBtn: false,
        delBtn: false,
        editBtn: true,
        editBtnText: "修改",
        addBtnIcon: " ",
        viewBtnIcon: " ",
        delBtnIcon: " ",
        editBtnIcon: " ",
        labelWidth: 120,
        menuWidth: 150,
        dialogWidth: 600,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        columnSort: true,
        excelBtn: true,
        columnSort: true,
        index: false,
        showOverflowTooltip: true,
        menu: false,
        header: false,
        searchLabelPosition: "left",
        searchLabelPosition: "left",
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: "left",
        gridBtn: false,
        searchMenuPosition: "right",
        align: "center",
        column: [
          {
            label: "任务状态",
            prop: "taskStatus",
            sortable: true,
            filter: true,
            search: true,
            type: "select",
            value: "2",
            searchLabelWidth: 80,
            dicData: [
              {
                label: "已检",
                value: "1",
              },
              {
                label: "待检",
                value: "2",
              },
              {
                label: "未准时完成",
                value: "3",
              }

            ],
          },
          {
            label: "巡检点编号",
            prop: "insNum",
            sortable: true,
            filter: true,
            search: true,
            searchLabelWidth: 90,
          },
          {
            label: "巡检点位置",
            prop: "insSite",
            sortable: true,
            filter: true,
            search: true,
            searchLabelWidth: 90,
          },
          {
            label: "等待周期",
            prop: "waitCycle",
            sortable: true,
            filter: true,
            search: false,
            display: false,
          },
          {
            label: "巡检点备注",
            prop: "insMemo",
            sortable: true,
            filter: true,
            search: false,
            display: false,
            searchLabelWidth: 110,
          },
          {
            label: "发起时间",
            prop: "queryLaunchTime",        
            search: true,
            display: false,
            hide:true,
            type: 'datetime',
            format: 'YYYY-MM-DD HH:mm:ss',
            valueFormat: 'YYYY-MM-DD HH:mm:ss',
            searchRange: true,
          },
          {
            label: "发起时间",
            prop: "launchTime",
            sortable: true,
            filter: true,
            type: 'datetime',
            format: 'YYYY-MM-DD HH:mm:ss',
            valueFormat: 'YYYY-MM-DD HH:mm:ss',
            searchRange: true,
          },
          {
            label: "巡检人",
            prop: "insMan",
            sortable: true,
            filter: true,
            search: true,
          },
          {
            label: "检验时间",
            prop: "queryTestTime",
            sortable: true,
            filter: true,
            search: true,
            hide:true,
            type: "datetime",
            format: 'YYYY-MM-DD HH:mm:ss',
            valueFormat: 'YYYY-MM-DD HH:mm:ss',
            searchRange: true,
          },
          {
            label: "检验时间",
            prop: "testTime",
            sortable: true,
            filter: true,
            type: "datetime",
            format: 'YYYY-MM-DD HH:mm:ss',
            valueFormat: 'YYYY-MM-DD HH:mm:ss',
            // searchRange: true,
          },
       
          {
            label: "备注",
            prop: "memo",
            sortable: true,
            filter: true,
            search: false,
          },
        ],
      },
    };
  },
  methods: {
    // 加载页面数据
    onLoad(page, params = {}) {
      this.loading = true;
      console.log("params", params)
      console.log("this.query", this.query)
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
        (res) => {
          this.data = res.data.data.records;
          this.loading = false;
          this.page.total = res.data.data.total;
          // this.selectionClear();
        }
      );
    },
    //选择行
    selectionChange(list) {
      this.selectionList = list;
    },
    currentChange(val) {
      this.page.currentPage = val;
      this.onLoad(this.page);
    },
    // 搜索重置
    searchReset() {
      this.query = {}
      this.onLoad(this.page)
    },
    //刷新
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    //搜索
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params)
      done()

    }
  },
};
</script>

<style></style>
