<template>
  <div class="table-box">
    <LjVxeTable
      ref="VxeTableRef"
      row-key="billid"
      :columns="columns"
      :request-api="getData"
      :data-callback="dataCallback"
      :dwname="dwname"
      :table-props="tableProps"
      :table-events="tableEvents"
      :init-param="initParams"
      :auto-load-layout="false"
      pagination
    >
    </LjVxeTable>
  </div>
</template>

<script setup lang="ts" name="saleprice_invalidmtrllist">
import { ref, onMounted, provide } from "vue";
import { getInvalidMtrlList } from "@/api/modules/saleprice";
import { ColumnProps } from "@/components/LjVxeTable/interface";
import LjDrawer from "@/components/LjDrawer/index.vue";
import { useHooks } from "./hooks/index";
import LjDialog from "@/components/LjDialog/index.vue";
import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
import { useI18n } from "vue-i18n";
import { useAuthButtons } from "@/hooks/useAuthButtons";
import { cloneDeep } from "lodash-es";

const dwname = "web_invalid_mtrllist";
const mainData = ref({});
const tableProps = {
  height: "auto",
  editConfig: { trigger: "click", mode: "cell" }
  // rowClassName: rowClsNameFunc
  // exportConfig: {
  //   filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  // }
};

const { t } = useI18n();
const { VxeTableRef, LjDetailRef, columns } = useHooks(t);
const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);

const orderStatus = ref("");
const deptname = ref("");
const enumMap = ref(new Map());
const initParams = ref({});

// const orderDefaultAction = [
//   buttonDefault({
//     label: t("common.cancelText"),
//     icon: "iconchevron-left"
//   }),
//   buttonNew({
//     label: t("common.saveText"),
//     icon: "iconsave-01",
//     clickFunc: item => {
//       const save_data = orderStatus.value == "new" ? LjDetailRef.value?.infoParam : LjDetailRef.value?._mainData;

//       fSave({ dept: save_data }).then(() => {
//         LjDrawerRef.value.hide();
//       });
//     }
//   })
// ];
// const orderEditAction = [
//   buttonNew({
//     label: t("common.saveText"),
//     icon: "iconsave-01",
//     clickFunc: item => {
//       const save_data = orderStatus.value == "new" ? LjDetailRef.value?.infoParam : LjDetailRef.value?._mainData;

//       fSave({ dept: save_data }).then(() => {
//         LjDrawerRef.value.hide();
//       });
//     }
//   })
// ];

/*
 * @description 抽屉默认属性
 */
const drawerDefineProp = {
  draggable: true,
  overflow: true,
  width: "40%"
  // modalClass: "lj-file-dialog"
};

const getData = (params: any) => {
  return getInvalidMtrlList(params);
};

const dataCallback = (data: any) => {
  if (data.tableinfo?.columns) {
    data.tableinfo?.columns.map((item: any) => {
      if (item?.enum) {
        enumMap.value.set(item.field, item.enum);
      }
    });
  }
  return {
    list: data.datatable,
    tableinfo: data.tableinfo,
    total: data.totalcnt,
    pageNum: data.pageindex,
    pageSize: data.pagesize
  };
};

// const LjDrawerRef = ref();
// const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
//   // 弹窗
//   mainData.value = cloneDeep(row);
//   deptname.value = row.deptname;
//   orderStatus.value = "edit";
//   LjDrawerRef.value.show();
// };

// const handleOpenNewTable = () => {
//   mainData.value = {
//     deptid: 0
//   };
//   deptname.value = "";
//   orderStatus.value = "new";
//   LjDrawerRef.value.show();
// };

// 返回绑定的事件
const tableEvents = {
  // "cell-dblclick": handleDBlClickTable
  // "cell-click": handleClickTable
};
</script>
