@weitutech/by-components 1.0.27 → 1.0.28
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/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/components/custom-column/index.vue +0 -369
- package/src/components/fold-search/index.vue +0 -29
- package/src/components/form/comps/custom-date-picker.vue +0 -109
- package/src/components/form/comps/date-picker-range.vue +0 -78
- package/src/components/form/comps/pair-number-input.vue +0 -67
- package/src/components/form/comps/select.vue +0 -127
- package/src/components/form/form.vue +0 -352
- package/src/components/page-search/page-search.vue +0 -114
- package/src/components/pager/index.vue +0 -81
- package/src/components/table/index.vue +0 -219
- package/src/index.js +0 -31
- package/src/plugin/vxeTable.js +0 -300
- package/src/plugin/vxeTable.scss +0 -14
- package/src/style/custom-column.scss +0 -194
- package/src/style/fold-search.scss +0 -21
- package/src/style/form.scss +0 -342
- package/src/style/index.scss +0 -6
- package/src/style/page-search.scss +0 -26
- package/src/style/pager.scss +0 -40
- package/src/style/table.scss +0 -39
- package/src/utils/index.js +0 -32
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weitutech/by-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"private": false,
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "lib/by-components.umd.min.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "npm run build:js && npm run build:css",
|
|
8
8
|
"build:js": "vue-cli-service build --target lib --name by-components src/index.js",
|
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
<!-- 自定义表头 -->
|
|
2
|
-
<template>
|
|
3
|
-
<div id="custom_column">
|
|
4
|
-
<el-dialog
|
|
5
|
-
:close-on-click-modal="false"
|
|
6
|
-
:visible="dialogVisible"
|
|
7
|
-
width="920px"
|
|
8
|
-
:append-to-body="true"
|
|
9
|
-
:show-close="false"
|
|
10
|
-
custom-class="custom_dialog_class"
|
|
11
|
-
@close="closeDialog"
|
|
12
|
-
>
|
|
13
|
-
<div class="el-dialog-box">
|
|
14
|
-
<!-- 数据指标 -->
|
|
15
|
-
<div class="left_box">
|
|
16
|
-
<div class="box_title">数据指标</div>
|
|
17
|
-
<div class="row" style="padding-right: 20px;">
|
|
18
|
-
<div class="cell">
|
|
19
|
-
<el-input
|
|
20
|
-
v-model="search"
|
|
21
|
-
style="width: 228px; margin-bottom: 10px"
|
|
22
|
-
placeholder="搜索指标"
|
|
23
|
-
size="medium"
|
|
24
|
-
prefix-icon="el-icon-search"
|
|
25
|
-
/>
|
|
26
|
-
</div>
|
|
27
|
-
<el-button type="text" @click="selectNone">全不选</el-button>
|
|
28
|
-
</div>
|
|
29
|
-
<div class="left_box_body">
|
|
30
|
-
<div class="left_nav">
|
|
31
|
-
<ul>
|
|
32
|
-
<li
|
|
33
|
-
v-for="(item, index) in checkBoxMenuBySearch"
|
|
34
|
-
:key="index"
|
|
35
|
-
:class="{ active: activeId === index }"
|
|
36
|
-
@click="setHighlight(index)"
|
|
37
|
-
>
|
|
38
|
-
{{ item.label }}
|
|
39
|
-
</li>
|
|
40
|
-
</ul>
|
|
41
|
-
</div>
|
|
42
|
-
<div class="left_menu">
|
|
43
|
-
<div v-for="(item, index) in checkBoxMenuBySearch" :key="index" ref="tagItem">
|
|
44
|
-
<div class="checkbox_title">
|
|
45
|
-
{{ item.label }}
|
|
46
|
-
</div>
|
|
47
|
-
<el-row>
|
|
48
|
-
<el-col
|
|
49
|
-
v-for="(each, idx) in item.data"
|
|
50
|
-
:key="idx"
|
|
51
|
-
:span="12"
|
|
52
|
-
style="margin-bottom:3px"
|
|
53
|
-
>
|
|
54
|
-
<el-checkbox
|
|
55
|
-
v-model="each.type"
|
|
56
|
-
@change="changeCheckbox(each.key,each.type)"
|
|
57
|
-
>
|
|
58
|
-
{{ each.label }}
|
|
59
|
-
</el-checkbox>
|
|
60
|
-
</el-col>
|
|
61
|
-
</el-row>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
<!-- 已选指标 -->
|
|
67
|
-
<div class="right_box">
|
|
68
|
-
<div class="drag_box">
|
|
69
|
-
<el-row>
|
|
70
|
-
<div class="drag_text_box">
|
|
71
|
-
<span class="drag_title">{{`已选指标(${number})`}}</span>
|
|
72
|
-
<span class="recover" @click="recoverDefault">恢复默认</span>
|
|
73
|
-
</div>
|
|
74
|
-
</el-row>
|
|
75
|
-
<div class="drag_ul">
|
|
76
|
-
<draggable
|
|
77
|
-
v-model="draggableMenu"
|
|
78
|
-
chosen-class="chosen"
|
|
79
|
-
force-fallback="true"
|
|
80
|
-
animation="500"
|
|
81
|
-
@end="onEnd"
|
|
82
|
-
>
|
|
83
|
-
<transition-group>
|
|
84
|
-
<div
|
|
85
|
-
v-for="(col) in draggableMenu"
|
|
86
|
-
v-show="col.type"
|
|
87
|
-
:class="col.key === 'sort-cut-off' ? 'fixedClass' : 'drag_li_box'"
|
|
88
|
-
:key="col.key"
|
|
89
|
-
>
|
|
90
|
-
<div v-if="col.key !== 'sort-cut-off'">
|
|
91
|
-
<i class="el-icon-rank icon-box" />
|
|
92
|
-
<span class="drag_li_text">{{ col.label }}</span>
|
|
93
|
-
</div>
|
|
94
|
-
<i
|
|
95
|
-
v-if="col.key !== 'sort-cut-off'"
|
|
96
|
-
class="el-icon-close remove"
|
|
97
|
-
@click="changeCheckbox(col.key, false)"
|
|
98
|
-
/>
|
|
99
|
-
</div>
|
|
100
|
-
</transition-group>
|
|
101
|
-
</draggable>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
<template #footer>
|
|
107
|
-
<el-row style="margin-top: 7px">
|
|
108
|
-
<el-button
|
|
109
|
-
size="small"
|
|
110
|
-
style="width: 96px"
|
|
111
|
-
@click="closeDialog"
|
|
112
|
-
>取消</el-button>
|
|
113
|
-
<el-button
|
|
114
|
-
size="small"
|
|
115
|
-
style="width: 96px"
|
|
116
|
-
type="primary"
|
|
117
|
-
@click="submit"
|
|
118
|
-
>确定</el-button>
|
|
119
|
-
</el-row>
|
|
120
|
-
</template>
|
|
121
|
-
</el-dialog>
|
|
122
|
-
</div>
|
|
123
|
-
</template>
|
|
124
|
-
|
|
125
|
-
<script>
|
|
126
|
-
import draggable from "vuedraggable"
|
|
127
|
-
import { deepClone } from "../../utils/index"
|
|
128
|
-
export default {
|
|
129
|
-
name: "CustomColumn",
|
|
130
|
-
components: {
|
|
131
|
-
draggable
|
|
132
|
-
},
|
|
133
|
-
props: {
|
|
134
|
-
dialogVisible: {
|
|
135
|
-
type: Boolean,
|
|
136
|
-
default: false
|
|
137
|
-
},
|
|
138
|
-
infoMethod: {
|
|
139
|
-
type: Function,
|
|
140
|
-
required: true,
|
|
141
|
-
default: () => {}
|
|
142
|
-
},
|
|
143
|
-
submitMethod: {
|
|
144
|
-
type: Function,
|
|
145
|
-
required: true,
|
|
146
|
-
default: () => {}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
data() {
|
|
150
|
-
return {
|
|
151
|
-
draggableMenu: [],
|
|
152
|
-
/** 勾选的主标题菜单 */
|
|
153
|
-
checkBoxMenu: [],
|
|
154
|
-
/** 选中高亮的菜单ID */
|
|
155
|
-
activeId: 0,
|
|
156
|
-
/** 表头id */
|
|
157
|
-
id: undefined,
|
|
158
|
-
/** 表格列接口路径 */
|
|
159
|
-
page: "",
|
|
160
|
-
/** 搜索字段 */
|
|
161
|
-
search: "",
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
computed: {
|
|
165
|
-
number() {
|
|
166
|
-
return this.draggableMenu.filter(item => item.type && item.key !== "sort-cut-off").length
|
|
167
|
-
},
|
|
168
|
-
checkBoxMenuBySearch() {
|
|
169
|
-
if (this.search) {
|
|
170
|
-
return this.checkBoxMenu.map(group => {
|
|
171
|
-
const filteredItems = group.data.filter(item => item.label.includes(this.search))
|
|
172
|
-
return {
|
|
173
|
-
label: group.label,
|
|
174
|
-
data: filteredItems
|
|
175
|
-
};
|
|
176
|
-
}).filter(group => group.data.length > 0)
|
|
177
|
-
} else {
|
|
178
|
-
return this.checkBoxMenu
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
methods: {
|
|
184
|
-
deepClone,
|
|
185
|
-
/**
|
|
186
|
-
* @describe 获取自定义表头数据
|
|
187
|
-
* @param { string } page 表格列接口路径
|
|
188
|
-
* @param { object[] } column 列数据
|
|
189
|
-
*/
|
|
190
|
-
async getCustomTableList(page, column) {
|
|
191
|
-
if (!page) {
|
|
192
|
-
throw new Error("缺少表格列接口路径");
|
|
193
|
-
} else {
|
|
194
|
-
// 克隆一份
|
|
195
|
-
this.columnList = this.deepClone(column)
|
|
196
|
-
this.page = page || ""
|
|
197
|
-
const bePreservedColumn = []
|
|
198
|
-
const res = await this.infoMethod({ page: page })
|
|
199
|
-
if (JSON.stringify(res.data) !== "[]") {
|
|
200
|
-
this.id = res.data.id || undefined
|
|
201
|
-
res.data.column.forEach(col => bePreservedColumn.push(...col.data))
|
|
202
|
-
}
|
|
203
|
-
this.initTableList(this.deepClone(column), bePreservedColumn)
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
/**
|
|
207
|
-
* @describe 第一次保存执行的函数(还未保存过的情况下)
|
|
208
|
-
* @param { object[] } initColumn 初始的列数据
|
|
209
|
-
* @param { object[] } bePreservedColumn 被保存过的列数据
|
|
210
|
-
*/
|
|
211
|
-
initTableList(initColumn, bePreservedColumn = []) {
|
|
212
|
-
const setDraggableMenu = (arr) => {
|
|
213
|
-
const cols = []
|
|
214
|
-
arr.forEach(item => cols.push(...item.data))
|
|
215
|
-
cols.sort((a, b) => a.sort - b.sort)
|
|
216
|
-
if(cols.some(item=> item.fixed)) {
|
|
217
|
-
let cutOffIndex = 0
|
|
218
|
-
for(let index = 0; index <= cols.length; index++) {
|
|
219
|
-
const col = cols[index]
|
|
220
|
-
const nextCol = cols[index + 1]
|
|
221
|
-
if (col.fixed === "left" && (!nextCol || !nextCol.fixed)) {
|
|
222
|
-
cutOffIndex = index + 1
|
|
223
|
-
break
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
cols.splice(cutOffIndex, 0, {
|
|
227
|
-
type: true,
|
|
228
|
-
label: "",
|
|
229
|
-
key: "sort-cut-off",
|
|
230
|
-
parent: ""
|
|
231
|
-
})
|
|
232
|
-
}
|
|
233
|
-
return cols
|
|
234
|
-
}
|
|
235
|
-
if (bePreservedColumn && bePreservedColumn.length > 0) {
|
|
236
|
-
// 需要处理被保存过的进行回显
|
|
237
|
-
initColumn.forEach((cols) => {
|
|
238
|
-
cols.data.forEach((col) => {
|
|
239
|
-
const beSaveCol = bePreservedColumn.find(item => item.key === col.key) || {}
|
|
240
|
-
col.type = (beSaveCol.type === "true" || beSaveCol.type === true) ? true : false
|
|
241
|
-
col.sort = beSaveCol.sort
|
|
242
|
-
col.fixed = beSaveCol.fixed ? beSaveCol.fixed : col.fixed,
|
|
243
|
-
col.parent = { label: cols.label }
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
// 需要显示的列的数据
|
|
247
|
-
this.checkBoxMenu = this.deepClone(initColumn)
|
|
248
|
-
this.draggableMenu = setDraggableMenu(this.checkBoxMenu)
|
|
249
|
-
} else {
|
|
250
|
-
// 从未被保存过
|
|
251
|
-
let num = 0
|
|
252
|
-
initColumn.forEach((cols) => {
|
|
253
|
-
cols.data.forEach((col) => {
|
|
254
|
-
num++
|
|
255
|
-
col.type = true
|
|
256
|
-
col.width = col.width ? +col.width : 0,
|
|
257
|
-
col.sort = num
|
|
258
|
-
col.parent = { label: cols.label }
|
|
259
|
-
})
|
|
260
|
-
})
|
|
261
|
-
this.checkBoxMenu = this.deepClone(initColumn)
|
|
262
|
-
this.draggableMenu = setDraggableMenu(this.checkBoxMenu)
|
|
263
|
-
}
|
|
264
|
-
this.$emit("changeTable", this.draggableMenu.filter(item => item.key !== "sort-cut-off").sort((a, b) => a.sort - b.sort))
|
|
265
|
-
this.$emit("changeTableGroup", this.checkBoxMenu)
|
|
266
|
-
},
|
|
267
|
-
// 全不选
|
|
268
|
-
selectNone() {
|
|
269
|
-
this.checkBoxMenu.forEach(cols => cols.data.forEach(col => col.type = false))
|
|
270
|
-
this.draggableMenu.forEach(item => {
|
|
271
|
-
if (item.key === "sort-cut-off") {
|
|
272
|
-
item.type = true
|
|
273
|
-
} else {
|
|
274
|
-
item.type = false
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
},
|
|
278
|
-
/**
|
|
279
|
-
* @describe 点击高亮
|
|
280
|
-
* @param { number } index 索引
|
|
281
|
-
*/
|
|
282
|
-
setHighlight(index) {
|
|
283
|
-
this.activeId = index
|
|
284
|
-
if (this.$refs.tagItem) {
|
|
285
|
-
this.$refs.tagItem[index].scrollIntoView({ behavior: "smooth" })
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
/**
|
|
289
|
-
* @describe 勾选、关闭
|
|
290
|
-
* @param { string } key 唯一标识
|
|
291
|
-
* @param { boolean } type 是否显示
|
|
292
|
-
*/
|
|
293
|
-
changeCheckbox(key, type) {
|
|
294
|
-
this.draggableMenu.forEach(item => {
|
|
295
|
-
if (item.key === key) {
|
|
296
|
-
item.type = type
|
|
297
|
-
}
|
|
298
|
-
})
|
|
299
|
-
this.checkBoxMenu.forEach(item => {
|
|
300
|
-
item.data.forEach(each => {
|
|
301
|
-
if (each.key === key) {
|
|
302
|
-
each.type = type
|
|
303
|
-
}
|
|
304
|
-
})
|
|
305
|
-
})
|
|
306
|
-
},
|
|
307
|
-
// 恢复默认
|
|
308
|
-
recoverDefault() {
|
|
309
|
-
this.initTableList(this.deepClone(this.columnList))
|
|
310
|
-
},
|
|
311
|
-
// 拖拽结束事件
|
|
312
|
-
onEnd() {
|
|
313
|
-
let isFixed = true
|
|
314
|
-
this.draggableMenu.forEach((item, index) => {
|
|
315
|
-
if (item.key === "sort-cut-off") { isFixed = false }
|
|
316
|
-
if (isFixed) {
|
|
317
|
-
item.sort = index + 1
|
|
318
|
-
item.fixed = "left"
|
|
319
|
-
} else {
|
|
320
|
-
item.sort = index
|
|
321
|
-
delete item.fixed
|
|
322
|
-
}
|
|
323
|
-
})
|
|
324
|
-
},
|
|
325
|
-
// 点击保存
|
|
326
|
-
async submit() {
|
|
327
|
-
const params = {
|
|
328
|
-
column: [],
|
|
329
|
-
id: this.id,
|
|
330
|
-
page: this.page
|
|
331
|
-
}
|
|
332
|
-
this.draggableMenu.forEach(item => {
|
|
333
|
-
if (item.key !== "sort-cut-off") {
|
|
334
|
-
const { parent, ...other } = item
|
|
335
|
-
// 是否存在
|
|
336
|
-
const isExit = params.column.some(col => col.label === parent.label)
|
|
337
|
-
if (isExit) {
|
|
338
|
-
params.column.forEach(col => {
|
|
339
|
-
if (col.label === parent.label) {
|
|
340
|
-
col.data.push(other)
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
} else {
|
|
344
|
-
params.column.push({
|
|
345
|
-
label: parent.label,
|
|
346
|
-
data: [other]
|
|
347
|
-
})
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
})
|
|
351
|
-
await this.submitMethod(params)
|
|
352
|
-
const cols = []
|
|
353
|
-
params.column.forEach(item => {
|
|
354
|
-
cols.push(...item.data)
|
|
355
|
-
})
|
|
356
|
-
this.$emit("changeTable", cols.sort((a, b) => a.sort - b.sort))
|
|
357
|
-
this.$emit("changeTableGroup", params.column)
|
|
358
|
-
this.closeDialog()
|
|
359
|
-
},
|
|
360
|
-
// 关闭弹窗
|
|
361
|
-
closeDialog() {
|
|
362
|
-
// 重置数据
|
|
363
|
-
this.search = ""
|
|
364
|
-
this.activeId = 0
|
|
365
|
-
this.$emit("closeDialog")
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
</script>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="drawer_query_btn b-fold-search">
|
|
3
|
-
<div @click="drawer">
|
|
4
|
-
<template v-if="show == true">
|
|
5
|
-
<span style="color: #3aa1ff; vertical-align:middle;">收起</span> <img style="vertical-align:middle;" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTg3Ny41IDU2NS45bC0zNjcuNi0zNDAtMzY3LjYgMzQwYy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xTDQ5NSAxMTcuNWMwLTcuMiA3LjUtNy4yIDE1LTcuMnM3LjUgMCAxNSA3LjJsNDIwLjIgMzgzLjNjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjcgMTQuNS01Mi43IDE0LjUtNjcuNyAwek00OTQuOCA0NTAuMWMwLTcuMiA3LjUtNy4yIDE1LTcuMnMxNSAwIDE1IDcuMkw5NDUgODMzLjRjMjIuNSAyMS43IDE1IDUwLjYgMCA2NS4xLTIyLjUgMTQuNC01Mi41IDE0LjQtNjcuNSAwTDUwOS44IDU1OC42IDE0Mi4yIDkwNS44Yy0yMi41IDE0LjUtNTIuNSAxNC41LTY3LjUgMC0xNS0yMS43LTE1LTUwLjcgMC02NS4xbDQyMC4xLTM5MC42eiBtMCAwIiAvPjwvc3ZnPg==" alt="收起">
|
|
6
|
-
</template>
|
|
7
|
-
<template v-else>
|
|
8
|
-
<span style="color: #3aa1ff; vertical-align:middle;">展开更多</span> <img style="vertical-align:middle;" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyBjbGFzcz0iaWNvbiIgd2lkdGg9IjIwMHB4IiBoZWlnaHQ9IjIwMC4wMHB4IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0iIzVjYWRmZiIgZD0iTTE0NS40IDQ2MS4xbDM2Ny42IDM0MCAzNjcuNi0zNDBjMjIuNS0xNC41IDUyLjUtMTQuNSA2Ny41IDAgMTUgMjEuNyAxNSA1MC43IDAgNjUuMUw1MjcuOSA5MDkuNWMwIDcuMi03LjUgNy4yLTE1IDcuMnMtNy41IDAtMTUtNy4yTDc3LjcgNTI2LjJjLTIyLjUtMjEuNy0xNS01MC42IDAtNjUuMSAyMi42LTE0LjUgNTIuNi0xNC41IDY3LjcgMHpNNTI4IDU3Ni45YzAgNy4yLTcuNSA3LjItMTUgNy4ycy0xNSAwLTE1LTcuMkw3Ny44IDE5My42Yy0yMi41LTIxLjctMTUtNTAuNiAwLTY1LjEgMjIuNS0xNC40IDUyLjUtMTQuNCA2Ny41IDBMNTEzIDQ2OC40bDM2Ny42LTM0Ny4yYzIyLjUtMTQuNSA1Mi41LTE0LjUgNjcuNSAwIDE1IDIxLjcgMTUgNTAuNyAwIDY1LjFMNTI4IDU3Ni45eiBtMCAwIiAvPjwvc3ZnPg==" alt="展开更多">
|
|
9
|
-
</template>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
<script>
|
|
14
|
-
export default {
|
|
15
|
-
data() {
|
|
16
|
-
return {
|
|
17
|
-
show: false
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
methods: {
|
|
21
|
-
drawer(value) {
|
|
22
|
-
this.show = !this.show
|
|
23
|
-
this.$emit("change", this.show)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="b-picker wrapper">
|
|
3
|
-
<el-date-picker
|
|
4
|
-
style="width: 70%"
|
|
5
|
-
:value="value"
|
|
6
|
-
v-bind="dateOptions"
|
|
7
|
-
@input="handleChange"
|
|
8
|
-
/>
|
|
9
|
-
<div class="btn">
|
|
10
|
-
<span
|
|
11
|
-
v-for="item in shortcuts"
|
|
12
|
-
:key="item.key"
|
|
13
|
-
class="item"
|
|
14
|
-
:class="{ item_active: item.key === active }"
|
|
15
|
-
@click="handleClick(item)"
|
|
16
|
-
>
|
|
17
|
-
{{ item.label }}
|
|
18
|
-
</span>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script>
|
|
24
|
-
import moment from "moment"
|
|
25
|
-
export default {
|
|
26
|
-
props: {
|
|
27
|
-
value: {
|
|
28
|
-
type: [Array, String],
|
|
29
|
-
required: true,
|
|
30
|
-
default: () => []
|
|
31
|
-
},
|
|
32
|
-
otherOption: {
|
|
33
|
-
type: Object,
|
|
34
|
-
default: () => ({
|
|
35
|
-
startPlaceholder: "开始时间",
|
|
36
|
-
endPlaceholder: "结束时间",
|
|
37
|
-
type: "daterange",
|
|
38
|
-
rangeSeparator: "-",
|
|
39
|
-
size: "mini",
|
|
40
|
-
active: ""
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
data() {
|
|
46
|
-
return {
|
|
47
|
-
shortcuts: [
|
|
48
|
-
{ label: "上月", start_time: moment().subtract(1, "months").startOf("month").format("YYYY-MM-DD"), end_time: moment().subtract(1, "months").endOf("month").format("YYYY-MM-DD"), key: "last_month" },
|
|
49
|
-
{ label: "昨天", start_time: moment().subtract(1, "days").format("YYYY-MM-DD"), end_time: moment().subtract(1, "days").format("YYYY-MM-DD"), key: "yesterday" },
|
|
50
|
-
{ label: "今天", start_time: moment().startOf("day").format("YYYY-MM-DD"), end_time: moment().startOf("day").format("YYYY-MM-DD"), key: "today" },
|
|
51
|
-
{ label: "本周", start_time: moment().startOf("week").format("YYYY-MM-DD"), end_time: moment().endOf("week").format("YYYY-MM-DD"), key: "week" },
|
|
52
|
-
{ label: "本月", start_time: moment().startOf("month").format("YYYY-MM-DD"), end_time: moment().endOf("month").format("YYYY-MM-DD"), key: "month" }
|
|
53
|
-
],
|
|
54
|
-
active: ""
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
computed: {
|
|
59
|
-
dateOptions() {
|
|
60
|
-
return {
|
|
61
|
-
startPlaceholder: "开始时间",
|
|
62
|
-
endPlaceholder: "结束时间",
|
|
63
|
-
type: "daterange",
|
|
64
|
-
rangeSeparator: "至",
|
|
65
|
-
size: "mini",
|
|
66
|
-
active: "",
|
|
67
|
-
...this.otherOption
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
watch: {
|
|
73
|
-
value: {
|
|
74
|
-
handler(newValue, oldValue) {
|
|
75
|
-
if (newValue && newValue.length) {
|
|
76
|
-
this.active = ""
|
|
77
|
-
this.shortcuts.forEach(item => {
|
|
78
|
-
if (item.start_time === newValue[0] && item.end_time === newValue[1]) {
|
|
79
|
-
this.active = item.key
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
} else {
|
|
83
|
-
this.active = this.dateOptions.active
|
|
84
|
-
const item = this.shortcuts.find(item => item.key === this.dateOptions.active) || {}
|
|
85
|
-
if (item.start_time && item.end_time) {
|
|
86
|
-
this.handleClick(item)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
immediate: true
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
methods: {
|
|
95
|
-
handleChange(e) {
|
|
96
|
-
if (!e) {
|
|
97
|
-
this.$emit("input", [])
|
|
98
|
-
} else {
|
|
99
|
-
this.$emit("input", e.map(item => moment(item).format("YYYY-MM-DD")))
|
|
100
|
-
}
|
|
101
|
-
this.active = ""
|
|
102
|
-
},
|
|
103
|
-
handleClick(item) {
|
|
104
|
-
this.active = item.key
|
|
105
|
-
this.$emit("input", [item.start_time, item.end_time])
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
</script>
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="b-picker wrapper">
|
|
3
|
-
<el-date-picker
|
|
4
|
-
style="width: 70%"
|
|
5
|
-
v-model="value[config.field]"
|
|
6
|
-
:start-placeholder="config.startPlaceholder || '开始时间'"
|
|
7
|
-
:end-placeholder="config.endPlaceholder || '结束时间'"
|
|
8
|
-
:range-separator="config.rangeSeparator || '-'"
|
|
9
|
-
:size="config.size || 'mini'"
|
|
10
|
-
type= "daterange"
|
|
11
|
-
@input="handleChange"
|
|
12
|
-
/>
|
|
13
|
-
<div class="btn">
|
|
14
|
-
<span
|
|
15
|
-
v-for="item in shortcuts"
|
|
16
|
-
:key="item.key"
|
|
17
|
-
class="item"
|
|
18
|
-
:class="{ item_active: item.key === active }"
|
|
19
|
-
@click="handleClick(item)"
|
|
20
|
-
>
|
|
21
|
-
{{ item.label }}
|
|
22
|
-
</span>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
<script>
|
|
28
|
-
import moment from "moment"
|
|
29
|
-
export default {
|
|
30
|
-
name: 'ByDatePickerRange',
|
|
31
|
-
props: {
|
|
32
|
-
//绑定的表单数据
|
|
33
|
-
value: {
|
|
34
|
-
type: Object,
|
|
35
|
-
default: null
|
|
36
|
-
},
|
|
37
|
-
//当前配置
|
|
38
|
-
config: {
|
|
39
|
-
type: Object,
|
|
40
|
-
default: null
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
data() {
|
|
44
|
-
return {
|
|
45
|
-
shortcuts: [
|
|
46
|
-
{ label: "上月", start_time: moment().subtract(1, "months").startOf("month").format("YYYY-MM-DD"), end_time: moment().subtract(1, "months").endOf("month").format("YYYY-MM-DD"), key: "last_month" },
|
|
47
|
-
{ label: "昨天", start_time: moment().subtract(1, "days").format("YYYY-MM-DD"), end_time: moment().subtract(1, "days").format("YYYY-MM-DD"), key: "yesterday" },
|
|
48
|
-
{ label: "今天", start_time: moment().startOf("day").format("YYYY-MM-DD"), end_time: moment().startOf("day").format("YYYY-MM-DD"), key: "today" },
|
|
49
|
-
{ label: "本周", start_time: moment().startOf("week").format("YYYY-MM-DD"), end_time: moment().endOf("week").format("YYYY-MM-DD"), key: "week" },
|
|
50
|
-
{ label: "本月", start_time: moment().startOf("month").format("YYYY-MM-DD"), end_time: moment().endOf("month").format("YYYY-MM-DD"), key: "month" }
|
|
51
|
-
],
|
|
52
|
-
active: ""
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
mounted() {
|
|
56
|
-
this.active = this.config.active || 'today'
|
|
57
|
-
const item = this.shortcuts.find(item => item.key === this.active) || {}
|
|
58
|
-
if (item.start_time && item.end_time) {
|
|
59
|
-
this.handleClick(item)
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
methods: {
|
|
63
|
-
handleChange(e) {
|
|
64
|
-
if (!e) {
|
|
65
|
-
this.$emit("input", [])
|
|
66
|
-
} else {
|
|
67
|
-
this.$emit("input", e.map(item => moment(item).format("YYYY-MM-DD")))
|
|
68
|
-
}
|
|
69
|
-
this.active = ""
|
|
70
|
-
},
|
|
71
|
-
handleClick(item) {
|
|
72
|
-
this.active = item.key
|
|
73
|
-
this.value[this.config.field] = [item.start_time, item.end_time]
|
|
74
|
-
this.$emit("input", [item.start_time, item.end_time])
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
</script>
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="w-full flex">
|
|
3
|
-
<el-input class="w-1/2" :value="value[0]" :placeholder="earliestPlaceholder" @input="(value) => handleInput(value, 'min')" @blur="(e) => handleBlur(+e.target.value, 'min')" />
|
|
4
|
-
<span>~</span>
|
|
5
|
-
<el-input class="w-1/2" :value="value[1]" :placeholder="latestPlaceholder" @input="(value) => handleInput(value, 'max')" @blur="(e) => handleBlur(+e.target.value, 'max')" />
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
export default {
|
|
11
|
-
props: {
|
|
12
|
-
value: {
|
|
13
|
-
type: Array,
|
|
14
|
-
required: true,
|
|
15
|
-
default: () => ["", 0]
|
|
16
|
-
},
|
|
17
|
-
earliestPlaceholder: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: ""
|
|
20
|
-
},
|
|
21
|
-
latestPlaceholder: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: ""
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
methods: {
|
|
28
|
-
/**
|
|
29
|
-
* 输入框输入回调,将其转换为数字,并反馈到父组件
|
|
30
|
-
* @param { string } val 输入框的value值
|
|
31
|
-
* @param { string } type 输入框的类型 min | max
|
|
32
|
-
*/
|
|
33
|
-
handleInput(val, type) {
|
|
34
|
-
if (type === "min") {
|
|
35
|
-
const values = [val.replace(/\D+/, ""), this.value[1]]
|
|
36
|
-
|
|
37
|
-
this.$emit("input", values)
|
|
38
|
-
} else if (type === "max") {
|
|
39
|
-
const values = [this.value[0], val.replace(/\D+/, "")]
|
|
40
|
-
|
|
41
|
-
this.$emit("input", values)
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 输入框失去焦点回调,判断最小输入框是否大于最大输入框和最大输入框小于最小输入框,并反馈到父组件
|
|
47
|
-
* @param { number } val 输入框的value值
|
|
48
|
-
* @param { string } type 输入框的类型 min | max
|
|
49
|
-
*/
|
|
50
|
-
handleBlur(val, type) {
|
|
51
|
-
if (type === "min") {
|
|
52
|
-
if (val > this.value[1]) {
|
|
53
|
-
const values = [this.value[1], this.value[1]]
|
|
54
|
-
|
|
55
|
-
this.$emit("input", values)
|
|
56
|
-
}
|
|
57
|
-
} else if (type === "max") {
|
|
58
|
-
if (val < this.value[0]) {
|
|
59
|
-
const values = [this.value[0], this.value[0]]
|
|
60
|
-
|
|
61
|
-
this.$emit("input", values)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
</script>
|