@wp1001/ui 2.9.13
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/.env +6 -0
- package/@vant-D4fmGxs6.js +3891 -0
- package/index.js +8419 -0
- package/package.json +59 -0
- package/packages/assets/devtools-detector.js +2 -0
- package/packages/components/xarray/index.js +64 -0
- package/packages/components/xarray/xarray.vue +57 -0
- package/packages/components/xautorows/index.js +35 -0
- package/packages/components/xautorows/xautorows.vue +29 -0
- package/packages/components/xbutton/mobile.js +3 -0
- package/packages/components/xbutton/mobile.vue +9 -0
- package/packages/components/xbutton/pc.js +3 -0
- package/packages/components/xbutton/pc.vue +9 -0
- package/packages/components/xbuttons/mobile.js +51 -0
- package/packages/components/xbuttons/mobile.vue +12 -0
- package/packages/components/xbuttons/pc.js +51 -0
- package/packages/components/xbuttons/pc.vue +16 -0
- package/packages/components/xchart/constants.js +58 -0
- package/packages/components/xchart/index.js +263 -0
- package/packages/components/xchart/utils.js +121 -0
- package/packages/components/xchart/xchart.vue +173 -0
- package/packages/components/xcheckboxs/mobile.js +58 -0
- package/packages/components/xcheckboxs/mobile.vue +38 -0
- package/packages/components/xcheckboxs/pc.js +49 -0
- package/packages/components/xcheckboxs/pc.vue +42 -0
- package/packages/components/xcol/mobile.js +10 -0
- package/packages/components/xcol/mobile.vue +9 -0
- package/packages/components/xcol/pc.js +10 -0
- package/packages/components/xcol/pc.vue +9 -0
- package/packages/components/xdatepicker/mobile.js +71 -0
- package/packages/components/xdatepicker/mobile.vue +44 -0
- package/packages/components/xdatepicker/pc.js +9 -0
- package/packages/components/xdatepicker/pc.vue +12 -0
- package/packages/components/xdialog/mobile.js +60 -0
- package/packages/components/xdialog/mobile.vue +43 -0
- package/packages/components/xdialog/pc.js +64 -0
- package/packages/components/xdialog/pc.vue +51 -0
- package/packages/components/xdict/index.js +47 -0
- package/packages/components/xdict/xdict.vue +9 -0
- package/packages/components/xdistrictselect/mobile.js +79 -0
- package/packages/components/xdistrictselect/mobile.vue +28 -0
- package/packages/components/xdistrictselect/pc.js +127 -0
- package/packages/components/xdistrictselect/pc.vue +32 -0
- package/packages/components/xform/mobile.js +29 -0
- package/packages/components/xform/mobile.vue +43 -0
- package/packages/components/xform/pc.js +42 -0
- package/packages/components/xform/pc.vue +76 -0
- package/packages/components/xform/utils.js +95 -0
- package/packages/components/xformitem/mobile.js +56 -0
- package/packages/components/xformitem/mobile.vue +3 -0
- package/packages/components/xformitem/pc.js +72 -0
- package/packages/components/xformitem/pc.vue +10 -0
- package/packages/components/xformitem/utils.jsx +181 -0
- package/packages/components/xicon/mobile.js +35 -0
- package/packages/components/xicon/mobile.vue +9 -0
- package/packages/components/xicon/pc.js +35 -0
- package/packages/components/xicon/pc.vue +11 -0
- package/packages/components/xinfo/index.js +100 -0
- package/packages/components/xinfo/xinfo.vue +140 -0
- package/packages/components/xlooper/index.js +7 -0
- package/packages/components/xlooper/xlooper.vue +20 -0
- package/packages/components/xpagination/mobile.js +21 -0
- package/packages/components/xpagination/mobile.vue +31 -0
- package/packages/components/xpagination/pc.js +21 -0
- package/packages/components/xpagination/pc.vue +16 -0
- package/packages/components/xpicker/index.js +38 -0
- package/packages/components/xpicker/xpicker.vue +29 -0
- package/packages/components/xradios/mobile.js +40 -0
- package/packages/components/xradios/mobile.vue +22 -0
- package/packages/components/xradios/pc.js +53 -0
- package/packages/components/xradios/pc.vue +43 -0
- package/packages/components/xrow/mobile.js +9 -0
- package/packages/components/xrow/mobile.vue +23 -0
- package/packages/components/xrow/pc.js +9 -0
- package/packages/components/xrow/pc.vue +22 -0
- package/packages/components/xscan/mobile.js +24 -0
- package/packages/components/xscan/mobile.vue +21 -0
- package/packages/components/xscan/pc.js +20 -0
- package/packages/components/xscan/pc.vue +18 -0
- package/packages/components/xsearcher/index.js +198 -0
- package/packages/components/xsearcher/xsearcher.vue +170 -0
- package/packages/components/xselect/mobile.js +86 -0
- package/packages/components/xselect/mobile.vue +24 -0
- package/packages/components/xselect/pc.js +114 -0
- package/packages/components/xselect/pc.vue +55 -0
- package/packages/components/xselect/util.js +66 -0
- package/packages/components/xselectv2/index.js +91 -0
- package/packages/components/xselectv2/xselectv2.vue +46 -0
- package/packages/components/xtable/mobile.js +108 -0
- package/packages/components/xtable/mobile.vue +246 -0
- package/packages/components/xtable/pc.js +143 -0
- package/packages/components/xtable/pc.vue +421 -0
- package/packages/components/xtable/searcher.js +477 -0
- package/packages/components/xtable/searcher.jsx +330 -0
- package/packages/components/xtable/searcher.vue +133 -0
- package/packages/components/xtable/settings.js +80 -0
- package/packages/components/xtable/settings.vue +77 -0
- package/packages/components/xtable/utils.js +692 -0
- package/packages/components/xtabletools/mobile.js +25 -0
- package/packages/components/xtabletools/mobile.vue +126 -0
- package/packages/components/xtabletools/pc.js +18 -0
- package/packages/components/xtabletools/pc.vue +135 -0
- package/packages/components/xtablev2/index.js +53 -0
- package/packages/components/xtablev2/utils.jsx +214 -0
- package/packages/components/xtablev2/xtablev2.vue +147 -0
- package/packages/components/xtags/mobile.js +17 -0
- package/packages/components/xtags/mobile.vue +21 -0
- package/packages/components/xtags/pc.js +17 -0
- package/packages/components/xtags/pc.vue +22 -0
- package/packages/components/xtinymce/index.js +71 -0
- package/packages/components/xtinymce/xtinymce.vue +9 -0
- package/packages/components/xuploader/xfileuploader.js +48 -0
- package/packages/components/xuploader/xfileuploader.vue +54 -0
- package/packages/components/xuploader/ximageuploader.js +53 -0
- package/packages/components/xuploader/ximageuploader.vue +52 -0
- package/packages/comps.js +108 -0
- package/packages/controllers/BaseController.js +125 -0
- package/packages/controllers/CrudController.js +907 -0
- package/packages/controllers/TempCrudController.js +32 -0
- package/packages/controllers/index.js +15 -0
- package/packages/directives/el-table-infinite-scroll.js +55 -0
- package/packages/directives/index.js +5 -0
- package/packages/index.js +81 -0
- package/packages/index.scss +4 -0
- package/packages/layout/breadcrumb/breadcrumb.vue +31 -0
- package/packages/layout/breadcrumb/index.js +41 -0
- package/packages/layout/header/header.vue +281 -0
- package/packages/layout/header/inner.js +11 -0
- package/packages/layout/header/inner.vue +3 -0
- package/packages/layout/mobile-menu.vue +83 -0
- package/packages/layout/mobile-tabs.vue +54 -0
- package/packages/layout/pc.vue +85 -0
- package/packages/layout/screenlock/index.js +129 -0
- package/packages/layout/screenlock/screenlock.vue +85 -0
- package/packages/layout/sidebar/item.js +16 -0
- package/packages/layout/sidebar/item.vue +16 -0
- package/packages/layout/sidebar/menu.js +72 -0
- package/packages/layout/sidebar/menu.vue +106 -0
- package/packages/layout/sidebar/sidebar.vue +147 -0
- package/packages/layout/tagsview/ScrollPane.js +65 -0
- package/packages/layout/tagsview/ScrollPane.vue +24 -0
- package/packages/layout/tagsview/index.js +169 -0
- package/packages/layout/tagsview/index.vue +124 -0
- package/packages/plop/actions/make-fill-admin-partials-action.js +95 -0
- package/packages/plop/generators/make-admin-page.js +39 -0
- package/packages/plop/generators/make-database-admin-pages.js +84 -0
- package/packages/plop/generators/make-page-generator.js +52 -0
- package/packages/plop/generators/make-simple-page.js +20 -0
- package/packages/plop/plopfile.js +24 -0
- package/packages/plop/templates/admin_page/controller.js +3 -0
- package/packages/plop/templates/admin_page/model.js +24 -0
- package/packages/plop/templates/admin_page/{{snakeCase pagename}}-scoped.scss +3 -0
- package/packages/plop/templates/admin_page/{{snakeCase pagename}}.vue +11 -0
- package/packages/plop/templates/simple_page/controller.js +3 -0
- package/packages/plop/templates/simple_page/model.js +6 -0
- package/packages/plop/templates/simple_page/{{snakeCase pagename}}-scoped.scss +3 -0
- package/packages/plop/templates/simple_page/{{snakeCase pagename}}.vue +7 -0
- package/packages/plop/utils/index.js +168 -0
- package/packages/plop/utils/plop-utils.js +86 -0
- package/packages/styles/common.scss +137 -0
- package/packages/styles/element-ui.scss +142 -0
- package/packages/styles/vant.scss +133 -0
- package/packages/styles/variables.scss +23 -0
- package/packages/utils/crypt.js +24 -0
- package/packages/utils/decorators.js +67 -0
- package/packages/utils/disallowDevtools.js +53 -0
- package/packages/utils/effects.js +173 -0
- package/packages/utils/funcs.js +78 -0
- package/packages/utils/index.js +95 -0
- package/packages/utils/message.js +110 -0
- package/packages/utils/middlewares.js +86 -0
- package/packages/utils/model.js +71 -0
- package/packages/utils/modelUtils.js +203 -0
- package/packages/utils/request.js +57 -0
- package/packages/utils/site.js +33 -0
- package/packages/vite-plugins.js +141 -0
- package/publish.sh +12 -0
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
import { getUrlType, getFiletypeIcon } from '../../utils/funcs.js'
|
|
2
|
+
|
|
3
|
+
const { highdict } = StardustJs
|
|
4
|
+
const { storage } = StardustBrowser
|
|
5
|
+
|
|
6
|
+
const { local } = storage
|
|
7
|
+
|
|
8
|
+
const TYPES = ['index', 'selection', 'expand', 'radio', '_index']
|
|
9
|
+
|
|
10
|
+
export function props () {
|
|
11
|
+
return {
|
|
12
|
+
table: Object,
|
|
13
|
+
loading: Boolean,
|
|
14
|
+
data: Array,
|
|
15
|
+
columns: Array,
|
|
16
|
+
query: Object,
|
|
17
|
+
total: Number,
|
|
18
|
+
finished: Boolean,
|
|
19
|
+
selection: Array,
|
|
20
|
+
chartHeight: String,
|
|
21
|
+
chartOption: Object,
|
|
22
|
+
tref: Object,
|
|
23
|
+
defaultValue: '',
|
|
24
|
+
slotAll: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
onSelectionChange: Function,
|
|
29
|
+
onSortChange: Function,
|
|
30
|
+
onHeaderDragend: Function,
|
|
31
|
+
onCheckedChange: Function,
|
|
32
|
+
onKeywordsSearch: Function,
|
|
33
|
+
onSearch: Function,
|
|
34
|
+
onAdd: Function,
|
|
35
|
+
onEdit: Function,
|
|
36
|
+
onDelete: Function,
|
|
37
|
+
onRowEdit: Function,
|
|
38
|
+
onCancelEdit: Function,
|
|
39
|
+
onExport: Function,
|
|
40
|
+
onSearchExport: Function,
|
|
41
|
+
onImport: Function,
|
|
42
|
+
onMultiDelete: Function,
|
|
43
|
+
onLoad: Function,
|
|
44
|
+
|
|
45
|
+
controller: Object,
|
|
46
|
+
listen: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: '*'
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
actions: {
|
|
52
|
+
type: Array,
|
|
53
|
+
default: () => []
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
title: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: '表格'
|
|
59
|
+
},
|
|
60
|
+
useCollapse: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false
|
|
63
|
+
},
|
|
64
|
+
uid: String,
|
|
65
|
+
doms: Array
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function emits () {
|
|
70
|
+
return [
|
|
71
|
+
'update:tref',
|
|
72
|
+
'search',
|
|
73
|
+
'add',
|
|
74
|
+
'edit',
|
|
75
|
+
'row-edit',
|
|
76
|
+
'cancel-edit',
|
|
77
|
+
'delete',
|
|
78
|
+
'export',
|
|
79
|
+
'search-export',
|
|
80
|
+
'load'
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function _attrs () {
|
|
85
|
+
const platform = this.$.attrs.platform || (window.isMobile ? 'mobile' : 'pc')
|
|
86
|
+
const key = platform + 'TableAttrs'
|
|
87
|
+
const dict = {}
|
|
88
|
+
if (key in this) Object.assign(dict, this[key])
|
|
89
|
+
Object.assign(dict, this.$attrs)
|
|
90
|
+
return dict
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function domids () {
|
|
94
|
+
const domids = {}
|
|
95
|
+
const keys = [
|
|
96
|
+
'keywords-search',
|
|
97
|
+
'search',
|
|
98
|
+
'add',
|
|
99
|
+
'multi-delete',
|
|
100
|
+
'export',
|
|
101
|
+
'search-export',
|
|
102
|
+
'import',
|
|
103
|
+
|
|
104
|
+
'edit',
|
|
105
|
+
'row-edit',
|
|
106
|
+
'cancel-edit',
|
|
107
|
+
'delete',
|
|
108
|
+
'operates'
|
|
109
|
+
]
|
|
110
|
+
keys.forEach(key => domids[key] = key)
|
|
111
|
+
return { ...domids, ...this.$attrs.domids }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function elTableAttrs () {
|
|
115
|
+
const keys = Object.keys(this._attrs).filter(key => !key.endsWith('-btn'))
|
|
116
|
+
const attrs = {}
|
|
117
|
+
keys.forEach(key => attrs[key] = this._attrs[key])
|
|
118
|
+
delete attrs.platform
|
|
119
|
+
return {
|
|
120
|
+
border: true,
|
|
121
|
+
stripe: true,
|
|
122
|
+
fit: true,
|
|
123
|
+
'highlight-current-row': true,
|
|
124
|
+
...attrs,
|
|
125
|
+
data: this._data,
|
|
126
|
+
'cell-class-name': this.cellClassName,
|
|
127
|
+
'cell-style': this.cellStyle
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function _loading () {
|
|
132
|
+
const { table, loading } = this.$props
|
|
133
|
+
return loading || table?.loading
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function _data () {
|
|
137
|
+
const { table, data } = this.$props
|
|
138
|
+
return data || table?.list || []
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function _columns () {
|
|
142
|
+
const { $props, _query } = this
|
|
143
|
+
const { table, columns } = $props
|
|
144
|
+
const cols = columns || table?.columns || []
|
|
145
|
+
const domids = cols.map(col => col.tableAttrs?.domid)
|
|
146
|
+
return cols.filter((col, index) => !domids[index] || this._doms.includes(domids[index])).map(col => {
|
|
147
|
+
if (col.type === '_index') {
|
|
148
|
+
return Object.assign({
|
|
149
|
+
width: 60,
|
|
150
|
+
label: '序号',
|
|
151
|
+
index (num) {
|
|
152
|
+
const { page, limit } = _query
|
|
153
|
+
return (table.isInfinite ? 0 : (page - 1) * limit) + num + 1
|
|
154
|
+
}
|
|
155
|
+
}, col, { type: 'index' })
|
|
156
|
+
} else if (col.type === 'radio') {
|
|
157
|
+
return Object.assign({ width: 60, label: '单选' }, col)
|
|
158
|
+
}
|
|
159
|
+
return Object.assign({}, col, col.tableAttrs)
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function _doms () {
|
|
164
|
+
return this.doms || this.$store?.acl?.routeDoms || []
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function _query () {
|
|
168
|
+
const { table, query } = this.$props
|
|
169
|
+
return query || table?.query
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function _total () {
|
|
173
|
+
const { table, total } = this.$props
|
|
174
|
+
return total || table?.total
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function _finished () {
|
|
178
|
+
const { table, finished } = this.$props
|
|
179
|
+
return finished ?? table?.finished
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function _selection () {
|
|
183
|
+
const { table, selection } = this.$props
|
|
184
|
+
return selection || table?.selection
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function _actions () {
|
|
188
|
+
const path = this.$route?.path.slice(1).replaceAll('/', ':')
|
|
189
|
+
const doms = this.$store?.acl?.routeDoms || []
|
|
190
|
+
let items = this.$attrs.platform === 'pc' ? [] : [
|
|
191
|
+
{ name: '编辑', color: '#07c160', domid: 'edit' },
|
|
192
|
+
{ name: '删除', color: '#eb6f6f', domid: 'delete' },
|
|
193
|
+
]
|
|
194
|
+
items = items.concat(this.actions)
|
|
195
|
+
items.forEach(it => {
|
|
196
|
+
if (this.$attrs.platform === 'pc') {
|
|
197
|
+
if (it.type) delete it.color
|
|
198
|
+
}
|
|
199
|
+
if (typeof it.handler === 'string') {
|
|
200
|
+
it.handler = this.controller[it.handler]
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
return items.filter(ele => {
|
|
204
|
+
return !ele.domid || doms?.includes(this.domids[ele.domid] ?? ele.domid)
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function _chartHeight () {
|
|
209
|
+
const { table, chartHeight } = this.$props
|
|
210
|
+
return chartHeight || table?.chartHeight || (Math.max(window.innerHeight - 300, 360) + 'px')
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function _chartOption () {
|
|
214
|
+
const { table, chartOption } = this.$props
|
|
215
|
+
return { ...this._attrs.chartOption, ...table?.chartOption, ...chartOption }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function _onKeywordsSearch () {
|
|
219
|
+
if (this.onKeywordsSearch || this._listen['keywords-search']) {
|
|
220
|
+
return (...props) => this._emit('keywords-search', ...props)
|
|
221
|
+
}
|
|
222
|
+
return null
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function _onSearch () {
|
|
226
|
+
if (this.hideSearcher) {
|
|
227
|
+
return (this.onSearch || this._listen['search']) ? () => this._emit('search') : null
|
|
228
|
+
}
|
|
229
|
+
if (this.onSearch || this._listen['search']) {
|
|
230
|
+
return (params) => {
|
|
231
|
+
if (params) {
|
|
232
|
+
this._emit('search')
|
|
233
|
+
} else {
|
|
234
|
+
this.$refs.searcher.open()
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function _onAdd () {
|
|
242
|
+
return (this.onAdd || this._listen['add']) ? () => this._emit('add') : null
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function _onExport () {
|
|
246
|
+
return (this.onExport || this._listen['export']) ? () => this._emit('export') : null
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function _onSearchExport () {
|
|
250
|
+
return (this.onSearchExport || this._listen['search-export']) ? () => this._emit('search-export') : null
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function _onImport () {
|
|
254
|
+
return (this.onImport || this._listen['import']) ? () => this._emit('import') : null
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function _onMultiDelete () {
|
|
258
|
+
return (this.onMultiDelete || this._listen['multi-delete']) ? () => this._emit('multi-delete') : null
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function _onLoad () {
|
|
262
|
+
return this.onLoad || this._listen['load'] ? () => this._emit('load') : () => {}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function _listen () {
|
|
266
|
+
if (!this.controller || !this.listen?.length) return {}
|
|
267
|
+
let events = this.listen.split(',')
|
|
268
|
+
if (events.includes('*')) {
|
|
269
|
+
events = [...new Set([
|
|
270
|
+
...events, 'keywords-search', 'search', 'add', 'multi-delete', 'export', 'search-export', 'import',
|
|
271
|
+
'edit', 'row-edit', 'cancel-edit', 'delete'
|
|
272
|
+
])]
|
|
273
|
+
}
|
|
274
|
+
const dict = {}
|
|
275
|
+
events.forEach(e => {
|
|
276
|
+
const funcName = 'handle' + e.split('-').map(p => p[0].toUpperCase() + p.slice(1)).join('')
|
|
277
|
+
dict[e] = this.controller[funcName]
|
|
278
|
+
})
|
|
279
|
+
return dict
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function _visibleColumns () {
|
|
283
|
+
const left = this._columns.filter(col => col.type && TYPES.includes(col.type) || col.fixed === 'left')
|
|
284
|
+
const right = this.settings.columns.filter(col => !col.hide && col.fixed !== 'left').map(col => {
|
|
285
|
+
const column = this._columns.find(c => c.prop === col.prop)
|
|
286
|
+
if (!column) return
|
|
287
|
+
return {
|
|
288
|
+
sortable: 'custom',
|
|
289
|
+
...column,
|
|
290
|
+
width: col.width || column.width
|
|
291
|
+
}
|
|
292
|
+
}).filter(col => col)
|
|
293
|
+
return left.concat(right)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function _uid () {
|
|
297
|
+
const { table, uid } = this.$props
|
|
298
|
+
return uid || table?.uid || ''
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export function plain () {
|
|
302
|
+
const { plain } = this._attrs
|
|
303
|
+
return plain || plain === ''
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function hideHeader () {
|
|
307
|
+
const { 'hide-header': hideHeader } = this._attrs
|
|
308
|
+
return hideHeader || hideHeader === ''
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function hideTools () {
|
|
312
|
+
const { 'hide-tools': hideTools } = this._attrs
|
|
313
|
+
return this.plain ? hideTools !== false : (hideTools || hideTools === '')
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function hideSearcher () {
|
|
317
|
+
const { 'hide-searcher': hideSearcher } = this._attrs
|
|
318
|
+
return this.plain ? hideSearcher !== false : (hideSearcher || hideSearcher === '')
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export function hideChart () {
|
|
322
|
+
const { 'hide-chart': hideChart } = this._attrs
|
|
323
|
+
return this.plain ? hideChart !== false : (hideChart || hideChart === '')
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function hideSettings () {
|
|
327
|
+
const { 'hide-settings': hideSettings } = this._attrs
|
|
328
|
+
return this.plain ? hideSettings !== false : (hideSettings || hideSettings === '')
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function hideOperates () {
|
|
332
|
+
const { 'hide-operates': hideOperates } = this._attrs
|
|
333
|
+
return this.plain ? hideOperates !== false : (hideOperates || hideOperates === '')
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function hidePagination () {
|
|
337
|
+
const { 'hide-pagination': hidePagination } = this._attrs
|
|
338
|
+
return this.plain ? hidePagination !== false : (hidePagination || hidePagination === '')
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function operatesWidth () {
|
|
342
|
+
return this._attrs['operates-width'] ?? 150
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function operatesDropdown () {
|
|
346
|
+
return this._attrs['operates-dropdown']
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function searcherColumns () {
|
|
350
|
+
return this._columns.filter(col => !col.virtual && col.canSearch !== false && (!col.type || !TYPES.includes(col.type)))
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function searcherConfig () {
|
|
354
|
+
const config = this.table.searcherConfig ?? this._attrs['searcher-config'] ?? {}
|
|
355
|
+
if (config.conditions?.length) {
|
|
356
|
+
const props = this._columns.map(col => col.prop)
|
|
357
|
+
config.conditions = config.conditions.filter(con => props.includes(con.prop))
|
|
358
|
+
}
|
|
359
|
+
return config
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function initSettings () {
|
|
363
|
+
const settings = this._uid && local.getJson(`Settings[${this._uid}]`, {}) || {}
|
|
364
|
+
if (!settings.columns?.length) {
|
|
365
|
+
settings.columns = this._columns.filter(col => {
|
|
366
|
+
return col.label && (col.prop || col.prop === 0) && !(col.type && TYPES.includes(col.type))
|
|
367
|
+
}).map(col => {
|
|
368
|
+
const { prop, label, show, hide, width, virtual, fixed } = col
|
|
369
|
+
return { prop, label, show, hide, width, virtual, fixed }
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
this.settings = settings
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function saveSettings (value) {
|
|
376
|
+
Object.assign(this.settings, value)
|
|
377
|
+
local.setJson(`Settings[${this._uid}]`, this.settings)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export function calcValue (row, column) {
|
|
381
|
+
const { prop } = column
|
|
382
|
+
const value = row[prop]
|
|
383
|
+
let { format, formatter } = column.tableAttrs || column
|
|
384
|
+
if (formatter) return formatter(value, row)
|
|
385
|
+
format = Array.isArray(column.options) ? format !== false : format
|
|
386
|
+
if (format) {
|
|
387
|
+
const formatProp = `_formatted_${prop}`
|
|
388
|
+
if (formatProp in row) {
|
|
389
|
+
return row[formatProp]
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (value == undefined) {
|
|
393
|
+
if (prop.includes('.') || prop.includes('[')) {
|
|
394
|
+
return highdict.get(row, prop, this.defaultValue)
|
|
395
|
+
}
|
|
396
|
+
return this.defaultValue
|
|
397
|
+
}
|
|
398
|
+
if (value === '') {
|
|
399
|
+
return this.defaultValue
|
|
400
|
+
}
|
|
401
|
+
return value
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export function calcLink (row, column) {
|
|
405
|
+
if (column.link) return column.link(row)
|
|
406
|
+
return highdict.get(row, column.linkProp || column.prop)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export function calcOverflowTooltip (column) {
|
|
410
|
+
if (['index', 'selection', 'expand'].includes(column.type)) {
|
|
411
|
+
return false
|
|
412
|
+
}
|
|
413
|
+
const { showOverflowTooltip } = column.tableAttrs || column
|
|
414
|
+
return showOverflowTooltip !== false
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export function handleSearch (params) {
|
|
418
|
+
this.params = params
|
|
419
|
+
this._emit('search', params)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function handleResetSettings () {
|
|
423
|
+
this.saveSettings({})
|
|
424
|
+
this.initSettings()
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function handleHeaderDragend (newWidth, oldWidth, column, event) {
|
|
428
|
+
const col = this.settings.columns.find(col => col.prop === column.property)
|
|
429
|
+
if (col) {
|
|
430
|
+
col.width = newWidth
|
|
431
|
+
this.saveSettings(this.settings)
|
|
432
|
+
}
|
|
433
|
+
if (this.onHeaderDragend) {
|
|
434
|
+
this.onHeaderDragend(newWidth, oldWidth, column, event)
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export function handleSelectionChange (rows) {
|
|
439
|
+
if (this._selection) {
|
|
440
|
+
this._selection.splice(0)
|
|
441
|
+
this._selection.push(...rows)
|
|
442
|
+
}
|
|
443
|
+
if (this.onSelectionChange) {
|
|
444
|
+
this.onSelectionChange(rows)
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export function handleSortChange (params) {
|
|
449
|
+
if (this.onSortChange) {
|
|
450
|
+
this.onSortChange(params)
|
|
451
|
+
} else {
|
|
452
|
+
if (Array.isArray(params)) {
|
|
453
|
+
this.controller?.handleSortChange?.(params)
|
|
454
|
+
} else if (params.column.sortable === 'custom') {
|
|
455
|
+
this.controller?.handleSortChange?.(params)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export function handleCheckedChange (e) {
|
|
461
|
+
this.checked = e.target.value * 1
|
|
462
|
+
const row = this._data[this.checked]
|
|
463
|
+
if (this.table) {
|
|
464
|
+
this.table.checked = row
|
|
465
|
+
}
|
|
466
|
+
if (this.onCheckedChange) {
|
|
467
|
+
this.onCheckedChange(row)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export function handleCollapseChange (activeNames) {
|
|
472
|
+
if (activeNames.length) {
|
|
473
|
+
this.isMinus = false
|
|
474
|
+
if (!this.useCollapse) {
|
|
475
|
+
this._useCollapse = false
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export function handleMinus () {
|
|
481
|
+
this.isMinus = !this.isMinus
|
|
482
|
+
if (this.isMinus) {
|
|
483
|
+
this._useCollapse = true
|
|
484
|
+
this.activeNames = []
|
|
485
|
+
} else {
|
|
486
|
+
this._useCollapse = this.useCollapse
|
|
487
|
+
this.activeNames = ['name']
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export function handleToggleFullscreen () {
|
|
492
|
+
this.isFullscreen = !this.isFullscreen
|
|
493
|
+
if (this.isFullscreen) {
|
|
494
|
+
this.zoom = document.documentElement.style.zoom
|
|
495
|
+
document.documentElement.style.zoom = 1
|
|
496
|
+
} else {
|
|
497
|
+
document.documentElement.style.zoom = this.zoom
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export function cellClassName (props) {
|
|
502
|
+
let classNames = this._attrs['cell-class-name'] ? this._attrs['cell-class-name'](props) : ''
|
|
503
|
+
const col = this._visibleColumns[props.columnIndex]
|
|
504
|
+
if (col?.tableAttrs?.class) {
|
|
505
|
+
const klass = col.tableAttrs.class
|
|
506
|
+
if (typeof klass === 'function') {
|
|
507
|
+
classNames += ' ' + klass(props)
|
|
508
|
+
} else if (typeof klass === 'string') {
|
|
509
|
+
classNames += ' ' + klass
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return !classNames ? '' : [...new Set(classNames.split(' '))].join(' ')
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export function cellStyle (props) {
|
|
516
|
+
const style = this._attrs['cell-style'] ? this._attrs['cell-style'](props) : {}
|
|
517
|
+
const col = this._visibleColumns[props.columnIndex]
|
|
518
|
+
if (col?.tableAttrs?.style) {
|
|
519
|
+
const sty = col.tableAttrs.style
|
|
520
|
+
if (typeof sty === 'function') {
|
|
521
|
+
Object.assign(style, sty(props))
|
|
522
|
+
} else if (typeof sty === 'object') {
|
|
523
|
+
Object.assign(style, sty)
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return Object.keys(style) ? style : null
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export function calcTagType (scope, column) {
|
|
530
|
+
const { tagTypes, prop, options } = column
|
|
531
|
+
const value = scope.row[prop]
|
|
532
|
+
if (tagTypes) {
|
|
533
|
+
if (typeof tagTypes === 'function') {
|
|
534
|
+
return tagTypes(value, scope, column)
|
|
535
|
+
} else if (typeof tagTypes === 'object') {
|
|
536
|
+
return tagTypes[value]
|
|
537
|
+
}
|
|
538
|
+
} else if (options) {
|
|
539
|
+
const op = options.find(o => o[column.value || 'value'] === value)
|
|
540
|
+
if (op?.tagType) return op.tagType
|
|
541
|
+
}
|
|
542
|
+
return value ? 'success' : 'danger'
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export function calcTagValue (scope, column) {
|
|
546
|
+
const { tagValues, prop, options } = column
|
|
547
|
+
const value = scope.row[prop]
|
|
548
|
+
if (tagValues) {
|
|
549
|
+
if (typeof tagValues === 'function') {
|
|
550
|
+
return tagValues(value, scope, column)
|
|
551
|
+
} else if (typeof tagValues === 'object') {
|
|
552
|
+
return tagValues[value]
|
|
553
|
+
}
|
|
554
|
+
} else if (options) {
|
|
555
|
+
const op = options.find(o => o[column.value || 'value'] === value)
|
|
556
|
+
if (op) return op[column.text || 'text']
|
|
557
|
+
}
|
|
558
|
+
return value
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export function canEdit (row) {
|
|
562
|
+
return !!(this.onEdit || this._listen['edit']) && (row.editable !== false) && !row.isEditing
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function canSave (row) {
|
|
566
|
+
return !!(this.onRowEdit || this._listen['row-edit']) && this.table.isRowEdit && row.isEditing
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
export function canRowEdit (row) {
|
|
570
|
+
return !!(this.onRowEdit || this._listen['row-edit']) && this.table.isRowEdit && row.isEditing
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export function canCancelEdit (row) {
|
|
574
|
+
return !!(this.onCancelEdit || this._listen['cancel-edit']) && this.table.isRowEdit && row.isEditing
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export function canDelete (row) {
|
|
578
|
+
return !!(this.onDelete || this._listen['delete']) && row.deletable !== false
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export function calcImages (scope, column) {
|
|
582
|
+
const value = scope.row[column.prop]
|
|
583
|
+
let images = []
|
|
584
|
+
if (column.images) {
|
|
585
|
+
images = column.images(value, scope.row)
|
|
586
|
+
} else {
|
|
587
|
+
images = Array.isArray(value) ? value : [value]
|
|
588
|
+
}
|
|
589
|
+
images = images.filter(ele => ele).map(ele => {
|
|
590
|
+
if (typeof ele !== 'object') {
|
|
591
|
+
ele = { url: ele, name: ele.split('/').pop() }
|
|
592
|
+
}
|
|
593
|
+
ele.type ||= getUrlType(ele.url)
|
|
594
|
+
ele.icon = column.icons?.[ele.type] ?? getFiletypeIcon(ele.type)
|
|
595
|
+
return ele
|
|
596
|
+
})
|
|
597
|
+
scope._images = images
|
|
598
|
+
scope._urls = images.map(ele => ele.url)
|
|
599
|
+
scope._image_urls = images.filter(ele => ele.type === 'image').map(ele => ele.url)
|
|
600
|
+
return images
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export function _emit (event, payload) {
|
|
604
|
+
const funcName = 'on' + event.split('-').map(p => p[0].toUpperCase() + p.slice(1)).join('')
|
|
605
|
+
if (this[funcName]) {
|
|
606
|
+
this[funcName](payload)
|
|
607
|
+
} else if (this._listen[event]) {
|
|
608
|
+
this._listen[event](payload)
|
|
609
|
+
} else {
|
|
610
|
+
this.$emit(event, payload)
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export function $route () {
|
|
615
|
+
if (this.zoom !== 1) {
|
|
616
|
+
document.documentElement.style.zoom = this.zoom
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export default {
|
|
621
|
+
props,
|
|
622
|
+
emits,
|
|
623
|
+
computed: {
|
|
624
|
+
_attrs,
|
|
625
|
+
domids,
|
|
626
|
+
elTableAttrs,
|
|
627
|
+
_loading,
|
|
628
|
+
_data,
|
|
629
|
+
_columns,
|
|
630
|
+
_doms,
|
|
631
|
+
_query,
|
|
632
|
+
_total,
|
|
633
|
+
_finished,
|
|
634
|
+
_selection,
|
|
635
|
+
_actions,
|
|
636
|
+
_chartHeight,
|
|
637
|
+
_chartOption,
|
|
638
|
+
_onKeywordsSearch,
|
|
639
|
+
_onSearch,
|
|
640
|
+
_onAdd,
|
|
641
|
+
_onExport,
|
|
642
|
+
_onSearchExport,
|
|
643
|
+
_onImport,
|
|
644
|
+
_onMultiDelete,
|
|
645
|
+
_onLoad,
|
|
646
|
+
_listen,
|
|
647
|
+
_visibleColumns,
|
|
648
|
+
_uid,
|
|
649
|
+
plain,
|
|
650
|
+
hideHeader,
|
|
651
|
+
hideTools,
|
|
652
|
+
hideSearcher,
|
|
653
|
+
hideChart,
|
|
654
|
+
hideSettings,
|
|
655
|
+
hideOperates,
|
|
656
|
+
hidePagination,
|
|
657
|
+
operatesWidth,
|
|
658
|
+
operatesDropdown,
|
|
659
|
+
searcherColumns,
|
|
660
|
+
searcherConfig
|
|
661
|
+
},
|
|
662
|
+
watch: {
|
|
663
|
+
$route
|
|
664
|
+
},
|
|
665
|
+
methods: {
|
|
666
|
+
initSettings,
|
|
667
|
+
saveSettings,
|
|
668
|
+
calcValue,
|
|
669
|
+
calcLink,
|
|
670
|
+
calcOverflowTooltip,
|
|
671
|
+
handleSearch,
|
|
672
|
+
handleResetSettings,
|
|
673
|
+
handleHeaderDragend,
|
|
674
|
+
handleSelectionChange,
|
|
675
|
+
handleSortChange,
|
|
676
|
+
handleCheckedChange,
|
|
677
|
+
handleCollapseChange,
|
|
678
|
+
handleMinus,
|
|
679
|
+
handleToggleFullscreen,
|
|
680
|
+
cellClassName,
|
|
681
|
+
cellStyle,
|
|
682
|
+
calcTagType,
|
|
683
|
+
calcTagValue,
|
|
684
|
+
canEdit,
|
|
685
|
+
canSave,
|
|
686
|
+
canRowEdit,
|
|
687
|
+
canCancelEdit,
|
|
688
|
+
canDelete,
|
|
689
|
+
calcImages,
|
|
690
|
+
_emit
|
|
691
|
+
}
|
|
692
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: 'MobileXTableTools',
|
|
3
|
+
inheritAttrs: false,
|
|
4
|
+
props: {
|
|
5
|
+
searchBtn: Object,
|
|
6
|
+
addBtn: Object,
|
|
7
|
+
multiEditBtn: Object,
|
|
8
|
+
multiDeleteBtn: Object,
|
|
9
|
+
exportBtn: Object,
|
|
10
|
+
importBtn: Object,
|
|
11
|
+
domids: Object
|
|
12
|
+
},
|
|
13
|
+
data () {
|
|
14
|
+
return {
|
|
15
|
+
keywords: '',
|
|
16
|
+
domidsCanAdd: true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
async mounted () {
|
|
20
|
+
await this.$nextTick()
|
|
21
|
+
if (!this.$refs.fbc.isConnected) {
|
|
22
|
+
this.domidsCanAdd = false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|