1
0
Selaa lähdekoodia

增加三种导出

xwh 4 vuotta sitten
vanhempi
commit
748b35cee0

+ 184 - 9
kmall-admin/src/main/java/com/kmall/admin/controller/statistics/MonthlyCustomersController.java

@@ -1,16 +1,27 @@
 package com.kmall.admin.controller.statistics;
 
+import com.kmall.admin.dao.statistics.MonthlyCustomersDao;
+import com.kmall.admin.dao.statistics.WechatFollowersDao;
+import com.kmall.admin.entity.MonthlySalesGrowthEntity;
+import com.kmall.admin.entity.ProductStoreRelaEntity;
 import com.kmall.admin.entity.WechatFollowersEntity;
 import com.kmall.admin.fromcomm.entity.SysUserEntity;
 import com.kmall.admin.service.statistics.MonthlyCustomersService;
+import com.kmall.admin.utils.ParamUtils;
 import com.kmall.admin.utils.ShiroUtils;
 import com.kmall.common.utils.R;
+import com.kmall.common.utils.excel.ExcelExport;
+import com.kmall.common.utils.excel.ExcelUtil;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -27,6 +38,14 @@ public class MonthlyCustomersController {
     @Autowired
     private MonthlyCustomersService monthlyCustomersService;
 
+    @Autowired
+    private ExcelUtil excelUtil;
+
+    @Autowired
+    private MonthlyCustomersDao monthlyCustomersDao;
+    @Autowired
+    private WechatFollowersDao wechatFollowersDao;
+
 
     private void calculateDifferentMonth(List<String> monthList, String startMonth, String endMonth) throws ParseException {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
@@ -45,7 +64,6 @@ public class MonthlyCustomersController {
 
     @RequestMapping("/customersQuery")
     public R queryMonthlyCustomers(@RequestParam("startMonth") String startMonth, @RequestParam("endMonth") String endMonth) {
-
         List<String> dateList = new ArrayList<>();
         Map<String, Object> returnMap = new HashMap<>();
         try {
@@ -53,15 +71,12 @@ public class MonthlyCustomersController {
         } catch (ParseException e) {
             e.printStackTrace();
         }
-
         try {
             String merchSn = null;
             SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
             if(!"1".equals(sysUser.getRoleType())){
                 merchSn = sysUser.getMerchSn();
             }
-
-
             Map<String,Object> map = monthlyCustomersService.queryMonthlyCustomers(startMonth,endMonth,merchSn);
 
             returnMap.put("dateList", dateList);
@@ -70,9 +85,96 @@ public class MonthlyCustomersController {
             e.printStackTrace();
             return R.error(e.getMessage());
         }
+        return R.ok(returnMap);
+    }
 
+    /**
+     * 每月销售额销售量导出
+     * @param params
+     * @param response
+     * @param request
+     * @return
+     */
+    @RequestMapping("/monthlySalesGrowthExport")
+    public R monthlySalesGrowthExport(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request) {
+        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
+        if (Objects.isNull(params.get("startMonth"))  || "".equals(params.get("startMonth"))){
+            return R.error("请先选择开始时间");
+        }
+        if (Objects.isNull(params.get("endMonth"))  || "".equals(params.get("endMonth"))){
+            return R.error("请先选择结束时间");
+        }
+        String merchSn = null;
+        SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
+        if(!"1".equals(sysUser.getRoleType())){
+            merchSn = sysUser.getMerchSn();
+        }
+        List<MonthlySalesGrowthEntity> monthlySalesGrowthEntities = monthlyCustomersDao.queryMonthlyCustomers((String) params.get("startMonth"), (String) params.get("endMonth"), merchSn);
+        ExcelExport ee = new ExcelExport("Monthly Sales Growth");
+        String[] header = new String[]{"序号","商户编号","商户名称","销售额","销售数量","年-月"};
+        List<Map<String, Object>> list = new ArrayList<>();
+        int count = 1;
+        if (monthlySalesGrowthEntities!=null && monthlySalesGrowthEntities.size()>0) {
+            for (MonthlySalesGrowthEntity monthlySalesGrowthEntity : monthlySalesGrowthEntities) {
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+                map.put("OrderNumber",count++);
+                map.put("MerchSn",monthlySalesGrowthEntity.getMerchSn());
+                map.put("MerchName",monthlySalesGrowthEntity.getMerchName());
+                map.put("TotalSales",monthlySalesGrowthEntity.getTotalSales());
+                map.put("TotalNumber",monthlySalesGrowthEntity.getTotalNumber());
+                map.put("YearAndMonth",monthlySalesGrowthEntity.getYearAndMonth());
+                list.add(map);
+            }
+        }
+        ee.addSheetByMap("Monthly Sales Growth", list, header);
+        ee.export(response);
+        return R.ok();
+    }
 
-        return R.ok(returnMap);
+    /**
+     * 导出销售额销售数客单数客单价
+     * @param params
+     * @param response
+     * @param request
+     * @return
+     */
+    @RequestMapping("/monthlySalesGrowthExport2")
+    public R monthlySalesGrowthExport2(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request) {
+        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
+        if (Objects.isNull(params.get("startMonth")) || "".equals(params.get("startMonth"))){
+            return R.error("请先选择开始时间");
+        }
+        if (Objects.isNull(params.get("endMonth"))  || "".equals(params.get("endMonth"))){
+            return R.error("请先选择结束时间");
+        }
+        String merchSn = null;
+        SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
+        if(!"1".equals(sysUser.getRoleType())){
+            merchSn = sysUser.getMerchSn();
+        }
+        List<MonthlySalesGrowthEntity> monthlySalesGrowthEntities = monthlyCustomersDao.queryMonthlyCustomers((String) params.get("startMonth"), (String) params.get("endMonth"), merchSn);
+        ExcelExport ee = new ExcelExport("Monthly Customers&Avg Basket");
+        String[] header = new String[]{"序号","商户编号","商户名称","销售额","销售数量","客户数","客单价","年-月"};
+        List<Map<String, Object>> list = new ArrayList<>();
+        int count = 1;
+        if (monthlySalesGrowthEntities!=null && monthlySalesGrowthEntities.size()>0) {
+            for (MonthlySalesGrowthEntity monthlySalesGrowthEntity : monthlySalesGrowthEntities) {
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+                map.put("OrderNumber",count++);
+                map.put("MerchSn",monthlySalesGrowthEntity.getMerchSn());
+                map.put("MerchName",monthlySalesGrowthEntity.getMerchName());
+                map.put("TotalSales",monthlySalesGrowthEntity.getTotalSales());
+                map.put("TotalNumber",monthlySalesGrowthEntity.getTotalNumber());
+                map.put("TotalCustomers",monthlySalesGrowthEntity.getTotalCustomers());
+                String avgBasketSale = new BigDecimal(monthlySalesGrowthEntity.getTotalSales()).divide(new BigDecimal(monthlySalesGrowthEntity.getTotalNumber()),3, RoundingMode.HALF_UP).toString();
+                map.put("avgBasketSale",avgBasketSale);
+                map.put("YearAndMonth",monthlySalesGrowthEntity.getYearAndMonth());
+                list.add(map);
+            }
+        }
+        ee.addSheetByMap("Monthly Customers&Avg Basket", list, header);
+        ee.export(response);
+        return R.ok();
     }
 
 
@@ -94,7 +196,13 @@ public class MonthlyCustomersController {
         return R.ok(map);
     }
 
-
+    /**
+     * 每周销售额销售量图表查询
+     * @param startWeek
+     * @param endWeek
+     * @return
+     * @throws ParseException
+     */
     @RequestMapping("/customersQueryByWeek")
     public R queryWeeklyCustomers(@RequestParam("startWeek") String startWeek, @RequestParam("endWeek") String endWeek) throws ParseException {
 
@@ -141,8 +249,66 @@ public class MonthlyCustomersController {
         return R.ok(returnMap);
     }
 
+    @RequestMapping("/weeklySalesSummaryExport")
+    public R weeklySalesSummaryExport(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request) throws ParseException {
+        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
+        if (Objects.isNull(params.get("startWeek"))){
+            return R.error("请先选择开始时间");
+        }
+        if (Objects.isNull(params.get("endWeek"))){
+            return R.error("请先选择结束时间");
+        }
+        String startWeek = (String) params.get("startWeek");
+        String endWeek = (String) params.get("endWeek");
+
+        String merchSn = null;
+        SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
+        if(!"1".equals(sysUser.getRoleType())){
+            merchSn = sysUser.getMerchSn();
+        }
+        SimpleDateFormat weekSdf = new SimpleDateFormat("yyyy");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar bef = Calendar.getInstance();
+        Calendar aft = Calendar.getInstance();
+        bef.setFirstDayOfWeek(Calendar.MONDAY);
+        aft.setFirstDayOfWeek(Calendar.MONDAY);
+        bef.setTime(sdf.parse(startWeek));
+        aft.setTime(sdf.parse(endWeek));
+        int befWeek = bef.get(Calendar.WEEK_OF_YEAR);
+        int aftWeek = aft.get(Calendar.WEEK_OF_YEAR);
+        if(befWeek<10){
+            startWeek =weekSdf.format(bef.getTime())+"-0"+befWeek;
+        }else{
+            startWeek =weekSdf.format(bef.getTime())+"-"+befWeek;
+        }
+        if(aftWeek<10){
+            endWeek =weekSdf.format(aft.getTime())+"-0"+aftWeek;
+        }else{
+            endWeek =weekSdf.format(aft.getTime())+"-"+aftWeek;
+        }
+        List<MonthlySalesGrowthEntity> monthlySalesGrowthEntities = monthlyCustomersDao.queryWeeklyCustomers(startWeek, endWeek, merchSn);
+        ExcelExport ee = new ExcelExport("Weekly Sales Summary");
+        String[] header = new String[]{"序号","商户编号","商户名称","销售额","销售数量","年-周"};
+        List<Map<String, Object>> list = new ArrayList<>();
+        int count = 1;
+        if (monthlySalesGrowthEntities!=null && monthlySalesGrowthEntities.size()>0) {
+            for (MonthlySalesGrowthEntity monthlySalesGrowthEntity : monthlySalesGrowthEntities) {
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+                map.put("OrderNumber",count++);
+                map.put("MerchSn",monthlySalesGrowthEntity.getMerchSn());
+                map.put("MerchName",monthlySalesGrowthEntity.getMerchName());
+                map.put("TotalSales",monthlySalesGrowthEntity.getTotalSales());
+                map.put("TotalNumber",monthlySalesGrowthEntity.getTotalNumber());
+                map.put("YearAndWeek",monthlySalesGrowthEntity.getYearAndWeek());
+                list.add(map);
+            }
+        }
+        ee.addSheetByMap("Weekly Sales Summary", list, header);
+        ee.export(response);
+        return R.ok();
+    }
+
 
-    // todo
     private void calculateDifferentWeek(List<String> weekList, String startWeek, String endWeek) throws ParseException {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat weekSdf = new SimpleDateFormat("yyyy");
@@ -166,7 +332,12 @@ public class MonthlyCustomersController {
     }
 
 
-
+    /**
+     * 每月微信好友图表查询
+     * @param startMonth
+     * @param endMonth
+     * @return
+     */
     @RequestMapping("/queryMonthlyWechatFollowers")
     public R queryMonthlyWechatFollowers(@RequestParam("startMonth") String startMonth, @RequestParam("endMonth") String endMonth) {
         List<String> dateList = new ArrayList<>();
@@ -199,7 +370,11 @@ public class MonthlyCustomersController {
     }
 
 
-
+    /**
+     * 添加微信好友数据
+     * @param wechatFollowers
+     * @return
+     */
     @RequestMapping("/addWechatFollowers")
     public R addWechatFollowers( @RequestParam("wechatFollowers") Integer wechatFollowers) {
 

+ 1 - 0
kmall-admin/src/main/webapp/WEB-INF/page/sale/monthlyCustomers.html

@@ -41,6 +41,7 @@
             <input type="month" name="startMonth" id="startMonth"/>&nbsp;
             <input type="month" name="endMonth" id="endMonth" />&nbsp;
                 <input type="button" name="queryButton" value="查询" onclick="queryMonthly()" />
+                <input type="button" name="exportButton" value="导出" onclick="exportMonthly()" />
             </div>
         </div>
     </header>

+ 1 - 0
kmall-admin/src/main/webapp/WEB-INF/page/sale/monthlySalesGrowth.html

@@ -41,6 +41,7 @@
             <input type="month" name="startMonth" id="startMonth"/>&nbsp;
             <input type="month" name="endMonth" id="endMonth" />&nbsp;
             <input type="button" name="queryButton" value="查询" onclick="queryMonthly()" />
+            <input type="button" name="exportButton" value="导出" onclick="exportMonthly()" />
         </div>
     </div>
 </header>

+ 1 - 0
kmall-admin/src/main/webapp/WEB-INF/page/sale/weeklySalesSummary.html

@@ -41,6 +41,7 @@
             <input type="date" name="startWeek" id="startWeek"/>&nbsp;
             <input type="date" name="endWeek" id="endWeek" />&nbsp;
             <input type="button" name="queryButton" value="查询" onclick="queryWeekly()" />
+            <input type="button" name="exportButton" value="导出" onclick="exportWeekly()" />
         </div>
     </div>
 </header>

+ 13 - 0
kmall-admin/src/main/webapp/js/sale/monthlyCustomers.js

@@ -196,6 +196,19 @@ function queryMonthly(){
 
 }
 
+function exportMonthly(){
+    var startMonth = document.getElementById("startMonth").value;
+    var endMonth = document.getElementById("endMonth").value;
+
+    var params = {
+        startMonth:startMonth,
+        endMonth:endMonth
+    };
+    console.log(params);
+    exportFile('#rrapp', '../monthly/monthlySalesGrowthExport2', params);
+
+}
+
 
 let vm = new Vue({
     el: '#rrapp',

+ 10 - 286
kmall-admin/src/main/webapp/js/sale/monthlySalesGrowth.js

@@ -40,11 +40,6 @@ var dChart = echarts.init(document.getElementById('main3'));
 // 指定图表的配置项和数据
 function dFun(dateList, totalNumberList, totalSalesList) {
     dChart.setOption({
-        // title: {
-        //     left: 'left',
-        //     text: '概率',
-        //     show: false
-        // },
         tooltip: {
             trigger: 'axis',
             // formatter: '{a}:{c}',
@@ -61,18 +56,6 @@ function dFun(dateList, totalNumberList, totalSalesList) {
             right: '4%',
             bottom: '10%'
         },
-        // legend: {
-        //     show: true,
-        //     selectedMode: 'single', // 设置显示单一图例的图形,点击可切换
-        //     bottom: 10,
-        //     left: 50,
-        //     textStyle: {
-        //         color: '#666',
-        //         fontSize: 12
-        //     },
-        //     itemGap: 20,
-        //     inactiveColor: '#ccc'
-        // },
         xAxis: {
             // splitLine: {     show: false   },
             type: 'category',
@@ -179,274 +162,15 @@ function queryMonthly(){
 }
 
 
-let vm = new Vue({
-    el: '#rrapp',
-    data: {
-        date: '',
-        refreshTime: 10,
-        type: 'store',
-        refreshCount:0,
-
-        storeId: '',
-        merchSn: '',
-        merchName: '',
-        storeName: '',
-        salesDate: '',
-        totalSales: '',
-        actualSales: '',
-        preferentialLoss: '',
-        totalCost: '',
-        grossProfit: '',
-        grossProfitRatio: '',
-        proportion: '',
-        guestNumber: '',
-        guestUnitPrice: '',
-        lastSalesTime: '',
-        categoryId: '',
-        categoryName: '',
-
-        showList: false,
-        compareDate: '',//比较日期
-        storeId2: '',
-        merchSn2: '',
-        merchName2: '',
-        storeName2: '',
-        salesDate2: '',
-        totalSales2: '',
-        actualSales2: '',
-        preferentialLoss2: '',
-        totalCost2: '',
-        grossProfit2: '',
-        grossProfitRatio2: '',
-        proportion2: '',
-        guestNumber2: '',
-        guestUnitPrice2: '',
-        lastSalesTime2: '',
-        intervalId: 0,
-        isCompare: false,
-        compare2: '',
-
-
-        temp: {
-            date: '',
-            refreshTime: 10,
-            type: '',
-            storeId: '',
-            merchSn: '',
-            salesDate: '',
-            categoryId: ''
-        },
-
-
-        rateList: [
-            {
-                id: '0',
-                name: '含税'
-            },
-            {
-                id: '1',
-                name: '不含税'
-
-            }
-        ],
-        projectList: [
-            {
-                id: '0',
-                name: '销售总额'
-            },
-            {
-                id: '1',
-                name: '客单价'
-
-            }
-        ],
-        seriesTypeList: [
-            {
-                id: 'bar',
-                name: '垂直柱状图'
-            },
-            {
-                id: 'line',
-                name: '折线图'
-
-            },
-            {
-                id: 'pie',
-                name: '饼图'
-
-            }
-        ],
-        formatsList: [
-            {
-                id: '0',
-                name: '<全部>'
-            },
-            {
-                id: '1',
-                name: '<非全部>'
-
-            }
-        ],
-        salesList: [
-            {
-                store: {storeId: '11106', storeName: '前海店'},
-                totalSales: 43046.18,
-                actualSales: 35593.46
-            }
-        ],
-        dept: {
-            deptId: '',
-            deptName: ''
-        },
-        category: {
-            categoryId: '',
-            categoryName: ''
-        },
-        seriesList: [], //保存饼图数据
-        seriesList2: [],
-        xAxisList: {    //主要用于保存 启动刷新时的条件和数据
-            storeId: '',
-            storeName: '',
-            merchSn: '',
-            merchName: '',
-            totalSales: '',
-            actualSales: '',
-            preferentialLoss: '',
-            totalCost: '',
-            grossProfit: '',
-            grossProfitRatio: '',
-            proportion: '',
-            guestNumber: '',
-            guestUnitPrice: '',
-            lastSalesTime: '',
-
-            salesDate: '0',
-            projectSelect: '0',
-            type:''
-        },
-        dataList: [],
-        tooltip: {},
-        today:''
-    },
-    created() {
-        this.rateSelect = this.rateList[0].id;
-        this.projectSelect = this.projectList[0].id;
-        this.seriesTypeSelect = this.seriesTypeList[0].id;
-        this.formatsSelect = this.formatsList[0].id;
-    },
-    methods: {
-
-        seriesTypeSwitch: function () {
-            console.log(vm.seriesTypeSelect);
-        },
-        showEcharts: function () {
-            // 基于准备好的dom,初始化echarts实例
-            myChart = echarts.init(document.getElementById('main'));
-            myChart.clear();
-            //加载动画
-            myChart.showLoading();
-
-
-            //项目下拉框判断       6-19,饼图设置 vm.xAxisList
-            var temp = '';
-            if (vm.xAxisList.projectSelect == '0') {
-                if (vm.xAxisList.type == 'dept') {
-                    temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/销售总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
-                } else {
-                    temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/销售总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
-                }
-                vm.seriesList2.push(vm.xAxisList.totalSales);
-                vm.seriesList.push({value: vm.xAxisList.totalSales, name: temp});
-
-            } else if (vm.xAxisList.projectSelect == '1') {
-                if (vm.xAxisList.type == 'dept') {
-                    temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
-                } else {
-                    temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
-                }
-                vm.seriesList2.push(vm.xAxisList.guestUnitPrice);
-                vm.seriesList.push({value: vm.xAxisList.guestUnitPrice, name: temp});
-
-            }
-
-            vm.dataList = [temp];
-
-            if (vm.seriesTypeSelect == "pie") {
-                vm.seriesList2 = vm.seriesList.concat();
-            }
-
-            // console.log('vm.seriesList2');
-            // console.log(vm.seriesList2);
-
-            // 指定图表的配置项和数据
-            //销售量
-            var option = {
-                title: {
-                    // textAlign: 'right',
-                    text: 'Monthly Customers & Avg Basket',
-                    x: 'center',
-                    textStyle: {
-                        //文字颜色
-                        color: '#17233d',
-                        //字体风格,'normal','italic','oblique'
-                        fontStyle: 'normal',
-                        //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
-                        fontWeight: 'bold',
-                        //字体系列
-                        fontFamily: 'sans-serif',
-                        //字体大小
-                        fontSize: 28
-                    }
-                },
-                tooltip: {
-                    formatter: function (params) {
-                        return params.name;
-                    }
-                },
-                legend: {
-                    data: ['/销售总额']
-                },
-                xAxis: {
-                    data: vm.dataList,
-                    axisLabel: {
-                        interval: 0
-                    }
-                },
-                yAxis: {},
-                series: [{
-                    barMaxWidth: '20%',
-                    barWidth: '50%',
-                    radius: '55%',
-                    roseType: 'angle',
-                    type: vm.seriesTypeSelect,
-                    color: ['#dd6b66', '#759aa0'],
-                    data: vm.seriesList2
-                }]
-            };
-
-            //隐藏
-            myChart.hideLoading();
-            // 使用刚指定的配置项和数据显示图表。
-            myChart.setOption(option);
-
-        },
-        tooltipFormatter: function () {
-            if (vm.type == 'dept') {
-                return '[' + vm.merchSn + ']' + vm.merchName + '/销售总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
-            }
-            return '[' + vm.storeId + ']' + vm.storeName + '/销售总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
-        },
-        showTable: function (postParam) {
-
-            console.log(postParam);
+function exportMonthly(){
+    var startMonth = document.getElementById("startMonth").value;
+    var endMonth = document.getElementById("endMonth").value;
 
-            $("#jqGrid").jqGrid('setGridParam', {
-                postData: postParam
+    var params = {
+        startMonth:startMonth,
+        endMonth:endMonth
+    };
+    console.log(params);
+    exportFile('#rrapp', '../monthly/monthlySalesGrowthExport', params);
 
-            }).trigger("reloadGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
-        },
-        switchProjectView: function () {
-            console.log(vm.projectSelect);
-        }
-    }
-});
+}

+ 10 - 270
kmall-admin/src/main/webapp/js/sale/weeklySalesSummary.js

@@ -170,7 +170,6 @@ function queryWeekly(){
         contentType:"application/x-www-form-urlencoded",
         type: 'POST',
         success: function(data) {
-            console.log(JSON.stringify(data))
             dFun(data.dateList, data.totalNumberList, data.totalSalesList);
 
         },
@@ -179,274 +178,15 @@ function queryWeekly(){
 }
 
 
-let vm = new Vue({
-    el: '#rrapp',
-    data: {
-        date: '',
-        refreshTime: 10,
-        type: 'store',
-        refreshCount:0,
-
-        storeId: '',
-        merchSn: '',
-        merchName: '',
-        storeName: '',
-        salesDate: '',
-        totalSales: '',
-        actualSales: '',
-        preferentialLoss: '',
-        totalCost: '',
-        grossProfit: '',
-        grossProfitRatio: '',
-        proportion: '',
-        guestNumber: '',
-        guestUnitPrice: '',
-        lastSalesTime: '',
-        categoryId: '',
-        categoryName: '',
-
-        showList: false,
-        compareDate: '',//比较日期
-        storeId2: '',
-        merchSn2: '',
-        merchName2: '',
-        storeName2: '',
-        salesDate2: '',
-        totalSales2: '',
-        actualSales2: '',
-        preferentialLoss2: '',
-        totalCost2: '',
-        grossProfit2: '',
-        grossProfitRatio2: '',
-        proportion2: '',
-        guestNumber2: '',
-        guestUnitPrice2: '',
-        lastSalesTime2: '',
-        intervalId: 0,
-        isCompare: false,
-        compare2: '',
-
-
-        temp: {
-            date: '',
-            refreshTime: 10,
-            type: '',
-            storeId: '',
-            merchSn: '',
-            salesDate: '',
-            categoryId: ''
-        },
-
-
-        rateList: [
-            {
-                id: '0',
-                name: '含税'
-            },
-            {
-                id: '1',
-                name: '不含税'
-
-            }
-        ],
-        projectList: [
-            {
-                id: '0',
-                name: '销售总额'
-            },
-            {
-                id: '1',
-                name: '客单价'
-
-            }
-        ],
-        seriesTypeList: [
-            {
-                id: 'bar',
-                name: '垂直柱状图'
-            },
-            {
-                id: 'line',
-                name: '折线图'
-
-            },
-            {
-                id: 'pie',
-                name: '饼图'
-
-            }
-        ],
-        formatsList: [
-            {
-                id: '0',
-                name: '<全部>'
-            },
-            {
-                id: '1',
-                name: '<非全部>'
-
-            }
-        ],
-        salesList: [
-            {
-                store: {storeId: '11106', storeName: '前海店'},
-                totalSales: 43046.18,
-                actualSales: 35593.46
-            }
-        ],
-        dept: {
-            deptId: '',
-            deptName: ''
-        },
-        category: {
-            categoryId: '',
-            categoryName: ''
-        },
-        seriesList: [], //保存饼图数据
-        seriesList2: [],
-        xAxisList: {    //主要用于保存 启动刷新时的条件和数据
-            storeId: '',
-            storeName: '',
-            merchSn: '',
-            merchName: '',
-            totalSales: '',
-            actualSales: '',
-            preferentialLoss: '',
-            totalCost: '',
-            grossProfit: '',
-            grossProfitRatio: '',
-            proportion: '',
-            guestNumber: '',
-            guestUnitPrice: '',
-            lastSalesTime: '',
-
-            salesDate: '0',
-            projectSelect: '0',
-            type:''
-        },
-        dataList: [],
-        tooltip: {},
-        today:''
-    },
-    created() {
-        this.rateSelect = this.rateList[0].id;
-        this.projectSelect = this.projectList[0].id;
-        this.seriesTypeSelect = this.seriesTypeList[0].id;
-        this.formatsSelect = this.formatsList[0].id;
-    },
-    methods: {
-
-        seriesTypeSwitch: function () {
-            console.log(vm.seriesTypeSelect);
-        },
-        showEcharts: function () {
-            // 基于准备好的dom,初始化echarts实例
-            myChart = echarts.init(document.getElementById('main'));
-            myChart.clear();
-            //加载动画
-            myChart.showLoading();
-
-
-            //项目下拉框判断       6-19,饼图设置 vm.xAxisList
-            var temp = '';
-            if (vm.xAxisList.projectSelect == '0') {
-                if (vm.xAxisList.type == 'dept') {
-                    temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/销售总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
-                } else {
-                    temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/销售总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
-                }
-                vm.seriesList2.push(vm.xAxisList.totalSales);
-                vm.seriesList.push({value: vm.xAxisList.totalSales, name: temp});
-
-            } else if (vm.xAxisList.projectSelect == '1') {
-                if (vm.xAxisList.type == 'dept') {
-                    temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
-                } else {
-                    temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
-                }
-                vm.seriesList2.push(vm.xAxisList.guestUnitPrice);
-                vm.seriesList.push({value: vm.xAxisList.guestUnitPrice, name: temp});
-
-            }
-
-            vm.dataList = [temp];
-
-            if (vm.seriesTypeSelect == "pie") {
-                vm.seriesList2 = vm.seriesList.concat();
-            }
-
-            // console.log('vm.seriesList2');
-            // console.log(vm.seriesList2);
-
-            // 指定图表的配置项和数据
-            //销售量
-            var option = {
-                title: {
-                    // textAlign: 'right',
-                    text: 'Monthly Customers & Avg Basket',
-                    x: 'center',
-                    textStyle: {
-                        //文字颜色
-                        color: '#17233d',
-                        //字体风格,'normal','italic','oblique'
-                        fontStyle: 'normal',
-                        //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
-                        fontWeight: 'bold',
-                        //字体系列
-                        fontFamily: 'sans-serif',
-                        //字体大小
-                        fontSize: 28
-                    }
-                },
-                tooltip: {
-                    formatter: function (params) {
-                        return params.name;
-                    }
-                },
-                legend: {
-                    data: ['/销售总额']
-                },
-                xAxis: {
-                    data: vm.dataList,
-                    axisLabel: {
-                        interval: 0
-                    }
-                },
-                yAxis: {},
-                series: [{
-                    barMaxWidth: '20%',
-                    barWidth: '50%',
-                    radius: '55%',
-                    roseType: 'angle',
-                    type: vm.seriesTypeSelect,
-                    color: ['#dd6b66', '#759aa0'],
-                    data: vm.seriesList2
-                }]
-            };
-
-            //隐藏
-            myChart.hideLoading();
-            // 使用刚指定的配置项和数据显示图表。
-            myChart.setOption(option);
-
-        },
-        tooltipFormatter: function () {
-            if (vm.type == 'dept') {
-                return '[' + vm.merchSn + ']' + vm.merchName + '/销售总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
-            }
-            return '[' + vm.storeId + ']' + vm.storeName + '/销售总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
-        },
-        showTable: function (postParam) {
-
-            console.log(postParam);
+function exportWeekly(){
+    var startWeek = document.getElementById("startWeek").value;
+    var endWeek = document.getElementById("endWeek").value;
 
-            $("#jqGrid").jqGrid('setGridParam', {
-                postData: postParam
+    var params = {
+        startWeek:startWeek,
+        endWeek:endWeek
+    };
+    console.log(params);
+    exportFile('#rrapp', '../monthly/weeklySalesSummaryExport', params);
 
-            }).trigger("reloadGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
-        },
-        switchProjectView: function () {
-            console.log(vm.projectSelect);
-        }
-    }
-});
+}