<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"
    />

  </div>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance } from "vue";
import { useCrud } from "@/hooks/userCrud";

import {
  useCommonStoreHook,
  useDictionaryStore,
  useDictionaryStoreHook,
} from "@/store";
const { isShowTable, tableType } = toRefs(useCommonStoreHook());

const { dicts } = useDictionaryStore();

const test = () => {
  isShowTable.value = true;
  tableType.value = tableType.value == 1 ? 2 : 1;
};

const drawingDetail = ref(null);
const drawing = (row) => {
  drawingDetail.value = row;
  dialog.visible = true;
};
// 传入一个url，后面不带/
const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
    useCrud({
      src: "/api/v1/routeChange",
    });
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对象
const props = defineProps({
  targetRouteId: {
    type: String,
    required: true,
  },
});
onMounted(() => {
  // 设置表格列或者其他自定义的option
  search.value.targetRouteId = props.targetRouteId;
  dataList();
});

/**
 * 上传excel相关
 */
const uploadRef = ref(null);
const uploadFinished = () => {
  // 上传完成后的刷新操作
  page.currentPage = 1;
  dataList();
};

option.value = Object.assign(option.value, {
  searchEnter: true,
  addBtn: false,
  menu: false,
  column: [
    {
      label: "来源工艺路线编码",
      prop: "sourceRouteCode",
      width: 160,
      overHidden: true,
    },
    {
      label: "修改的工序名称",
      prop: "operationName",
      width: 140,
      overHidden: true,
    },
    {
      label: "修改前版本",
      prop: "sourceVersion",
    },
    {
      label: "修改后版本",
      prop: "targetVersion",
    },
    {
      label: "修改内容",
      prop: "difference",
    },
    {
      label: "修改人",
      prop: "creator",
    },
    {
      label: "修改时间",
      prop: "created",
    },
  ],
});
</script>
