<!-- 报故记录 -->
<template>
  <div class="mainContentBox">
    <avue-crud
      ref="crudRef2"
      v-model:search="search"
      v-model="form"
      :data="data"
      @size-change="dataList"
      @search-reset="resetChange"
      @current-change="dataList"
      :option="option"
      v-model:page="page"
    >
      <template #menu="{ row, index, type }">
        <el-button
          @click="openDialog(row)"
          icon="el-icon-link"
          text
          type="primary"
          >查看</el-button
        >
      </template>
    </avue-crud>
    <el-dialog
      v-model="dialog.visible"
      :title="dialog.title"
      width="60%"
      @close="dialog.visible = false"
      ><el-image :src="url" fit="contain" />
    </el-dialog>
  </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();
const dialog = reactive({
  title: "图片预览",
  visible: false,
});
const url = ref(null);
// 传入一个url，后面不带/
const {
  form,
  data,
  option,
  search,
  page,
  toDeleteIds,
  Methords,
  Utils,
  commonConfig,
} = useCrud({
  src: "/api/v1/process/media",
});
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 openDialog = (row) => {
  dialog.visible = true;
  url.value = import.meta.env.VITE_APP_UPLOAD_URL + row.filePath;
};
const refreshTra = (row) => {
  commonConfig.value.params = {
    seqNo: row.seqNo,
    workOrderCode: row.workOrderCode,
  };
  dataList();
};
defineExpose({ refreshTra });
onMounted(() => {});

option.value = Object.assign(option.value, {
  selection: false,
  border: true,
  index: false,
  expandLevel: 3,
  headerAlign: "center",
  align: "center",
  labelWidth: 100,
  addBtn: false,
  menu: true,
  editBtn: false,
  delBtn: false,
  viewBtn: false,
  header: false,
  column: [
    {
      label: "上传工序",
      prop: "operationName",
      search: false,
    },
    {
      label: "上传人员",
      prop: "creator",
      type: "select",
      dicData: dicts.user_name_list,
      props: { label: "dictLabel", value: "dictValue" },
      search: false,
    },
    {
      label: "上传时间",
      prop: "created",
      search: false,
    },
  ],
});
</script>
