马宇豪
2024-04-15 b6a27b9ca71d636a1598751f8114c36a5d7007fe
src/views/warehouse/stockAnalyse.vue
@@ -1,7 +1,7 @@
<template>
    <div class="app-container">
        <div class="filter-container">
            <div style="display: block;">
            <div style="display: block;" v-show="disable == false">
<!--                <div class="basic_search">-->
<!--                    <span>区域:</span>-->
<!--                    <el-select v-model="listQuery.province" clearable filterable @change="changeArea('province')">-->
@@ -67,7 +67,7 @@
                <el-table-column label="库区" prop="reserveName" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.reserveName =='合计'">{{scope.row.reserveName}}</span>
                        <el-link v-else type="primary" @click="openStock('edit',scope.row)">{{scope.row.reserveName}}</el-link>
                        <el-link v-else type="primary" @click="openStock('view',scope.row)">{{scope.row.reserveName}}</el-link>
                    </template>
                </el-table-column>
                <el-table-column label="库区总库存" prop="gName" align="center"></el-table-column>
@@ -106,7 +106,7 @@
                <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
                    <template slot-scope="scope" v-if="scope.row.storehouseName !== '本库区合计' && scope.row.storehouseName !== '合计'">
                        <el-button type="text" @click="showEnterprises(scope.row)">查看详情</el-button>
                        <el-button type="text" @click="delData(scope.row)">删除</el-button>
<!--                        <el-button type="text" @click="delData(scope.row)">删除</el-button>-->
                    </template>
                </el-table-column>
            </el-table>
@@ -150,14 +150,16 @@
    },
    created() {
        const t = this
        t.getList()
        t.getProvince()
        const roles = JSON.parse(Cookies.get('roles'))
        if(roles.find(i=>i.name == '管理员'|| i.name == '监管部门')){
            this.disable = false
            t.listQuery.enterpriseName = ''
        }else{
            this.disable = true
            t.listQuery.enterpriseName = Cookies.get('company')
        }
        t.getList()
        t.getProvince()
    },
    mounted() {
    },
@@ -180,14 +182,21 @@
                                content['gName'] = item.enterpriseName
                                // 重点!赋值合并的行数数值,只需要取子循环的第一个数赋值待合并的行数即可
                                if(subIndex == 0){
                                    content['gNum'] = item.reserves.length
                                    let gNum = 0
                                    for(let i of item.reserves){
                                        if(i.storehouse && i.storehouse.warehouses && Array.isArray(i.storehouse.warehouses)){
                                            gNum= gNum + i.storehouse.warehouses.length + 1
                                        }else{
                                            gNum = gNum + 0
                                        }
                                    }
                                    content['gNum'] = gNum
                                }
                                gData.push(content)
                            })
                        }
                    })
                }
                console.log(gData,'gData')
                if(Array.isArray(gData)){
                    gData.map(item=>{
                        if(Array.isArray(item.storehouse.warehouses) && item.storehouse.whTotal){
@@ -212,8 +221,10 @@
                            item.storehouse.warehouses.map((subRes, subIndex)=>{
                                let content2 = {}
                                content2 = subRes
                                content2['gId'] = item.enterpriseId
                                content2['gId'] = item.gId
                                content2['ggId'] = item.enterpriseId
                                content2['gStock'] = item.gStock
                                content2['enterpriseName'] = item.enteripriseName
                                content2['gName'] = item.gName
                                content2['gNum'] = item.gNum || null
                                content2['topId'] = item.reserveId
@@ -237,6 +248,7 @@
                        topId: null,
                        reserveName: total.name,
                        gId: null,
                        ggId: null,
                        gName: total.name,
                        gStock: total.enterpriseTotalStock,
                        storehouseName: total.name,
@@ -281,7 +293,7 @@
        showEnterprises(row){
            const t = this
            t.$refs.enterStock.open(row)
            t.$refs.enterStock.open(row,'汇总')
        },
        openStock(type,data){
@@ -373,8 +385,8 @@
            // columnIndex 代表列数,从0开始计数,我们要合并的字段属于第一列,取0
            if(columnIndex ==0 || columnIndex ==1){
                return {
                    rowspan: row.gNum * row.rowNum, // 待合并行数 -- 合并的行数长度就等于之前赋值的子数据的长度;未赋值的即表示0,不显示
                    colspan: row.gNum>0?1:0  // 待合并列数 -- 合并的列数自身占一列,被合并的要返回0,表示不显示
                    rowspan: row.gNum, // 待合并行数 -- 合并的行数长度就等于之前赋值的子数据的长度;未赋值的即表示0,不显示
                    colspan: row.rowNum>0?1:0  // 待合并列数 -- 合并的列数自身占一列,被合并的要返回0,表示不显示
                };
            }
            if(columnIndex >1 && columnIndex < 7){