@smallwei/avue 3.8.2 → 3.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/README.md +206 -86
  2. package/dist/avue.js +37302 -0
  3. package/dist/avue.js.map +1 -0
  4. package/dist/avue.min.js +6 -0
  5. package/dist/avue.min.mjs +2 -0
  6. package/dist/avue.mjs +2 -0
  7. package/dist/index.css +1 -0
  8. package/es/avue.min.mjs +2 -0
  9. package/es/avue.min.ts +2 -0
  10. package/es/avue.mjs +2 -0
  11. package/es/avue.ts +2 -0
  12. package/es/core/create.mjs +8 -0
  13. package/es/core/create.ts +16 -0
  14. package/es/core/dataformat.mjs +184 -0
  15. package/es/core/dataformat.ts +190 -0
  16. package/es/core/detail.mjs +74 -0
  17. package/es/core/detail.ts +81 -0
  18. package/es/core/dic.mjs +213 -0
  19. package/es/core/dic.ts +235 -0
  20. package/es/core/locale.mjs +8 -0
  21. package/es/core/locale.ts +9 -0
  22. package/es/core/packages.mjs +61 -0
  23. package/es/core/packages.ts +62 -0
  24. package/es/core/slot.mjs +32 -0
  25. package/es/core/slot.ts +30 -0
  26. package/es/global/variable.mjs +80 -0
  27. package/es/global/variable.ts +84 -0
  28. package/es/icon.mjs +9 -0
  29. package/es/icon.ts +11 -0
  30. package/es/index.mjs +127 -0
  31. package/es/index.ts +177 -0
  32. package/es/locale/browser/en.mjs +288 -0
  33. package/es/locale/browser/zh-cn.mjs +288 -0
  34. package/es/locale/browser/zh.mjs +288 -0
  35. package/es/locale/index.mjs +141 -0
  36. package/es/locale/index.ts +196 -0
  37. package/es/locale/lang/en.mjs +282 -0
  38. package/es/locale/lang/en.ts +282 -0
  39. package/es/locale/lang/zh-cn.mjs +282 -0
  40. package/es/locale/lang/zh-cn.ts +282 -0
  41. package/es/locale/lang/zh.mjs +282 -0
  42. package/es/locale/lang/zh.ts +282 -0
  43. package/es/packages/core/common/event.mjs +58 -0
  44. package/es/packages/core/common/event.ts +56 -0
  45. package/es/packages/core/common/init.mjs +134 -0
  46. package/es/packages/core/common/init.ts +133 -0
  47. package/es/packages/core/common/props.mjs +239 -0
  48. package/es/packages/core/common/props.ts +240 -0
  49. package/es/packages/core/components/dialog-form/index.mjs +29 -0
  50. package/es/packages/core/components/dialog-form/index.ts +29 -0
  51. package/es/packages/core/components/dialog-form/index.vue +108 -0
  52. package/es/packages/core/components/form/custom.mjs +41 -0
  53. package/es/packages/core/components/form/custom.ts +41 -0
  54. package/es/packages/core/components/form/index.vue +176 -0
  55. package/es/packages/core/components/icon/index.vue +37 -0
  56. package/es/packages/core/components/image-preview/index.mjs +34 -0
  57. package/es/packages/core/components/image-preview/index.ts +37 -0
  58. package/es/packages/core/components/image-preview/index.vue +215 -0
  59. package/es/packages/core/directive/contextmenu.mjs +92 -0
  60. package/es/packages/core/directive/contextmenu.ts +103 -0
  61. package/es/packages/core/directive/permission.mjs +19 -0
  62. package/es/packages/core/directive/permission.ts +18 -0
  63. package/es/packages/data/box/index.vue +66 -0
  64. package/es/packages/data/card/index.vue +62 -0
  65. package/es/packages/data/cardText/index.vue +56 -0
  66. package/es/packages/data/countdown/index.vue +81 -0
  67. package/es/packages/data/dashboard/index.vue +72 -0
  68. package/es/packages/data/display/index.vue +63 -0
  69. package/es/packages/data/icons/index.vue +68 -0
  70. package/es/packages/data/imgText/index.vue +72 -0
  71. package/es/packages/data/list/index.vue +69 -0
  72. package/es/packages/data/notice/index.vue +63 -0
  73. package/es/packages/data/operaText/index.vue +62 -0
  74. package/es/packages/data/panel/index.vue +62 -0
  75. package/es/packages/data/pay/index.vue +92 -0
  76. package/es/packages/data/price/index.vue +55 -0
  77. package/es/packages/data/product/index.vue +106 -0
  78. package/es/packages/data/profile/index.vue +91 -0
  79. package/es/packages/data/progress/index.vue +64 -0
  80. package/es/packages/data/rank/index.vue +92 -0
  81. package/es/packages/data/rotate/index.vue +69 -0
  82. package/es/packages/data/statistic/index.vue +71 -0
  83. package/es/packages/data/tabs/index.vue +64 -0
  84. package/es/packages/data/task/index.vue +82 -0
  85. package/es/packages/data/weather/index.vue +103 -0
  86. package/es/packages/element-plus/array/index.vue +115 -0
  87. package/es/packages/element-plus/article/index.vue +73 -0
  88. package/es/packages/element-plus/card/index.vue +103 -0
  89. package/es/packages/element-plus/cascader/index.vue +132 -0
  90. package/es/packages/element-plus/chat/index.vue +513 -0
  91. package/es/packages/element-plus/checkbox/index.vue +84 -0
  92. package/es/packages/element-plus/comment/index.vue +76 -0
  93. package/es/packages/element-plus/count-up/index.vue +109 -0
  94. package/es/packages/element-plus/crud/column/column-default.vue +128 -0
  95. package/es/packages/element-plus/crud/column/column-dynamic.vue +86 -0
  96. package/es/packages/element-plus/crud/column/column-menu.vue +267 -0
  97. package/es/packages/element-plus/crud/column/column-slot.vue +348 -0
  98. package/es/packages/element-plus/crud/column/column.vue +119 -0
  99. package/es/packages/element-plus/crud/column/menu.vue +78 -0
  100. package/es/packages/element-plus/crud/config.mjs +74 -0
  101. package/es/packages/element-plus/crud/config.ts +74 -0
  102. package/es/packages/element-plus/crud/dialog/dialog-column.vue +102 -0
  103. package/es/packages/element-plus/crud/dialog/dialog-excel.vue +204 -0
  104. package/es/packages/element-plus/crud/dialog/dialog-filter.vue +159 -0
  105. package/es/packages/element-plus/crud/dialog/dialog-form.vue +352 -0
  106. package/es/packages/element-plus/crud/grid/index.vue +271 -0
  107. package/es/packages/element-plus/crud/grid/item.vue +39 -0
  108. package/es/packages/element-plus/crud/index.vue +1018 -0
  109. package/es/packages/element-plus/crud/menu/header-menu.vue +175 -0
  110. package/es/packages/element-plus/crud/menu/header-search.vue +228 -0
  111. package/es/packages/element-plus/crud/menu/table-page.vue +108 -0
  112. package/es/packages/element-plus/date/index.vue +81 -0
  113. package/es/packages/element-plus/draggable/index.vue +444 -0
  114. package/es/packages/element-plus/dynamic/index.vue +353 -0
  115. package/es/packages/element-plus/flow/index.vue +339 -0
  116. package/es/packages/element-plus/flow/node.vue +84 -0
  117. package/es/packages/element-plus/form/config.mjs +6 -0
  118. package/es/packages/element-plus/form/config.ts +6 -0
  119. package/es/packages/element-plus/form/index.vue +954 -0
  120. package/es/packages/element-plus/form/menu.vue +63 -0
  121. package/es/packages/element-plus/group/index.vue +90 -0
  122. package/es/packages/element-plus/input/index.vue +1264 -0
  123. package/es/packages/element-plus/input-color/index.vue +70 -0
  124. package/es/packages/element-plus/input-cron/index.vue +363 -0
  125. package/es/packages/element-plus/input-icon/index.vue +143 -0
  126. package/es/packages/element-plus/input-map/index.vue +311 -0
  127. package/es/packages/element-plus/input-number/index.vue +91 -0
  128. package/es/packages/element-plus/input-table/index.vue +279 -0
  129. package/es/packages/element-plus/input-tag/index.vue +79 -0
  130. package/es/packages/element-plus/input-tree/index.vue +194 -0
  131. package/es/packages/element-plus/license/index.vue +155 -0
  132. package/es/packages/element-plus/login/index.vue +203 -0
  133. package/es/packages/element-plus/mention/index.vue +117 -0
  134. package/es/packages/element-plus/radio/index.vue +38 -0
  135. package/es/packages/element-plus/rate/index.vue +51 -0
  136. package/es/packages/element-plus/search/index.vue +129 -0
  137. package/es/packages/element-plus/select/index.vue +292 -0
  138. package/es/packages/element-plus/sign/index.vue +230 -0
  139. package/es/packages/element-plus/slider/index.vue +66 -0
  140. package/es/packages/element-plus/switch/index.vue +72 -0
  141. package/es/packages/element-plus/tabs/index.vue +62 -0
  142. package/es/packages/element-plus/text-ellipsis/index.vue +104 -0
  143. package/es/packages/element-plus/time/index.vue +81 -0
  144. package/es/packages/element-plus/title/index.vue +30 -0
  145. package/es/packages/element-plus/tree/index.vue +460 -0
  146. package/es/packages/element-plus/upload/index.vue +728 -0
  147. package/es/packages/element-plus/verify/index.vue +62 -0
  148. package/es/packages/element-plus/video/index.vue +90 -0
  149. package/es/plugin/ali/index.mjs +4 -0
  150. package/es/plugin/ali/index.ts +6 -0
  151. package/es/plugin/clipboard/index.mjs +61 -0
  152. package/es/plugin/clipboard/index.ts +67 -0
  153. package/es/plugin/export/_blob.mjs +151 -0
  154. package/es/plugin/export/_blob.ts +176 -0
  155. package/es/plugin/export/_export2Excel.mjs +141 -0
  156. package/es/plugin/export/_export2Excel.ts +166 -0
  157. package/es/plugin/export/index.mjs +263 -0
  158. package/es/plugin/export/index.ts +274 -0
  159. package/es/plugin/logs/index.mjs +46 -0
  160. package/es/plugin/logs/index.ts +66 -0
  161. package/es/plugin/print/index.mjs +145 -0
  162. package/es/plugin/print/index.ts +155 -0
  163. package/es/plugin/qiniu/index.mjs +78 -0
  164. package/es/plugin/qiniu/index.ts +88 -0
  165. package/es/plugin/screenshot/index.mjs +8 -0
  166. package/es/plugin/screenshot/index.ts +9 -0
  167. package/es/plugin/video/index.mjs +52 -0
  168. package/es/plugin/video/index.ts +60 -0
  169. package/es/plugin/watermark/index.mjs +114 -0
  170. package/es/plugin/watermark/index.ts +127 -0
  171. package/es/plugin/watermark/watermark.mjs +109 -0
  172. package/es/plugin/watermark/watermark.ts +121 -0
  173. package/es/ui/data/index.mjs +49 -0
  174. package/es/ui/data/index.ts +51 -0
  175. package/es/ui/element-plus/index.mjs +87 -0
  176. package/es/ui/element-plus/index.ts +89 -0
  177. package/es/ui/index.mjs +4 -0
  178. package/es/ui/index.ts +6 -0
  179. package/es/utils/bem.mjs +29 -0
  180. package/es/utils/bem.ts +36 -0
  181. package/es/utils/mock.mjs +137 -0
  182. package/es/utils/mock.ts +151 -0
  183. package/es/utils/util.mjs +370 -0
  184. package/es/utils/util.ts +392 -0
  185. package/es/utils/validate.mjs +18 -0
  186. package/es/utils/validate.ts +23 -0
  187. package/es/version.mjs +1 -0
  188. package/es/version.ts +1 -0
  189. package/lib/avue.js +11 -35880
  190. package/lib/avue.min.js +11 -6
  191. package/lib/avue.min.ts +2 -0
  192. package/lib/avue.ts +2 -0
  193. package/lib/core/create.js +14 -0
  194. package/lib/core/create.ts +16 -0
  195. package/lib/core/dataformat.js +194 -0
  196. package/lib/core/dataformat.ts +190 -0
  197. package/lib/core/detail.js +81 -0
  198. package/lib/core/detail.ts +81 -0
  199. package/lib/core/dic.js +220 -0
  200. package/lib/core/dic.ts +235 -0
  201. package/lib/core/locale.js +10 -0
  202. package/lib/core/locale.ts +9 -0
  203. package/lib/core/packages.js +66 -0
  204. package/lib/core/packages.ts +62 -0
  205. package/lib/core/slot.js +34 -0
  206. package/lib/core/slot.ts +30 -0
  207. package/lib/global/variable.js +83 -0
  208. package/lib/global/variable.ts +84 -0
  209. package/lib/icon.js +44 -0
  210. package/lib/icon.ts +11 -0
  211. package/lib/index.js +134 -0
  212. package/lib/index.ts +177 -0
  213. package/lib/locale/browser/en.js +288 -0
  214. package/lib/locale/browser/zh-cn.js +288 -0
  215. package/lib/locale/browser/zh.js +288 -0
  216. package/lib/locale/index.js +153 -47
  217. package/lib/locale/index.ts +196 -0
  218. package/lib/locale/lang/en.js +284 -100
  219. package/lib/locale/lang/en.ts +282 -0
  220. package/lib/locale/lang/zh-cn.js +284 -0
  221. package/lib/locale/lang/zh-cn.ts +282 -0
  222. package/lib/locale/lang/zh.js +284 -100
  223. package/lib/locale/lang/zh.ts +282 -0
  224. package/lib/packages/core/common/event.js +61 -0
  225. package/lib/packages/core/common/event.ts +56 -0
  226. package/lib/packages/core/common/init.js +140 -0
  227. package/lib/packages/core/common/init.ts +133 -0
  228. package/lib/packages/core/common/props.js +245 -0
  229. package/lib/packages/core/common/props.ts +240 -0
  230. package/lib/packages/core/components/dialog-form/index.js +35 -0
  231. package/lib/packages/core/components/dialog-form/index.ts +29 -0
  232. package/lib/packages/core/components/dialog-form/index.vue +108 -0
  233. package/lib/packages/core/components/form/custom.js +43 -0
  234. package/lib/packages/core/components/form/custom.ts +41 -0
  235. package/lib/packages/core/components/form/index.vue +176 -0
  236. package/lib/packages/core/components/icon/index.vue +37 -0
  237. package/lib/packages/core/components/image-preview/index.js +40 -0
  238. package/lib/packages/core/components/image-preview/index.ts +37 -0
  239. package/lib/packages/core/components/image-preview/index.vue +215 -0
  240. package/lib/packages/core/directive/contextmenu.js +94 -0
  241. package/lib/packages/core/directive/contextmenu.ts +103 -0
  242. package/lib/packages/core/directive/permission.js +21 -0
  243. package/lib/packages/core/directive/permission.ts +18 -0
  244. package/lib/packages/data/box/index.vue +66 -0
  245. package/lib/packages/data/card/index.vue +62 -0
  246. package/lib/packages/data/cardText/index.vue +56 -0
  247. package/lib/packages/data/countdown/index.vue +81 -0
  248. package/lib/packages/data/dashboard/index.vue +72 -0
  249. package/lib/packages/data/display/index.vue +63 -0
  250. package/lib/packages/data/icons/index.vue +68 -0
  251. package/lib/packages/data/imgText/index.vue +72 -0
  252. package/lib/packages/data/list/index.vue +69 -0
  253. package/lib/packages/data/notice/index.vue +63 -0
  254. package/lib/packages/data/operaText/index.vue +62 -0
  255. package/lib/packages/data/panel/index.vue +62 -0
  256. package/lib/packages/data/pay/index.vue +92 -0
  257. package/lib/packages/data/price/index.vue +55 -0
  258. package/lib/packages/data/product/index.vue +106 -0
  259. package/lib/packages/data/profile/index.vue +91 -0
  260. package/lib/packages/data/progress/index.vue +64 -0
  261. package/lib/packages/data/rank/index.vue +92 -0
  262. package/lib/packages/data/rotate/index.vue +69 -0
  263. package/lib/packages/data/statistic/index.vue +71 -0
  264. package/lib/packages/data/tabs/index.vue +64 -0
  265. package/lib/packages/data/task/index.vue +82 -0
  266. package/lib/packages/data/weather/index.vue +103 -0
  267. package/lib/packages/element-plus/array/index.vue +115 -0
  268. package/lib/packages/element-plus/article/index.vue +73 -0
  269. package/lib/packages/element-plus/card/index.vue +103 -0
  270. package/lib/packages/element-plus/cascader/index.vue +132 -0
  271. package/lib/packages/element-plus/chat/index.vue +513 -0
  272. package/lib/packages/element-plus/checkbox/index.vue +84 -0
  273. package/lib/packages/element-plus/comment/index.vue +76 -0
  274. package/lib/packages/element-plus/count-up/index.vue +109 -0
  275. package/lib/packages/element-plus/crud/column/column-default.vue +128 -0
  276. package/lib/packages/element-plus/crud/column/column-dynamic.vue +86 -0
  277. package/lib/packages/element-plus/crud/column/column-menu.vue +267 -0
  278. package/lib/packages/element-plus/crud/column/column-slot.vue +348 -0
  279. package/lib/packages/element-plus/crud/column/column.vue +119 -0
  280. package/lib/packages/element-plus/crud/column/menu.vue +78 -0
  281. package/lib/packages/element-plus/crud/config.js +76 -0
  282. package/lib/packages/element-plus/crud/config.ts +74 -0
  283. package/lib/packages/element-plus/crud/dialog/dialog-column.vue +102 -0
  284. package/lib/packages/element-plus/crud/dialog/dialog-excel.vue +204 -0
  285. package/lib/packages/element-plus/crud/dialog/dialog-filter.vue +159 -0
  286. package/lib/packages/element-plus/crud/dialog/dialog-form.vue +352 -0
  287. package/lib/packages/element-plus/crud/grid/index.vue +271 -0
  288. package/lib/packages/element-plus/crud/grid/item.vue +39 -0
  289. package/lib/packages/element-plus/crud/index.vue +1018 -0
  290. package/lib/packages/element-plus/crud/menu/header-menu.vue +175 -0
  291. package/lib/packages/element-plus/crud/menu/header-search.vue +228 -0
  292. package/lib/packages/element-plus/crud/menu/table-page.vue +108 -0
  293. package/lib/packages/element-plus/date/index.vue +81 -0
  294. package/lib/packages/element-plus/draggable/index.vue +444 -0
  295. package/lib/packages/element-plus/dynamic/index.vue +353 -0
  296. package/lib/packages/element-plus/flow/index.vue +339 -0
  297. package/lib/packages/element-plus/flow/node.vue +84 -0
  298. package/lib/packages/element-plus/form/config.js +8 -0
  299. package/lib/packages/element-plus/form/config.ts +6 -0
  300. package/lib/packages/element-plus/form/index.vue +954 -0
  301. package/lib/packages/element-plus/form/menu.vue +63 -0
  302. package/lib/packages/element-plus/group/index.vue +90 -0
  303. package/lib/packages/element-plus/input/index.vue +1264 -0
  304. package/lib/packages/element-plus/input-color/index.vue +70 -0
  305. package/lib/packages/element-plus/input-cron/index.vue +363 -0
  306. package/lib/packages/element-plus/input-icon/index.vue +143 -0
  307. package/lib/packages/element-plus/input-map/index.vue +311 -0
  308. package/lib/packages/element-plus/input-number/index.vue +91 -0
  309. package/lib/packages/element-plus/input-table/index.vue +279 -0
  310. package/lib/packages/element-plus/input-tag/index.vue +79 -0
  311. package/lib/packages/element-plus/input-tree/index.vue +194 -0
  312. package/lib/packages/element-plus/license/index.vue +155 -0
  313. package/lib/packages/element-plus/login/index.vue +203 -0
  314. package/lib/packages/element-plus/mention/index.vue +117 -0
  315. package/lib/packages/element-plus/radio/index.vue +38 -0
  316. package/lib/packages/element-plus/rate/index.vue +51 -0
  317. package/lib/packages/element-plus/search/index.vue +129 -0
  318. package/lib/packages/element-plus/select/index.vue +292 -0
  319. package/lib/packages/element-plus/sign/index.vue +230 -0
  320. package/lib/packages/element-plus/slider/index.vue +66 -0
  321. package/lib/packages/element-plus/switch/index.vue +72 -0
  322. package/lib/packages/element-plus/tabs/index.vue +62 -0
  323. package/lib/packages/element-plus/text-ellipsis/index.vue +104 -0
  324. package/lib/packages/element-plus/time/index.vue +81 -0
  325. package/lib/packages/element-plus/title/index.vue +30 -0
  326. package/lib/packages/element-plus/tree/index.vue +460 -0
  327. package/lib/packages/element-plus/upload/index.vue +728 -0
  328. package/lib/packages/element-plus/verify/index.vue +62 -0
  329. package/lib/packages/element-plus/video/index.vue +90 -0
  330. package/lib/plugin/ali/index.js +8 -0
  331. package/lib/plugin/ali/index.ts +6 -0
  332. package/lib/plugin/clipboard/index.js +64 -0
  333. package/lib/plugin/clipboard/index.ts +67 -0
  334. package/lib/plugin/export/_blob.js +151 -0
  335. package/lib/plugin/export/_blob.ts +176 -0
  336. package/lib/plugin/export/_export2Excel.js +145 -0
  337. package/lib/plugin/export/_export2Excel.ts +166 -0
  338. package/lib/plugin/export/index.js +268 -0
  339. package/lib/plugin/export/index.ts +274 -0
  340. package/lib/plugin/logs/index.js +48 -0
  341. package/lib/plugin/logs/index.ts +66 -0
  342. package/lib/plugin/print/index.js +147 -0
  343. package/lib/plugin/print/index.ts +155 -0
  344. package/lib/plugin/qiniu/index.js +82 -0
  345. package/lib/plugin/qiniu/index.ts +88 -0
  346. package/lib/plugin/screenshot/index.js +14 -0
  347. package/lib/plugin/screenshot/index.ts +9 -0
  348. package/lib/plugin/video/index.js +55 -0
  349. package/lib/plugin/video/index.ts +60 -0
  350. package/lib/plugin/watermark/index.js +121 -0
  351. package/lib/plugin/watermark/index.ts +127 -0
  352. package/lib/plugin/watermark/watermark.js +111 -0
  353. package/lib/plugin/watermark/watermark.ts +121 -0
  354. package/lib/ui/data/index.js +54 -0
  355. package/lib/ui/data/index.ts +51 -0
  356. package/lib/ui/element-plus/index.js +92 -0
  357. package/lib/ui/element-plus/index.ts +89 -0
  358. package/lib/ui/index.js +9 -0
  359. package/lib/ui/index.ts +6 -0
  360. package/lib/utils/bem.js +31 -0
  361. package/lib/utils/bem.ts +36 -0
  362. package/lib/utils/mock.js +142 -0
  363. package/lib/utils/mock.ts +151 -0
  364. package/lib/utils/util.js +403 -0
  365. package/lib/utils/util.ts +392 -0
  366. package/lib/utils/validate.js +21 -0
  367. package/lib/utils/validate.ts +23 -0
  368. package/lib/version.js +4 -0
  369. package/lib/version.ts +1 -0
  370. package/package.json +20 -10
  371. package/types/index.d.ts +139 -47
  372. package/types/shims-aliases.d.ts +4 -0
  373. package/lib/avue.js.map +0 -1
  374. package/lib/locale/format.js +0 -44
@@ -0,0 +1,1018 @@
1
+ <template>
2
+ <div :class="b({ card: !option.card })">
3
+ <component
4
+ :is="tableOption.titleSize || 'h2'"
5
+ :style="tableOption.titleStyle"
6
+ v-if="tableOption.title"
7
+ >{{ tableOption.title }}</component
8
+ >
9
+ <!-- 搜索组件 -->
10
+ <header-search ref="headerSearch">
11
+ <template #search="scope">
12
+ <slot name="search" v-bind="scope"></slot>
13
+ </template>
14
+ <template #search-menu="scope">
15
+ <slot name="search-menu" v-bind="scope"></slot>
16
+ </template>
17
+ <template v-for="item in searchSlot" #[item]="scope">
18
+ <slot v-bind="scope" :name="item"></slot>
19
+ </template>
20
+ </header-search>
21
+ <el-card :shadow="isCard" :class="b('body')">
22
+ <slot name="header"></slot>
23
+ <!-- 表格功能列 -->
24
+ <header-menu ref="headerMenu" v-if="validData(tableOption.header, true)">
25
+ <template #menu-left="scope">
26
+ <slot name="menu-left" v-bind="scope"></slot>
27
+ </template>
28
+ <template #menu-right="scope">
29
+ <slot name="menu-right" v-bind="scope"></slot>
30
+ </template>
31
+ </header-menu>
32
+ <div
33
+ class="avue-crud__tip"
34
+ v-if="validData(tableOption.tip, config.tip) && tableOption.selection"
35
+ >
36
+ <span class="avue-crud__tip-name">
37
+ {{ t("crud.tipStartTitle") }}
38
+ <span class="avue-crud__tip-count">{{ selectLen }}</span>
39
+ {{ t("crud.tipEndTitle") }}
40
+ </span>
41
+ <span class="avue-crud__tip-button" @click="clearSelection">{{
42
+ t("crud.emptyBtn")
43
+ }}</span>
44
+ <slot name="tip"></slot>
45
+ </div>
46
+ <slot name="body"></slot>
47
+ <el-form :model="cellForm" @validate="handleValidate" ref="cellForm">
48
+ <component
49
+ :is="tableName"
50
+ :key="reload"
51
+ :data="cellForm.list"
52
+ :fixed="tableOption.fixed"
53
+ :columns="columnVirtualizeOption"
54
+ :row-key="rowKey"
55
+ :class="{
56
+ 'avue-crud--indeterminate': validData(
57
+ tableOption.indeterminate,
58
+ false
59
+ ),
60
+ }"
61
+ :size="size"
62
+ :append-filter-panel-to="tableOption.appendFilterPanelTo"
63
+ :allow-drag-last-column="tableOption.allowDragLastColumn"
64
+ :lazy="validData(tableOption.lazy, false)"
65
+ :load="treeLoad"
66
+ :tree-props="treeProps"
67
+ :scrollbar-always-on="tableOption.scrollbarAlwaysOn"
68
+ :flexible="tableOption.flexible"
69
+ :table-layout="tableOption.tableLayout"
70
+ :expand-row-keys="tableOption.expandRowKeys"
71
+ :default-expand-all="tableOption.defaultExpandAll"
72
+ :highlight-current-row="tableOption.highlightCurrentRow"
73
+ :tooltip-effect="tableOption.tooltipEffect"
74
+ :tooltip-options="tableOption.tooltipOptions"
75
+ :show-overflow-tooltip="
76
+ tableOption.showOverflowTooltip || tableOption.overHidden
77
+ "
78
+ :tooltip-formatter="tableOption.tooltipFormatter"
79
+ @current-change="currentRowChange"
80
+ @expand-change="expandChange"
81
+ @header-dragend="headerDragend"
82
+ :show-summary="tableOption.showSummary"
83
+ :summary-method="tableSummaryMethod"
84
+ :span-method="tableSpanMethod"
85
+ :stripe="tableOption.stripe"
86
+ :show-header="tableOption.showHeader"
87
+ :default-sort="tableOption.defaultSort"
88
+ :expand-column-key="tableOption.expandColumnKey"
89
+ @scroll="scroll"
90
+ @row-click="rowClick"
91
+ @row-dblclick="rowDblclick"
92
+ @cell-mouse-enter="cellMouseEnter"
93
+ @cell-mouse-leave="cellMouseLeave"
94
+ @cell-click="cellClick"
95
+ @header-click="headerClick"
96
+ @row-contextmenu="rowContextmenu"
97
+ @header-contextmenu="headerContextmenu"
98
+ @cell-dblclick="cellDblclick"
99
+ :row-class-name="rowClassName"
100
+ :cell-class-name="cellClassName"
101
+ :row-style="rowStyle"
102
+ :cell-style="cellStyle"
103
+ :fit="tableOption.fit"
104
+ :header-cell-class-name="headerCellClassName"
105
+ :header-row-class-name="headerRowClassName"
106
+ :header-row-style="headerRowStyle"
107
+ :header-cell-style="headerCellStyle"
108
+ :max-height="isAutoHeight ? tableHeight : tableOption.maxHeight"
109
+ :height="height ? height : tableHeight"
110
+ ref="table"
111
+ :width="width ? width : setPx(tableOption.width, config.width)"
112
+ :border="tableOption.border"
113
+ v-loading.lock="tableLoading"
114
+ :element-loading-text="tableOption.loadingText"
115
+ :element-loading-spinner="tableOption.loadingSpinner"
116
+ :element-loading-svg="tableOption.loadingSvg"
117
+ :element-loading-background="tableOption.loadingBackground"
118
+ @filter-change="filterChange"
119
+ @selection-change="selectionChange"
120
+ @select="select"
121
+ @select-all="selectAll"
122
+ @sort-change="sortChange"
123
+ >
124
+ <template #empty>
125
+ <div :class="b('empty')">
126
+ <slot name="empty" v-if="$slots.empty"></slot>
127
+ <el-empty
128
+ :image-size="100"
129
+ v-else
130
+ :description="tableOption.emptyText || t('crud.emptyText')"
131
+ ></el-empty>
132
+ </div>
133
+ </template>
134
+ <column v-if="!virtualize" :columnOption="columnOption">
135
+ <template #header>
136
+ <column-default ref="columnDefault">
137
+ <template #expand="{ row, index }">
138
+ <slot :row="row" :index="index" name="expand"></slot>
139
+ </template>
140
+ </column-default>
141
+ </template>
142
+ <template v-for="item in mainSlot" #[item]="scope">
143
+ <slot v-bind="scope" :name="item"></slot>
144
+ </template>
145
+ <template #footer>
146
+ <column-menu>
147
+ <template #menu-header="scope">
148
+ <slot name="menu-header" v-bind="scope"></slot>
149
+ </template>
150
+ <template #menu="scope">
151
+ <slot name="menu" v-bind="scope"></slot>
152
+ </template>
153
+ <template #menu-btn="scope">
154
+ <slot name="menu-btn" v-bind="scope"></slot>
155
+ </template>
156
+ <template #menu-before="scope">
157
+ <slot name="menu-before" v-bind="scope"></slot>
158
+ </template>
159
+ <template #menu-btn-before="scope">
160
+ <slot name="menu-btn-before" v-bind="scope"></slot>
161
+ </template>
162
+ </column-menu>
163
+ </template>
164
+ </column>
165
+ </component>
166
+ </el-form>
167
+ <slot name="footer"></slot>
168
+ </el-card>
169
+ <!-- 分页 -->
170
+ <table-page ref="tablePage">
171
+ <template #page>
172
+ <slot name="page"></slot>
173
+ </template>
174
+ </table-page>
175
+ <!-- 表单 -->
176
+ <dialog-form ref="dialogForm">
177
+ <template v-for="item in formSlot" #[item]="scope">
178
+ <slot v-bind="scope" :name="item"></slot>
179
+ </template>
180
+ <template #menu-form="scope">
181
+ <slot name="menu-form" v-bind="scope"></slot>
182
+ </template>
183
+ <template #menu-form-before="scope">
184
+ <slot name="menu-form-before" v-bind="scope"></slot>
185
+ </template>
186
+ </dialog-form>
187
+ <dialog-excel ref="dialogExcel"></dialog-excel>
188
+ <dialog-column ref="dialogColumn"></dialog-column>
189
+ <dialog-filter ref="dialogFilter"></dialog-filter>
190
+ </div>
191
+ </template>
192
+ <script>
193
+ import create from "../../../core/create.js";
194
+ import packages from "../../../core/packages.js";
195
+ import locale from "../../../core/locale.js";
196
+ import permission from "../../core/directive/permission.js";
197
+ import init from "../../core/common/init.js";
198
+ import tableCard from "./grid/index.vue";
199
+ import tableItemCard from "./grid/item.vue";
200
+ import tablePage from "./menu/table-page.vue";
201
+ import headerSearch from "./menu/header-search.vue";
202
+ import headerMenu from "./menu/header-menu.vue";
203
+ import dialogColumn from "./dialog/dialog-column.vue";
204
+ import dialogFilter from "./dialog/dialog-filter.vue";
205
+ import dialogForm from "./dialog/dialog-form.vue";
206
+ import dialogExcel from "./dialog/dialog-excel.vue";
207
+ import column from "./column/column.vue";
208
+ import columnMenu from "./column/column-menu.vue";
209
+ import columnDefault from "./column/column-default.vue";
210
+ import config from "./config.js";
211
+ import { calcCascader, formInitVal } from "../../../core/dataformat.js";
212
+ import { DIC_PROPS } from "../../../global/variable.js";
213
+ import { CommonProps } from "element-plus";
214
+ import { getColumn } from "../../../utils/util.js";
215
+ export default create({
216
+ name: "crud",
217
+ mixins: [init("crud"), locale],
218
+ emits: [
219
+ "update:modelValue",
220
+ "tree-load",
221
+ "selection-clear",
222
+ "header-dragend",
223
+ "expand-change",
224
+ "current-row-change",
225
+ "refresh-change",
226
+ "selection-change",
227
+ "select",
228
+ "select-all",
229
+ "sortable-change",
230
+ "column-sortable-change",
231
+ "filter",
232
+ "filter-change",
233
+ "sort-change",
234
+ "row-dblclick",
235
+ "row-click",
236
+ "cell-mouse-enter",
237
+ "cell-mouse-leave",
238
+ "cell-click",
239
+ "header-click",
240
+ "tab-click",
241
+ "enter",
242
+ "error",
243
+ "date-change",
244
+ "grid-status-change",
245
+ "update:search",
246
+ "update:page",
247
+ "search-icon-change",
248
+ "search-change",
249
+ "search-reset",
250
+ "on-load",
251
+ "current-change",
252
+ "size-change",
253
+ "row-contextmenu",
254
+ "header-contextmenu",
255
+ "cell-dblclick",
256
+ "row-del",
257
+ "row-save",
258
+ "row-update",
259
+ "change",
260
+ "scroll",
261
+ ],
262
+ directives: {
263
+ permission,
264
+ },
265
+ provide() {
266
+ return {
267
+ crud: this,
268
+ };
269
+ },
270
+ components: {
271
+ tableCard,
272
+ tableItemCard,
273
+ column,
274
+ columnDefault, //其它列,
275
+ columnMenu, //操作栏,
276
+ tablePage, //分页
277
+ headerSearch, //搜索
278
+ headerMenu, //菜单头部
279
+ dialogColumn, //显隐列
280
+ dialogFilter, //过滤器
281
+ dialogForm, //分页
282
+ dialogExcel, //导出
283
+ },
284
+ data() {
285
+ return {
286
+ reload: Math.random(),
287
+ cellForm: {
288
+ list: [],
289
+ },
290
+ config: config,
291
+ list: [],
292
+ listError: {},
293
+ tableForm: {},
294
+ tableHeight: undefined,
295
+ tableIndex: -1,
296
+ tableSelect: [],
297
+ sumsList: {},
298
+ cascaderIndexList: [],
299
+ cascaderDicList: {},
300
+ cascaderFormList: {},
301
+ btnDisabledList: {},
302
+ btnDisabled: false,
303
+ default: {},
304
+ gridShow: false,
305
+ };
306
+ },
307
+ mounted() {
308
+ this.dataInit();
309
+ this.getTableHeight();
310
+ this.initFun();
311
+ this.initVirtualizeFun();
312
+ },
313
+ computed: {
314
+ columnVirtualizeOption() {
315
+ return this.columnOption.map((ele) => {
316
+ return {
317
+ ...ele,
318
+ ...{
319
+ key: ele.prop,
320
+ title: ele.label,
321
+ dataKey: ele.prop,
322
+ },
323
+ };
324
+ });
325
+ },
326
+ tableName() {
327
+ if (this.virtualize) {
328
+ return "elTableV2";
329
+ }
330
+ return this.gridShow ? "tableCard" : "elTable";
331
+ },
332
+ tableColumnName() {
333
+ return this.gridShow ? "tableItemCard" : "elTableColumn";
334
+ },
335
+ virtualize() {
336
+ return this.tableOption.virtualize;
337
+ },
338
+ size() {
339
+ return this.tableOption.size || this.$AVUE.tableSize || this.$AVUE.size;
340
+ },
341
+ isSortable() {
342
+ return this.tableOption.sortable;
343
+ },
344
+ isRowSort() {
345
+ return this.tableOption.rowSort;
346
+ },
347
+ isColumnSort() {
348
+ return this.tableOption.columnSort;
349
+ },
350
+ rowParentKey() {
351
+ return this.option.rowParentKey || DIC_PROPS.rowParentKey;
352
+ },
353
+ childrenKey() {
354
+ return this.treeProps.children || DIC_PROPS.children;
355
+ },
356
+ hasChildrenKey() {
357
+ return this.treeProps.hasChildren || DIC_PROPS.hasChildren;
358
+ },
359
+ treeProps() {
360
+ return this.tableOption.treeProps || {};
361
+ },
362
+ isAutoHeight() {
363
+ return this.tableOption.height === "auto";
364
+ },
365
+ formSlot() {
366
+ return this.getSlotList(
367
+ ["-error", "-label", "-type", "-form", "-header", "-desc"],
368
+ this.$slots,
369
+ this.propOption
370
+ );
371
+ },
372
+ searchSlot() {
373
+ return this.getSlotList(["-search"], this.$slots, this.propOption);
374
+ },
375
+ mainSlot() {
376
+ let result = [];
377
+ this.propOption.forEach((item) => {
378
+ let prop = item.prop;
379
+ if (this.$slots[prop]) result.push(prop);
380
+ });
381
+ return this.getSlotList(
382
+ ["-header", "-form"],
383
+ this.$slots,
384
+ this.propOption
385
+ ).concat(result);
386
+ },
387
+ calcHeight() {
388
+ return (this.tableOption.calcHeight || 0) + this.$AVUE.calcHeight;
389
+ },
390
+ propOption() {
391
+ let result = [];
392
+ function findProp(list = []) {
393
+ if (!Array.isArray(list)) return;
394
+ list.forEach((ele) => {
395
+ if (Array.isArray(ele.children)) findProp(ele.children);
396
+ else result.push(ele);
397
+ });
398
+ }
399
+ findProp(this.columnOption);
400
+ result = calcCascader(result);
401
+ return result;
402
+ },
403
+ isShowSummary() {
404
+ return this.option.showSummary;
405
+ },
406
+ isHeader() {
407
+ let flag = false;
408
+ this.columnOption.forEach((ele) => {
409
+ if (ele.children) {
410
+ flag = true;
411
+ }
412
+ });
413
+ return flag;
414
+ },
415
+ isTree() {
416
+ let flag = false;
417
+ this.data.forEach((ele) => {
418
+ if (ele.children) {
419
+ flag = true;
420
+ }
421
+ });
422
+ return this.validData(this.tableOption.tree, flag);
423
+ },
424
+ isCard() {
425
+ return this.option.card ? "always" : "never";
426
+ },
427
+ expandLevel() {
428
+ return this.parentOption.expandLevel || 0;
429
+ },
430
+ expandAll() {
431
+ return this.parentOption.expandAll || false;
432
+ },
433
+ parentOption() {
434
+ return this.tableOption || {};
435
+ },
436
+ columnOption() {
437
+ return getColumn(this.tableOption.column);
438
+ },
439
+ sumColumnList() {
440
+ return this.tableOption.sumColumnList || [];
441
+ },
442
+ selectLen() {
443
+ return this.tableSelect ? this.tableSelect.length : 0;
444
+ },
445
+ },
446
+ watch: {
447
+ modelValue: {
448
+ handler(val) {
449
+ this.tableForm = val;
450
+ },
451
+ immediate: true,
452
+ deep: true,
453
+ },
454
+ list: {
455
+ handler() {
456
+ this.cellForm.list = this.list;
457
+ },
458
+ deep: true,
459
+ },
460
+ data: {
461
+ handler() {
462
+ this.dataInit();
463
+ },
464
+ deep: true,
465
+ },
466
+ tableOption: {
467
+ handler() {
468
+ this.gridShow = this.tableOption.grid;
469
+ },
470
+ immediate: true,
471
+ },
472
+ },
473
+ props: {
474
+ spanMethod: Function,
475
+ summaryMethod: Function,
476
+ beforeClose: Function,
477
+ beforeOpen: Function,
478
+ rowStyle: [Function, Object],
479
+ cellStyle: [Function, Object],
480
+ rowClassName: [Function, String],
481
+ cellClassName: [Function, String],
482
+ headerCellClassName: [Function, String],
483
+ headerRowClassName: [Function, String],
484
+ headerRowStyle: [Function, Object],
485
+ headerCellStyle: [Function, Object],
486
+ uploadSized: Function,
487
+ uploadBefore: Function,
488
+ uploadAfter: Function,
489
+ uploadDelete: Function,
490
+ uploadPreview: Function,
491
+ uploadError: Function,
492
+ uploadExceed: Function,
493
+ permission: {
494
+ type: [Function, Object],
495
+ default: () => {
496
+ return {};
497
+ },
498
+ },
499
+ modelValue: {
500
+ type: Object,
501
+ default: () => {
502
+ return {};
503
+ },
504
+ },
505
+ search: {
506
+ type: Object,
507
+ default() {
508
+ return {};
509
+ },
510
+ },
511
+ page: {
512
+ type: Object,
513
+ default() {
514
+ return {};
515
+ },
516
+ },
517
+ tableLoading: {
518
+ type: Boolean,
519
+ default: false,
520
+ },
521
+ disabled: {
522
+ type: Boolean,
523
+ default: false,
524
+ },
525
+ data: {
526
+ type: Array,
527
+ required: true,
528
+ default: () => {
529
+ return [];
530
+ },
531
+ },
532
+ width: {
533
+ type: [Number, String],
534
+ default: null,
535
+ },
536
+ height: {
537
+ type: [Number, String],
538
+ default: null,
539
+ },
540
+ },
541
+ methods: {
542
+ initVirtualizeFun() {
543
+ if (!this.virtualize) return;
544
+ this.initTableMethods([
545
+ "scrollTo",
546
+ "scrollToTop",
547
+ "scrollToLeft",
548
+ "scrollRow",
549
+ ]);
550
+ },
551
+ initFun() {
552
+ this.initTableMethods([
553
+ "scrollTo",
554
+ "setScrollTop",
555
+ "setScrollLeft",
556
+ "columns",
557
+ "doLayout",
558
+ "updateKeyChildren",
559
+ "toggleAllSelection",
560
+ "toggleRowSelection",
561
+ "toggleRowExpansion",
562
+ "setCurrentRow",
563
+ "clearFilter",
564
+ "clearSort",
565
+ ]);
566
+ },
567
+ initTableMethods(methods) {
568
+ methods.forEach((ele) => {
569
+ this[ele] = (...args) => {
570
+ const tableRef = this.$refs.table;
571
+ if (tableRef && typeof tableRef[ele] === "function") {
572
+ return tableRef[ele](...args);
573
+ }
574
+ };
575
+ });
576
+ },
577
+ handleGridShow() {
578
+ this.gridShow = !this.gridShow;
579
+ this.$emit("grid-status-change", this.gridShow);
580
+ },
581
+ handleValidate(prop, valid, msg) {
582
+ if (!this.listError[prop])
583
+ this.listError[prop] = { valid: false, msg: "" };
584
+
585
+ this.listError[prop].valid = !valid;
586
+ this.listError[prop].msg = msg;
587
+ },
588
+ getPermission(key, row, index) {
589
+ if (typeof this.permission === "function") {
590
+ return this.permission(key, row, index);
591
+ } else if (!this.validatenull(this.permission[key])) {
592
+ return this.permission[key];
593
+ } else {
594
+ return true;
595
+ }
596
+ },
597
+ getTableHeight() {
598
+ this.$nextTick(() => {
599
+ if (this.isAutoHeight) {
600
+ const clientHeight = document.documentElement.clientHeight;
601
+ const calcHeight = this.calcHeight || 0;
602
+ const tableRef = this.$refs.table;
603
+ const tablePageRef = this.$refs.tablePage;
604
+ let tableHeight = clientHeight - calcHeight;
605
+ if (tableRef) {
606
+ const height = tableRef.$el.offsetTop || 0;
607
+ tableHeight -= height;
608
+ }
609
+ if (tablePageRef) {
610
+ const height = tablePageRef.$el.offsetHeight || 0;
611
+ tableHeight -= height;
612
+ }
613
+ this.tableHeight = tableHeight;
614
+ } else {
615
+ this.tableHeight = this.tableOption.height;
616
+ }
617
+ this.doLayout();
618
+ });
619
+ },
620
+ refreshTable(callback) {
621
+ this.reload = Math.random();
622
+ this.tableSelect = [];
623
+ this.$nextTick(() => {
624
+ callback && callback();
625
+ });
626
+ },
627
+ //树懒加载
628
+ treeLoad(tree, treeNode, resolve) {
629
+ this.$emit("tree-load", tree, treeNode, (data) => {
630
+ tree.children = data;
631
+ resolve(data);
632
+ });
633
+ },
634
+ menuIcon(value) {
635
+ return this.validData(
636
+ this.tableOption[value + "Text"],
637
+ this.t("crud." + value)
638
+ );
639
+ },
640
+ getBtnIcon(value) {
641
+ const name = value + "Icon";
642
+ return this.tableOption[name]
643
+ ? this.tableOption[name].trim()
644
+ : config[name];
645
+ },
646
+ //对部分表单字段进行校验的方法
647
+ validateField(val, fn) {
648
+ return this.$refs.dialogForm.$refs.tableForm.validateField(val, fn);
649
+ },
650
+ clearSelection() {
651
+ this.$emit("selection-clear", this.deepClone(this.tableSelect));
652
+ this.$refs.table.clearSelection();
653
+ },
654
+ dataInit() {
655
+ this.list = this.data;
656
+ //初始化序列的参数
657
+ this.list.forEach((ele, index) => {
658
+ if (ele.$cellEdit && !this.cascaderFormList[index]) {
659
+ this.cascaderFormList[index] = this.deepClone(ele);
660
+ }
661
+ ele.$cellEdit = ele.$cellEdit || false;
662
+ ele.$index = index;
663
+ });
664
+ },
665
+ //拖动表头事件
666
+ headerDragend(newWidth, oldWidth, column, event) {
667
+ this.$emit("header-dragend", newWidth, oldWidth, column, event);
668
+ },
669
+ headerSort(oldIndex, newIndex) {
670
+ const visibleColumns = this.columnOption.filter(
671
+ (col) => col.hide !== true
672
+ );
673
+ const oldProp = visibleColumns[oldIndex].prop;
674
+ const newProp = visibleColumns[newIndex].prop;
675
+ const allColumns = this.columnOption;
676
+ const realOldIndex = allColumns.findIndex((col) => col.prop === oldProp);
677
+ const realNewIndex = allColumns.findIndex((col) => col.prop === newProp);
678
+ const targetRow = allColumns.splice(realOldIndex, 1)[0];
679
+ allColumns.splice(realNewIndex, 0, targetRow);
680
+ this.doLayout();
681
+ },
682
+ scroll(params) {
683
+ this.$emit("scroll", params);
684
+ },
685
+ //展开或则关闭
686
+ expandChange(row, expand) {
687
+ this.$emit("expand-change", row, expand);
688
+ },
689
+ //设置单选
690
+ currentRowChange(row) {
691
+ this.$emit("current-row-change", row);
692
+ },
693
+ //刷新事件
694
+ refreshChange() {
695
+ this.$emit("refresh-change");
696
+ },
697
+ // 选中实例
698
+ toggleSelection(rows, checked) {
699
+ if (rows) {
700
+ rows.forEach((row) => {
701
+ this.$refs.table.toggleRowSelection(row, checked);
702
+ });
703
+ } else {
704
+ this.$refs.table.clearSelection();
705
+ }
706
+ },
707
+ // 选择回调
708
+ selectionChange(val) {
709
+ this.tableSelect = val;
710
+ this.$emit("selection-change", this.tableSelect);
711
+ },
712
+ // 单个选择回调
713
+ select(selection, row) {
714
+ this.$emit("select", selection, row);
715
+ },
716
+ // 点击勾选全选 Checkbox
717
+ selectAll(selection) {
718
+ this.$emit("select-all", selection);
719
+ },
720
+ //筛选回调用
721
+ filterChange(filters) {
722
+ this.$emit("filter-change", filters);
723
+ },
724
+ // 排序回调
725
+ sortChange(val) {
726
+ this.$emit("sort-change", val);
727
+ },
728
+ // 行双击
729
+ rowDblclick(row, event) {
730
+ this.$emit("row-dblclick", row, event);
731
+ },
732
+ // 行单机
733
+ rowClick(row, event, column) {
734
+ this.$emit("row-click", row, event, column);
735
+ },
736
+ //当单元格 hover 进入时会触发该事件
737
+ cellMouseEnter(row, column, cell, event) {
738
+ this.$emit("cell-mouse-enter", row, column, cell, event);
739
+ },
740
+ //当单元格 hover 退出时会触发该事件
741
+ cellMouseLeave(row, column, cell, event) {
742
+ this.$emit("cell-mouse-leave", row, column, cell, event);
743
+ },
744
+ //当某个单元格被点击时会触发该事件
745
+ cellClick(row, column, cell, event) {
746
+ this.$emit("cell-click", row, column, cell, event);
747
+ },
748
+ // 当某一列的表头被点击时会触发该事件
749
+ headerClick(column, event) {
750
+ this.$emit("header-click", column, event);
751
+ },
752
+ //当某一行被鼠标右键点击时会触发该事件
753
+ rowContextmenu(row, column, event) {
754
+ this.$emit("row-contextmenu", row, column, event);
755
+ },
756
+ //当某一列的表头被鼠标右键点击时触发该事件
757
+ headerContextmenu(column, event) {
758
+ this.$emit("header-contextmenu", column, event);
759
+ },
760
+ //当某个单元格被双击击时会触发该事件
761
+ cellDblclick(row, column, cell, event) {
762
+ this.$emit("cell-dblclick", row, column, cell, event);
763
+ },
764
+ //单元格新增
765
+ rowCellAdd(row = {}) {
766
+ let len = this.list.length;
767
+ let formDefault = formInitVal(this.propOption);
768
+ row = this.deepClone(
769
+ Object.assign(
770
+ {
771
+ $cellEdit: true,
772
+ $index: len,
773
+ },
774
+ formDefault,
775
+ row
776
+ )
777
+ );
778
+ this.list.push(row);
779
+ },
780
+ //行取消
781
+ rowCancel(row, index) {
782
+ if (this.validatenull(row[this.rowKey])) {
783
+ this.list.splice(index, 1);
784
+ delete this.cascaderDIC[index];
785
+ } else {
786
+ this.cascaderFormList[index].$cellEdit = false;
787
+ this.cascaderDIC[index] = this.cascaderDicList[index];
788
+ this.list[index] = this.cascaderFormList[index];
789
+ }
790
+ delete this.cascaderDicList[index];
791
+ delete this.cascaderFormList[index];
792
+ this.cascaderIndexList.splice(this.cascaderIndexList.indexOf(index), 1);
793
+ },
794
+ //行编辑点击
795
+ rowCell(row, index) {
796
+ if (row.$cellEdit) {
797
+ this.rowCellUpdate(row, index);
798
+ } else {
799
+ this.rowCellEdit(row, index);
800
+ }
801
+ },
802
+ rowCellUpdate(row, index) {
803
+ const done = (newRow) => {
804
+ row = newRow || row;
805
+ this.btnDisabledList[index] = false;
806
+ this.btnDisabled = false;
807
+ row.$cellEdit = false;
808
+ this.list[index] = row;
809
+ this.cascaderIndexList.splice(this.cascaderIndexList.indexOf(index), 1);
810
+ delete this.cascaderFormList[index];
811
+ };
812
+ const loading = () => {
813
+ this.btnDisabledList[index] = false;
814
+ this.btnDisabled = false;
815
+ };
816
+ this.validateCellField(index).then(() => {
817
+ this.btnDisabledList[index] = true;
818
+ this.btnDisabled = true;
819
+ if (this.validatenull(row[this.rowKey])) {
820
+ this.$emit("row-save", row, done, loading);
821
+ } else {
822
+ this.$emit("row-update", row, index, done, loading);
823
+ }
824
+ });
825
+ },
826
+ // 单元格编辑
827
+ rowCellEdit(row, index) {
828
+ row.$cellEdit = true;
829
+ //缓冲行数据
830
+ this.cascaderFormList[index] = this.deepClone(row);
831
+ //缓冲级联字典
832
+ this.cascaderDicList[index] = this.deepClone(this.cascaderDIC[index]);
833
+ },
834
+ // 对部分表单字段进行校验
835
+ validateCellForm(cb) {
836
+ return new Promise((resolve) => {
837
+ this.$refs.cellForm.validate((valid, msg) => {
838
+ resolve(msg);
839
+ });
840
+ });
841
+ },
842
+ validateCellField(index) {
843
+ return new Promise((resolve, reject) => {
844
+ this.$refs.cellForm.validate((valid, msg = {}) => {
845
+ let result = true;
846
+ let list = [];
847
+ Object.keys(msg).forEach((ele) => {
848
+ if (ele.indexOf(`list.${index}.`) !== -1) {
849
+ result = false;
850
+ } else {
851
+ list.push(ele);
852
+ }
853
+ });
854
+ if (!this.validatenull(list)) this.$refs.cellForm.clearValidate(list);
855
+ if (result) resolve();
856
+ });
857
+ });
858
+ },
859
+ clearValidate(list) {
860
+ this.$refs.cellForm.clearValidate(list);
861
+ },
862
+ rowAdd() {
863
+ this.$refs.dialogForm.show("add");
864
+ },
865
+ rowSave() {
866
+ return this.$refs.dialogForm.$refs.tableForm.submit();
867
+ },
868
+ rowUpdate() {
869
+ return this.$refs.dialogForm.$refs.tableForm.submit();
870
+ },
871
+ closeDialog() {
872
+ return this.$refs.dialogForm.closeDialog();
873
+ },
874
+ getPropRef(prop) {
875
+ return this.$refs.dialogForm.$refs.tableForm.getPropRef(prop);
876
+ },
877
+ setVal() {
878
+ this.$emit("update:modelValue", this.tableForm);
879
+ this.$emit("change", this.tableForm);
880
+ },
881
+ // 编辑
882
+ rowEdit(row, index) {
883
+ this.tableForm = this.deepClone(row);
884
+ this.tableIndex = index;
885
+ this.setVal();
886
+ this.$refs.dialogForm.show("edit");
887
+ },
888
+ //复制
889
+ rowCopy(row) {
890
+ this.tableForm = this.deepClone(row);
891
+ delete this.tableForm[this.rowKey];
892
+ this.tableIndex = -1;
893
+ this.setVal();
894
+ this.$refs.dialogForm.show("add");
895
+ },
896
+ //查看
897
+ rowView(row, index) {
898
+ this.tableForm = this.deepClone(row);
899
+ this.tableIndex = index;
900
+ this.setVal();
901
+ this.$refs.dialogForm.show("view");
902
+ },
903
+ // 删除
904
+ rowDel(row, index) {
905
+ this.$emit("row-del", row, index, () => {
906
+ let { parentList, index } = this.findData(row[this.rowKey]);
907
+ if (parentList) parentList.splice(index, 1);
908
+ });
909
+ },
910
+ //合并行
911
+ tableSpanMethod(param) {
912
+ if (typeof this.spanMethod === "function") return this.spanMethod(param);
913
+ },
914
+ //合集统计逻辑
915
+ tableSummaryMethod(param) {
916
+ let sumsList = {};
917
+ let sums = [];
918
+ const { columns, data } = param;
919
+ //如果自己写逻辑则调用summaryMethod方法
920
+ if (typeof this.summaryMethod === "function") {
921
+ sums = this.summaryMethod(param);
922
+ columns.forEach((column, index) => {
923
+ sumsList[column.property] = sums[index];
924
+ });
925
+ this.sumsList = sumsList;
926
+ } else {
927
+ columns.forEach((column, index) => {
928
+ let currItem = this.sumColumnList.find(
929
+ (item) => item.name === column.property
930
+ );
931
+ if (currItem) {
932
+ let decimals = currItem.decimals !== void 0 ? currItem.decimals : 2;
933
+ let label = currItem.label || "";
934
+ switch (currItem.type) {
935
+ case "count":
936
+ sums[index] = label + data.length;
937
+ break;
938
+ case "avg":
939
+ let avgValues = data.map((item) =>
940
+ Number(item[column.property])
941
+ );
942
+ let nowindex = 1;
943
+ sums[index] = avgValues.reduce((perv, curr) => {
944
+ let value = Number(curr);
945
+ if (!isNaN(value)) {
946
+ return (perv * (nowindex - 1) + curr) / nowindex++;
947
+ } else {
948
+ return perv;
949
+ }
950
+ }, 0);
951
+ sums[index] = label + sums[index].toFixed(decimals);
952
+ break;
953
+ case "sum":
954
+ let values = data.map((item) => Number(item[column.property]));
955
+ sums[index] = values.reduce((perv, curr) => {
956
+ let value = Number(curr);
957
+ if (!isNaN(value)) {
958
+ return perv + curr;
959
+ } else {
960
+ return perv;
961
+ }
962
+ }, 0);
963
+ sums[index] = label + sums[index].toFixed(decimals);
964
+ break;
965
+ }
966
+ sumsList[column.property] = sums[index];
967
+ } else {
968
+ sums[index] = "";
969
+ }
970
+ });
971
+ }
972
+ this.sumsList = sumsList;
973
+ return sums;
974
+ },
975
+ tableDrop(type, el, callback) {
976
+ if (this.isSortable !== true) {
977
+ if (type == "row" && !this.isRowSort) {
978
+ return;
979
+ } else if (type == "column" && !this.isColumnSort) {
980
+ return;
981
+ }
982
+ } else if (!el) return;
983
+ if (!window.Sortable) {
984
+ packages.logs("Sortable");
985
+ return;
986
+ }
987
+ return window.Sortable.create(el, {
988
+ ghostClass: config.ghostClass,
989
+ chosenClass: config.ghostClass,
990
+ animation: 100,
991
+ delay: 100,
992
+ onEnd: (evt) => callback(evt),
993
+ filter: ".el-table-fixed-column--right",
994
+ });
995
+ },
996
+ findData(id) {
997
+ let result = {};
998
+ const callback = (parentList, parent) => {
999
+ parentList.forEach((ele, index) => {
1000
+ if (ele[this.rowKey] == id) {
1001
+ result = {
1002
+ item: ele,
1003
+ index: index,
1004
+ parentList: parentList,
1005
+ parent: parent,
1006
+ };
1007
+ }
1008
+ if (ele[this.childrenKey]) {
1009
+ callback(ele[this.childrenKey], ele);
1010
+ }
1011
+ });
1012
+ };
1013
+ callback(this.list);
1014
+ return result;
1015
+ },
1016
+ },
1017
+ });
1018
+ </script>