panel.blade.php 18 KB

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