ol-base-components 3.2.2 → 3.2.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.
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -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
|
//保存
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
row-key="value"
|
|
30
30
|
:tree-props="{ children: '' }"
|
|
31
31
|
>
|
|
32
|
-
<el-table-column label="排序" width="80" align="center">
|
|
32
|
+
<el-table-column label="排序" width="80" align="center" v-if="dragable">
|
|
33
33
|
<template slot-scope="scope">
|
|
34
34
|
<i class="el-icon-rank sort-handle" style="cursor: move; font-size: 18px" />
|
|
35
35
|
</template>
|
|
@@ -152,17 +152,18 @@
|
|
|
152
152
|
</el-radio-group>
|
|
153
153
|
</el-form-item>
|
|
154
154
|
|
|
155
|
-
<el-form-item v-if="currentOptionConfig.sourceType === 'dict'" label="字典
|
|
155
|
+
<el-form-item v-if="currentOptionConfig.sourceType === 'dict'" label="字典">
|
|
156
156
|
<el-select
|
|
157
157
|
v-model="currentOptionConfig.dictKey"
|
|
158
158
|
filterable
|
|
159
159
|
remote
|
|
160
160
|
reserve-keyword
|
|
161
|
-
placeholder="
|
|
161
|
+
placeholder="请输入字典,如:orderTypeEnum"
|
|
162
162
|
:remote-method="remoteDictQuery"
|
|
163
163
|
:loading="dictLoading"
|
|
164
164
|
style="width: 100%"
|
|
165
165
|
@change="handleDictKeyChange"
|
|
166
|
+
clearable
|
|
166
167
|
>
|
|
167
168
|
<el-option
|
|
168
169
|
v-for="dict in allDictList"
|
|
@@ -187,11 +188,11 @@
|
|
|
187
188
|
</el-select>
|
|
188
189
|
</el-form-item>
|
|
189
190
|
|
|
190
|
-
<el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="文本字段">
|
|
191
|
+
<el-form-item v-if="currentOptionConfig.sourceType === 'api' && show" label="文本字段">
|
|
191
192
|
<el-input v-model="currentOptionConfig.labelField" placeholder="如:name" />
|
|
192
193
|
</el-form-item>
|
|
193
194
|
|
|
194
|
-
<el-form-item v-if="currentOptionConfig.sourceType === 'api'" label="值字段">
|
|
195
|
+
<el-form-item v-if="currentOptionConfig.sourceType === 'api' && show" label="值字段">
|
|
195
196
|
<el-input v-model="currentOptionConfig.valueField" placeholder="如:id" />
|
|
196
197
|
</el-form-item>
|
|
197
198
|
|
|
@@ -233,7 +234,7 @@
|
|
|
233
234
|
</div>
|
|
234
235
|
</el-form-item>
|
|
235
236
|
|
|
236
|
-
<el-form-item v-if="currentOptionConfig.sourceType === 'dict'" label="预览">
|
|
237
|
+
<el-form-item v-if="currentOptionConfig.sourceType === 'dict' && show" label="预览">
|
|
237
238
|
<div class="preview-box">
|
|
238
239
|
<el-tag v-for="(item, index) in previewOptions" :key="index" style="margin: 5px">
|
|
239
240
|
{{ item.value }} ({{ item.key }})
|
|
@@ -246,10 +247,12 @@
|
|
|
246
247
|
</div>
|
|
247
248
|
</el-form-item>
|
|
248
249
|
</el-form>
|
|
249
|
-
<
|
|
250
|
-
<
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
<div class="dialog-footer">
|
|
251
|
+
<slot name="footer">
|
|
252
|
+
<el-button @click="optionsDialogVisible = false">取消</el-button>
|
|
253
|
+
<el-button type="primary" @click="handleSaveOptions">确定</el-button>
|
|
254
|
+
</slot>
|
|
255
|
+
</div>
|
|
253
256
|
</el-dialog>
|
|
254
257
|
|
|
255
258
|
<el-dialog
|
|
@@ -353,9 +356,14 @@ export default {
|
|
|
353
356
|
type: Array,
|
|
354
357
|
default: () => [],
|
|
355
358
|
},
|
|
359
|
+
dragable: {
|
|
360
|
+
type: Boolean,
|
|
361
|
+
default: false,
|
|
362
|
+
},
|
|
356
363
|
},
|
|
357
364
|
data() {
|
|
358
365
|
return {
|
|
366
|
+
show: false,
|
|
359
367
|
dialogVisible: false,
|
|
360
368
|
configList: [],
|
|
361
369
|
optionsDialogVisible: false,
|
|
@@ -375,6 +383,7 @@ export default {
|
|
|
375
383
|
dictLoading: false,
|
|
376
384
|
dictQuery: "",
|
|
377
385
|
sortable: null,
|
|
386
|
+
currentConfig: {}, // 配置选项
|
|
378
387
|
};
|
|
379
388
|
},
|
|
380
389
|
computed: {
|
|
@@ -595,6 +604,7 @@ export default {
|
|
|
595
604
|
handleConfigOptions(index) {
|
|
596
605
|
this.currentEditIndex = index;
|
|
597
606
|
const currentConfig = this.configList[index];
|
|
607
|
+
this.currentConfig = JSON.parse(JSON.stringify(currentConfig));
|
|
598
608
|
|
|
599
609
|
const optionSource = currentConfig.optionSource || {};
|
|
600
610
|
this.currentOptionConfig = {
|
|
@@ -624,7 +634,55 @@ export default {
|
|
|
624
634
|
handleDeleteOption(index) {
|
|
625
635
|
this.currentOptionConfig.options.splice(index, 1);
|
|
626
636
|
},
|
|
627
|
-
|
|
637
|
+
async loadApiOptions(item) {
|
|
638
|
+
try {
|
|
639
|
+
const apiUrl = item.optionSource.apiUrl;
|
|
640
|
+
const method = item.optionSource.method || "get";
|
|
641
|
+
if (!apiUrl) return;
|
|
642
|
+
|
|
643
|
+
let response;
|
|
644
|
+
if (method === "post") {
|
|
645
|
+
response = await this.post({ url: apiUrl });
|
|
646
|
+
} else {
|
|
647
|
+
response = await this.get({ url: apiUrl });
|
|
648
|
+
}
|
|
649
|
+
if (response.code !== 200) return;
|
|
650
|
+
if (response.result && Array.isArray(response.result)) {
|
|
651
|
+
const { valueField, labelField } = item.optionSource;
|
|
652
|
+
const children = response.result.map(d => ({
|
|
653
|
+
key: d[valueField],
|
|
654
|
+
value: d[labelField],
|
|
655
|
+
}));
|
|
656
|
+
return children;
|
|
657
|
+
}
|
|
658
|
+
} catch (error) {
|
|
659
|
+
console.error("加载接口数据失败:", error);
|
|
660
|
+
return [];
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
needSetChildren(oldConfig, newConfig) {
|
|
664
|
+
const { inputType, optionSource } = oldConfig;
|
|
665
|
+
if (!optionSource) return false;
|
|
666
|
+
const { sourceType, apiUrl, method, valueField, labelField } = optionSource;
|
|
667
|
+
if (inputType !== "select" || sourceType !== "api") return false;
|
|
668
|
+
const {
|
|
669
|
+
sourceType: newSourceType,
|
|
670
|
+
apiUrl: newApiUrl,
|
|
671
|
+
method: newMethod,
|
|
672
|
+
valueField: newValueField,
|
|
673
|
+
labelField: newLabelField,
|
|
674
|
+
} = newConfig;
|
|
675
|
+
if (
|
|
676
|
+
sourceType === newSourceType &&
|
|
677
|
+
apiUrl === newApiUrl &&
|
|
678
|
+
method === newMethod &&
|
|
679
|
+
valueField === newValueField &&
|
|
680
|
+
labelField === newLabelField
|
|
681
|
+
)
|
|
682
|
+
return false;
|
|
683
|
+
return true;
|
|
684
|
+
},
|
|
685
|
+
async handleSaveOptions() {
|
|
628
686
|
const config = this.configList[this.currentEditIndex];
|
|
629
687
|
const configDefault = {
|
|
630
688
|
sourceType: "",
|
|
@@ -654,7 +712,12 @@ export default {
|
|
|
654
712
|
valueField: this.currentOptionConfig.valueField,
|
|
655
713
|
labelField: this.currentOptionConfig.labelField,
|
|
656
714
|
};
|
|
657
|
-
|
|
715
|
+
// 接口请求
|
|
716
|
+
// 判断是否需要走 api接口获取
|
|
717
|
+
let children = [];
|
|
718
|
+
const bool = this.needSetChildren(this.currentConfig, config.optionSource);
|
|
719
|
+
if (bool) children = await this.loadApiOptions(config);
|
|
720
|
+
else config.children = children || [];
|
|
658
721
|
}
|
|
659
722
|
this.optionsDialogVisible = false;
|
|
660
723
|
},
|