<!-- 点检判定 -->
<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"
    >
      <template #menu="{ size, row, index }">
        <el-button
            v-if="
            row.checkName!=undefined && row.checkName!=null
          "
            type="primary"
            link
            size="small"
            @click="doEdit(row,index)"
        ><i-ep-edit />编辑
        </el-button>
      </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/checkRecordInfo",
});
const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  Methords; //增删改查
const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具

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

const refreshTra = (row) => {
  commonConfig.value.params = { seqNo: row.seqNo };
  dataList();
};
defineExpose({ refreshTra });
const userStore = useUserStoreHook();
onMounted(() => {
  if(userStore.user.userId===10000){
    option.value.menu=true;

  }
});
const doEdit = (row, index) => {
  crudRef2.value && crudRef2.value.rowEdit(row, index);
};
option.value = Object.assign(option.value, {
  selection: false,
  border: true,
  index: false,
  expandLevel: 3,
  headerAlign: "center",
  align: "center",
  labelWidth: 100,
  addBtn: false,
  menu: false,
  editBtn : false,
  viewBtn: false,
  delBtn: false,
  header: false,
  rowKey: "opId",
  column: [
    {
      label: "工序Id",
      prop: "opId",
      display: false,
      hide: true,
    },
    {
      label: "工序名称",
      prop: "opName",
      display: false,
    },
    {
      label: "点检项名称",
      prop: "checkName",
      search: false,
      disabled: true,
    },
    {
      label: "点检项编码",
      prop: "checkCode",
      search: false,
      disabled: true,
    },
    {
      label: "内容",
      prop: "content",
      search: false,
      disabled: true,
    },
    {
      label: "结果",
      prop: "result",
      type: "select",
      dicData: dicts.process_check_result,
      props: {
        label: "dictLabel",
        value: "dictValue",
      },
      search: false,
    },
    // {
    //   label: "操作人",
    //   prop: "operator",
    //   search: false,
    // },
    {
      label: "标准值",
      prop: "standard",
      search: false,
      disabled: true,
    },
    {
      label: "上限值",
      prop: "upper",
      search: false,
      disabled: true,
    },
    {
      label: "下限值",
      prop: "lower",
      search: false,
      disabled: true,
    },
    // {
    //   label: "实测值",
    //   prop: "realValue",
    //   search: false,
    // },
    // {
    //   label: "单位",
    //   prop: "unit",
    //   search: false,
    //   dicData: dicts.danwei_type,
    //   props: {
    //     label: "dictLabel",
    //     value: "dictValue",
    //   },
    // },
    {
      label: "录入时间",
      prop: "created",
      search: false,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      type: "datetime",
    },
  ],
});
</script>
