ol-base-components 3.2.1 → 3.2.5
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/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
// timer: [],
|
|
140
140
|
// range: [10, 200],
|
|
141
141
|
},
|
|
142
|
-
|
|
142
|
+
tableSearch1: [
|
|
143
143
|
// {
|
|
144
144
|
// label: "数字区间",
|
|
145
145
|
// value: "range",
|
|
@@ -277,6 +277,81 @@ export default {
|
|
|
277
277
|
// inputType: "text"
|
|
278
278
|
// }
|
|
279
279
|
],
|
|
280
|
+
tableSearch: [
|
|
281
|
+
{
|
|
282
|
+
label: "选项1",
|
|
283
|
+
value: "code1",
|
|
284
|
+
inputType: "text",
|
|
285
|
+
compare: "contains",
|
|
286
|
+
children: [],
|
|
287
|
+
props: {},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
label: "选项2",
|
|
291
|
+
value: "code2",
|
|
292
|
+
inputType: "number",
|
|
293
|
+
compare: "eq",
|
|
294
|
+
children: [],
|
|
295
|
+
props: {},
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
label: "选项3",
|
|
299
|
+
value: "code3",
|
|
300
|
+
inputType: "select",
|
|
301
|
+
compare: "eq",
|
|
302
|
+
children: [
|
|
303
|
+
{
|
|
304
|
+
key: 0,
|
|
305
|
+
value: "货位点",
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
key: 1,
|
|
309
|
+
value: "环线载货通道点",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: 2,
|
|
313
|
+
value: "其它载货通道点",
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
key: 3,
|
|
317
|
+
value: "提升机点",
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
key: 4,
|
|
321
|
+
value: "充电点",
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
key: 5,
|
|
325
|
+
value: "暂停位点",
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
key: 6,
|
|
329
|
+
value: "提升机等待位",
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: 7,
|
|
333
|
+
value: "入库口",
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
key: 8,
|
|
337
|
+
value: "出库口",
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
key: 9,
|
|
341
|
+
value: "地图外",
|
|
342
|
+
},
|
|
343
|
+
],
|
|
344
|
+
props: {},
|
|
345
|
+
optionSource: {
|
|
346
|
+
sourceType: "dict",
|
|
347
|
+
dictKey: "pointType",
|
|
348
|
+
apiUrl: "",
|
|
349
|
+
valueField: "id",
|
|
350
|
+
labelField: "name",
|
|
351
|
+
options: [],
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
],
|
|
280
355
|
customs: [
|
|
281
356
|
{
|
|
282
357
|
name: "选项1",
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
@onSave="onSave"
|
|
5
5
|
v-bind="$attrs"
|
|
6
6
|
v-on="$listeners"
|
|
7
|
+
:key="key"
|
|
7
8
|
/>
|
|
8
9
|
</template>
|
|
9
10
|
|
|
@@ -33,12 +34,13 @@ export default {
|
|
|
33
34
|
data() {
|
|
34
35
|
return {
|
|
35
36
|
currentPageItem: {},
|
|
37
|
+
key: 0,
|
|
36
38
|
};
|
|
37
39
|
},
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
mounted() {
|
|
39
42
|
this.init();
|
|
40
43
|
},
|
|
41
|
-
mounted() {},
|
|
42
44
|
methods: {
|
|
43
45
|
init() {
|
|
44
46
|
const handleMenu = (arr, _this) => {
|
|
@@ -68,6 +70,7 @@ export default {
|
|
|
68
70
|
if (res.code !== 200) return;
|
|
69
71
|
const configList = res.result.settingJson ? JSON.parse(res.result.settingJson) : [];
|
|
70
72
|
this.formSearchData.tableSearch = configList;
|
|
73
|
+
this.key++;
|
|
71
74
|
});
|
|
72
75
|
},
|
|
73
76
|
//保存
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
size="small"
|
|
60
60
|
placeholder="请选择类型"
|
|
61
61
|
@change="handleTypeChange(scope.row)"
|
|
62
|
-
disabled
|
|
62
|
+
:disabled="['number', 'picker'].includes(scope.row.inputType)"
|
|
63
63
|
>
|
|
64
64
|
<el-option label="文本输入" value="text" />
|
|
65
|
-
<el-option label="数字输入" value="number" />
|
|
65
|
+
<el-option label="数字输入" value="number" disabled />
|
|
66
66
|
<el-option label="下拉选择" value="select" />
|
|
67
|
-
<el-option label="日期选择" value="picker" />
|
|
67
|
+
<el-option label="日期选择" value="picker" disabled />
|
|
68
68
|
</el-select>
|
|
69
69
|
</template>
|
|
70
70
|
</el-table-column>
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
</el-select>
|
|
188
188
|
</el-form-item>
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
<el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="文本字段">
|
|
191
191
|
<el-input v-model="currentOptionConfig.labelField" placeholder="如:name" />
|
|
192
192
|
</el-form-item>
|
|
193
193
|
|
|
@@ -375,6 +375,7 @@ export default {
|
|
|
375
375
|
dictLoading: false,
|
|
376
376
|
dictQuery: "",
|
|
377
377
|
sortable: null,
|
|
378
|
+
currentConfig: {}, // 配置选项
|
|
378
379
|
};
|
|
379
380
|
},
|
|
380
381
|
computed: {
|
|
@@ -447,6 +448,7 @@ export default {
|
|
|
447
448
|
}
|
|
448
449
|
this.$emit("save", this.configList);
|
|
449
450
|
this.dialogVisible = false;
|
|
451
|
+
console.log(`\x1b[36m\x1b[4mol插件-动态搜索框配置数据`, this.configList);
|
|
450
452
|
},
|
|
451
453
|
async loadItemOptionsForSave(item) {
|
|
452
454
|
if (!item.optionSource) return;
|
|
@@ -594,6 +596,7 @@ export default {
|
|
|
594
596
|
handleConfigOptions(index) {
|
|
595
597
|
this.currentEditIndex = index;
|
|
596
598
|
const currentConfig = this.configList[index];
|
|
599
|
+
this.currentConfig = JSON.parse(JSON.stringify(currentConfig));
|
|
597
600
|
|
|
598
601
|
const optionSource = currentConfig.optionSource || {};
|
|
599
602
|
this.currentOptionConfig = {
|
|
@@ -623,7 +626,55 @@ export default {
|
|
|
623
626
|
handleDeleteOption(index) {
|
|
624
627
|
this.currentOptionConfig.options.splice(index, 1);
|
|
625
628
|
},
|
|
626
|
-
|
|
629
|
+
async loadApiOptions(item) {
|
|
630
|
+
try {
|
|
631
|
+
const apiUrl = item.optionSource.apiUrl;
|
|
632
|
+
const method = item.optionSource.method || "get";
|
|
633
|
+
if (!apiUrl) return;
|
|
634
|
+
|
|
635
|
+
let response;
|
|
636
|
+
if (method === "post") {
|
|
637
|
+
response = await this.post({ url: apiUrl });
|
|
638
|
+
} else {
|
|
639
|
+
response = await this.get({ url: apiUrl });
|
|
640
|
+
}
|
|
641
|
+
if (response.code !== 200) return;
|
|
642
|
+
if (response.result && Array.isArray(response.result)) {
|
|
643
|
+
const { valueField, labelField } = item.optionSource;
|
|
644
|
+
const children = response.result.map(d => ({
|
|
645
|
+
key: d[valueField],
|
|
646
|
+
value: d[labelField],
|
|
647
|
+
}));
|
|
648
|
+
return children;
|
|
649
|
+
}
|
|
650
|
+
} catch (error) {
|
|
651
|
+
console.error("加载接口数据失败:", error);
|
|
652
|
+
return [];
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
needSetChildren(oldConfig, newConfig) {
|
|
656
|
+
const { inputType, optionSource } = oldConfig;
|
|
657
|
+
if (!optionSource) return false;
|
|
658
|
+
const { sourceType, apiUrl, method, valueField, labelField } = optionSource;
|
|
659
|
+
if (inputType !== "select" || sourceType !== "api") return false;
|
|
660
|
+
const {
|
|
661
|
+
sourceType: newSourceType,
|
|
662
|
+
apiUrl: newApiUrl,
|
|
663
|
+
method: newMethod,
|
|
664
|
+
valueField: newValueField,
|
|
665
|
+
labelField: newLabelField,
|
|
666
|
+
} = newConfig;
|
|
667
|
+
if (
|
|
668
|
+
sourceType === newSourceType &&
|
|
669
|
+
apiUrl === newApiUrl &&
|
|
670
|
+
method === newMethod &&
|
|
671
|
+
valueField === newValueField &&
|
|
672
|
+
labelField === newLabelField
|
|
673
|
+
)
|
|
674
|
+
return false;
|
|
675
|
+
return true;
|
|
676
|
+
},
|
|
677
|
+
async handleSaveOptions() {
|
|
627
678
|
const config = this.configList[this.currentEditIndex];
|
|
628
679
|
const configDefault = {
|
|
629
680
|
sourceType: "",
|
|
@@ -653,7 +704,12 @@ export default {
|
|
|
653
704
|
valueField: this.currentOptionConfig.valueField,
|
|
654
705
|
labelField: this.currentOptionConfig.labelField,
|
|
655
706
|
};
|
|
656
|
-
|
|
707
|
+
// 接口请求
|
|
708
|
+
// 判断是否需要走 api接口获取
|
|
709
|
+
let children = [];
|
|
710
|
+
const bool = this.needSetChildren(this.currentConfig, config.optionSource);
|
|
711
|
+
if (bool) children = await this.loadApiOptions(config);
|
|
712
|
+
else config.children = children || [];
|
|
657
713
|
}
|
|
658
714
|
this.optionsDialogVisible = false;
|
|
659
715
|
},
|
|
@@ -495,10 +495,15 @@ export default {
|
|
|
495
495
|
const filterConditions = [];
|
|
496
496
|
Object.keys(formSearch).forEach(key => {
|
|
497
497
|
const tempItem = this.formSearchData.tableSearch.find(item => item.value === key);
|
|
498
|
-
if (
|
|
498
|
+
if (
|
|
499
|
+
formSearch[key] !== undefined &&
|
|
500
|
+
formSearch[key] !== null &&
|
|
501
|
+
formSearch[key] !== "" &&
|
|
502
|
+
formSearch[key] != []
|
|
503
|
+
) {
|
|
499
504
|
filterConditions.push({
|
|
500
505
|
key: key,
|
|
501
|
-
|
|
506
|
+
values: Array.isArray(formSearch[key]) ? formSearch[key] : [formSearch[key]], //必须包数组,后端会统一处理
|
|
502
507
|
compare: tempItem && tempItem.compare ? tempItem.compare : "",
|
|
503
508
|
});
|
|
504
509
|
}
|
|
@@ -546,6 +551,7 @@ export default {
|
|
|
546
551
|
} else {
|
|
547
552
|
// 转成接口需要的结构filterConditions
|
|
548
553
|
const filterConditions = this.setFilterConditionsByFormSearch(this.formSearch) || [];
|
|
554
|
+
|
|
549
555
|
// 动态模式
|
|
550
556
|
this.$emit("handleSearch", this.formSearch, { filterConditions });
|
|
551
557
|
console.log(`\x1b[36m\x1b[4mol插件-动态搜索框查询`, this.formSearch, { filterConditions });
|
package/src/package/index.js
CHANGED
|
@@ -210,8 +210,6 @@ const components = [OlTable, OlSearch, OlCustomSearch, Dialog, OlForm, OlNumberR
|
|
|
210
210
|
const install = async function (Vue) {
|
|
211
211
|
// 设置全局数据
|
|
212
212
|
components.map(item => {
|
|
213
|
-
console.log(777, item);
|
|
214
|
-
|
|
215
213
|
Vue.component(`ol-${item.name}`, item);
|
|
216
214
|
});
|
|
217
215
|
consoleTooltip();
|