<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",
    method: "get",
  });
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 = [
    {
      device_code: "123",
      device_name: "设备名称",
      liyonglv: "设备利用率",
      xiaolv: "综合效率",
      shengcl: "安全有效生产率",
      pjgz: "平均故障间隔时间",
      pjbysj: "设备平均保养时间",
      wgzgzsj: "平均无故障工作时间(MTBF)",
      pjxfsj: "平均修复时间(MTTR)",
      pjsxsj: "平均失效时间(MTTF)",
    },
  ];
});

option.value = Object.assign(option.value, {
  selection: true,
  addBtn: false,
  menu: false,
  searchMenuSpan: 8,
  column: [
    {
      label: "设备编号",
      prop: "device_code",
      search: true,
    },
    {
      label: "设备名称",
      prop: "device_name",
      search: true,
    },
    {
      label: "设备利用率",
      prop: "liyonglv",
    },
    {
      label: "综合效率",
      prop: "xiaolv",
    },
    {
      label: "安全有效生产率",
      prop: "shengcl",
    },
    {
      label: "平均故障间隔时间",
      prop: "pjgz",
    },
    {
      label: "设备平均保养时间",
      prop: "pjbysj",
    },
    {
      label: "平均无故障工作时间(MTBF)",
      prop: "wgzgzsj",
    },
    {
      label: "平均修复时间(MTTR)",
      prop: "pjxfsj",
    },
    {
      label: "平均失效时间(MTTF)",
      prop: "pjsxsj",
    },
  ],
});
</script>
