Commit 5bbe6f4a by 张立顺

fix 功能联调bug修复

1 parent f6b47079
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
"private": true, "private": true,
"scripts": { "scripts": {
"备注": "去掉nomock配置命令", "备注": "去掉nomock配置命令",
"serve": "vue-cli-service serve", "serve": "set NODE_OPTIONS=--max-old-space-size=4096&& vue-cli-service serve",
"start": "set NODE_OPTIONS=--openssl-legacy-provider && npm run serve", "start": "npm run serve",
"dev": "set NODE_OPTIONS=--openssl-legacy-provider && npm run serve", "dev": "npm run serve",
"build": "vue-cli-service build --no-module", "build": "vue-cli-service build --no-module",
"build:nomock": "vue-cli-service build --mode nomock", "build:nomock": "vue-cli-service build --mode nomock",
"lint": "vue-cli-service lint --fix", "lint": "vue-cli-service lint --fix",
......
<template> <template>
<glsk-form-dialog <glsk-form-dialog v-if="visible"
v-if="visible" default-width="320px"
:selectVisible="visible" dialog-width="520px"
:dialogConfig="dialogConfig" label-width="120px"
label-width="120px" :base-data="baseData"
dialog-width="520px" :dialog-config="dialogConfig"
defaultWidth="320px" :edit-data="editData"
:formRules="formRules" :edit-form-data="editFormData"
:editData="editData" :form-rules="formRules"
:editFormData="editFormData" :select-visible="visible"
:baseData="baseData" @handleClose="$emit('update:visible', false)"
@handleClose="$emit('update:visible', false)" @handleConfirm="handleConfirm" />
@handleConfirm="handleConfirm"
/>
</template> </template>
<script> <script>
import { import {
createTagDimension, createTagDimension,
updateTagDimension,
queryTagDimensionDetail, queryTagDimensionDetail,
updateTagDimension,
} from "@api/tagManagement"; } from "@api/tagManagement";
export default { export default {
...@@ -41,10 +39,6 @@ export default { ...@@ -41,10 +39,6 @@ export default {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
defaultCategoryId: {
type: [Number, String],
default: "",
},
}, },
data() { data() {
return { return {
...@@ -92,7 +86,7 @@ export default { ...@@ -92,7 +86,7 @@ export default {
placeholder: "请选择所属标签类别", placeholder: "请选择所属标签类别",
filterable: true, filterable: true,
optionsName: "categoryOptions", optionsName: "categoryOptions",
optionId: "value", optionId: "id",
optionLabel: "fullPath", optionLabel: "fullPath",
optionList: [], optionList: [],
disabled: this.categoryReadonly, disabled: this.categoryReadonly,
...@@ -119,13 +113,27 @@ export default { ...@@ -119,13 +113,27 @@ export default {
}, },
categoryOptions: { categoryOptions: {
handler(val) { handler(val) {
this.baseData.categoryOptions = val || []; this.baseData.categoryOptions = (val || []).map(item => ({
...item,
id: item.id != null ? item.id : item.value,
fullPath: item.fullPath || item.categoryName || "",
}));
}, },
immediate: true, immediate: true,
deep: true, deep: true,
}, },
}, },
methods: { methods: {
resolveCategoryId(categoryId) {
if (categoryId == null || categoryId === "") {
return "";
}
const options = this.baseData.categoryOptions || [];
const matched = options.find(
item => String(item.id) === String(categoryId),
);
return matched ? matched.id : categoryId;
},
async initForm() { async initForm() {
if (this.isEdit) { if (this.isEdit) {
try { try {
...@@ -135,7 +143,7 @@ export default { ...@@ -135,7 +143,7 @@ export default {
this.editData = { this.editData = {
id: detail.id, id: detail.id,
dimensionName: detail.dimensionName || "", dimensionName: detail.dimensionName || "",
categoryId: detail.categoryId, categoryId: this.resolveCategoryId(detail.categoryId),
}; };
} catch (err) { } catch (err) {
this.$message.error(err.message || "获取维度详情失败"); this.$message.error(err.message || "获取维度详情失败");
...@@ -143,14 +151,14 @@ export default { ...@@ -143,14 +151,14 @@ export default {
this.editData = { this.editData = {
id: row.id, id: row.id,
dimensionName: row.dimensionName || "", dimensionName: row.dimensionName || "",
categoryId: row.categoryId, categoryId: this.resolveCategoryId(row.categoryId),
}; };
} }
} else { } else {
this.editData = { this.editData = {
id: "", id: "",
dimensionName: "", dimensionName: "",
categoryId: this.defaultCategoryId || "", categoryId: "",
}; };
} }
}, },
......
...@@ -84,6 +84,7 @@ export default { ...@@ -84,6 +84,7 @@ export default {
{ {
label: "标签枚举值名称", label: "标签枚举值名称",
name: "enumName", name: "enumName",
labelRequired: true,
type: "input", type: "input",
placeholder: "请输入", placeholder: "请输入",
maxlength: 20, maxlength: 20,
...@@ -95,6 +96,7 @@ export default { ...@@ -95,6 +96,7 @@ export default {
{ {
label: "命中客户分", label: "命中客户分",
name: "score", name: "score",
labelRequired: true,
type: "input", type: "input",
placeholder: "请输入0~100的整数", placeholder: "请输入0~100的整数",
maxlength: 3, maxlength: 3,
......
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
</el-button> </el-button>
</template> </template>
</d2-table> </d2-table>
<div class="footer-actions">
<el-button size="medium"
type="primary"
@click="handleBack">
返回
</el-button>
</div>
</div> </div>
<EnumFormDialog :dimension-data="dimensionDetail" <EnumFormDialog :dimension-data="dimensionDetail"
...@@ -186,6 +193,9 @@ export default { ...@@ -186,6 +193,9 @@ export default {
handleEnumFormSuccess() { handleEnumFormSuccess() {
this.refreshTable(); this.refreshTable();
}, },
handleBack() {
this.$router.push({ name: "tagManagement" });
},
}, },
}; };
</script> </script>
...@@ -211,5 +221,11 @@ export default { ...@@ -211,5 +221,11 @@ export default {
.d2-container-content { .d2-container-content {
padding: 16px 20px; padding: 16px 20px;
} }
.footer-actions {
margin-top: 8px;
padding: 16px 0 8px;
text-align: center;
}
} }
</style> </style>
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
:visible.sync="categoryDialogVisible" :visible.sync="categoryDialogVisible"
@success="handleCategorySuccess" /> @success="handleCategorySuccess" />
<DimensionFormDialog :category-options="dimensionCategoryOptions" <DimensionFormDialog :category-options="dimensionCategoryOptions"
:default-category-id="selectedCategoryId"
:dimension-data="currentDimension" :dimension-data="currentDimension"
:mode="dimensionDialogMode" :mode="dimensionDialogMode"
:visible.sync="dimensionDialogVisible" :visible.sync="dimensionDialogVisible"
...@@ -213,6 +212,31 @@ export default { ...@@ -213,6 +212,31 @@ export default {
this.$refs.dimensionTable.refreshTable(); this.$refs.dimensionTable.refreshTable();
} }
}, },
findCategoryInTree(list, id) {
for (const item of list || []) {
if (String(item.id) === String(id)) {
return item;
}
if (item.children && item.children.length) {
const found = this.findCategoryInTree(item.children, id);
if (found) {
return found;
}
}
}
return null;
},
syncSelectedCategory() {
if (this.selectedCategoryId === "" || this.selectedCategoryId == null) {
this.selectedCategory = null;
return;
}
const found = this.findCategoryInTree(
this.categoryTree,
this.selectedCategoryId,
);
this.selectedCategory = found;
},
handleAddCategory() { handleAddCategory() {
this.categoryDialogMode = "add"; this.categoryDialogMode = "add";
this.currentCategory = {}; this.currentCategory = {};
...@@ -260,15 +284,20 @@ export default { ...@@ -260,15 +284,20 @@ export default {
}, },
}); });
}, },
handleCategorySuccess() { async handleCategorySuccess() {
this.loadCategoryTree(); await this.loadCategoryTree();
this.loadCategoryLeafOptions(); this.syncSelectedCategory();
this.loadDimensionCategoryOptions(); await Promise.all([
this.loadCategoryLeafOptions(),
this.loadDimensionCategoryOptions(),
]);
this.refreshTable();
}, },
handleDimensionSuccess() { async handleDimensionSuccess() {
await this.loadCategoryTree();
this.syncSelectedCategory();
await this.loadDimensionCategoryOptions();
this.refreshTable(); this.refreshTable();
this.loadCategoryTree();
this.loadDimensionCategoryOptions();
}, },
}, },
}; };
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!