<template>
  <div class="mainContentBox">
    <avue-crud
      ref="crudRef"
      v-model:search="search"
      v-model="form"
      :data="data"
      :option="option"
      v-model:page="page"
      @row-save="createRow"
      @row-update="updateRow"
      @row-del="deleteRow"
      @search-change="searchChange"
      @search-reset="resetChange"
      @size-change="dataList"
      @current-change="dataList"
      @selection-change="selectionChange"
    >
      <template #menu-right="{}">
        <el-button
          class="ml-3"
          @click="exportData('/api/v1/plan/order/export')"
        >
          <template #icon> <i-ep-download /> </template>导出
        </el-button>
      </template>
    </avue-crud>
  </div>
</template>
<script setup>
import { ref, getCurrentInstance } from "vue";
import { useCrud } from "@/hooks/userCrud";
import dictDataUtil from "@/common/configs/dictDataUtil";
import ButtonPermKeys from "@/common/configs/buttonPermission";
import { useCommonStoreHook, useDictionaryStore } from "@/store";

// 数据字典相关
const { dicts } = useDictionaryStore();

// 传入一个url，后面不带/
const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  useCrud({
    src: "/api/v1/op/baseOperation",
  });
const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  Methords; //增删改查
const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
// checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
// const permission = reactive({
//   delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
//   addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
//   editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
//   menu: true,
// });

const crudRef = ref(null); //crudRef.value 获取avue-crud对象

onMounted(() => {
  // dataList();
  data.value = [
    {
      time: "2022-01-01 10:00:00",
      dian: "123",
      temperature: "23.4",
      humidity: "56.7",
    },
    {
      time: "2022-01-01 11:00:00",
      dian: "456",
      temperature: "24.5",
      humidity: "57.8",
    },
  ];
});

option.value = Object.assign(option.value, {
  selection: true,
  addBtn: false,
  menu: false,
  column: [
    {
      label: "时间",
      prop: "time",
    },
    {
      label: "防静电监控",
      prop: "dian",
    },
    {
      label: "温度",
      prop: "temperature",
    },
    {
      label: "湿度",
      prop: "humidity",
    },
  ],
});
</script>
