fastlion-amis
Version:
一种MIS页面生成工具
150 lines (145 loc) • 3.86 kB
text/typescript
// 默认成员对象
import { CRUDProps, CRUDState } from "./types";
// 默认需求的属性列表
const defaultPropList = [
'headerBulkActions',
'footerBulkActions',
'itemActions',
'mode',
'orderField',
'syncLocation',
'toolbar',
'toolbarInline',
'messages',
'value',
'options',
'multiple',
'valueField',
'defaultParams',
'bodyClassName',
'perPageAvailable',
'pageField',
'perPageField',
'hideQuickSaveBtn',
'autoJumpToTopOnPagerChange',
'interval',
'api',
'affixHeader',
'columnsTogglable',
'placeholder',
'tableClassName',
'headerClassName',
'footerClassName',
// 'toolbarClassName',
'headerToolbar',
'footerToolbar',
'filterTogglable',
'filterDefaultVisible',
'autoGenerateFilter',
'syncResponse2Query',
'keepItemSelectionOnPageChange',
'labelTpl',
'labelField',
'loadDataOnce',
'loadDataOnceFetchOnFilter',
'source',
'header',
'columns',
'size',
'onChange',
'onInit',
'onSaved',
'onQuery',
'formStore',
'autoFillHeight',
'preSortAble',
'showIndex'
];
// 默认属性
const defaultProps = (isMobile: Boolean) => ({
toolbarInline: true,
headerToolbar: ['headerBulkActions'], // Aug
footerToolbar: [], // 初始化默认给空
primaryField: 'id',
syncLocation: true,
pageField: 'page',
currentSelectedRow: 0,
perPageField: 'perPage',
hideQuickSaveBtn: false,
autoJumpToTopOnPagerChange: true,
filterTogglable: false,
filterDefaultVisible: true,
loadDataOnce: false,
loadDataOnceFetchOnFilter: true,
autoFillHeight: true, // Aug 移动端让他自由滚动
infinteLoad: isMobile, // Aug 移动端默认启用滚动加载,
setBorder: true,
preSortAble: true,
tableLayout: 'horizontal',
showIndex: false
})
const defaulState = ({ name, initFetch, advancedMode, mode, useMobileUI }: CRUDProps, isMobile: Boolean): CRUDState => ({
printType: undefined,
flowModalVisible: false,
fingerModalVisible: false,
filterDrawerVisible: false,
showColumnsFilter: false,
mobileFilterShow: false,
hasFetch: false, // Jay 标记是否发送过请求
ModalProps: {
show: false,
onHide: null
},
currentSelectedRow: 0,
filterData: {},
flowModalProps: {},//流程数据传递下一层
defaultVisible: false,
selectTmpShow: false,
defaultList: [],
defaultTempKey: '',
defaultTempValue: 'defaultQuery',
advancedFilterVisible: (!initFetch && (advancedMode === 'popup-normal' || advancedMode === 'popup-condition')) ? true : false,
foldColumns: [], //折叠的操作列
filtercont: {}, //获取高级查询中的数据,上层获取不到储存到这里
filterOptions: {}, //只是文字写入,将上层数据导入到高级查询数据中
multipleDefault: '',
filtertpl: [], //高级查询展示在form中的内容
filterExist: false,//在移动端判断筛选按钮是否高亮判断基础查询是否有默认值,仅首次加载有效
filData: {},//body查询
transferSubmission: {}, //储存表单送签信息
tableRotate: false, //移动端表格横屏模式
offline: false, //是否离线
offlineColumns: [],
offlineData: [],
offlineFormShow: false,
currentRow: null,
position: { x: document.body.clientWidth / 2 - 135, y: document.body.clientHeight - 200 },
offlineLoading: false,
offlineTemplist: [],
offlineProgress: 0,
offlineStatus: false,
useMobileUI: useMobileUI && isMobile,
openModle: {
open: false,
width: '65rem',
openModleBody: null,
linkTitle: '',
bodydata: null
},
codeVisible: false,
codeValue: '',
advancedFilterAction: false,
formSwitch: false,
templateSwitch: false,
toolActionSwitch: false,
staticExportShow: false,
showFilterTimer: undefined,
staticExportRange: '0',
keepDataFormat: '0',
offlineMode: false
})
export {
defaultPropList,
defaultProps,
defaulState
}