@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,263 @@
|
|
|
1
|
+
import { baseDialog, baseTable } from '../../utils/model.js'
|
|
2
|
+
import utils from './utils.js'
|
|
3
|
+
import {
|
|
4
|
+
TYPES, SORTS,
|
|
5
|
+
COMMON_FORMATTERS, DATE_FORMATTERS, NUMBER_FORMATTERS, FORMATTERS,
|
|
6
|
+
} from './constants.js'
|
|
7
|
+
const { funcs, highdict } = StardustJs
|
|
8
|
+
const { StardustEcharts } = StardustBrowser
|
|
9
|
+
|
|
10
|
+
const OPTIONS_COMPONENTS = [
|
|
11
|
+
'x-select', 'x-select-v2', 'x-radios', 'x-checkboxs',
|
|
12
|
+
'XSelect', 'XSelectV2', 'XRadios', 'XCheckboxs'
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: 'XChart',
|
|
17
|
+
props: {
|
|
18
|
+
...utils.props
|
|
19
|
+
},
|
|
20
|
+
data () {
|
|
21
|
+
return {
|
|
22
|
+
zoom: 1,
|
|
23
|
+
loading: false,
|
|
24
|
+
filterType: '分类',
|
|
25
|
+
SORTS,
|
|
26
|
+
dialog: {
|
|
27
|
+
...baseDialog(),
|
|
28
|
+
formItems: utils.formItems,
|
|
29
|
+
form: utils.form
|
|
30
|
+
},
|
|
31
|
+
hasRendered: false,
|
|
32
|
+
dataDialog: {
|
|
33
|
+
visible: false,
|
|
34
|
+
table: baseTable()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
computed: {
|
|
39
|
+
...utils.computed
|
|
40
|
+
},
|
|
41
|
+
watch: {
|
|
42
|
+
option: {
|
|
43
|
+
handler: 'update',
|
|
44
|
+
immediate: true
|
|
45
|
+
},
|
|
46
|
+
zoomedHeight () {
|
|
47
|
+
this.$nextTick(this.resize)
|
|
48
|
+
},
|
|
49
|
+
sidebarCollapse () {
|
|
50
|
+
const duration = (this.$store.app.toggleDuration || 0) * 1000 + 50
|
|
51
|
+
const interval = 50
|
|
52
|
+
for (let i = 0; i < Math.ceil(duration / interval); i++) {
|
|
53
|
+
setTimeout(this.resize, interval * i)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
mounted () {
|
|
58
|
+
this.init()
|
|
59
|
+
},
|
|
60
|
+
beforeUnmount () {
|
|
61
|
+
this.timer && clearInterval(this.timer)
|
|
62
|
+
this.observer.disconnect()
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
async init () {
|
|
66
|
+
await window.DynamicLibs?.use('echarts')
|
|
67
|
+
window.echarts._transforms_ ||= {}
|
|
68
|
+
if (!window.echarts._transforms_['StardustEcharts.grouping']) {
|
|
69
|
+
window.echarts.registerTransform(StardustEcharts.grouping)
|
|
70
|
+
window.echarts._transforms_['StardustEcharts.grouping'] = StardustEcharts.grouping
|
|
71
|
+
}
|
|
72
|
+
if (this.chart) this.$refs.el.removeAttribute('_echarts_instance_')
|
|
73
|
+
this.chart = window.echarts.init(this.$refs.el, null, this.option)
|
|
74
|
+
this.observer = new ResizeObserver(this.resize)
|
|
75
|
+
this.observer.observe(this.$refs.el)
|
|
76
|
+
this.update(this.getOption())
|
|
77
|
+
if (this.updator) {
|
|
78
|
+
this.timer = setInterval(this.updator.handler.bind(this), this.updator.interval || 1000)
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
initDatasource () {
|
|
82
|
+
if (!this.datasource) return
|
|
83
|
+
const columns = this.datasource.columns.filter(col => !TYPES.includes(col.type)).map(col => {
|
|
84
|
+
const column = { ...col, prop: col.label }
|
|
85
|
+
column.formatters = Object.keys(COMMON_FORMATTERS)
|
|
86
|
+
if (col.type === 'date' || ['el-date-picker', 'ElDatePicker'].includes(col.comp)) {
|
|
87
|
+
column.formatters.push(...Object.keys(DATE_FORMATTERS))
|
|
88
|
+
} else if (col.type === 'number' || ['el-input-number', 'ElInputNumber'].includes(col.comp)) {
|
|
89
|
+
column.formatters.push(...Object.keys(NUMBER_FORMATTERS))
|
|
90
|
+
}
|
|
91
|
+
return column
|
|
92
|
+
})
|
|
93
|
+
this.dialog.formItems.slice(0, 3).forEach(it => it.options = columns)
|
|
94
|
+
this.handleMakeChart()
|
|
95
|
+
},
|
|
96
|
+
handleCalcFormatters (item) {
|
|
97
|
+
const value = this.dialog.form[item.prop]
|
|
98
|
+
if (!value) {
|
|
99
|
+
this.dialog.form[item.prop + '_formatter'] = ''
|
|
100
|
+
return item.formatters = []
|
|
101
|
+
}
|
|
102
|
+
this.dialog.form[item.prop + '_formatter'] = '原样'
|
|
103
|
+
item.formatters = item.options.find(op => op.prop === value).formatters
|
|
104
|
+
},
|
|
105
|
+
async handleMakeChart () {
|
|
106
|
+
if (this.loading) return
|
|
107
|
+
if (!await this.dialog.formRef?.validate()) return
|
|
108
|
+
this.dialog.visible = false
|
|
109
|
+
this.loading = true
|
|
110
|
+
const rich = { ...this.dialog.form }
|
|
111
|
+
const { category, series, value } = rich
|
|
112
|
+
const attributes = [category, series, value].map(e => {
|
|
113
|
+
return e && this.datasource.columns.find(c => c.label === e)?.prop
|
|
114
|
+
}).filter(e => e)
|
|
115
|
+
if (!rich.filter?.category.isLimit) rich.filter.category.mergeOthers = false
|
|
116
|
+
if (!rich.filter?.series.isLimit) rich.filter.series.mergeOthers = false
|
|
117
|
+
let list = this.datasource.list
|
|
118
|
+
if (this.datasource.search) {
|
|
119
|
+
list = await this.datasource.search({ attributes })
|
|
120
|
+
}
|
|
121
|
+
rich.data = list
|
|
122
|
+
this.setRich(rich)
|
|
123
|
+
this.loading = false
|
|
124
|
+
},
|
|
125
|
+
handleViewData () {
|
|
126
|
+
this.dataDialog.table.columns = this.excel.header.map((label, index) => {
|
|
127
|
+
return {
|
|
128
|
+
label,
|
|
129
|
+
prop: index + '',
|
|
130
|
+
sortable: false,
|
|
131
|
+
tableAttrs: { minWidth: Math.min(label.length * 12 + 20, 150) }
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
this.dataDialog.table.list = this.excel.data
|
|
135
|
+
this.dataDialog.visible = true
|
|
136
|
+
},
|
|
137
|
+
handleDownloadData () {
|
|
138
|
+
StardustBrowser.excel.export2Excel(this.excel)
|
|
139
|
+
},
|
|
140
|
+
setRich (rich) {
|
|
141
|
+
const {
|
|
142
|
+
data,
|
|
143
|
+
category, series, value,
|
|
144
|
+
category_formatter, series_formatter, value_formatter,
|
|
145
|
+
summary, filter, sort,
|
|
146
|
+
chartType, coordinateSystem, grid, fontSizes
|
|
147
|
+
} = rich
|
|
148
|
+
if (!series || !value) return
|
|
149
|
+
const indicators = [category, series, value].filter(ele => ele)
|
|
150
|
+
const cols = indicators.map(ele => {
|
|
151
|
+
return this.datasource.columns.find(col => !col.virtual && col.prop && col.label === ele)
|
|
152
|
+
}).filter(col => col)
|
|
153
|
+
cols.sort((a, b) => indicators.indexOf(a) - indicators.indexOf(b))
|
|
154
|
+
const props = cols.map(col => col.tableAttrs?.linkProp ?? col.prop)
|
|
155
|
+
const numberMarks = cols.map(col => {
|
|
156
|
+
return col.type === 'number' || ['el-input-number', 'ElInputNumber'].includes(col.comp)
|
|
157
|
+
})
|
|
158
|
+
const optionsMarks = cols.map(col => {
|
|
159
|
+
return OPTIONS_COMPONENTS.includes(col.comp) && col.options?.length && !col.tableAttrs?.linkProp
|
|
160
|
+
})
|
|
161
|
+
const optionsDicts = cols.map((col, i) => {
|
|
162
|
+
if (!optionsMarks[i]) return
|
|
163
|
+
const dict = {}
|
|
164
|
+
col.options.forEach(o => {
|
|
165
|
+
const isPlain = typeof o !== 'object'
|
|
166
|
+
const text = isPlain ? o : (col.text || 'text')
|
|
167
|
+
const value = isPlain ? o : (col.value || 'value')
|
|
168
|
+
dict[isPlain ? o : o[value]] = isPlain ? o : o[text]
|
|
169
|
+
})
|
|
170
|
+
return dict
|
|
171
|
+
})
|
|
172
|
+
const dimensions = cols.map(col => col.label)
|
|
173
|
+
const source = data.map(ele => {
|
|
174
|
+
return props.map((d, i) => {
|
|
175
|
+
let value
|
|
176
|
+
if (optionsMarks[i]) {
|
|
177
|
+
value = optionsDicts[i][ele[d]]
|
|
178
|
+
} else {
|
|
179
|
+
value = highdict.get(ele, d)
|
|
180
|
+
if (numberMarks[i]) {
|
|
181
|
+
if (typeof value !== 'number') {
|
|
182
|
+
value = value * 1 || 0
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return value
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
let updated = false
|
|
190
|
+
const params = {
|
|
191
|
+
dimensions,
|
|
192
|
+
source,
|
|
193
|
+
category,
|
|
194
|
+
series,
|
|
195
|
+
value,
|
|
196
|
+
category_formatter, series_formatter, value_formatter,
|
|
197
|
+
filter, sort,
|
|
198
|
+
summary,
|
|
199
|
+
chartType,
|
|
200
|
+
coordinateSystem: chartType === 'bar' || chartType === 'line' ? coordinateSystem : undefined,
|
|
201
|
+
FORMATTERS,
|
|
202
|
+
updateOnce: async option => {
|
|
203
|
+
if (updated) return
|
|
204
|
+
updated = true
|
|
205
|
+
await funcs.sleep(0)
|
|
206
|
+
this.update(option)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const option = StardustEcharts.generateOption(params, this.getOption())
|
|
210
|
+
this.update(option)
|
|
211
|
+
this.hasRendered = true
|
|
212
|
+
this.excel = {
|
|
213
|
+
header: option.dataset[0].dimensions,
|
|
214
|
+
data: option.dataset[0].source,
|
|
215
|
+
filename: StardustJs.funcs.randomUUID()
|
|
216
|
+
}
|
|
217
|
+
if (option.transposition) {
|
|
218
|
+
const header = this.excel.header
|
|
219
|
+
this.excel.header = [series, ...this.excel.data.map(row => row[0])]
|
|
220
|
+
this.excel.data = header.slice(1).map((ele, index) => {
|
|
221
|
+
return [ele, ...this.excel.data.map((row, i) => row[index + 1])]
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
resize () {
|
|
226
|
+
this.zoom = 1 / (parseFloat(document.documentElement.style.zoom) || 1)
|
|
227
|
+
this.chart?.resize()
|
|
228
|
+
},
|
|
229
|
+
getOption () {
|
|
230
|
+
const { devicePixelRatio, maxLimit, query, remote, ...others } = this.option
|
|
231
|
+
const option = {
|
|
232
|
+
tooltip: {},
|
|
233
|
+
toolbox: { feature: { saveAsImage: {} } },
|
|
234
|
+
...others,
|
|
235
|
+
xAxis: { type: 'category' },
|
|
236
|
+
yAxis: {
|
|
237
|
+
type: 'value',
|
|
238
|
+
axisLabel: {
|
|
239
|
+
fontSize: this.fontSizes[1]
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
grid: {
|
|
243
|
+
left: 40, top: 40, right: 20, bottom: 35,
|
|
244
|
+
...this.dialog.form.grid
|
|
245
|
+
},
|
|
246
|
+
legend: { padding: [10, 60] }
|
|
247
|
+
}
|
|
248
|
+
return option
|
|
249
|
+
},
|
|
250
|
+
update (option) {
|
|
251
|
+
const { chartType, coordinateSystem, grid } = this.dialog.form
|
|
252
|
+
if (chartType === 'bar' || chartType === 'line') {
|
|
253
|
+
const axis = coordinateSystem === '直角坐标系-横轴' ? 'xAxis' : 'yAxis'
|
|
254
|
+
highdict.set(option, axis + '.axisLabel.fontSize', this.fontSizes[1])
|
|
255
|
+
}
|
|
256
|
+
option.series?.forEach(ele => {
|
|
257
|
+
highdict.set(ele, 'label.fontSize', this.fontSizes[2])
|
|
258
|
+
})
|
|
259
|
+
option.grid = { ...option.grid, ...grid }
|
|
260
|
+
this.chart?.setOption(option, true)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const { funcs } = StardustBrowser
|
|
2
|
+
|
|
3
|
+
export const props = {
|
|
4
|
+
height: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: '150px'
|
|
7
|
+
},
|
|
8
|
+
option: {
|
|
9
|
+
type: Object,
|
|
10
|
+
default: () => ({})
|
|
11
|
+
},
|
|
12
|
+
updator: Object,
|
|
13
|
+
datasource: Object
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const formItems = [
|
|
17
|
+
{
|
|
18
|
+
label: '分类', prop: 'category', comp: 'x-select',
|
|
19
|
+
text: 'label', value: 'prop', options: [],
|
|
20
|
+
slot: 'selects-formatters', formatters: []
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: '系列', prop: 'series', comp: 'x-select', clearable: false, required: true,
|
|
24
|
+
text: 'label', value: 'prop', options: [],
|
|
25
|
+
slot: 'selects-formatters', formatters: []
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: '值', prop: 'value', comp: 'x-select', clearable: false, required: true,
|
|
29
|
+
text: 'label', value: 'prop', options: [],
|
|
30
|
+
slot: 'selects-formatters', formatters: []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: '汇总方式', prop: 'summary', comp: 'x-select', clearable: false, required: true,
|
|
34
|
+
options: [
|
|
35
|
+
{ text: '求和', value: 'sum' },
|
|
36
|
+
{ text: '平均', value: 'average' },
|
|
37
|
+
{ text: '首个', value: 'first' },
|
|
38
|
+
{ text: '最后一个', value: 'last' },
|
|
39
|
+
{ text: '最大值', value: 'max' },
|
|
40
|
+
{ text: '最小值', value: 'min' },
|
|
41
|
+
{ text: '个数', value: 'count' },
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: '图表类型', prop: 'chartType', comp: 'x-select', clearable: false, required: true,
|
|
46
|
+
options: [
|
|
47
|
+
{ text: '柱状图', value: 'bar' },
|
|
48
|
+
{ text: '折线图', value: 'line' },
|
|
49
|
+
{ text: '饼图', value: 'pie' },
|
|
50
|
+
{ text: '环形图', value: 'pie-doughnut' },
|
|
51
|
+
{ text: '旭日图', value: 'sunburst' }
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: '坐标系', prop: 'coordinateSystem', comp: 'x-select', clearable: false,
|
|
56
|
+
options: ['直角坐标系-横轴', '直角坐标系-纵轴', '极坐标系'],
|
|
57
|
+
when: 'chartType=bar|line'
|
|
58
|
+
},
|
|
59
|
+
{ label: '边距', slot: 'grid' },
|
|
60
|
+
{ label: '数据筛选', slot: 'filter' },
|
|
61
|
+
{ label: '字体大小', slot: 'font-sizes' }
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
export const form = {
|
|
65
|
+
sort: '',
|
|
66
|
+
category: '',
|
|
67
|
+
series: '',
|
|
68
|
+
value: '',
|
|
69
|
+
summary: 'count',
|
|
70
|
+
chartType: 'bar',
|
|
71
|
+
coordinateSystem: '直角坐标系-横轴',
|
|
72
|
+
grid: {
|
|
73
|
+
left: 40,
|
|
74
|
+
top: 40,
|
|
75
|
+
right: 20,
|
|
76
|
+
bottom: 30
|
|
77
|
+
},
|
|
78
|
+
filter: {
|
|
79
|
+
category: { isLimit: false, limit: 10, mergeOthers: false },
|
|
80
|
+
series: { isLimit: false, limit: 10, mergeOthers: false }
|
|
81
|
+
},
|
|
82
|
+
fontSizes: [12, 12, 12]
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function zoomedHeight () {
|
|
86
|
+
return funcs.calcPixel(this.height) * this.zoom + 'px'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function sidebarCollapse () {
|
|
90
|
+
return this.$store.app.sidebarCollapse
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function grid () {
|
|
94
|
+
return this.dialog.form.grid
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function category () {
|
|
98
|
+
return this.dialog.form.filter.category
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function series () {
|
|
102
|
+
return this.dialog.form.filter.series
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function fontSizes () {
|
|
106
|
+
return this.dialog.form.fontSizes
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
props,
|
|
111
|
+
formItems,
|
|
112
|
+
form,
|
|
113
|
+
computed: {
|
|
114
|
+
zoomedHeight,
|
|
115
|
+
sidebarCollapse,
|
|
116
|
+
grid,
|
|
117
|
+
category,
|
|
118
|
+
series,
|
|
119
|
+
fontSizes
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './index.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
v-loading="loading" element-loading-text="加载中..."
|
|
8
|
+
class="x-chart" :class="isMobile ? 'mobile-x-chart' : 'pc-x-chart'"
|
|
9
|
+
>
|
|
10
|
+
<div class="chart-container">
|
|
11
|
+
<div class="chart" ref="el" />
|
|
12
|
+
</div>
|
|
13
|
+
<div class="tools">
|
|
14
|
+
<el-button v-show="!!datasource" icon="setting" @click="dialog.visible = true">
|
|
15
|
+
配置
|
|
16
|
+
</el-button>
|
|
17
|
+
<el-button v-show="hasRendered" icon="View" @click="handleViewData">
|
|
18
|
+
显示数据
|
|
19
|
+
</el-button>
|
|
20
|
+
</div>
|
|
21
|
+
<x-dialog
|
|
22
|
+
v-model="dialog.visible" title="图表配置" drawer class="x-chart-config__dialog"
|
|
23
|
+
width="460" submit-text="生成图表" cancel-text="关闭"
|
|
24
|
+
@submit="handleMakeChart"
|
|
25
|
+
@cancel="dialog.visible = false"
|
|
26
|
+
>
|
|
27
|
+
<x-form :dialog use-when>
|
|
28
|
+
<template #selects-formatters="{ item }">
|
|
29
|
+
<el-row :gutter="5">
|
|
30
|
+
<el-col :span="12">
|
|
31
|
+
<x-select
|
|
32
|
+
v-model="dialog.form[item.prop]" v-bind="item"
|
|
33
|
+
@change="handleCalcFormatters(item)"
|
|
34
|
+
/>
|
|
35
|
+
</el-col>
|
|
36
|
+
<el-col :span="12">
|
|
37
|
+
<x-select
|
|
38
|
+
v-model="dialog.form[item.prop + '_formatter']" :options="item.formatters"
|
|
39
|
+
placeholder="格式化方式"
|
|
40
|
+
/>
|
|
41
|
+
</el-col>
|
|
42
|
+
</el-row>
|
|
43
|
+
</template>
|
|
44
|
+
<template #grid>
|
|
45
|
+
<el-row :gutter="5" class="grid">
|
|
46
|
+
<el-col :span="12">
|
|
47
|
+
<span>左</span>
|
|
48
|
+
<el-input-number v-model="grid.left" />
|
|
49
|
+
</el-col>
|
|
50
|
+
<el-col :span="12">
|
|
51
|
+
<span>上</span>
|
|
52
|
+
<el-input-number v-model="grid.top" />
|
|
53
|
+
</el-col>
|
|
54
|
+
<el-col :span="12">
|
|
55
|
+
<span>右</span>
|
|
56
|
+
<el-input-number v-model="grid.right" />
|
|
57
|
+
</el-col>
|
|
58
|
+
<el-col :span="12">
|
|
59
|
+
<span>下</span>
|
|
60
|
+
<el-input-number v-model="grid.bottom" />
|
|
61
|
+
</el-col>
|
|
62
|
+
</el-row>
|
|
63
|
+
</template>
|
|
64
|
+
<template #filter>
|
|
65
|
+
<label class="sorts flex-center">
|
|
66
|
+
排序方式
|
|
67
|
+
<x-radios v-model="dialog.form.sort" :options="SORTS" />
|
|
68
|
+
</label>
|
|
69
|
+
<el-tabs v-model="filterType">
|
|
70
|
+
<el-tab-pane label="分类" name="分类">
|
|
71
|
+
<el-checkbox v-model="category.isLimit">只使用前有限条记录</el-checkbox>
|
|
72
|
+
<div v-show="category.isLimit">
|
|
73
|
+
记录条数
|
|
74
|
+
<el-input-number v-model="category.limit" :min="0" :precision="0" />
|
|
75
|
+
<el-checkbox v-model="category.mergeOthers">合并剩余项为其他</el-checkbox>
|
|
76
|
+
</div>
|
|
77
|
+
</el-tab-pane>
|
|
78
|
+
<el-tab-pane label="系列" name="系列">
|
|
79
|
+
<el-checkbox v-model="series.isLimit">只使用前有限条记录</el-checkbox>
|
|
80
|
+
<div v-show="series.isLimit">
|
|
81
|
+
记录条数
|
|
82
|
+
<el-input-number v-model="series.limit" :min="0" :precision="0" />
|
|
83
|
+
<el-checkbox v-model="series.mergeOthers">合并剩余项为其他</el-checkbox>
|
|
84
|
+
</div>
|
|
85
|
+
</el-tab-pane>
|
|
86
|
+
</el-tabs>
|
|
87
|
+
</template>
|
|
88
|
+
<template #font-sizes>
|
|
89
|
+
<el-row :gutter="5">
|
|
90
|
+
<el-col :span="8">
|
|
91
|
+
X轴
|
|
92
|
+
<el-input-number v-model="fontSizes[0]" />
|
|
93
|
+
</el-col>
|
|
94
|
+
<el-col :span="8">
|
|
95
|
+
Y轴
|
|
96
|
+
<el-input-number v-model="fontSizes[1]" />
|
|
97
|
+
</el-col>
|
|
98
|
+
<el-col :span="8">
|
|
99
|
+
值
|
|
100
|
+
<el-input-number v-model="fontSizes[2]" />
|
|
101
|
+
</el-col>
|
|
102
|
+
</el-row>
|
|
103
|
+
</template>
|
|
104
|
+
</x-form>
|
|
105
|
+
</x-dialog>
|
|
106
|
+
|
|
107
|
+
<x-dialog
|
|
108
|
+
v-model="dataDialog.visible" width="88%"
|
|
109
|
+
class="x-chart-data__dialog" title="图表数据"
|
|
110
|
+
>
|
|
111
|
+
<el-button icon="Download" @click="handleDownloadData">
|
|
112
|
+
下载数据
|
|
113
|
+
</el-button>
|
|
114
|
+
<x-table :table="dataDialog.table" :max-height="360" plain />
|
|
115
|
+
</x-dialog>
|
|
116
|
+
</div>
|
|
117
|
+
</template>
|
|
118
|
+
|
|
119
|
+
<style lang="scss" scoped>
|
|
120
|
+
.x-chart {
|
|
121
|
+
width: 100%;
|
|
122
|
+
height: 100%;
|
|
123
|
+
position: relative;
|
|
124
|
+
.chart-container {
|
|
125
|
+
height: 100%;
|
|
126
|
+
overflow-y: auto;
|
|
127
|
+
zoom: v-bind('zoom');
|
|
128
|
+
}
|
|
129
|
+
.chart {
|
|
130
|
+
height: v-bind('zoomedHeight');
|
|
131
|
+
}
|
|
132
|
+
.tools {
|
|
133
|
+
position: absolute;
|
|
134
|
+
left: 310px;
|
|
135
|
+
top: -40px;
|
|
136
|
+
}
|
|
137
|
+
&-config__dialog {
|
|
138
|
+
.el-form-item {
|
|
139
|
+
margin-bottom: 10px;
|
|
140
|
+
}
|
|
141
|
+
.grid {
|
|
142
|
+
.el-col {
|
|
143
|
+
margin-bottom: 5px;
|
|
144
|
+
}
|
|
145
|
+
span {
|
|
146
|
+
display: inline-block;
|
|
147
|
+
width: 20px;
|
|
148
|
+
}
|
|
149
|
+
.el-input-number {
|
|
150
|
+
width: calc(100% - 20px);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
.sorts {
|
|
154
|
+
height: 32px;
|
|
155
|
+
justify-content: flex-start;
|
|
156
|
+
.el-radio-group {
|
|
157
|
+
margin-left: 20px;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
</style>
|
|
163
|
+
|
|
164
|
+
<style lang="scss">
|
|
165
|
+
.x-chart-data__dialog {
|
|
166
|
+
.el-dialog__body {
|
|
167
|
+
padding: 10px;
|
|
168
|
+
}
|
|
169
|
+
.el-button {
|
|
170
|
+
margin-bottom: 10px;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
</style>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { formatOptions } from '../../utils/index.js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: 'MobileXCheckboxs',
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
text: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'text'
|
|
10
|
+
},
|
|
11
|
+
plain: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
value: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'value'
|
|
18
|
+
},
|
|
19
|
+
shape: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: 'square'
|
|
22
|
+
},
|
|
23
|
+
direction: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'horizontal'
|
|
26
|
+
},
|
|
27
|
+
sort: Boolean | String,
|
|
28
|
+
options: Array | Object
|
|
29
|
+
},
|
|
30
|
+
emits: ['change'],
|
|
31
|
+
data () {
|
|
32
|
+
return {
|
|
33
|
+
_options: []
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
computed: {
|
|
37
|
+
attrs () {
|
|
38
|
+
const {
|
|
39
|
+
clearable,
|
|
40
|
+
platform,
|
|
41
|
+
placeholder,
|
|
42
|
+
rules,
|
|
43
|
+
required,
|
|
44
|
+
...others
|
|
45
|
+
} = this.$attrs
|
|
46
|
+
return others
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
watch: {
|
|
50
|
+
options: {
|
|
51
|
+
immediate: true,
|
|
52
|
+
deep: true,
|
|
53
|
+
handler () {
|
|
54
|
+
this._options = formatOptions(this.options, this)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './mobile.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<van-checkbox-group
|
|
7
|
+
class="x-checkboxs mobile-x-checkboxs"
|
|
8
|
+
:class="plain ? 'mobile-x-checkboxs--plain' : ''"
|
|
9
|
+
v-bind="attrs"
|
|
10
|
+
:direction
|
|
11
|
+
@change="$emit('change', $event)"
|
|
12
|
+
>
|
|
13
|
+
<van-checkbox
|
|
14
|
+
v-for="option in _options"
|
|
15
|
+
v-bind="attrs"
|
|
16
|
+
:disabled="option.raw?.disabled"
|
|
17
|
+
:key="option.text"
|
|
18
|
+
:shape
|
|
19
|
+
:name="option.value"
|
|
20
|
+
>
|
|
21
|
+
{{ option.text }}
|
|
22
|
+
</van-checkbox>
|
|
23
|
+
</van-checkbox-group>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<style lang="scss" scoped>
|
|
27
|
+
.mobile-x-checkboxs--plain {
|
|
28
|
+
:deep(.van-checkbox) {
|
|
29
|
+
margin-right: 20px;
|
|
30
|
+
.van-checkbox__icon {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
.van-checkbox__icon--checked ~ .van-checkbox__label {
|
|
34
|
+
color: var(--van-blue);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { formatOptions } from '../../utils/index.js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: 'PcXCheckboxs',
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: Array,
|
|
8
|
+
plain: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false
|
|
11
|
+
},
|
|
12
|
+
text: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'text'
|
|
15
|
+
},
|
|
16
|
+
value: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'value'
|
|
19
|
+
},
|
|
20
|
+
sort: Boolean | String,
|
|
21
|
+
options: Array | Object
|
|
22
|
+
},
|
|
23
|
+
emits: ['update:modelValue', 'change'],
|
|
24
|
+
data () {
|
|
25
|
+
return {
|
|
26
|
+
_options: []
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
computed: {
|
|
30
|
+
attrs () {
|
|
31
|
+
const {
|
|
32
|
+
clearable,
|
|
33
|
+
platform,
|
|
34
|
+
placeholder,
|
|
35
|
+
...others
|
|
36
|
+
} = this.$attrs
|
|
37
|
+
return others
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
watch: {
|
|
41
|
+
options: {
|
|
42
|
+
immediate: true,
|
|
43
|
+
deep: true,
|
|
44
|
+
handler (value) {
|
|
45
|
+
this._options = formatOptions(value, this)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|