import { ref, reactive, computed, toRefs } from "vue";
import { Table } from "@/hooks/interface";
import { ColumnProps } from "@/components/LjVxeTable/interface";
import { ALLOW_EDIT_STATE } from "@/config/index";

interface defaultState {
  /**
   * @description 单据当前状态
   */
  orderStatus: string;
}
/**
 * @description 表格多选数据操作
 * @param {String} rowKey 当表格可以多选时，所指定的 id
 * */
export const useHooks = (t?: any) => {
  const state = reactive<defaultState>({
    orderStatus: ""
  });

  // 表格配置项
  const columns: ColumnProps<any>[] = [
    { type: "seq", title: "#", fixed: "left", width: 80 },
    {
      field: "pricelistname",
      title: "价格表名称",
      align: "left",
      basicinfo: {
        el: "input",
        editable: ALLOW_EDIT_STATE
      }
    },
    {
      field: "dscrp",
      title: "备注",
      align: "left",
      width: 300,
      basicinfo: {
        el: "input",
        editable: ALLOW_EDIT_STATE,
        props: { type: "textarea", rows: 5 }
      }
    },
    {
      field: "createtime",
      title: "建立时间",
      basicinfo: {
        visible: false
      }
    },
    {
      field: "flag",
      title: "审核",
      datatype: "checkbox",
      basicinfo: {
        visible: false
      }
    },
    {
      field: "modemp",
      title: "修改人",
      basicinfo: {
        visible: false
      }
    },
    {
      field: "moddate",
      title: "修改时间",
      basicinfo: {
        visible: false
      }
    },
    {
      field: "auditemp",
      title: "审核人",
      basicinfo: {
        visible: false
      }
    },
    {
      field: "audidate",
      title: "审核时间",
      basicinfo: {
        visible: false
      }
    }
  ];

  return {
    ...toRefs(state),
    columns
  };
};
