<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 dictDataUtil from "@/common/configs/dictDataUtil";
import ButtonPermKeys from "@/common/configs/buttonPermission";
import { useCommonStoreHook, useDictionaryStore } from "@/store";
import SingleUpload from "@/components/Upload/SingleUpload.vue";

// 数据字典相关
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, {
  searchEnter: true,
  selection: false,
  addBtn: false,
  delBtn: false,
  editBtn: false,
  viewBtn: true,
  column: [
    {
      label: "批次号",
      prop: "batchNo",
      formatter: (val) => {
        if (val.batchNo == "0") {
          return '';
        }else{
          return val.batchNo;
        }
      },
    },
    {
      label: "原批次号",
      prop: "oldBatchNo",
      formatter: (val) => {
        if (val.odlBatchNo == "0") {
          return '';
        }else{
          return val.oldBatchNo;
        }
      },
    },
    {
      label: "物料名称",
      prop: "itemName",
      search: true,
    },
    {
      label: "物料编码",
      prop: "itemCode",
      search: true,
    },
    {
      label: "物料型号",
      prop: "itemModel",
      search: true,
    },

   /* {
      label: "物料序列号",
      prop: "itemSeq",
    },
    {
      label: "旧序列号",
      prop: "oldSeq",
      hide: true,
    },*/
    {
      label: "工序id",
      prop: "operationId",
      hide: true,
    },
    {
      label: "工序名称",
      prop: "operationName",
      search: true,
    },
    {
      label: "生产过程id",
      prop: "processId",
      hide: true,
    },
    {
      label: "工作台名称",
      prop: "stationName",
    },
    {
      label: "步骤id",
      prop: "stepInstanceId",
      hide: true,
    },
    {
      label: "录入数量",
      prop: "num",
    },
    /*{
      label: "排序号",
      prop: "sortNum",
    },*/
    {
      label: "采集人",
      prop: "trackBy",
      hide: true,
    },
    {
      label: "追溯类型",
      prop: "trackType",
      hide: true,
    },
    {
      label: "采集时间",
      prop: "trackWhen",
    },
    {
      label: "工单号",
      prop: "workOrderCode",
    },
    {
      label: "修改时间",
      prop: "updated",
    },
  ],
});
</script>
