<!-- 工序文件 -->
<template>
  <div class="mainContentBox">
    <avue-crud
      ref="crudRef2"
      v-model:search="search"
      v-model="form"
      :data="data"
      :option="option"
      @row-update="updateRow"
      v-model:page="page"
      @size-change="dataList"
      @current-change="dataList"
    >
      <template #menu="{ size, row, index }">
        <a v-if="row.filePath" :href="row.filePath"
          ><el-button type="primary" text round size="small">下载</el-button>
        </a>
      </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,
  useUserStoreHook,
} from "@/store";

// 数据字典相关
const { dicts } = useDictionaryStore();
// 传入一个url，后面不带/
const {
  form,
  data,
  option,
  search,
  page,
  toDeleteIds,
  Methords,
  Utils,
  commonConfig,
} = useCrud({
  src: "/api/v1/process/web/traceability/testRecord",
});
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对象
const userStore = useUserStoreHook();
const refreshTra = (row) => {
  commonConfig.value.params = {
    seqNo: row.seqNo,
    workOrderCode: row.workOrderCode,
  };
  dataList();
};
defineExpose({ refreshTra });
option.value = Object.assign(option.value, {
  searchEnter: true,
  selection: false,
  border: true,
  index: false,
  expandLevel: 3,
  headerAlign: "center",
  align: "center",
  labelWidth: 100,
  addBtn: false,
  delBtn: false,
  viewBtn: false,
  editBtn: false,

  header: false,
  rowKey: "operationId",
  column: [
    {
      label: "工序Id",
      prop: "operationId",
      display: false,
      hide: true,
    },
    {
      label: "工序名称",
      prop: "operationName",
      display: false,
    },

    {
      label: "文件名称",
      prop: "fileName",
      display: false,
    },
    {
      label: "录入时间",
      prop: "created",
      format: "YYYY-MM-DD HH:mm:ss",
      valueFormat: "YYYY-MM-DD HH:mm:ss",
      type: "datetime",
      search: false,
      span: 24,
      rules: [
        {
          required: true,
          message: "请输入录入时间",
          trigger: "blur",
        },
      ],
    },
  ],
});
</script>
