stock_trend.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="content" style="height: 724px;">
  3. <div id="echartTrend">
  4. <div class="trend-title">出入库趋势-最近1月</div>
  5. <div style="width: 100%;height:80%;" ref="echartTrendLast"></div>
  6. </div>
  7. <div style="height: 53%;position: relative;margin-top: 4%;background: #ffffff3d;">
  8. <div style="position: absolute;" id="totalStock"><b>{{ stockData.curr }}</b><div style="line-height: 0px;font-size: 12px;">当前库存</div></div>
  9. <div id="inlist">
  10. <div class="trend-title" style="height: 18%"><span>当日入库明细</span><div style="line-height: 18px; text-align: left;font-size: 16px;">当日总入库库存:<b>{{ stockData['d-in'] }}</b></div></div>
  11. <div style="width: 100%;height:79%;overflow-y: auto;">
  12. <table style="width: 100%;">
  13. <thead>
  14. <tr style="text-align: center;font-weight: bold;">
  15. <td width="30%">物料类型</td>
  16. <td width="40%">单据类型</td>
  17. <td width="30%">数量 ({{unit}})</td>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. <tr v-for="item in stockData['in']">
  22. <td width="30%">{{item.clas}}</td>
  23. <td width="40%">{{item.type}}</td>
  24. <td width="30%">{{item.total}}</td>
  25. </tr>
  26. </tbody>
  27. </table>
  28. </div>
  29. </div>
  30. <div id="outlist">
  31. <div class="trend-title" style="height: 18%"><span>当日出库明细</span><div style="line-height: 18px; text-align: right;font-size: 16px;">当日总出库库存:<b>{{stockData['d-out']}}</b></div></div>
  32. <div style="width: 100%;height:79%;overflow-y: auto;">
  33. <table style="width: 100%;">
  34. <thead>
  35. <tr style="text-align: center;font-weight: bold;">
  36. <td width="30%">物料类型</td>
  37. <td width="40%">单据类型</td>
  38. <td width="30%">数量 ({{unit}})</td>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. <tr v-for="item in stockData['out']">
  43. <td width="30%">{{item.clas}}</td>
  44. <td width="40%">{{item.type}}</td>
  45. <td width="30%">{{item.total}}</td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <style>
  55. @import '../../styles/main.css';
  56. </style>
  57. <style>
  58. body{
  59. overflow: hidden;
  60. }
  61. .content>div{
  62. float: left;
  63. width: 100%;
  64. color: #fff;
  65. }
  66. #echartTrend{
  67. height: 40%;
  68. }
  69. #inlist,#outlist{
  70. width: 48%;
  71. height: 98%;
  72. margin: 1%;
  73. float: left;
  74. }
  75. .trend-title{
  76. width: 100%;height:20%;text-align: center;line-height: 40px;font-weight: bold;font-size: 20px;
  77. }
  78. #totalStock{
  79. position: absolute;
  80. left: 50%;
  81. top: -13%;
  82. width: 100px;
  83. height: 100px;
  84. line-height: 70px;
  85. font-size:16px;
  86. text-align: center;
  87. border: 2px solid rgb(39, 230, 255);
  88. border-radius: 50%;
  89. background: #154360 ;
  90. margin-left: -50px;
  91. color:rgb(39, 230, 255);
  92. }
  93. </style>
  94. <script>
  95. import { ref,onMounted,watch } from 'vue';
  96. import api from "@/api/system";
  97. import * as echarts from 'echarts';
  98. import { ElMessage } from 'element-plus';
  99. export default {
  100. props:{
  101. },
  102. setup(props,{emit}) {
  103. const echartTrendLast = ref(null);
  104. let stockData = ref({trend:[],"in":[],"out":[],"curr":0,"d-in":0,"d-out":0});
  105. let unit = ref('')
  106. function showTrend(data){
  107. var inNum = [],outNum=[];
  108. var times = [];
  109. var v_series = [];
  110. for (var i = 0; i < data.length; i++) {
  111. var tv = data[i]['date'].split("-")
  112. times.push(tv[1] + "-" + tv[2])
  113. inNum.push(data[i]['inNum']);
  114. outNum.push(data[i]['outNum']);
  115. }
  116. if (times.length == 0) {
  117. //t.parent().hide();
  118. } else {
  119. v_series.push({
  120. name: "入库",
  121. type: 'line',
  122. smooth: true,
  123. //symbol: 'none',
  124. data: inNum,
  125. itemStyle: {
  126. normal: {
  127. color: 'yellow', // 这里设置折线的颜色
  128. lineStyle: {
  129. color: 'yellow' // 这里同时设置线头的颜色
  130. }
  131. }
  132. },
  133. });
  134. v_series.push({
  135. name: "出库",
  136. type: 'line',
  137. smooth: true,
  138. //symbol: 'none',
  139. data: outNum,
  140. itemStyle: {
  141. normal: {
  142. color: 'red', // 这里设置折线的颜色
  143. lineStyle: {
  144. color: 'red' // 这里同时设置线头的颜色
  145. }
  146. }
  147. },
  148. });
  149. var opt = {
  150. title: {
  151. show: false, //不显示标题
  152. text: '',
  153. textStyle: {
  154. color: "rgb(89, 151, 229)",
  155. fontWeight: "bold"
  156. },
  157. top: "0px",
  158. left: "30px"
  159. },
  160. tooltip: {
  161. trigger: 'axis',
  162. backgroundColor:'rgba(41,85,137,0.7)',
  163. textStyle: {
  164. // 设置字体颜色
  165. color: '#fff'
  166. },
  167. formatter: function (params) {
  168. let xv='';
  169. let result = '';
  170. params.forEach(function (item) {
  171. xv=`${item.name}<br/>`;
  172. result += ` ${item.marker} ${item.value}(`+unit.value+`)<br/>`;
  173. });
  174. return xv+result;
  175. }
  176. },
  177. legend: {
  178. show: true, //不显示图例
  179. inactiveColor: "#04417A",
  180. data: ["入库","出库"],
  181. textStyle: {color: "#fff"},
  182. top: "-5px"
  183. },
  184. grid: {
  185. left: '1%',
  186. right: '1%',
  187. bottom: '5%',
  188. top: '10%',
  189. containLabel: true
  190. },
  191. xAxis: {
  192. type: 'category',
  193. boundaryGap: false,
  194. axisLabel: {
  195. rotate: 45,
  196. color: "#fff"
  197. },
  198. data: times
  199. },
  200. yAxis: {
  201. type: 'value',
  202. nameTextStyle: {
  203. color: "#fff"
  204. },
  205. axisLabel: {
  206. color: "rgb(203,215,235)"
  207. },
  208. splitLine: {
  209. lineStyle: {
  210. color: "#7DA7CD",
  211. type: "dashed",
  212. width: 1
  213. }
  214. }
  215. },
  216. series: v_series
  217. };
  218. var echartsEle = echarts.init(echartTrendLast.value);
  219. echartsEle.setOption(opt);
  220. }
  221. }
  222. onMounted(()=>{
  223. let typecode = window.location.hash.replace("#","");
  224. unit.value = StockTypeUnit[typecode]
  225. let msg = ElMessage({
  226. message:"正在加载数据",
  227. type:"info",
  228. duration:0,
  229. })
  230. api.GetFacData().then((res)=>{
  231. msg.close();
  232. if (res == null || res[typecode]==null) {
  233. return
  234. }
  235. stockData.value = res[typecode];
  236. var datalist = res[typecode]['trend'];
  237. if(datalist!=null) showTrend(datalist);
  238. //var indatalst = res[typecode]['in'];
  239. //var outdatalst = res[typecode]['out'];
  240. }).catch(()=>{
  241. ElMessage({
  242. message:"数据获取失败!",
  243. type:"error",
  244. });
  245. });
  246. });
  247. return{
  248. echartTrendLast,
  249. stockData,
  250. unit,
  251. }
  252. }
  253. }
  254. </script>