<template>
  <div class="mainContentBox">
    <avue-crud
        ref="crudRef"
        v-model:search="search"
        v-model="form"
        :data="data"
        :option="option"
        v-model:page="page"
        @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({
    dataListUrl: "/api/v1/wms/check/resultList",
  });
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: "houseNo",
      type: "select",
      width:90,
      overHidden: true,
      search: true,
      dicUrl:
          dictDataUtil.request_url +
          dictDataUtil.TYPE_CODE.warehouse_type,
      props: {
        label: "dictLabel",
        value: "dictValue",
      },
    },
    {
      label: "仓库区域",
      prop: "houseArea",
      width:90,
      overHidden: true,
      search: true,
    },
    {
      label: "仓库位置",
      prop: "locationNo",
      width:90,
      overHidden: true,
    },
    {
      label: "物料编号",
      width: 130,
      overHidden: true,
      prop: "materialCode",
    },
    {
      label: "物料名称",
      width:150,
      overHidden: true,
      prop: "materialName",
    },
    {
      label: "盘点类型",
      prop: "type",
      type: 'select',
      dicData: [{label: '物料盘点',value: '1'},{label: '库位盘点',value: '2'},{label: '计划盘点',value: '3'},],
      search: true,
      width:150,
      overHidden: true
    },
    {
      label: "剩余数量",
      prop: "surplusNum",
    },
    {
      label: "实际数量",
      prop: "actualNum",
      html: true,
      formatter: (val) => {
        return '<b class="el-tag el-tag--danger el-tag--light">'+val.actualNum+'</b>';
      },
    },
    {
      label: "盘点人员",
      prop: "checkUser",
    },
    {
      label: "盘点时间",
      prop: "checkTime",
    },
  ],
});

onMounted(() => {
  dataList();
});
</script>
