@weitutech/by-components 1.1.86 → 1.1.87

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/README.md CHANGED
@@ -1,513 +1,513 @@
1
- # @weitutech/by-components
2
-
3
- ### npm 安装
4
-
5
- ```
6
- 安装时切换淘宝源比较快
7
- npm config set registry https://registry.npmmirror.com/
8
-
9
- npm install @weitutech/by-components
10
- ```
11
-
12
- ### 引入
13
-
14
- 由于对 vxeTable 进行了再次处理,所以需要复制 plugin 文件夹到项目中
15
- 并手动引入 vxeTable
16
- plugin 目录可从组件库中复制到项目
17
-
18
- ```
19
- import '@/plugin/vxeTable.js';
20
- import '@weitutech/by-components/lib/index.css'
21
- import BYComponents from '@weitutech/by-components'
22
- Vue.use(BYComponents)
23
- ```
24
-
25
- ### npm 发布
26
-
27
- ```
28
- 第一次发布
29
- npm login
30
-
31
- 发布时需要确保npm的源是官方 npm
32
- npm config set registry https://registry.npmjs.org/
33
-
34
-
35
- 出现功能修改后,需更新package的版本号
36
- 清除缓存
37
- npm cache clean --force
38
- 发布
39
- npm publish --access public
40
- ```
41
-
42
- ### 注意事项
43
-
44
- 1. 组件开发中 css 样式单独放在 style 目录下, 整体打包成一个 css 样式引入
45
- 2. 打包后会在 lib 目录下生成 js 和 css 文件
46
- 3. 本地开发时可采用 npm link 方式关联依赖,package 入口配置为 src/index.js
47
-
48
- ### npm link
49
-
50
- ```
51
- 组件库中运行 npm link
52
- 项目中运行 npm link @weitutech/by-components
53
- ```
54
-
55
- > **💡 提示**
56
- > 本地link调试时,需要把组件库的package.json中的main字段改为src/index.js("main": "src/index.js")
57
- > 如需link调试样式, 宿主工程main.js中要 import '@weitutech/by-components/src/style/index.scss' //TODO:注意:调试样式link , 调试完需注释
58
- > 调试完成后,切记改回 "main": "lib/by-components.umd.js",
59
- > 如果组件库更新,宿主项目没有同步更新, 尝试重新编译组件库npm run build, 且清除宿主项目缓存rm -rf node_modules/.cache
60
-
61
- ### 组件文档构建
62
-
63
- ```
64
- npm run docs:dev
65
- npm run docs:build
66
- 文档部署到Github Pages: npm run docs:deploy
67
- ```
68
-
69
- [组件文档·Github Pages](https://weitutech.github.io/by-frontend-components-docs/)
70
-
71
- ### 关于新组件开发
72
-
73
- 1. 采用 by 为前缀命名方式
74
- 2. 避免过度耦合,考虑不同项目的复用性,尽量避免组件内调取接口
75
-
76
- ### 表单 by-page-search
77
-
78
- ```
79
- <template>
80
- <by-page-search
81
- ref="pageSearchRef"
82
- v-model="searchQuery"
83
- :search-form-config="formConfig"
84
- @queryBtnClick="handleQueryClick"
85
- @change="handleChangePageSearch"
86
- >
87
- <template #custom>
88
- 我是外部自定义内容
89
- </template>
90
- </by-page-search>
91
- </template>
92
-
93
- <script>
94
- export default {
95
- data() {
96
- return {
97
- searchQuery: {
98
- // 对应formConfig对象中formItems中的每个field
99
- },
100
- formConfig: {
101
- labelWidth: "80px",
102
- itemStyle: {
103
- padding: "0px 0px"
104
- },
105
- // 需要折叠的字段、不分顺序、写在里面的字段都会被隐藏 --- 仅在isFlexible = true 才可用
106
- flexible: {
107
- // 这里模拟写一些
108
- foldField: ["area_id", "department_id", "team_id", "user_id", "favourite_id", "category_id", "brand_id"]
109
- },
110
- // 是否开启折叠功能
111
- isFlexible: true,
112
- colLayout: {
113
- xs: 24,
114
- sm: 12,
115
- md: 12,
116
- lg: 6,
117
- xl: 4
118
- },
119
- elSize: "mini",
120
- // 对应表单单独的显隐权限 可设置isHidden来控制
121
- formItems: [
122
- // 输入框
123
- {
124
- id: 1, // 作为可选的唯一标识,如果field有重复可以设置id作为唯一标识
125
- field: "input",
126
- type: "input",
127
- label: "输入框",
128
- placeholder: "请输入",
129
- labelWidth: "70px",
130
- isHidden: false, // 是否隐藏 false || true
131
- otherOptions: {
132
- // 其他选项配置、参考Element的输入框配置
133
- }
134
- },
135
- // 密码输入框
136
- {
137
- field: "password",
138
- type: "password",
139
- label: "密码输入框",
140
- placeholder: "请输入密码",
141
- labelWidth: "70px",
142
- otherOptions: {
143
- // 其他选项配置、参考Element的输入框配置
144
- }
145
- },
146
- // 选择器
147
- {
148
- field: "select",
149
- type: "select",
150
- label: "选择器",
151
- placeholder: "请选择",
152
- labelWidth: "100px",
153
- mode: "", // 可选 "group" || false 默认 不传不用配置 group为分组模式
154
- options: [
155
- // 必须按照label、value的键值对传入
156
- { label: "全选", value: undefined },
157
- { label: "选项一", value: "one" },
158
- { label: "选项二", value: "two" }
159
- ],
160
- otherOptions: {
161
- // 其他配置、参考Element的选择器配置
162
- },
163
- colLayout: {
164
- xs: 24,
165
- sm: 8,
166
- md: 8,
167
- lg: 4,
168
- xl: 4
169
- }
170
- },
171
- // 日期选择器
172
- {
173
- field: "datepicker",
174
- type: "datepicker",
175
- label: "日期选择器",
176
- placeholder: "请选择日期",
177
- labelWidth: "70px",
178
- otherOptions: {
179
- // 其他选项配置、参考Element的配置
180
- }
181
- },
182
- // 级联
183
- {
184
- field: "cascader",
185
- type: "cascader",
186
- label: "级联",
187
- placeholder: "请选择",
188
- labelWidth: "70px",
189
- options: [], // 于Element保持一致
190
- otherOptions: {
191
- // 其他选项配置、参考Element的配置
192
- }
193
- },
194
- // 开关
195
- {
196
- field: "switch",
197
- type: "switch",
198
- label: "开关",
199
- labelWidth: "70px",
200
- otherOptions: {
201
- // 其他选项配置、参考Element的配置
202
- }
203
- },
204
- // 单选框
205
- {
206
- field: "radioGroup",
207
- type: "radioGroup",
208
- label: "单选框",
209
- labelWidth: "70px",
210
- otherOptions: {
211
- // 其他选项配置、参考Element的配置
212
- },
213
- cGOptions: {
214
- type: "button", // "button" || "checkbox"
215
- options: [] // 按照label、value的键值对传入
216
- }
217
- },
218
- // 多选框
219
- {
220
- field: "checkboxGroup",
221
- type: "checkboxGroup",
222
- label: "多选框",
223
- labelWidth: "70px",
224
- otherOptions: {
225
- // 其他选项配置、参考Element的配置
226
- },
227
- cGOptions: {
228
- type: "button", // "button" || "checkbox"
229
- options: [] // 按照label、value的键值对传入
230
- }
231
- },
232
- // 文本类型
233
- {
234
- field: "text",
235
- type: "text",
236
- label: "文本类型",
237
- labelWidth: "70px",
238
- defaultValue: "需要显示的文本"
239
- },
240
- // 数字范围输入框
241
- {
242
- field: "pairNumberInput",
243
- type: "pairNumberInput",
244
- label: "数字范围输入框",
245
- labelWidth: "70px",
246
- earliestPlaceholder: "前面输入框的Placeholder",
247
- latestPlaceholder: "后面输入框的Placeholder"
248
- },
249
- {
250
- field: "custom",
251
- type: "custom",
252
- label: "自定义",
253
- labelWidth: "70px",
254
- },
255
- }
256
- }
257
- },
258
- methods: {
259
- // 查询
260
- handleQueryClick() {},
261
- /**
262
- * @describe 表单回调、以下对推广人员四级和标签于推广账户组件交互是进行一些传参的改变、逻辑依据原老组件需要的参数进行复制处理
263
- * @param { Object } value 为对象字段名和所赋予的值
264
- */
265
- handleChangePageSearch({ field, value }) {
266
- if (["area_id", "department_id", "team_id", "user_id", "favourite_id"].includes(field)) {
267
- if (field === "area_id") {
268
- this.formConfig.formItems.forEach(item => {
269
- if (item.field === "department_id" || item.field === "team_id" || item.field === "user_id") {
270
- item.otherOptions.areaId = value
271
- }
272
- })
273
- } else if (field === "department_id") {
274
- this.formConfig.formItems.forEach(item => {
275
- if (item.field === "team_id" || item.field === "user_id") {
276
- item.otherOptions.departmentId = value
277
- }
278
- })
279
- } else if (field === "team_id") {
280
- this.formConfig.formItems.forEach(item => {
281
- if (item.field === "user_id") {
282
- item.otherOptions.teamId = value
283
- }
284
- })
285
- } else if (field === "user_id") {
286
- this.formConfig.formItems.forEach(item => {
287
- if (item.field === "favourite_id" || item.field === "advertiser_id") {
288
- item.otherOptions.userId = value
289
- }
290
- })
291
- } else if (field === "favourite_id") {
292
- if (value.length) {
293
- this.formConfig.formItems.forEach(item => {
294
- if (item.field === "advertiser_id") {
295
- item.otherOptions.options.favouriteId = value
296
- item.isHidden = false
297
- }
298
- })
299
- } else {
300
- this.formConfig.formItems.forEach(item => {
301
- if (item.field === "advertiser_id") {
302
- console.log(item, "item")
303
- item.otherOptions.options.favouriteId = []
304
- item.isHidden = true
305
- }
306
- })
307
- }
308
- }
309
- }
310
- }
311
- }
312
- }
313
- </script>
314
-
315
- ```
316
-
317
- #### 自定义时间选择器'customDatePicker'特别说明
318
-
319
- 自定义时间选择器同时支持时间段方式绑定值 和 单独时间方式绑定值
320
-
321
- ```
322
- // 时间段方式绑定值
323
- {
324
- type: 'customDatePicker',
325
- field: 'report_time',
326
- label: '报表时间'
327
- }
328
- ```
329
-
330
- ```
331
- // 单独时间方式绑定值
332
- {
333
- type: 'customDatePicker',
334
- field: 'report_time', // 仍然保留原来的字段,保证兼容性
335
- startTimeField: 'start_time', // 新增开始时间字段
336
- endTimeField: 'end_time', // 新增结束时间字段
337
- label: '报表时间'
338
- }
339
- ```
340
-
341
- ### 表格 by-table
342
-
343
- [vxe-table 文档](https://vxetable.cn/v3.8/#/table/start/install)
344
-
345
- ###### 通用配置
346
-
347
- ```
348
- <template>
349
- <by-table
350
- ref="BTableRef"
351
- :grid-options="gridOptions"
352
- @checkbox-change="({records}) => handleCheckboxChange(records)"
353
- @checkbox-all="({records}) => handleCheckboxChange(records)"
354
- @page-change="handlePageChange"
355
- @sort-change="handleSortChange"
356
- >
357
- <template #switch="{ row }">
358
- <el-switch
359
- v-if="row.id"
360
- size="mini"
361
- :value="row.opt_status==='ENABLE'"
362
- />
363
- </template>
364
- <template #status_text="{ row }">
365
- <span class="text_pointer_primary">{{ row.status_text }}</span>
366
- </template>
367
- <template #operate>
368
- <el-button type="text">编辑</el-button>
369
- <el-button style="color:red" type="text">删除</el-button>
370
- </template>
371
- </by-table>
372
- </template>
373
-
374
- <script>
375
- export default {
376
- data() {
377
- return {
378
- /**
379
- * @see https://vxetable.cn/v3.8/#/grid/api
380
- * @description 其他配置想看vxe-table文档(除 pagerConfig 和 copyFields 外)
381
- * @param { false | Object } pagerConfig 分页配置、如果不想设置分页的话则设置false值即可、如果为对象的话则只接受pageSize、currentPage、total字段
382
- * @param { Array } copyFields 需要用户点击单元格复制的字段标识数组集合
383
- */
384
- gridOptions: {
385
- height: 700,
386
- pagerConfig: {
387
- // 默认每页大小
388
- pageSize: 15,
389
- // 当前页码
390
- currentPage: 1,
391
- // 总条数
392
- total: 25
393
- },
394
- checkboxConfig: {
395
- checkMethod: ({ row }) => {
396
- return !!row.id
397
- },
398
- visibleMethod: ({ row }) => {
399
- return !!row.id
400
- }
401
- },
402
- seqConfig: {
403
- seqMethod: ({ row, rowIndex }) => {
404
- return row.id ? rowIndex : "汇总"
405
- }
406
- },
407
- copyFields: ["status_text"],
408
- // 默认显示的排序
409
- sortConfig: {
410
- defaultSort: {
411
- // 默认消耗倒序
412
- field: "cost", order: "desc"
413
- }
414
- },
415
-
416
- customColumnConfig: { // 自定义列
417
- showCustomColumn: true, // 是否显示自定义列
418
- infoMethod: getCustomTableList, // 回显用的接口
419
- submitMethod: setCustomTableList, // 保存用的接口
420
- slots: ["source_material_count"] // 需要使用插槽的字段集合
421
- },
422
- columns: [
423
- { type: "checkbox", width: 50, fixed: "left" },
424
- { type: "seq", width: 50, fixed: "left", title: "序号" },
425
- { field: "switch", title: "开关", width: 70, fixed: "left", slots: { default: "switch" }},
426
- { field: "status_text", title: "状态", width: 70, fixed: "left", slots: { default: "status_text" }},
427
- { field: "cost", title: "消耗", width: 70 },
428
- { field: "operate", title: "操作", width: 70, fixed: "left", slots: { default: "operate" }}
429
- ],
430
- data: []
431
- }
432
- }
433
- },
434
- methods: {
435
- // 多选回调
436
- handleCheckboxChange(records) {
437
- console.log(records, "records")
438
- },
439
- // 排序回调
440
- handleSortChange(context) {
441
- this.searchQuery.order = `${context.field} ${context.order}`
442
- // 以下执行列表接口.....
443
- },
444
- // 分页回调
445
- handlePageChange({ page, limit }) {
446
- this.gridOptions.pagerConfig.currentPage = page
447
- this.gridOptions.pagerConfig.pageSize = limit
448
- // 以下执行列表接口.....
449
- }
450
- }
451
- }
452
- </script>
453
-
454
- ```
455
-
456
- ###### 自定义列支持多级表头
457
-
458
- ```
459
- <template>
460
- <by-table
461
- :grid-options="gridOptions"
462
- @setColumn="handleSetColumn"
463
- @setGroupColumn="handleSetColumn"
464
- >
465
- </by-table>
466
- </template>
467
-
468
- <script>
469
- export default {
470
- data() {
471
- return {
472
- gridOptions: {
473
- border: true,
474
- stripe: true,
475
- resizable: true,
476
- height: 500,
477
- // 非自定义列的情况下的多级表头配置方式
478
- columns: [
479
- { type: 'seq', width: 50 },
480
- {
481
- title: '基本信息',
482
- children: [
483
- { field: 'name', title: 'Name' },
484
- {
485
- title: '其他信息',
486
- children: [
487
- { field: 'nickname', title: 'Nickname' },
488
- { field: 'age', title: 'Age', sortable: true }
489
- ]
490
- },
491
- { field: 'sex', title: 'Sex' }
492
- ]
493
- },
494
- { field: 'address', title: 'Address', sortable: true, showOverflow: true }
495
- ],
496
- }
497
- }
498
- },
499
- methods: {
500
- // setColumn 返回只有一级的表头
501
- // setGroupColumn 返回多级表头数据
502
- handleSetColumn(columns) {
503
- this.gridOptions.columns = [
504
- { type: "checkbox", width: 50, fixed: "left" },
505
- { type: "seq", width: 50, fixed: "left", title: "序号" },
506
- ...columns,
507
- { title: "操作", width: 80, fixed: "right", slots: { default: "operate" }}
508
- ]
509
- },
510
- }
511
- }
512
- </script>
513
- ```
1
+ # @weitutech/by-components
2
+
3
+ ### npm 安装
4
+
5
+ ```
6
+ 安装时切换淘宝源比较快
7
+ npm config set registry https://registry.npmmirror.com/
8
+
9
+ npm install @weitutech/by-components
10
+ ```
11
+
12
+ ### 引入
13
+
14
+ 由于对 vxeTable 进行了再次处理,所以需要复制 plugin 文件夹到项目中
15
+ 并手动引入 vxeTable
16
+ plugin 目录可从组件库中复制到项目
17
+
18
+ ```
19
+ import '@/plugin/vxeTable.js';
20
+ import '@weitutech/by-components/lib/index.css'
21
+ import BYComponents from '@weitutech/by-components'
22
+ Vue.use(BYComponents)
23
+ ```
24
+
25
+ ### npm 发布
26
+
27
+ ```
28
+ 第一次发布
29
+ npm login
30
+
31
+ 发布时需要确保npm的源是官方 npm
32
+ npm config set registry https://registry.npmjs.org/
33
+
34
+
35
+ 出现功能修改后,需更新package的版本号
36
+ 清除缓存
37
+ npm cache clean --force
38
+ 发布
39
+ npm publish --access public
40
+ ```
41
+
42
+ ### 注意事项
43
+
44
+ 1. 组件开发中 css 样式单独放在 style 目录下, 整体打包成一个 css 样式引入
45
+ 2. 打包后会在 lib 目录下生成 js 和 css 文件
46
+ 3. 本地开发时可采用 npm link 方式关联依赖,package 入口配置为 src/index.js
47
+
48
+ ### npm link
49
+
50
+ ```
51
+ 组件库中运行 npm link
52
+ 项目中运行 npm link @weitutech/by-components
53
+ ```
54
+
55
+ > **💡 提示**
56
+ > 本地link调试时,需要把组件库的package.json中的main字段改为src/index.js("main": "src/index.js")
57
+ > 如需link调试样式, 宿主工程main.js中要 import '@weitutech/by-components/src/style/index.scss' //TODO:注意:调试样式link , 调试完需注释
58
+ > 调试完成后,切记改回 "main": "lib/by-components.umd.js",
59
+ > 如果组件库更新,宿主项目没有同步更新, 尝试重新编译组件库npm run build, 且清除宿主项目缓存rm -rf node_modules/.cache
60
+
61
+ ### 组件文档构建
62
+
63
+ ```
64
+ npm run docs:dev
65
+ npm run docs:build
66
+ 文档部署到Github Pages: npm run docs:deploy
67
+ ```
68
+
69
+ [组件文档·Github Pages](https://weitutech.github.io/by-frontend-components-docs/)
70
+
71
+ ### 关于新组件开发
72
+
73
+ 1. 采用 by 为前缀命名方式
74
+ 2. 避免过度耦合,考虑不同项目的复用性,尽量避免组件内调取接口
75
+
76
+ ### 表单 by-page-search
77
+
78
+ ```
79
+ <template>
80
+ <by-page-search
81
+ ref="pageSearchRef"
82
+ v-model="searchQuery"
83
+ :search-form-config="formConfig"
84
+ @queryBtnClick="handleQueryClick"
85
+ @change="handleChangePageSearch"
86
+ >
87
+ <template #custom>
88
+ 我是外部自定义内容
89
+ </template>
90
+ </by-page-search>
91
+ </template>
92
+
93
+ <script>
94
+ export default {
95
+ data() {
96
+ return {
97
+ searchQuery: {
98
+ // 对应formConfig对象中formItems中的每个field
99
+ },
100
+ formConfig: {
101
+ labelWidth: "80px",
102
+ itemStyle: {
103
+ padding: "0px 0px"
104
+ },
105
+ // 需要折叠的字段、不分顺序、写在里面的字段都会被隐藏 --- 仅在isFlexible = true 才可用
106
+ flexible: {
107
+ // 这里模拟写一些
108
+ foldField: ["area_id", "department_id", "team_id", "user_id", "favourite_id", "category_id", "brand_id"]
109
+ },
110
+ // 是否开启折叠功能
111
+ isFlexible: true,
112
+ colLayout: {
113
+ xs: 24,
114
+ sm: 12,
115
+ md: 12,
116
+ lg: 6,
117
+ xl: 4
118
+ },
119
+ elSize: "mini",
120
+ // 对应表单单独的显隐权限 可设置isHidden来控制
121
+ formItems: [
122
+ // 输入框
123
+ {
124
+ id: 1, // 作为可选的唯一标识,如果field有重复可以设置id作为唯一标识
125
+ field: "input",
126
+ type: "input",
127
+ label: "输入框",
128
+ placeholder: "请输入",
129
+ labelWidth: "70px",
130
+ isHidden: false, // 是否隐藏 false || true
131
+ otherOptions: {
132
+ // 其他选项配置、参考Element的输入框配置
133
+ }
134
+ },
135
+ // 密码输入框
136
+ {
137
+ field: "password",
138
+ type: "password",
139
+ label: "密码输入框",
140
+ placeholder: "请输入密码",
141
+ labelWidth: "70px",
142
+ otherOptions: {
143
+ // 其他选项配置、参考Element的输入框配置
144
+ }
145
+ },
146
+ // 选择器
147
+ {
148
+ field: "select",
149
+ type: "select",
150
+ label: "选择器",
151
+ placeholder: "请选择",
152
+ labelWidth: "100px",
153
+ mode: "", // 可选 "group" || false 默认 不传不用配置 group为分组模式
154
+ options: [
155
+ // 必须按照label、value的键值对传入
156
+ { label: "全选", value: undefined },
157
+ { label: "选项一", value: "one" },
158
+ { label: "选项二", value: "two" }
159
+ ],
160
+ otherOptions: {
161
+ // 其他配置、参考Element的选择器配置
162
+ },
163
+ colLayout: {
164
+ xs: 24,
165
+ sm: 8,
166
+ md: 8,
167
+ lg: 4,
168
+ xl: 4
169
+ }
170
+ },
171
+ // 日期选择器
172
+ {
173
+ field: "datepicker",
174
+ type: "datepicker",
175
+ label: "日期选择器",
176
+ placeholder: "请选择日期",
177
+ labelWidth: "70px",
178
+ otherOptions: {
179
+ // 其他选项配置、参考Element的配置
180
+ }
181
+ },
182
+ // 级联
183
+ {
184
+ field: "cascader",
185
+ type: "cascader",
186
+ label: "级联",
187
+ placeholder: "请选择",
188
+ labelWidth: "70px",
189
+ options: [], // 于Element保持一致
190
+ otherOptions: {
191
+ // 其他选项配置、参考Element的配置
192
+ }
193
+ },
194
+ // 开关
195
+ {
196
+ field: "switch",
197
+ type: "switch",
198
+ label: "开关",
199
+ labelWidth: "70px",
200
+ otherOptions: {
201
+ // 其他选项配置、参考Element的配置
202
+ }
203
+ },
204
+ // 单选框
205
+ {
206
+ field: "radioGroup",
207
+ type: "radioGroup",
208
+ label: "单选框",
209
+ labelWidth: "70px",
210
+ otherOptions: {
211
+ // 其他选项配置、参考Element的配置
212
+ },
213
+ cGOptions: {
214
+ type: "button", // "button" || "checkbox"
215
+ options: [] // 按照label、value的键值对传入
216
+ }
217
+ },
218
+ // 多选框
219
+ {
220
+ field: "checkboxGroup",
221
+ type: "checkboxGroup",
222
+ label: "多选框",
223
+ labelWidth: "70px",
224
+ otherOptions: {
225
+ // 其他选项配置、参考Element的配置
226
+ },
227
+ cGOptions: {
228
+ type: "button", // "button" || "checkbox"
229
+ options: [] // 按照label、value的键值对传入
230
+ }
231
+ },
232
+ // 文本类型
233
+ {
234
+ field: "text",
235
+ type: "text",
236
+ label: "文本类型",
237
+ labelWidth: "70px",
238
+ defaultValue: "需要显示的文本"
239
+ },
240
+ // 数字范围输入框
241
+ {
242
+ field: "pairNumberInput",
243
+ type: "pairNumberInput",
244
+ label: "数字范围输入框",
245
+ labelWidth: "70px",
246
+ earliestPlaceholder: "前面输入框的Placeholder",
247
+ latestPlaceholder: "后面输入框的Placeholder"
248
+ },
249
+ {
250
+ field: "custom",
251
+ type: "custom",
252
+ label: "自定义",
253
+ labelWidth: "70px",
254
+ },
255
+ }
256
+ }
257
+ },
258
+ methods: {
259
+ // 查询
260
+ handleQueryClick() {},
261
+ /**
262
+ * @describe 表单回调、以下对推广人员四级和标签于推广账户组件交互是进行一些传参的改变、逻辑依据原老组件需要的参数进行复制处理
263
+ * @param { Object } value 为对象字段名和所赋予的值
264
+ */
265
+ handleChangePageSearch({ field, value }) {
266
+ if (["area_id", "department_id", "team_id", "user_id", "favourite_id"].includes(field)) {
267
+ if (field === "area_id") {
268
+ this.formConfig.formItems.forEach(item => {
269
+ if (item.field === "department_id" || item.field === "team_id" || item.field === "user_id") {
270
+ item.otherOptions.areaId = value
271
+ }
272
+ })
273
+ } else if (field === "department_id") {
274
+ this.formConfig.formItems.forEach(item => {
275
+ if (item.field === "team_id" || item.field === "user_id") {
276
+ item.otherOptions.departmentId = value
277
+ }
278
+ })
279
+ } else if (field === "team_id") {
280
+ this.formConfig.formItems.forEach(item => {
281
+ if (item.field === "user_id") {
282
+ item.otherOptions.teamId = value
283
+ }
284
+ })
285
+ } else if (field === "user_id") {
286
+ this.formConfig.formItems.forEach(item => {
287
+ if (item.field === "favourite_id" || item.field === "advertiser_id") {
288
+ item.otherOptions.userId = value
289
+ }
290
+ })
291
+ } else if (field === "favourite_id") {
292
+ if (value.length) {
293
+ this.formConfig.formItems.forEach(item => {
294
+ if (item.field === "advertiser_id") {
295
+ item.otherOptions.options.favouriteId = value
296
+ item.isHidden = false
297
+ }
298
+ })
299
+ } else {
300
+ this.formConfig.formItems.forEach(item => {
301
+ if (item.field === "advertiser_id") {
302
+ console.log(item, "item")
303
+ item.otherOptions.options.favouriteId = []
304
+ item.isHidden = true
305
+ }
306
+ })
307
+ }
308
+ }
309
+ }
310
+ }
311
+ }
312
+ }
313
+ </script>
314
+
315
+ ```
316
+
317
+ #### 自定义时间选择器'customDatePicker'特别说明
318
+
319
+ 自定义时间选择器同时支持时间段方式绑定值 和 单独时间方式绑定值
320
+
321
+ ```
322
+ // 时间段方式绑定值
323
+ {
324
+ type: 'customDatePicker',
325
+ field: 'report_time',
326
+ label: '报表时间'
327
+ }
328
+ ```
329
+
330
+ ```
331
+ // 单独时间方式绑定值
332
+ {
333
+ type: 'customDatePicker',
334
+ field: 'report_time', // 仍然保留原来的字段,保证兼容性
335
+ startTimeField: 'start_time', // 新增开始时间字段
336
+ endTimeField: 'end_time', // 新增结束时间字段
337
+ label: '报表时间'
338
+ }
339
+ ```
340
+
341
+ ### 表格 by-table
342
+
343
+ [vxe-table 文档](https://vxetable.cn/v3.8/#/table/start/install)
344
+
345
+ ###### 通用配置
346
+
347
+ ```
348
+ <template>
349
+ <by-table
350
+ ref="BTableRef"
351
+ :grid-options="gridOptions"
352
+ @checkbox-change="({records}) => handleCheckboxChange(records)"
353
+ @checkbox-all="({records}) => handleCheckboxChange(records)"
354
+ @page-change="handlePageChange"
355
+ @sort-change="handleSortChange"
356
+ >
357
+ <template #switch="{ row }">
358
+ <el-switch
359
+ v-if="row.id"
360
+ size="mini"
361
+ :value="row.opt_status==='ENABLE'"
362
+ />
363
+ </template>
364
+ <template #status_text="{ row }">
365
+ <span class="text_pointer_primary">{{ row.status_text }}</span>
366
+ </template>
367
+ <template #operate>
368
+ <el-button type="text">编辑</el-button>
369
+ <el-button style="color:red" type="text">删除</el-button>
370
+ </template>
371
+ </by-table>
372
+ </template>
373
+
374
+ <script>
375
+ export default {
376
+ data() {
377
+ return {
378
+ /**
379
+ * @see https://vxetable.cn/v3.8/#/grid/api
380
+ * @description 其他配置想看vxe-table文档(除 pagerConfig 和 copyFields 外)
381
+ * @param { false | Object } pagerConfig 分页配置、如果不想设置分页的话则设置false值即可、如果为对象的话则只接受pageSize、currentPage、total字段
382
+ * @param { Array } copyFields 需要用户点击单元格复制的字段标识数组集合
383
+ */
384
+ gridOptions: {
385
+ height: 700,
386
+ pagerConfig: {
387
+ // 默认每页大小
388
+ pageSize: 15,
389
+ // 当前页码
390
+ currentPage: 1,
391
+ // 总条数
392
+ total: 25
393
+ },
394
+ checkboxConfig: {
395
+ checkMethod: ({ row }) => {
396
+ return !!row.id
397
+ },
398
+ visibleMethod: ({ row }) => {
399
+ return !!row.id
400
+ }
401
+ },
402
+ seqConfig: {
403
+ seqMethod: ({ row, rowIndex }) => {
404
+ return row.id ? rowIndex : "汇总"
405
+ }
406
+ },
407
+ copyFields: ["status_text"],
408
+ // 默认显示的排序
409
+ sortConfig: {
410
+ defaultSort: {
411
+ // 默认消耗倒序
412
+ field: "cost", order: "desc"
413
+ }
414
+ },
415
+
416
+ customColumnConfig: { // 自定义列
417
+ showCustomColumn: true, // 是否显示自定义列
418
+ infoMethod: getCustomTableList, // 回显用的接口
419
+ submitMethod: setCustomTableList, // 保存用的接口
420
+ slots: ["source_material_count"] // 需要使用插槽的字段集合
421
+ },
422
+ columns: [
423
+ { type: "checkbox", width: 50, fixed: "left" },
424
+ { type: "seq", width: 50, fixed: "left", title: "序号" },
425
+ { field: "switch", title: "开关", width: 70, fixed: "left", slots: { default: "switch" }},
426
+ { field: "status_text", title: "状态", width: 70, fixed: "left", slots: { default: "status_text" }},
427
+ { field: "cost", title: "消耗", width: 70 },
428
+ { field: "operate", title: "操作", width: 70, fixed: "left", slots: { default: "operate" }}
429
+ ],
430
+ data: []
431
+ }
432
+ }
433
+ },
434
+ methods: {
435
+ // 多选回调
436
+ handleCheckboxChange(records) {
437
+ console.log(records, "records")
438
+ },
439
+ // 排序回调
440
+ handleSortChange(context) {
441
+ this.searchQuery.order = `${context.field} ${context.order}`
442
+ // 以下执行列表接口.....
443
+ },
444
+ // 分页回调
445
+ handlePageChange({ page, limit }) {
446
+ this.gridOptions.pagerConfig.currentPage = page
447
+ this.gridOptions.pagerConfig.pageSize = limit
448
+ // 以下执行列表接口.....
449
+ }
450
+ }
451
+ }
452
+ </script>
453
+
454
+ ```
455
+
456
+ ###### 自定义列支持多级表头
457
+
458
+ ```
459
+ <template>
460
+ <by-table
461
+ :grid-options="gridOptions"
462
+ @setColumn="handleSetColumn"
463
+ @setGroupColumn="handleSetColumn"
464
+ >
465
+ </by-table>
466
+ </template>
467
+
468
+ <script>
469
+ export default {
470
+ data() {
471
+ return {
472
+ gridOptions: {
473
+ border: true,
474
+ stripe: true,
475
+ resizable: true,
476
+ height: 500,
477
+ // 非自定义列的情况下的多级表头配置方式
478
+ columns: [
479
+ { type: 'seq', width: 50 },
480
+ {
481
+ title: '基本信息',
482
+ children: [
483
+ { field: 'name', title: 'Name' },
484
+ {
485
+ title: '其他信息',
486
+ children: [
487
+ { field: 'nickname', title: 'Nickname' },
488
+ { field: 'age', title: 'Age', sortable: true }
489
+ ]
490
+ },
491
+ { field: 'sex', title: 'Sex' }
492
+ ]
493
+ },
494
+ { field: 'address', title: 'Address', sortable: true, showOverflow: true }
495
+ ],
496
+ }
497
+ }
498
+ },
499
+ methods: {
500
+ // setColumn 返回只有一级的表头
501
+ // setGroupColumn 返回多级表头数据
502
+ handleSetColumn(columns) {
503
+ this.gridOptions.columns = [
504
+ { type: "checkbox", width: 50, fixed: "left" },
505
+ { type: "seq", width: 50, fixed: "left", title: "序号" },
506
+ ...columns,
507
+ { title: "操作", width: 80, fixed: "right", slots: { default: "operate" }}
508
+ ]
509
+ },
510
+ }
511
+ }
512
+ </script>
513
+ ```