@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,108 @@
|
|
|
1
|
+
import utils from './utils.js'
|
|
2
|
+
import Searcher from './searcher.vue'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
name: 'MobileXTable',
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
props: {
|
|
8
|
+
...utils.props(),
|
|
9
|
+
platform: String,
|
|
10
|
+
labelWidth: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: '80px'
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
emits: [
|
|
16
|
+
...utils.emits()
|
|
17
|
+
],
|
|
18
|
+
components: { Searcher },
|
|
19
|
+
data () {
|
|
20
|
+
return {
|
|
21
|
+
scope: {},
|
|
22
|
+
selected: [],
|
|
23
|
+
settings: {},
|
|
24
|
+
checked: null,
|
|
25
|
+
operatesVisible: false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
computed: {
|
|
29
|
+
...utils.computed,
|
|
30
|
+
hasIndex () {
|
|
31
|
+
return this._visibleColumns.some(col => col.type === 'index' || col.type === '_index')
|
|
32
|
+
},
|
|
33
|
+
hasSelection () {
|
|
34
|
+
return this._visibleColumns.some(col => col.type === 'selection')
|
|
35
|
+
},
|
|
36
|
+
hasRadio () {
|
|
37
|
+
return this._visibleColumns.some(col => col.type === 'radio')
|
|
38
|
+
},
|
|
39
|
+
cols () {
|
|
40
|
+
return this._visibleColumns.filter(col => {
|
|
41
|
+
return !['index', 'selection', 'expand', 'radio', '_index'].includes(col.type)
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
_mobileColumns () {
|
|
45
|
+
return this._visibleColumns.filter(col => !['_index', 'index', 'selection'].includes(col.type))
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
watch: {
|
|
49
|
+
selected: {
|
|
50
|
+
handler (value) {
|
|
51
|
+
const rows = []
|
|
52
|
+
value.forEach((ele, index) => {
|
|
53
|
+
if (ele) rows.push(this._data[index])
|
|
54
|
+
})
|
|
55
|
+
this.handleSelectionChange(rows)
|
|
56
|
+
},
|
|
57
|
+
deep: true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
created () {
|
|
61
|
+
this.initSettings()
|
|
62
|
+
},
|
|
63
|
+
mounted () {
|
|
64
|
+
if (this.table) {
|
|
65
|
+
this.table.tableRef = this
|
|
66
|
+
this.table.ref = this
|
|
67
|
+
}
|
|
68
|
+
this.$emit('update:tref', this)
|
|
69
|
+
},
|
|
70
|
+
methods: {
|
|
71
|
+
...utils.methods,
|
|
72
|
+
handleClickCard (index) {
|
|
73
|
+
if (this.hasSelection) {
|
|
74
|
+
this.selected[index] = !this.selected[index]
|
|
75
|
+
} else if (this.hasRadio) {
|
|
76
|
+
this.handleCheckedChange({ target: { value: index } })
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
handleShowActionSheet (row, $index) {
|
|
80
|
+
this.scope = { row, $index }
|
|
81
|
+
this.operatesVisible = true
|
|
82
|
+
},
|
|
83
|
+
handleSelectAction (action, index) {
|
|
84
|
+
const { handler } = this._actions[index]
|
|
85
|
+
if (typeof handler === 'function') {
|
|
86
|
+
return handler(this.scope)
|
|
87
|
+
} else if (typeof handler === 'string') {
|
|
88
|
+
return this.controller[handler]?.(this.scope)
|
|
89
|
+
}
|
|
90
|
+
if (action.name === '编辑') {
|
|
91
|
+
this._emit('edit', this.scope)
|
|
92
|
+
} else if (action.name === '删除') {
|
|
93
|
+
this._emit('delete', this.scope)
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
clearSelection () {
|
|
97
|
+
this.selected = []
|
|
98
|
+
this.checked = null
|
|
99
|
+
},
|
|
100
|
+
calcScope (row, $index) {
|
|
101
|
+
this._scopes ||= new WeakMap()
|
|
102
|
+
if (!this._scopes.get(row)) {
|
|
103
|
+
this._scopes.set(row, { row, $index })
|
|
104
|
+
}
|
|
105
|
+
return this._scopes.get(row)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './mobile.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
class="x-table mobile-x-table"
|
|
8
|
+
v-loading="_loading"
|
|
9
|
+
element-loading-text="加载中..."
|
|
10
|
+
>
|
|
11
|
+
<searcher
|
|
12
|
+
ref="searcher"
|
|
13
|
+
:uid="_uid"
|
|
14
|
+
:columns="searcherColumns"
|
|
15
|
+
:config="searcherConfig"
|
|
16
|
+
@search="handleSearch"
|
|
17
|
+
@save="saveSettings"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<x-table-tools
|
|
21
|
+
v-if="hideTools !== '' && hideTools !== true"
|
|
22
|
+
v-bind="_attrs"
|
|
23
|
+
:domids
|
|
24
|
+
@add="_onAdd"
|
|
25
|
+
@keywords-search="_onKeywordsSearch"
|
|
26
|
+
@search="_onSearch"
|
|
27
|
+
@export="_onExport"
|
|
28
|
+
@search-export="_onSearchExport"
|
|
29
|
+
@import="_onImport"
|
|
30
|
+
@multi-delete="_onMultiDelete"
|
|
31
|
+
>
|
|
32
|
+
<template v-if="$slots['tools-prefix']" #tools-prefix>
|
|
33
|
+
<slot name="tools-prefix" />
|
|
34
|
+
</template>
|
|
35
|
+
<template v-if="$slots['tools-suffix']" #tools-suffix>
|
|
36
|
+
<slot name="tools-suffix" />
|
|
37
|
+
</template>
|
|
38
|
+
</x-table-tools>
|
|
39
|
+
|
|
40
|
+
<div class="x-table-body">
|
|
41
|
+
<div
|
|
42
|
+
v-for="(row, index) in _data"
|
|
43
|
+
:key="index"
|
|
44
|
+
class="card"
|
|
45
|
+
>
|
|
46
|
+
<div class="card-header flex-center">
|
|
47
|
+
<span class="flex-center">
|
|
48
|
+
<van-checkbox
|
|
49
|
+
v-if="hasSelection"
|
|
50
|
+
v-model="selected[index]"
|
|
51
|
+
shape="square"
|
|
52
|
+
class="selection"
|
|
53
|
+
@click.stop
|
|
54
|
+
/>
|
|
55
|
+
<span class="index">{{ (_query.page - 1) * _query.limit + index + 1 }}</span>
|
|
56
|
+
</span>
|
|
57
|
+
<van-button
|
|
58
|
+
v-if="_actions.length" icon="ellipsis" size="mini" type="primary" circle plain
|
|
59
|
+
@click.stop="handleShowActionSheet(row, index)"
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
<input
|
|
63
|
+
v-if="hasRadio"
|
|
64
|
+
type="radio"
|
|
65
|
+
:value="index"
|
|
66
|
+
:checked="index === checked"
|
|
67
|
+
class="radio"
|
|
68
|
+
@click.stop
|
|
69
|
+
@change="handleCheckedChange"
|
|
70
|
+
>
|
|
71
|
+
<van-row class="card-info" :gutter="10">
|
|
72
|
+
<van-col
|
|
73
|
+
v-for="(column, i) in _mobileColumns"
|
|
74
|
+
:key="i"
|
|
75
|
+
:span="column.xs ?? 24"
|
|
76
|
+
class="card-field flex-center"
|
|
77
|
+
>
|
|
78
|
+
<span class="card-field__label">{{ column.label }}</span>
|
|
79
|
+
<span class="card-field__value">
|
|
80
|
+
<el-space v-if="column.slot === '$image'" wrap>
|
|
81
|
+
<div class="image-item" v-for="(image, index) in calcImages(calcScope(row, index), column)" :key="index">
|
|
82
|
+
<el-image
|
|
83
|
+
v-if="image.type === 'image'"
|
|
84
|
+
:src="image.url"
|
|
85
|
+
:preview-src-list="calcScope(row, index)._image_urls"
|
|
86
|
+
:initial-index="calcScope(row, index)._image_urls.indexOf(image.url)"
|
|
87
|
+
lazy preview-teleported
|
|
88
|
+
/>
|
|
89
|
+
<a v-else :href="image.url" target="_blank">
|
|
90
|
+
<x-icon :name="image.icon" class="file-icon" />
|
|
91
|
+
</a>
|
|
92
|
+
</div>
|
|
93
|
+
</el-space>
|
|
94
|
+
<el-tag
|
|
95
|
+
v-else-if="column.slot === '$tag'"
|
|
96
|
+
:type="calcTagType({ row, $index: index }, column)"
|
|
97
|
+
>
|
|
98
|
+
{{ calcTagValue({ row, $index: index }, column) }}
|
|
99
|
+
</el-tag>
|
|
100
|
+
<a
|
|
101
|
+
v-else-if="column.slot === '$link' && /https?\:/.test(column.to(row))"
|
|
102
|
+
:href="column.to(row)" target="_blank"
|
|
103
|
+
>
|
|
104
|
+
{{ calcLink(row, column) }}
|
|
105
|
+
</a>
|
|
106
|
+
<router-link
|
|
107
|
+
v-else-if="column.slot === '$link'"
|
|
108
|
+
:to="column.to(row)"
|
|
109
|
+
>
|
|
110
|
+
{{ calcLink(row, column) }}
|
|
111
|
+
</router-link>
|
|
112
|
+
<a :href="`tel:${row[column.prop]}`" v-else-if="column.slot === '$phone'">
|
|
113
|
+
{{ row[column.prop] }}
|
|
114
|
+
</a>
|
|
115
|
+
<img
|
|
116
|
+
v-else-if="column.slot === '$qrcode'"
|
|
117
|
+
:title="row[column.prop]"
|
|
118
|
+
:data-qrcodeid="`qrcode-${i}-${index}`"
|
|
119
|
+
:style="{ width: '128px', height: '128px', ...(column.tableAttrs?.style || column.style) }"
|
|
120
|
+
/>
|
|
121
|
+
<el-icon v-else-if="column.slot === '$icon'" class="cell-icon">
|
|
122
|
+
<component :is="row[column.prop]" />
|
|
123
|
+
</el-icon>
|
|
124
|
+
<slot
|
|
125
|
+
v-else-if="column.slot"
|
|
126
|
+
:name="column.slot"
|
|
127
|
+
:scope="{ row, $index: index }"
|
|
128
|
+
:column
|
|
129
|
+
:value="row[column.prop]"
|
|
130
|
+
/>
|
|
131
|
+
<slot
|
|
132
|
+
v-else-if="slotAll"
|
|
133
|
+
name="all"
|
|
134
|
+
:scope="{ row, $index: index }"
|
|
135
|
+
:column
|
|
136
|
+
:value="row[column.prop]"
|
|
137
|
+
/>
|
|
138
|
+
<template v-else>
|
|
139
|
+
<component
|
|
140
|
+
v-if="column.comp === 'ElSwitch' || table.isRowEdit && row.isEditing && (column.visible !== false || column.canEdit)"
|
|
141
|
+
:is="column.comp || 'ElInput'"
|
|
142
|
+
v-bind="{...column, ...column.formAttrs}"
|
|
143
|
+
v-model="row[column.prop]"
|
|
144
|
+
:disabled="!row.editable || !row.isEditing"
|
|
145
|
+
/>
|
|
146
|
+
<span v-else class="card-field__value">
|
|
147
|
+
{{ calcValue(row, column) }}
|
|
148
|
+
</span>
|
|
149
|
+
</template>
|
|
150
|
+
</span>
|
|
151
|
+
</van-col>
|
|
152
|
+
</van-row>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<x-pagination
|
|
157
|
+
v-if="!!_query && !!_total && !!(onSearch || _listen['search'])"
|
|
158
|
+
:query="_query"
|
|
159
|
+
:total="_total"
|
|
160
|
+
@search="_emit('search')"
|
|
161
|
+
/>
|
|
162
|
+
|
|
163
|
+
<van-action-sheet
|
|
164
|
+
v-model:show="operatesVisible"
|
|
165
|
+
:actions="_actions"
|
|
166
|
+
close-on-click-action
|
|
167
|
+
@select="handleSelectAction"
|
|
168
|
+
>
|
|
169
|
+
</van-action-sheet>
|
|
170
|
+
</div>
|
|
171
|
+
</template>
|
|
172
|
+
|
|
173
|
+
<style lang="scss" scoped>
|
|
174
|
+
.mobile-x-table {
|
|
175
|
+
font-size: 14px;
|
|
176
|
+
padding: 1px 0;
|
|
177
|
+
color: #303333;
|
|
178
|
+
background-color: var(--x-bg-color);
|
|
179
|
+
.selection, .radio {
|
|
180
|
+
display: inline-block;
|
|
181
|
+
vertical-align: middle;
|
|
182
|
+
margin-right: var(--x-medium-padding);
|
|
183
|
+
}
|
|
184
|
+
.radio {
|
|
185
|
+
width: 18px;
|
|
186
|
+
height: 18px;
|
|
187
|
+
}
|
|
188
|
+
.card {
|
|
189
|
+
border-radius: 8px;
|
|
190
|
+
margin: var(--x-medium-padding);
|
|
191
|
+
padding: var(--x-medium-padding);
|
|
192
|
+
background-color: white;
|
|
193
|
+
.card-header {
|
|
194
|
+
justify-content: space-between;
|
|
195
|
+
margin-bottom: 5px;
|
|
196
|
+
.van-button {
|
|
197
|
+
font-size: 13px;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
.card-info {
|
|
201
|
+
.card-field {
|
|
202
|
+
padding: 5px 0;
|
|
203
|
+
}
|
|
204
|
+
.card-field__label {
|
|
205
|
+
display: inline-block;
|
|
206
|
+
width: v-bind('labelWidth');
|
|
207
|
+
color: #909999;
|
|
208
|
+
vertical-align: top;
|
|
209
|
+
}
|
|
210
|
+
.card-field__value {
|
|
211
|
+
display: inline-block;
|
|
212
|
+
width: calc(100% - v-bind('labelWidth'));
|
|
213
|
+
color: #303333;
|
|
214
|
+
text-align: right;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
.index {
|
|
219
|
+
display: inline-block;
|
|
220
|
+
width: 30px;
|
|
221
|
+
}
|
|
222
|
+
:deep(.van-cell__value) {
|
|
223
|
+
text-align: left;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
.van-popup {
|
|
227
|
+
position: relative;
|
|
228
|
+
.x-info {
|
|
229
|
+
height: calc(100% - 65px);
|
|
230
|
+
overflow-y: auto;
|
|
231
|
+
}
|
|
232
|
+
.operates {
|
|
233
|
+
position: absolute;
|
|
234
|
+
width: calc(100% - var(--x-medium-padding) * 2);
|
|
235
|
+
left: var(--x-medium-padding);
|
|
236
|
+
bottom: var(--x-medium-padding);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
:deep(.van-collapse-item__content) {
|
|
240
|
+
--van-collapse-item-content-padding: 0;
|
|
241
|
+
}
|
|
242
|
+
.van-pagination {
|
|
243
|
+
--van-pagination-height: 33px;
|
|
244
|
+
margin: var(--x-medium-padding) 0;
|
|
245
|
+
}
|
|
246
|
+
</style>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import utils from './utils.js'
|
|
2
|
+
import { baseDialog } from '../../utils/model.js'
|
|
3
|
+
import Searcher from './searcher.vue'
|
|
4
|
+
import Settings from './settings.vue'
|
|
5
|
+
|
|
6
|
+
const { funcs, highdict } = StardustJs
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
name: 'PcXTable',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: {
|
|
12
|
+
...utils.props()
|
|
13
|
+
},
|
|
14
|
+
emits: [
|
|
15
|
+
...utils.emits()
|
|
16
|
+
],
|
|
17
|
+
components: { Searcher, Settings },
|
|
18
|
+
data () {
|
|
19
|
+
return {
|
|
20
|
+
searcher: null,
|
|
21
|
+
isMinus: false,
|
|
22
|
+
isFullscreen: false,
|
|
23
|
+
zoom: 1,
|
|
24
|
+
checked: null,
|
|
25
|
+
activeNames: ['name'],
|
|
26
|
+
settings: {},
|
|
27
|
+
params: {},
|
|
28
|
+
_useCollapse: false,
|
|
29
|
+
dialog: {
|
|
30
|
+
...baseDialog()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
computed: {
|
|
35
|
+
...utils.computed,
|
|
36
|
+
hasQrcodeColumns () {
|
|
37
|
+
return this._visibleColumns.some(c => c.slot === '$qrcode' || c.tableAttrs?.slot === '$qrcode')
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
watch: {
|
|
41
|
+
...utils.watch,
|
|
42
|
+
settings: 'saveSettings'
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
_uid: 'initSettings',
|
|
46
|
+
_columns: {
|
|
47
|
+
deep: true,
|
|
48
|
+
immediate: true,
|
|
49
|
+
handler: 'initSettings'
|
|
50
|
+
},
|
|
51
|
+
_loading: {
|
|
52
|
+
immediate: true,
|
|
53
|
+
async handler (loading) {
|
|
54
|
+
if (window.QRCode && !loading && this.hasQrcodeColumns) {
|
|
55
|
+
await funcs.sleep(0)
|
|
56
|
+
window.$all('img[data-qrcodeid]').forEach(async img => {
|
|
57
|
+
const [_, colIndex, rowIndex] = img.dataset.qrcodeid.split('-').map(Number)
|
|
58
|
+
const column = this._visibleColumns[colIndex]
|
|
59
|
+
if (column?.prop) {
|
|
60
|
+
const value = this.table.list[rowIndex]?.[column.prop]
|
|
61
|
+
if (!value) return
|
|
62
|
+
this.qrcodeDict ||= {}
|
|
63
|
+
this.qrcodeDict[value] ||= new Promise(resolve => {
|
|
64
|
+
QRCode.toDataURL(value, {
|
|
65
|
+
width: 128, height: 128, margin: 1, ...(column.tableAttrs || column)
|
|
66
|
+
}).then(src => {
|
|
67
|
+
this.qrcodeDict[value] = src
|
|
68
|
+
resolve(src)
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
img.src = await this.qrcodeDict[value]
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
created () {
|
|
79
|
+
this._useCollapse = this.useCollapse
|
|
80
|
+
},
|
|
81
|
+
mounted () {
|
|
82
|
+
if (this.table) {
|
|
83
|
+
this.table.tableRef = this.$refs.tableRef
|
|
84
|
+
this.table.ref = this
|
|
85
|
+
}
|
|
86
|
+
this.$emit('update:tref', this.$refs.tableRef)
|
|
87
|
+
},
|
|
88
|
+
methods: {
|
|
89
|
+
...utils.methods,
|
|
90
|
+
async handleShowPieDialog () {
|
|
91
|
+
this.dialog.visible = true
|
|
92
|
+
await this.$nextTick()
|
|
93
|
+
if (this.table) {
|
|
94
|
+
this.table.chartRef = this.$refs.chartRef
|
|
95
|
+
}
|
|
96
|
+
await this.$refs.chartRef.init()
|
|
97
|
+
this.$refs.chartRef.initDatasource()
|
|
98
|
+
},
|
|
99
|
+
async handleChartDialogFullscreen () {
|
|
100
|
+
await this.$nextTick()
|
|
101
|
+
this.$refs.chartRef.chart.resize()
|
|
102
|
+
},
|
|
103
|
+
async search (params = {}) {
|
|
104
|
+
const { remote, maxLimit, query, remoteMethod, search } = this._chartOption
|
|
105
|
+
if (search) {
|
|
106
|
+
return search()
|
|
107
|
+
} else if (this.controller[remoteMethod]) {
|
|
108
|
+
return this.controller[remoteMethod]()
|
|
109
|
+
} else if (remote && this.controller.getSearchParams) {
|
|
110
|
+
let searchParams = this.controller.getSearchParams({ page: 1, limit: 100, ...query }, false)
|
|
111
|
+
if (typeof params === 'function') {
|
|
112
|
+
searchParams = params(searchParams)
|
|
113
|
+
} else {
|
|
114
|
+
Object.assign(searchParams, params)
|
|
115
|
+
}
|
|
116
|
+
const paramsJson = JSON.stringify(searchParams)
|
|
117
|
+
if (paramsJson === this._lastSearchParams) return this._lastList
|
|
118
|
+
this._lastSearchParams = paramsJson
|
|
119
|
+
const data = await this.controller.dbTable.search(searchParams)
|
|
120
|
+
if (maxLimit && maxLimit > query.limit && data.total > query.limit) {
|
|
121
|
+
const numPages = Math.ceil(Math.min(maxLimit, data.total) / query.limit)
|
|
122
|
+
const left = await this.controller.dbTable.batch({
|
|
123
|
+
transaction: false,
|
|
124
|
+
operations: Array.from({ length: numPages - 1 }).map((_, i) => ({
|
|
125
|
+
type: 'search',
|
|
126
|
+
data: { ...searchParams, page: i + 2 }
|
|
127
|
+
}))
|
|
128
|
+
}, 'data')
|
|
129
|
+
left.forEach(ele => data.data = data.data.concat(ele.data))
|
|
130
|
+
}
|
|
131
|
+
let list = highdict.get(data, this.controller.listProp)
|
|
132
|
+
list = this.controller.formatList(this.controller._defaultFormatList(list, data), data)
|
|
133
|
+
this._lastList = list
|
|
134
|
+
return list
|
|
135
|
+
}
|
|
136
|
+
return this._data
|
|
137
|
+
},
|
|
138
|
+
onPaging () {
|
|
139
|
+
if (this.params.page) delete this.params.page
|
|
140
|
+
this._emit('search', this.params)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|