weeklySalesSummary.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. $(function () {
  2. var data = {
  3. "echatX": [
  4. "2019-07-02",
  5. "2019-07-03",
  6. "2019-07-04",
  7. "2019-07-05",
  8. "2019-07-06",
  9. "2019-07-07",
  10. "2019-07-08",
  11. "2019-07-09",
  12. "2019-07-10",
  13. "2019-07-11",
  14. "2019-07-12",
  15. "2019-07-13",
  16. "2019-07-14",
  17. "2019-07-15"
  18. ],
  19. "echatY": [
  20. 501,210,123,333,445,157,151,369,101,101,350,435,153,100
  21. ],
  22. "echatY2": [
  23. 80,40,13,36,57,77,41,39,61,31,60,73,33,50
  24. ],
  25. "echatY3": [
  26. 5091,2210,1233,3133,4415,1517,1511,3619,1101,1011,3510,4315,1513,1100
  27. ],
  28. "echatY4": [
  29. 501,210,123,333,445,157,151,369,101,101,350,435,153,100
  30. ],
  31. "peopleTotal":15,"peopleOnline":4,"peopleOutline":12,"ranges":[]
  32. };
  33. dFun(data.echatX, data.echatY, data.echatY2,data.echatY3,data.echatY4);
  34. });
  35. var myChart;
  36. // 基于准备好的dom,初始化echarts实例
  37. var dChart = echarts.init(document.getElementById('main3'));
  38. // 指定图表的配置项和数据
  39. function dFun(dateList, totalNumberList, totalSalesList) {
  40. dChart.setOption({
  41. // title: {
  42. // left: 'left',
  43. // text: '概率',
  44. // show: false
  45. // },
  46. tooltip: {
  47. trigger: 'axis',
  48. // formatter: '{a}:{c}',
  49. axisPointer: {
  50. type: 'shadow',
  51. crossStyle: {
  52. color: '#999'
  53. }
  54. }
  55. },
  56. grid: {
  57. show: false,
  58. left: '3%',
  59. right: '4%',
  60. bottom: '10%'
  61. },
  62. // legend: {
  63. // show: true,
  64. // selectedMode: 'single', // 设置显示单一图例的图形,点击可切换
  65. // bottom: 10,
  66. // left: 50,
  67. // textStyle: {
  68. // color: '#666',
  69. // fontSize: 12
  70. // },
  71. // itemGap: 20,
  72. // inactiveColor: '#ccc'
  73. // },
  74. xAxis: {
  75. // splitLine: {     show: false   },
  76. type: 'category',
  77. data: dateList,
  78. axisPointer: {
  79. type: 'shadow'
  80. },
  81. // 改变x轴颜色
  82. axisLine: {
  83. lineStyle: {
  84. color: '#00a2e2',
  85. width: 1, // 这里是为了突出显示加上的
  86. }
  87. },
  88. axisTick: {
  89. show: true,
  90. interval: 0
  91. },
  92. },
  93. // 设置两个y轴,左边显示数量,右边显示概率
  94. yAxis: [{
  95. splitLine: {     show: false   },
  96. type: 'value',
  97. name: '销售量',
  98. // max: 10000,
  99. // min: 0,
  100. // show: true,
  101. // interval: 1000,
  102. // 改变y轴颜色
  103. axisLine: {
  104. lineStyle: {
  105. color: '#00a2e2',
  106. width: 1, // 这里是为了突出显示加上的
  107. }
  108. },
  109. }, // 右边显示概率
  110. {
  111. splitLine: {     show: false   },
  112. type: 'value',
  113. name: '销售额',
  114. // min: 0,
  115. // max: 100,
  116. // interval: 10,
  117. // 改变y轴颜色
  118. axisLine: {
  119. lineStyle: {
  120. color: '#00a2e2',
  121. width: 1, // 这里是为了突出显示加上的
  122. }
  123. }
  124. }],
  125. // 每个设备分数量、概率2个指标,只要让他们的name一致,即可通过,legeng进行统一的切换
  126. series: [{
  127. name: 'Units Sold',
  128. type: 'bar',
  129. symbol: 'circle', // 折线点设置为实心点
  130. symbolSize: 4, // 折线点的大小
  131. data: totalNumberList,
  132. barWidth: '20%',
  133. },{
  134. //折线
  135. name: 'Sales',
  136. type: 'line',
  137. symbol: 'circle', // 折线点设置为实心点
  138. symbolSize: 6, // 折线点的大小
  139. yAxisIndex: 1, // 这里要设置哪个y轴,默认是最左边的是0,然后1,2顺序来。
  140. data: totalSalesList,
  141. symbolSize: 10,
  142. itemStyle: {
  143. normal: {
  144. color: "#DDA0DD"
  145. }
  146. }
  147. },
  148. ]
  149. });
  150. }
  151. function queryWeekly(){
  152. var startWeek = document.getElementById("startWeek").value;
  153. var endWeek = document.getElementById("endWeek").value;
  154. var param = {
  155. startWeek:startWeek,
  156. endWeek:endWeek
  157. };
  158. console.log(param);
  159. // 折线图
  160. $.ajax({
  161. url: "../monthly/customersQueryByWeek",
  162. data: param,
  163. contentType:"application/x-www-form-urlencoded",
  164. type: 'POST',
  165. success: function(data) {
  166. console.log(JSON.stringify(data))
  167. dFun(data.dateList, data.totalNumberList, data.totalSalesList);
  168. },
  169. });
  170. }
  171. let vm = new Vue({
  172. el: '#rrapp',
  173. data: {
  174. date: '',
  175. refreshTime: 10,
  176. type: 'store',
  177. refreshCount:0,
  178. storeId: '',
  179. merchSn: '',
  180. merchName: '',
  181. storeName: '',
  182. salesDate: '',
  183. totalSales: '',
  184. actualSales: '',
  185. preferentialLoss: '',
  186. totalCost: '',
  187. grossProfit: '',
  188. grossProfitRatio: '',
  189. proportion: '',
  190. guestNumber: '',
  191. guestUnitPrice: '',
  192. lastSalesTime: '',
  193. categoryId: '',
  194. categoryName: '',
  195. showList: false,
  196. compareDate: '',//比较日期
  197. storeId2: '',
  198. merchSn2: '',
  199. merchName2: '',
  200. storeName2: '',
  201. salesDate2: '',
  202. totalSales2: '',
  203. actualSales2: '',
  204. preferentialLoss2: '',
  205. totalCost2: '',
  206. grossProfit2: '',
  207. grossProfitRatio2: '',
  208. proportion2: '',
  209. guestNumber2: '',
  210. guestUnitPrice2: '',
  211. lastSalesTime2: '',
  212. intervalId: 0,
  213. isCompare: false,
  214. compare2: '',
  215. temp: {
  216. date: '',
  217. refreshTime: 10,
  218. type: '',
  219. storeId: '',
  220. merchSn: '',
  221. salesDate: '',
  222. categoryId: ''
  223. },
  224. rateList: [
  225. {
  226. id: '0',
  227. name: '含税'
  228. },
  229. {
  230. id: '1',
  231. name: '不含税'
  232. }
  233. ],
  234. projectList: [
  235. {
  236. id: '0',
  237. name: '销售总额'
  238. },
  239. {
  240. id: '1',
  241. name: '客单价'
  242. }
  243. ],
  244. seriesTypeList: [
  245. {
  246. id: 'bar',
  247. name: '垂直柱状图'
  248. },
  249. {
  250. id: 'line',
  251. name: '折线图'
  252. },
  253. {
  254. id: 'pie',
  255. name: '饼图'
  256. }
  257. ],
  258. formatsList: [
  259. {
  260. id: '0',
  261. name: '<全部>'
  262. },
  263. {
  264. id: '1',
  265. name: '<非全部>'
  266. }
  267. ],
  268. salesList: [
  269. {
  270. store: {storeId: '11106', storeName: '前海店'},
  271. totalSales: 43046.18,
  272. actualSales: 35593.46
  273. }
  274. ],
  275. dept: {
  276. deptId: '',
  277. deptName: ''
  278. },
  279. category: {
  280. categoryId: '',
  281. categoryName: ''
  282. },
  283. seriesList: [], //保存饼图数据
  284. seriesList2: [],
  285. xAxisList: { //主要用于保存 启动刷新时的条件和数据
  286. storeId: '',
  287. storeName: '',
  288. merchSn: '',
  289. merchName: '',
  290. totalSales: '',
  291. actualSales: '',
  292. preferentialLoss: '',
  293. totalCost: '',
  294. grossProfit: '',
  295. grossProfitRatio: '',
  296. proportion: '',
  297. guestNumber: '',
  298. guestUnitPrice: '',
  299. lastSalesTime: '',
  300. salesDate: '0',
  301. projectSelect: '0',
  302. type:''
  303. },
  304. dataList: [],
  305. tooltip: {},
  306. today:''
  307. },
  308. created() {
  309. this.rateSelect = this.rateList[0].id;
  310. this.projectSelect = this.projectList[0].id;
  311. this.seriesTypeSelect = this.seriesTypeList[0].id;
  312. this.formatsSelect = this.formatsList[0].id;
  313. },
  314. methods: {
  315. seriesTypeSwitch: function () {
  316. console.log(vm.seriesTypeSelect);
  317. },
  318. showEcharts: function () {
  319. // 基于准备好的dom,初始化echarts实例
  320. myChart = echarts.init(document.getElementById('main'));
  321. myChart.clear();
  322. //加载动画
  323. myChart.showLoading();
  324. //项目下拉框判断 6-19,饼图设置 vm.xAxisList
  325. var temp = '';
  326. if (vm.xAxisList.projectSelect == '0') {
  327. if (vm.xAxisList.type == 'dept') {
  328. temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/销售总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
  329. } else {
  330. temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/销售总额:' + vm.xAxisList.totalSales + '元(' + vm.xAxisList.salesDate + ')';
  331. }
  332. vm.seriesList2.push(vm.xAxisList.totalSales);
  333. vm.seriesList.push({value: vm.xAxisList.totalSales, name: temp});
  334. } else if (vm.xAxisList.projectSelect == '1') {
  335. if (vm.xAxisList.type == 'dept') {
  336. temp = '[' + vm.xAxisList.merchSn + ']' + vm.xAxisList.merchName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
  337. } else {
  338. temp = '[' + vm.xAxisList.storeId + ']' + vm.xAxisList.storeName + '/客单价:' + vm.xAxisList.guestUnitPrice + '元(' + vm.xAxisList.salesDate + ')';
  339. }
  340. vm.seriesList2.push(vm.xAxisList.guestUnitPrice);
  341. vm.seriesList.push({value: vm.xAxisList.guestUnitPrice, name: temp});
  342. }
  343. vm.dataList = [temp];
  344. if (vm.seriesTypeSelect == "pie") {
  345. vm.seriesList2 = vm.seriesList.concat();
  346. }
  347. // console.log('vm.seriesList2');
  348. // console.log(vm.seriesList2);
  349. // 指定图表的配置项和数据
  350. //销售量
  351. var option = {
  352. title: {
  353. // textAlign: 'right',
  354. text: 'Monthly Customers & Avg Basket',
  355. x: 'center',
  356. textStyle: {
  357. //文字颜色
  358. color: '#17233d',
  359. //字体风格,'normal','italic','oblique'
  360. fontStyle: 'normal',
  361. //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
  362. fontWeight: 'bold',
  363. //字体系列
  364. fontFamily: 'sans-serif',
  365. //字体大小
  366. fontSize: 28
  367. }
  368. },
  369. tooltip: {
  370. formatter: function (params) {
  371. return params.name;
  372. }
  373. },
  374. legend: {
  375. data: ['/销售总额']
  376. },
  377. xAxis: {
  378. data: vm.dataList,
  379. axisLabel: {
  380. interval: 0
  381. }
  382. },
  383. yAxis: {},
  384. series: [{
  385. barMaxWidth: '20%',
  386. barWidth: '50%',
  387. radius: '55%',
  388. roseType: 'angle',
  389. type: vm.seriesTypeSelect,
  390. color: ['#dd6b66', '#759aa0'],
  391. data: vm.seriesList2
  392. }]
  393. };
  394. //隐藏
  395. myChart.hideLoading();
  396. // 使用刚指定的配置项和数据显示图表。
  397. myChart.setOption(option);
  398. },
  399. tooltipFormatter: function () {
  400. if (vm.type == 'dept') {
  401. return '[' + vm.merchSn + ']' + vm.merchName + '/销售总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
  402. }
  403. return '[' + vm.storeId + ']' + vm.storeName + '/销售总额:' + vm.totalSales + '元(' + vm.salesDate + ')';
  404. },
  405. showTable: function (postParam) {
  406. console.log(postParam);
  407. $("#jqGrid").jqGrid('setGridParam', {
  408. postData: postParam
  409. }).trigger("reloadGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
  410. },
  411. switchProjectView: function () {
  412. console.log(vm.projectSelect);
  413. }
  414. }
  415. });