|
|
@@ -56,10 +56,10 @@
|
|
|
<el-form-item label="数据领域">
|
|
|
<el-select v-model="form.dataField">
|
|
|
<el-option
|
|
|
- v-for="dict in dict.type.service_data_field"
|
|
|
+ v-for="dict in optionsDataField"
|
|
|
:key="dict.value"
|
|
|
- :label="dict.label"
|
|
|
- :value="dict.value"
|
|
|
+ :label="dict.dictLabel"
|
|
|
+ :value="dict.dictCode"
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
@@ -154,7 +154,7 @@
|
|
|
</el-form-item>
|
|
|
<el-row type="flex" justify="center">
|
|
|
<el-button
|
|
|
- icon="el-icon-arrow-left"
|
|
|
+ icon="ArrowLeft"
|
|
|
size="small"
|
|
|
disabled
|
|
|
@click="forwardStep"
|
|
|
@@ -163,7 +163,7 @@
|
|
|
<el-button type="primary" @click="onSubmit"> 保存</el-button>
|
|
|
<el-button @click="exit">退出</el-button>
|
|
|
<el-button
|
|
|
- icon="el-icon-arrow-right"
|
|
|
+ icon="ArrowRight"
|
|
|
size="small"
|
|
|
@click="nextStep"
|
|
|
circle
|
|
|
@@ -198,6 +198,8 @@ import {saveServiceInfo} from "@/api/service/info";
|
|
|
import {getCatalog} from "@/api/service/catalog";
|
|
|
import ParamAndFile from "./paramAndFile.vue";
|
|
|
import ServiceFile from "./serviceFile.vue";
|
|
|
+import { getDicts } from "@/api/system/dict/data";
|
|
|
+import useDictStore from '@/store/modules/dict'
|
|
|
|
|
|
export default {
|
|
|
props: ["service", "serviceVisible"],
|
|
|
@@ -207,6 +209,7 @@ export default {
|
|
|
return {
|
|
|
step: 0,
|
|
|
type: "添加",
|
|
|
+ optionsDataField:[],
|
|
|
form: {
|
|
|
srvId: "",
|
|
|
cateCode: "",
|
|
|
@@ -225,7 +228,7 @@ export default {
|
|
|
maintainUnit: "",
|
|
|
maintainContacer: "",
|
|
|
intro: "",
|
|
|
- dataField: "22",
|
|
|
+ dataField: "",
|
|
|
openCndtn: "0",
|
|
|
},
|
|
|
cascader: {
|
|
|
@@ -270,8 +273,17 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.fetchData();
|
|
|
+ this.getDicts()
|
|
|
},
|
|
|
methods: {
|
|
|
+ getDicts(){
|
|
|
+ getDicts('service_data_field').then((r) => {
|
|
|
+ for(var i =0;i<r.data.length;i++){
|
|
|
+ r.data[i].dictCode = r.data[i].dictCode.toString()
|
|
|
+ }
|
|
|
+ this.optionsDataField = r.data
|
|
|
+ });
|
|
|
+ },
|
|
|
exit() {
|
|
|
this.$emit("close");
|
|
|
},
|
|
|
@@ -326,14 +338,44 @@ export default {
|
|
|
return false;
|
|
|
});
|
|
|
},
|
|
|
+ buildTree(flatData, rootValue = '0') {
|
|
|
+ // 1. 创建哈希映射和结果集
|
|
|
+ const nodeMap = new Map();
|
|
|
+ const tree = [];
|
|
|
+
|
|
|
+ // 2. 构建初始映射(浅拷贝节点,避免污染原数据)
|
|
|
+ flatData.forEach(item => {
|
|
|
+ nodeMap.set(item.cateCode, { ...item, children: [] });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 3. 构建树结构
|
|
|
+ for (const [code, node] of nodeMap) {
|
|
|
+ const parentCode = node.catePcode;
|
|
|
+
|
|
|
+ // 根节点直接加入结果集
|
|
|
+ if (parentCode === rootValue || !parentCode) {
|
|
|
+ tree.push(node);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 非根节点:挂载到父节点
|
|
|
+ const parent = nodeMap.get(parentCode);
|
|
|
+ if (parent) {
|
|
|
+ parent.children.push(node);
|
|
|
+ } else {
|
|
|
+ // 处理孤儿节点(可选:也可选择忽略)
|
|
|
+ console.warn(`Orphan node detected: ${code}. Parent ${parentCode} not found`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return tree;
|
|
|
+ },
|
|
|
fetchData() {
|
|
|
getCatalog().then((r) => {
|
|
|
- this.cascader.options = this.handleTree2(
|
|
|
- r.data,
|
|
|
- "catePcode",
|
|
|
- "cateCode",
|
|
|
- "0"
|
|
|
+ this.cascader.options = this.buildTree(
|
|
|
+ r.data
|
|
|
);
|
|
|
+ console.log(this.cascader.options)
|
|
|
});
|
|
|
},
|
|
|
addParam() {
|
|
|
@@ -376,15 +418,13 @@ export default {
|
|
|
maintainUnit: "",
|
|
|
maintainContacer: "",
|
|
|
intro: "",
|
|
|
- dataField: "22",
|
|
|
+ dataField: "",
|
|
|
openCndtn: "0",
|
|
|
};
|
|
|
-
|
|
|
- if (this.service.srvId) {
|
|
|
+ if (this.service) {
|
|
|
this.type = "修改";
|
|
|
const httpsReg = new RegExp("https://", "i");
|
|
|
const httpReg = new RegExp("http://", "i");
|
|
|
-
|
|
|
this.form = this.service;
|
|
|
if (this.form.url) {
|
|
|
let isHas = this.form.url.match(httpsReg);
|