ol-base-components 3.4.5 → 3.4.7

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,928 +0,0 @@
1
- <template>
2
- <div class="formSearch formSearchArrowUp">
3
- <div
4
- v-if="formSearchData.tableSearch && formSearchData.tableSearch.length >= 0"
5
- class="table-header"
6
- >
7
- <el-form
8
- ref="formSearch"
9
- size="small"
10
- :rules="formSearchData.rules"
11
- :model="formSearch"
12
- :inline="true"
13
- label-position="right"
14
- v-bind="{
15
- ...(formSearchData.options && formSearchData.options.formProps),
16
- }"
17
- :key="key"
18
- >
19
- <!-- 'label-width': '100px', -->
20
- <div
21
- class="transitionGroup"
22
- :class="[formSearchData.expendShow ? 'formSearchBtnArrowDowns' : 'formSearchBtnArrowUps']"
23
- >
24
- <el-form-item
25
- v-for="item in findTableSearch"
26
- v-show="!item.show"
27
- :key="item.value"
28
- class="table-header-item"
29
- :label="item.label"
30
- :prop="item.value"
31
- v-bind="item.labelProps || {}"
32
- :class="{
33
- picker: item.props && item.props.type === 'datetimerange',
34
- date: item.props && item.props.type === 'date',
35
- }"
36
- >
37
- <!-- <template v-if="item.inputType === 'treeSelect'">
38
- <slot name="treeSlot"></slot>
39
- </template> -->
40
- <Tree-select
41
- v-if="item.inputType === 'treeSelect'"
42
- ref="TreeSelectref"
43
- v-model="formSearch[item.value]"
44
- v-bind="item.props || {}"
45
- :options="item.children"
46
- @getValue="item.change && item.change(formSearch[item.value])"
47
- />
48
-
49
- <el-select
50
- v-else-if="item.inputType === 'select'"
51
- v-model="formSearch[item.value]"
52
- v-el-select-all="item.loadmores"
53
- :clearable="item.clearable === undefined || item.clearable"
54
- v-bind="item.props || {}"
55
- :placeholder="`请选择${item.placeholder || item.label}`"
56
- :popper-append-to-body="false"
57
- @change="item.change && item.change(formSearch[item.value])"
58
- @keyup.enter.native="handleSearch('formSearch')"
59
- >
60
- <el-option
61
- v-for="option in item.children"
62
- :key="option.key"
63
- :label="option.value"
64
- :value="option.key"
65
- />
66
- </el-select>
67
- <!-- v-bind="item.props || {}" -->
68
- <el-select
69
- v-else-if="item.inputType === 'selectTEMP'"
70
- v-model="formSearch[item.value]"
71
- v-el-select-all="item.loadmores"
72
- v-bind="{ clearable: true, ...(item.props || {}) }"
73
- :placeholder="`请选择${item.placeholder || item.label}`"
74
- :popper-append-to-body="false"
75
- @change="item.change && item.change(formSearch[item.value])"
76
- @keyup.enter.native="handleSearch('formSearch')"
77
- >
78
- <el-option
79
- v-for="option in item.children"
80
- :key="option.key"
81
- :label="option.value"
82
- :value="option.key"
83
- />
84
- </el-select>
85
- <el-select
86
- v-else-if="item.inputType === 'selectRemoteMethod'"
87
- v-model="formSearch[item.value]"
88
- v-el-select-all="item.loadmores"
89
- filterable
90
- remote
91
- clearable
92
- reserve-keyword
93
- :placeholder="`请输入至少3位关键字`"
94
- :remote-method="item.remoteMethod"
95
- :loading="item.loading"
96
- >
97
- <el-option
98
- v-for="option in item.children"
99
- :key="option.key"
100
- :label="option.value"
101
- :value="option.key"
102
- />
103
- </el-select>
104
- <el-date-picker
105
- v-else-if="item.inputType === 'picker'"
106
- v-model="formSearch[item.value]"
107
- clearable
108
- style="width: 100%"
109
- :placeholder="item.props.placeholder || '选择日期'"
110
- v-bind="item.props || { type: 'date' }"
111
- :default-time="item.props.type == 'datetimerange' ? ['00:00:00', '23:59:59'] : ''"
112
- />
113
- <ol-number-range
114
- v-else-if="item.inputType === 'numberRange'"
115
- v-model="formSearch[item.value]"
116
- v-bind="item.props || {}"
117
- v-on="{
118
- ...item.listeners,
119
- change: val =>
120
- item.listeners && item.listeners.change && item.listeners.change({ item, val }),
121
- }"
122
- ></ol-number-range>
123
- <el-input
124
- v-else
125
- v-model="formSearch[item.value]"
126
- clearable
127
- v-bind="item.props || {}"
128
- :type="item.inputType || 'text'"
129
- :placeholder="`请输入${item.placeholder || item.label}`"
130
- :maxlength="item.maxlength"
131
- :oninput="handleChangeInput(item)"
132
- :class="item.inputType == 'number' ? 'numrule' : ''"
133
- @keyup.enter.native="handleSearch('formSearch')"
134
- @keydown.native="keyInput(item, $event)"
135
- @paste.native="onPaste(item, $event)"
136
- />
137
- </el-form-item>
138
- </div>
139
- <el-form-item
140
- style="word-break: keep-all; white-space: nowrap; margin-left: 10px"
141
- class="fromBtn"
142
- :class="[formSearchData.expendShow ? 'formSearchBtnArrowDown' : 'formSearchBtnArrowUp']"
143
- >
144
- <el-button
145
- v-if="formSearchData.reset"
146
- size="small"
147
- type="primary"
148
- @click="handleSearch('formSearch')"
149
- >查询
150
- </el-button>
151
- <el-button
152
- v-if="formSearchData.reset"
153
- plain
154
- size="small"
155
- @click="handleReset('formSearch')"
156
- >重置</el-button
157
- >
158
- <el-button
159
- v-if="formSearchData.expendShow"
160
- plain
161
- size="small"
162
- :icon="expend ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
163
- @click="handleExpend('formSearch')"
164
- >
165
- {{ expend ? "收起" : "展开" }}</el-button
166
- >
167
- <el-button
168
- v-if="isCustomSearch"
169
- plain
170
- size="small"
171
- icon="el-icon-setting"
172
- @click="handleOpenConfig"
173
- >
174
- 配置
175
- </el-button>
176
- </el-form-item>
177
- </el-form>
178
- </div>
179
- <search-config-dialog
180
- v-if="configDialogVisible"
181
- :visible.sync="configDialogVisible"
182
- :table-search="formSearchData.tableSearch"
183
- :formSearchData="formSearchData"
184
- :formSearch="formSearch"
185
- :customs="formSearchData.customs"
186
- @save="handleSaveConfig"
187
- v-bind="$attrs"
188
- />
189
- </div>
190
- </template>
191
-
192
- <script>
193
- import { getData } from "../../index.js";
194
- import { getEnum } from "../../../utils/getEnum.js";
195
- import OlNumberRange from "../../numberRange/index.js";
196
- import SearchConfigDialog from "./components/SearchConfigDialog.vue";
197
-
198
- export default {
199
- name: "search",
200
- components: {
201
- OlNumberRange,
202
- SearchConfigDialog,
203
- },
204
- directives: {
205
- "el-select-loadmore": {
206
- bind(el, binding) {
207
- // 获取element-ui定义好的scroll盒子
208
- const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
209
- SELECTWRAP_DOM.addEventListener("scroll", function () {
210
- /**
211
- * scrollHeight 获取元素内容高度(只读)
212
- * scrollTop 获取或者设置元素的偏移值,常用于, 计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0.
213
- * clientHeight 读取元素的可见高度(只读)
214
- * 如果元素滚动到底, 下面等式返回true, 没有则返回false:
215
- * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
216
- */
217
- const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
218
- if (condition > 0 && condition < 2) {
219
- binding.value();
220
- }
221
- });
222
- },
223
- },
224
- "el-select-all": {
225
- bind(el, binding, vnode) {
226
- // console.log(binding.value)
227
- const _that = vnode.context; // 当前vue对象
228
- const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
229
- SELECTWRAP_DOM.addEventListener("scroll", function () {
230
- // console.log(SELECTWRAP_DOM.scrollHeight) // 文档内容的实际高度
231
- // console.log(SELECTWRAP_DOM.scrollTop) // 滚动条滚动高度
232
- // console.log(SELECTWRAP_DOM.clientHeight) // 可视窗口高度
233
- // CONDITION //滚动条到底了
234
- const CONDITION =
235
- SELECTWRAP_DOM.scrollHeight - SELECTWRAP_DOM.scrollTop - 2 <=
236
- SELECTWRAP_DOM.clientHeight;
237
- if (CONDITION) {
238
- binding.value.SELECTWRAP_DOM_index += 10;
239
- binding.value.fn();
240
- }
241
- });
242
- },
243
- unbind(el, binding, vnode) {
244
- // 解除事件监听
245
- const _that = vnode.context; // 当前vue对象
246
- const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
247
- if (SELECTWRAP_DOM) {
248
- SELECTWRAP_DOM.removeEventListener("scroll", function () {
249
- binding.value.SELECTWRAP_DOM_index = 0;
250
- });
251
- }
252
- },
253
- },
254
- },
255
- props: {
256
- url: {
257
- type: String,
258
- default: "",
259
- },
260
- formSearchData: {
261
- type: Object,
262
- default: () => {
263
- return {
264
- buttonData: [],
265
- rules: {},
266
- value: {},
267
- tableSearchSlice: 4, // 默认为展开4当出现特色情况可以自行设置
268
- // 循环的各种组件
269
- tableSearch: [],
270
- // 表格框架各种样式
271
- options: {},
272
- reset: false, // 是否要重置
273
- customs: [], //根据customs确定是动态还是swagger配置
274
- };
275
- },
276
- },
277
- // btnlist: Array,
278
- tableSearchSlice: {
279
- type: Number,
280
- default: 4,
281
- },
282
- //获取swagger后的钩子,返回swagger结构数据。用于处理swagger数据
283
- onSwagger: {
284
- type: Function,
285
- default: null,
286
- },
287
- isCustomSearch: {
288
- type: Boolean,
289
- default: false,
290
- },
291
- // 请求方式 post get
292
- method: {
293
- type: String,
294
- },
295
- },
296
- data() {
297
- return {
298
- findTableSearch: {},
299
- expend: !this.formSearchData.expendShow,
300
- formSearch: {
301
- ...this.formSearchData.value,
302
- },
303
- configDialogVisible: false,
304
- // 自定义指令
305
- loadmores: {
306
- fn: this.loadmoreGX,
307
- SELECTWRAP_DOM_index: 0,
308
- flage: null,
309
- },
310
- tempBoxData: [],
311
- optionBox: [],
312
- key: 0,
313
- };
314
- },
315
- async created() {
316
- this.init();
317
- },
318
- mounted() {
319
- this.$nextTick(() => {
320
- this.loadOptionSources();
321
- });
322
- },
323
- computed: {
324
- // 优先级:props > 全局配置 > 默认值
325
- finalMethod() {
326
- return this.method || (this.$olBaseConfig && this.$olBaseConfig.method) || "get";
327
- },
328
- },
329
- watch: {
330
- "formSearchData.value": {
331
- handler: function (newVal, OldVal) {
332
- if (newVal) {
333
- return (this.formSearch = {
334
- ...newVal,
335
- });
336
- // return (this.findTableSearch = { ...newVal });
337
- }
338
- },
339
- deep: true,
340
- },
341
- },
342
- methods: {
343
- async init() {
344
- if (!this.isCustomSearch && this.url) {
345
- const swaggerData = await getData();
346
- let swaggersearchColumns = swaggerData.paths[this.url][this.finalMethod].parameters || [];
347
- if (typeof this.onSwagger === "function") {
348
- try {
349
- const res = await this.onSwagger({ columns: swaggersearchColumns });
350
- if (res) swaggersearchColumns = res;
351
- } catch (err) {}
352
- }
353
- swaggersearchColumns.forEach(item => {
354
- let tempItem = this.formSearchData.tableSearch.find(
355
- e => e.value.toLowerCase() === item.name.toLowerCase()
356
- );
357
- if (tempItem) {
358
- // 匹配到
359
- tempItem = { ...item, ...tempItem };
360
- } else if (item.description) {
361
- // 未匹配到
362
- const pushItem = {
363
- value: item.name,
364
- label: item.description,
365
- inputType: "text",
366
- props: {},
367
- };
368
- if (item.schema.enum && Array.isArray(item.schema.enum)) {
369
- //枚举值
370
- pushItem.inputType = "select";
371
- const ref = item.schema["$$ref"].split("/");
372
- const enumName = ref[ref.length - 1];
373
- const tempEnum = getEnum(enumName);
374
- pushItem.children = tempEnum.length
375
- ? tempEnum
376
- : item.schema.enum.map(e => ({
377
- key: e,
378
- value: e,
379
- }));
380
- } else if (item.schema.format === "date-time") {
381
- //日期
382
- pushItem.inputType = "picker";
383
- pushItem.props.valueFormat = "yyyy-MM-dd";
384
- pushItem.props.format = "yyyy/MM/dd";
385
- } else if (item.schema && item.schema.type === "string") {
386
- pushItem.inputType = "text";
387
- }
388
- this.formSearchData.tableSearch.push(pushItem);
389
- }
390
- });
391
-
392
- // 自动识别范围时间字段,以Begin和End结尾的字段,和"BeginTime", "EndTime",这样的时间范围字段
393
- const rangeTimeCloumns = await this.autoDetectRangeTimeFields(swaggersearchColumns);
394
- this.formSearchData.tableSearch = [...this.formSearchData.tableSearch, ...rangeTimeCloumns];
395
- }
396
-
397
- this.findTableSearch =
398
- this.formSearchData.tableSearch.length > this.tableSearchSlice
399
- ? this.formSearchData.tableSearch.slice(0, this.tableSearchSlice)
400
- : this.formSearchData.tableSearch;
401
- console.log(`\x1b[36m\x1b[4mol插件-搜索框渲染`, this.formSearchData.tableSearch);
402
- },
403
- // 统一的自动识别范围时间字段方法
404
- async autoDetectRangeTimeFields(swaggersearchColumns) {
405
- const tableSearch = [];
406
- // 1. 处理 BeginTime, EndTime 特殊情况
407
- const tableHasCreatedTime = this.formSearchData.tableSearch.some(
408
- e => e.value === "createdTime"
409
- );
410
- if (!tableHasCreatedTime) {
411
- const requiredNames = ["BeginTime", "EndTime"];
412
- const hseCreatedTime = requiredNames.every(name =>
413
- swaggersearchColumns.some(item => item.name === name)
414
- );
415
- if (hseCreatedTime) {
416
- tableSearch.push({
417
- label: "创建时间",
418
- value: "createdTime",
419
- inputType: "picker",
420
- props: {
421
- type: "datetimerange",
422
- startPlaceholder: "开始时间",
423
- endPlaceholder: "结束时间",
424
- placeholder: "选择时间范围",
425
- valueFormat: "yyyy-MM-dd HH:mm:ss",
426
- format: "yyyy/MM/dd HH:mm:ss",
427
- },
428
- originalFields: {
429
- begin: "BeginTime",
430
- end: "EndTime",
431
- },
432
- });
433
- }
434
- }
435
-
436
- // 2. 自动识别 xxxxBegin 和 xxxxEnd 格式的范围时间字段
437
- const beginFields = swaggersearchColumns.filter(item => item.name.endsWith("Begin"));
438
-
439
- const endFields = swaggersearchColumns.filter(item => item.name.endsWith("End"));
440
-
441
- // 找出匹配的 Begin 和 End 字段对
442
- const rangeTimePairs = [];
443
- beginFields.forEach(item => {
444
- const prefix = item.name.replace("Begin", "");
445
- const correspondingEndField = prefix + "End";
446
- const endTemp = endFields.find(e => e.name === correspondingEndField);
447
- if (endTemp) {
448
- rangeTimePairs.push({
449
- ...item,
450
- description: item.description || endTemp.description || "", //先用Begin的中文,没有就用End的
451
- beginField: item.name,
452
- endField: correspondingEndField,
453
- timeField: prefix + "Time",
454
- label: prefix,
455
- });
456
- }
457
- });
458
-
459
- // 使用 for...of 循环等待所有异步操作完成
460
- for (const pair of rangeTimePairs) {
461
- const { beginField, endField, timeField, description } = pair;
462
-
463
- // 检查是否已经存在该时间字段
464
- const timeFieldExists = this.formSearchData.tableSearch.some(
465
- item => item.value === timeField
466
- );
467
-
468
- if (!timeFieldExists) {
469
- // const labelCHN = await camelCaseToChinese(label); //内网项目无法使用
470
- const labelCHN = description;
471
-
472
- // 从 formSearchData.value 中移除原始字段
473
- this.removeOriginalFieldsFromValue([beginField, endField]);
474
-
475
- tableSearch.push({
476
- label: labelCHN,
477
- value: timeField,
478
- inputType: "picker",
479
- props: {
480
- type: "datetimerange",
481
- startPlaceholder: "开始时间",
482
- endPlaceholder: "结束时间",
483
- placeholder: `选择${labelCHN}范围`,
484
- valueFormat: "yyyy-MM-dd HH:mm:ss",
485
- format: "yyyy/MM/dd HH:mm:ss",
486
- },
487
- originalFields: {
488
- begin: beginField,
489
- end: endField,
490
- },
491
- });
492
- }
493
- }
494
- return tableSearch;
495
- },
496
- // 新增方法:从 formSearchData.value 中移除原始字段
497
- removeOriginalFieldsFromValue(removeKeys) {
498
- removeKeys.forEach(key => {
499
- const index = this.formSearchData.tableSearch.findIndex(item => item.value === key);
500
- if (index !== -1) {
501
- this.formSearchData.tableSearch.splice(index, 1);
502
- }
503
- });
504
- },
505
- // 树形下拉
506
- getValue(val) {
507
- this.$emit("getTreeSelectValue", val);
508
- },
509
- setFilterConditionsByFormSearch(formSearch) {
510
- const filterConditions = [];
511
- Object.keys(formSearch).forEach(key => {
512
- const tempItem = this.formSearchData.tableSearch.find(item => item.value === key);
513
- if (formSearch[key] !== undefined && formSearch[key] !== null && formSearch[key] !== "") {
514
- filterConditions.push({
515
- key: key,
516
- values: Array.isArray(formSearch[key]) ? formSearch[key] : [formSearch[key]], //必须包数组,后端会统一处理
517
- compare: tempItem && tempItem.compare ? tempItem.compare : "",
518
- });
519
- }
520
- });
521
- return filterConditions;
522
- },
523
- // 搜索查询按钮
524
- handleSearch(formName, item) {
525
- if (!this.isCustomSearch) {
526
- if (this.formSearch.createdTime) {
527
- this.formSearch.BeginTime = this.formSearch.createdTime[0];
528
- this.formSearch.EndTime = this.formSearch.createdTime[1];
529
- } else {
530
- this.formSearch.BeginTime = null;
531
- this.formSearch.EndTime = null;
532
- }
533
- // 有originalFields字段的就是范围时间,查询时候转回接口需要的字段
534
- Object.keys(this.formSearch).forEach(key => {
535
- const fieldConfig = this.formSearchData.tableSearch.find(item => item.value === key);
536
- if (fieldConfig && fieldConfig.originalFields) {
537
- const { begin, end } = fieldConfig.originalFields;
538
- if (this.formSearch[key] && Array.isArray(this.formSearch[key])) {
539
- this.formSearch[begin] = this.formSearch[key][0];
540
- this.formSearch[end] = this.formSearch[key][1];
541
- } else {
542
- this.formSearch[begin] = null;
543
- this.formSearch[end] = null;
544
- }
545
- }
546
- });
547
-
548
- const tempFormSearch = Object.assign({}, this.formSearch);
549
- if (this.formSearchData.rules) {
550
- return this.$refs[formName].validate(valid => {
551
- if (!valid) return false;
552
- this.$emit("handleSearch", tempFormSearch, item);
553
- });
554
- }
555
- this.$emit("handleSearch", tempFormSearch, item);
556
- console.log(`\x1b[36m\x1b[4mol插件-搜索框查询`, tempFormSearch);
557
- } else {
558
- // 转成接口需要的结构filterConditions
559
- const filterConditions = this.setFilterConditionsByFormSearch(this.formSearch) || [];
560
-
561
- // 动态模式
562
- this.$emit("handleSearch", this.formSearch, { filterConditions });
563
- console.log(`\x1b[36m\x1b[4mol插件-动态搜索框查询`, this.formSearch, { filterConditions });
564
- }
565
- },
566
- loadmore(obj) {
567
- this.$emit("loadmore", obj);
568
- },
569
- // 搜索重置按钮
570
- handleReset(formName) {
571
- this.$refs[formName].resetFields();
572
- if (this.formSearchData.reset) {
573
- for (const key in this.formSearch) {
574
- if (Object.prototype.toString.call(this.formSearch[key]) === "[object String]") {
575
- this.formSearch[key] = null;
576
- } else if (Object.prototype.toString.call(this.formSearch[key]) === "[object Array]") {
577
- this.formSearch[key] = [];
578
- } else if (Object.prototype.toString.call(this.formSearch[key]) === "[object Object]") {
579
- this.formSearch[key] = {};
580
- } else if (Object.prototype.toString.call(this.formSearch[key]) === "[object Boolean]") {
581
- this.formSearch[key] = false;
582
- } else {
583
- this.formSearch[key] = null;
584
- }
585
- }
586
- } else {
587
- this.formSearch = {
588
- ...this.formSearchData.value,
589
- };
590
- }
591
- this.$emit("handleReset", this.formSearch);
592
- if (this.formSearchData.reset) return false;
593
- this.handleSearch();
594
- },
595
- // 展开和收起
596
- handleExpend() {
597
- this.expend = !this.expend; // 展开和收起
598
- this.findTableSearch = this.expend
599
- ? this.formSearchData.tableSearch.slice(0, this.formSearchData.tableSearch.length)
600
- : this.formSearchData.tableSearch.slice(0, this.tableSearchSlice);
601
-
602
- this.$emit("btnHandleExpend", this.expend);
603
- },
604
- handleOpenConfig() {
605
- this.configDialogVisible = true;
606
- },
607
- handleSaveConfig(configList) {
608
- if (this.isCustomSearch) {
609
- this.key++; // 下拉框多选时候高度被撑开,改成单选时候高度无法重置。所以重写渲染。这里不管直接全都重写渲染
610
- }
611
- this.formSearchData.tableSearch = configList;
612
- this.findTableSearch =
613
- this.formSearchData.tableSearch.length > this.tableSearchSlice
614
- ? this.formSearchData.tableSearch.slice(0, this.tableSearchSlice)
615
- : this.formSearchData.tableSearch;
616
-
617
- this.$emit("onSave", configList);
618
- },
619
- async loadOptionSources() {
620
- for (const item of this.formSearchData.tableSearch) {
621
- if (item.inputType === "select" && item.optionSource) {
622
- await this.loadItemOptions(item);
623
- }
624
- }
625
- },
626
- async loadItemOptions(item) {
627
- if (!item.optionSource) return;
628
-
629
- const { sourceType } = item.optionSource;
630
-
631
- if (sourceType === "dict") {
632
- await this.loadDictOptions(item);
633
- } else if (sourceType === "api") {
634
- await this.loadApiOptions(item);
635
- }
636
- },
637
- async loadDictOptions(item) {
638
- try {
639
- const dictKey = item.optionSource.dictKey;
640
- if (!dictKey) return;
641
-
642
- const dictData = await this.getDictData(dictKey);
643
- if (dictData && Array.isArray(dictData)) {
644
- const children = dictData.map(d => ({
645
- key: d.key,
646
- value: d.value,
647
- }));
648
- this.$set(item, "children", children);
649
- }
650
- } catch (error) {
651
- console.error("加载字典数据失败:", error);
652
- }
653
- },
654
- async loadApiOptions(item) {
655
- try {
656
- const apiUrl = item.optionSource.apiUrl;
657
- const method = item.optionSource.method || "get";
658
- if (!apiUrl) return;
659
-
660
- let response;
661
- if (method === "post") {
662
- response = await this.post({ url: apiUrl });
663
- } else {
664
- response = await this.get({ url: apiUrl });
665
- }
666
- if (response.code !== 200) return;
667
- if (response.result && Array.isArray(response.result)) {
668
- const { valueField, labelField } = item.optionSource;
669
- const children = response.result.map(d => ({
670
- key: d[valueField],
671
- value: d[labelField],
672
- }));
673
- this.$set(item, "children", children);
674
- }
675
- } catch (error) {
676
- console.error("加载接口数据失败:", error);
677
- }
678
- },
679
- getDictData(dictKey) {
680
- return new Promise(resolve => {
681
- try {
682
- const wmsStr = localStorage.getItem("wms") || "{}";
683
- const wmsData = JSON.parse(wmsStr);
684
- const dictData = wmsData.SET_enumsSelect || {};
685
- const dictItem = dictData[dictKey];
686
- const result = [];
687
-
688
- if (dictItem && dictItem.enums && Array.isArray(dictItem.enums)) {
689
- dictItem.enums.forEach(item => {
690
- result.push({
691
- key: item.key,
692
- value: item.value,
693
- });
694
- });
695
- }
696
-
697
- resolve(result);
698
- } catch (error) {
699
- console.error("获取字典数据失败:", error);
700
- resolve([]);
701
- }
702
- });
703
- },
704
- // input为number校验
705
- handleChangeInput(item) {
706
- return item.inputType === "number"
707
- ? this.handleOnInput(this.formSearch[item.value], item.value, item.max)
708
- : null;
709
- },
710
- keyInput(item, e) {
711
- if (item.inputType === "number") {
712
- let key = e.key;
713
- if (key === "e" || key === "E" || key === "-" || key === "+" || key === ".") {
714
- e.returnValue = false;
715
- return false;
716
- }
717
- return true;
718
- }
719
- },
720
- // 输入框的粘贴事件
721
- onPaste(item, e) {
722
- if (item.inputType === "number") {
723
- const pastedText = e.clipboardData.getData("text");
724
- const nonNumericPattern = /[^\d]/g;
725
- if (nonNumericPattern.test(pastedText)) {
726
- e.preventDefault();
727
- }
728
- }
729
- },
730
- // input渲染长度校验
731
- handleOnInput(val, label, max) {
732
- if (val && Number(val) <= 0) {
733
- this.formSearch[label] = 0;
734
- }
735
- if (val && Number(val) > max) {
736
- this.formSearch[label] = max;
737
- }
738
- },
739
- },
740
- };
741
- </script>
742
-
743
- <style lang="scss" scoped>
744
- .formSearch {
745
- .el-form-item {
746
- // width: 21%;
747
- margin-right: 2px;
748
- margin-bottom: 5px;
749
-
750
- ::v-deep .el-form-item__label {
751
- width: 37% !important;
752
- padding: 0 5px 0 0;
753
- word-break: keep-all;
754
- white-space: nowrap;
755
- font-size: 13px;
756
- }
757
-
758
- ::v-deep .el-form-item__content {
759
- width: 63% !important;
760
- }
761
- }
762
-
763
- ::v-deep .el-select {
764
- width: 100% !important;
765
- }
766
-
767
- ::v-deep .picker {
768
- }
769
-
770
- .formSearchBtnArrowUp {
771
- // width: 12%;
772
- ::v-deep .el-form-item__content {
773
- width: 130px !important;
774
- }
775
- }
776
- }
777
-
778
- .formSearchArrowUp {
779
- // height: auto;
780
- // overflow: hidden;
781
-
782
- .el-form {
783
- position: relative;
784
- }
785
-
786
- .formSearchBtnArrowDown {
787
- position: absolute;
788
- top: 0px;
789
- width: 15%;
790
- left: 81.5%;
791
-
792
- ::v-deep .el-form-item__content {
793
- width: 100% !important;
794
-
795
- ::v-deep .el-button {
796
- // width: 30.3%;
797
- padding: 7px;
798
- margin-left: 0px;
799
- font-size: 13px;
800
- padding: 5px 10px;
801
- }
802
- }
803
- }
804
- }
805
-
806
- .table-header {
807
- padding-top: 10px;
808
- border-bottom: 1px #ccc solid;
809
- min-height: 49px;
810
-
811
- ::v-deep .table-header-item {
812
- }
813
-
814
- .table-header-item .el-form-item {
815
- width: 100%;
816
- display: flex;
817
- margin-bottom: 12px;
818
-
819
- .el-form-item__content,
820
- .el-select {
821
- width: 100%;
822
- }
823
- }
824
- }
825
-
826
- .transitionGroup {
827
- display: flex;
828
- flex-wrap: wrap;
829
-
830
- .el-form-item {
831
- width: calc(100% / 5);
832
- }
833
-
834
- // .picker {
835
- // width: 25%;
836
-
837
- // ::v-deep .el-form-item__label {
838
- // width: 27% !important;
839
- // padding: 0 5px 0 0;
840
- // word-break: break-all;
841
- // white-space: nowrap;
842
- // }
843
-
844
- // ::v-deep .el-form-item__content {
845
- // width: 73% !important;
846
- // height: 28px;
847
- // }
848
- // }
849
- }
850
-
851
- .formSearchBtnArrowDowns {
852
- .el-form-item {
853
- width: 20%;
854
- }
855
- }
856
-
857
- .formSearchBtnArrowUps {
858
- display: inline;
859
- }
860
-
861
- .list-enter-active,
862
- .list-leave-active {
863
- transition: all 1s;
864
- }
865
-
866
- .list-enter {
867
- opacity: 0;
868
- transform: translateX(-30px);
869
- }
870
-
871
- .list-leave-to {
872
- opacity: 0;
873
- transform: translateX(30px);
874
- }
875
-
876
- ::v-deep .el-select-dropdown__item.hover {
877
- background-color: #eff7ff !important;
878
- }
879
-
880
- ::v-deep .el-select-dropdown__item:hover {
881
- background-color: #eff7ff !important;
882
- }
883
-
884
- ::v-deep .el-input.is-disabled {
885
- ::v-deep .el-input__inner {
886
- background-color: #eceff8;
887
- border-color: #eceff8;
888
- }
889
- }
890
-
891
- ::v-deep .el-input--small {
892
- ::v-deep .el-input__inner {
893
- height: 28px;
894
- line-height: 28px;
895
- }
896
- }
897
-
898
- .fromBtn {
899
- ::v-deep .el-button {
900
- // padding: 7px;
901
- font-size: 12px;
902
- }
903
- }
904
-
905
- .btnbox {
906
- .upload-demo {
907
- display: -webkit-inline-box;
908
- margin-left: 10px;
909
- }
910
-
911
- padding: 10px;
912
- }
913
-
914
- //解决type=number的上下箭头
915
- ::v-deep .numrule input::-webkit-outer-spin-button,
916
- ::v-deep .numrule input::-webkit-inner-spin-button {
917
- -webkit-appearance: none !important;
918
- }
919
-
920
- ::v-deep .numrule input[type="number"] {
921
- -moz-appearance: textfield !important;
922
- }
923
-
924
- // 解决type=number输入中文后光标上移的问题
925
- ::v-deep .numrule .el-input__inner {
926
- line-height: 1px !important;
927
- }
928
- </style>