|
@@ -202,8 +202,8 @@ const rules = {
|
|
|
// 分类变化时更新二级分类
|
|
// 分类变化时更新二级分类
|
|
|
const handleCategoryChange = (val: string) => {
|
|
const handleCategoryChange = (val: string) => {
|
|
|
form.value.subCategory = '';
|
|
form.value.subCategory = '';
|
|
|
- const children = categoryRawList.value.filter(item => item.parentNo === val);
|
|
|
|
|
- subCategoryOptions.value = children.map(item => ({
|
|
|
|
|
|
|
+ const children = categoryRawList.value.filter((item) => item.parentNo === val);
|
|
|
|
|
+ subCategoryOptions.value = children.map((item) => ({
|
|
|
value: item.categoryName,
|
|
value: item.categoryName,
|
|
|
label: item.categoryName
|
|
label: item.categoryName
|
|
|
}));
|
|
}));
|
|
@@ -214,8 +214,8 @@ const getCategoryList = async () => {
|
|
|
try {
|
|
try {
|
|
|
const res = await listHelpCategory({ platformCode: 'opm', pageSize: 1000 });
|
|
const res = await listHelpCategory({ platformCode: 'opm', pageSize: 1000 });
|
|
|
categoryRawList.value = res.rows || [];
|
|
categoryRawList.value = res.rows || [];
|
|
|
- const topCategories = categoryRawList.value.filter(item => !item.parentNo);
|
|
|
|
|
- categoryOptions.value = topCategories.map(item => ({
|
|
|
|
|
|
|
+ const topCategories = categoryRawList.value.filter((item) => !item.parentNo);
|
|
|
|
|
+ categoryOptions.value = topCategories.map((item) => ({
|
|
|
value: item.categoryNo,
|
|
value: item.categoryNo,
|
|
|
label: item.categoryName
|
|
label: item.categoryName
|
|
|
}));
|
|
}));
|
|
@@ -241,7 +241,7 @@ const getList = async () => {
|
|
|
// 根据分类编号获取分类名称
|
|
// 根据分类编号获取分类名称
|
|
|
const getCategoryName = (categoryNo: string) => {
|
|
const getCategoryName = (categoryNo: string) => {
|
|
|
if (!categoryNo) return '';
|
|
if (!categoryNo) return '';
|
|
|
- const category = categoryRawList.value.find(item => item.categoryNo === categoryNo);
|
|
|
|
|
|
|
+ const category = categoryRawList.value.find((item) => item.categoryNo === categoryNo);
|
|
|
return category?.categoryName || categoryNo;
|
|
return category?.categoryName || categoryNo;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -281,8 +281,8 @@ const handleView = async (row: any) => {
|
|
|
viewDialog.data = res.data || {};
|
|
viewDialog.data = res.data || {};
|
|
|
// 加载查看时的二级分类选项
|
|
// 加载查看时的二级分类选项
|
|
|
const helpType = res.data.helpType || '';
|
|
const helpType = res.data.helpType || '';
|
|
|
- const children = categoryRawList.value.filter(item => item.parentNo === helpType);
|
|
|
|
|
- viewSubCategoryOptions.value = children.map(item => ({
|
|
|
|
|
|
|
+ const children = categoryRawList.value.filter((item) => item.parentNo === helpType);
|
|
|
|
|
+ viewSubCategoryOptions.value = children.map((item) => ({
|
|
|
value: item.categoryName,
|
|
value: item.categoryName,
|
|
|
label: item.categoryName
|
|
label: item.categoryName
|
|
|
}));
|
|
}));
|
|
@@ -298,12 +298,12 @@ const handleEdit = async (row: any) => {
|
|
|
try {
|
|
try {
|
|
|
const res = await getHelpCenter(row.id);
|
|
const res = await getHelpCenter(row.id);
|
|
|
const helpType = res.data.helpType || '';
|
|
const helpType = res.data.helpType || '';
|
|
|
- const children = categoryRawList.value.filter(item => item.parentNo === helpType);
|
|
|
|
|
- subCategoryOptions.value = children.map(item => ({
|
|
|
|
|
- value: item.categoryName,
|
|
|
|
|
|
|
+ const children = categoryRawList.value.filter((item) => item.parentNo === helpType);
|
|
|
|
|
+ subCategoryOptions.value = children.map((item) => ({
|
|
|
|
|
+ value: item.categoryNo,
|
|
|
label: item.categoryName
|
|
label: item.categoryName
|
|
|
}));
|
|
}));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
formRef.value?.resetFields();
|
|
formRef.value?.resetFields();
|
|
|
form.value = {
|
|
form.value = {
|
|
|
id: res.data.id,
|
|
id: res.data.id,
|
|
@@ -362,6 +362,14 @@ const submitForm = async () => {
|
|
|
const valid = await formRef.value?.validate();
|
|
const valid = await formRef.value?.validate();
|
|
|
if (!valid) return;
|
|
if (!valid) return;
|
|
|
|
|
|
|
|
|
|
+ // 二级分类优先:如果选了二级分类,用它的 categoryNo 作为 helpType
|
|
|
|
|
+ if (form.value.subCategory) {
|
|
|
|
|
+ const matched = categoryRawList.value.find((item: any) => item.categoryName === form.value.subCategory);
|
|
|
|
|
+ if (matched) {
|
|
|
|
|
+ form.value.helpType = matched.categoryNo;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
if (form.value.id) {
|
|
if (form.value.id) {
|
|
|
await updateHelpCenter(form.value);
|
|
await updateHelpCenter(form.value);
|