<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>
import { useCrud } from "@/hooks/userCrud";
import { useCommonStoreHook, useDictionaryStore } from "@/store";

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

// 传入一个url，后面不带/
const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  useCrud({
    src: "/api/v1/process/itemRecord/itemInfo",
  });
const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  Methords; //增删改查
const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具

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

onMounted(() => {
  dataList();
});

// 设置表格列或者其他自定义的option
option.value = Object.assign(option.value, {
  selection: false,
  addBtn: false,
  delBtn: false,
  editBtn: false,
  viewBtn: true,
  column: [
    {
      label: "物料编码",
      prop: "itemCode",
      search: true,
    },
    {
      label: "物料型号",
      prop: "itemModel",
      search: true,
    },
    {
      label: "物料名称",
      prop: "itemName",
    },
    {
      label: "序列号",
      prop: "itemSeq",
    },
    {
      label: "序列号",
      prop: "itemSeq",
      hide: true,
      search: true,
    },
    {
      label: "采集工单",
      prop: "workOrderCode",
    },
    {
      label: "采集产品",
      prop: "seqNo",
    },
    {
      label: "工作台名称",
      prop: "stationName",
    },
    {
      label: "录入数量",
      prop: "num",
    },
    {
      label: "追溯类型",
      prop: "trackType",
      hide: true,
    },
    {
      label: "采集时间",
      prop: "trackWhen",
    },
    {
      label: "修改时间",
      prop: "updated",
    },
  ],
});
</script>
