@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.
- package/.editorconfig +12 -12
- package/_docs/docs/components/field-table.md +58 -58
- package/_docs/docs/components/field-tree.md +21 -21
- package/_docs/docs/components/table.md +24 -24
- package/_docs/docs/utils/table.md +196 -196
- package/components/column-title/index.vue +38 -38
- package/components/data/index.vue +20 -20
- package/components/dialog/img-viewer/index.vue +697 -697
- package/components/dialog/index.vue +387 -387
- package/components/dragger/index.vue +203 -203
- package/components/drawer/index.vue +303 -303
- package/components/editor-code/index.vue +328 -328
- package/components/empty/index.vue +82 -82
- package/components/field-date/index.vue +860 -860
- package/components/field-date/methods.js +100 -100
- package/components/field-table/index.vue +1483 -1483
- package/components/field-text/index.vue +166 -166
- package/components/field-tree/index.vue +755 -755
- package/components/img/index.vue +279 -279
- package/components/input-number/index.vue +560 -560
- package/components/list-menu/index.vue +149 -149
- package/components/list-menu-item/index.vue +79 -79
- package/components/mixed-table/index.vue +532 -532
- package/components/mixed-table-splitter/index.vue +377 -377
- package/components/power-page/index.vue +96 -96
- package/components/price/index.vue +188 -188
- package/components/private/components/index.js +11 -11
- package/components/private/components/move-to-tree/index.vue +154 -154
- package/components/private/edit-power-data/index.vue +846 -846
- package/components/private/table-visible-columns-button/index.vue +114 -114
- package/components/render/index.vue +123 -123
- package/components/search/index.vue +231 -231
- package/components/search-item/index.vue +210 -210
- package/components/select/index.vue +177 -177
- package/components/splitter/index.vue +422 -422
- package/components/table/index.vue +513 -513
- package/components/table-column-fixed/index.vue +110 -110
- package/components/table-pagination/index.vue +192 -192
- package/components/table-summary/index.vue +107 -107
- package/components/thumbnail/index.vue +72 -72
- package/components/toolbar/index.vue +150 -150
- package/components/tree/index.vue +1728 -1728
- package/components/tree/virtual-scroll.vue +41 -41
- package/components/uploader/index.vue +196 -196
- package/components/uploader-query/index.vue +945 -945
- package/components/value-format/index.vue +274 -274
- package/components/virtual-scroll/index.vue +136 -136
- package/configs/area3.js +1 -1
- package/docs/404.html +33 -33
- package/docs/assets/404.html-60b35caa.js +1 -1
- package/docs/assets/404.html-d1e63d77.js +1 -1
- package/docs/assets/alert.html-b2a2a72f.js +5 -5
- package/docs/assets/alert.html-ba46d137.js +1 -1
- package/docs/assets/app-9f30aa4b.js +6 -6
- package/docs/assets/area.html-01b9b58d.js +42 -42
- package/docs/assets/area.html-9a4fce6a.js +1 -1
- package/docs/assets/arr.html-145d27e7.js +1 -1
- package/docs/assets/arr.html-674e65ab.js +11 -11
- package/docs/assets/auth.html-579fa830.js +1 -1
- package/docs/assets/auth.html-8544ed95.js +8 -8
- package/docs/assets/bus.html-c71254aa.js +1 -1
- package/docs/assets/bus.html-dc7d3d19.js +6 -6
- package/docs/assets/column-title.html-c735cb5a.js +3 -3
- package/docs/assets/column-title.html-e9316762.js +1 -1
- package/docs/assets/confirm.html-ddfdc27f.js +10 -10
- package/docs/assets/confirm.html-ef3e2bef.js +1 -1
- package/docs/assets/copy.html-d20345b6.js +1 -1
- package/docs/assets/copy.html-ef8c8571.js +13 -13
- package/docs/assets/data.html-6432175d.js +30 -30
- package/docs/assets/data.html-a3b05d5b.js +1 -1
- package/docs/assets/dialog.html-1f698e5a.js +1 -1
- package/docs/assets/dialog.html-62902b83.js +68 -68
- package/docs/assets/dialog.html-baea77c9.js +1 -1
- package/docs/assets/dialog.html-bb082fc4.js +1 -1
- package/docs/assets/dict.html-1311da3d.js +23 -23
- package/docs/assets/dict.html-b96fbf0c.js +1 -1
- package/docs/assets/dictOptions.html-7c4f40a5.js +1 -1
- package/docs/assets/dictOptions.html-fb99d175.js +5 -5
- package/docs/assets/dragger.html-668d3efa.js +1 -1
- package/docs/assets/dragger.html-749d585a.js +1 -1
- package/docs/assets/editor-code.html-6ab26ea9.js +1 -1
- package/docs/assets/editor-code.html-d196205d.js +1 -1
- package/docs/assets/empty.html-1c139131.js +1 -1
- package/docs/assets/empty.html-1e9c441d.js +1 -1
- package/docs/assets/field-date.html-069fdb13.js +1 -1
- package/docs/assets/field-date.html-ad204aa9.js +1 -1
- package/docs/assets/field-table.html-ce480f03.js +1 -1
- package/docs/assets/field-table.html-d9236160.js +1 -1
- package/docs/assets/field-text.html-7277c62f.js +1 -1
- package/docs/assets/field-text.html-ccb4cecf.js +1 -1
- package/docs/assets/field-tree.html-519bfb45.js +1 -1
- package/docs/assets/field-tree.html-fdc748d6.js +1 -1
- package/docs/assets/form.html-2b562c37.js +2 -2
- package/docs/assets/form.html-75104cd5.js +1 -1
- package/docs/assets/framework-204010b2.js +5 -5
- package/docs/assets/getData.html-990e3787.js +1 -1
- package/docs/assets/getData.html-bb72025f.js +34 -34
- package/docs/assets/getFile.html-42368004.js +1 -1
- package/docs/assets/getFile.html-99abd054.js +3 -3
- package/docs/assets/getImage.html-3429c5a1.js +1 -1
- package/docs/assets/getImage.html-4d886d83.js +3 -3
- package/docs/assets/getTime.html-7435f922.js +1 -1
- package/docs/assets/getTime.html-b37f49eb.js +20 -20
- package/docs/assets/img.html-7d1da657.js +1 -1
- package/docs/assets/img.html-fbea1105.js +1 -1
- package/docs/assets/index.html-1695dd7c.js +1 -1
- package/docs/assets/index.html-65a4aa67.js +1 -1
- package/docs/assets/index.html-7b98d5bd.js +1 -1
- package/docs/assets/index.html-c01f2648.js +1 -1
- package/docs/assets/input-number.html-0b250d2a.js +1 -1
- package/docs/assets/input-number.html-a8eb0378.js +1 -1
- package/docs/assets/list-menu-item.html-7f1b4611.js +1 -1
- package/docs/assets/list-menu-item.html-84ed5ab8.js +1 -1
- package/docs/assets/list-menu.html-28b4163f.js +1 -1
- package/docs/assets/list-menu.html-cb6ba95b.js +1 -1
- package/docs/assets/loading.html-dae9e39d.js +6 -6
- package/docs/assets/loading.html-dc74c9e6.js +1 -1
- package/docs/assets/notify.html-e6c4c514.js +1 -1
- package/docs/assets/notify.html-f2c4d914.js +8 -8
- package/docs/assets/power-page.html-32e02f82.js +1 -1
- package/docs/assets/power-page.html-485e77da.js +1 -1
- package/docs/assets/power.html-d258cc19.js +93 -93
- package/docs/assets/power.html-e490bd32.js +1 -1
- package/docs/assets/previewImage.html-6a6b4245.js +1 -1
- package/docs/assets/previewImage.html-c5b7e945.js +2 -2
- package/docs/assets/price.html-1882c548.js +19 -19
- package/docs/assets/price.html-94d3f5be.js +1 -1
- package/docs/assets/price.html-d213df0f.js +1 -1
- package/docs/assets/price.html-deaf880f.js +1 -1
- package/docs/assets/render.html-8efcbdd4.js +1 -1
- package/docs/assets/render.html-df228e38.js +1 -1
- package/docs/assets/rule.html-2cd57fc2.js +13 -13
- package/docs/assets/rule.html-61662001.js +1 -1
- package/docs/assets/ruleValid.html-04fe2552.js +1 -1
- package/docs/assets/ruleValid.html-e0a776af.js +14 -14
- package/docs/assets/search-0782d0d1.svg +1 -1
- package/docs/assets/search-item.html-3f75394c.js +1 -1
- package/docs/assets/search-item.html-4e942ecd.js +1 -1
- package/docs/assets/search.html-2807043e.js +1 -1
- package/docs/assets/search.html-c24f8806.js +1 -1
- package/docs/assets/select.html-00d0607c.js +1 -1
- package/docs/assets/select.html-de7731f5.js +1 -1
- package/docs/assets/splitter.html-56f51a70.js +1 -1
- package/docs/assets/splitter.html-f5c836d7.js +1 -1
- package/docs/assets/style-161e43ab.css +1 -1
- package/docs/assets/symbols.html-a6aea4bf.js +1 -1
- package/docs/assets/symbols.html-b1f65bad.js +21 -21
- package/docs/assets/table-column-fixed.html-3a69e7b2.js +1 -1
- package/docs/assets/table-column-fixed.html-e763c38b.js +1 -1
- package/docs/assets/table-pagination.html-236934d3.js +1 -1
- package/docs/assets/table-pagination.html-c37ee2ac.js +1 -1
- package/docs/assets/table-splitter.html-07eab15c.js +1 -1
- package/docs/assets/table-splitter.html-7670ee65.js +1 -1
- package/docs/assets/table-summary.html-04db434f.js +1 -1
- package/docs/assets/table-summary.html-943c65a0.js +1 -1
- package/docs/assets/table.html-36253ad7.js +1 -1
- package/docs/assets/table.html-7f9c5d1b.js +38 -38
- package/docs/assets/table.html-93d53dc8.js +1 -1
- package/docs/assets/table.html-ac99b9cb.js +1 -1
- package/docs/assets/thumbnail.html-bab1976b.js +1 -1
- package/docs/assets/thumbnail.html-eb64e5e8.js +1 -1
- package/docs/assets/timestamp.html-4e54f79b.js +13 -13
- package/docs/assets/timestamp.html-d0e1b88a.js +1 -1
- package/docs/assets/toast.html-58ecbe21.js +1 -1
- package/docs/assets/toast.html-c9b9d36b.js +6 -6
- package/docs/assets/toolbar.html-83d9f97c.js +1 -1
- package/docs/assets/toolbar.html-ff7b8c92.js +1 -1
- package/docs/assets/tree.html-d07cbe79.js +23 -23
- package/docs/assets/tree.html-ea04193e.js +1 -1
- package/docs/assets/uploader-query.html-05590718.js +1 -1
- package/docs/assets/uploader-query.html-3175bac5.js +1 -1
- package/docs/assets/uploader.html-36da4394.js +2 -2
- package/docs/assets/uploader.html-6b5f3079.js +1 -1
- package/docs/assets/uploader.html-b9340b57.js +1 -1
- package/docs/assets/uploader.html-bc1c22e3.js +1 -1
- package/docs/assets/value-format.html-8ae3d47d.js +1 -1
- package/docs/assets/value-format.html-afa99b3d.js +1 -1
- package/docs/components/column-title.html +35 -35
- package/docs/components/data.html +62 -62
- package/docs/components/dialog.html +33 -33
- package/docs/components/dragger.html +33 -33
- package/docs/components/editor-code.html +33 -33
- package/docs/components/empty.html +33 -33
- package/docs/components/field-date.html +33 -33
- package/docs/components/field-table.html +33 -33
- package/docs/components/field-text.html +33 -33
- package/docs/components/field-tree.html +33 -33
- package/docs/components/img.html +33 -33
- package/docs/components/input-number.html +33 -33
- package/docs/components/list-menu-item.html +33 -33
- package/docs/components/list-menu.html +33 -33
- package/docs/components/power-page.html +33 -33
- package/docs/components/price.html +33 -33
- package/docs/components/render.html +33 -33
- package/docs/components/search-item.html +33 -33
- package/docs/components/search.html +33 -33
- package/docs/components/select.html +33 -33
- package/docs/components/splitter.html +33 -33
- package/docs/components/table-column-fixed.html +33 -33
- package/docs/components/table-pagination.html +33 -33
- package/docs/components/table-splitter.html +33 -33
- package/docs/components/table-summary.html +33 -33
- package/docs/components/table.html +33 -33
- package/docs/components/thumbnail.html +33 -33
- package/docs/components/toolbar.html +33 -33
- package/docs/components/uploader-query.html +33 -33
- package/docs/components/uploader.html +33 -33
- package/docs/components/value-format.html +33 -33
- package/docs/css/index.css +3 -3
- package/docs/index.html +33 -33
- package/docs/utils/alert.html +37 -37
- package/docs/utils/area.html +74 -74
- package/docs/utils/arr.html +43 -43
- package/docs/utils/auth.html +40 -40
- package/docs/utils/bus.html +38 -38
- package/docs/utils/confirm.html +42 -42
- package/docs/utils/copy.html +45 -45
- package/docs/utils/dialog.html +100 -100
- package/docs/utils/dict.html +55 -55
- package/docs/utils/dictOptions.html +37 -37
- package/docs/utils/form.html +34 -34
- package/docs/utils/getData.html +66 -66
- package/docs/utils/getFile.html +35 -35
- package/docs/utils/getImage.html +35 -35
- package/docs/utils/getTime.html +52 -52
- package/docs/utils/index.html +33 -33
- package/docs/utils/loading.html +38 -38
- package/docs/utils/notify.html +40 -40
- package/docs/utils/power.html +125 -125
- package/docs/utils/previewImage.html +34 -34
- package/docs/utils/price.html +51 -51
- package/docs/utils/rule.html +45 -45
- package/docs/utils/ruleValid.html +46 -46
- package/docs/utils/symbols.html +53 -53
- package/docs/utils/table.html +70 -70
- package/docs/utils/timestamp.html +45 -45
- package/docs/utils/toast.html +38 -38
- package/docs/utils/tree.html +55 -55
- package/docs/utils/uploader.html +34 -34
- package/package.json +25 -25
- package/sass/common.scss +184 -184
- package/sass/index.scss +12 -12
- package/sass/line.scss +39 -39
- package/sass/quasar/btn.scss +46 -46
- package/sass/quasar/common.scss +3 -3
- package/sass/quasar/drawer.scss +6 -6
- package/sass/quasar/field.scss +259 -259
- package/sass/quasar/loading.scss +6 -6
- package/sass/quasar/table.scss +168 -168
- package/sass/quasar/toolbar.scss +22 -22
- package/sass/variables.scss +140 -140
- package/store/index.js +29 -29
- package/utils/$auth.js +128 -128
- package/utils/$form.js +72 -72
- package/utils/$power.js +1494 -1494
- package/utils/$render.js +75 -75
- package/utils/$rule.js +13 -13
- package/utils/$ruleValid.js +10 -10
- package/utils/$search.js +416 -416
- package/utils/$table.js +1351 -1348
- package/utils/$tree.js +682 -682
- package/utils/alert.js +12 -12
- package/utils/area.js +400 -400
- package/utils/arr.js +51 -51
- package/utils/bus.js +6 -6
- package/utils/config.js +66 -66
- package/utils/confirm.js +11 -11
- package/utils/copy.js +30 -30
- package/utils/dialog.js +36 -36
- package/utils/dict.js +21 -21
- package/utils/dictOptions.js +28 -28
- package/utils/getData.js +88 -88
- package/utils/getFile.js +67 -67
- package/utils/getImage.js +276 -276
- package/utils/getTime.js +113 -113
- package/utils/index.js +67 -67
- package/utils/loading.js +15 -15
- package/utils/notify.js +13 -13
- package/utils/play.js +40 -40
- package/utils/previewImage.js +14 -14
- package/utils/price.js +18 -18
- package/utils/symbols.js +18 -18
- package/utils/timestamp.js +18 -18
- package/utils/toast.js +13 -13
- package/utils/uploader.js +2114 -2114
- package/utils/useAuth.js +30 -30
- package/utils/useFileUrl.js +26 -26
- package/utils/useRouter.js +47 -47
- 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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
//
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
//
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
//
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
//
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
//
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
//
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
//
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
//
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
//
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
//
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
//
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
//
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
//
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
//
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
//
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
//
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
//
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
//
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
//
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
//
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
//
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
//
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
//
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
//
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
//
|
|
830
|
-
|
|
831
|
-
newValue.push(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
//
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
//
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
//
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
//
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
//
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
//
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
//
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
//
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
//
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
//
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
//
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
//
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
//
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
//
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
//
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
//
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
//
|
|
1242
|
-
|
|
1243
|
-
//
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
//
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
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
|