panel.blade.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. @extends('layouts.app')
  2. @section('title')控制台@endsection
  3. @section('content')
  4. <div class="container-fluid" id="list">
  5. <div class="card">
  6. <h5 class="card-header">最近使用功能</h5>
  7. <div class="card-body row">
  8. <ul class="list-group" v-for="(menu,index) in menus">
  9. <div class="container-fluid btn-group justify-content-center">
  10. <a class="btn-primary btn-lg" v-if="index<=3" :href="'/'+menu.route">@{{ menu.name }}</a>
  11. </div>
  12. <div v-if="menu.secondLevelMenu && menu.secondLevelMenu.length>0&&index<=3">
  13. <div class="container-fluid btn-group m-1">
  14. <a class="bth btn-sm btn-info m-1" v-for="(secondMenu,index) in menu.secondLevelMenu"
  15. :href="'/'+secondMenu.route" v-if="index < 2"> @{{ secondMenu.name }}</a>
  16. </div>
  17. </div>
  18. </ul>
  19. </div>
  20. </div>
  21. <div class="row my-3">
  22. <div class="col-2">
  23. <div class="card">
  24. <div class="card-header text-dark h5">
  25. <p>实时待处理订(总):@{{ totalOrders.total }}</p>
  26. </div>
  27. <div class="card-body">
  28. <p>创建订单:@{{ totalOrders.createOrder }}</p>
  29. <p>分配完成:@{{ totalOrders.assignedComplete }}</p>
  30. <p>部分分配:@{{ totalOrders.partialAllocation }}</p>
  31. <p>部分装箱:@{{ totalOrders.partPacking }}</p>
  32. <p>播种完成:@{{ totalOrders.sowComplete }}</p>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="col-2" v-for="(warehousesOrder,index) in warehousesOrders">
  37. <div class="card">
  38. <div class="card-header text-success h5">
  39. <p>@{{ getWareHouse(warehousesOrder.name) }}:@{{ warehousesOrder.total }}</p>
  40. </div>
  41. <div class="card-body">
  42. <p>创建订单:@{{ warehousesOrder.createOrder }}</p>
  43. <p>分配完成:@{{ warehousesOrder.assignedComplete }}</p>
  44. <p>部分分配:@{{ warehousesOrder.partialAllocation }}</p>
  45. <p>部分装箱:@{{ warehousesOrder.partPacking }}</p>
  46. <p>播种完成:@{{ warehousesOrder.sowComplete }}</p>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="row my-3">
  52. <div class="col-5">
  53. <div class="card">
  54. <div class="card-header">
  55. <span class="demonstration" ></span>
  56. <el-date-picker @blur="orderCountingRecordApi('')"
  57. v-model="orderCountingRecordsDate"
  58. type="daterange"
  59. align="right"
  60. unlink-panels
  61. range-separator="-"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. value-format="yyyy-MM-dd"
  65. :picker-options="pickerOptions">
  66. </el-date-picker>
  67. <el-button type="primary" value="日" @click="orderCountingRecordApi('日')" v-model="unit">日</el-button>
  68. <el-button type="primary" value="周" @click="orderCountingRecordApi('周')" v-model="unit">周</el-button>
  69. <el-button type="primary" value="月" @click="orderCountingRecordApi('月')" v-model="unit">月</el-button>
  70. </div>
  71. <div class="card-body row">
  72. <div id="orderCountingRecords" class="col" style="width:600px;height:600px;"></div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="col-7">
  77. <div class="row">
  78. <div class="col-6">
  79. <div class="card">
  80. <div class="card-header">
  81. <div class="col-5 row">
  82. <div class="block">
  83. <span class="demonstration"></span>
  84. <el-date-picker @blur="logisticsCountingRecordsApi()"
  85. v-model="logisticsCountingRecordsData"
  86. type="daterange"
  87. align="right"
  88. unlink-panels
  89. range-separator="-"
  90. start-placeholder="开始日期"
  91. end-placeholder="结束日期"
  92. value-format="yyyy-MM-dd"
  93. :picker-options="pickerOptions">
  94. </el-date-picker>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="card-body row">
  99. <div id="logisticsCountingRecords" class="col"
  100. style="width: 600px;height:600px;"></div>
  101. </div>
  102. </div>
  103. </div>
  104. <div class="col-6">
  105. <div class="card">
  106. <div class="card-header">
  107. <div class="col-5 row">
  108. <div class="block">
  109. <span class="demonstration"></span>
  110. <el-date-picker @blur="warehouseCountingRecordsApi()"
  111. v-model="warehouseCountingRecordsData"
  112. type="daterange"
  113. align="right"
  114. unlink-panels
  115. range-separator="-"
  116. start-placeholder="开始日期"
  117. end-placeholder="结束日期"
  118. value-format="yyyy-MM-dd"
  119. :picker-options="pickerOptions">
  120. </el-date-picker>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="card-body row">
  125. <div id="warehouseCountingRecords" class="col"
  126. style="width: 600px;height:600px;"></div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. @endsection
  135. @section('lastScript')
  136. <script src="{{ mix('js/echarts.js') }}"></script>
  137. <!-- 引入样式 -->
  138. <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  139. <!-- 引入组件库 -->
  140. <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  141. <script>
  142. let vue = new Vue({
  143. el: "#list",
  144. data: {
  145. myChart: null,
  146. menus:{!! $menus !!},
  147. warehousesOrders:{!! $warehousesOrders !!},
  148. orderCountingRecords:{!! $orderCountingRecords !!},
  149. logisticsCountingRecords:{!! $logisticsCountingRecords !!},
  150. warehouseCountingRecords:{!! $warehouseCountingRecords !!},
  151. warehouses: {},
  152. totalOrders: {
  153. total: null,
  154. createOrder: null,
  155. assignedComplete: null,
  156. partialAllocation: null,
  157. partPacking: null,
  158. sowComplete: null,
  159. },
  160. orderCountingRecordsDateTarget: [],
  161. orderCountingRecordsData: [],
  162. pickerOptions: {
  163. shortcuts: [{
  164. text: '最近一周',
  165. onClick(picker) {
  166. const end = new Date();
  167. const start = new Date();
  168. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  169. picker.$emit('pick', [start, end]);
  170. }
  171. }, {
  172. text: '最近一个月',
  173. onClick(picker) {
  174. const end = new Date();
  175. const start = new Date();
  176. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  177. picker.$emit('pick', [start, end]);
  178. }
  179. }, {
  180. text: '最近三个月',
  181. onClick(picker) {
  182. const end = new Date();
  183. const start = new Date();
  184. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  185. picker.$emit('pick', [start, end]);
  186. }
  187. }]
  188. },
  189. orderCountingRecordsDate: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
  190. moment(new Date()).format('yyyy-MM-DD')],
  191. logisticsCountingRecordsData: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
  192. moment(new Date()).format('yyyy-MM-DD')],
  193. warehouseCountingRecordsData: [moment(new Date(new Date().getTime() - 3600 * 1000 * 24 * 30)).format('yyyy-MM-DD'),
  194. moment(new Date()).format('yyyy-MM-DD')],
  195. unit: '日'
  196. },
  197. mounted: function () {
  198. let _this = this;
  199. this.warehouses = {
  200. "WH01": '松江一仓',
  201. "WH02": '松江二仓',
  202. "WH03": '嘉定一仓',
  203. }
  204. this.warehousesOrders.forEach(function (item) {
  205. _this.totalOrders.total += parseInt(item.total);
  206. _this.totalOrders.createOrder += item.createOrder;
  207. _this.totalOrders.assignedComplete += item.assignedComplete;
  208. _this.totalOrders.partialAllocation += item.partialAllocation;
  209. _this.totalOrders.partPacking += item.partPacking;
  210. _this.totalOrders.sowComplete += item.sowComplete;
  211. });
  212. this.initOrderCountingRecords();
  213. this.orderCountingRecordsChart = echarts.init(document.getElementById('orderCountingRecords'));
  214. this.initOrderCountingRecordsChart();
  215. this.logisticsCountingRecordsChart = echarts.init(document.getElementById('logisticsCountingRecords'));
  216. this.initLogisticsCountingRecordsChart();
  217. this.warehouseCountingRecordsChart = echarts.init(document.getElementById('warehouseCountingRecords'));
  218. this.initWarehouseCountingRecordsChart();
  219. },
  220. methods: {
  221. getWareHouse: function (code) {
  222. return this.warehouses[code];
  223. },
  224. initOrderCountingRecords() {
  225. let _this = this;
  226. this.orderCountingRecords.forEach(function (item) {
  227. _this.orderCountingRecordsDateTarget.push(item.date_target);
  228. _this.orderCountingRecordsData.push(item.counter);
  229. });
  230. },
  231. initOrderCountingRecordsChart() {
  232. this.orderCountingRecordsChart.setOption({
  233. title: {text: '实时待处理订单'},
  234. tooltip: {},
  235. legend: {data: ['订单数']},
  236. xAxis: {
  237. type: 'category',
  238. data: this.orderCountingRecordsDateTarget
  239. },
  240. yAxis: {type: 'value'},
  241. series: [{
  242. data: this.orderCountingRecordsData,
  243. type: 'line',
  244. smooth: true
  245. }]
  246. });
  247. },
  248. initLogisticsCountingRecordsChart() {
  249. this.logisticsCountingRecordsChart.setOption({
  250. title: {
  251. text: '快递分布',
  252. left: 'left'
  253. },
  254. tooltip: {
  255. trigger: 'item',
  256. formatter: '{a} <br/>{b} : {c} ({d}%)'
  257. },
  258. series: [
  259. {
  260. name: '访问来源',
  261. type: 'pie',
  262. radius: '55%',
  263. center: ['50%', '60%'],
  264. data: this.logisticsCountingRecords,
  265. emphasis: {
  266. itemStyle: {
  267. shadowBlur: 10,
  268. shadowOffsetX: 0,
  269. shadowColor: 'rgba(0, 0, 0, 0.5)'
  270. }
  271. }
  272. }
  273. ]
  274. });
  275. },
  276. initWarehouseCountingRecordsChart() {
  277. this.warehouseCountingRecordsChart.setOption({
  278. title: {
  279. text: '仓库分布',
  280. left: 'left'
  281. },
  282. tooltip: {
  283. trigger: 'item',
  284. formatter: '{a} <br/>{b} : {c} ({d}%)'
  285. },
  286. series: [
  287. {
  288. name: '访问来源',
  289. type: 'pie',
  290. radius: '55%',
  291. center: ['50%', '60%'],
  292. data: this.warehouseCountingRecords,
  293. emphasis: {
  294. itemStyle: {
  295. shadowBlur: 10,
  296. shadowOffsetX: 0,
  297. shadowColor: 'rgba(0, 0, 0, 0.5)'
  298. }
  299. }
  300. }
  301. ]
  302. });
  303. },
  304. orderCountingRecordApi(unit) {
  305. this.unit = unit;
  306. let formData = new FormData();
  307. formData.append('start', this.orderCountingRecordsDate[0]);
  308. formData.append('end', this.orderCountingRecordsDate[1]);
  309. formData.append('unit', unit);
  310. console.log(formData.get('unit'));
  311. let _this = this;
  312. axios.post('{{url('apiLocal/control/panel/menu/orderCountingRecordApi')}}', formData).then(function (res) {
  313. if (res.status === 200) {
  314. _this.orderCountingRecords = res.data.orderCountingRecords;
  315. _this.orderCountingRecordsDateTarget = [];
  316. _this.orderCountingRecordsData = [];
  317. _this.initOrderCountingRecords();
  318. _this.initOrderCountingRecordsChart();
  319. }
  320. });
  321. },
  322. logisticsCountingRecordsApi() {
  323. let formData = new FormData();
  324. formData.append('start', this.logisticsCountingRecordsData[0]);
  325. formData.append('end', this.logisticsCountingRecordsData[1]);
  326. let _this = this;
  327. axios.post('{{url('apiLocal/control/panel/menu/logisticsCountingRecordsApi')}}', formData).then(function (res) {
  328. if (res.status === 200) {
  329. _this.logisticsCountingRecords = res.data.logisticsCountingRecords;
  330. _this.initLogisticsCountingRecordsChart();
  331. }
  332. });
  333. },
  334. warehouseCountingRecordsApi() {
  335. let formData = new FormData();
  336. formData.append('start', this.warehouseCountingRecordsData[0]);
  337. formData.append('end', this.warehouseCountingRecordsData[1]);
  338. let _this = this;
  339. axios.post('{{url('apiLocal/control/panel/menu/warehouseCountingRecordsApi')}}', formData).then(function (res) {
  340. if (res.status === 200) {
  341. _this.warehouseCountingRecords = res.data.warehouseCountingRecords;
  342. _this.initWarehouseCountingRecordsChart();
  343. }
  344. });
  345. },
  346. }
  347. });
  348. </script>
  349. @endsection