realtimeSalesDetection.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. $(function () {
  2. vm.showEcharts();
  3. var date = new Date();
  4. var year = date.getFullYear();
  5. var month = ('0'+ (date.getMonth() + 1)).slice(-2);
  6. var day = ('0' + date.getDate()).slice(-2);
  7. var time = year +'-'+ month +'-'+ day;
  8. console.log('time');
  9. console.log(time);
  10. // document.getElementById('salesDate').value = time;
  11. //限制不能选择今天之后的日期(加du上属性max)
  12. document.getElementById('salesDate').setAttribute('max', time);
  13. var dateTime = date.setDate(date.getDate()-1);
  14. date=new Date(dateTime);
  15. day = ('0' + date.getDate()).slice(-2);
  16. var time3 = year +'-'+ month +'-'+ day;
  17. document.getElementById('compareDate').setAttribute('max', time3);
  18. $("#jqGrid").jqGrid({
  19. url: '../realtimeSalesDetection/query',
  20. datatype: "json",
  21. colModel: [
  22. {label: '门店编码', name: 'storeId', index: 'storeId', width: 80},
  23. {label: '门店名称', name: 'storeName', index: 'storeName', width: 120},
  24. {label: '商户编码', name: 'merchSn', index: 'storeId', width: 220},
  25. {label: '商户名称', name: 'merchName', index: 'storeName', width: 120},
  26. {label: '售价总额', name: 'totalSales', index: 'totalSales', align: 'right', width: 80},
  27. {label: '实际销售额', name: 'actualSales', index: 'actualSales', align: 'right', width: 80},
  28. {label: '占比 %', name: 'proportion', index: 'proportion', align: 'right', width: 60},
  29. {label: '优惠损失', name: 'preferentialLoss', index: 'preferentialLoss', align: 'right', width: 80},
  30. {label: '成本总额', name: 'totalCost', index: 'totalCost', align: 'right', width: 80},
  31. {label: '毛利', name: 'grossProfit', index: 'grossProfit', align: 'right', width: 80},
  32. {label: '毛利率', name: 'grossProfitRatio', index: 'grossProfitRatio', align: 'right', width: 60},
  33. {label: '来客数', name: 'guestNumber', index: 'guestNumber', align: 'right', width: 100},
  34. {label: '客单价', name: 'guestUnitPrice', index: 'guestUnitPrice', align: 'right', width: 80},
  35. {
  36. label: '最后销售时间',
  37. name: 'lastSalesTime',
  38. index: 'lastSalesTime',
  39. align: 'center',
  40. width: 180,
  41. formatter: function (value) {
  42. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  43. }
  44. }
  45. // {label: '说明', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 80}
  46. ],
  47. viewrecords: true,
  48. height: 200,
  49. rowNum: 10,
  50. rowList: [10, 30, 50],
  51. rownumbers: true,
  52. rownumWidth: 25,
  53. autowidth: true,
  54. shrinkToFit: false,
  55. autoScroll: true, //开启水平滚动条
  56. width: 1500,
  57. multiselect: true,
  58. pager: "#jqGridPager",
  59. jsonReader: {
  60. root: "page.list",
  61. page: "page.currPage",
  62. total: "page.totalPage",
  63. records: "page.totalCount"
  64. },
  65. prmNames: {
  66. page: "page",
  67. rows: "limit",
  68. order: "order"
  69. },
  70. gridComplete: function () {
  71. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  72. }
  73. });
  74. });
  75. var myChart;
  76. let vm = new Vue({
  77. el: '#rrapp',
  78. data: {
  79. date: '',
  80. refreshTime: 10,
  81. type: 'store',
  82. storeId: '',
  83. merchSn: '',
  84. merchName: '',
  85. storeName: '',
  86. salesDate: '',
  87. totalSales: '',
  88. actualSales: '',
  89. preferentialLoss: '',
  90. totalCost: '',
  91. grossProfit: '',
  92. grossProfitRatio: '',
  93. proportion: '',
  94. guestNumber: '',
  95. guestUnitPrice: '',
  96. lastSalesTime: '',
  97. categoryId: '',
  98. categoryName: '',
  99. showList: false,
  100. compareDate: '',//比较日期
  101. storeId2: '',
  102. merchSn2: '',
  103. merchName2: '',
  104. storeName2: '',
  105. salesDate2: '',
  106. totalSales2: '',
  107. actualSales2: '',
  108. preferentialLoss2: '',
  109. totalCost2: '',
  110. grossProfit2: '',
  111. grossProfitRatio2: '',
  112. proportion2: '',
  113. guestNumber2: '',
  114. guestUnitPrice2: '',
  115. lastSalesTime2: '',
  116. intervalId: 0,
  117. isCompare: false,
  118. compare2: '',
  119. temp: {
  120. date: '',
  121. refreshTime: 10,
  122. type: '',
  123. storeId: '',
  124. merchSn: '',
  125. salesDate: '',
  126. categoryId: ''
  127. },
  128. rateList: [
  129. {
  130. id: '0',
  131. name: '含税'
  132. },
  133. {
  134. id: '1',
  135. name: '不含税'
  136. }
  137. ],
  138. projectList: [
  139. {
  140. id: '0',
  141. name: '售价总额'
  142. },
  143. {
  144. id: '1',
  145. name: '客单价'
  146. }
  147. ],
  148. seriesTypeList: [
  149. {
  150. id: 'bar',
  151. name: '垂直柱状图'
  152. },
  153. {
  154. id: 'line',
  155. name: '折线图'
  156. },
  157. {
  158. id: 'pie',
  159. name: '饼图'
  160. }
  161. ],
  162. formatsList: [
  163. {
  164. id: '0',
  165. name: '<全部>'
  166. },
  167. {
  168. id: '1',
  169. name: '<非全部>'
  170. }
  171. ],
  172. salesList: [
  173. {
  174. store: {storeId: '11106', storeName: '前海店'},
  175. totalSales: 43046.18,
  176. actualSales: 35593.46
  177. }
  178. ],
  179. dept: {
  180. deptId: '',
  181. deptName: ''
  182. },
  183. category: {
  184. categoryId: '',
  185. categoryName: ''
  186. },
  187. seriesList: [], //保存饼图数据
  188. seriesList2: [],
  189. xAxisList: {
  190. storeId: '',
  191. storeName: '',
  192. merchSn: '',
  193. merchName: '',
  194. totalSales: '',
  195. actualSales: '',
  196. preferentialLoss: '',
  197. totalCost: '',
  198. grossProfit: '',
  199. grossProfitRatio: '',
  200. proportion: '',
  201. guestNumber: '',
  202. guestUnitPrice: '',
  203. lastSalesTime: '',
  204. salesDate: '0',
  205. projectSelect: '0'
  206. },
  207. dataList: [],
  208. tooltip: {}
  209. },
  210. created() {
  211. this.rateSelect = this.rateList[0].id;
  212. this.projectSelect = this.projectList[0].id;
  213. this.seriesTypeSelect = this.seriesTypeList[0].id;
  214. this.formatsSelect = this.formatsList[0].id;
  215. },
  216. methods: {
  217. addParam: function (postParam, dateType) { //添加请求参数, dateType: 0刷新,1比较
  218. // var currentDate = new Date();
  219. // currentDate = currentDate.getFullYear()+'-'+(currentDate.getMonth()+1)+'-'+currentDate.getDate();
  220. postParam = {};
  221. if (!(Math.floor(vm.refreshTime) == vm.refreshTime && vm.refreshTime % 1 === 0 && vm.refreshTime >= 10)) {
  222. alert("刷新间隔请输入10秒以上的整数!");
  223. return false;
  224. }
  225. if (vm.type == "store") {
  226. // vm.storeId = '10'; //测试
  227. if (vm.storeId == '' || vm.storeId == null) {
  228. alert("请在输入框中输入门店编号!");
  229. return false;
  230. }
  231. postParam.storeId = vm.storeId;
  232. } else if (vm.type == "dept") {
  233. if (vm.merchSn == '' || vm.merchSn == null) {
  234. alert("请在输入框中输入部门编号!");
  235. return false;
  236. }
  237. postParam.merchSn = vm.merchSn;
  238. } else if (vm.type == "category") {
  239. if (vm.storeId == '' || vm.storeId == null) {
  240. alert("请在输入框中输入门店编号和品类编号!");
  241. return false;
  242. }
  243. if (vm.categoryId == '' || vm.categoryId == null) {
  244. alert("请在输入框中输入品类编号!");
  245. return false;
  246. }
  247. postParam.storeId = vm.storeId;
  248. postParam.categoryId = vm.categoryId;
  249. } else {
  250. alert("请选中查询条件(门店、部门、品类,选中一个)" + vm.type);
  251. return false;
  252. }
  253. //判断是刷新还是比较
  254. if (dateType == 0) {
  255. var sDate = vm.salesDate.replace(/(^\s+|\s+$)/g, '');//去两边空格;
  256. if (sDate != '') {
  257. postParam.salesDate = vm.salesDate;
  258. }
  259. } else if (dateType == 1) {
  260. var sDate = vm.compareDate.replace(/(^\s+|\s+$)/g, '');//去两边空格;
  261. if (sDate != '') {
  262. postParam.compareDate = vm.compareDate;
  263. }
  264. }
  265. // console.log('postParam');
  266. // console.log(postParam);
  267. return postParam;
  268. },
  269. refreshButton: function () {
  270. var postParam = {};
  271. postParam = vm.addParam(postParam, 0);
  272. var start = vm.refresh(postParam);
  273. console.log("start" + start);
  274. if (!start) {
  275. return;
  276. }
  277. //
  278. vm.xAxisList.salesDate='';
  279. //当天日期开启定时器刷新
  280. var currentDate = new Date();
  281. var month = currentDate.getMonth() + 1;
  282. var day = currentDate.getDate();
  283. if ((day + '').length == 1 && day < 10) {
  284. day = "0" + day;
  285. }
  286. currentDate = currentDate.getFullYear() + '-' + (month > 10 ? month : "0" + month) + '-' + day;
  287. console.log(vm.salesDate);
  288. console.log(currentDate);
  289. if (vm.salesDate == currentDate) {
  290. alert("启动定时器刷新");
  291. vm.temp = postParam;
  292. console.log(vm.temp);
  293. vm.saveFlushTime();
  294. } else {
  295. console.log("关闭定时器刷新");
  296. vm.clearFlushTime();
  297. }
  298. },
  299. refresh: function (postParam) {
  300. // postParam = vm.addParam(postParam, 0);
  301. if (!postParam) {
  302. return false;
  303. }
  304. vm.showList = true;
  305. $.ajax({
  306. url: '../realtimeSalesDetection/query',
  307. type: "POST",
  308. data: postParam,
  309. dataType: 'json',
  310. success: function (r) {
  311. //查询显示表格数据
  312. vm.showTable(postParam);
  313. r = r.page.list[0];
  314. console.log(r);
  315. if (r.lastSalesTime == null) {
  316. if (vm.type == 'dept') {
  317. alert("该部门" + vm.salesDate + "无销售记录");
  318. return false;
  319. }
  320. alert("该门店" + vm.salesDate + "无销售记录");
  321. return false;
  322. }
  323. vm.storeId = r.storeId;
  324. vm.storeName = r.storeName;
  325. vm.merchSn = r.merchSn;
  326. vm.merchName = r.merchName;
  327. vm.totalSales = r.totalSales;
  328. vm.actualSales = r.actualSales;
  329. vm.preferentialLoss = r.preferentialLoss;
  330. vm.totalCost = r.totalCost;
  331. vm.grossProfit = r.grossProfit;
  332. vm.grossProfitRatio = r.grossProfitRatio;
  333. vm.proportion = r.proportion;
  334. vm.guestNumber = r.guestNumber;
  335. vm.guestUnitPrice = r.guestUnitPrice;
  336. vm.lastSalesTime = r.lastSalesTime;
  337. vm.xAxisList.totalSales = r.totalSales;
  338. vm.xAxisList.actualSales = r.actualSales;
  339. vm.xAxisList.preferentialLoss = r.preferentialLoss;
  340. vm.xAxisList.totalCost = r.totalCost;
  341. vm.xAxisList.grossProfit = r.grossProfit;
  342. vm.xAxisList.grossProfitRatio = r.grossProfitRatio;
  343. vm.xAxisList.proportion = r.proportion;
  344. vm.xAxisList.guestNumber = r.guestNumber;
  345. vm.xAxisList.guestUnitPrice = r.guestUnitPrice;
  346. vm.xAxisList.lastSalesTime = r.lastSalesTime;
  347. if(vm.xAxisList.salesDate == ''){
  348. vm.xAxisList.storeId = r.storeId;
  349. vm.xAxisList.storeName = r.storeName;
  350. vm.xAxisList.merchSn = r.merchSn;
  351. vm.xAxisList.merchName = r.merchName;
  352. vm.xAxisList.totalSales = r.totalSales;
  353. vm.xAxisList.actualSales = r.actualSales;
  354. vm.xAxisList.preferentialLoss = r.preferentialLoss;
  355. vm.xAxisList.totalCost = r.totalCost;
  356. vm.xAxisList.grossProfit = r.grossProfit;
  357. vm.xAxisList.grossProfitRatio = r.grossProfitRatio;
  358. vm.xAxisList.proportion = r.proportion;
  359. vm.xAxisList.guestNumber = r.guestNumber;
  360. vm.xAxisList.guestUnitPrice = r.guestUnitPrice;
  361. vm.xAxisList.lastSalesTime = r.lastSalesTime;
  362. vm.xAxisList.salesDate = vm.salesDate;
  363. vm.xAxisList.projectSelect = vm.projectSelect;
  364. }
  365. vm.seriesList = [];
  366. vm.seriesList2 = []; //清空 系列 数据
  367. vm.showEcharts();
  368. if(vm.isCompare){
  369. vm.compare('1');
  370. }
  371. }
  372. });
  373. return true;
  374. },
  375. compare: function (c) {
  376. if(c == '1'){ //程序调用
  377. vm.compareDate = vm.compare2;
  378. if (vm.seriesList2.length > 1) {
  379. //删除并替换
  380. if (vm.projectSelect == '0') {
  381. vm.seriesList2.splice(1, 1, vm.totalSales2);
  382. if (vm.type == 'dept') {
  383. vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  384. } else {
  385. vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  386. }
  387. // pie 设置
  388. vm.seriesList.splice(1, 1, {value: vm.totalSales2, name: vm.dataList[1]});
  389. } else if (vm.projectSelect == '1') {
  390. vm.seriesList2.splice(1, 1, vm.guestUnitPrice);
  391. if (vm.type == 'dept') {
  392. vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  393. } else {
  394. vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  395. }
  396. // pie 设置
  397. vm.seriesList.splice(1, 1, {value: vm.guestUnitPrice2, name: vm.dataList[1]});
  398. }
  399. }
  400. // else {
  401. //
  402. // if (vm.projectSelect == '0') {
  403. // vm.seriesList2.push(vm.totalSales2);
  404. // if (vm.type == 'dept') {
  405. // vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  406. // } else {
  407. // vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  408. // }
  409. // // pie 设置
  410. // vm.seriesList.push({value: vm.totalSales2, name: vm.dataList[1]});
  411. //
  412. // } else if (vm.projectSelect == '1') {
  413. // vm.seriesList2.push(vm.guestUnitPrice2);
  414. // if (vm.type == 'dept') {
  415. // vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  416. // } else {
  417. // vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  418. // }
  419. //
  420. // // pie 设置
  421. // vm.seriesList.push({value: vm.guestUnitPrice2, name: vm.dataList[1]});
  422. // }
  423. // }
  424. if (vm.seriesTypeSelect == "pie") {
  425. vm.seriesList2 = vm.seriesList.concat();
  426. }
  427. myChart.setOption({
  428. xAxis: {
  429. data: vm.dataList
  430. },
  431. series: [{
  432. type: vm.seriesTypeSelect,
  433. color: ['#dd6b66', '#759aa0'],
  434. data: vm.seriesList2
  435. }]
  436. });
  437. return;
  438. }else{ //手动比较
  439. vm.refreshButton();
  440. vm.isCompare = true;
  441. vm.compare2 = vm.compareDate;
  442. }
  443. // vm.refresh();
  444. // if(vm.seriesList2.length <1 || vm.seriesList2[0] ==""){
  445. // alert("请先刷新一条数据再比较!");
  446. // return;
  447. // }
  448. vm.switchProjectView();
  449. var postParam = {};
  450. postParam = vm.addParam(postParam, 1);
  451. if (!postParam) {
  452. return;
  453. }
  454. $.ajax({
  455. url: '../realtimeSalesDetection/query',
  456. type: "POST",
  457. data: postParam,
  458. dataType: 'json',
  459. success: function (r) {
  460. console.log(r);
  461. r = r.page.list[0];
  462. console.log(r);
  463. if (r.lastSalesTime == null) {
  464. if (vm.type == 'dept') {
  465. if (vm.seriesList2.length > 1) {
  466. //统计图有两条数据删除一条
  467. vm.seriesList2.pop();
  468. myChart.setOption({
  469. xAxis: {
  470. data: vm.dataList
  471. },
  472. series: [{
  473. type: vm.seriesTypeSelect,
  474. color: ['#dd6b66', '#759aa0'],
  475. data: vm.seriesList2
  476. }]
  477. });
  478. }
  479. alert("该部门" + vm.compareDate + "无销售记录");
  480. return;
  481. }
  482. if (vm.seriesList2.length > 1) {
  483. vm.seriesList2.pop();
  484. myChart.setOption({
  485. xAxis: {
  486. data: vm.dataList
  487. },
  488. series: [{
  489. type: vm.seriesTypeSelect,
  490. color: ['#dd6b66', '#759aa0'],
  491. data: vm.seriesList2
  492. }]
  493. });
  494. }
  495. alert("该门店" + vm.compareDate + "无销售记录");
  496. return;
  497. }
  498. vm.storeId2 = r.storeId;
  499. vm.merchSn2 = r.merchSn;
  500. vm.merchName2 = r.merchName;
  501. vm.storeName2 = r.storeName;
  502. vm.salesDate2 = vm.compareDate;
  503. vm.totalSales2 = r.totalSales;
  504. vm.actualSales2 = r.actualSales;
  505. vm.preferentialLoss2 = r.preferentialLoss;
  506. vm.totalCost2 = r.totalCost;
  507. vm.grossProfit2 = r.grossProfit;
  508. vm.grossProfitRatio2 = r.grossProfitRatio;
  509. vm.proportion2 = r.proportion;
  510. vm.guestNumber2 = r.guestNumber;
  511. vm.guestUnitPrice2 = r.guestUnitPrice;
  512. vm.lastSalesTime2 = r.lastSalesTime;
  513. if (vm.seriesList2.length > 1) {
  514. //删除并替换
  515. if (vm.projectSelect == '0') {
  516. vm.seriesList2.splice(1, 1, vm.totalSales2);
  517. if (vm.type == 'dept') {
  518. vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  519. } else {
  520. vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  521. }
  522. // pie 设置
  523. vm.seriesList.splice(1, 1, {value: vm.totalSales2, name: vm.dataList[1]});
  524. } else if (vm.projectSelect == '1') {
  525. vm.seriesList2.splice(1, 1, vm.guestUnitPrice);
  526. if (vm.type == 'dept') {
  527. vm.dataList.splice(1, 1, '[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  528. } else {
  529. vm.dataList.splice(1, 1, '[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  530. }
  531. // pie 设置
  532. vm.seriesList.splice(1, 1, {value: vm.guestUnitPrice2, name: vm.dataList[1]});
  533. }
  534. } else {
  535. if (vm.projectSelect == '0') {
  536. vm.seriesList2.push(vm.totalSales2);
  537. if (vm.type == 'dept') {
  538. vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  539. } else {
  540. vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/售价总额:' + vm.totalSales2 + '元(' + vm.salesDate2 + ')');
  541. }
  542. // pie 设置
  543. vm.seriesList.push({value: vm.totalSales2, name: vm.dataList[1]});
  544. } else if (vm.projectSelect == '1') {
  545. vm.seriesList2.push(vm.guestUnitPrice2);
  546. if (vm.type == 'dept') {
  547. vm.dataList.push('[' + vm.merchSn + ']' + vm.merchName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  548. } else {
  549. vm.dataList.push('[' + vm.storeId + ']' + vm.storeName2 + '/客单价:' + vm.guestUnitPrice2 + '元(' + vm.salesDate2 + ')');
  550. }
  551. // pie 设置
  552. vm.seriesList.push({value: vm.guestUnitPrice2, name: vm.dataList[1]});
  553. }
  554. }
  555. if (vm.seriesTypeSelect == "pie") {
  556. vm.seriesList2 = vm.seriesList.concat();
  557. }
  558. myChart.setOption({
  559. xAxis: {
  560. data: vm.dataList
  561. },
  562. series: [{
  563. type: vm.seriesTypeSelect,
  564. color: ['#dd6b66', '#759aa0'],
  565. data: vm.seriesList2
  566. }]
  567. });
  568. }
  569. });
  570. },
  571. saveFlushTime: function (postParam) {
  572. console.log('typeof vm.refreshTime');
  573. console.log(typeof vm.refreshTime);
  574. console.log(vm.temp);
  575. window.clearInterval(vm.intervalId);
  576. vm.intervalId = window.setInterval('vm.refresh(vm.temp)', vm.refreshTime * 1000)
  577. },
  578. clearFlushTime: function () {
  579. window.clearInterval(vm.intervalId);
  580. vm.intervalId = 0;
  581. },
  582. seriesTypeSwitch: function () {
  583. console.log(vm.seriesTypeSelect);
  584. },
  585. showEcharts: function () {
  586. // 基于准备好的dom,初始化echarts实例
  587. myChart = echarts.init(document.getElementById('main'));
  588. myChart.clear();
  589. //加载动画
  590. myChart.showLoading();
  591. //项目下拉框判断 6-19,饼图设置 vm.xAxisList
  592. var temp = '';
  593. if (vm.xAxisList.projectSelect == '0') {
  594. if (vm.type == 'dept') {
  595. temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/售价总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
  596. } else {
  597. temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/售价总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
  598. }
  599. vm.seriesList2.push(vm.xAxisList.totalSales);
  600. vm.seriesList.push({value: vm.xAxisList.totalSales, name: temp});
  601. } else if (vm.xAxisList.projectSelect == '1') {
  602. if (vm.type == 'dept') {
  603. temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
  604. } else {
  605. temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
  606. }
  607. vm.seriesList2.push(vm.xAxisList.guestUnitPrice);
  608. vm.seriesList.push({value: vm.xAxisList.guestUnitPrice, name: temp});
  609. }
  610. // if (vm.projectSelect == '0') {
  611. // if (vm.type == 'dept') {
  612. // temp = '[' + vm.merchSn + ']' + vm.merchName + '/售价总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
  613. // } else {
  614. // temp = '[' + vm.storeId + ']' + vm.storeName + '/售价总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
  615. // }
  616. // vm.seriesList2.push(vm.totalSales);
  617. // vm.seriesList.push({value: vm.totalSales, name: temp});
  618. //
  619. // } else if (vm.projectSelect == '1') {
  620. // if (vm.type == 'dept') {
  621. // temp = '[' + vm.merchSn + ']' + vm.merchName + '/客单价:' + vm.guestUnitPrice + '元(' + vm.salesDate + ')';
  622. // } else {
  623. // temp = '[' + vm.storeId + ']' + vm.storeName + '/客单价:' + vm.guestUnitPrice + '元(' + vm.salesDate + ')';
  624. // }
  625. // vm.seriesList2.push(vm.guestUnitPrice);
  626. // vm.seriesList.push({value: vm.guestUnitPrice, name: temp});
  627. //
  628. // }
  629. vm.dataList = [temp];
  630. if (vm.seriesTypeSelect == "pie") {
  631. vm.seriesList2 = vm.seriesList.concat();
  632. }
  633. // console.log('vm.seriesList2');
  634. // console.log(vm.seriesList2);
  635. // 指定图表的配置项和数据
  636. //销售量
  637. var option = {
  638. title: {
  639. // textAlign: 'right',
  640. text: '实时销售统计图',
  641. x: 'center',
  642. textStyle: {
  643. //文字颜色
  644. color: '#17233d',
  645. //字体风格,'normal','italic','oblique'
  646. fontStyle: 'normal',
  647. //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
  648. fontWeight: 'bold',
  649. //字体系列
  650. fontFamily: 'sans-serif',
  651. //字体大小
  652. fontSize: 28
  653. }
  654. },
  655. tooltip: {
  656. formatter: function (params) {
  657. return params.name;
  658. }
  659. },
  660. legend: {
  661. data: ['/售价总额']
  662. },
  663. xAxis: {
  664. data: vm.dataList,
  665. axisLabel: {
  666. interval: 0
  667. }
  668. },
  669. yAxis: {},
  670. series: [{
  671. barMaxWidth: '20%',
  672. barWidth: '50%',
  673. radius: '55%',
  674. roseType: 'angle',
  675. type: vm.seriesTypeSelect,
  676. color: ['#dd6b66', '#759aa0'],
  677. data: vm.seriesList2
  678. }]
  679. };
  680. //隐藏
  681. myChart.hideLoading();
  682. // 使用刚指定的配置项和数据显示图表。
  683. myChart.setOption(option);
  684. },
  685. tooltipFormatter: function () {
  686. if (vm.type == 'dept') {
  687. return '[' + vm.merchSn + ']' + vm.merchName + '/售价总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
  688. }
  689. return '[' + vm.storeId + ']' + vm.storeName + '/售价总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
  690. },
  691. showTable: function (postParam) {
  692. console.log(postParam);
  693. $("#jqGrid").jqGrid('setGridParam', {
  694. postData: postParam
  695. }).trigger("reloadGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  696. },
  697. switchProjectView: function () {
  698. console.log(vm.projectSelect);
  699. }
  700. }
  701. });