<template>
  <div class="mainContentBox">
    <avue-crud
      ref="crudRef"
      v-model:search="search"
      v-model="form"
      :data="data"
      :option="option"
      v-model:page="page"
      @row-click="rowClick"
      @search-change="searchChange"
      @search-reset="resetChange"
      @size-change="dataList"
      @current-change="dataList"
      @row-update="updateRow"
    >
    </avue-crud>
  </div>
</template>
<script setup>
import { defineProps, ref } from "vue";
import { useCrud } from "@/hooks/userCrud";

import { useCommonStoreHook } from "@/store";
import dictDataUtil from "@/common/configs/dictDataUtil";
import { getShortageItem } from "@/api/order/index";
const { isShowTable, tableType } = toRefs(useCommonStoreHook());
const test = () => {
  isShowTable.value = true;
  tableType.value = tableType.value == 1 ? 2 : 1;
};
// 传入一个url，后面不带/
const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  useCrud({
    src: "/api/v1/planShortageItem",
  });
const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  Methords; //增删改查
const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
const { checkBtnPerm, downloadTemplate } = Utils; //按钮权限等工具

const crudRef = ref(null); //crudRef.value 获取avue-crud对象
const emit = defineEmits(["orderInfo"]);
const rowClick = (row) => {
  emit("orderInfo", row);
};
const dataTable = ref([]);
const props = defineProps({
  shortage: {
    type: Object,
    default: () => {
      return "0";
    },
  },
  dialog: {
    type: Object,
    default: () => {
      return "0";
    },
  },
});
const userList = ref([]);
import { getUserList } from "@/api/system/user";
const queryUserList = () => {
  getUserList({}).then((data) => {
    userList.value = data.data;
  });
};
onMounted(() => {
  search.value.shortageId = props.shortage.id;
  dataList();
});
// 设置表格列或者其他自定义的option
option.value = Object.assign(option.value, {
  selection: false,
  search: false,
  addBtn: false,
  viewBtn: false,
  menu: false,
  column: [
    {
      label: "物料编号",
      prop: "materialCode",
      search: true,
      overHidden: true,
      disabled: true,
    },
    {
      label: "物料名称",
      prop: "materialName",
      search: true,
      overHidden: true,
      disabled: true,
    },
    {
      label: "数量",
      prop: "materialNum",
      overHidden: true,
    },
    {
      label: "单位",
      prop: "unit",
      overHidden: true,
      disabled: true,
    },
    {
      label: "物料规格",
      prop: "materialModel",
      overHidden: true,
      disabled: true,
    },
  ],
});
</script>
