Bläddra i källkod

产品展示接口使用之前的, 新接口没有层级区分

yangzm123 10 månader sedan
förälder
incheckning
46e7006e1e
1 ändrade filer med 38 tillägg och 17 borttagningar
  1. 38 17
      src/pages/affairs/transaction.vue

+ 38 - 17
src/pages/affairs/transaction.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: PoJun
  * @Date: 2023-10-13 10:35:43
- * @LastEditTime: 2024-05-08 21:14:46 * @Message: 事务处理中心
+ * @LastEditTime: 2024-05-08 22:45:08
 -->
 <template>
     <div class="affairsTransaction">
@@ -21,7 +21,12 @@
             </template>
         </CommonTable>
 
-        <a-modal v-model="showModal" :zIndex="1002" title="内容详情">
+        <a-modal
+            v-model="showModal"
+            :zIndex="1002"
+            title="内容详情"
+            :bodyStyle="{ height: '500px', overflow: 'hidden auto' }"
+        >
             <a-spin :spinning="spinning">
                 <common-card>
                     <common-card-item label="标题" :text="detailItem?.title" :span="24"></common-card-item>
@@ -36,10 +41,10 @@
                         <common-card-item label="联系方式" :text="detailItem?.data.phone" :span="24"></common-card-item>
                         <common-card-item label="地址" :text="detailItem?.data.address" :span="24"></common-card-item>
                         <common-card-item label="企业简介" :text="detailItem?.data.intro" :span="24"></common-card-item>
-                        
+
                         <common-card-item
                             label="产品分类"
-                            :text="detailItem?.productName"
+                            :text="showProductNames(detailItem?.data.product)"
                             :span="24"
                         ></common-card-item>
                         <common-card-item
@@ -110,7 +115,7 @@ import CommonTable from "@/components/table/CommonTable.vue";
 import CommonCard from "@/components/table/CommonCard.vue";
 import CommonCardItem from "@/components/table/CommonCardItem.vue";
 import UploadImg from "@/components/tool/UploadImg.vue";
-import { refuseAffairs, agreeAffairs, getAffairSelfInfo, getProductsInfoFromIds } from "@/api/index.js";
+import { refuseAffairs, agreeAffairs, getAffairSelfInfo, getProductsTreeNoAuth } from "@/api/index.js";
 export default {
     components: { CommonTable, CommonCard, CommonCardItem, UploadImg },
     name: "affairsTransaction",
@@ -139,9 +144,12 @@ export default {
             showModal: false,
             detailItem: null,
             currentKey: "todo",
+            treeData: [],
         };
     },
-    created() {},
+    created() {
+        this.getTreeData();
+    },
     methods: {
         // 需要获取详情
         async optClick(row) {
@@ -150,10 +158,6 @@ export default {
             const data = await getAffairSelfInfo(row.id);
             this.detailItem = data;
             this.spinning = false;
-            const product = data.data.product;
-            if (product && product.length > 0) {
-                this.getProductName(product);
-            }
         },
         menuSelect(e) {
             const key = e.target.value;
@@ -175,14 +179,11 @@ export default {
             this.showModal = false;
             this.$refs.xTable.refresh();
         },
-
-        async getProductName(idArray) {
+        async getTreeData() {
             try {
-                const data = await getProductsInfoFromIds({ ids: idArray.join(",") });
-                const productName = data.map(item => {
-                    return item.name;
-                });
-this.$set(this.detailItem, "productName", productName.join(","));            } catch (error) {
+                const data = await getProductsTreeNoAuth();
+                this.treeData = data;
+            } catch (error) {
                 console.log(error);
             }
         },
@@ -196,6 +197,26 @@ this.$set(this.detailItem, "productName", productName.join(","));            }
             },
         },
     },
+    computed: {
+        showProductNames() {
+            return (rv = []) => {
+                if (!rv || !rv.length) return "";
+                let names = [];
+                this.treeData.map(item => {
+                    let itemNs = [];
+                    if (item.children && item.children.length) {
+                        item.children.map(v => {
+                            if (rv.includes(v.id)) {
+                                itemNs.push(v.name);
+                            }
+                        });
+                    }
+                    names = names.concat(itemNs);
+                });
+                return names.join(",");
+            };
+        },
+    },
 };
 </script>