@weitutech/by-components 1.0.27

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/lib/demo.html ADDED
@@ -0,0 +1 @@
1
+ <!doctype html><meta charset="utf-8"><title>by-components demo</title><script src="./by-components.umd.js"></script><link rel="stylesheet" href="./by-components.css"><script>console.log(by-components)</script>
package/lib/index.css ADDED
@@ -0,0 +1 @@
1
+ #pager{padding:10px 0;background:#fff;border-top:1px solid #f2f2f3;width:100%;display:flex;justify-content:flex-end}#pager ::v-deep .el-pagination__jump{margin-left:0}#pager ::v-deep .el-pagination ul li{border:1px solid #e7e7f1}#pager ::v-deep .el-pagination button{border:1px solid #e7e7f1}#pager ::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active{background-color:#f3f3fe;color:#000}#pager ::v-deep .el-pagination.is-background .btn-prev{background-color:#fff}#pager ::v-deep .el-pagination.is-background .btn-next{background-color:#fff}#pager ::v-deep .el-pagination.is-background .el-pager li{background-color:#fff}.b-page-search .footer{position:relative}.b-page-search .header{color:red}.b-page-search .btn{display:flex;justify-content:space-between}.b-page-search .handle-btn{display:flex;flex-wrap:nowrap}.b-page-search .page-search{position:relative}.b-page-search .fold{position:absolute;bottom:-30px;left:40%}.b-fold-search{text-align:center;position:relative}.b-fold-search div{display:inline-block;background-color:#fff;cursor:pointer;padding:0 15px;height:34px;line-height:32px;font-size:14px;border-radius:0 0 5px 5px}.b-fold-search span{color:#999}.b-fold-search img{width:15px;height:15px}.b-table .table-row-overflow-line-2{overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;line-height:15px}.b-table .text_pointer_primary{cursor:pointer;color:#409eff}.b-table .table_wrapper{background-color:#fff;padding:10px 10px 0 10px;border-radius:5px}.b-table .vxe-header--column.group-split,.b-table .vxe-body--column.group-split{background:#e8eaec}.table_wrapper{background-color:#fff;padding:10px 10px 0 10px;border-radius:5px}.form_wrapper{background-color:#fff;padding:10px 0 5px 0px;border-radius:5px}.b-form .el-input,.b-form .el-select{max-width:none !important}.b-form .el-input-group{vertical-align:middle !important}.b-form .el-form-item{margin-bottom:0px !important}.b-form .el-row{display:flex;flex-wrap:wrap}.b-form .b-picker{display:flex;align-items:center}.b-form .b-picker .btn{display:flex;margin-left:8px}.b-form .b-picker .item{color:#606266;font-size:12px;white-space:nowrap;margin:0 3px;cursor:pointer}.b-form .b-picker .item_active{color:#409eff}.b-form .store-selector{display:flex}.b-form .store-selector .store-select-container{display:inline-block;width:calc(100% - 104px);vertical-align:top;border:solid 1px rgba(0,0,0,.2);padding:0 10px;border-radius:5px}.b-form .store-selector .store-select-container.shrink{border:none;padding:0}.b-form .store-selector .store-select-container.shrink .el-checkbox-group{overflow:hidden}.b-form .store-selector .selected_all,.b-form .store-selector .store-select-container .el-checkbox{border-width:1px !important;border-color:rgba(0,0,0,0);padding:0 4px !important;margin:5px 10px 5px 0 !important}.b-form .store-selector .selected_all.is-checked,.b-form .store-selector .store-select-container .el-checkbox.is-checked{border-color:#409eff}.b-form .store-selector .el-radio-group{width:100% !important}.b-form .store-selector .el-checkbox-group{line-height:1;width:100% !important}.b-form .store-selector label{margin:0 10px 0 0 !important;padding:0 5px !important}.b-form .store-selector .leave{color:#adadad}.b-form .store-selector .openShrink{vertical-align:top}.b-form .consult_select .consult-select-container{display:inline-block;width:calc(100% - 104px);vertical-align:top;border:solid 1px rgba(0,0,0,.2);padding:0 10px;border-radius:5px}.b-form .consult_select .consult-select-container.shrink{border:none;padding:0}.b-form .consult_select .consult-select-container.shrink .el-radio-group.Eng{visibility:hidden;display:none}.b-form .consult_select .consult-select-container.shrink .el-checkbox-group{overflow:hidden}.b-form .consult_select .selected_all,.b-form .consult_select .consult-select-container .el-checkbox{border-width:1px !important;border-color:rgba(0,0,0,0);padding:0 4px !important;margin:5px 10px 5px 0 !important}.b-form .consult_select .selected_all.is-checked,.b-form .consult_select .consult-select-container .el-checkbox.is-checked{border-color:#409eff}.b-form .consult_select .el-radio-group{width:100% !important}.b-form .consult_select .el-checkbox-group{line-height:1;max-height:75px;overflow-y:auto;width:100% !important}.b-form .consult_select label{margin:0 10px 0 0 !important;padding:0 5px !important}.b-form .consult_select .leave{color:#adadad}.b-form .consult_select .el-checkbox__inner{display:none}.b-form .date-selector{display:inline-block}.b-form .date-selector .el-range-editor--large.el-input__inner{height:36px;line-height:36px}.b-form .date-selector .el-date-editor{margin-right:10px;vertical-align:middle}.b-form .date-selector .el-date-editor ::v-deep .el-range-separator{width:10%;padding:0}.b-form .date-selector .quickBtns{display:inline-block}.b-form .date-selector .quickBtns .el-button{color:#606266}.b-form .date-selector .quickBtns .el-button.active{color:#409eff}.b-form .store-select-container{display:inline-block;width:calc(100% - 104px);vertical-align:top;border:solid 1px rgba(0,0,0,.2);padding:0 10px;border-radius:5px}.b-form .store-select-container.shrink{border:none;padding:0}.b-form .store-select-container.shrink .el-radio-group.Eng{visibility:hidden;display:none}.b-form .store-select-container.shrink .el-checkbox-group{overflow:hidden}.b-form .dialog{display:flex}.b-form .dialog .dialog-container{height:60vh;min-width:50rem}.b-form .dialog .dialog-container .dia-content{position:relative;height:80%}.b-form .dialog .dialog-container .selected{position:absolute;right:0;top:0;width:25%;height:calc(100% + 40px);overflow-y:scroll;border:1px solid #ddd;color:#000}.b-form .dialog .dialog-container .selected .selected-title{display:flex;justify-content:space-between;position:sticky;top:0;width:100%;height:2.5rem;line-height:2.5rem;font-weight:bold;padding:0 1.25rem;background-color:#f8f8f8;border-bottom:1px solid #ddd;z-index:99}.b-form .dialog .dialog-container .selected .selected-title .clearAll{font-size:.75rem;color:#999;cursor:pointer;font-weight:normal}.b-form .dialog .dialog-container .selected .selected-list{padding-left:.625rem;padding-bottom:.625rem}.b-form .dialog .dialog-container .selected .selected-list .list-tags{margin-top:.625rem}.b-form .dialog .dialog-container .selected .selected-list .list-tags .el-tags{width:calc(100% - 10px);color:#000;display:flex;align-items:center}.b-form .dialog .dia-title{display:flex;justify-content:flex-end;align-items:center}.b-form .dialog .dia-title>.el-input{margin-right:auto;width:40%}.b-form .dialog .header{margin-top:.625rem;height:40px !important;border:1px solid #ddd;border-bottom:none;line-height:40px;background-color:#f8f8f8;width:74%}.b-form .dialog .can-add{width:74%;height:100%;border:1px solid #ddd}.b-form .dialog .can-add .el-aside{padding-top:.625rem}.b-form .dialog .can-add .el-aside .list-list{padding-left:1.25rem}.b-form .dialog .can-add .el-aside .list-list .list-title{height:1.875rem;line-height:1.875rem;font-weight:bold}.b-form .dialog .can-add .el-aside .list-list .list-content{padding-left:1.25rem;color:#666}.b-form .dialog .can-add .el-aside .list-list .list-content .list-lists{height:1.875rem;line-height:1.875rem;list-style:none;cursor:pointer}.b-form .dialog .can-add .el-aside .list-list .list-content .list-lists:hover{color:#197afb}.b-form .dialog .can-add .check-content .check-title{margin-bottom:1.25rem;font-weight:bold}.b-form .dialog .can-add .check-content .check-all{width:100%;height:1.875rem;line-height:1.875rem;padding-left:.625rem;border-radius:.3125rem;background-color:#eee;font-weight:bold}.b-form .dialog .can-add .check-content .check-list{padding-left:.625rem}.b-form .dialog .can-add .check-content .check-list .el-checkbox{width:50%;margin:0 0 .625rem 0}.b-form .dialog .btn{text-align:right}.custom_dialog_class .el-dialog__header{display:none !important}.custom_dialog_class .el-dialog__body{padding:0 0 0 20px !important}.custom_dialog_class .el-dialog__body{border-top:0px !important}.chosen{border:solid 2px #a48bec !important}.drag_ul{height:480px;overflow:hidden;overflow-y:auto}.remove{padding:0 10px;border-left:1px solid #cbcbcb;height:12px;cursor:pointer}.icon-box{margin:0 10px}.drag_li_text{margin-right:8px;color:#606266}.drag_li_box{display:flex;justify-content:space-between;align-items:center;margin-top:10px;height:36px;line-height:36px;color:#cbcbcb;background-color:#fff;box-shadow:0 0 1px rgba(0,0,0,.1);cursor:move}.fixedClass{width:100%;height:2px;border-bottom:2px dashed #ccc;padding-top:10px}.recover{cursor:pointer;color:#8966f3}.drag_text_box{height:60px;line-height:60px;margin-left:5px}.drag_title{margin:10px 115px 10px 0;font-size:14px;font-weight:700;color:#666}.box_title{margin:10px 0;font-size:14px;font-weight:700;color:#333}.drag_box{flex:1;height:540px;padding:0 10px;background-color:#fafafa}.el-dialog-box{display:flex;height:550px}.el-dialog-box .left_box{padding-top:10px;width:600px}.el-dialog-box .right_box{flex:1}.draggable_title{font-size:12px;font-weight:700;margin:20px 0}.left_box_body{display:flex;height:444px;border:1px solid #ececec}.left_box_body .left_nav{width:85px;padding:10px 0 0 10px;border-right:1px solid #ececec;list-style:none}.left_box_body .left_nav ul{padding:0;margin:0}.left_box_body .left_nav ul li{list-style:none;padding:10px 0;font-weight:700;color:#333;cursor:pointer}.left_box_body .left_menu{flex:1;padding:10px 0 0 20px;overflow:hidden;overflow-y:auto}.left_box_body .left_menu .checkbox_title{margin:20px 0}.left_box_body .left_menu div:nth-child(1) .checkbox_title{margin-top:8px}.left_box_body .active{color:#8966f3 !important}.left_box_body ::v-deep .el-form--label-top .el-form-item__label{padding:0;font-size:12px}.left_box_body ::v-deep .el-radio__label{font-size:12px !important}.flex{display:flex}.row-wrap,.column-wrap{flex-wrap:wrap}.column{display:flex;flex-direction:column}.row.column-c,.column.row-c{align-items:center}.row{display:flex;flex-direction:row}.row.row-c,.column.column-c{justify-content:center}.row.row-sb,.column.column-sb{justify-content:space-between}.cell,.cell-1{flex:1}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@weitutech/by-components",
3
+ "version": "1.0.27",
4
+ "private": false,
5
+ "main": "src/index",
6
+ "scripts": {
7
+ "build": "npm run build:js && npm run build:css",
8
+ "build:js": "vue-cli-service build --target lib --name by-components src/index.js",
9
+ "build:css": "sass src/style/index.scss lib/index.css --no-source-map --style=compressed"
10
+ },
11
+ "dependencies": {
12
+ "axios": "^1.7.7",
13
+ "core-js": "^3.8.3",
14
+ "dom-zindex": "^1.0.6",
15
+ "element-ui": "^2.15.14",
16
+ "js-cookie": "^3.0.5",
17
+ "moment": "^2.30.1",
18
+ "vue": "^2.6.14",
19
+ "vuedraggable": "^2.24.3",
20
+ "vxe-table": "3.8.24"
21
+ },
22
+ "devDependencies": {
23
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
24
+ "@babel/plugin-proposal-optional-chaining": "^7.21.0",
25
+ "@vue/cli-plugin-babel": "~5.0.0",
26
+ "@vue/cli-service": "~5.0.0",
27
+ "sass": "^1.79.4",
28
+ "sass-loader": "^16.0.2",
29
+ "vue-template-compiler": "^2.6.14"
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ plugins: {
3
+ // 可以根据您的需求添加具体的 PostCSS 插件
4
+ // 例如 autoprefixer 用于添加浏览器前缀
5
+ 'autoprefixer': {}
6
+ }
7
+ }
@@ -0,0 +1,369 @@
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>
@@ -0,0 +1,29 @@
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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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
+
@@ -0,0 +1,109 @@
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>
@@ -0,0 +1,78 @@
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>