ol-base-components 3.4.5 → 3.4.6

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.
Files changed (64) hide show
  1. package/dist/index.mjs +7105 -0
  2. package/dist/index.umd.js +1 -0
  3. package/dist/style.css +1 -0
  4. package/package.json +18 -4
  5. package/.eslintrc +0 -59
  6. package/.github/deploy.yml +0 -81
  7. package/.prettierignore +0 -6
  8. package/.prettierrc +0 -13
  9. package/.trae/rules/project.md +0 -2
  10. package/babel.config.js +0 -5
  11. package/jsconfig.json +0 -19
  12. package/readme1.md +0 -164
  13. package/src/App.vue +0 -932
  14. package/src/assets/Snipaste_2025-09-03_14-30-49.png +0 -0
  15. package/src/assets/api.png +0 -0
  16. package/src/assets/css/iconfont.css +0 -342
  17. package/src/assets/duojibiaotou.png +0 -0
  18. package/src/assets/effectPicture.png +0 -0
  19. package/src/assets/generator0.png +0 -0
  20. package/src/assets/generator1.png +0 -0
  21. package/src/assets/generator2.png +0 -0
  22. package/src/assets/icon/printModel.svg +0 -1
  23. package/src/assets/init.png +0 -0
  24. package/src/assets/logo.png +0 -0
  25. package/src/assets/olBaseComponentsLogo.svg +0 -100
  26. package/src/assets/print.svg +0 -1
  27. package/src/assets/run.png +0 -0
  28. package/src/assets/vscodecj.png +0 -0
  29. package/src/bin/initTemplate.js +0 -409
  30. package/src/bin/news.js +0 -171
  31. package/src/bin/openCloseloop.js +0 -154
  32. package/src/bin/openLoop.js +0 -154
  33. package/src/main.js +0 -13
  34. package/src/package/customSearch/index.js +0 -7
  35. package/src/package/customSearch/src/index.vue +0 -120
  36. package/src/package/dialog/index.js +0 -7
  37. package/src/package/dialog/src/index.vue +0 -419
  38. package/src/package/form/index.js +0 -7
  39. package/src/package/form/src/index.vue +0 -405
  40. package/src/package/formSearch/index.js +0 -7
  41. package/src/package/formSearch/src/components/SearchConfigDialog.vue +0 -957
  42. package/src/package/formSearch/src/index.js +0 -29
  43. package/src/package/formSearch/src/index.vue +0 -928
  44. package/src/package/index.js +0 -243
  45. package/src/package/numberRange/index.js +0 -7
  46. package/src/package/numberRange/src/index.vue +0 -351
  47. package/src/package/print/index.js +0 -76
  48. package/src/package/print/src/components/PaperSelector.vue +0 -109
  49. package/src/package/print/src/index.vue +0 -622
  50. package/src/package/print/src/provide/provider1.js +0 -215
  51. package/src/package/printModel/index.js +0 -7
  52. package/src/package/printModel/src/index.vue +0 -493
  53. package/src/package/table/index.js +0 -12
  54. package/src/package/table/src/TableColumn.vue +0 -77
  55. package/src/package/table/src/components/PrintTemplateSelector.vue +0 -210
  56. package/src/package/table/src/index.vue +0 -945
  57. package/src/package/table/src/nodata.jpg +0 -0
  58. package/src/package/table/src/printTable.vue +0 -196
  59. package/src/utils/getEnum.js +0 -8
  60. package/src/utils/initData.js +0 -138
  61. package/vue.config.js +0 -21
  62. /package/{public → dist}/favicon.ico +0 -0
  63. /package/{public → dist}/index.html +0 -0
  64. /package/{public → dist}/print-lock.css +0 -0
@@ -1,957 +0,0 @@
1
- <template>
2
- <el-dialog
3
- title="搜索条件配置"
4
- :visible.sync="dialogVisible"
5
- width="60%"
6
- :close-on-click-modal="false"
7
- @close="handleClose"
8
- append-to-body
9
- >
10
- <div class="search-config-container">
11
- <div class="config-header">
12
- <el-button
13
- v-if="customs && customs.length > 0"
14
- type="success"
15
- size="small"
16
- @click="customsDialogVisible = true"
17
- >
18
- <i class="el-icon-plus" />
19
- 从预设添加
20
- </el-button>
21
- </div>
22
-
23
- <el-table
24
- ref="configTable"
25
- :data="configList"
26
- border
27
- stripe
28
- style="width: 100%; margin-top: 10px"
29
- :row-class-name="tableRowClassName"
30
- row-key="value"
31
- :tree-props="{ children: '' }"
32
- >
33
- <el-table-column label="排序" width="80" align="center" v-if="dragable">
34
- <template slot-scope="scope">
35
- <i class="el-icon-rank sort-handle" style="cursor: move; font-size: 18px" />
36
- </template>
37
- </el-table-column>
38
-
39
- <el-table-column label="字段名称" prop="label" align="center">
40
- <template slot-scope="scope">
41
- <el-input
42
- v-model="scope.row.label"
43
- size="small"
44
- placeholder="请输入字段名称"
45
- disabled
46
- />
47
- </template>
48
- </el-table-column>
49
-
50
- <el-table-column label="字段值" prop="value" align="center">
51
- <template slot-scope="scope">
52
- <el-input v-model="scope.row.value" size="small" placeholder="请输入字段值" disabled />
53
- </template>
54
- </el-table-column>
55
-
56
- <el-table-column label="输入类型" prop="inputType" width="130" align="center">
57
- <template slot-scope="scope">
58
- <el-select
59
- v-model="scope.row.inputType"
60
- size="small"
61
- placeholder="请选择类型"
62
- @change="handleTypeChange(scope.row)"
63
- :disabled="['number', 'picker'].includes(scope.row.inputType)"
64
- >
65
- <el-option label="文本输入" value="text" />
66
- <el-option label="数字输入" value="number" disabled />
67
- <el-option label="下拉选择" value="select" />
68
- <el-option label="日期选择" value="picker" disabled />
69
- </el-select>
70
- </template>
71
- </el-table-column>
72
-
73
- <el-table-column label="日期类型" width="150" align="center">
74
- <template slot-scope="scope">
75
- <el-select
76
- v-if="scope.row.inputType === 'picker'"
77
- v-model="scope.row.dateType"
78
- size="small"
79
- placeholder="请选择日期类型"
80
- @change="handleDateTypeChange(scope.row)"
81
- >
82
- <el-option label="日期" value="date" />
83
- <el-option label="日期时间" value="datetime" />
84
- <el-option label="日期范围" value="daterange" />
85
- <el-option label="日期时间范围" value="datetimerange" />
86
- <el-option label="月份" value="month" />
87
- <el-option label="月份范围" value="monthrange" />
88
- <el-option label="年份" value="year" />
89
- </el-select>
90
- <div v-else class="gray-text">-</div>
91
- </template>
92
- </el-table-column>
93
-
94
- <el-table-column label="比较方式" width="130" align="center">
95
- <template slot-scope="scope">
96
- <el-select v-model="scope.row.compare" size="small" placeholder="请选择比较方式">
97
- <el-option label="范围" value="range" />
98
- <el-option label="包含于" value="in" />
99
- <el-option label="不包含于" value="not in" />
100
- <el-option label="等于" value="eq" />
101
- <el-option label="不等于" value="ne" />
102
- <el-option label="大于" value="gt" />
103
- <el-option label="大于等于" value="ge" />
104
- <el-option label="小于" value="lt" />
105
- <el-option label="小于等于" value="le" />
106
- <el-option label="包含" value="contains" />
107
- <el-option label="以...开始" value="startswith" />
108
- <el-option label="以...结束" value="endswith" />
109
- </el-select>
110
- </template>
111
- </el-table-column>
112
-
113
- <el-table-column label="配置" width="150" align="center">
114
- <template slot-scope="scope">
115
- <div v-if="scope.row.inputType === 'select'">
116
- <el-button type="text" size="small" @click="handleConfigOptions(scope.$index)">
117
- 配置选项
118
- </el-button>
119
- </div>
120
- <div v-else class="gray-text">无需配置</div>
121
- </template>
122
- </el-table-column>
123
-
124
- <el-table-column label="操作" width="100" align="center">
125
- <template slot-scope="scope">
126
- <el-button
127
- type="text"
128
- icon="el-icon-delete"
129
- style="color: #f56c6c"
130
- @click="handleDelete(scope.$index)"
131
- >
132
- 删除
133
- </el-button>
134
- </template>
135
- </el-table-column>
136
- </el-table>
137
- </div>
138
-
139
- <div class="dialog-footer">
140
- <slot name="footer">
141
- <el-button @click="handleClose">取消</el-button>
142
- <el-button type="primary" @click="handleSave">确定</el-button>
143
- </slot>
144
- </div>
145
-
146
- <el-dialog title="配置选项" :visible.sync="optionsDialogVisible" width="700px" append-to-body>
147
- <el-form :model="currentOptionConfig" label-width="100px" size="small">
148
- <el-form-item label="数据来源">
149
- <el-radio-group v-model="currentOptionConfig.sourceType">
150
- <el-radio label="manual">手动配置</el-radio>
151
- <el-radio label="dict">本地字典</el-radio>
152
- <el-radio label="api">接口获取</el-radio>
153
- </el-radio-group>
154
- </el-form-item>
155
-
156
- <el-form-item v-if="currentOptionConfig.sourceType === 'dict'" label="字典">
157
- <el-select
158
- v-model="currentOptionConfig.dictKey"
159
- filterable
160
- :filter-method="filterDict"
161
- placeholder="请输入字典,如:orderTypeEnum"
162
- style="width: 100%"
163
- @change="handleDictKeyChange"
164
- clearable
165
- >
166
- <el-option
167
- v-for="dict in allDictList"
168
- :key="dict.key"
169
- :label="dict.label"
170
- :value="dict.key"
171
- >
172
- <span style="float: left">{{ dict.label }}</span>
173
- <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.key }}</span>
174
- </el-option>
175
- </el-select>
176
- </el-form-item>
177
-
178
- <el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="接口地址">
179
- <el-input
180
- v-model="currentOptionConfig.apiUrl"
181
- placeholder="请输入接口地址,如:/api/dict/list"
182
- />
183
- </el-form-item>
184
-
185
- <el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="请求方式">
186
- <el-select v-model="currentOptionConfig.method" placeholder="请选择请求方式">
187
- <el-option label="GET" value="get" />
188
- <el-option label="POST" value="post" />
189
- </el-select>
190
- </el-form-item>
191
-
192
- <el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="文本字段">
193
- <el-input v-model="currentOptionConfig.labelField" placeholder="如:name" />
194
- </el-form-item>
195
-
196
- <el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="值字段">
197
- <el-input v-model="currentOptionConfig.valueField" placeholder="如:id" />
198
- </el-form-item>
199
-
200
- <el-form-item v-if="currentOptionConfig.sourceType === 'manual'" label="选项列表">
201
- <div class="options-config">
202
- <div
203
- v-for="(option, index) in currentOptionConfig.options"
204
- :key="index"
205
- class="option-item"
206
- >
207
- <el-input
208
- v-model="option.value"
209
- size="small"
210
- placeholder="文本"
211
- style="width: 150px"
212
- />
213
- <el-input
214
- v-model="option.key"
215
- size="small"
216
- placeholder="值"
217
- style="width: 150px; margin-left: 10px"
218
- />
219
- <el-button
220
- type="text"
221
- icon="el-icon-delete"
222
- style="color: #f56c6c; margin-left: 10px"
223
- @click="handleDeleteOption(index)"
224
- />
225
- </div>
226
- <el-button
227
- type="dashed"
228
- size="small"
229
- icon="el-icon-plus"
230
- style="width: 100%; margin-top: 10px"
231
- @click="handleAddOption"
232
- >
233
- 添加选项
234
- </el-button>
235
- </div>
236
- </el-form-item>
237
-
238
- <el-form-item v-if="currentOptionConfig.sourceType === 'dict' && isPreview" label="预览">
239
- <div class="preview-box">
240
- <el-tag v-for="(item, index) in previewOptions" :key="index" style="margin: 5px">
241
- {{ item.value }} ({{ item.key }})
242
- </el-tag>
243
- <el-empty
244
- v-if="!previewOptions || previewOptions.length === 0"
245
- description="暂无数据"
246
- :image-size="60"
247
- />
248
- </div>
249
- </el-form-item>
250
- </el-form>
251
- <div class="dialog-footer">
252
- <slot name="footer">
253
- <el-button @click="optionsDialogVisible = false">取消</el-button>
254
- <el-button type="primary" @click="handleSaveOptions">确定</el-button>
255
- </slot>
256
- </div>
257
- </el-dialog>
258
-
259
- <el-dialog
260
- title="从预设添加条件"
261
- :visible.sync="customsDialogVisible"
262
- width="600px"
263
- append-to-body
264
- >
265
- <el-table :data="availableCustoms" border stripe style="width: 100%">
266
- <el-table-column label="字段名称" prop="name" align="center" />
267
- <el-table-column label="字段值" prop="key" align="center" />
268
- <el-table-column label="数据类型" width="120" align="center">
269
- <template slot-scope="scope">
270
- <el-tag v-if="scope.row.keyType === 1" type="info">字符串</el-tag>
271
- <el-tag v-else-if="scope.row.keyType === 2" type="warning">数字</el-tag>
272
- <el-tag v-else-if="scope.row.keyType === 3" type="success">枚举</el-tag>
273
- <el-tag v-else-if="scope.row.keyType === 4" type="primary">日期</el-tag>
274
- </template>
275
- </el-table-column>
276
- <el-table-column label="操作" width="100" align="center">
277
- <template slot-scope="scope">
278
- <el-button type="text" size="small" @click="handleSelectCustom(scope.row)">
279
- 添加
280
- </el-button>
281
- </template>
282
- </el-table-column>
283
- </el-table>
284
- <div slot="footer" style="text-align: right">
285
- <el-button @click="customsDialogVisible = false">取消</el-button>
286
- </div>
287
- </el-dialog>
288
- </el-dialog>
289
- </template>
290
-
291
- <script>
292
- import Sortable from "sortablejs";
293
-
294
- // interface OptionItem {
295
- // key: string;
296
- // value: string;
297
- // }
298
-
299
- // interface OptionSource {
300
- // sourceType: "manual" | "dict" | "api";
301
- // dictKey?: string;
302
- // apiUrl?: string;
303
- // valueField?: string;
304
- // labelField?: string;
305
- // options?: OptionItem[];
306
- // }
307
-
308
- // interface TableSearchItem {
309
- // label: string;
310
- // value: string;
311
- // inputType: "text" | "number" | "select";
312
- // children?: OptionItem[];
313
- // optionSource?: OptionSource;
314
- // }
315
-
316
- // interface DictItem {
317
- // key: string;
318
- // label: string;
319
- // }
320
-
321
- // interface WmsDictItem {
322
- // desc?: string;
323
- // enums?: Array<{ key: string; value: string }>;
324
- // }
325
-
326
- // interface WmsData {
327
- // SET_enumsSelect?: Record<string, WmsDictItem>;
328
- // }
329
-
330
- // interface CurrentOptionConfig {
331
- // sourceType: "manual" | "dict" | "api";
332
- // dictKey: string;
333
- // apiUrl: string;
334
- // valueField: string;
335
- // labelField: string;
336
- // options: OptionItem[];
337
- // }
338
-
339
- export default {
340
- name: "SearchConfigDialog",
341
- props: {
342
- visible: {
343
- type: Boolean,
344
- default: false,
345
- },
346
- formSearchData: {
347
- type: Object,
348
- default: () => {},
349
- },
350
- formSearch: {
351
- type: Object,
352
- default: () => {},
353
- },
354
- tableSearch: {
355
- type: Array,
356
- default: () => [],
357
- },
358
- // interface ICustoms {
359
- // key: string;//键名
360
- // name: string; //显示的名称
361
- // keyType: number; //数据类型 1字符串 2数字 3枚举 4日期
362
- // }
363
- //后端返回的可选的查询入参
364
- customs: {
365
- type: Array,
366
- default: () => [],
367
- },
368
- dragable: {
369
- type: Boolean,
370
- default: false,
371
- },
372
- isPreview: {
373
- type: Boolean,
374
- default: false,
375
- },
376
- },
377
- data() {
378
- return {
379
- dialogVisible: false,
380
- configList: [],
381
- optionsDialogVisible: false,
382
- customsDialogVisible: false,
383
- currentEditIndex: -1,
384
- currentOptionConfig: {
385
- sourceType: "manual",
386
- dictKey: "",
387
- apiUrl: "",
388
- method: "get",
389
- valueField: "id",
390
- labelField: "name",
391
- options: [],
392
- },
393
- previewOptions: [],
394
- allDictList: [],
395
- allDictListBackup: [],
396
- sortable: null,
397
- currentConfig: {}, // 配置选项
398
- };
399
- },
400
- computed: {
401
- availableCustoms() {
402
- const selectedKeys = this.configList.map(item => item.value);
403
- return this.customs.filter(custom => !selectedKeys.includes(custom.key));
404
- },
405
- },
406
- created() {
407
- this.loadAllDictList();
408
- // 重置数据
409
- this.setArrVModelReset();
410
- },
411
- watch: {
412
- visible: {
413
- handler(newVal) {
414
- this.dialogVisible = newVal;
415
- if (newVal) {
416
- this.configList = JSON.parse(JSON.stringify(this.tableSearch));
417
- this.$nextTick(() => {
418
- this.initSortable();
419
- });
420
- }
421
- },
422
- immediate: true,
423
- },
424
- dialogVisible(newVal) {
425
- this.$emit("update:visible", newVal);
426
- if (!newVal) {
427
- this.destroySortable();
428
- }
429
- },
430
- },
431
- methods: {
432
- initSortable() {
433
- if (this.sortable) {
434
- this.sortable.destroy();
435
- }
436
-
437
- const table = this.$refs.configTable;
438
- if (!table) return;
439
-
440
- const tbody = table.$el.querySelector(".el-table__body-wrapper tbody");
441
- if (!tbody) return;
442
-
443
- this.sortable = Sortable.create(tbody, {
444
- animation: 150,
445
- handle: ".sort-handle",
446
- ghostClass: "sortable-ghost",
447
- dragClass: "sortable-drag",
448
- onEnd: ({ newIndex, oldIndex }) => {
449
- if (newIndex !== oldIndex) {
450
- const movedItem = this.configList[oldIndex];
451
- this.configList.splice(oldIndex, 1);
452
- this.configList.splice(newIndex, 0, movedItem);
453
- }
454
- },
455
- });
456
- },
457
- destroySortable() {
458
- if (this.sortable) {
459
- this.sortable.destroy();
460
- this.sortable = null;
461
- }
462
- },
463
- handleClose() {
464
- this.dialogVisible = false;
465
- },
466
- async handleSave() {
467
- for (const item of this.configList) {
468
- if (item.inputType === "select" && item.optionSource) {
469
- await this.loadItemOptionsForSave(item);
470
- // 如果是“包含于”则,下拉框多选
471
- if (item.compare === "in") {
472
- item.props.multiple = true;
473
- } else {
474
- delete item.props.multiple;
475
- }
476
- }
477
- }
478
- this.$emit("save", this.configList);
479
- this.dialogVisible = false;
480
- console.log(`\x1b[36m\x1b[4mol插件-动态搜索框配置数据`, this.configList);
481
- },
482
- async loadItemOptionsForSave(item) {
483
- if (!item.optionSource) return;
484
-
485
- const { sourceType } = item.optionSource;
486
-
487
- if (sourceType === "dict") {
488
- await this.loadDictOptionsForSave(item);
489
- }
490
- // else if (sourceType === "api") {
491
- // await this.loadApiOptionsForSave(item);
492
- // }
493
- },
494
- async loadDictOptionsForSave(item) {
495
- try {
496
- const dictKey = item.optionSource.dictKey;
497
- if (!dictKey) return;
498
-
499
- const dictData = await this.getDictData(dictKey);
500
- if (dictData && Array.isArray(dictData)) {
501
- item.children = dictData.map(d => ({
502
- key: d.key,
503
- value: d.value,
504
- }));
505
- }
506
- } catch (error) {
507
- console.error("加载字典数据失败:", error);
508
- }
509
- },
510
- // async loadApiOptionsForSave(item) {
511
- // try {
512
- // const apiUrl = item.optionSource.apiUrl;
513
- // const method = item.optionSource.method || "get";
514
- // if (!apiUrl) return;
515
-
516
- // let response;
517
- // if (method === "post") {
518
- // response = await this.$http.post(apiUrl);
519
- // } else {
520
- // response = await this.$http.get(apiUrl);
521
- // }
522
-
523
- // if (response.data && Array.isArray(response.data)) {
524
- // const { valueField, labelField } = item.optionSource;
525
- // item.children = response.data.map(d => ({
526
- // key: d[valueField],
527
- // value: d[labelField],
528
- // }));
529
- // }
530
- // } catch (error) {
531
- // console.error("加载接口数据失败:", error);
532
- // }
533
- // },
534
-
535
- handleDelete(index) {
536
- this.$confirm("确定要删除该条件吗?", "提示", {
537
- confirmButtonText: "确定",
538
- cancelButtonText: "取消",
539
- type: "warning",
540
- }).then(() => {
541
- this.configList.splice(index, 1);
542
- });
543
- },
544
- handleTypeChange(row) {
545
- if (row.inputType === "select" && !row.children) {
546
- row.children = [];
547
- } else if (row.inputType === "picker") {
548
- if (!row.props) {
549
- row.props = {};
550
- }
551
- this.updateDatePickerProps(row);
552
- } else {
553
- row.dateType = "";
554
- }
555
- },
556
- handleDateTypeChange(row) {
557
- if (!row.props) {
558
- row.props = {};
559
- }
560
- this.updateDatePickerProps(row);
561
-
562
- const rangeTypes = ["daterange", "datetimerange", "monthrange"];
563
- if (rangeTypes.includes(row.dateType)) {
564
- row.compare = "range";
565
- } else {
566
- row.compare = "eq";
567
- }
568
- },
569
- updateDatePickerProps(row) {
570
- const dateType = row.dateType || "date";
571
- const props = row.props || {};
572
-
573
- switch (dateType) {
574
- case "date":
575
- props.type = "date";
576
- props.placeholder = "选择日期";
577
- props.valueFormat = "yyyy-MM-dd";
578
- props.format = "yyyy/MM/dd";
579
- break;
580
- case "datetime":
581
- props.type = "datetime";
582
- props.placeholder = "选择日期时间";
583
- props.valueFormat = "yyyy-MM-dd HH:mm:ss";
584
- props.format = "yyyy/MM/dd HH:mm:ss";
585
- break;
586
- case "daterange":
587
- props.type = "daterange";
588
- props.startPlaceholder = "开始日期";
589
- props.endPlaceholder = "结束日期";
590
- props.placeholder = "选择日期范围";
591
- props.valueFormat = "yyyy-MM-dd";
592
- props.format = "yyyy/MM/dd";
593
- break;
594
- case "datetimerange":
595
- props.type = "datetimerange";
596
- props.startPlaceholder = "开始时间";
597
- props.endPlaceholder = "结束时间";
598
- props.placeholder = "选择时间范围";
599
- props.valueFormat = "yyyy-MM-dd HH:mm:ss";
600
- props.format = "yyyy/MM/dd HH:mm:ss";
601
- props.defaultTime = ["00:00:00", "23:59:59"];
602
- break;
603
- case "month":
604
- props.type = "month";
605
- props.placeholder = "选择月份";
606
- props.valueFormat = "yyyy-MM";
607
- props.format = "yyyy年MM月";
608
- break;
609
- case "monthrange":
610
- props.type = "monthrange";
611
- props.startPlaceholder = "开始月份";
612
- props.endPlaceholder = "结束月份";
613
- props.placeholder = "选择月份范围";
614
- props.valueFormat = "yyyy-MM";
615
- props.format = "yyyy年MM月";
616
- break;
617
- case "year":
618
- props.type = "year";
619
- props.placeholder = "选择年份";
620
- props.valueFormat = "yyyy";
621
- props.format = "yyyy年";
622
- break;
623
- default:
624
- props.type = "date";
625
- props.placeholder = "选择日期";
626
- props.valueFormat = "yyyy-MM-dd";
627
- props.format = "yyyy/MM/dd";
628
- }
629
-
630
- row.props = props;
631
- },
632
- handleConfigOptions(index) {
633
- this.currentEditIndex = index;
634
- const currentConfig = this.configList[index];
635
- this.currentConfig = JSON.parse(JSON.stringify(currentConfig));
636
-
637
- const optionSource = currentConfig.optionSource || {};
638
- this.currentOptionConfig = {
639
- sourceType: optionSource.sourceType || "manual",
640
- dictKey: optionSource.dictKey || "",
641
- apiUrl: optionSource.apiUrl || "",
642
- method: optionSource.method || "get",
643
- valueField: optionSource.valueField || "id",
644
- labelField: optionSource.labelField || "name",
645
- options: [],
646
- };
647
-
648
- if (this.currentOptionConfig.sourceType === "manual") {
649
- this.currentOptionConfig.options = JSON.parse(JSON.stringify(currentConfig.children || []));
650
- }
651
-
652
- this.optionsDialogVisible = true;
653
-
654
- this.loadPreviewOptions();
655
- },
656
- handleAddOption() {
657
- this.currentOptionConfig.options.push({
658
- key: "",
659
- value: "",
660
- });
661
- },
662
- handleDeleteOption(index) {
663
- this.currentOptionConfig.options.splice(index, 1);
664
- },
665
- async loadApiOptions(item) {
666
- try {
667
- const apiUrl = item.optionSource.apiUrl;
668
- const method = item.optionSource.method || "get";
669
- if (!apiUrl) return;
670
-
671
- let response;
672
- if (method === "post") {
673
- response = await this.post({ url: apiUrl });
674
- } else {
675
- response = await this.get({ url: apiUrl });
676
- }
677
- if (response.code !== 200) return;
678
- if (response.result && Array.isArray(response.result)) {
679
- const { valueField, labelField } = item.optionSource;
680
- const children = response.result.map(d => ({
681
- key: d[valueField],
682
- value: d[labelField],
683
- }));
684
- return children;
685
- }
686
- } catch (error) {
687
- console.error("加载接口数据失败:", error);
688
- return [];
689
- }
690
- },
691
- needSetChildren(oldConfig, newConfig) {
692
- const { inputType, optionSource } = oldConfig;
693
- if (!optionSource) return false;
694
- const { sourceType, apiUrl, method, valueField, labelField } = optionSource;
695
- if (inputType !== "select" || sourceType !== "api") return false;
696
- const {
697
- sourceType: newSourceType,
698
- apiUrl: newApiUrl,
699
- method: newMethod,
700
- valueField: newValueField,
701
- labelField: newLabelField,
702
- } = newConfig;
703
- if (
704
- sourceType === newSourceType &&
705
- apiUrl === newApiUrl &&
706
- method === newMethod &&
707
- valueField === newValueField &&
708
- labelField === newLabelField
709
- )
710
- return false;
711
- return true;
712
- },
713
- async handleSaveOptions() {
714
- const config = this.configList[this.currentEditIndex];
715
- const configDefault = {
716
- sourceType: "",
717
- dictKey: "",
718
- apiUrl: "",
719
- valueField: "id",
720
- labelField: "name",
721
- options: [],
722
- };
723
- if (this.currentOptionConfig.sourceType === "manual") {
724
- const options = JSON.parse(JSON.stringify(this.currentOptionConfig.options));
725
- config.children = options;
726
- config.optionSource = { ...configDefault, sourceType: "manual", options };
727
- } else if (this.currentOptionConfig.sourceType === "dict") {
728
- config.optionSource = {
729
- ...configDefault,
730
- sourceType: "dict",
731
- dictKey: this.currentOptionConfig.dictKey,
732
- };
733
- config.children = [];
734
- } else if (this.currentOptionConfig.sourceType === "api") {
735
- config.optionSource = {
736
- ...configDefault,
737
- sourceType: "api",
738
- apiUrl: this.currentOptionConfig.apiUrl,
739
- method: this.currentOptionConfig.method,
740
- valueField: this.currentOptionConfig.valueField,
741
- labelField: this.currentOptionConfig.labelField,
742
- };
743
- // 接口请求
744
- // 判断是否需要走 api接口获取
745
- let children = [];
746
- const bool = this.needSetChildren(this.currentConfig, config.optionSource);
747
- if (bool) children = await this.loadApiOptions(config);
748
- else config.children = children || [];
749
- }
750
- this.optionsDialogVisible = false;
751
- },
752
- tableRowClassName({ row, rowIndex }) {
753
- return `row-${rowIndex}`;
754
- },
755
- async loadPreviewOptions() {
756
- this.previewOptions = [];
757
-
758
- if (this.currentOptionConfig.sourceType === "dict") {
759
- await this.loadDictOptions();
760
- }
761
- },
762
- async loadDictOptions() {
763
- try {
764
- const dictKey = this.currentOptionConfig.dictKey;
765
- if (!dictKey) return;
766
-
767
- const dictData = await this.getDictData(dictKey);
768
- if (dictData && Array.isArray(dictData)) {
769
- this.previewOptions = dictData.map(item => ({
770
- key: item.key,
771
- value: item.value,
772
- }));
773
- }
774
- } catch (error) {
775
- console.error("加载字典数据失败:", error);
776
- this.$message.error("加载字典数据失败");
777
- }
778
- },
779
- getDictData(dictKey) {
780
- return new Promise(resolve => {
781
- try {
782
- const wmsStr = localStorage.getItem("wms") || "{}";
783
- const wmsData = JSON.parse(wmsStr);
784
- const dictData = wmsData.SET_enumsSelect || {};
785
- const dictItem = dictData[dictKey];
786
- const result = [];
787
-
788
- if (dictItem && dictItem.enums && Array.isArray(dictItem.enums)) {
789
- dictItem.enums.forEach(item => {
790
- result.push({
791
- key: item.key,
792
- value: item.value,
793
- });
794
- });
795
- }
796
-
797
- resolve(result);
798
- } catch (error) {
799
- console.error("获取字典数据失败:", error);
800
- resolve([]);
801
- }
802
- });
803
- },
804
- async loadAllDictList() {
805
- try {
806
- const wmsStr = localStorage.getItem("wms") || "{}";
807
- const wmsData = JSON.parse(wmsStr);
808
- const dictData = wmsData.SET_enumsSelect || {};
809
-
810
- const dictList = [];
811
- Object.keys(dictData).forEach(key => {
812
- const dictItem = dictData[key];
813
- if (dictItem && key) {
814
- dictList.push({
815
- key: String(key),
816
- label: dictItem.desc || key,
817
- });
818
- }
819
- });
820
-
821
- this.allDictList = dictList;
822
- this.allDictListBackup = dictList;
823
- } catch (error) {
824
- console.error("加载字典列表失败:", error);
825
- this.allDictList = [];
826
- this.allDictListBackup = [];
827
- }
828
- },
829
- filterDict(query) {
830
- if (!query) {
831
- this.allDictList = this.allDictListBackup || [];
832
- return;
833
- }
834
- const filteredList = this.allDictListBackup.filter(item => {
835
- return (
836
- item.key.toLowerCase().includes(query.toLowerCase()) ||
837
- item.label.toLowerCase().includes(query.toLowerCase())
838
- );
839
- });
840
- this.allDictList = filteredList;
841
- },
842
- handleDictKeyChange(dictKey) {
843
- this.allDictList = this.allDictListBackup || [];
844
- if (dictKey) {
845
- this.loadPreviewOptions();
846
- }
847
- },
848
- handleSelectCustom(custom) {
849
- const inputTypeMap = {
850
- 1: "text",
851
- 2: "number",
852
- 3: "select",
853
- 4: "picker",
854
- };
855
-
856
- const compareTypeMap = {
857
- 1: "contains",
858
- 2: "eq",
859
- 3: "eq",
860
- 4: "eq",
861
- };
862
-
863
- const newItem = {
864
- label: custom.name,
865
- value: custom.key,
866
- inputType: inputTypeMap[custom.keyType] || "text",
867
- compare: compareTypeMap[custom.keyType] || "eq",
868
- children: [],
869
- props: {},
870
- };
871
-
872
- if (custom.keyType === 4) {
873
- newItem.dateType = "date";
874
- newItem.props = {
875
- type: "date",
876
- placeholder: "选择日期",
877
- valueFormat: "yyyy-MM-dd",
878
- format: "yyyy/MM/dd",
879
- };
880
- } else if (custom.keyType === 3) {
881
- newItem.optionSource = {
882
- sourceType: "dict",
883
- dictKey: custom.enumName,
884
- };
885
- }
886
-
887
- this.configList.push(newItem);
888
- this.customsDialogVisible = false;
889
- },
890
- // 处理数组和非数组的双向绑定值, 例如:下拉框和日期选择器切换成多选下拉框时间范围时候 双向绑定的值的类型要改变。this.formSearch是实际双向绑定的值
891
- setArrVModelReset() {
892
- this.tableSearch.forEach(item => {
893
- const { value: key, inputType } = item;
894
- if (!Object.keys(this.formSearch).includes(key)) return;
895
- if (!(inputType === "select" || inputType === "picker")) return; //只有下拉框和日期选择器会有 双向绑定数组
896
- delete this.formSearchData.value[key];
897
- delete this.formSearch[key];
898
- });
899
- },
900
- },
901
- };
902
- </script>
903
-
904
- <style scoped>
905
- .search-config-container {
906
- padding-bottom: 10px;
907
- }
908
-
909
- .config-header {
910
- display: flex;
911
- justify-content: space-between;
912
- align-items: center;
913
- margin-bottom: 10px;
914
- }
915
-
916
- .option-item {
917
- display: flex;
918
- align-items: center;
919
- margin-bottom: 10px;
920
- }
921
-
922
- .gray-text {
923
- color: #909399;
924
- font-size: 12px;
925
- }
926
-
927
- .sort-handle {
928
- color: #909399;
929
- transition: color 0.3s;
930
- }
931
-
932
- .sort-handle:hover {
933
- color: #409eff;
934
- }
935
-
936
- .sortable-ghost {
937
- opacity: 0.4;
938
- background-color: #f5f7fa;
939
- }
940
-
941
- .sortable-drag {
942
- opacity: 1;
943
- background-color: #fff;
944
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
945
- }
946
-
947
- .dialog-footer {
948
- display: flex;
949
- align-items: center;
950
- justify-content: center;
951
- }
952
-
953
- .options-config {
954
- max-height: 400px;
955
- overflow-y: auto;
956
- }
957
- </style>