<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"
    >
    </avue-crud>
  </div>
</template>
<script setup>
import { ref, getCurrentInstance } from "vue";
import { useCrud } from "@/hooks/userCrud";
import ButtonPermKeys from "@/common/configs/buttonPermission";

import { useCommonStoreHook } from "@/store";
import dictDataUtil from "@/common/configs/dictDataUtil";
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/wms/task",
  });
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对象
// 设置表格列或者其他自定义的option
option.value = Object.assign(option.value, {
  delBtn: false,
  selection: false,
  viewBtn: false,
  editBtn: false,
  menu: false,
  addBtn: false,
  column: [
    {
      label: "入库单号",
      prop: "taskNo",
      search: true,
      width:150,
      overHidden: true
    },
    {
      label: "计划单号",
      prop: "planNo",
      search: true,
    },
    {
      label: "物料编号",
      width: 130,
      overHidden: true,
      prop: "materialNo",
    },
    {
      label: "物料名称",
      width:150,
      overHidden: true,
      prop: "materialName",
    },
    {
      label: "批次号",
      prop: "batchCode",
      width:150,
      overHidden: true
    },
    {
      label: "入库总数量",
      prop: "num",
    },
    {
      label: "已入库数量",
      prop: "completedNum",
    },
    {
      label: "待入库数量",
      prop: "unDoNum",
    },
    {
      label: "单位",
      prop: "unit",
    },
    {
      label: "入库仓库",
      prop: "houseType",
      type: "select",
      search: true,
      dicUrl:
          dictDataUtil.request_url +
          dictDataUtil.TYPE_CODE.warehouse_type,
      props: {
        label: "dictLabel",
        value: "dictValue",
      }
    },
    {
      label: "状态",
      prop: "state",
      type: "select",
      search: true,
      dicUrl:
          dictDataUtil.request_url +
          dictDataUtil.TYPE_CODE.warehouse_task_state,
      props: {
        label: "dictLabel",
        value: "dictValue",
      }
    },
  ],
});

onMounted(() => {
  // console.log("crudRef", crudRef)
  search.value.type = '1'
  dataList();
});
</script>
