1.1.1-2 • Published 2 years ago

@rick7/vhooks v1.1.1-2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

基于vue3.2+ts4+antv2,rick-hooks-in-jx

use

import { 
  useTable,
  UseTableOption,
  useTableSelection,
  UseTableSelectionProps,
  useModal,
  UseModalOption,
} from '@rick7/vhooks';

useTable

const {
 formState,
 hookState,
 pagination,
 getListData,
 changePage,
 handleDel,
 handleReset,
 handleSearch,
 clearIntervalFn,
} = useTable({
  getApi: (payload?: any) => Promise<any>; // 获取列表接口
  getPayload?: () => any; // 获取列表参数的函数
  delApi?: (payload?: any) => Promise<any>; // 删除接口
  mapItemFn?: (data: any) => void; // 对响应数据遍历中进行特殊处理数据
  keyOfTimestampToDate?: string[]; // 时间戳转换成日期的key;用数组是因为可能多个日期字段
  isNoPage?: boolean; // 是否不需要翻页
  definedPageSize?: number; // 定义PageSize
  noHttp?: boolean; // 初始化是否不http请求
  isManualNo?: boolean; // 是否手动加序号
  forPage?: string|undefined; // 用于判断是否有“查看”权限,有 才自动获取列表数据
  needModalConfirm?: boolean; // 用于判断删除是否要modal.confirm二次确认
  intervalDelay?: number|undefined; // 不为undefined时,说明要轮询
  initFormState?: Record<string, string>; // 搜索条件初始值
})

useTableSelection

const {
  selectionState, rowSelection, customRow
} = useTableSelection('id', { isRadio: true });

useModal

const { visible, changeVisible } = useModal({
  afterSubmitFn: () => getListData(true)
});