From 8389556ab406cf1508fdbbfd2df19125c539c19e Mon Sep 17 00:00:00 2001
From: pengda <10266652509@qq.com>
Date: Thu, 15 May 2025 14:06:34 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B4=9F=E6=AF=9B=E5=88=A9=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/components/super/RankingLeftMenu.vue |  4 ++
 src/router/index.js                      | 10 +++-
 src/views/super/Ranking/RankDetail.vue   | 90 ++++++++++++++++++++++++++------
 3 files changed, 87 insertions(+), 17 deletions(-)

diff --git a/src/components/super/RankingLeftMenu.vue b/src/components/super/RankingLeftMenu.vue
index 5df9f50..250a2fd 100644
--- a/src/components/super/RankingLeftMenu.vue
+++ b/src/components/super/RankingLeftMenu.vue
@@ -78,6 +78,10 @@ export default {
                     imgActive: require('@/assets/super/ranking-menu.svg'),
                     list: [
                         {
+                            name: '负毛利',
+                            path: '/super/ranking/loss',
+                        },
+                        {
                             name: '采购价',
                             path: '/super/ranking/purchase',
                         },
diff --git a/src/router/index.js b/src/router/index.js
index 057e708..3c0ef1c 100755
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -11,12 +11,12 @@ const whiteHeaderList = ['/', '/ui', '/register', '/configureServicePrices', '/s
   ,'/siteSetting/siteH5','/siteSetting/siteSem','/pageTemplete','/demo',
   '/super/ranking/yearProfit', '/super/ranking/monthProfit', '/super/ranking/checkProfit', '/super/ranking/checkOrdernum',
   '/super/ranking/checkRefund', '/super/ranking/agentProfit', '/super/ranking/agentRecharge', '/super/ranking/agentNew',
-  '/super/ranking/purchase','/super/ranking/stagePurchase'
+  '/super/ranking/purchase','/super/ranking/stagePurchase','/super/ranking/loss'
 ]; //头部导航白名单
 const whiteFooterList = ['/', '/ui', '/configureServicePrices',
   '/super/ranking/yearProfit', '/super/ranking/monthProfit', '/super/ranking/checkProfit', '/super/ranking/checkOrdernum',
   '/super/ranking/checkRefund', '/super/ranking/agentProfit', '/super/ranking/agentRecharge', '/super/ranking/agentNew',
-  '/super/ranking/purchase','/super/ranking/stagePurchase'
+  '/super/ranking/purchase','/super/ranking/stagePurchase','/super/ranking/loss'
 ]; //底部白名单
 const routes = [{
     path: '/',
@@ -179,6 +179,12 @@ const routes = [{
         props: {pageTitle:'代理商 - 新加盟', type: 'agentnew', showDateSelect: false}
       },
       {
+        path: 'loss',
+        name: '负毛利',
+        component: () => import( /* webpackChunkName: "Ranking" */ '../views/super/Ranking/RankDetail.vue'),
+        props: {pageTitle:'负毛利 - 排行', type: 'loss'}
+      },
+      {
         path: 'purchase',
         name: '采购价',
         component: () => import( /* webpackChunkName: "Ranking" */ '../views/super/Ranking/Purchase.vue'),
diff --git a/src/views/super/Ranking/RankDetail.vue b/src/views/super/Ranking/RankDetail.vue
index ffc12ad..14adb14 100644
--- a/src/views/super/Ranking/RankDetail.vue
+++ b/src/views/super/Ranking/RankDetail.vue
@@ -14,7 +14,7 @@
                             @change="handleDateChange"/>
             </CustomDropdown>
         </div>
-        <div class=" flex-common" v-if="type == 'year'">
+        <div class=" flex-common" v-if="dataType == 'year'">
             <el-form>
                 <el-table :data="tableData"
                           style="width: 100%"
@@ -75,7 +75,7 @@
             </el-form>
         </div>
 
-        <div class=" flex-common" v-if="type == 'month'">
+        <div class=" flex-common" v-if="dataType == 'month'">
             <el-form>
                 <el-table :data="tableData"
                           style="width: 100%"
@@ -136,7 +136,7 @@
             </el-form>
         </div>
 
-        <div class=" flex-common" v-if="type == 'day'">
+        <div class=" flex-common" v-if="dataType == 'day'">
             <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
                 <h3 style="margin: 0;"></h3>
                 <span style="font-size: 14px; color: #999;">总{{ rank_type_desc[dataRank] }}:{{ total_value }}</span>
@@ -167,7 +167,7 @@
             </el-form>
         </div>
 
-        <div class=" flex-common" v-if="type == 'agentnew'">
+        <div class=" flex-common" v-if="dataType == 'agentnew'">
             <el-form>
                 <el-table :data="tableData"
                           style="width: 100%"
@@ -198,6 +198,35 @@
                 </el-table>
             </el-form>
         </div>
+
+        <div class=" flex-common" v-if="dataType == 'loss'">
+            <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
+                <h3 style="margin: 0;"></h3>
+                <span style="font-size: 14px; color: #999;">总负毛利:{{ total_value }}</span>
+            </div>
+
+            <el-form>
+                <el-table :data="tableData"
+                          style="width: 100%"
+                          @sort-change="handleSortChange"
+                          @cell-mouse-enter="handleRowHover">
+
+                    <el-table-column prop="sort" label="排序"></el-table-column>
+
+                    <el-table-column prop="1" label="日期" sortable="custom">
+                        <template slot-scope="scope">
+                            {{ scope.row.value_1 }}
+                        </template>
+                    </el-table-column>
+
+                    <el-table-column prop="2" label="负毛利" sortable="custom">
+                        <template slot-scope="scope">
+                            {{ scope.row.value_2 }}
+                        </template>
+                    </el-table-column>
+                </el-table>
+            </el-form>
+        </div>
     </div>
 </template>
 <script>
@@ -253,6 +282,7 @@ export default {
             filterTitle: "",
             view: 'year',
             onlyYear: true,
+            dataType: '',
             dataRank: '',
             text: '',//下拉框显示具体文案
             selectedDate: new Date(),//默认当天日期
@@ -280,18 +310,16 @@ export default {
             this.text = ""
             if (this.showDateSelect) this.text = this.getNowYear()
             this.dataRank = this.rank_type
+            this.dataType = this.type
             this.aid = this.$route.query.aid
             this.ver_type = this.$route.query.ver_type
             this.check_type = this.$route.query.check_type
             if (this.$route.query.date) this.text = this.$route.query.date
+            if (this.$route.query.type) this.dataType = this.$route.query.type
             if (this.$route.query.rank_type) this.dataRank = this.$route.query.rank_type
             if (Object.keys(this.$route.query).length > 0) this.showfilterTitle = true
 
-            if (this.type == 'agentnew') {
-                this.getAgentNew()
-            } else {
-                this.getRankingDetail()
-            }
+            this.getData()
         },
         handleUpdateView(newView) {
             this.view = newView;
@@ -318,7 +346,7 @@ export default {
             localStorage.setItem('date', JSON.stringify(date))
 
             this.$refs.dropdownRef.closeDropdown();
-            this.getRankingDetail()
+            this.getData()
         },
         goLookMoreData(date) {
             let query = {}
@@ -369,15 +397,25 @@ export default {
                 sort_by = prop;
                 sort_order = 2;
             }
-            if (this.type == 'agentnew') {
-                this.getAgentNew({sort_by: sort_by, sort_order: sort_order})
-                return
-            }
-            this.getRankingDetail({sort_by: sort_by, sort_order: sort_order})
+            this.getData({sort_by: sort_by, sort_order: sort_order})
         },
         handleRowHover(row) {
             this.show_detail_index = row.sort
         },
+        getData(obj){
+            if (this.dataType == 'agentnew') {
+                this.getAgentNew(obj)
+                return true;
+            }
+
+            if (this.dataType == 'loss') {
+                this.onlyYear = false;
+                this.getLossDetail(obj)
+                return true;
+            }
+
+            this.getRankingDetail(obj)
+        },
         getRankingDetail(obj) {
             const that = this
             that.tableData = []
@@ -403,6 +441,28 @@ export default {
                 console.error(error, 'error')
             })
         },
+        getLossDetail(obj) {
+            const that = this
+            that.tableData = []
+            that.total_value = 0
+            this.$http('POST', '/supernew/ajax_get_loss_detail', {
+                aid: that.aid,
+                ver_type: that.ver_type,
+                check_type: that.check_type,
+                date: that.text,
+                ...obj
+            }).then(response => {
+                this.$nextTick(() => {
+                    that.tableData = response.data.list
+                    that.total_value = response.data.total_value
+                    that.total = response.data.total
+
+                    if (that.showfilterTitle) that.filterTitle = response.data.title
+                })
+            }).catch(error => {
+                console.error(error, 'error')
+            })
+        },
         getRankingList(obj) {
             const that = this
             that.tableData1 = []