@netang/quasar 0.2.32 → 0.2.33

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 (289) hide show
  1. package/.editorconfig +12 -12
  2. package/_docs/docs/components/field-table.md +58 -58
  3. package/_docs/docs/components/field-tree.md +21 -21
  4. package/_docs/docs/components/table.md +24 -24
  5. package/_docs/docs/utils/table.md +196 -196
  6. package/components/column-title/index.vue +38 -38
  7. package/components/data/index.vue +20 -20
  8. package/components/dialog/img-viewer/index.vue +697 -697
  9. package/components/dialog/index.vue +387 -387
  10. package/components/dragger/index.vue +203 -203
  11. package/components/drawer/index.vue +303 -303
  12. package/components/editor-code/index.vue +328 -328
  13. package/components/empty/index.vue +82 -82
  14. package/components/field-date/index.vue +860 -860
  15. package/components/field-date/methods.js +100 -100
  16. package/components/field-table/index.vue +1483 -1483
  17. package/components/field-text/index.vue +166 -166
  18. package/components/field-tree/index.vue +755 -755
  19. package/components/img/index.vue +279 -279
  20. package/components/input-number/index.vue +560 -560
  21. package/components/list-menu/index.vue +149 -149
  22. package/components/list-menu-item/index.vue +79 -79
  23. package/components/mixed-table/index.vue +532 -532
  24. package/components/mixed-table-splitter/index.vue +377 -377
  25. package/components/power-page/index.vue +96 -96
  26. package/components/price/index.vue +188 -188
  27. package/components/private/components/index.js +11 -11
  28. package/components/private/components/move-to-tree/index.vue +154 -154
  29. package/components/private/edit-power-data/index.vue +846 -846
  30. package/components/private/table-visible-columns-button/index.vue +114 -114
  31. package/components/render/index.vue +123 -123
  32. package/components/search/index.vue +231 -231
  33. package/components/search-item/index.vue +210 -210
  34. package/components/select/index.vue +177 -177
  35. package/components/splitter/index.vue +422 -422
  36. package/components/table/index.vue +513 -513
  37. package/components/table-column-fixed/index.vue +110 -110
  38. package/components/table-pagination/index.vue +192 -192
  39. package/components/table-summary/index.vue +107 -107
  40. package/components/thumbnail/index.vue +72 -72
  41. package/components/toolbar/index.vue +150 -150
  42. package/components/tree/index.vue +1728 -1728
  43. package/components/tree/virtual-scroll.vue +41 -41
  44. package/components/uploader/index.vue +196 -196
  45. package/components/uploader-query/index.vue +945 -945
  46. package/components/value-format/index.vue +274 -274
  47. package/components/virtual-scroll/index.vue +136 -136
  48. package/configs/area3.js +1 -1
  49. package/docs/404.html +33 -33
  50. package/docs/assets/404.html-60b35caa.js +1 -1
  51. package/docs/assets/404.html-d1e63d77.js +1 -1
  52. package/docs/assets/alert.html-b2a2a72f.js +5 -5
  53. package/docs/assets/alert.html-ba46d137.js +1 -1
  54. package/docs/assets/app-9f30aa4b.js +6 -6
  55. package/docs/assets/area.html-01b9b58d.js +42 -42
  56. package/docs/assets/area.html-9a4fce6a.js +1 -1
  57. package/docs/assets/arr.html-145d27e7.js +1 -1
  58. package/docs/assets/arr.html-674e65ab.js +11 -11
  59. package/docs/assets/auth.html-579fa830.js +1 -1
  60. package/docs/assets/auth.html-8544ed95.js +8 -8
  61. package/docs/assets/bus.html-c71254aa.js +1 -1
  62. package/docs/assets/bus.html-dc7d3d19.js +6 -6
  63. package/docs/assets/column-title.html-c735cb5a.js +3 -3
  64. package/docs/assets/column-title.html-e9316762.js +1 -1
  65. package/docs/assets/confirm.html-ddfdc27f.js +10 -10
  66. package/docs/assets/confirm.html-ef3e2bef.js +1 -1
  67. package/docs/assets/copy.html-d20345b6.js +1 -1
  68. package/docs/assets/copy.html-ef8c8571.js +13 -13
  69. package/docs/assets/data.html-6432175d.js +30 -30
  70. package/docs/assets/data.html-a3b05d5b.js +1 -1
  71. package/docs/assets/dialog.html-1f698e5a.js +1 -1
  72. package/docs/assets/dialog.html-62902b83.js +68 -68
  73. package/docs/assets/dialog.html-baea77c9.js +1 -1
  74. package/docs/assets/dialog.html-bb082fc4.js +1 -1
  75. package/docs/assets/dict.html-1311da3d.js +23 -23
  76. package/docs/assets/dict.html-b96fbf0c.js +1 -1
  77. package/docs/assets/dictOptions.html-7c4f40a5.js +1 -1
  78. package/docs/assets/dictOptions.html-fb99d175.js +5 -5
  79. package/docs/assets/dragger.html-668d3efa.js +1 -1
  80. package/docs/assets/dragger.html-749d585a.js +1 -1
  81. package/docs/assets/editor-code.html-6ab26ea9.js +1 -1
  82. package/docs/assets/editor-code.html-d196205d.js +1 -1
  83. package/docs/assets/empty.html-1c139131.js +1 -1
  84. package/docs/assets/empty.html-1e9c441d.js +1 -1
  85. package/docs/assets/field-date.html-069fdb13.js +1 -1
  86. package/docs/assets/field-date.html-ad204aa9.js +1 -1
  87. package/docs/assets/field-table.html-ce480f03.js +1 -1
  88. package/docs/assets/field-table.html-d9236160.js +1 -1
  89. package/docs/assets/field-text.html-7277c62f.js +1 -1
  90. package/docs/assets/field-text.html-ccb4cecf.js +1 -1
  91. package/docs/assets/field-tree.html-519bfb45.js +1 -1
  92. package/docs/assets/field-tree.html-fdc748d6.js +1 -1
  93. package/docs/assets/form.html-2b562c37.js +2 -2
  94. package/docs/assets/form.html-75104cd5.js +1 -1
  95. package/docs/assets/framework-204010b2.js +5 -5
  96. package/docs/assets/getData.html-990e3787.js +1 -1
  97. package/docs/assets/getData.html-bb72025f.js +34 -34
  98. package/docs/assets/getFile.html-42368004.js +1 -1
  99. package/docs/assets/getFile.html-99abd054.js +3 -3
  100. package/docs/assets/getImage.html-3429c5a1.js +1 -1
  101. package/docs/assets/getImage.html-4d886d83.js +3 -3
  102. package/docs/assets/getTime.html-7435f922.js +1 -1
  103. package/docs/assets/getTime.html-b37f49eb.js +20 -20
  104. package/docs/assets/img.html-7d1da657.js +1 -1
  105. package/docs/assets/img.html-fbea1105.js +1 -1
  106. package/docs/assets/index.html-1695dd7c.js +1 -1
  107. package/docs/assets/index.html-65a4aa67.js +1 -1
  108. package/docs/assets/index.html-7b98d5bd.js +1 -1
  109. package/docs/assets/index.html-c01f2648.js +1 -1
  110. package/docs/assets/input-number.html-0b250d2a.js +1 -1
  111. package/docs/assets/input-number.html-a8eb0378.js +1 -1
  112. package/docs/assets/list-menu-item.html-7f1b4611.js +1 -1
  113. package/docs/assets/list-menu-item.html-84ed5ab8.js +1 -1
  114. package/docs/assets/list-menu.html-28b4163f.js +1 -1
  115. package/docs/assets/list-menu.html-cb6ba95b.js +1 -1
  116. package/docs/assets/loading.html-dae9e39d.js +6 -6
  117. package/docs/assets/loading.html-dc74c9e6.js +1 -1
  118. package/docs/assets/notify.html-e6c4c514.js +1 -1
  119. package/docs/assets/notify.html-f2c4d914.js +8 -8
  120. package/docs/assets/power-page.html-32e02f82.js +1 -1
  121. package/docs/assets/power-page.html-485e77da.js +1 -1
  122. package/docs/assets/power.html-d258cc19.js +93 -93
  123. package/docs/assets/power.html-e490bd32.js +1 -1
  124. package/docs/assets/previewImage.html-6a6b4245.js +1 -1
  125. package/docs/assets/previewImage.html-c5b7e945.js +2 -2
  126. package/docs/assets/price.html-1882c548.js +19 -19
  127. package/docs/assets/price.html-94d3f5be.js +1 -1
  128. package/docs/assets/price.html-d213df0f.js +1 -1
  129. package/docs/assets/price.html-deaf880f.js +1 -1
  130. package/docs/assets/render.html-8efcbdd4.js +1 -1
  131. package/docs/assets/render.html-df228e38.js +1 -1
  132. package/docs/assets/rule.html-2cd57fc2.js +13 -13
  133. package/docs/assets/rule.html-61662001.js +1 -1
  134. package/docs/assets/ruleValid.html-04fe2552.js +1 -1
  135. package/docs/assets/ruleValid.html-e0a776af.js +14 -14
  136. package/docs/assets/search-0782d0d1.svg +1 -1
  137. package/docs/assets/search-item.html-3f75394c.js +1 -1
  138. package/docs/assets/search-item.html-4e942ecd.js +1 -1
  139. package/docs/assets/search.html-2807043e.js +1 -1
  140. package/docs/assets/search.html-c24f8806.js +1 -1
  141. package/docs/assets/select.html-00d0607c.js +1 -1
  142. package/docs/assets/select.html-de7731f5.js +1 -1
  143. package/docs/assets/splitter.html-56f51a70.js +1 -1
  144. package/docs/assets/splitter.html-f5c836d7.js +1 -1
  145. package/docs/assets/style-161e43ab.css +1 -1
  146. package/docs/assets/symbols.html-a6aea4bf.js +1 -1
  147. package/docs/assets/symbols.html-b1f65bad.js +21 -21
  148. package/docs/assets/table-column-fixed.html-3a69e7b2.js +1 -1
  149. package/docs/assets/table-column-fixed.html-e763c38b.js +1 -1
  150. package/docs/assets/table-pagination.html-236934d3.js +1 -1
  151. package/docs/assets/table-pagination.html-c37ee2ac.js +1 -1
  152. package/docs/assets/table-splitter.html-07eab15c.js +1 -1
  153. package/docs/assets/table-splitter.html-7670ee65.js +1 -1
  154. package/docs/assets/table-summary.html-04db434f.js +1 -1
  155. package/docs/assets/table-summary.html-943c65a0.js +1 -1
  156. package/docs/assets/table.html-36253ad7.js +1 -1
  157. package/docs/assets/table.html-7f9c5d1b.js +38 -38
  158. package/docs/assets/table.html-93d53dc8.js +1 -1
  159. package/docs/assets/table.html-ac99b9cb.js +1 -1
  160. package/docs/assets/thumbnail.html-bab1976b.js +1 -1
  161. package/docs/assets/thumbnail.html-eb64e5e8.js +1 -1
  162. package/docs/assets/timestamp.html-4e54f79b.js +13 -13
  163. package/docs/assets/timestamp.html-d0e1b88a.js +1 -1
  164. package/docs/assets/toast.html-58ecbe21.js +1 -1
  165. package/docs/assets/toast.html-c9b9d36b.js +6 -6
  166. package/docs/assets/toolbar.html-83d9f97c.js +1 -1
  167. package/docs/assets/toolbar.html-ff7b8c92.js +1 -1
  168. package/docs/assets/tree.html-d07cbe79.js +23 -23
  169. package/docs/assets/tree.html-ea04193e.js +1 -1
  170. package/docs/assets/uploader-query.html-05590718.js +1 -1
  171. package/docs/assets/uploader-query.html-3175bac5.js +1 -1
  172. package/docs/assets/uploader.html-36da4394.js +2 -2
  173. package/docs/assets/uploader.html-6b5f3079.js +1 -1
  174. package/docs/assets/uploader.html-b9340b57.js +1 -1
  175. package/docs/assets/uploader.html-bc1c22e3.js +1 -1
  176. package/docs/assets/value-format.html-8ae3d47d.js +1 -1
  177. package/docs/assets/value-format.html-afa99b3d.js +1 -1
  178. package/docs/components/column-title.html +35 -35
  179. package/docs/components/data.html +62 -62
  180. package/docs/components/dialog.html +33 -33
  181. package/docs/components/dragger.html +33 -33
  182. package/docs/components/editor-code.html +33 -33
  183. package/docs/components/empty.html +33 -33
  184. package/docs/components/field-date.html +33 -33
  185. package/docs/components/field-table.html +33 -33
  186. package/docs/components/field-text.html +33 -33
  187. package/docs/components/field-tree.html +33 -33
  188. package/docs/components/img.html +33 -33
  189. package/docs/components/input-number.html +33 -33
  190. package/docs/components/list-menu-item.html +33 -33
  191. package/docs/components/list-menu.html +33 -33
  192. package/docs/components/power-page.html +33 -33
  193. package/docs/components/price.html +33 -33
  194. package/docs/components/render.html +33 -33
  195. package/docs/components/search-item.html +33 -33
  196. package/docs/components/search.html +33 -33
  197. package/docs/components/select.html +33 -33
  198. package/docs/components/splitter.html +33 -33
  199. package/docs/components/table-column-fixed.html +33 -33
  200. package/docs/components/table-pagination.html +33 -33
  201. package/docs/components/table-splitter.html +33 -33
  202. package/docs/components/table-summary.html +33 -33
  203. package/docs/components/table.html +33 -33
  204. package/docs/components/thumbnail.html +33 -33
  205. package/docs/components/toolbar.html +33 -33
  206. package/docs/components/uploader-query.html +33 -33
  207. package/docs/components/uploader.html +33 -33
  208. package/docs/components/value-format.html +33 -33
  209. package/docs/css/index.css +3 -3
  210. package/docs/index.html +33 -33
  211. package/docs/utils/alert.html +37 -37
  212. package/docs/utils/area.html +74 -74
  213. package/docs/utils/arr.html +43 -43
  214. package/docs/utils/auth.html +40 -40
  215. package/docs/utils/bus.html +38 -38
  216. package/docs/utils/confirm.html +42 -42
  217. package/docs/utils/copy.html +45 -45
  218. package/docs/utils/dialog.html +100 -100
  219. package/docs/utils/dict.html +55 -55
  220. package/docs/utils/dictOptions.html +37 -37
  221. package/docs/utils/form.html +34 -34
  222. package/docs/utils/getData.html +66 -66
  223. package/docs/utils/getFile.html +35 -35
  224. package/docs/utils/getImage.html +35 -35
  225. package/docs/utils/getTime.html +52 -52
  226. package/docs/utils/index.html +33 -33
  227. package/docs/utils/loading.html +38 -38
  228. package/docs/utils/notify.html +40 -40
  229. package/docs/utils/power.html +125 -125
  230. package/docs/utils/previewImage.html +34 -34
  231. package/docs/utils/price.html +51 -51
  232. package/docs/utils/rule.html +45 -45
  233. package/docs/utils/ruleValid.html +46 -46
  234. package/docs/utils/symbols.html +53 -53
  235. package/docs/utils/table.html +70 -70
  236. package/docs/utils/timestamp.html +45 -45
  237. package/docs/utils/toast.html +38 -38
  238. package/docs/utils/tree.html +55 -55
  239. package/docs/utils/uploader.html +34 -34
  240. package/package.json +25 -25
  241. package/sass/common.scss +184 -184
  242. package/sass/index.scss +12 -12
  243. package/sass/line.scss +39 -39
  244. package/sass/quasar/btn.scss +46 -46
  245. package/sass/quasar/common.scss +3 -3
  246. package/sass/quasar/drawer.scss +6 -6
  247. package/sass/quasar/field.scss +259 -259
  248. package/sass/quasar/loading.scss +6 -6
  249. package/sass/quasar/table.scss +168 -168
  250. package/sass/quasar/toolbar.scss +22 -22
  251. package/sass/variables.scss +140 -140
  252. package/store/index.js +29 -29
  253. package/utils/$auth.js +128 -128
  254. package/utils/$form.js +72 -72
  255. package/utils/$power.js +1494 -1494
  256. package/utils/$render.js +75 -75
  257. package/utils/$rule.js +13 -13
  258. package/utils/$ruleValid.js +10 -10
  259. package/utils/$search.js +416 -416
  260. package/utils/$table.js +1351 -1348
  261. package/utils/$tree.js +682 -682
  262. package/utils/alert.js +12 -12
  263. package/utils/area.js +400 -400
  264. package/utils/arr.js +51 -51
  265. package/utils/bus.js +6 -6
  266. package/utils/config.js +66 -66
  267. package/utils/confirm.js +11 -11
  268. package/utils/copy.js +30 -30
  269. package/utils/dialog.js +36 -36
  270. package/utils/dict.js +21 -21
  271. package/utils/dictOptions.js +28 -28
  272. package/utils/getData.js +88 -88
  273. package/utils/getFile.js +67 -67
  274. package/utils/getImage.js +276 -276
  275. package/utils/getTime.js +113 -113
  276. package/utils/index.js +67 -67
  277. package/utils/loading.js +15 -15
  278. package/utils/notify.js +13 -13
  279. package/utils/play.js +40 -40
  280. package/utils/previewImage.js +14 -14
  281. package/utils/price.js +18 -18
  282. package/utils/symbols.js +18 -18
  283. package/utils/timestamp.js +18 -18
  284. package/utils/toast.js +13 -13
  285. package/utils/uploader.js +2114 -2114
  286. package/utils/useAuth.js +30 -30
  287. package/utils/useFileUrl.js +26 -26
  288. package/utils/useRouter.js +47 -47
  289. package/utils/useSearch.js +587 -562
package/utils/$table.js CHANGED
@@ -1,1348 +1,1351 @@
1
- import { ref, computed, provide, inject, watch } from 'vue'
2
- import { useQuasar } from 'quasar'
3
-
4
- import $n_has from 'lodash/has'
5
- import $n_get from 'lodash/get'
6
- import $n_cloneDeep from 'lodash/cloneDeep'
7
- import $n_merge from 'lodash/merge'
8
- import $n_isFunction from 'lodash/isFunction'
9
- import $n_findIndex from 'lodash/findIndex'
10
- import $n_uniq from 'lodash/uniq'
11
- import $n_concat from 'lodash/concat'
12
- import $n_isNil from 'lodash/isNil'
13
-
14
- import $n_router from '@netang/utils/vue/router'
15
-
16
- import $n_forEach from '@netang/utils/forEach'
17
- import $n_isValidArray from '@netang/utils/isValidArray'
18
- import $n_isValidString from '@netang/utils/isValidString'
19
- import $n_indexOf from '@netang/utils/indexOf'
20
- import $n_storage from '@netang/utils/storage'
21
-
22
- import $n_isRequired from '@netang/utils/isRequired'
23
- import $n_forIn from '@netang/utils/forIn'
24
- import $n_run from '@netang/utils/run'
25
- import $n_runAsync from '@netang/utils/runAsync'
26
- import $n_isValidObject from '@netang/utils/isValidObject'
27
- import $n_isValidValue from '@netang/utils/isValidValue'
28
- import $n_slash from '@netang/utils/slash'
29
- import $n_http from '@netang/utils/http'
30
- import $n_cb from '@netang/utils/cb'
31
-
32
- import $n_$power from './$power'
33
- import $n_dict from './dict'
34
- import $n_price from './price'
35
- import $n_getTime from './getTime'
36
-
37
- import { configs } from './config'
38
-
39
- import {
40
- // 设置单个搜索值
41
- setItemValue,
42
- // 从表格列获取原始值
43
- getRawData,
44
- // 获取参数
45
- getOptions,
46
- // 格式化值
47
- formatValue,
48
- } from './useSearch'
49
-
50
- import { NRenderKey, NPowerKey, NTableKey } from './symbols'
51
-
52
- const {
53
- // 表格配置
54
- tablesConfig,
55
- // 字典常量
56
- dicts,
57
- } = configs
58
-
59
- /**
60
- * 创建表格
61
- */
62
- function create(options) {
63
-
64
- // ==========【数据】=================================================================================================
65
-
66
- // quasar 对象
67
- const $q = useQuasar()
68
-
69
- // 每页显示行数选项
70
- const rowsPerPageOptions = [30, 40, 50, 100, 200, 500, 1000]
71
-
72
- // 原始参数
73
- const rawOptions = {
74
- // 路由路径
75
- path: '',
76
- // 请求地址(默认为 path)
77
- url: '',
78
- // 路由参数
79
- query: {},
80
- // 附加请求数据
81
- data: {},
82
- // 表格行唯一键值
83
- rowKey: 'id',
84
- // 选择类型, 可选值 none single(默认) multiple
85
- // selection: '',
86
- // 分隔栏, 可选值 horizontal vertical cell none
87
- separator: 'cell',
88
- // 初始已选数据
89
- selected: [],
90
- // 初始表格加载状态
91
- loading: false,
92
- // 表格列数据(对象数组)
93
- columns: [],
94
- // 初始可见列
95
- visibleColumns: [],
96
- // 表格行数据
97
- rows: [],
98
- // 表格翻页参数
99
- pagination: {
100
- // 页码
101
- page: 1,
102
- // 每页的数据条数
103
- rowsPerPage: $n_has(options, 'rowsPerPageOptions') ? options.rowsPerPageOptions[0] : rowsPerPageOptions[0],
104
- // 数据总数(服务器返回)
105
- rowsNumber: 1,
106
- // 排序字段
107
- sortBy: null,
108
- // sortBy: 'id',
109
- // 是否降序排列
110
- descending: true,
111
- },
112
- // 每页显示行数选项
113
- rowsPerPageOptions,
114
- // 请求前执行
115
- requestBefore: null,
116
- // 请求成功执行
117
- requestSuccess: null,
118
- // 请求失败执行
119
- requestFail: null,
120
- // 请求后执行
121
- requestAfter: null,
122
- // 自定义请求方法
123
- request: null,
124
- // 格式化单条数据
125
- formatRow: null,
126
- // http 设置
127
- httpSettings: {},
128
- // 是否开启初始搜素
129
- search: true,
130
- // 是否开启合计
131
- summary: false,
132
- // 从参数中获取搜索值
133
- searchFromQuery: true,
134
- // 是否显示宫格
135
- showGrid: false,
136
- // 是否显示可见列
137
- showVisibleColumns: true,
138
- // 是否开启缓存
139
- cache: true,
140
- // 是否刷新后清空已选数据
141
- refreshResetSelected: true,
142
-
143
- // 单击表格行事件
144
- rowClick: null,
145
- // 双击表格行事件
146
- rowDblClick: null,
147
- }
148
-
149
- let o
150
- let $power
151
- let hasPowr
152
- let $render
153
- let $route
154
- let hasPowerBtns
155
- let tableSelected
156
- let isCache
157
- let cacheName
158
- let tableColumns
159
- let tableImgs
160
-
161
- // 是否显示可见列
162
- let tableShowVisibleColumns
163
- // 表格可见列
164
- let tableVisibleColumns
165
- // 表格加载状态
166
- let tableLoading
167
- // 表格行数据
168
- let tableRows
169
- // 表格翻页参数
170
- let tablePagination
171
- // 表格宫格
172
- let tableGrid
173
- // 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
174
- let tableRequestQuery
175
- // 是否请求表格合计
176
- let isRequestSummary
177
- // 表格合计
178
- let tableSummary
179
- // 表格选择类型
180
- let tableSelection
181
- // 表格分隔栏
182
- let tableSeparator
183
-
184
- // 原始参数
185
- let rawQuery
186
- // 原始表格搜索参数
187
- let rawSearchOptions
188
- // 原始表格搜索值(空表格搜索值, 用于搜索重置)
189
- let rawTableSearchValue
190
- // 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
191
- let firstTableSearchValue
192
-
193
- // 表格搜索数据值
194
- let tableSearchValue
195
- // 表格搜索参数
196
- let tableSearchOptions
197
- // 是否已加载
198
- let _isTableLoaded
199
-
200
- // 是否已生成数据
201
- let _isCreated = false
202
-
203
- // 创建表格
204
- reCreate(options)
205
-
206
- // 已生成数据
207
- _isCreated = true
208
-
209
- // ==========【方法】================================================================================================
210
-
211
- /**
212
- * 重新创建表格
213
- */
214
- function reCreate(options) {
215
-
216
- // 获取参数
217
- o = $n_merge({}, rawOptions, options)
218
-
219
- // 获取权限注入
220
- $power = $n_has(options, '$power') ? options.$power : (_isCreated ? $power : inject(NPowerKey))
221
- hasPowr = !! $power
222
-
223
- // 获取渲染注入
224
- $render = $n_has(options, '$render') ? options.$render : (_isCreated ? $render : inject(NRenderKey))
225
- if (!! $render) {
226
- // 如果有表格传参, 则合并参数
227
- const tableProps = $n_get($render, 'props.tableProps')
228
- if ($n_isValidObject(tableProps)) {
229
- $n_merge(o, tableProps)
230
- }
231
- }
232
-
233
- // 获取选择类型(默认 single)
234
- if (! $n_has(o, 'selection') || ! $n_isValidString(o.selection)) {
235
- if (hasPowr) {
236
- o.selection = $n_get($power, 'powerPage.data.selection')
237
- if (! $n_isValidString(o.selection)) {
238
- o.selection = 'single'
239
- }
240
- } else {
241
- o.selection = 'single'
242
- }
243
- }
244
-
245
- // 自定义参数
246
- const optionsQuery = $n_isValidObject(o.query) ? o.query : {}
247
-
248
- // 如果为自定义路由
249
- if ($n_isValidString(o.path)) {
250
- // 获取权限路由
251
- $route = $n_router.resolve({
252
- path: o.path,
253
- query: optionsQuery,
254
- })
255
- // 否则获取当前路由
256
- } else {
257
- // 获取权限路由
258
- $route = hasPowr ? $power.getRoute() : $n_router.getRoute()
259
- Object.assign($route.query, optionsQuery)
260
- }
261
-
262
- // 是否有权限按钮
263
- const _hasPowerBtns = hasPowr ? $power.powerBtns.value.length : false
264
- if (_isCreated) {
265
- hasPowerBtns.value = _hasPowerBtns
266
- } else {
267
- hasPowerBtns = ref(_hasPowerBtns)
268
- }
269
-
270
- // 表格已选数据
271
- if (hasPowr) {
272
- tableSelected = $power.tableSelected
273
- } else if (_isCreated) {
274
- tableSelected.value = []
275
- } else {
276
- tableSelected = ref([])
277
- }
278
- if ($n_isValidArray(o.selected)) {
279
- tableSelected.value = o.selected
280
- }
281
-
282
- // 是否开启缓存
283
- isCache = !! o.cache
284
-
285
- // 缓存名
286
- cacheName = $route.path ? $route.path : ($n_isValidString(o.cache) ? o.cache : '')
287
-
288
- // 表格列
289
- const _tableColumns = []
290
-
291
- // 如果有权限按钮
292
- if (hasPowerBtns.value) {
293
- // 添加操作列
294
- o.columns.push({
295
- label: '操作',
296
- name: 'settings',
297
- })
298
- }
299
-
300
- // 表格图片
301
- if (_isCreated) {
302
- tableImgs.value = []
303
- } else {
304
- tableImgs = ref([])
305
- }
306
-
307
- // 设置表格列数据
308
- // 设置列参数
309
- $n_forEach(o.columns, function(item) {
310
-
311
- if (
312
- ! $n_has(item, 'field')
313
- && $n_has(item, 'name')
314
- ) {
315
- item.field = item.name
316
- }
317
-
318
- if (! $n_has(item, 'align')) {
319
- item.align = 'left'
320
- }
321
-
322
- // 是否隐藏
323
- item.hide = $n_get(item, 'hide') === true
324
-
325
- // 如果有显示项
326
- if ($n_get(item, 'visible') !== false) {
327
- o.visibleColumns.push(item.field)
328
- }
329
-
330
- // 如果有时间戳
331
- if ($n_has(item, 'time')) {
332
- if (! $n_has(item, 'format')) {
333
- item.format = val => $n_getTime(val, { format: item.time === true ? `YYYY-MM-DD HH:mm` : item.time }, '-')
334
- }
335
-
336
- // 如果有数据字典
337
- } else if ($n_has(item, 'dict')) {
338
- if (! $n_has(item, 'format')) {
339
- item.format = val => $n_dict(item.dict, val)
340
- }
341
-
342
- // 如果有图片
343
- } else if ($n_has(item, 'img')) {
344
- tableImgs.value.push({
345
- name: item.name,
346
- count: item.img === true ? 1 : item.img,
347
- })
348
-
349
- // 如果有价格
350
- } else if ($n_has(item, 'price')) {
351
- if (! $n_has(item, 'format')) {
352
- item.format = val => $n_price(val)
353
- }
354
- }
355
-
356
- // 如果有路由
357
- if ($n_get(item, 'route')) {
358
- // 如果该值在当前路由路径中, 则显示
359
- if ($n_indexOf($route.fullPath, item.route) > -1) {
360
- _tableColumns.push(item)
361
- }
362
-
363
- } else {
364
- _tableColumns.push(item)
365
- }
366
- })
367
-
368
- // 表格可见列
369
- const _tableVisibleColumns = o.showVisibleColumns && isCache ?
370
- $n_cb($n_storage.get('table:visible_columns:' + cacheName), e => Array.isArray(e) ? e : $n_uniq([...o.visibleColumns]))
371
- : $n_uniq([...o.visibleColumns])
372
-
373
- // 表格翻页参数
374
- const _tablePagination = $route.fullPath ? o.pagination : {}
375
-
376
- // 表格宫格
377
- const _tableGrid = isCache && $n_storage.get('table:grid:' + cacheName) === true ? true : o.showGrid
378
-
379
- // 获取原始数据
380
- const r = getRawData(_tableColumns, Object.assign({}, $route.query), o.searchFromQuery)
381
- // 原始参数
382
- rawQuery = r.rawQuery
383
- // 原始表格搜索参数
384
- rawSearchOptions = r.rawSearchOptions
385
- // 原始表格搜索值(空表格搜索值, 用于搜索重置)
386
- rawTableSearchValue = r.rawTableSearchValue
387
- // 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
388
- firstTableSearchValue = r.firstTableSearchValue
389
-
390
- // 表格搜索数据值
391
- const _tableSearchValue = $route.fullPath ? firstTableSearchValue : []
392
-
393
- if (_isCreated) {
394
-
395
- // 表格列
396
- tableColumns.value = _tableColumns
397
-
398
- // 表格是否显示可见列
399
- tableShowVisibleColumns.value = o.showVisibleColumns
400
-
401
- // 表格可见列
402
- tableVisibleColumns.value = _tableVisibleColumns
403
-
404
- // 表格加载状态
405
- tableLoading.value = o.loading
406
-
407
- // 表格行数据
408
- tableRows.value = o.rows
409
-
410
- // 表格翻页参数
411
- tablePagination.value = _tablePagination
412
-
413
- // 表格宫格
414
- tableGrid.value = _tableGrid
415
-
416
- // 表格合计
417
- tableSummary.value = null
418
-
419
- // 表格选择类型
420
- tableSelection.value = o.selection
421
-
422
- // 表格分隔栏
423
- tableSeparator.value = o.separator
424
-
425
- // 表格搜索数据值
426
- tableSearchValue.value = _tableSearchValue
427
-
428
- // 表格搜索参数
429
- tableSearchOptions.value = null
430
-
431
- } else {
432
-
433
- // 表格列
434
- tableColumns = ref(_tableColumns)
435
-
436
- // 表格是否显示可见列
437
- tableShowVisibleColumns = ref(o.showVisibleColumns)
438
-
439
- // 表格可见列
440
- tableVisibleColumns = ref(_tableVisibleColumns)
441
-
442
- // 表格加载状态
443
- tableLoading = ref(o.loading)
444
-
445
- // 表格行数据
446
- tableRows = ref(o.rows)
447
-
448
- // 表格翻页参数
449
- tablePagination = ref(_tablePagination)
450
-
451
- // 表格宫格
452
- tableGrid = ref(_tableGrid)
453
-
454
- // 表格合计
455
- tableSummary = ref(null)
456
-
457
- // 表格选择类型
458
- tableSelection = ref(o.selection)
459
-
460
- // 表格分隔栏
461
- tableSeparator = ref(o.separator)
462
-
463
- // 表格搜索数据值
464
- tableSearchValue = ref(_tableSearchValue)
465
-
466
- // 表格搜索参数
467
- tableSearchOptions = ref(null)
468
- }
469
-
470
- // 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
471
- tableRequestQuery = {}
472
-
473
- // 是否请求表格合计
474
- isRequestSummary = false
475
-
476
- // 是否已加载
477
- _isTableLoaded = false
478
-
479
- // 如果开启搜索
480
- if (o.search) {
481
- // 设置表格搜索参数
482
- setTableSearchOptions()
483
- .finally()
484
- }
485
-
486
- if (_isCreated) {
487
-
488
- // 重新赋值
489
- Object.assign(resTable, {
490
- // 当前路由全路径
491
- routeFullPath: $route.fullPath,
492
- // 当前路由路径
493
- routePath: $route.path,
494
- // 当前路由参数
495
- routeQuery: $route.query,
496
- // 表格行唯一键值
497
- tableRowKey: o.rowKey,
498
- // 表格每页显示行数选项
499
- tableRowsPerPageOptions: o.rowsPerPageOptions,
500
- })
501
-
502
- if (hasPowr) {
503
- $power.update(function(data, _data) {
504
- _data.$table = resTable
505
- })
506
- }
507
- }
508
- }
509
-
510
- // ==========【计算属性】=============================================================================================
511
-
512
- /**
513
- * 固定在表格右边的权限按钮列表
514
- */
515
- const tableFixedPowerBtns = computed(function () {
516
-
517
- const lists = []
518
-
519
- if (hasPowerBtns.value) {
520
-
521
- // 先格式化权限按钮列表
522
- $n_forEach($n_$power.formatBtns($power.powerBtns.value), function(item) {
523
- // 如果是固定按钮
524
- if (item.fixed) {
525
- lists.push(item)
526
- }
527
- })
528
- }
529
-
530
- return lists
531
- })
532
-
533
- /**
534
- * 获取权限按钮中可双击的按钮
535
- */
536
- const tableDbClickPowerBtn = computed(function () {
537
- if (
538
- // 如果有权限按钮
539
- hasPowerBtns.value
540
- // 非手机模式
541
- && ! $q.platform.is.mobile
542
- // 有权限列表
543
- && $n_isValidArray($power.powerBtns.value)
544
- ) {
545
- for (const item of $power.powerBtns.value) {
546
- if ($n_has(item, 'data.dbclick') === true) {
547
- return item
548
- }
549
- }
550
- }
551
- })
552
-
553
- /**
554
- * 是否显示固定在右边的权限按钮列表
555
- */
556
- const showTableFixed = computed(function () {
557
- return $n_indexOf(tableVisibleColumns.value, 'settings') > -1
558
- })
559
-
560
- // ==========【监听数据】=============================================================================================
561
-
562
- // #if ! IS_DEV
563
-
564
- /**
565
- * 监听表格宫格模式
566
- */
567
- watch(tableGrid, function(val) {
568
- if (isCache) {
569
- // 设置宫格模式缓存(永久缓存)
570
- $n_storage.set('table:grid:' + cacheName, val, 0)
571
- }
572
- })
573
-
574
- /**
575
- * 监听表格可见列
576
- */
577
- watch(tableVisibleColumns, function(val) {
578
- if (o.showVisibleColumns && isCache) {
579
- // 设置监听表格可见列缓存(永久缓存)
580
- $n_storage.set('table:visible_columns:' + cacheName, val, 0)
581
- }
582
- })
583
-
584
- // #endif
585
-
586
- /**
587
- * 监听固定在右边的权限按钮列表
588
- */
589
- watch(tableFixedPowerBtns, function (lists) {
590
-
591
- if (! hasPowerBtns.value) {
592
- return
593
- }
594
-
595
- const index = $n_indexOf(tableVisibleColumns.value, 'settings')
596
-
597
- // 如果有固定在右边的权限按钮列表
598
- if ($n_isValidArray(lists)) {
599
-
600
- // 如果设置不在可见列中
601
- if (index === -1) {
602
-
603
- // 如果非手机模式
604
- if (! $q.platform.is.mobile) {
605
-
606
- // 则将设置加入可见列中
607
- tableVisibleColumns.value.push('settings')
608
- }
609
-
610
- // 否则在可见列中 && 如果是手机模式
611
- } else if ($q.platform.is.mobile) {
612
-
613
- // 则将设置从可见列中删除
614
- tableVisibleColumns.value.splice(index, 1)
615
- }
616
-
617
- // 否则如果设置在可见列中
618
- } else if (index > -1) {
619
-
620
- // 则将设置从可见列中删除
621
- tableVisibleColumns.value.splice(index, 1)
622
- }
623
-
624
- }, {
625
- // 立即执行
626
- immediate: true,
627
- })
628
-
629
- // ==========【方法】================================================================================================
630
-
631
- /**
632
- * 设置表格传参
633
- */
634
- function setQuery(query) {
635
-
636
- if ($n_isValidObject(query)) {
637
-
638
- query = $n_cloneDeep(query)
639
-
640
- // 搜索参数键值数组
641
- const searchQueryKey = []
642
-
643
- // 搜索键值数组
644
- const NSearchKeys = []
645
- // 搜索数组
646
- const NSearchValues = []
647
-
648
- // 参数中是否有自定义搜索参数
649
- const hasNSearch = $n_has(query, 'n_search')
650
- if (hasNSearch) {
651
- // 删除在搜索中存在的参数键值
652
- $n_forIn(query.n_search, function (item, key) {
653
- if ($n_has(query, key)) {
654
- delete query[key]
655
- }
656
- })
657
- }
658
-
659
- // 如果允许从参数中获取搜索值
660
- if (o.searchFromQuery) {
661
-
662
- $n_forEach(rawSearchOptions, function (item, index) {
663
-
664
- const valueItem = tableSearchValue.value[index]
665
-
666
- // 如果传参在搜素 n_search 参数中
667
- if (hasNSearch && $n_has(query.n_search, item.name)) {
668
- const newSearchItem = query.n_search[item.name]
669
- if ($n_isValidArray(newSearchItem)) {
670
- valueItem[0].compare = newSearchItem[0].compare
671
- valueItem[0].value = newSearchItem[0].value
672
-
673
- if (newSearchItem.length > 1) {
674
- valueItem[1].compare = newSearchItem[1].compare
675
- valueItem[1].value = newSearchItem[1].value
676
- }
677
- }
678
- // 设置搜索的 key
679
- NSearchKeys.push(item.name)
680
-
681
- // 如果传参在搜索参数中
682
- } else if ($n_has(query, item.name)) {
683
- // 设置单个搜索值
684
- setItemValue(valueItem, $n_isRequired(query[item.name]) ? query[item.name] : '')
685
- // 设置参数中搜索的 key
686
- searchQueryKey.push(item.name)
687
- }
688
- })
689
-
690
- $n_forEach(searchQueryKey, function (key) {
691
- delete query[key]
692
- })
693
-
694
- if (hasNSearch) {
695
- $n_forIn(query.n_search, function(item, key) {
696
- if (
697
- NSearchKeys.indexOf(key) === -1
698
- && $n_isValidArray(item)
699
- ) {
700
- item[0].field = key
701
- NSearchValues.push(item[0])
702
-
703
- if (item.length > 1) {
704
- item[1].field = key
705
- NSearchValues.push(item[1])
706
- }
707
- }
708
- })
709
- }
710
-
711
- } else {
712
- $n_forIn(query.n_search, function(item, key) {
713
- if ($n_isValidArray(item)) {
714
- item[0].field = key
715
- NSearchValues.push(item[0])
716
- if (item.length > 1) {
717
- item[1].field = key
718
- NSearchValues.push(item[1])
719
- }
720
- }
721
- })
722
- }
723
-
724
- if (NSearchValues.length) {
725
- query.n_search = NSearchValues
726
- } else if (hasNSearch) {
727
- delete query.n_search
728
- }
729
-
730
- tableRequestQuery = query
731
- return
732
- }
733
-
734
- tableRequestQuery = {}
735
- }
736
-
737
-
738
- /**
739
- * 表格是否已加载
740
- */
741
- function isTableLoaded() {
742
- return _isTableLoaded
743
- }
744
-
745
- /**
746
- * 表格加载(只加载一次)
747
- */
748
- async function tableLoad() {
749
-
750
- // 如果表格已加载过了
751
- if (_isTableLoaded) {
752
- // 则无任何操作
753
- return
754
- }
755
-
756
- // 表格重新加载
757
- await tableReload()
758
- }
759
-
760
- /**
761
- * 表格重新加载
762
- */
763
- async function tableReload(params = null) {
764
-
765
- // 表格已加载
766
- _isTableLoaded = true
767
-
768
- if (! $route.fullPath) {
769
- return
770
- }
771
-
772
- // 请求表格合计
773
- if (o.summary) {
774
- isRequestSummary = true
775
- }
776
-
777
- // 请求表格数据
778
- // $tableRef?.requestServerInteraction({
779
- // pagination: o.pagination,
780
- // })
781
-
782
- await tableRequest(Object.assign({
783
- pagination: o.pagination,
784
- }, params))
785
-
786
- // 清空表格已选数据
787
- if (o.refreshResetSelected) {
788
- tableSelected.value = []
789
- }
790
- }
791
-
792
- /**
793
- * 表格刷新
794
- */
795
- async function tableRefresh() {
796
-
797
- if (! $route.fullPath) {
798
- return
799
- }
800
-
801
- // 请求表格合计
802
- if (o.summary) {
803
- isRequestSummary = true
804
- }
805
-
806
- // 请求表格数据
807
- // $tableRef.requestServerInteraction()
808
- await tableRequest({
809
- pagination: tablePagination.value,
810
- })
811
-
812
- // 清空表格已选数据
813
- if (o.refreshResetSelected) {
814
- tableSelected.value = []
815
- }
816
- }
817
-
818
- /**
819
- * 表格搜索重置
820
- */
821
- function tableSearchReset(reload = true, params = null) {
822
-
823
- const newValue = []
824
-
825
- $n_forEach(rawSearchOptions, function (item, index) {
826
- // 如果该搜索条件是隐藏的
827
- if (item.hide) {
828
- newValue.push(tableSearchValue.value[index])
829
- // 否则为初始值
830
- } else {
831
- newValue.push(rawTableSearchValue[index])
832
- }
833
- })
834
-
835
- // 还原表格搜索数据
836
- tableSearchValue.value = $n_cloneDeep(newValue)
837
-
838
- // 表格重新加载
839
- if (reload) {
840
- tableReload(params)
841
- .finally()
842
- }
843
- }
844
-
845
- /**
846
- * 获取表格请求数据
847
- */
848
- function getTableRequestData(props, isSummary = undefined) {
849
-
850
- // 解构数据
851
- const {
852
- // filter,
853
- pagination: {
854
- // 页码
855
- page,
856
- // 每页的数据条数
857
- rowsPerPage,
858
- // 排序字段
859
- sortBy,
860
- // 是否降序排列
861
- descending,
862
- }
863
- } = props
864
-
865
- // 请求数据
866
- const data = {
867
- // 页码
868
- page,
869
- // 每页的数据条数
870
- per_page: rowsPerPage,
871
- }
872
-
873
- // 如果排序字段是有效值
874
- if ($n_isValidValue(sortBy)) {
875
- Object.assign(data, {
876
- // 排序字段
877
- order_by: sortBy,
878
- // 是否降序排列
879
- is_desc: descending ? 1 : 0,
880
- })
881
- }
882
-
883
- // 合并参数
884
- $n_forIn(Object.assign({}, rawQuery, tableRequestQuery, o.data), function(value, key) {
885
- // 如果有值
886
- if ($n_isRequired(value)) {
887
- data[key] = value
888
- }
889
- })
890
-
891
- // 获取搜索值
892
- const search = formatValue(rawSearchOptions, tableSearchValue.value)
893
- if ($n_isValidArray(search)) {
894
- data.n_search = $n_has(data, 'n_search') ? $n_concat(data.n_search, search) : search
895
- }
896
-
897
- if ($n_isNil(isSummary)) {
898
- isSummary = isRequestSummary
899
- }
900
-
901
- // 如果请求表格合计
902
- if (isSummary) {
903
- data.summary = 1
904
- }
905
-
906
- return data
907
- }
908
-
909
- /**
910
- * 请求数据
911
- */
912
- async function tableRequest(props) {
913
-
914
- // 加载
915
- tableLoading.value = true
916
-
917
- // 解构数据
918
- const {
919
- // filter,
920
- pagination: {
921
- // 页码
922
- page,
923
- // 每页的数据条数
924
- rowsPerPage,
925
- // 排序字段
926
- sortBy,
927
- // 是否降序排列
928
- descending,
929
- }
930
- } = props
931
-
932
- // http 请求参数
933
- let httpOptions = Object.assign({
934
- // 请求数据
935
- url: $n_isValidString(o.url) ? o.url : $route.path,
936
- // 请求数据
937
- data: getTableRequestData(props, isRequestSummary),
938
- // ~~~~~~ 先开启防抖, 如果后期遇到表格加载不出来的情况, 再关闭防抖
939
- // 关闭防抖(允许重复请求)
940
- debounce: false,
941
- }, o.httpSettings)
942
-
943
- // 下一步
944
- async function next() {
945
-
946
- const e = $n_isFunction(o.request)
947
- // 如果有自定义请求方法
948
- ? await $n_runAsync(o.request)({
949
- // http 请求参数
950
- httpOptions,
951
- // 表格声明属性
952
- props,
953
- // 表格行数据
954
- rows: tableRows,
955
- // 表格已选数据
956
- selected: tableSelected,
957
- })
958
- // 否则请求服务器
959
- : await $n_http(httpOptions)
960
-
961
- const { status, data: res } = e
962
-
963
- // 返回结果数据
964
- const resultData = Object.assign({
965
- // 请求地址
966
- requestUrl: httpOptions.url,
967
- // 参数
968
- options: httpOptions,
969
- // 请求数据
970
- requestData: httpOptions.data,
971
- }, e)
972
-
973
- // 请求后执行
974
- if (await $n_runAsync(o.requestAfter)(resultData) === false) {
975
- return
976
- }
977
-
978
- // 请求成功
979
- if (status) {
980
-
981
- // 下一步
982
- function nextSuccess() {
983
-
984
- const {
985
- // 返回数据
986
- rows,
987
- // 数据总数
988
- total,
989
- } = res
990
-
991
- // 如果请求表格合计
992
- if (isRequestSummary) {
993
- const summary = $n_get(res, 'summary')
994
- tableSummary.value = $n_isValidObject(summary) ? summary : null
995
- }
996
-
997
- // 更新页码
998
- tablePagination.value.page = page
999
- // 更新每页的数据条数
1000
- tablePagination.value.rowsPerPage = rowsPerPage
1001
- // 更新数据总数
1002
- tablePagination.value.rowsNumber = total
1003
- // 更新排序字段
1004
- tablePagination.value.sortBy = sortBy
1005
- // 更新是否降序排列
1006
- tablePagination.value.descending = descending
1007
-
1008
- // 格式化单条数据
1009
- if ($n_isFunction(o.formatRow)) {
1010
- $n_forEach(rows, function(row) {
1011
- o.formatRow({
1012
- row,
1013
- rows: tableRows,
1014
- selected: tableSelected,
1015
- })
1016
- })
1017
- }
1018
-
1019
- // 清除现有数据并添加新数据
1020
- tableRows.value.splice(0, tableRows.value.length, ...rows)
1021
-
1022
- // 取消请求表格合计
1023
- isRequestSummary = false
1024
-
1025
- // 取消加载
1026
- tableLoading.value = false
1027
- }
1028
-
1029
- // 请求成功执行
1030
- if (await $n_runAsync(o.requestSuccess)(Object.assign({ next: nextSuccess }, resultData)) === false) {
1031
- return
1032
- }
1033
-
1034
- nextSuccess()
1035
-
1036
- // 否则请求失败
1037
- } else {
1038
-
1039
- // 请求失败执行
1040
- $n_run(o.requestFail)(resultData)
1041
-
1042
- // 取消请求表格合计
1043
- isRequestSummary = false
1044
-
1045
- // 取消加载
1046
- tableLoading.value = false
1047
- }
1048
- }
1049
-
1050
- if (o.requestBefore) {
1051
-
1052
- // 请求前执行
1053
- const resBefore = await $n_runAsync(o.requestBefore)({
1054
- options: httpOptions,
1055
- next,
1056
- })
1057
- if (resBefore !== void 0) {
1058
- if (resBefore === false) {
1059
- return
1060
- }
1061
- httpOptions = resBefore
1062
- }
1063
- }
1064
-
1065
- // 下一步
1066
- next()
1067
- .finally()
1068
- }
1069
-
1070
- /**
1071
- * 单击表格行
1072
- */
1073
- function _tableRowClick(e, row) {
1074
-
1075
- // 如果选择类型为无
1076
- if (tableSelection.value === 'none') {
1077
- // 则无任何操作
1078
- return
1079
- }
1080
-
1081
- const opt = {}
1082
- opt[o.rowKey] = row[o.rowKey]
1083
-
1084
- // 获取当前数据索引
1085
- const itemIndex = $n_findIndex(tableSelected.value, opt)
1086
-
1087
- // 如果不存在, 则添加
1088
- if (itemIndex === -1) {
1089
-
1090
- // 如果选择类型为单选
1091
- if (tableSelection.value === 'single') {
1092
- tableSelected.value = [ row ]
1093
-
1094
- // 否则为多选
1095
- } else {
1096
- tableSelected.value.push(row)
1097
- }
1098
-
1099
- // 否则删除
1100
- } else {
1101
- tableSelected.value.splice(itemIndex, 1)
1102
- }
1103
- }
1104
- function tableRowClick(...e) {
1105
-
1106
- // 单击表格行
1107
- _tableRowClick(...e)
1108
-
1109
- // 如果有自定义单击事件
1110
- if ($n_isFunction(o.rowClick)) {
1111
- o.rowClick(...e)
1112
- }
1113
- }
1114
-
1115
- /**
1116
- * 双击表格行
1117
- */
1118
- function _tableRowDblclick(e, row) {
1119
-
1120
- // 如果选择类型为无
1121
- if (tableSelection.value === 'none') {
1122
- // 则无任何操作
1123
- return
1124
- }
1125
-
1126
- if (
1127
- // 有权限
1128
- hasPowr
1129
- // 有双击的权限按钮
1130
- && tableDbClickPowerBtn.value
1131
- ) {
1132
- $power.powerBtnClick(tableDbClickPowerBtn.value, [ row ])
1133
- }
1134
- }
1135
- function tableRowDblclick(...e) {
1136
-
1137
- // 双击表格行
1138
- _tableRowDblclick(...e)
1139
-
1140
- // 如果有自定义双击表格行事件
1141
- if ($n_isFunction(o.tableRowDblclick)) {
1142
- o.tableRowDblclick(...e)
1143
- }
1144
- }
1145
-
1146
- /**
1147
- * 设置表格搜索参数
1148
- */
1149
- async function setTableSearchOptions(format) {
1150
- tableSearchOptions.value = await getOptions(rawSearchOptions, format)
1151
- }
1152
-
1153
- /**
1154
- * 获取表格搜索值
1155
- */
1156
- function getTableSearchValue() {
1157
- return formatValue(rawSearchOptions, tableSearchValue.value)
1158
- }
1159
-
1160
- /**
1161
- * 是否有表格搜索值
1162
- */
1163
- // function hasTableSearchValue() {
1164
- // return !! formatValue(rawSearchOptions, tableSearchValue.value).length
1165
- // }
1166
-
1167
- // ==========【返回】=================================================================================================
1168
-
1169
- const resTable = {
1170
- // 当前路由全路径
1171
- routeFullPath: $route.fullPath,
1172
- // 当前路由路径
1173
- routePath: $route.path,
1174
- // 当前路由参数
1175
- routeQuery: $route.query,
1176
- // 表格行唯一键值
1177
- tableRowKey: o.rowKey,
1178
- // 表格每页显示行数选项
1179
- tableRowsPerPageOptions: o.rowsPerPageOptions,
1180
-
1181
- // 表格加载状态
1182
- tableLoading,
1183
- // 表格选择类型
1184
- tableSelection,
1185
- // 表格分隔栏
1186
- tableSeparator,
1187
- // 表格列数据(对象数组)
1188
- tableColumns,
1189
- // 表格是否显示可见列
1190
- tableShowVisibleColumns,
1191
- // 表格可见列
1192
- tableVisibleColumns,
1193
- // 表格行数据
1194
- tableRows,
1195
- // 表格翻页参数
1196
- tablePagination,
1197
- // 表格已选数据
1198
- tableSelected,
1199
- // 固定在右边的权限按钮列表
1200
- tableFixedPowerBtns,
1201
- // 是否显示固定在右边的权限按钮列表
1202
- showTableFixed,
1203
- // 表格图片
1204
- tableImgs,
1205
-
1206
- // 表格宫格
1207
- tableGrid,
1208
- // 表格合计
1209
- tableSummary,
1210
- // 表格搜索数据
1211
- tableSearchValue,
1212
- // 表格搜索参数
1213
- tableSearchOptions,
1214
-
1215
- // 设置表格传参
1216
- setQuery,
1217
- // 表格是否已加载
1218
- isTableLoaded,
1219
- // 表格加载(只加载一次)
1220
- tableLoad,
1221
- // 表格重新加载
1222
- tableReload,
1223
- // 表格刷新
1224
- tableRefresh,
1225
- // 表格搜索重置
1226
- tableSearchReset,
1227
- // 获取表格请求数据
1228
- getTableRequestData,
1229
- // 表格请求数据
1230
- tableRequest,
1231
- // 表格单击表格行
1232
- tableRowClick,
1233
- // 表格双击表格行
1234
- tableRowDblclick,
1235
- // 设置表格搜索参数
1236
- setTableSearchOptions,
1237
-
1238
- // 获取表格搜索值
1239
- getTableSearchValue,
1240
- // 是否有表格搜索值
1241
- // hasTableSearchValue,
1242
-
1243
- // 获取当前路由
1244
- getRoute() {
1245
- return $route
1246
- },
1247
- // 重新创建表格
1248
- reCreate,
1249
- }
1250
-
1251
- if (hasPowr) {
1252
- $power.update(function(data, _data) {
1253
- _data.$table = resTable
1254
- })
1255
- }
1256
-
1257
- // 提供可以被后代组件注入的值
1258
- provide(NTableKey, resTable)
1259
-
1260
- return resTable
1261
- }
1262
-
1263
- /**
1264
- * 获取表格配置
1265
- */
1266
- function config(routePath, path, defaultValue) {
1267
- const res = $n_get(tablesConfig, $n_slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue)
1268
- return $n_cloneDeep($n_isFunction(res) ? res() : res)
1269
- }
1270
-
1271
- /**
1272
- * 获取表格浏览数据
1273
- */
1274
- async function getViewData(options) {
1275
-
1276
- const {
1277
- url,
1278
- field,
1279
- value: httpValue,
1280
- data: httpData,
1281
- } = Object.assign({
1282
- field: 'id',
1283
- value: [],
1284
- data: {},
1285
- }, options)
1286
-
1287
- const _isValidValue = $n_isValidValue(httpValue)
1288
- if (_isValidValue || $n_isValidArray(httpValue)) {
1289
-
1290
- let per_page
1291
- let value
1292
- let compare
1293
-
1294
- if (_isValidValue) {
1295
- compare = dicts.SEARCH_COMPARE_TYPE__EQUAL
1296
- value = httpValue
1297
- per_page = 1
1298
- } else {
1299
- compare = dicts.SEARCH_COMPARE_TYPE__IN
1300
- value = $n_uniq(httpValue)
1301
- per_page = value.length
1302
- }
1303
-
1304
- const { status, data } = await $n_http({
1305
- url,
1306
- // 头部请求
1307
- headers: {
1308
- // 添加头部查看请求
1309
- Pview: 1,
1310
- },
1311
- data: Object.assign({
1312
- n_search: [
1313
- {
1314
- field,
1315
- compare,
1316
- value,
1317
- },
1318
- ],
1319
- page: 1,
1320
- per_page,
1321
- }, httpData),
1322
- })
1323
-
1324
- if (
1325
- status
1326
- && $n_isValidArray($n_get(data, 'rows'))
1327
- ) {
1328
- return data.rows
1329
- }
1330
- }
1331
-
1332
- return []
1333
- }
1334
-
1335
- /**
1336
- * 业务表格
1337
- */
1338
- const $table = {
1339
- // 创建表格
1340
- create,
1341
- // 获取表格配置
1342
- config,
1343
-
1344
- // 获取表格浏览数据
1345
- getViewData,
1346
- }
1347
-
1348
- export default $table
1
+ import { ref, computed, provide, inject, watch } from 'vue'
2
+ import { useQuasar } from 'quasar'
3
+
4
+ import $n_has from 'lodash/has'
5
+ import $n_get from 'lodash/get'
6
+ import $n_cloneDeep from 'lodash/cloneDeep'
7
+ import $n_merge from 'lodash/merge'
8
+ import $n_isFunction from 'lodash/isFunction'
9
+ import $n_findIndex from 'lodash/findIndex'
10
+ import $n_uniq from 'lodash/uniq'
11
+ import $n_concat from 'lodash/concat'
12
+ import $n_isNil from 'lodash/isNil'
13
+
14
+ import $n_router from '@netang/utils/vue/router'
15
+
16
+ import $n_forEach from '@netang/utils/forEach'
17
+ import $n_isValidArray from '@netang/utils/isValidArray'
18
+ import $n_isValidString from '@netang/utils/isValidString'
19
+ import $n_indexOf from '@netang/utils/indexOf'
20
+ import $n_storage from '@netang/utils/storage'
21
+
22
+ import $n_isRequired from '@netang/utils/isRequired'
23
+ import $n_forIn from '@netang/utils/forIn'
24
+ import $n_run from '@netang/utils/run'
25
+ import $n_runAsync from '@netang/utils/runAsync'
26
+ import $n_isValidObject from '@netang/utils/isValidObject'
27
+ import $n_isValidValue from '@netang/utils/isValidValue'
28
+ import $n_slash from '@netang/utils/slash'
29
+ import $n_http from '@netang/utils/http'
30
+ import $n_cb from '@netang/utils/cb'
31
+
32
+ import $n_$power from './$power'
33
+ import $n_dict from './dict'
34
+ import $n_price from './price'
35
+ import $n_getTime from './getTime'
36
+
37
+ import { configs } from './config'
38
+
39
+ import {
40
+ // 设置单个搜索值
41
+ setItemValue,
42
+ // 从表格列获取原始值
43
+ getRawData,
44
+ // 获取参数
45
+ getOptions,
46
+ // 格式化值
47
+ formatValue,
48
+ } from './useSearch'
49
+
50
+ import { NRenderKey, NPowerKey, NTableKey } from './symbols'
51
+
52
+ const {
53
+ // 表格配置
54
+ tablesConfig,
55
+ // 字典常量
56
+ dicts,
57
+ } = configs
58
+
59
+ /**
60
+ * 创建表格
61
+ */
62
+ function create(options) {
63
+
64
+ // ==========【数据】=================================================================================================
65
+
66
+ // quasar 对象
67
+ const $q = useQuasar()
68
+
69
+ // 每页显示行数选项
70
+ const rowsPerPageOptions = [30, 40, 50, 100, 200, 500, 1000]
71
+
72
+ // 原始参数
73
+ const rawOptions = {
74
+ // 路由路径
75
+ path: '',
76
+ // 请求地址(默认为 path)
77
+ url: '',
78
+ // 路由参数
79
+ query: {},
80
+ // 附加请求数据
81
+ data: {},
82
+ // 表格行唯一键值
83
+ rowKey: 'id',
84
+ // 选择类型, 可选值 none single(默认) multiple
85
+ // selection: '',
86
+ // 分隔栏, 可选值 horizontal vertical cell none
87
+ separator: 'cell',
88
+ // 初始已选数据
89
+ selected: [],
90
+ // 初始表格加载状态
91
+ loading: false,
92
+ // 表格列数据(对象数组)
93
+ columns: [],
94
+ // 初始可见列
95
+ visibleColumns: [],
96
+ // 表格行数据
97
+ rows: [],
98
+ // 表格翻页参数
99
+ pagination: {
100
+ // 页码
101
+ page: 1,
102
+ // 每页的数据条数
103
+ rowsPerPage: $n_has(options, 'rowsPerPageOptions') ? options.rowsPerPageOptions[0] : rowsPerPageOptions[0],
104
+ // 数据总数(服务器返回)
105
+ rowsNumber: 1,
106
+ // 排序字段
107
+ sortBy: null,
108
+ // sortBy: 'id',
109
+ // 是否降序排列
110
+ descending: true,
111
+ },
112
+ // 每页显示行数选项
113
+ rowsPerPageOptions,
114
+ // 请求前执行
115
+ requestBefore: null,
116
+ // 请求成功执行
117
+ requestSuccess: null,
118
+ // 请求失败执行
119
+ requestFail: null,
120
+ // 请求后执行
121
+ requestAfter: null,
122
+ // 自定义请求方法
123
+ request: null,
124
+ // 格式化单条数据
125
+ formatRow: null,
126
+ // http 设置
127
+ httpSettings: {},
128
+ // 是否开启初始搜素
129
+ search: true,
130
+ // 是否开启合计
131
+ summary: false,
132
+ // 从参数中获取搜索值
133
+ searchFromQuery: true,
134
+ // 是否显示宫格
135
+ showGrid: false,
136
+ // 是否显示可见列
137
+ showVisibleColumns: true,
138
+ // 是否开启缓存
139
+ cache: true,
140
+ // 是否刷新后清空已选数据
141
+ refreshResetSelected: true,
142
+
143
+ // 单击表格行事件
144
+ rowClick: null,
145
+ // 双击表格行事件
146
+ rowDblClick: null,
147
+ }
148
+
149
+ let o
150
+ let $power
151
+ let hasPowr
152
+ let $render
153
+ let $route
154
+ let hasPowerBtns
155
+ let tableSelected
156
+ let isCache
157
+ let cacheName
158
+ let tableColumns
159
+ let tableImgs
160
+
161
+ // 是否显示可见列
162
+ let tableShowVisibleColumns
163
+ // 表格可见列
164
+ let tableVisibleColumns
165
+ // 表格加载状态
166
+ let tableLoading
167
+ // 表格行数据
168
+ let tableRows
169
+ // 表格翻页参数
170
+ let tablePagination
171
+ // 表格宫格
172
+ let tableGrid
173
+ // 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
174
+ let tableRequestQuery
175
+ // 是否请求表格合计
176
+ let isRequestSummary
177
+ // 表格合计
178
+ let tableSummary
179
+ // 表格选择类型
180
+ let tableSelection
181
+ // 表格分隔栏
182
+ let tableSeparator
183
+
184
+ // 原始参数
185
+ let rawQuery
186
+ // 原始表格搜索参数
187
+ let rawSearchOptions
188
+ // 原始表格搜索值(空表格搜索值, 用于搜索重置)
189
+ let rawTableSearchValue
190
+ // 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
191
+ let firstTableSearchValue
192
+
193
+ // 表格搜索数据值
194
+ let tableSearchValue
195
+ // 表格搜索参数
196
+ let tableSearchOptions
197
+ // 是否已加载
198
+ let _isTableLoaded
199
+
200
+ // 是否已生成数据
201
+ let _isCreated = false
202
+
203
+ // 创建表格
204
+ reCreate(options)
205
+
206
+ // 已生成数据
207
+ _isCreated = true
208
+
209
+ // ==========【方法】================================================================================================
210
+
211
+ /**
212
+ * 重新创建表格
213
+ */
214
+ function reCreate(options) {
215
+
216
+ // 获取参数
217
+ o = $n_merge({}, rawOptions, options)
218
+
219
+ // 获取权限注入
220
+ $power = $n_has(options, '$power') ? options.$power : (_isCreated ? $power : inject(NPowerKey))
221
+ hasPowr = !! $power
222
+
223
+ // 获取渲染注入
224
+ $render = $n_has(options, '$render') ? options.$render : (_isCreated ? $render : inject(NRenderKey))
225
+ if (!! $render) {
226
+ // 如果有表格传参, 则合并参数
227
+ const tableProps = $n_get($render, 'props.tableProps')
228
+ if ($n_isValidObject(tableProps)) {
229
+ $n_merge(o, tableProps)
230
+ }
231
+ }
232
+
233
+ // 获取选择类型(默认 single)
234
+ if (! $n_has(o, 'selection') || ! $n_isValidString(o.selection)) {
235
+ if (hasPowr) {
236
+ o.selection = $n_get($power, 'powerPage.data.selection')
237
+ if (! $n_isValidString(o.selection)) {
238
+ o.selection = 'single'
239
+ }
240
+ } else {
241
+ o.selection = 'single'
242
+ }
243
+ }
244
+
245
+ // 自定义参数
246
+ const optionsQuery = $n_isValidObject(o.query) ? o.query : {}
247
+
248
+ // 如果为自定义路由
249
+ if ($n_isValidString(o.path)) {
250
+ // 获取权限路由
251
+ $route = $n_router.resolve({
252
+ path: o.path,
253
+ query: optionsQuery,
254
+ })
255
+ // 否则获取当前路由
256
+ } else {
257
+ // 获取权限路由
258
+ $route = hasPowr ? $power.getRoute() : $n_router.getRoute()
259
+ Object.assign($route.query, optionsQuery)
260
+ }
261
+
262
+ // 是否有权限按钮
263
+ const _hasPowerBtns = hasPowr ? $power.powerBtns.value.length : false
264
+ if (_isCreated) {
265
+ hasPowerBtns.value = _hasPowerBtns
266
+ } else {
267
+ hasPowerBtns = ref(_hasPowerBtns)
268
+ }
269
+
270
+ // 表格已选数据
271
+ if (hasPowr) {
272
+ tableSelected = $power.tableSelected
273
+ } else if (_isCreated) {
274
+ tableSelected.value = []
275
+ } else {
276
+ tableSelected = ref([])
277
+ }
278
+ if ($n_isValidArray(o.selected)) {
279
+ tableSelected.value = o.selected
280
+ }
281
+
282
+ // 是否开启缓存
283
+ isCache = !! o.cache
284
+
285
+ // 缓存名
286
+ cacheName = $route.path ? $route.path : ($n_isValidString(o.cache) ? o.cache : '')
287
+
288
+ // 表格列
289
+ const _tableColumns = []
290
+
291
+ // 如果有权限按钮
292
+ if (hasPowerBtns.value) {
293
+ // 添加操作列
294
+ o.columns.push({
295
+ label: '操作',
296
+ name: 'settings',
297
+ })
298
+ }
299
+
300
+ // 表格图片
301
+ if (_isCreated) {
302
+ tableImgs.value = []
303
+ } else {
304
+ tableImgs = ref([])
305
+ }
306
+
307
+ // 设置表格列数据
308
+ // 设置列参数
309
+ $n_forEach(o.columns, function(item) {
310
+
311
+ if (
312
+ ! $n_has(item, 'field')
313
+ && $n_has(item, 'name')
314
+ ) {
315
+ item.field = item.name
316
+ }
317
+
318
+ if (! $n_has(item, 'align')) {
319
+ item.align = 'left'
320
+ }
321
+
322
+ // 是否隐藏
323
+ item.hide = $n_get(item, 'hide') === true
324
+
325
+ // 如果有显示项
326
+ if ($n_get(item, 'visible') !== false) {
327
+ o.visibleColumns.push(item.field)
328
+ }
329
+
330
+ // 如果有时间戳
331
+ if ($n_has(item, 'time')) {
332
+ if (! $n_has(item, 'format')) {
333
+ item.format = val => $n_getTime(val, { format: item.time === true ? `YYYY-MM-DD HH:mm` : item.time }, '-')
334
+ }
335
+
336
+ // 如果有数据字典
337
+ } else if ($n_has(item, 'dict')) {
338
+ if (! $n_has(item, 'format')) {
339
+ item.format = val => $n_dict(item.dict, val)
340
+ }
341
+
342
+ // 如果有图片
343
+ } else if ($n_has(item, 'img')) {
344
+ tableImgs.value.push({
345
+ name: item.name,
346
+ count: item.img === true ? 1 : item.img,
347
+ })
348
+
349
+ // 如果有价格
350
+ } else if ($n_has(item, 'price')) {
351
+ if (! $n_has(item, 'format')) {
352
+ item.format = val => $n_price(val)
353
+ }
354
+ }
355
+
356
+ // 如果有路由
357
+ if ($n_get(item, 'route')) {
358
+ // 如果该值在当前路由路径中, 则显示
359
+ if ($n_indexOf($route.fullPath, item.route) > -1) {
360
+ _tableColumns.push(item)
361
+ }
362
+
363
+ } else {
364
+ _tableColumns.push(item)
365
+ }
366
+ })
367
+
368
+ // 表格可见列
369
+ const _tableVisibleColumns = o.showVisibleColumns && isCache ?
370
+ $n_cb($n_storage.get('table:visible_columns:' + cacheName), e => Array.isArray(e) ? e : $n_uniq([...o.visibleColumns]))
371
+ : $n_uniq([...o.visibleColumns])
372
+
373
+ // 表格翻页参数
374
+ const _tablePagination = $route.fullPath ? o.pagination : {}
375
+
376
+ // 表格宫格
377
+ const _tableGrid = isCache && $n_storage.get('table:grid:' + cacheName) === true ? true : o.showGrid
378
+
379
+ // 获取原始数据
380
+ const r = getRawData(_tableColumns, Object.assign({}, $route.query), o.searchFromQuery)
381
+
382
+ console.log('-----r', $n.cloneDeep(r.firstTableSearchValue))
383
+
384
+ // 原始参数
385
+ rawQuery = r.rawQuery
386
+ // 原始表格搜索参数
387
+ rawSearchOptions = r.rawSearchOptions
388
+ // 原始表格搜索值(空表格搜索值, 用于搜索重置)
389
+ rawTableSearchValue = r.rawTableSearchValue
390
+ // 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
391
+ firstTableSearchValue = r.firstTableSearchValue
392
+
393
+ // 表格搜索数据值
394
+ const _tableSearchValue = $route.fullPath ? firstTableSearchValue : []
395
+
396
+ if (_isCreated) {
397
+
398
+ // 表格列
399
+ tableColumns.value = _tableColumns
400
+
401
+ // 表格是否显示可见列
402
+ tableShowVisibleColumns.value = o.showVisibleColumns
403
+
404
+ // 表格可见列
405
+ tableVisibleColumns.value = _tableVisibleColumns
406
+
407
+ // 表格加载状态
408
+ tableLoading.value = o.loading
409
+
410
+ // 表格行数据
411
+ tableRows.value = o.rows
412
+
413
+ // 表格翻页参数
414
+ tablePagination.value = _tablePagination
415
+
416
+ // 表格宫格
417
+ tableGrid.value = _tableGrid
418
+
419
+ // 表格合计
420
+ tableSummary.value = null
421
+
422
+ // 表格选择类型
423
+ tableSelection.value = o.selection
424
+
425
+ // 表格分隔栏
426
+ tableSeparator.value = o.separator
427
+
428
+ // 表格搜索数据值
429
+ tableSearchValue.value = _tableSearchValue
430
+
431
+ // 表格搜索参数
432
+ tableSearchOptions.value = null
433
+
434
+ } else {
435
+
436
+ // 表格列
437
+ tableColumns = ref(_tableColumns)
438
+
439
+ // 表格是否显示可见列
440
+ tableShowVisibleColumns = ref(o.showVisibleColumns)
441
+
442
+ // 表格可见列
443
+ tableVisibleColumns = ref(_tableVisibleColumns)
444
+
445
+ // 表格加载状态
446
+ tableLoading = ref(o.loading)
447
+
448
+ // 表格行数据
449
+ tableRows = ref(o.rows)
450
+
451
+ // 表格翻页参数
452
+ tablePagination = ref(_tablePagination)
453
+
454
+ // 表格宫格
455
+ tableGrid = ref(_tableGrid)
456
+
457
+ // 表格合计
458
+ tableSummary = ref(null)
459
+
460
+ // 表格选择类型
461
+ tableSelection = ref(o.selection)
462
+
463
+ // 表格分隔栏
464
+ tableSeparator = ref(o.separator)
465
+
466
+ // 表格搜索数据值
467
+ tableSearchValue = ref(_tableSearchValue)
468
+
469
+ // 表格搜索参数
470
+ tableSearchOptions = ref(null)
471
+ }
472
+
473
+ // 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
474
+ tableRequestQuery = {}
475
+
476
+ // 是否请求表格合计
477
+ isRequestSummary = false
478
+
479
+ // 是否已加载
480
+ _isTableLoaded = false
481
+
482
+ // 如果开启搜索
483
+ if (o.search) {
484
+ // 设置表格搜索参数
485
+ setTableSearchOptions()
486
+ .finally()
487
+ }
488
+
489
+ if (_isCreated) {
490
+
491
+ // 重新赋值
492
+ Object.assign(resTable, {
493
+ // 当前路由全路径
494
+ routeFullPath: $route.fullPath,
495
+ // 当前路由路径
496
+ routePath: $route.path,
497
+ // 当前路由参数
498
+ routeQuery: $route.query,
499
+ // 表格行唯一键值
500
+ tableRowKey: o.rowKey,
501
+ // 表格每页显示行数选项
502
+ tableRowsPerPageOptions: o.rowsPerPageOptions,
503
+ })
504
+
505
+ if (hasPowr) {
506
+ $power.update(function(data, _data) {
507
+ _data.$table = resTable
508
+ })
509
+ }
510
+ }
511
+ }
512
+
513
+ // ==========【计算属性】=============================================================================================
514
+
515
+ /**
516
+ * 固定在表格右边的权限按钮列表
517
+ */
518
+ const tableFixedPowerBtns = computed(function () {
519
+
520
+ const lists = []
521
+
522
+ if (hasPowerBtns.value) {
523
+
524
+ // 先格式化权限按钮列表
525
+ $n_forEach($n_$power.formatBtns($power.powerBtns.value), function(item) {
526
+ // 如果是固定按钮
527
+ if (item.fixed) {
528
+ lists.push(item)
529
+ }
530
+ })
531
+ }
532
+
533
+ return lists
534
+ })
535
+
536
+ /**
537
+ * 获取权限按钮中可双击的按钮
538
+ */
539
+ const tableDbClickPowerBtn = computed(function () {
540
+ if (
541
+ // 如果有权限按钮
542
+ hasPowerBtns.value
543
+ // 非手机模式
544
+ && ! $q.platform.is.mobile
545
+ // 有权限列表
546
+ && $n_isValidArray($power.powerBtns.value)
547
+ ) {
548
+ for (const item of $power.powerBtns.value) {
549
+ if ($n_has(item, 'data.dbclick') === true) {
550
+ return item
551
+ }
552
+ }
553
+ }
554
+ })
555
+
556
+ /**
557
+ * 是否显示固定在右边的权限按钮列表
558
+ */
559
+ const showTableFixed = computed(function () {
560
+ return $n_indexOf(tableVisibleColumns.value, 'settings') > -1
561
+ })
562
+
563
+ // ==========【监听数据】=============================================================================================
564
+
565
+ // #if ! IS_DEV
566
+
567
+ /**
568
+ * 监听表格宫格模式
569
+ */
570
+ watch(tableGrid, function(val) {
571
+ if (isCache) {
572
+ // 设置宫格模式缓存(永久缓存)
573
+ $n_storage.set('table:grid:' + cacheName, val, 0)
574
+ }
575
+ })
576
+
577
+ /**
578
+ * 监听表格可见列
579
+ */
580
+ watch(tableVisibleColumns, function(val) {
581
+ if (o.showVisibleColumns && isCache) {
582
+ // 设置监听表格可见列缓存(永久缓存)
583
+ $n_storage.set('table:visible_columns:' + cacheName, val, 0)
584
+ }
585
+ })
586
+
587
+ // #endif
588
+
589
+ /**
590
+ * 监听固定在右边的权限按钮列表
591
+ */
592
+ watch(tableFixedPowerBtns, function (lists) {
593
+
594
+ if (! hasPowerBtns.value) {
595
+ return
596
+ }
597
+
598
+ const index = $n_indexOf(tableVisibleColumns.value, 'settings')
599
+
600
+ // 如果有固定在右边的权限按钮列表
601
+ if ($n_isValidArray(lists)) {
602
+
603
+ // 如果设置不在可见列中
604
+ if (index === -1) {
605
+
606
+ // 如果非手机模式
607
+ if (! $q.platform.is.mobile) {
608
+
609
+ // 则将设置加入可见列中
610
+ tableVisibleColumns.value.push('settings')
611
+ }
612
+
613
+ // 否则在可见列中 && 如果是手机模式
614
+ } else if ($q.platform.is.mobile) {
615
+
616
+ // 则将设置从可见列中删除
617
+ tableVisibleColumns.value.splice(index, 1)
618
+ }
619
+
620
+ // 否则如果设置在可见列中
621
+ } else if (index > -1) {
622
+
623
+ // 则将设置从可见列中删除
624
+ tableVisibleColumns.value.splice(index, 1)
625
+ }
626
+
627
+ }, {
628
+ // 立即执行
629
+ immediate: true,
630
+ })
631
+
632
+ // ==========【方法】================================================================================================
633
+
634
+ /**
635
+ * 设置表格传参
636
+ */
637
+ function setQuery(query) {
638
+
639
+ if ($n_isValidObject(query)) {
640
+
641
+ query = $n_cloneDeep(query)
642
+
643
+ // 搜索参数键值数组
644
+ const searchQueryKey = []
645
+
646
+ // 搜索键值数组
647
+ const NSearchKeys = []
648
+ // 搜索数组
649
+ const NSearchValues = []
650
+
651
+ // 参数中是否有自定义搜索参数
652
+ const hasNSearch = $n_has(query, 'n_search')
653
+ if (hasNSearch) {
654
+ // 删除在搜索中存在的参数键值
655
+ $n_forIn(query.n_search, function (item, key) {
656
+ if ($n_has(query, key)) {
657
+ delete query[key]
658
+ }
659
+ })
660
+ }
661
+
662
+ // 如果允许从参数中获取搜索值
663
+ if (o.searchFromQuery) {
664
+
665
+ $n_forEach(rawSearchOptions, function (item, index) {
666
+
667
+ const valueItem = tableSearchValue.value[index]
668
+
669
+ // 如果传参在搜素 n_search 参数中
670
+ if (hasNSearch && $n_has(query.n_search, item.name)) {
671
+ const newSearchItem = query.n_search[item.name]
672
+ if ($n_isValidArray(newSearchItem)) {
673
+ valueItem[0].compare = newSearchItem[0].compare
674
+ valueItem[0].value = newSearchItem[0].value
675
+
676
+ if (newSearchItem.length > 1) {
677
+ valueItem[1].compare = newSearchItem[1].compare
678
+ valueItem[1].value = newSearchItem[1].value
679
+ }
680
+ }
681
+ // 设置搜索的 key
682
+ NSearchKeys.push(item.name)
683
+
684
+ // 如果传参在搜索参数中
685
+ } else if ($n_has(query, item.name)) {
686
+ // 设置单个搜索值
687
+ setItemValue(valueItem, $n_isRequired(query[item.name]) ? query[item.name] : '')
688
+ // 设置参数中搜索的 key
689
+ searchQueryKey.push(item.name)
690
+ }
691
+ })
692
+
693
+ $n_forEach(searchQueryKey, function (key) {
694
+ delete query[key]
695
+ })
696
+
697
+ if (hasNSearch) {
698
+ $n_forIn(query.n_search, function(item, key) {
699
+ if (
700
+ NSearchKeys.indexOf(key) === -1
701
+ && $n_isValidArray(item)
702
+ ) {
703
+ item[0].field = key
704
+ NSearchValues.push(item[0])
705
+
706
+ if (item.length > 1) {
707
+ item[1].field = key
708
+ NSearchValues.push(item[1])
709
+ }
710
+ }
711
+ })
712
+ }
713
+
714
+ } else {
715
+ $n_forIn(query.n_search, function(item, key) {
716
+ if ($n_isValidArray(item)) {
717
+ item[0].field = key
718
+ NSearchValues.push(item[0])
719
+ if (item.length > 1) {
720
+ item[1].field = key
721
+ NSearchValues.push(item[1])
722
+ }
723
+ }
724
+ })
725
+ }
726
+
727
+ if (NSearchValues.length) {
728
+ query.n_search = NSearchValues
729
+ } else if (hasNSearch) {
730
+ delete query.n_search
731
+ }
732
+
733
+ tableRequestQuery = query
734
+ return
735
+ }
736
+
737
+ tableRequestQuery = {}
738
+ }
739
+
740
+
741
+ /**
742
+ * 表格是否已加载
743
+ */
744
+ function isTableLoaded() {
745
+ return _isTableLoaded
746
+ }
747
+
748
+ /**
749
+ * 表格加载(只加载一次)
750
+ */
751
+ async function tableLoad() {
752
+
753
+ // 如果表格已加载过了
754
+ if (_isTableLoaded) {
755
+ // 则无任何操作
756
+ return
757
+ }
758
+
759
+ // 表格重新加载
760
+ await tableReload()
761
+ }
762
+
763
+ /**
764
+ * 表格重新加载
765
+ */
766
+ async function tableReload(params = null) {
767
+
768
+ // 表格已加载
769
+ _isTableLoaded = true
770
+
771
+ if (! $route.fullPath) {
772
+ return
773
+ }
774
+
775
+ // 请求表格合计
776
+ if (o.summary) {
777
+ isRequestSummary = true
778
+ }
779
+
780
+ // 请求表格数据
781
+ // $tableRef?.requestServerInteraction({
782
+ // pagination: o.pagination,
783
+ // })
784
+
785
+ await tableRequest(Object.assign({
786
+ pagination: o.pagination,
787
+ }, params))
788
+
789
+ // 清空表格已选数据
790
+ if (o.refreshResetSelected) {
791
+ tableSelected.value = []
792
+ }
793
+ }
794
+
795
+ /**
796
+ * 表格刷新
797
+ */
798
+ async function tableRefresh() {
799
+
800
+ if (! $route.fullPath) {
801
+ return
802
+ }
803
+
804
+ // 请求表格合计
805
+ if (o.summary) {
806
+ isRequestSummary = true
807
+ }
808
+
809
+ // 请求表格数据
810
+ // $tableRef.requestServerInteraction()
811
+ await tableRequest({
812
+ pagination: tablePagination.value,
813
+ })
814
+
815
+ // 清空表格已选数据
816
+ if (o.refreshResetSelected) {
817
+ tableSelected.value = []
818
+ }
819
+ }
820
+
821
+ /**
822
+ * 表格搜索重置
823
+ */
824
+ function tableSearchReset(reload = true, params = null) {
825
+
826
+ const newValue = []
827
+
828
+ $n_forEach(rawSearchOptions, function (item, index) {
829
+ // 如果该搜索条件是隐藏的
830
+ if (item.hide) {
831
+ newValue.push(tableSearchValue.value[index])
832
+ // 否则为初始值
833
+ } else {
834
+ newValue.push(rawTableSearchValue[index])
835
+ }
836
+ })
837
+
838
+ // 还原表格搜索数据
839
+ tableSearchValue.value = $n_cloneDeep(newValue)
840
+
841
+ // 表格重新加载
842
+ if (reload) {
843
+ tableReload(params)
844
+ .finally()
845
+ }
846
+ }
847
+
848
+ /**
849
+ * 获取表格请求数据
850
+ */
851
+ function getTableRequestData(props, isSummary = undefined) {
852
+
853
+ // 解构数据
854
+ const {
855
+ // filter,
856
+ pagination: {
857
+ // 页码
858
+ page,
859
+ // 每页的数据条数
860
+ rowsPerPage,
861
+ // 排序字段
862
+ sortBy,
863
+ // 是否降序排列
864
+ descending,
865
+ }
866
+ } = props
867
+
868
+ // 请求数据
869
+ const data = {
870
+ // 页码
871
+ page,
872
+ // 每页的数据条数
873
+ per_page: rowsPerPage,
874
+ }
875
+
876
+ // 如果排序字段是有效值
877
+ if ($n_isValidValue(sortBy)) {
878
+ Object.assign(data, {
879
+ // 排序字段
880
+ order_by: sortBy,
881
+ // 是否降序排列
882
+ is_desc: descending ? 1 : 0,
883
+ })
884
+ }
885
+
886
+ // 合并参数
887
+ $n_forIn(Object.assign({}, rawQuery, tableRequestQuery, o.data), function(value, key) {
888
+ // 如果有值
889
+ if ($n_isRequired(value)) {
890
+ data[key] = value
891
+ }
892
+ })
893
+
894
+ // 获取搜索值
895
+ const search = formatValue(rawSearchOptions, tableSearchValue.value)
896
+ if ($n_isValidArray(search)) {
897
+ data.n_search = $n_has(data, 'n_search') ? $n_concat(data.n_search, search) : search
898
+ }
899
+
900
+ if ($n_isNil(isSummary)) {
901
+ isSummary = isRequestSummary
902
+ }
903
+
904
+ // 如果请求表格合计
905
+ if (isSummary) {
906
+ data.summary = 1
907
+ }
908
+
909
+ return data
910
+ }
911
+
912
+ /**
913
+ * 请求数据
914
+ */
915
+ async function tableRequest(props) {
916
+
917
+ // 加载
918
+ tableLoading.value = true
919
+
920
+ // 解构数据
921
+ const {
922
+ // filter,
923
+ pagination: {
924
+ // 页码
925
+ page,
926
+ // 每页的数据条数
927
+ rowsPerPage,
928
+ // 排序字段
929
+ sortBy,
930
+ // 是否降序排列
931
+ descending,
932
+ }
933
+ } = props
934
+
935
+ // http 请求参数
936
+ let httpOptions = Object.assign({
937
+ // 请求数据
938
+ url: $n_isValidString(o.url) ? o.url : $route.path,
939
+ // 请求数据
940
+ data: getTableRequestData(props, isRequestSummary),
941
+ // ~~~~~~ 先开启防抖, 如果后期遇到表格加载不出来的情况, 再关闭防抖
942
+ // 关闭防抖(允许重复请求)
943
+ debounce: false,
944
+ }, o.httpSettings)
945
+
946
+ // 下一步
947
+ async function next() {
948
+
949
+ const e = $n_isFunction(o.request)
950
+ // 如果有自定义请求方法
951
+ ? await $n_runAsync(o.request)({
952
+ // http 请求参数
953
+ httpOptions,
954
+ // 表格声明属性
955
+ props,
956
+ // 表格行数据
957
+ rows: tableRows,
958
+ // 表格已选数据
959
+ selected: tableSelected,
960
+ })
961
+ // 否则请求服务器
962
+ : await $n_http(httpOptions)
963
+
964
+ const { status, data: res } = e
965
+
966
+ // 返回结果数据
967
+ const resultData = Object.assign({
968
+ // 请求地址
969
+ requestUrl: httpOptions.url,
970
+ // 参数
971
+ options: httpOptions,
972
+ // 请求数据
973
+ requestData: httpOptions.data,
974
+ }, e)
975
+
976
+ // 请求后执行
977
+ if (await $n_runAsync(o.requestAfter)(resultData) === false) {
978
+ return
979
+ }
980
+
981
+ // 请求成功
982
+ if (status) {
983
+
984
+ // 下一步
985
+ function nextSuccess() {
986
+
987
+ const {
988
+ // 返回数据
989
+ rows,
990
+ // 数据总数
991
+ total,
992
+ } = res
993
+
994
+ // 如果请求表格合计
995
+ if (isRequestSummary) {
996
+ const summary = $n_get(res, 'summary')
997
+ tableSummary.value = $n_isValidObject(summary) ? summary : null
998
+ }
999
+
1000
+ // 更新页码
1001
+ tablePagination.value.page = page
1002
+ // 更新每页的数据条数
1003
+ tablePagination.value.rowsPerPage = rowsPerPage
1004
+ // 更新数据总数
1005
+ tablePagination.value.rowsNumber = total
1006
+ // 更新排序字段
1007
+ tablePagination.value.sortBy = sortBy
1008
+ // 更新是否降序排列
1009
+ tablePagination.value.descending = descending
1010
+
1011
+ // 格式化单条数据
1012
+ if ($n_isFunction(o.formatRow)) {
1013
+ $n_forEach(rows, function(row) {
1014
+ o.formatRow({
1015
+ row,
1016
+ rows: tableRows,
1017
+ selected: tableSelected,
1018
+ })
1019
+ })
1020
+ }
1021
+
1022
+ // 清除现有数据并添加新数据
1023
+ tableRows.value.splice(0, tableRows.value.length, ...rows)
1024
+
1025
+ // 取消请求表格合计
1026
+ isRequestSummary = false
1027
+
1028
+ // 取消加载
1029
+ tableLoading.value = false
1030
+ }
1031
+
1032
+ // 请求成功执行
1033
+ if (await $n_runAsync(o.requestSuccess)(Object.assign({ next: nextSuccess }, resultData)) === false) {
1034
+ return
1035
+ }
1036
+
1037
+ nextSuccess()
1038
+
1039
+ // 否则请求失败
1040
+ } else {
1041
+
1042
+ // 请求失败执行
1043
+ $n_run(o.requestFail)(resultData)
1044
+
1045
+ // 取消请求表格合计
1046
+ isRequestSummary = false
1047
+
1048
+ // 取消加载
1049
+ tableLoading.value = false
1050
+ }
1051
+ }
1052
+
1053
+ if (o.requestBefore) {
1054
+
1055
+ // 请求前执行
1056
+ const resBefore = await $n_runAsync(o.requestBefore)({
1057
+ options: httpOptions,
1058
+ next,
1059
+ })
1060
+ if (resBefore !== void 0) {
1061
+ if (resBefore === false) {
1062
+ return
1063
+ }
1064
+ httpOptions = resBefore
1065
+ }
1066
+ }
1067
+
1068
+ // 下一步
1069
+ next()
1070
+ .finally()
1071
+ }
1072
+
1073
+ /**
1074
+ * 单击表格行
1075
+ */
1076
+ function _tableRowClick(e, row) {
1077
+
1078
+ // 如果选择类型为无
1079
+ if (tableSelection.value === 'none') {
1080
+ // 则无任何操作
1081
+ return
1082
+ }
1083
+
1084
+ const opt = {}
1085
+ opt[o.rowKey] = row[o.rowKey]
1086
+
1087
+ // 获取当前数据索引
1088
+ const itemIndex = $n_findIndex(tableSelected.value, opt)
1089
+
1090
+ // 如果不存在, 则添加
1091
+ if (itemIndex === -1) {
1092
+
1093
+ // 如果选择类型为单选
1094
+ if (tableSelection.value === 'single') {
1095
+ tableSelected.value = [ row ]
1096
+
1097
+ // 否则为多选
1098
+ } else {
1099
+ tableSelected.value.push(row)
1100
+ }
1101
+
1102
+ // 否则删除
1103
+ } else {
1104
+ tableSelected.value.splice(itemIndex, 1)
1105
+ }
1106
+ }
1107
+ function tableRowClick(...e) {
1108
+
1109
+ // 单击表格行
1110
+ _tableRowClick(...e)
1111
+
1112
+ // 如果有自定义单击事件
1113
+ if ($n_isFunction(o.rowClick)) {
1114
+ o.rowClick(...e)
1115
+ }
1116
+ }
1117
+
1118
+ /**
1119
+ * 双击表格行
1120
+ */
1121
+ function _tableRowDblclick(e, row) {
1122
+
1123
+ // 如果选择类型为无
1124
+ if (tableSelection.value === 'none') {
1125
+ // 则无任何操作
1126
+ return
1127
+ }
1128
+
1129
+ if (
1130
+ // 有权限
1131
+ hasPowr
1132
+ // 有双击的权限按钮
1133
+ && tableDbClickPowerBtn.value
1134
+ ) {
1135
+ $power.powerBtnClick(tableDbClickPowerBtn.value, [ row ])
1136
+ }
1137
+ }
1138
+ function tableRowDblclick(...e) {
1139
+
1140
+ // 双击表格行
1141
+ _tableRowDblclick(...e)
1142
+
1143
+ // 如果有自定义双击表格行事件
1144
+ if ($n_isFunction(o.tableRowDblclick)) {
1145
+ o.tableRowDblclick(...e)
1146
+ }
1147
+ }
1148
+
1149
+ /**
1150
+ * 设置表格搜索参数
1151
+ */
1152
+ async function setTableSearchOptions(format) {
1153
+ tableSearchOptions.value = await getOptions(rawSearchOptions, format)
1154
+ }
1155
+
1156
+ /**
1157
+ * 获取表格搜索值
1158
+ */
1159
+ function getTableSearchValue() {
1160
+ return formatValue(rawSearchOptions, tableSearchValue.value)
1161
+ }
1162
+
1163
+ /**
1164
+ * 是否有表格搜索值
1165
+ */
1166
+ // function hasTableSearchValue() {
1167
+ // return !! formatValue(rawSearchOptions, tableSearchValue.value).length
1168
+ // }
1169
+
1170
+ // ==========【返回】=================================================================================================
1171
+
1172
+ const resTable = {
1173
+ // 当前路由全路径
1174
+ routeFullPath: $route.fullPath,
1175
+ // 当前路由路径
1176
+ routePath: $route.path,
1177
+ // 当前路由参数
1178
+ routeQuery: $route.query,
1179
+ // 表格行唯一键值
1180
+ tableRowKey: o.rowKey,
1181
+ // 表格每页显示行数选项
1182
+ tableRowsPerPageOptions: o.rowsPerPageOptions,
1183
+
1184
+ // 表格加载状态
1185
+ tableLoading,
1186
+ // 表格选择类型
1187
+ tableSelection,
1188
+ // 表格分隔栏
1189
+ tableSeparator,
1190
+ // 表格列数据(对象数组)
1191
+ tableColumns,
1192
+ // 表格是否显示可见列
1193
+ tableShowVisibleColumns,
1194
+ // 表格可见列
1195
+ tableVisibleColumns,
1196
+ // 表格行数据
1197
+ tableRows,
1198
+ // 表格翻页参数
1199
+ tablePagination,
1200
+ // 表格已选数据
1201
+ tableSelected,
1202
+ // 固定在右边的权限按钮列表
1203
+ tableFixedPowerBtns,
1204
+ // 是否显示固定在右边的权限按钮列表
1205
+ showTableFixed,
1206
+ // 表格图片
1207
+ tableImgs,
1208
+
1209
+ // 表格宫格
1210
+ tableGrid,
1211
+ // 表格合计
1212
+ tableSummary,
1213
+ // 表格搜索数据
1214
+ tableSearchValue,
1215
+ // 表格搜索参数
1216
+ tableSearchOptions,
1217
+
1218
+ // 设置表格传参
1219
+ setQuery,
1220
+ // 表格是否已加载
1221
+ isTableLoaded,
1222
+ // 表格加载(只加载一次)
1223
+ tableLoad,
1224
+ // 表格重新加载
1225
+ tableReload,
1226
+ // 表格刷新
1227
+ tableRefresh,
1228
+ // 表格搜索重置
1229
+ tableSearchReset,
1230
+ // 获取表格请求数据
1231
+ getTableRequestData,
1232
+ // 表格请求数据
1233
+ tableRequest,
1234
+ // 表格单击表格行
1235
+ tableRowClick,
1236
+ // 表格双击表格行
1237
+ tableRowDblclick,
1238
+ // 设置表格搜索参数
1239
+ setTableSearchOptions,
1240
+
1241
+ // 获取表格搜索值
1242
+ getTableSearchValue,
1243
+ // 是否有表格搜索值
1244
+ // hasTableSearchValue,
1245
+
1246
+ // 获取当前路由
1247
+ getRoute() {
1248
+ return $route
1249
+ },
1250
+ // 重新创建表格
1251
+ reCreate,
1252
+ }
1253
+
1254
+ if (hasPowr) {
1255
+ $power.update(function(data, _data) {
1256
+ _data.$table = resTable
1257
+ })
1258
+ }
1259
+
1260
+ // 提供可以被后代组件注入的值
1261
+ provide(NTableKey, resTable)
1262
+
1263
+ return resTable
1264
+ }
1265
+
1266
+ /**
1267
+ * 获取表格配置
1268
+ */
1269
+ function config(routePath, path, defaultValue) {
1270
+ const res = $n_get(tablesConfig, $n_slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue)
1271
+ return $n_cloneDeep($n_isFunction(res) ? res() : res)
1272
+ }
1273
+
1274
+ /**
1275
+ * 获取表格浏览数据
1276
+ */
1277
+ async function getViewData(options) {
1278
+
1279
+ const {
1280
+ url,
1281
+ field,
1282
+ value: httpValue,
1283
+ data: httpData,
1284
+ } = Object.assign({
1285
+ field: 'id',
1286
+ value: [],
1287
+ data: {},
1288
+ }, options)
1289
+
1290
+ const _isValidValue = $n_isValidValue(httpValue)
1291
+ if (_isValidValue || $n_isValidArray(httpValue)) {
1292
+
1293
+ let per_page
1294
+ let value
1295
+ let compare
1296
+
1297
+ if (_isValidValue) {
1298
+ compare = dicts.SEARCH_COMPARE_TYPE__EQUAL
1299
+ value = httpValue
1300
+ per_page = 1
1301
+ } else {
1302
+ compare = dicts.SEARCH_COMPARE_TYPE__IN
1303
+ value = $n_uniq(httpValue)
1304
+ per_page = value.length
1305
+ }
1306
+
1307
+ const { status, data } = await $n_http({
1308
+ url,
1309
+ // 头部请求
1310
+ headers: {
1311
+ // 添加头部查看请求
1312
+ Pview: 1,
1313
+ },
1314
+ data: Object.assign({
1315
+ n_search: [
1316
+ {
1317
+ field,
1318
+ compare,
1319
+ value,
1320
+ },
1321
+ ],
1322
+ page: 1,
1323
+ per_page,
1324
+ }, httpData),
1325
+ })
1326
+
1327
+ if (
1328
+ status
1329
+ && $n_isValidArray($n_get(data, 'rows'))
1330
+ ) {
1331
+ return data.rows
1332
+ }
1333
+ }
1334
+
1335
+ return []
1336
+ }
1337
+
1338
+ /**
1339
+ * 业务表格
1340
+ */
1341
+ const $table = {
1342
+ // 创建表格
1343
+ create,
1344
+ // 获取表格配置
1345
+ config,
1346
+
1347
+ // 获取表格浏览数据
1348
+ getViewData,
1349
+ }
1350
+
1351
+ export default $table