home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='仓储管理' :showback='false' bgColor='transparent'></cus-header>
  4. <image class="topbg" :src="imgBase+'storage/home_bg.png'" mode="widthFix"></image>
  5. <div class="inout" :style="{'backgroundImage':'url('+imgBase+'/storage/home_bgimg1.png)'}">
  6. <div class="pre">
  7. <text>入库总量</text>
  8. <p>{{priceFormat(inNum,0)}}</p>
  9. </div>
  10. <div class="line"></div>
  11. <div class="pre">
  12. <text>出库总量</text>
  13. <p>{{outNum}}</p>
  14. </div>
  15. </div>
  16. <div class="menus">
  17. <div class="item" v-for="(item,index) in menuList" :key="index" @tap="toTurn(item.path)">
  18. <image :src="item.icon" :class="index<4?'img1':'img2'"></image>
  19. <p :class="index<4?'p1':'p2'">{{item.title}}</p>
  20. </div>
  21. </div>
  22. <div class="chartBox">
  23. <p class="title">库存数量占比</p>
  24. <div class="chart">
  25. <l-echart ref="kcslzbChartRef" :canvas2d="true" @finished="initKcslzb"></l-echart>
  26. </div>
  27. </div>
  28. <div class="chartBox">
  29. <p class="title">入库统计</p>
  30. <div class="chart">
  31. <div class="btns">
  32. <div class="pre" :class="{'active':rkIdx===0}" @tap="changeRkCahrtData(0)">按月</div>
  33. <div class="pre" :class="{'active':rkIdx===1}" @tap="changeRkCahrtData(1)">按年</div>
  34. </div>
  35. <l-echart ref="rktjChartRef" :canvas2d="true" @finished="initRktj"></l-echart>
  36. </div>
  37. </div>
  38. <div class="chartBox">
  39. <p class="title">出库统计</p>
  40. <div class="chart">
  41. <div class="btns">
  42. <div class="pre" :class="{'active':ckIdx===0}" @tap="changeCkCahrtData(0)">按月</div>
  43. <div class="pre" :class="{'active':ckIdx===1}" @tap="changeCkCahrtData(1)">按年</div>
  44. </div>
  45. <l-echart ref="cktjChartRef" :canvas2d="true" @finished="initCktj"></l-echart>
  46. </div>
  47. </div>
  48. <Tabbar :tabbarIndex="2"></Tabbar>
  49. </div>
  50. </template>
  51. <script>
  52. import * as echarts from '@/pagesStorage/components/lime-echart/static/echarts.min.js'
  53. import lEchart from '@/pagesStorage/components/lime-echart/components/l-echart/l-echart.vue'
  54. import Tabbar from '@/components/CusTabbar/index.vue'
  55. export default {
  56. components:{
  57. lEchart,
  58. Tabbar
  59. },
  60. data(){
  61. return {
  62. inNum:0,
  63. outNum:0,
  64. menuList:[
  65. {
  66. icon:this.$imgBase+'storage/home_icon_rk.png',
  67. title:'入库',
  68. path:'/pagesStorage/inStorage/index'
  69. },
  70. {
  71. icon:this.$imgBase+'storage/home_icon_ck.png',
  72. title:'出库',
  73. path:'/pagesStorage/outStorage/index'
  74. },
  75. {
  76. icon:this.$imgBase+'storage/home_icon_pk.png',
  77. title:'盘库',
  78. path:'/pagesStorage/checkStorage/index'
  79. },
  80. {
  81. icon:this.$imgBase+'storage/home_icon_yk.png',
  82. title:'移库',
  83. path:'/pagesStorage/moveStorage/index'
  84. },
  85. {
  86. icon:this.$imgBase+'storage/home_icon_kcjl.png',
  87. title:'库存记录',
  88. path:'/pagesStorage/storageRecord/index'
  89. },
  90. {
  91. icon:this.$imgBase+'storage/home_icon_kctj.png',
  92. title:'库存统计',
  93. path:'/pagesStorage/inventoryStatistics/index'
  94. },
  95. {
  96. icon:this.$imgBase+'storage/home_icon_wldw.png',
  97. title:'往来单位',
  98. path:'/pagesStorage/units/index'
  99. },
  100. {
  101. icon:this.$imgBase+'storage/home_icon_ckgl.png',
  102. title:'仓库管理',
  103. path:'/pagesStorage/storage/index'
  104. }
  105. ],
  106. rkIdx:0,
  107. ckIdx:0,
  108. }
  109. },
  110. onLoad() {
  111. this.getHeaderInfo();
  112. },
  113. methods:{
  114. toTurn(url){
  115. if(!url) return;
  116. uni.navigateTo({ url })
  117. },
  118. //头部统计信息
  119. getHeaderInfo(){
  120. this.$api.post('/wms/home/getAppHomeHeadGather').then(res=>{
  121. if(res.data.code===0){
  122. this.inNum = res.data.data.find(d=>d.orderType==1).total||0;
  123. this.outNum = res.data.data.find(d=>d.orderType==2).total||0;
  124. }else this.$showToast(res.data.msg)
  125. })
  126. },
  127. // 库存数量占比
  128. async getKcslzbData(){
  129. let res = await this.$api.post('/wms/home/getWarehouseCargoRatio');
  130. if(res.data.code===0){
  131. let data = res.data.data.map(d=>{
  132. return {
  133. value:d.quantity,
  134. name:d.warehouseName
  135. }
  136. })
  137. return data;
  138. }else{
  139. this.$showToast(res.data.msg);
  140. return [];
  141. }
  142. },
  143. async initKcslzb() {
  144. let data = await this.getKcslzbData();
  145. const chart = await this.$refs.kcslzbChartRef.init(echarts);
  146. let option = {
  147. legend: {
  148. top: 'bottom'
  149. },
  150. tooltip: {
  151. trigger: 'item'
  152. },
  153. series: [
  154. {
  155. name: '库存数量占比',
  156. type: 'pie',
  157. radius: [20, 100],
  158. center: ['50%', '42%'],
  159. itemStyle: {
  160. borderRadius: 5
  161. },
  162. data
  163. }
  164. ]
  165. };
  166. chart.setOption(option)
  167. },
  168. //入库统计
  169. async getRktjData(){
  170. let res = await this.$api.get('/wms/home/getReceiptTrend/'+(this.rkIdx+1));
  171. if(res.data.code===0){
  172. let xData = res.data.data.map(d=>d.optTime);
  173. let yData = res.data.data.map(d=>d.quantity);
  174. return {xData,yData}
  175. }else{
  176. this.$showToast(res.data.msg);
  177. return {xData:[],yData:[]};
  178. }
  179. },
  180. async initRktj(){
  181. let {xData,yData} = await this.getRktjData();
  182. const chart = await this.$refs.rktjChartRef.init(echarts);
  183. let option = {
  184. title: {
  185. text: '数量',
  186. textStyle:{
  187. fontSize:16,
  188. color:'#86909C'
  189. }
  190. },
  191. xAxis: {
  192. type: 'category',
  193. data: xData
  194. },
  195. yAxis: {
  196. type: 'value'
  197. },
  198. tooltip: {
  199. trigger: 'axis',
  200. axisPointer: {
  201. type: 'cross',
  202. label: {
  203. backgroundColor: '#6a7985'
  204. }
  205. }
  206. },
  207. grid: {
  208. left: '1%',
  209. right: '1%',
  210. bottom: '10%',
  211. top: '18%',
  212. containLabel: true
  213. },
  214. series: [
  215. {
  216. name:'入库数量',
  217. data: yData,
  218. type: 'line',
  219. lineStyle:{
  220. color:'#198CFF',
  221. width: 3
  222. },
  223. symbol:'none',
  224. areaStyle: {
  225. color:'rgba(25,140,255,.4)'
  226. },
  227. smooth: true
  228. }
  229. ]
  230. };
  231. chart.setOption(option);
  232. },
  233. changeRkCahrtData(type){
  234. this.rkIdx = type;
  235. this.initRktj();
  236. },
  237. //出库统计
  238. async getCktjData(){
  239. let res = await this.$api.get('/wms/home/getShipmentTrend/'+(this.ckIdx+1));
  240. if(res.data.code===0){
  241. let xData = res.data.data.map(d=>d.optTime);
  242. let yData = res.data.data.map(d=>d.quantity);
  243. return {xData,yData}
  244. }else{
  245. this.$showToast(res.data.msg);
  246. return {xData:[],yData:[]};
  247. }
  248. },
  249. async initCktj(){
  250. let {xData,yData} = await this.getCktjData();
  251. const chart = await this.$refs.cktjChartRef.init(echarts);
  252. let option = {
  253. title: {
  254. text: '数量',
  255. textStyle:{
  256. fontSize:16,
  257. color:'#86909C'
  258. }
  259. },
  260. xAxis: {
  261. type: 'category',
  262. data: xData
  263. },
  264. yAxis: {
  265. type: 'value'
  266. },
  267. tooltip: {
  268. trigger: 'axis',
  269. axisPointer: {
  270. type: 'cross',
  271. label: {
  272. backgroundColor: '#6a7985'
  273. }
  274. }
  275. },
  276. grid: {
  277. left: '1%',
  278. right: '1%',
  279. bottom: '10%',
  280. top: '18%',
  281. containLabel: true
  282. },
  283. series: [
  284. {
  285. name:'出库数量',
  286. data: yData,
  287. type: 'line',
  288. lineStyle:{
  289. color:'#198CFF',
  290. width: 3
  291. },
  292. symbol:'none',
  293. areaStyle: {
  294. color:'rgba(25,140,255,.4)'
  295. },
  296. smooth: true
  297. }
  298. ]
  299. };
  300. chart.setOption(option);
  301. },
  302. changeCkCahrtData(type){
  303. this.ckIdx = type;
  304. this.initCktj();
  305. },
  306. // 金额格式化
  307. priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparator = ',') {
  308. number = (`${number}`).replace(/[^0-9+-Ee.]/g, '')
  309. const n = !isFinite(+number) ? 0 : +number
  310. const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
  311. const sep = (typeof thousandsSeparator === 'undefined') ? ',' : thousandsSeparator
  312. const dec = (typeof decimalPoint === 'undefined') ? '.' : decimalPoint
  313. let s = ''
  314. s = (prec ? round(n, prec) + '' : `${Math.round(n)}`).split('.')
  315. const re = /(-?\d+)(\d{3})/
  316. while (re.test(s[0])) {
  317. s[0] = s[0].replace(re, `$1${sep}$2`)
  318. }
  319. if ((s[1] || '').length < prec) {
  320. s[1] = s[1] || ''
  321. s[1] += new Array(prec - s[1].length + 1).join('0')
  322. }
  323. return s.join(dec)
  324. },
  325. }
  326. }
  327. </script>
  328. <style scoped lang="less">
  329. .tabPage{
  330. padding: 0 24rpx 188rpx;
  331. background: #F4F8FB;
  332. .topbg{
  333. width: 100%;
  334. position: fixed;
  335. top: 0;
  336. left: 0;
  337. z-index: 0;
  338. }
  339. .inout{
  340. width: 100%;
  341. height: 180rpx;
  342. margin-top: 20rpx;
  343. border-radius: 16rpx;
  344. background-repeat: no-repeat;
  345. background-size: 100% 100%;
  346. position: relative;
  347. display: flex;
  348. align-items: center;
  349. box-sizing: border-box;
  350. .line{
  351. width: 1rpx;
  352. height: 98rpx;
  353. background: rgba(255,255,255,.35);
  354. position: absolute;
  355. left: 50%;
  356. margin-left: -0.5rpx;
  357. top: 50%;
  358. margin-top: -49rpx;
  359. }
  360. .pre{
  361. width: 50%;
  362. padding-left: 30rpx;
  363. text{
  364. font-family: PingFangSC, PingFang SC;
  365. font-weight: 400;
  366. font-size: 28rpx;
  367. color: #FFFFFF;
  368. line-height: 28rpx;
  369. }
  370. p{
  371. font-family: D-DIN, D-DIN;
  372. font-weight: bold;
  373. font-size: 48rpx;
  374. color: #FFFFFF;
  375. line-height: 48rpx;
  376. margin-top: 20rpx;
  377. }
  378. }
  379. }
  380. .menus{
  381. width: 100%;
  382. background: #FFFFFF;
  383. border-radius: 16rpx;
  384. padding: 3rpx 0 33rpx;
  385. box-sizing: border-box;
  386. display: flex;
  387. flex-wrap: wrap;
  388. position: relative;
  389. margin-top: 20rpx;
  390. .item{
  391. width: 25%;
  392. display: flex;
  393. flex-direction: column;
  394. align-items: center;
  395. margin-top: 37rpx;
  396. .img1{
  397. width: 80rpx;
  398. height: 80rpx;
  399. }
  400. .img2{
  401. width: 55rpx;
  402. height: 55rpx;
  403. }
  404. p{
  405. font-family: PingFangSC, PingFang SC;
  406. font-weight: 400;
  407. font-size: 24rpx;
  408. color: #4E5969;
  409. line-height: 33rpx;
  410. text-align: center;
  411. }
  412. .p1{
  413. margin-top: 20rpx;
  414. }
  415. .p2{
  416. margin-top: 14rpx;
  417. }
  418. }
  419. }
  420. .chartBox{
  421. width: 100%;
  422. background: #FFFFFF;
  423. border-radius: 16rpx;
  424. margin-top: 20rpx;
  425. padding: 40rpx 24rpx;
  426. box-sizing: border-box;
  427. position: relative;
  428. .title{
  429. font-family: PingFang-SC, PingFang-SC;
  430. font-weight: bold;
  431. font-size: 36rpx;
  432. color: #1D2129;
  433. line-height: 36rpx;
  434. letter-spacing: 2rpx;
  435. }
  436. .chart{
  437. width: 100%;
  438. position: relative;
  439. .btns{
  440. border: 1rpx solid #ECECEC;
  441. border-radius: 6rpx;
  442. display: flex;
  443. position: absolute;
  444. right: 12rpx;
  445. top: 32rpx;
  446. z-index: 999;
  447. .pre{
  448. padding: 12rpx 16rpx;
  449. font-family: PingFangSC, PingFang SC;
  450. font-weight: 400;
  451. font-size: 24rpx;
  452. color: #86909C;
  453. line-height: 24rpx;
  454. position: relative;
  455. &.active{
  456. color: #198CFF;
  457. }
  458. &:last-child{
  459. border-left: 1rpx solid #ECECEC;
  460. }
  461. }
  462. }
  463. }
  464. }
  465. }
  466. </style>