Commit 5bbe6f4a by 张立顺

fix 功能联调bug修复

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