瀏覽代碼

修改帮助中心

hurx 1 天之前
父節點
當前提交
577173a6ec
共有 1 個文件被更改,包括 19 次插入11 次删除
  1. 19 11
      src/views/platform/help/list/index.vue

+ 19 - 11
src/views/platform/help/list/index.vue

@@ -202,8 +202,8 @@ const rules = {
 // 分类变化时更新二级分类
 const handleCategoryChange = (val: string) => {
   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,
     label: item.categoryName
   }));
@@ -214,8 +214,8 @@ const getCategoryList = async () => {
   try {
     const res = await listHelpCategory({ platformCode: 'opm', pageSize: 1000 });
     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,
       label: item.categoryName
     }));
@@ -241,7 +241,7 @@ const getList = async () => {
 // 根据分类编号获取分类名称
 const getCategoryName = (categoryNo: string) => {
   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;
 };
 
@@ -281,8 +281,8 @@ const handleView = async (row: any) => {
     viewDialog.data = res.data || {};
     // 加载查看时的二级分类选项
     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,
       label: item.categoryName
     }));
@@ -298,12 +298,12 @@ const handleEdit = async (row: any) => {
   try {
     const res = await getHelpCenter(row.id);
     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
     }));
-    
+
     formRef.value?.resetFields();
     form.value = {
       id: res.data.id,
@@ -362,6 +362,14 @@ const submitForm = async () => {
   const valid = await formRef.value?.validate();
   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 {
     if (form.value.id) {
       await updateHelpCenter(form.value);