Parcourir la source

Merge branch 'master' of hhq/kmall-pt-general into master

张创标 il y a 4 ans
Parent
commit
52657b34de

+ 6 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/RealtimeSalesDetectionServiceImpl.java

@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -33,6 +34,11 @@ public class RealtimeSalesDetectionServiceImpl implements RealtimeSalesDetection
             }
             //计算客单价
             r.setGuestUnitPrice(r.getActualSales().divide(new BigDecimal(r.getGuestNumber()),2));
+
+            //时区-13小时
+            Date lastSalesTime = r.getLastSalesTime();
+            lastSalesTime.setTime(r.getLastSalesTime().getTime() - 13*60*60*1000);
+            r.setLastSalesTime(lastSalesTime);
         }
         return r;
     }

+ 52 - 36
kmall-admin/src/main/webapp/WEB-INF/page/sale/realtimeSalesDetection.html

@@ -13,10 +13,10 @@
             color: #515a6e;
         }
 
-        span, button, select, input {
-            font-size: 18px;
-            font-family: 微软雅黑;
-        }
+        /*span, button, select, input {*/
+            /*font-size: 18px;*/
+            /*font-family: 微软雅黑;*/
+        /*}*/
 
         #refreshTime, #storeId, #categoryId {
             width: 100px;
@@ -41,14 +41,37 @@
 <div id="rrapp" v-cloak>
     <header class="main-header">
         <div class="container-fluid  coldiv">
+
+
+            <div class="row" style="border:0;margin-bottom:10px">
+                <div class="col-md-12 ">
+                    <span>门店编号:</span><input v-model="storeId" id="storeId"/>
+                    <span style="color: red;margin: 10px">{{storeName}}</span>
+                    <span>品类编号:</span><input v-model="categoryId" id="categoryId"/>
+                    <span style="color: red;margin: 10px">{{categoryName}}</span>
+                <!--</div>-->
+                <!--</div>-->
+                <!--<div class="row" style="border:0;margin-bottom:10px">-->
+                <!--<div class="col-md-12 ">-->
+                    <span>部门编号:</span><input v-model="merchSn" id="merchSn"/>
+                    <span style="color: red;margin: 10px">{{merchName}}</span> &nbsp;&nbsp;
+                    <span>业态:</span>
+                    <!--业态下拉框-->
+                    <select name="formatsSelect" v-model="formatsSelect" disabled>
+                        <option :value="formats.id" v-for="formats in formatsList">{{formats.name}}</option>
+                    </select>&nbsp;
+                </div>
+            </div>
+
+
             <div class="row" style="border:0;margin-bottom:10px">
                 <div class="col-md-12">
 
                     <span>日期:</span>
                     <input type="date" name="salesDate" id="salesDate" v-model="salesDate"/>&nbsp;
                     <span>刷新间隔:</span>
-                    <input type="number" name="refreshTime" v-model="refreshTime" id="refreshTime"
-                           oninput="if(value > 1000 || value < 1 ){alert('非法输入!');value = ''}"/>
+                    <input type="number" name="refreshTime" v-model="refreshTime" id="refreshTime" min="10" max="100000"
+                           oninput="if(value > 1000 || value < 0 ){alert('非法输入!');value = '10'}"/>
                     <span>秒</span>&nbsp;
 
 
@@ -68,41 +91,34 @@
                     <select name="rateSelect" v-model="rateSelect" disabled>
                         <option :value="rate.id" v-for="rate in rateList">{{rate.name}}</option>
                     </select>
-                </div>
-            </div>
 
-            <div class="row" style="border:0;margin-bottom:10px">
-                <div class="col-md-12 ">
-                    <span>门店编号:</span><input v-model="storeId" id="storeId"/>
-                    <span style="color: red;margin: 10px">{{storeName}}</span>
-                    <span>品类编号:</span><input v-model="categoryId" id="categoryId"/>
-                    <span style="color: red;margin: 10px">{{categoryName}}</span>
-                </div>
-            </div>
-            <div class="row" style="border:0;margin-bottom:10px">
-                <div class="col-md-12 ">
-                    <span>部门编号:</span><input v-model="merchSn" id="merchSn"/>
-                    <span style="color: red;margin: 10px">{{merchName}}</span> &nbsp;&nbsp;
-                    <span>业态:</span>
-                    <!--业态下拉框-->
-                    <select name="formatsSelect" v-model="formatsSelect" disabled>
-                        <option :value="formats.id" v-for="formats in formatsList">{{formats.name}}</option>
-                    </select>&nbsp;
-                </div>
-            </div>
-            <div class="row" style="border:0;margin-bottom:10px">
-                <div class="col-md-12 ">
-                    <i-button style="margin-right: 10px" type="primary" icon="refresh" size="24px" v-on:click="refresh"
-                              id="refresh">刷新
-                    </i-button>
-                    <i-button style="margin-right: 10px" type="info" icon="arrow-down-c" v-on:click="saveFlushTime"
-                              id="saveFlushTime">保存条件
+
+                    <i-button style="margin-right: 10px" type="primary" v-on:click="refreshButton"
+                              id="refresh">启动刷新
+                    </i-button>(日期为<span style="color: red">当天日期</span>会根据<span style="color: red">刷新间隔</span>自动刷新)
+
                     </i-button>
-                    <i-button type="warning" icon="close" v-on:click="clearFlushTime" id="clearFlushTime">清除条件
+                    <i-button type="warning"v-on:click="clearFlushTime" id="clearFlushTime">停止刷新
                     </i-button>
+                    <!--<i-button style="margin-right: 10px" type="primary" v-on:click="refresh"-->
+                              <!--id="refresh">启动刷新-->
+                    <!--</i-button>-->
                 </div>
             </div>
 
+            <!--<div class="row" style="border:0;margin-bottom:10px">-->
+                <!--<div class="col-md-12 ">-->
+                    <!--<i-button style="margin-right: 10px" type="primary" icon="refresh" size="24px" v-on:click="refresh"-->
+                              <!--id="refresh">刷新-->
+                    <!--</i-button>-->
+                    <!--<i-button style="margin-right: 10px" type="info" icon="arrow-down-c" v-on:click="saveFlushTime"-->
+                              <!--id="saveFlushTime">保存条件-->
+                    <!--</i-button>-->
+                    <!--<i-button type="warning" icon="close" v-on:click="clearFlushTime" id="clearFlushTime">清除条件-->
+                    <!--</i-button>-->
+                <!--</div>-->
+            <!--</div>-->
+
             <div class="row" style="border:0;margin-bottom:10px">
                 <div class="col-md-12 ">
                     <span>项目:</span>
@@ -112,7 +128,7 @@
                     </select>&nbsp;
                     <span>比较日期:</span>
                     <input type="date" name="compareDate" id="compareDate" v-model="compareDate"/> &nbsp;
-                    <i-button style="margin-right: 10px" type="primary" shape="circle" icon="arrow-swap"
+                    <i-button style="margin-right: 10px" type="info" shape="circle"
                               v-on:click="compare" id="clearFlushTime">比较
                     </i-button>
 

+ 439 - 182
kmall-admin/src/main/webapp/js/sale/realtimeSalesDetection.js

@@ -1,60 +1,83 @@
 $(function () {
 
-vm.showEcharts();
-console.log(1);
-
-$("#jqGrid").jqGrid({
-    url:'../realtimeSalesDetection/query',
-    datatype: "json",
-    colModel: [
-        {label: '门店编码', name: 'storeId', index: 'storeId', width: 80},
-        {label: '门店名称', name: 'storeName', index: 'storeName', width: 120},
-        {label: '商户编码', name: 'merchSn', index: 'storeId', width: 220},
-        {label: '商户名称', name: 'merchName', index: 'storeName', width: 120},
-        {label: '售价总额', name: 'totalSales', index: 'totalSales',align: 'right',width: 80},
-        {label: '实际销售额', name: 'actualSales', index: 'actualSales',align: 'right',width: 80},
-        {label: '占比 %', name: 'proportion', index: 'proportion',align: 'right',width: 60},
-        {label: '优惠损失', name: 'preferentialLoss', index: 'preferentialLoss',align: 'right',width: 80},
-        {label: '成本总额', name: 'totalCost', index: 'totalCost',align: 'right',width: 80},
-        {label: '毛利', name: 'grossProfit', index: 'grossProfit',align: 'right',width: 80},
-        {label: '毛利率', name: 'grossProfitRatio', index: 'grossProfitRatio',align: 'right',width: 60},
-        {label: '来客数', name: 'guestNumber', index: 'guestNumber',align: 'right',width: 100},
-        {label: '客单价', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 80},
-
-        {label: '最后销售时间', name: 'lastSalesTime', index: 'lastSalesTime', align: 'center',width: 180,formatter: function (value) {
-                return transDate(value,'yyyy-MM-dd hh:mm:ss');
-            }}
-        // {label: '说明', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 80}
-    ],
-    viewrecords: true,
-    height: 200,
-    rowNum: 10,
-    rowList: [10, 30, 50],
-    rownumbers: true,
-    rownumWidth: 25,
-    autowidth: true,
-    shrinkToFit: false,
-    autoScroll: true,   //开启水平滚动条
-    width: 1500,
-    multiselect: true,
-    pager: "#jqGridPager",
-    jsonReader: {
-        root: "page.list",
-        page: "page.currPage",
-        total: "page.totalPage",
-        records: "page.totalCount"
-    },
-    prmNames: {
-        page: "page",
-        rows: "limit",
-        order: "order"
-    },
-    gridComplete: function () {
-        $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
-    }
-});
+    vm.showEcharts();
+    var date = new Date();
+    var year = date.getFullYear();
+    var month = ('0'+ (date.getMonth() + 1)).slice(-2);
+    var day = ('0' + date.getDate()).slice(-2);
+    var time = year +'-'+ month +'-'+ day;
+    console.log('time');
+    console.log(time);
+    // document.getElementById('salesDate').value = time;
+    //限制不能选择今天之后的日期(加du上属性max)
+    document.getElementById('salesDate').setAttribute('max', time);
+
+    var dateTime = date.setDate(date.getDate()-1);
+    date=new Date(dateTime);
+    day = ('0' + date.getDate()).slice(-2);
+    var time3 = year +'-'+ month +'-'+ day;
+    document.getElementById('compareDate').setAttribute('max', time3);
+
+
+    $("#jqGrid").jqGrid({
+        url: '../realtimeSalesDetection/query',
+        datatype: "json",
+        colModel: [
+            {label: '门店编码', name: 'storeId', index: 'storeId', width: 80},
+            {label: '门店名称', name: 'storeName', index: 'storeName', width: 120},
+            {label: '商户编码', name: 'merchSn', index: 'storeId', width: 220},
+            {label: '商户名称', name: 'merchName', index: 'storeName', width: 120},
+            {label: '售价总额', name: 'totalSales', index: 'totalSales', align: 'right', width: 80},
+            {label: '实际销售额', name: 'actualSales', index: 'actualSales', align: 'right', width: 80},
+            {label: '占比 %', name: 'proportion', index: 'proportion', align: 'right', width: 60},
+            {label: '优惠损失', name: 'preferentialLoss', index: 'preferentialLoss', align: 'right', width: 80},
+            {label: '成本总额', name: 'totalCost', index: 'totalCost', align: 'right', width: 80},
+            {label: '毛利', name: 'grossProfit', index: 'grossProfit', align: 'right', width: 80},
+            {label: '毛利率', name: 'grossProfitRatio', index: 'grossProfitRatio', align: 'right', width: 60},
+            {label: '来客数', name: 'guestNumber', index: 'guestNumber', align: 'right', width: 100},
+            {label: '客单价', name: 'guestUnitPrice', index: 'guestUnitPrice', align: 'right', width: 80},
+
+            {
+                label: '最后销售时间',
+                name: 'lastSalesTime',
+                index: 'lastSalesTime',
+                align: 'center',
+                width: 180,
+                formatter: function (value) {
+                    return transDate(value, 'yyyy-MM-dd hh:mm:ss');
+                }
+            }
+            // {label: '说明', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 80}
+        ],
+        viewrecords: true,
+        height: 200,
+        rowNum: 10,
+        rowList: [10, 30, 50],
+        rownumbers: true,
+        rownumWidth: 25,
+        autowidth: true,
+        shrinkToFit: false,
+        autoScroll: true,   //开启水平滚动条
+        width: 1500,
+        multiselect: true,
+        pager: "#jqGridPager",
+        jsonReader: {
+            root: "page.list",
+            page: "page.currPage",
+            total: "page.totalPage",
+            records: "page.totalCount"
+        },
+        prmNames: {
+            page: "page",
+            rows: "limit",
+            order: "order"
+        },
+        gridComplete: function () {
+            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
+        }
+    });
 });
-var myChart ;
+var myChart;
 
 let vm = new Vue({
     el: '#rrapp',
@@ -81,7 +104,7 @@ let vm = new Vue({
         categoryId: '',
         categoryName: '',
 
-        showList:false ,
+        showList: false,
         compareDate: '',//比较日期
         storeId2: '',
         merchSn2: '',
@@ -98,7 +121,21 @@ let vm = new Vue({
         guestNumber2: '',
         guestUnitPrice2: '',
         lastSalesTime2: '',
-        intervalId:0,
+        intervalId: 0,
+        isCompare: false,
+        compare2: '',
+
+
+        temp: {
+            date: '',
+            refreshTime: 10,
+            type: '',
+            storeId: '',
+            merchSn: '',
+            salesDate: '',
+            categoryId: ''
+        },
+
 
         rateList: [
             {
@@ -157,18 +194,35 @@ let vm = new Vue({
             }
         ],
         dept: {
-            deptId:'',
-            deptName:''
+            deptId: '',
+            deptName: ''
         },
         category: {
-            categoryId:'',
+            categoryId: '',
             categoryName: ''
         },
-        seriesList:[], //保存饼图数据
-        seriesList2:[],
-        xAxisList:[],
+        seriesList: [], //保存饼图数据
+        seriesList2: [],
+        xAxisList: {
+            storeId: '',
+            storeName: '',
+            merchSn: '',
+            merchName: '',
+            totalSales: '',
+            actualSales: '',
+            preferentialLoss: '',
+            totalCost: '',
+            grossProfit: '',
+            grossProfitRatio: '',
+            proportion: '',
+            guestNumber: '',
+            guestUnitPrice: '',
+            lastSalesTime: '',
+            salesDate: '0',
+            projectSelect: '0'
+        },
         dataList: [],
-        tooltip:{}
+        tooltip: {}
     },
     created() {
         this.rateSelect = this.rateList[0].id;
@@ -177,47 +231,51 @@ let vm = new Vue({
         this.formatsSelect = this.formatsList[0].id;
     },
     methods: {
-        addParam:function(postParam,dateType){ //添加请求参数, dateType: 0刷新,1比较
+        addParam: function (postParam, dateType) { //添加请求参数, dateType: 0刷新,1比较
             // var currentDate = new Date();
             // currentDate = currentDate.getFullYear()+'-'+(currentDate.getMonth()+1)+'-'+currentDate.getDate();
-            postParam={};
-            if(vm.type=="store"){
+            postParam = {};
+            if (!(Math.floor(vm.refreshTime) == vm.refreshTime && vm.refreshTime % 1 === 0 && vm.refreshTime >= 10)) {
+                alert("刷新间隔请输入10秒以上的整数!");
+                return false;
+            }
+            if (vm.type == "store") {
                 // vm.storeId = '10'; //测试
-                if(vm.storeId==''||vm.storeId==null){
+                if (vm.storeId == '' || vm.storeId == null) {
                     alert("请在输入框中输入门店编号!");
                     return false;
                 }
                 postParam.storeId = vm.storeId;
-            }else if(vm.type=="dept"){
-                if(vm.merchSn==''||vm.merchSn==null){
+            } else if (vm.type == "dept") {
+                if (vm.merchSn == '' || vm.merchSn == null) {
                     alert("请在输入框中输入部门编号!");
                     return false;
                 }
                 postParam.merchSn = vm.merchSn;
-            }else if(vm.type=="category"){
-                if(vm.storeId==''||vm.storeId==null){
+            } else if (vm.type == "category") {
+                if (vm.storeId == '' || vm.storeId == null) {
                     alert("请在输入框中输入门店编号和品类编号!");
                     return false;
                 }
-                if(vm.categoryId==''||vm.categoryId==null){
+                if (vm.categoryId == '' || vm.categoryId == null) {
                     alert("请在输入框中输入品类编号!");
                     return false;
                 }
                 postParam.storeId = vm.storeId;
                 postParam.categoryId = vm.categoryId;
-            }else{
-                alert("请选中查询条件(门店、部门、品类,选中一个)"+vm.type);
+            } else {
+                alert("请选中查询条件(门店、部门、品类,选中一个)" + vm.type);
                 return false;
             }
             //判断是刷新还是比较
-            if(dateType==0){
-                var sDate=vm.salesDate.replace(/(^\s+|\s+$)/g,'');//去两边空格;
-                if(sDate!=''){
+            if (dateType == 0) {
+                var sDate = vm.salesDate.replace(/(^\s+|\s+$)/g, '');//去两边空格;
+                if (sDate != '') {
                     postParam.salesDate = vm.salesDate;
                 }
-            }else if(dateType==1){
-                var sDate=vm.compareDate.replace(/(^\s+|\s+$)/g,'');//去两边空格;
-                if(sDate!=''){
+            } else if (dateType == 1) {
+                var sDate = vm.compareDate.replace(/(^\s+|\s+$)/g, '');//去两边空格;
+                if (sDate != '') {
                     postParam.compareDate = vm.compareDate;
                 }
             }
@@ -225,31 +283,64 @@ let vm = new Vue({
             // console.log(postParam);
             return postParam;
         },
-        refresh: function () {
-            var postParam={};
-            postParam =  vm.addParam(postParam,0);
-            if(!postParam){
+        refreshButton: function () {
+            var postParam = {};
+            postParam = vm.addParam(postParam, 0);
+            var start = vm.refresh(postParam);
+            console.log("start" + start);
+            if (!start) {
                 return;
             }
+            //
+            vm.xAxisList.salesDate='';
+            //当天日期开启定时器刷新
+            var currentDate = new Date();
+            var month = currentDate.getMonth() + 1;
+            var day = currentDate.getDate();
+            if ((day + '').length == 1 && day < 10) {
+                day = "0" + day;
+            }
+            currentDate = currentDate.getFullYear() + '-' + (month > 10 ? month : "0" + month) + '-' + day;
+            console.log(vm.salesDate);
+            console.log(currentDate);
+
+            if (vm.salesDate == currentDate) {
+                alert("启动定时器刷新");
+
+                vm.temp = postParam;
+                console.log(vm.temp);
+
+                vm.saveFlushTime();
+            } else {
+                console.log("关闭定时器刷新");
+                vm.clearFlushTime();
+            }
+        },
+        refresh: function (postParam) {
+
+            // postParam = vm.addParam(postParam, 0);
+            if (!postParam) {
+                return false;
+            }
             vm.showList = true;
             $.ajax({
-                url:'../realtimeSalesDetection/query',
-                type:"POST",
-                data:postParam,
-                dataType:'json',
-                success:function(r){
+                url: '../realtimeSalesDetection/query',
+                type: "POST",
+                data: postParam,
+                dataType: 'json',
+                success: function (r) {
                     //查询显示表格数据
                     vm.showTable(postParam);
                     r = r.page.list[0];
                     console.log(r);
 
-                    if(r.lastSalesTime == null){
-                        if(vm.type == 'dept'){
-                            alert("该部门"+vm.salesDate+"无销售记录");
-                            return;
+                    if (r.lastSalesTime == null) {
+                        if (vm.type == 'dept') {
+                            alert("该部门" + vm.salesDate + "无销售记录");
+                            return false;
                         }
-                        alert("该门店"+vm.salesDate+"无销售记录");
-                        return;
+                        alert("该门店" + vm.salesDate + "无销售记录");
+                        return false;
                     }
 
                     vm.storeId = r.storeId;
@@ -268,40 +359,182 @@ let vm = new Vue({
                     vm.lastSalesTime = r.lastSalesTime;
 
 
-                    vm.seriesList=[];
-                    vm.seriesList2 =[]; //清空 系列 数据
+                    vm.xAxisList.totalSales = r.totalSales;
+                    vm.xAxisList.actualSales = r.actualSales;
+                    vm.xAxisList.preferentialLoss = r.preferentialLoss;
+                    vm.xAxisList.totalCost = r.totalCost;
+                    vm.xAxisList.grossProfit = r.grossProfit;
+                    vm.xAxisList.grossProfitRatio = r.grossProfitRatio;
+                    vm.xAxisList.proportion = r.proportion;
+                    vm.xAxisList.guestNumber = r.guestNumber;
+                    vm.xAxisList.guestUnitPrice = r.guestUnitPrice;
+                    vm.xAxisList.lastSalesTime = r.lastSalesTime;
+
+                    if(vm.xAxisList.salesDate == ''){
+                        vm.xAxisList.storeId = r.storeId;
+                        vm.xAxisList.storeName = r.storeName;
+                        vm.xAxisList.merchSn = r.merchSn;
+                        vm.xAxisList.merchName = r.merchName;
+                        vm.xAxisList.totalSales = r.totalSales;
+                        vm.xAxisList.actualSales = r.actualSales;
+                        vm.xAxisList.preferentialLoss = r.preferentialLoss;
+                        vm.xAxisList.totalCost = r.totalCost;
+                        vm.xAxisList.grossProfit = r.grossProfit;
+                        vm.xAxisList.grossProfitRatio = r.grossProfitRatio;
+                        vm.xAxisList.proportion = r.proportion;
+                        vm.xAxisList.guestNumber = r.guestNumber;
+                        vm.xAxisList.guestUnitPrice = r.guestUnitPrice;
+                        vm.xAxisList.lastSalesTime = r.lastSalesTime;
+                        vm.xAxisList.salesDate = vm.salesDate;
+                        vm.xAxisList.projectSelect = vm.projectSelect;
+                    }
+
+                    vm.seriesList = [];
+                    vm.seriesList2 = []; //清空 系列 数据
 
                     vm.showEcharts();
+
+                    if(vm.isCompare){
+                        vm.compare('1');
+                    }
                 }
 
             });
+            return true;
         },
-        compare: function () {
-            if(vm.seriesList2.length <1){
-                alert("请先刷新一条数据再比较!");
+        compare: function (c) {
+            if(c == '1'){ //程序调用
+                vm.compareDate = vm.compare2;
+
+                if (vm.seriesList2.length > 1) {
+
+                    //删除并替换
+                    if (vm.projectSelect == '0') {
+                        vm.seriesList2.splice(1, 1, vm.totalSales2);
+                        if (vm.type == 'dept') {
+                            vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
+                        } else {
+                            vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
+                        }
+                        // pie 设置
+                        vm.seriesList.splice(1, 1, {value: vm.totalSales2, name: vm.dataList[1]});
+                    } else if (vm.projectSelect == '1') {
+                        vm.seriesList2.splice(1, 1, vm.guestUnitPrice);
+                        if (vm.type == 'dept') {
+                            vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
+                        } else {
+                            vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
+                        }
+                        // pie 设置
+                        vm.seriesList.splice(1, 1, {value: vm.guestUnitPrice2, name: vm.dataList[1]});
+                    }
+
+                }
+                // else {
+                //
+                //     if (vm.projectSelect == '0') {
+                //         vm.seriesList2.push(vm.totalSales2);
+                //         if (vm.type == 'dept') {
+                //             vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
+                //         } else {
+                //             vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
+                //         }
+                //         // pie 设置
+                //         vm.seriesList.push({value: vm.totalSales2, name: vm.dataList[1]});
+                //
+                //     } else if (vm.projectSelect == '1') {
+                //         vm.seriesList2.push(vm.guestUnitPrice2);
+                //         if (vm.type == 'dept') {
+                //             vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
+                //         } else {
+                //             vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
+                //         }
+                //
+                //         // pie 设置
+                //         vm.seriesList.push({value: vm.guestUnitPrice2, name: vm.dataList[1]});
+                //     }
+                // }
+
+                if (vm.seriesTypeSelect == "pie") {
+                    vm.seriesList2 = vm.seriesList.concat();
+                }
+
+                myChart.setOption({
+                    xAxis: {
+                        data: vm.dataList
+                    },
+                    series: [{
+                        type: vm.seriesTypeSelect,
+                        color: ['#dd6b66', '#759aa0'],
+                        data: vm.seriesList2
+                    }]
+                });
+
+
+
                 return;
+            }else{ //手动比较
+                vm.refreshButton();
+                vm.isCompare = true;
+                vm.compare2 = vm.compareDate;
             }
+
+            // vm.refresh();
+            // if(vm.seriesList2.length <1 || vm.seriesList2[0] ==""){
+            //     alert("请先刷新一条数据再比较!");
+            //     return;
+            // }
+
+
             vm.switchProjectView();
-            var postParam={};
-            postParam =  vm.addParam(postParam,1);
-            if(!postParam){
+            var postParam = {};
+            postParam = vm.addParam(postParam, 1);
+            if (!postParam) {
                 return;
             }
+
             $.ajax({
-                url:'../realtimeSalesDetection/query',
-                type:"POST",
-                data:postParam,
-                dataType:'json',
-                success:function(r){
+                url: '../realtimeSalesDetection/query',
+                type: "POST",
+                data: postParam,
+                dataType: 'json',
+                success: function (r) {
                     console.log(r);
                     r = r.page.list[0];
                     console.log(r);
-                    if(r.lastSalesTime == null){
-                        if(vm.type == 'dept'){
-                            alert("该部门"+vm.compareDate+"无销售记录");
+                    if (r.lastSalesTime == null) {
+                        if (vm.type == 'dept') {
+                            if (vm.seriesList2.length > 1) {
+                                //统计图有两条数据删除一条
+                                vm.seriesList2.pop();
+                                myChart.setOption({
+                                    xAxis: {
+                                        data: vm.dataList
+                                    },
+                                    series: [{
+                                        type: vm.seriesTypeSelect,
+                                        color: ['#dd6b66', '#759aa0'],
+                                        data: vm.seriesList2
+                                    }]
+                                });
+                            }
+                            alert("该部门" + vm.compareDate + "无销售记录");
                             return;
                         }
-                        alert("该门店"+vm.compareDate+"无销售记录");
+                        if (vm.seriesList2.length > 1) {
+                            vm.seriesList2.pop();
+                            myChart.setOption({
+                                xAxis: {
+                                    data: vm.dataList
+                                },
+                                series: [{
+                                    type: vm.seriesTypeSelect,
+                                    color: ['#dd6b66', '#759aa0'],
+                                    data: vm.seriesList2
+                                }]
+                            });
+                        }
+                        alert("该门店" + vm.compareDate + "无销售记录");
                         return;
                     }
 
@@ -321,54 +554,54 @@ let vm = new Vue({
                     vm.guestUnitPrice2 = r.guestUnitPrice;
                     vm.lastSalesTime2 = r.lastSalesTime;
 
-                    if(vm.seriesList2.length > 1){
+                    if (vm.seriesList2.length > 1) {
 
                         //删除并替换
-                        if(vm.projectSelect=='0'){
-                            vm.seriesList2.splice(1,1,vm.totalSales2);
-                            if(vm.type == 'dept'){
-                                vm.dataList.splice(1,1,'['+vm.merchSn+']'+vm.merchName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
-                            }else{
-                                vm.dataList.splice(1,1,'['+vm.storeId+']'+vm.storeName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
+                        if (vm.projectSelect == '0') {
+                            vm.seriesList2.splice(1, 1, vm.totalSales2);
+                            if (vm.type == 'dept') {
+                                vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '(' + vm.salesDate2 + ')');
+                            } else {
+                                vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '(' + vm.salesDate2 + ')');
                             }
                             // pie 设置
-                            vm.seriesList.splice(1,1,{value:vm.totalSales2,name:vm.dataList[1]});
-                        }else if(vm.projectSelect=='1'){
-                            vm.seriesList2.splice(1,1,vm.guestUnitPrice);
-                            if(vm.type == 'dept'){
-                                vm.dataList.splice(1,1,'['+vm.merchSn+']'+vm.merchName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
-                            }else{
-                                vm.dataList.splice(1,1,'['+vm.storeId+']'+vm.storeName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
+                            vm.seriesList.splice(1, 1, {value: vm.totalSales2, name: vm.dataList[1]});
+                        } else if (vm.projectSelect == '1') {
+                            vm.seriesList2.splice(1, 1, vm.guestUnitPrice);
+                            if (vm.type == 'dept') {
+                                vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '(' + vm.salesDate2 + ')');
+                            } else {
+                                vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '(' + vm.salesDate2 + ')');
                             }
                             // pie 设置
-                            vm.seriesList.splice(1,1,{value:vm.guestUnitPrice2,name:vm.dataList[1]});
+                            vm.seriesList.splice(1, 1, {value: vm.guestUnitPrice2, name: vm.dataList[1]});
                         }
 
-                    }else{
+                    } else {
 
-                        if(vm.projectSelect=='0'){
+                        if (vm.projectSelect == '0') {
                             vm.seriesList2.push(vm.totalSales2);
-                            if(vm.type == 'dept'){
-                                vm.dataList.push('['+vm.merchSn+']'+vm.merchName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
-                            }else{
-                                vm.dataList.push('['+vm.storeId+']'+vm.storeName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
+                            if (vm.type == 'dept') {
+                                vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '(' + vm.salesDate2 + ')');
+                            } else {
+                                vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '(' + vm.salesDate2 + ')');
                             }
                             // pie 设置
-                            vm.seriesList.push({value:vm.totalSales2,name:vm.dataList[1]});
+                            vm.seriesList.push({value: vm.totalSales2, name: vm.dataList[1]});
 
-                        }else if(vm.projectSelect=='1'){
+                        } else if (vm.projectSelect == '1') {
                             vm.seriesList2.push(vm.guestUnitPrice2);
-                            if(vm.type == 'dept'){
-                                vm.dataList.push('['+vm.merchSn+']'+vm.merchName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
-                            }else{
-                                vm.dataList.push('['+vm.storeId+']'+vm.storeName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
+                            if (vm.type == 'dept') {
+                                vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '(' + vm.salesDate2 + ')');
+                            } else {
+                                vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '(' + vm.salesDate2 + ')');
                             }
 
                             // pie 设置
-                            vm.seriesList.push({value:vm.guestUnitPrice2,name:vm.dataList[1]});
+                            vm.seriesList.push({value: vm.guestUnitPrice2, name: vm.dataList[1]});
                         }
                     }
-                    if(vm.seriesTypeSelect == "pie"){
+                    if (vm.seriesTypeSelect == "pie") {
                         vm.seriesList2 = vm.seriesList.concat();
                     }
 
@@ -376,9 +609,9 @@ let vm = new Vue({
                         xAxis: {
                             data: vm.dataList
                         },
-                        series:[{
+                        series: [{
                             type: vm.seriesTypeSelect,
-                            color: ['#dd6b66','#759aa0'],
+                            color: ['#dd6b66', '#759aa0'],
                             data: vm.seriesList2
                         }]
                     });
@@ -387,15 +620,19 @@ let vm = new Vue({
             });
 
         },
-        saveFlushTime:function(){
+        saveFlushTime: function (postParam) {
+            console.log('typeof vm.refreshTime');
             console.log(typeof vm.refreshTime);
-            vm.intervalId = window.setInterval('vm.refresh()',vm.refreshTime*1000)
+            console.log(vm.temp);
+
+            window.clearInterval(vm.intervalId);
+            vm.intervalId = window.setInterval('vm.refresh(vm.temp)', vm.refreshTime * 1000)
         },
-        clearFlushTime:function(){
+        clearFlushTime: function () {
             window.clearInterval(vm.intervalId);
             vm.intervalId = 0;
         },
-        seriesTypeSwitch: function(){
+        seriesTypeSwitch: function () {
             console.log(vm.seriesTypeSelect);
         },
         showEcharts: function () {
@@ -406,30 +643,50 @@ let vm = new Vue({
             myChart.showLoading();
 
 
-            //项目下拉框判断       6-19,饼图设置
-            var temp ='';
-            if(vm.projectSelect=='0'){
-                if(vm.type == 'dept'){
-                    temp = '['+vm.merchSn+']'+vm.merchName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
-                }else{
-                    temp = '['+vm.storeId+']'+vm.storeName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+            //项目下拉框判断       6-19,饼图设置 vm.xAxisList
+            var temp = '';
+            if (vm.xAxisList.projectSelect == '0') {
+                if (vm.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.totalSales);
-                vm.seriesList.push({value:vm.totalSales,name:temp});
-
-            }else if(vm.projectSelect=='1'){
-                if(vm.type == 'dept'){
-                    temp = '['+vm.merchSn+']'+vm.merchName+'/客单价:'+vm.guestUnitPrice+'('+vm.salesDate+')';
-                }else{
-                    temp = '['+vm.storeId+']'+vm.storeName+'/客单价:'+vm.guestUnitPrice+'('+vm.salesDate+')';
+                vm.seriesList2.push(vm.xAxisList.totalSales);
+                vm.seriesList.push({value: vm.xAxisList.totalSales, name: temp});
+
+            } else if (vm.xAxisList.projectSelect == '1') {
+                if (vm.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.guestUnitPrice);
-                vm.seriesList.push({value:vm.guestUnitPrice,name:temp});
+                vm.seriesList2.push(vm.xAxisList.guestUnitPrice);
+                vm.seriesList.push({value: vm.xAxisList.guestUnitPrice, name: temp});
 
             }
+
+            // if (vm.projectSelect == '0') {
+            //     if (vm.type == 'dept') {
+            //         temp = '[' + vm.merchSn + ']' + vm.merchName + '/售价总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
+            //     } else {
+            //         temp = '[' + vm.storeId + ']' + vm.storeName + '/售价总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
+            //     }
+            //     vm.seriesList2.push(vm.totalSales);
+            //     vm.seriesList.push({value: vm.totalSales, name: temp});
+            //
+            // } else if (vm.projectSelect == '1') {
+            //     if (vm.type == 'dept') {
+            //         temp = '[' + vm.merchSn + ']' + vm.merchName + '/客单价:' + vm.guestUnitPrice + '元(' + vm.salesDate + ')';
+            //     } else {
+            //         temp = '[' + vm.storeId + ']' + vm.storeName + '/客单价:' + vm.guestUnitPrice + '元(' + vm.salesDate + ')';
+            //     }
+            //     vm.seriesList2.push(vm.guestUnitPrice);
+            //     vm.seriesList.push({value: vm.guestUnitPrice, name: temp});
+            //
+            // }
             vm.dataList = [temp];
 
-            if(vm.seriesTypeSelect == "pie"){
+            if (vm.seriesTypeSelect == "pie") {
                 vm.seriesList2 = vm.seriesList.concat();
             }
 
@@ -442,18 +699,18 @@ let vm = new Vue({
                 title: {
                     // textAlign: 'right',
                     text: '实时销售统计图',
-                    x:'center',
-                    textStyle:{
+                    x: 'center',
+                    textStyle: {
                         //文字颜色
-                        color:'#17233d',
+                        color: '#17233d',
                         //字体风格,'normal','italic','oblique'
-                        fontStyle:'normal',
+                        fontStyle: 'normal',
                         //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
-                        fontWeight:'bold',
+                        fontWeight: 'bold',
                         //字体系列
-                        fontFamily:'sans-serif',
+                        fontFamily: 'sans-serif',
                         //字体大小
-                        fontSize:28
+                        fontSize: 28
                     }
                 },
                 tooltip: {
@@ -462,22 +719,22 @@ let vm = new Vue({
                     }
                 },
                 legend: {
-                    data:['/售价总额']
+                    data: ['/售价总额']
                 },
                 xAxis: {
                     data: vm.dataList,
                     axisLabel: {
-                        interval:0
+                        interval: 0
                     }
                 },
                 yAxis: {},
-                series:[{
-                    barMaxWidth: '20%' ,
-                    barWidth: '50%' ,
+                series: [{
+                    barMaxWidth: '20%',
+                    barWidth: '50%',
                     radius: '55%',
                     roseType: 'angle',
                     type: vm.seriesTypeSelect,
-                    color: ['#dd6b66','#759aa0'],
+                    color: ['#dd6b66', '#759aa0'],
                     data: vm.seriesList2
                 }]
             };
@@ -488,11 +745,11 @@ let vm = new Vue({
             myChart.setOption(option);
 
         },
-        tooltipFormatter: function(){
-            if(vm.type=='dept'){
-                return '['+vm.merchSn+']'+vm.merchName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+        tooltipFormatter: function () {
+            if (vm.type == 'dept') {
+                return '[' + vm.merchSn + ']' + vm.merchName + '/售价总额:' + vm.totalSales + '(' + vm.salesDate + ')';
             }
-            return '['+vm.storeId+']'+vm.storeName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+            return '[' + vm.storeId + ']' + vm.storeName + '/售价总额:' + vm.totalSales + '(' + vm.salesDate + ')';
         },
         showTable: function (postParam) {