index.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. import { VxeUI } from '@vxe-ui/core'
  2. import { getFuncText } from './src/utils'
  3. import type { VxeUploadDefines, VxePrintDefines, VxeGlobalConfig } from 'vxe-pc-ui'
  4. export const version = process.env.VUE_APP_VXE_VERSION as string
  5. VxeUI.version = version
  6. VxeUI.tableVersion = version
  7. VxeUI.setConfig({
  8. emptyCell: ' ',
  9. table: {
  10. fit: true,
  11. showHeader: true,
  12. animat: true,
  13. delayHover: 250,
  14. autoResize: true,
  15. padding: true,
  16. minHeight: 144,
  17. // keepSource: false,
  18. // showOverflow: null,
  19. // showHeaderOverflow: null,
  20. // showFooterOverflow: null,
  21. // resizeInterval: 500,
  22. // size: null,
  23. // zIndex: null,
  24. // stripe: false,
  25. // border: false,
  26. // round: false,
  27. // emptyText: '暂无数据',
  28. // emptyRender: {
  29. // name: ''
  30. // },
  31. // rowConfig: {
  32. // keyField: '_X_ROW_KEY' // 行数据的唯一主键字段名
  33. // },
  34. resizeConfig: {
  35. // refreshDelay: 20
  36. },
  37. resizableConfig: {
  38. dragMode: 'auto',
  39. showDragTip: true,
  40. isSyncAutoHeight: true,
  41. isSyncAutoWidth: true,
  42. minHeight: 18
  43. },
  44. radioConfig: {
  45. // trigger: 'default'
  46. strict: true
  47. },
  48. rowDragConfig: {
  49. showIcon: true,
  50. animation: true,
  51. showGuidesStatus: true,
  52. showDragTip: true
  53. },
  54. columnDragConfig: {
  55. showIcon: true,
  56. animation: true,
  57. showGuidesStatus: true,
  58. showDragTip: true
  59. },
  60. checkboxConfig: {
  61. // trigger: 'default',
  62. strict: true
  63. },
  64. tooltipConfig: {
  65. enterable: true
  66. },
  67. headerTooltipConfig: {
  68. enterable: true
  69. },
  70. footerTooltipConfig: {
  71. enterable: true
  72. },
  73. validConfig: {
  74. showMessage: true,
  75. autoClear: true,
  76. autoPos: true,
  77. message: 'inline',
  78. msgMode: 'single',
  79. theme: 'beautify'
  80. },
  81. columnConfig: {
  82. autoOptions: {
  83. isCalcHeader: true,
  84. isCalcBody: true,
  85. isCalcFooter: true
  86. },
  87. maxFixedSize: 4
  88. },
  89. cellConfig: {
  90. padding: true
  91. },
  92. headerCellConfig: {
  93. height: 'unset'
  94. },
  95. footerCellConfig: {
  96. height: 'unset'
  97. },
  98. menuConfig: {
  99. // visibleMethod () {},
  100. // transfer: false,
  101. destroyOnClose: true
  102. },
  103. customConfig: {
  104. // enabled: false,
  105. allowVisible: true,
  106. allowResizable: true,
  107. allowFixed: true,
  108. allowSort: true,
  109. showFooter: true,
  110. placement: 'top-right',
  111. // storage: false,
  112. storeOptions: {
  113. visible: true,
  114. resizable: true,
  115. sort: true,
  116. fixed: true
  117. // rowGroup: false,
  118. // aggFunc: false
  119. },
  120. // autoAggGroupValues: false,
  121. // checkMethod () {},
  122. modalOptions: {
  123. showMaximize: true,
  124. mask: true,
  125. lockView: true,
  126. resize: true,
  127. escClosable: true
  128. },
  129. drawerOptions: {
  130. mask: true,
  131. lockView: true,
  132. escClosable: true,
  133. resize: true
  134. }
  135. },
  136. sortConfig: {
  137. // remote: false,
  138. // trigger: 'default',
  139. // orders: ['asc', 'desc', null],
  140. // sortMethod: null,
  141. showIcon: true,
  142. allowClear: true,
  143. allowBtn: true,
  144. iconLayout: 'vertical'
  145. },
  146. filterConfig: {
  147. // remote: false,
  148. // filterMethod: null,
  149. // isEvery: false,
  150. // transfer: false,
  151. destroyOnClose: true,
  152. multiple: true,
  153. showIcon: true
  154. },
  155. floatingFilterConfig: {
  156. // enabled: false
  157. },
  158. aggregateConfig: {
  159. padding: true,
  160. rowField: 'id',
  161. parentField: '_X_ROW_PARENT_KEY',
  162. childrenField: '_X_ROW_CHILDREN',
  163. mapChildrenField: '_X_ROW_CHILD_LIST',
  164. indent: 20,
  165. showIcon: true,
  166. maxGroupSize: 4,
  167. showAggFuncTitle: true
  168. },
  169. treeConfig: {
  170. padding: true,
  171. rowField: 'id',
  172. parentField: 'parentId',
  173. childrenField: 'children',
  174. hasChildField: 'hasChild',
  175. mapChildrenField: '_X_ROW_CHILD',
  176. indent: 20,
  177. showIcon: true
  178. },
  179. expandConfig: {
  180. // trigger: 'default',
  181. showIcon: true,
  182. mode: 'fixed'
  183. },
  184. editConfig: {
  185. // mode: 'cell',
  186. showIcon: true,
  187. showAsterisk: true,
  188. autoFocus: true
  189. },
  190. importConfig: {
  191. _typeMaps: {
  192. csv: 1,
  193. html: 1,
  194. xml: 1,
  195. txt: 1
  196. }
  197. },
  198. exportConfig: {
  199. _typeMaps: {
  200. csv: 1,
  201. html: 1,
  202. xml: 1,
  203. txt: 1
  204. }
  205. },
  206. printConfig: {
  207. },
  208. mouseConfig: {
  209. extension: true
  210. },
  211. keyboardConfig: {
  212. isAll: true,
  213. isEsc: true
  214. },
  215. areaConfig: {
  216. autoClear: true,
  217. selectCellByHeader: true,
  218. selectCellByBody: true,
  219. extendDirection: {
  220. top: true,
  221. left: true,
  222. bottom: true,
  223. right: true
  224. }
  225. },
  226. clipConfig: {
  227. isCopy: true,
  228. isCut: true,
  229. isPaste: true
  230. },
  231. fnrConfig: {
  232. isFind: true,
  233. isReplace: true
  234. },
  235. virtualXConfig: {
  236. // enabled: false,
  237. gt: 24,
  238. preSize: 0,
  239. oSize: 0
  240. },
  241. virtualYConfig: {
  242. // enabled: false,
  243. // mode: 'wheel',
  244. gt: 100,
  245. preSize: 1,
  246. oSize: 0
  247. },
  248. scrollbarConfig: {
  249. // width: 14,
  250. // height: 14,
  251. x: {
  252. // position: 'bottom',
  253. visible: true
  254. },
  255. y: {
  256. // position: 'right',
  257. visible: true
  258. }
  259. }
  260. },
  261. grid: {
  262. // size: null,
  263. // zoomConfig: {
  264. // escRestore: true
  265. // },
  266. formConfig: {
  267. enabled: true
  268. },
  269. pagerConfig: {
  270. enabled: true
  271. // perfect: false
  272. },
  273. toolbarConfig: {
  274. enabled: true
  275. // perfect: false
  276. },
  277. proxyConfig: {
  278. enabled: true,
  279. autoLoad: true,
  280. showLoading: true,
  281. showResponseMsg: true,
  282. showActionMsg: true,
  283. response: {
  284. list: null,
  285. result: 'result',
  286. total: 'page.total',
  287. message: 'message'
  288. }
  289. // beforeItem: null,
  290. // beforeColumn: null,
  291. // beforeQuery: null,
  292. // afterQuery: null,
  293. // beforeDelete: null,
  294. // afterDelete: null,
  295. // beforeSave: null,
  296. // afterSave: null
  297. }
  298. },
  299. toolbar: {
  300. // size: null,
  301. // import: {
  302. // mode: 'covering'
  303. // },
  304. // export: {
  305. // types: ['csv', 'html', 'xml', 'txt']
  306. // },
  307. // buttons: []
  308. },
  309. gantt: {}
  310. })
  311. const iconPrefix = 'vxe-table-icon-'
  312. VxeUI.setIcon({
  313. // table
  314. TABLE_SORT_ASC: iconPrefix + 'caret-up',
  315. TABLE_SORT_DESC: iconPrefix + 'caret-down',
  316. TABLE_FILTER_NONE: iconPrefix + 'funnel',
  317. TABLE_FILTER_MATCH: iconPrefix + 'funnel',
  318. TABLE_EDIT: iconPrefix + 'edit',
  319. TABLE_TITLE_PREFIX: iconPrefix + 'question-circle-fill',
  320. TABLE_TITLE_SUFFIX: iconPrefix + 'question-circle-fill',
  321. TABLE_TREE_LOADED: iconPrefix + 'spinner roll',
  322. TABLE_TREE_OPEN: iconPrefix + 'caret-right rotate90',
  323. TABLE_TREE_CLOSE: iconPrefix + 'caret-right',
  324. TABLE_EXPAND_LOADED: iconPrefix + 'spinner roll',
  325. TABLE_EXPAND_OPEN: iconPrefix + 'arrow-right rotate90',
  326. TABLE_EXPAND_CLOSE: iconPrefix + 'arrow-right',
  327. TABLE_CHECKBOX_CHECKED: iconPrefix + 'checkbox-checked-fill',
  328. TABLE_CHECKBOX_UNCHECKED: iconPrefix + 'checkbox-unchecked',
  329. TABLE_CHECKBOX_INDETERMINATE: iconPrefix + 'checkbox-indeterminate-fill',
  330. TABLE_CHECKBOX_DISABLED_UNCHECKED: iconPrefix + 'checkbox-unchecked-fill',
  331. TABLE_RADIO_CHECKED: iconPrefix + 'radio-checked-fill',
  332. TABLE_RADIO_UNCHECKED: iconPrefix + 'radio-unchecked',
  333. TABLE_RADIO_DISABLED_UNCHECKED: iconPrefix + 'radio-unchecked-fill',
  334. TABLE_CUSTOM_SORT: iconPrefix + 'drag-handle',
  335. TABLE_MENU_OPTIONS: iconPrefix + 'arrow-right',
  336. TABLE_DRAG_ROW: iconPrefix + 'drag-handle',
  337. TABLE_DRAG_COLUMN: iconPrefix + 'drag-handle',
  338. TABLE_DRAG_STATUS_ROW: iconPrefix + 'sort',
  339. TABLE_DRAG_STATUS_SUB_ROW: iconPrefix + 'add-sub',
  340. TABLE_DRAG_STATUS_AGG_GROUP: iconPrefix + 'grouping',
  341. TABLE_DRAG_STATUS_AGG_VALUES: iconPrefix + 'values',
  342. TABLE_DRAG_STATUS_COLUMN: iconPrefix + 'swap',
  343. TABLE_DRAG_DISABLED: iconPrefix + 'no-drop',
  344. TABLE_ROW_GROUP_OPEN: iconPrefix + 'arrow-right rotate90',
  345. TABLE_ROW_GROUP_CLOSE: iconPrefix + 'arrow-right',
  346. TABLE_AGGREGATE_GROUPING: iconPrefix + 'grouping',
  347. TABLE_AGGREGATE_VALUES: iconPrefix + 'values',
  348. TABLE_AGGREGATE_SORT: iconPrefix + 'drag-handle',
  349. TABLE_AGGREGATE_DELETE: iconPrefix + 'close',
  350. // toolbar
  351. TOOLBAR_TOOLS_REFRESH: iconPrefix + 'repeat',
  352. TOOLBAR_TOOLS_REFRESH_LOADING: iconPrefix + 'repeat roll',
  353. TOOLBAR_TOOLS_IMPORT: iconPrefix + 'upload',
  354. TOOLBAR_TOOLS_EXPORT: iconPrefix + 'download',
  355. TOOLBAR_TOOLS_PRINT: iconPrefix + 'print',
  356. TOOLBAR_TOOLS_FULLSCREEN: iconPrefix + 'fullscreen',
  357. TOOLBAR_TOOLS_MINIMIZE: iconPrefix + 'minimize',
  358. TOOLBAR_TOOLS_CUSTOM: iconPrefix + 'custom-column',
  359. TOOLBAR_TOOLS_FIXED_LEFT: iconPrefix + 'fixed-left',
  360. TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE: iconPrefix + 'fixed-left-fill',
  361. TOOLBAR_TOOLS_FIXED_RIGHT: iconPrefix + 'fixed-right',
  362. TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE: iconPrefix + 'fixed-right-fill'
  363. })
  364. export const setTheme = VxeUI.setTheme
  365. export const getTheme = VxeUI.getTheme
  366. export const setConfig = VxeUI.setConfig
  367. export const getConfig = VxeUI.getConfig
  368. export const setIcon = VxeUI.setIcon
  369. export const getIcon = VxeUI.getIcon
  370. export const setLanguage = VxeUI.setLanguage
  371. export const setI18n = VxeUI.setI18n
  372. export const getI18n = VxeUI.getI18n
  373. export const globalEvents = VxeUI.globalEvents
  374. export const globalResize = VxeUI.globalResize
  375. export const renderer = VxeUI.renderer
  376. export const validators = VxeUI.validators
  377. export const menus = VxeUI.menus
  378. export const formats = VxeUI.formats
  379. export const commands = VxeUI.commands
  380. export const interceptor = VxeUI.interceptor
  381. export const clipboard = VxeUI.clipboard
  382. export const log = VxeUI.log
  383. export const use = VxeUI.use
  384. /**
  385. * 已废弃
  386. * @deprecated
  387. */
  388. export const setup = (options?: VxeGlobalConfig) => {
  389. return VxeUI.setConfig(options)
  390. }
  391. VxeUI.setup = setup
  392. /**
  393. * 已废弃
  394. * @deprecated
  395. */
  396. export const config = (options?: VxeGlobalConfig) => {
  397. return VxeUI.setConfig(options)
  398. }
  399. VxeUI.config = config
  400. /**
  401. * 已废弃
  402. * @deprecated
  403. */
  404. export const t = (key: string, args?: any) => {
  405. return VxeUI.getI18n(key, args)
  406. }
  407. VxeUI.t = t
  408. /**
  409. * 已废弃
  410. * @deprecated
  411. */
  412. export const _t = (content: string | number | boolean | null | undefined, args?: any) => {
  413. return getFuncText(content, args)
  414. }
  415. VxeUI._t = _t
  416. /**
  417. * 已废弃,兼容老版本
  418. * @deprecated
  419. */
  420. export const VXETable = VxeUI
  421. /**
  422. * 已废弃,兼容老版本
  423. * @deprecated
  424. */
  425. export const saveFile: VxeUploadDefines.SaveFileFunction = (options) => {
  426. return VxeUI.saveFile(options)
  427. }
  428. /**
  429. * 已废弃,兼容老版本
  430. * @deprecated
  431. */
  432. export const readFile: VxeUploadDefines.ReadFileFunction = (options) => {
  433. return VxeUI.readFile(options)
  434. }
  435. /**
  436. * 已废弃,兼容老版本
  437. * @deprecated
  438. */
  439. export const print: VxePrintDefines.PrintFunction = (options) => {
  440. return VxeUI.print(options)
  441. }
  442. /**
  443. * 已废弃,兼容老版本
  444. * @deprecated
  445. */
  446. export const modal = {
  447. /**
  448. * 已废弃,兼容老版本
  449. * @deprecated
  450. */
  451. get (id: any) {
  452. return VxeUI.modal.get(id)
  453. },
  454. /**
  455. * 已废弃,兼容老版本
  456. * @deprecated
  457. */
  458. close (id: any) {
  459. return VxeUI.modal.close(id)
  460. },
  461. /**
  462. * 已废弃,兼容老版本
  463. * @deprecated
  464. */
  465. open (options: any) {
  466. return VxeUI.modal.open(options)
  467. },
  468. /**
  469. * 已废弃,兼容老版本
  470. * @deprecated
  471. */
  472. alert (content: any, title: any, options: any) {
  473. return VxeUI.modal.alert(content, title, options)
  474. },
  475. /**
  476. * 已废弃,兼容老版本
  477. * @deprecated
  478. */
  479. confirm (content: any, title: any, options: any) {
  480. return VxeUI.modal.confirm(content, title, options)
  481. },
  482. /**
  483. * 已废弃,兼容老版本
  484. * @deprecated
  485. */
  486. message (content: any, options: any) {
  487. return VxeUI.modal.message(content, options)
  488. },
  489. /**
  490. * 已废弃,兼容老版本
  491. * @deprecated
  492. */
  493. notification (content: any, title: any, options: any) {
  494. return VxeUI.modal.notification(content, title, options)
  495. }
  496. }
  497. export {
  498. VxeUI
  499. }
  500. export default VxeUI