@weitutech/by-components 1.0.31 → 1.1.0
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/.babelrc +7 -0
- package/.editorconfig +19 -0
- package/.eslintignore +9 -0
- package/.eslintrc.cjs +65 -0
- package/.prettierignore +9 -0
- package/.prettierrc +22 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +27 -0
- package/CHANGELOG.md +14 -0
- package/README.md +30 -3
- package/docs/form.md +42 -1
- package/docs/table.md +25 -8
- package/lib/by-components.common.js +7831 -58668
- package/lib/by-components.umd.js +7631 -58451
- package/lib/by-components.umd.min.js +2 -301
- package/package.json +18 -4
- package/src/components/custom-column/index.vue +83 -58
- package/src/components/fold-search/index.vue +15 -5
- package/src/components/form/comps/custom-date-picker.vue +75 -39
- package/src/components/form/comps/date-picker-range.vue +47 -13
- package/src/components/form/comps/pair-number-input.vue +27 -15
- package/src/components/form/comps/select.vue +11 -8
- package/src/components/form/form.vue +89 -41
- package/src/components/page-search/page-search.vue +17 -9
- package/src/components/pager/index.vue +16 -10
- package/src/components/table/index.vue +190 -59
- package/src/index.js +2 -2
- package/src/plugin/vxeTable.js +3 -3
- package/src/style/custom-column.scss +6 -8
- package/src/style/index.scss +13 -6
- package/src/utils/index.js +3 -3
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weitutech/by-components",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "src/index",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.vue",
|
|
8
|
+
"*.scss"
|
|
9
|
+
],
|
|
6
10
|
"scripts": {
|
|
7
11
|
"dev": "vue-cli-service serve",
|
|
8
12
|
"build": "npm run build:js && npm run build:css",
|
|
9
13
|
"build:js": "vue-cli-service build --target lib --name by-components src/index.js",
|
|
10
|
-
"build:css": "sass src/style/index.scss lib/index.css --no-source-map --style=compressed"
|
|
14
|
+
"build:css": "sass src/style/index.scss lib/index.css --no-source-map --style=compressed",
|
|
15
|
+
"lint:fix": "eslint --ext .js,.vue src --fix",
|
|
16
|
+
"format": "prettier --write \"src/**/*.{js,vue,json,scss}\""
|
|
11
17
|
},
|
|
12
18
|
"dependencies": {
|
|
13
19
|
"axios": "^1.7.7",
|
|
@@ -18,15 +24,23 @@
|
|
|
18
24
|
"moment": "^2.30.1",
|
|
19
25
|
"vue": "^2.6.14",
|
|
20
26
|
"vuedraggable": "^2.24.3",
|
|
21
|
-
"vxe-table": "3.8.24"
|
|
27
|
+
"vxe-table": "^3.8.24"
|
|
22
28
|
},
|
|
23
29
|
"devDependencies": {
|
|
30
|
+
"@babel/core": "^7.19.1",
|
|
24
31
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
25
32
|
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
33
|
+
"@babel/preset-env": "^7.27.2",
|
|
26
34
|
"@vue/cli-plugin-babel": "~5.0.0",
|
|
27
35
|
"@vue/cli-service": "~5.0.0",
|
|
36
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
37
|
+
"eslint": "^8.57.1",
|
|
38
|
+
"eslint-config-prettier": "^9.1.0",
|
|
39
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
40
|
+
"eslint-plugin-vue": "^9.3.0",
|
|
41
|
+
"prettier": "^3.5.3",
|
|
28
42
|
"sass": "^1.79.4",
|
|
29
43
|
"sass-loader": "^16.0.2",
|
|
30
44
|
"vue-template-compiler": "^2.6.14"
|
|
31
45
|
}
|
|
32
|
-
}
|
|
46
|
+
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<!-- 数据指标 -->
|
|
15
15
|
<div class="left_box">
|
|
16
16
|
<div class="box_title">数据指标</div>
|
|
17
|
-
<div class="row" style="padding-right: 20px
|
|
17
|
+
<div class="row" style="padding-right: 20px">
|
|
18
18
|
<div class="cell">
|
|
19
19
|
<el-input
|
|
20
20
|
v-model="search"
|
|
@@ -40,7 +40,11 @@
|
|
|
40
40
|
</ul>
|
|
41
41
|
</div>
|
|
42
42
|
<div class="left_menu">
|
|
43
|
-
<div
|
|
43
|
+
<div
|
|
44
|
+
v-for="(item, index) in checkBoxMenuBySearch"
|
|
45
|
+
:key="index"
|
|
46
|
+
ref="tagItem"
|
|
47
|
+
>
|
|
44
48
|
<div class="checkbox_title">
|
|
45
49
|
{{ item.label }}
|
|
46
50
|
</div>
|
|
@@ -49,11 +53,11 @@
|
|
|
49
53
|
v-for="(each, idx) in item.data"
|
|
50
54
|
:key="idx"
|
|
51
55
|
:span="12"
|
|
52
|
-
style="margin-bottom:3px"
|
|
56
|
+
style="margin-bottom: 3px"
|
|
53
57
|
>
|
|
54
58
|
<el-checkbox
|
|
55
59
|
v-model="each.type"
|
|
56
|
-
@change="changeCheckbox(each.key,each.type)"
|
|
60
|
+
@change="changeCheckbox(each.key, each.type)"
|
|
57
61
|
>
|
|
58
62
|
{{ each.label }}
|
|
59
63
|
</el-checkbox>
|
|
@@ -68,7 +72,7 @@
|
|
|
68
72
|
<div class="drag_box">
|
|
69
73
|
<el-row>
|
|
70
74
|
<div class="drag_text_box">
|
|
71
|
-
<span class="drag_title">{{`已选指标(${number})`}}</span>
|
|
75
|
+
<span class="drag_title">{{ `已选指标(${number})` }}</span>
|
|
72
76
|
<span class="recover" @click="recoverDefault">恢复默认</span>
|
|
73
77
|
</div>
|
|
74
78
|
</el-row>
|
|
@@ -82,9 +86,11 @@
|
|
|
82
86
|
>
|
|
83
87
|
<transition-group>
|
|
84
88
|
<div
|
|
85
|
-
v-for="
|
|
89
|
+
v-for="col in draggableMenu"
|
|
86
90
|
v-show="col.type"
|
|
87
|
-
:class="
|
|
91
|
+
:class="
|
|
92
|
+
col.key === 'sort-cut-off' ? 'fixedClass' : 'drag_li_box'
|
|
93
|
+
"
|
|
88
94
|
:key="col.key"
|
|
89
95
|
>
|
|
90
96
|
<div v-if="col.key !== 'sort-cut-off'">
|
|
@@ -105,17 +111,16 @@
|
|
|
105
111
|
</div>
|
|
106
112
|
<template #footer>
|
|
107
113
|
<el-row style="margin-top: 7px">
|
|
108
|
-
<el-button
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
@click="closeDialog"
|
|
112
|
-
>取消</el-button>
|
|
114
|
+
<el-button size="small" style="width: 96px" @click="closeDialog"
|
|
115
|
+
>取消</el-button
|
|
116
|
+
>
|
|
113
117
|
<el-button
|
|
114
118
|
size="small"
|
|
115
119
|
style="width: 96px"
|
|
116
120
|
type="primary"
|
|
117
121
|
@click="submit"
|
|
118
|
-
|
|
122
|
+
>确定</el-button
|
|
123
|
+
>
|
|
119
124
|
</el-row>
|
|
120
125
|
</template>
|
|
121
126
|
</el-dialog>
|
|
@@ -123,10 +128,10 @@
|
|
|
123
128
|
</template>
|
|
124
129
|
|
|
125
130
|
<script>
|
|
126
|
-
import draggable from
|
|
127
|
-
import { deepClone } from
|
|
131
|
+
import draggable from 'vuedraggable'
|
|
132
|
+
import { deepClone } from '../../utils/index'
|
|
128
133
|
export default {
|
|
129
|
-
name:
|
|
134
|
+
name: 'CustomColumn',
|
|
130
135
|
components: {
|
|
131
136
|
draggable
|
|
132
137
|
},
|
|
@@ -156,28 +161,33 @@ export default {
|
|
|
156
161
|
/** 表头id */
|
|
157
162
|
id: undefined,
|
|
158
163
|
/** 表格列接口路径 */
|
|
159
|
-
page:
|
|
164
|
+
page: '',
|
|
160
165
|
/** 搜索字段 */
|
|
161
|
-
search:
|
|
166
|
+
search: ''
|
|
162
167
|
}
|
|
163
168
|
},
|
|
164
169
|
computed: {
|
|
165
170
|
number() {
|
|
166
|
-
return this.draggableMenu.filter(
|
|
171
|
+
return this.draggableMenu.filter(
|
|
172
|
+
item => item.type && item.key !== 'sort-cut-off'
|
|
173
|
+
).length
|
|
167
174
|
},
|
|
168
175
|
checkBoxMenuBySearch() {
|
|
169
176
|
if (this.search) {
|
|
170
|
-
return this.checkBoxMenu
|
|
171
|
-
|
|
177
|
+
return this.checkBoxMenu
|
|
178
|
+
.map(group => {
|
|
179
|
+
const filteredItems = group.data.filter(item =>
|
|
180
|
+
item.label.includes(this.search)
|
|
181
|
+
)
|
|
172
182
|
return {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
183
|
+
label: group.label,
|
|
184
|
+
data: filteredItems
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
.filter(group => group.data.length > 0)
|
|
177
188
|
} else {
|
|
178
189
|
return this.checkBoxMenu
|
|
179
190
|
}
|
|
180
|
-
|
|
181
191
|
}
|
|
182
192
|
},
|
|
183
193
|
methods: {
|
|
@@ -189,14 +199,14 @@ export default {
|
|
|
189
199
|
*/
|
|
190
200
|
async getCustomTableList(page, column) {
|
|
191
201
|
if (!page) {
|
|
192
|
-
throw new Error(
|
|
202
|
+
throw new Error('缺少表格列接口路径')
|
|
193
203
|
} else {
|
|
194
204
|
// 克隆一份
|
|
195
205
|
this.columnList = this.deepClone(column)
|
|
196
|
-
this.page = page ||
|
|
206
|
+
this.page = page || ''
|
|
197
207
|
const bePreservedColumn = []
|
|
198
208
|
const res = await this.infoMethod({ page: page })
|
|
199
|
-
if (JSON.stringify(res.data) !==
|
|
209
|
+
if (JSON.stringify(res.data) !== '[]') {
|
|
200
210
|
this.id = res.data.id || undefined
|
|
201
211
|
res.data.column.forEach(col => bePreservedColumn.push(...col.data))
|
|
202
212
|
}
|
|
@@ -209,38 +219,42 @@ export default {
|
|
|
209
219
|
* @param { object[] } bePreservedColumn 被保存过的列数据
|
|
210
220
|
*/
|
|
211
221
|
initTableList(initColumn, bePreservedColumn = []) {
|
|
212
|
-
const setDraggableMenu =
|
|
222
|
+
const setDraggableMenu = arr => {
|
|
213
223
|
const cols = []
|
|
214
224
|
arr.forEach(item => cols.push(...item.data))
|
|
215
225
|
cols.sort((a, b) => a.sort - b.sort)
|
|
216
|
-
if(cols.some(item=> item.fixed)) {
|
|
226
|
+
if (cols.some(item => item.fixed)) {
|
|
217
227
|
let cutOffIndex = 0
|
|
218
|
-
for(let index = 0; index <= cols.length; index++) {
|
|
228
|
+
for (let index = 0; index <= cols.length; index++) {
|
|
219
229
|
const col = cols[index]
|
|
220
230
|
const nextCol = cols[index + 1]
|
|
221
|
-
if (col.fixed ===
|
|
231
|
+
if (col.fixed === 'left' && (!nextCol || !nextCol.fixed)) {
|
|
222
232
|
cutOffIndex = index + 1
|
|
223
233
|
break
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
236
|
cols.splice(cutOffIndex, 0, {
|
|
227
237
|
type: true,
|
|
228
|
-
label:
|
|
229
|
-
key:
|
|
230
|
-
parent:
|
|
238
|
+
label: '',
|
|
239
|
+
key: 'sort-cut-off',
|
|
240
|
+
parent: ''
|
|
231
241
|
})
|
|
232
242
|
}
|
|
233
243
|
return cols
|
|
234
244
|
}
|
|
235
245
|
if (bePreservedColumn && bePreservedColumn.length > 0) {
|
|
236
246
|
// 需要处理被保存过的进行回显
|
|
237
|
-
initColumn.forEach(
|
|
238
|
-
cols.data.forEach(
|
|
239
|
-
const beSaveCol =
|
|
240
|
-
|
|
247
|
+
initColumn.forEach(cols => {
|
|
248
|
+
cols.data.forEach(col => {
|
|
249
|
+
const beSaveCol =
|
|
250
|
+
bePreservedColumn.find(item => item.key === col.key) || {}
|
|
251
|
+
col.type =
|
|
252
|
+
beSaveCol.type === 'true' || beSaveCol.type === true
|
|
253
|
+
? true
|
|
254
|
+
: false
|
|
241
255
|
col.sort = beSaveCol.sort
|
|
242
|
-
col.fixed = beSaveCol.fixed ? beSaveCol.fixed : col.fixed,
|
|
243
|
-
|
|
256
|
+
;(col.fixed = beSaveCol.fixed ? beSaveCol.fixed : col.fixed),
|
|
257
|
+
(col.parent = { label: cols.label })
|
|
244
258
|
})
|
|
245
259
|
})
|
|
246
260
|
// 需要显示的列的数据
|
|
@@ -249,26 +263,32 @@ export default {
|
|
|
249
263
|
} else {
|
|
250
264
|
// 从未被保存过
|
|
251
265
|
let num = 0
|
|
252
|
-
initColumn.forEach(
|
|
253
|
-
cols.data.forEach(
|
|
266
|
+
initColumn.forEach(cols => {
|
|
267
|
+
cols.data.forEach(col => {
|
|
254
268
|
num++
|
|
255
269
|
col.type = true
|
|
256
|
-
col.width = col.width ? +col.width : 0,
|
|
257
|
-
col.sort = num
|
|
270
|
+
;(col.width = col.width ? +col.width : 0), (col.sort = num)
|
|
258
271
|
col.parent = { label: cols.label }
|
|
259
272
|
})
|
|
260
273
|
})
|
|
261
274
|
this.checkBoxMenu = this.deepClone(initColumn)
|
|
262
275
|
this.draggableMenu = setDraggableMenu(this.checkBoxMenu)
|
|
263
276
|
}
|
|
264
|
-
this.$emit(
|
|
265
|
-
|
|
277
|
+
this.$emit(
|
|
278
|
+
'changeTable',
|
|
279
|
+
this.draggableMenu
|
|
280
|
+
.filter(item => item.key !== 'sort-cut-off')
|
|
281
|
+
.sort((a, b) => a.sort - b.sort)
|
|
282
|
+
)
|
|
283
|
+
this.$emit('changeTableGroup', this.checkBoxMenu)
|
|
266
284
|
},
|
|
267
285
|
// 全不选
|
|
268
286
|
selectNone() {
|
|
269
|
-
this.checkBoxMenu.forEach(cols =>
|
|
287
|
+
this.checkBoxMenu.forEach(cols =>
|
|
288
|
+
cols.data.forEach(col => (col.type = false))
|
|
289
|
+
)
|
|
270
290
|
this.draggableMenu.forEach(item => {
|
|
271
|
-
if (item.key ===
|
|
291
|
+
if (item.key === 'sort-cut-off') {
|
|
272
292
|
item.type = true
|
|
273
293
|
} else {
|
|
274
294
|
item.type = false
|
|
@@ -282,7 +302,7 @@ export default {
|
|
|
282
302
|
setHighlight(index) {
|
|
283
303
|
this.activeId = index
|
|
284
304
|
if (this.$refs.tagItem) {
|
|
285
|
-
this.$refs.tagItem[index].scrollIntoView({ behavior:
|
|
305
|
+
this.$refs.tagItem[index].scrollIntoView({ behavior: 'smooth' })
|
|
286
306
|
}
|
|
287
307
|
},
|
|
288
308
|
/**
|
|
@@ -312,10 +332,12 @@ export default {
|
|
|
312
332
|
onEnd() {
|
|
313
333
|
let isFixed = true
|
|
314
334
|
this.draggableMenu.forEach((item, index) => {
|
|
315
|
-
if (item.key ===
|
|
335
|
+
if (item.key === 'sort-cut-off') {
|
|
336
|
+
isFixed = false
|
|
337
|
+
}
|
|
316
338
|
if (isFixed) {
|
|
317
339
|
item.sort = index + 1
|
|
318
|
-
item.fixed =
|
|
340
|
+
item.fixed = 'left'
|
|
319
341
|
} else {
|
|
320
342
|
item.sort = index
|
|
321
343
|
delete item.fixed
|
|
@@ -330,7 +352,7 @@ export default {
|
|
|
330
352
|
page: this.page
|
|
331
353
|
}
|
|
332
354
|
this.draggableMenu.forEach(item => {
|
|
333
|
-
if (item.key !==
|
|
355
|
+
if (item.key !== 'sort-cut-off') {
|
|
334
356
|
const { parent, ...other } = item
|
|
335
357
|
// 是否存在
|
|
336
358
|
const isExit = params.column.some(col => col.label === parent.label)
|
|
@@ -353,16 +375,19 @@ export default {
|
|
|
353
375
|
params.column.forEach(item => {
|
|
354
376
|
cols.push(...item.data)
|
|
355
377
|
})
|
|
356
|
-
this.$emit(
|
|
357
|
-
|
|
378
|
+
this.$emit(
|
|
379
|
+
'changeTable',
|
|
380
|
+
cols.sort((a, b) => a.sort - b.sort)
|
|
381
|
+
)
|
|
382
|
+
this.$emit('changeTableGroup', params.column)
|
|
358
383
|
this.closeDialog()
|
|
359
384
|
},
|
|
360
385
|
// 关闭弹窗
|
|
361
386
|
closeDialog() {
|
|
362
387
|
// 重置数据
|
|
363
|
-
this.search =
|
|
388
|
+
this.search = ''
|
|
364
389
|
this.activeId = 0
|
|
365
|
-
this.$emit(
|
|
390
|
+
this.$emit('closeDialog')
|
|
366
391
|
}
|
|
367
392
|
}
|
|
368
393
|
}
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
<div class="drawer_query_btn b-fold-search">
|
|
3
3
|
<div @click="drawer">
|
|
4
4
|
<template v-if="show == true">
|
|
5
|
-
<span style="color: #3aa1ff; vertical-align:middle
|
|
5
|
+
<span style="color: #3aa1ff; vertical-align: middle">收起</span>
|
|
6
|
+
|
|
7
|
+
<img
|
|
8
|
+
style="vertical-align: middle"
|
|
9
|
+
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTg3Ny41IDU2NS45bC0zNjcuNi0zNDAtMzY3LjYgMzQwYy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xTDQ5NSAxMTcuNWMwLTcuMiA3LjUtNy4yIDE1LTcuMnM3LjUgMCAxNSA3LjJsNDIwLjIgMzgzLjNjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjcgMTQuNS01Mi43IDE0LjUtNjcuNyAwek00OTQuOCA0NTAuMWMwLTcuMiA3LjUtNy4yIDE1LTcuMnMxNSAwIDE1IDcuMkw5NDUgODMzLjRjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjUgMTQuNC01Mi41IDE0LjQtNjcuNSAwTDUwOS44IDU1OC42IDE0Mi4yIDkwNS44Yy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xbDQyMC4xLTM5MC42eiBtMCAwIiAvPjwvc3ZnPg=="
|
|
10
|
+
alt="收起"
|
|
11
|
+
/>
|
|
6
12
|
</template>
|
|
7
13
|
<template v-else>
|
|
8
|
-
<span style="color: #3aa1ff; vertical-align:middle
|
|
14
|
+
<span style="color: #3aa1ff; vertical-align: middle">展开更多</span>
|
|
15
|
+
|
|
16
|
+
<img
|
|
17
|
+
style="vertical-align: middle"
|
|
18
|
+
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTE0NS40IDQ2MS4xbDM2Ny42IDM0MCAzNjcuNi0zNDBjMjIuNS0xNC41IDUyLjUtMTQuNSA2Ny41IDAgMTUgMjEuNyAxNSA1MC43IDAgNjUuMUw1MjcuOSA5MDkuNWMwIDcuMi03LjUgNy4yLTE1IDcuMnMtNy41IDAtMTUtNy4yTDc3LjcgNTI2LjJjLTIyLjUtMjEuNy0xNS01MC42IDAtNjUuMSAyMi42LTE0LjUgNTIuNi0xNC41IDY3LjcgMHpNNTI4IDU3Ni45YzAgNy4yLTcuNSA3LjItMTUgNy4ycy0xNSAwLTE1LTcuMkw3Ny44IDE5My42Yy0yMi41LTIxLjctMTUtNTAuNiAwLTY1LjEgMjIuNS0xNC40IDUyLjUtMTQuNCA2Ny41IDBMNTEzIDQ2OC40bDM2Ny42LTM0Ny4yYzIyLjUtMTQuNSA1Mi41LTE0LjUgNjcuNSAwIDE1IDIxLjcgMTUgNTAuNyAwIDY1LjFMNTI4IDU3Ni45eiBtMCAwIiAvPjwvc3ZnPg=="
|
|
19
|
+
alt="展开更多"
|
|
20
|
+
/>
|
|
9
21
|
</template>
|
|
10
22
|
</div>
|
|
11
23
|
</div>
|
|
@@ -20,10 +32,8 @@ export default {
|
|
|
20
32
|
methods: {
|
|
21
33
|
drawer(value) {
|
|
22
34
|
this.show = !this.show
|
|
23
|
-
this.$emit(
|
|
35
|
+
this.$emit('change', this.show)
|
|
24
36
|
}
|
|
25
|
-
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
39
|
</script>
|
|
29
|
-
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script>
|
|
24
|
-
import moment from
|
|
24
|
+
import moment from 'moment'
|
|
25
25
|
export default {
|
|
26
26
|
props: {
|
|
27
27
|
value: {
|
|
@@ -32,46 +32,77 @@ export default {
|
|
|
32
32
|
otherOption: {
|
|
33
33
|
type: Object,
|
|
34
34
|
default: () => ({
|
|
35
|
-
startPlaceholder:
|
|
36
|
-
endPlaceholder:
|
|
37
|
-
type:
|
|
38
|
-
rangeSeparator:
|
|
39
|
-
size:
|
|
40
|
-
active:
|
|
35
|
+
startPlaceholder: '开始时间',
|
|
36
|
+
endPlaceholder: '结束时间',
|
|
37
|
+
type: 'daterange',
|
|
38
|
+
rangeSeparator: '-',
|
|
39
|
+
size: 'mini',
|
|
40
|
+
active: ''
|
|
41
41
|
})
|
|
42
42
|
},
|
|
43
43
|
startTimeField: {
|
|
44
44
|
type: String,
|
|
45
|
-
default:
|
|
45
|
+
default: ''
|
|
46
46
|
},
|
|
47
47
|
endTimeField: {
|
|
48
48
|
type: String,
|
|
49
|
-
default:
|
|
49
|
+
default: ''
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
|
|
53
53
|
data() {
|
|
54
54
|
return {
|
|
55
55
|
shortcuts: [
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
{
|
|
57
|
+
label: '上月',
|
|
58
|
+
start_time: moment()
|
|
59
|
+
.subtract(1, 'months')
|
|
60
|
+
.startOf('month')
|
|
61
|
+
.format('YYYY-MM-DD'),
|
|
62
|
+
end_time: moment()
|
|
63
|
+
.subtract(1, 'months')
|
|
64
|
+
.endOf('month')
|
|
65
|
+
.format('YYYY-MM-DD'),
|
|
66
|
+
key: 'last_month'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: '昨天',
|
|
70
|
+
start_time: moment().subtract(1, 'days').format('YYYY-MM-DD'),
|
|
71
|
+
end_time: moment().subtract(1, 'days').format('YYYY-MM-DD'),
|
|
72
|
+
key: 'yesterday'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: '今天',
|
|
76
|
+
start_time: moment().startOf('day').format('YYYY-MM-DD'),
|
|
77
|
+
end_time: moment().startOf('day').format('YYYY-MM-DD'),
|
|
78
|
+
key: 'today'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
label: '本周',
|
|
82
|
+
start_time: moment().startOf('week').format('YYYY-MM-DD'),
|
|
83
|
+
end_time: moment().endOf('week').format('YYYY-MM-DD'),
|
|
84
|
+
key: 'week'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: '本月',
|
|
88
|
+
start_time: moment().startOf('month').format('YYYY-MM-DD'),
|
|
89
|
+
end_time: moment().endOf('month').format('YYYY-MM-DD'),
|
|
90
|
+
key: 'month'
|
|
91
|
+
}
|
|
61
92
|
],
|
|
62
|
-
active:
|
|
93
|
+
active: ''
|
|
63
94
|
}
|
|
64
95
|
},
|
|
65
96
|
|
|
66
97
|
computed: {
|
|
67
98
|
dateOptions() {
|
|
68
99
|
return {
|
|
69
|
-
startPlaceholder:
|
|
70
|
-
endPlaceholder:
|
|
71
|
-
type:
|
|
72
|
-
rangeSeparator:
|
|
73
|
-
size:
|
|
74
|
-
active:
|
|
100
|
+
startPlaceholder: '开始时间',
|
|
101
|
+
endPlaceholder: '结束时间',
|
|
102
|
+
type: 'daterange',
|
|
103
|
+
rangeSeparator: '至',
|
|
104
|
+
size: 'mini',
|
|
105
|
+
active: '',
|
|
75
106
|
...this.otherOption
|
|
76
107
|
}
|
|
77
108
|
}
|
|
@@ -81,15 +112,20 @@ export default {
|
|
|
81
112
|
value: {
|
|
82
113
|
handler(newValue, oldValue) {
|
|
83
114
|
if (newValue && newValue.length) {
|
|
84
|
-
this.active =
|
|
115
|
+
this.active = ''
|
|
85
116
|
this.shortcuts.forEach(item => {
|
|
86
|
-
if (
|
|
117
|
+
if (
|
|
118
|
+
item.start_time === newValue[0] &&
|
|
119
|
+
item.end_time === newValue[1]
|
|
120
|
+
) {
|
|
87
121
|
this.active = item.key
|
|
88
122
|
}
|
|
89
123
|
})
|
|
90
124
|
} else {
|
|
91
125
|
this.active = this.dateOptions.active
|
|
92
|
-
const item =
|
|
126
|
+
const item =
|
|
127
|
+
this.shortcuts.find(item => item.key === this.dateOptions.active) ||
|
|
128
|
+
{}
|
|
93
129
|
if (item.start_time && item.end_time) {
|
|
94
130
|
this.handleClick(item)
|
|
95
131
|
}
|
|
@@ -98,35 +134,35 @@ export default {
|
|
|
98
134
|
immediate: true
|
|
99
135
|
}
|
|
100
136
|
},
|
|
101
|
-
|
|
137
|
+
|
|
102
138
|
methods: {
|
|
103
139
|
handleChange(e) {
|
|
104
140
|
if (!e) {
|
|
105
|
-
this.$emit(
|
|
141
|
+
this.$emit('input', [])
|
|
106
142
|
if (this.startTimeField && this.endTimeField) {
|
|
107
|
-
this.$emit(
|
|
143
|
+
this.$emit('range-change', { startTime: '', endTime: '' })
|
|
108
144
|
}
|
|
109
145
|
} else {
|
|
110
|
-
const formattedDates = e.map(item => moment(item).format(
|
|
111
|
-
this.$emit(
|
|
112
|
-
|
|
146
|
+
const formattedDates = e.map(item => moment(item).format('YYYY-MM-DD'))
|
|
147
|
+
this.$emit('input', formattedDates)
|
|
148
|
+
|
|
113
149
|
if (this.startTimeField && this.endTimeField) {
|
|
114
|
-
this.$emit(
|
|
115
|
-
startTime: formattedDates[0],
|
|
116
|
-
endTime: formattedDates[1]
|
|
150
|
+
this.$emit('range-change', {
|
|
151
|
+
startTime: formattedDates[0],
|
|
152
|
+
endTime: formattedDates[1]
|
|
117
153
|
})
|
|
118
154
|
}
|
|
119
155
|
}
|
|
120
|
-
this.active =
|
|
156
|
+
this.active = ''
|
|
121
157
|
},
|
|
122
158
|
handleClick(item) {
|
|
123
159
|
this.active = item.key
|
|
124
|
-
this.$emit(
|
|
125
|
-
|
|
160
|
+
this.$emit('input', [item.start_time, item.end_time])
|
|
161
|
+
|
|
126
162
|
if (this.startTimeField && this.endTimeField) {
|
|
127
|
-
this.$emit(
|
|
128
|
-
startTime: item.start_time,
|
|
129
|
-
endTime: item.end_time
|
|
163
|
+
this.$emit('range-change', {
|
|
164
|
+
startTime: item.start_time,
|
|
165
|
+
endTime: item.end_time
|
|
130
166
|
})
|
|
131
167
|
}
|
|
132
168
|
}
|