index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="app-container home">
  3. <div class="box01">
  4. <div class="top-main">
  5. <span>商品扫码分析</span>
  6. <el-button type="primary" @click="showHandle">扫描日志</el-button>
  7. </div>
  8. <div class="chart-box">
  9. <div class="l01">
  10. <div class="title">
  11. <span>总扫描次数</span>
  12. </div>
  13. <div class="show-main col">
  14. <span class="num">{{ scanNum }}</span>
  15. <div class="msg">最近{{time}}更新</div>
  16. </div>
  17. </div>
  18. <div class="line">
  19. <div class="title">
  20. <span>扫码时间分布</span>
  21. <el-select v-model="select" style="width: 120px;" placeholder="请选择" @change="loadLine">
  22. <el-option
  23. v-for="item in options"
  24. :key="item.value"
  25. :label="item.label"
  26. :value="item.value"
  27. />
  28. </el-select>
  29. </div>
  30. <div class="line-chart" id="line-index"></div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="box02">
  35. <div class="con">
  36. <div class="title">
  37. <span>广告</span>
  38. </div>
  39. <div class="show-main">
  40. <div>
  41. <span class="num">{{ adNum }}</span>
  42. <span class="spec">个</span>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="con">
  47. <div class="title">
  48. <span>设备</span>
  49. <div class="eqiup-state">
  50. <div class="success">正常使用:{{suc}}台</div>
  51. <div class="disad">禁止使用:{{dis}}台</div>
  52. </div>
  53. </div>
  54. <div class="show-main">
  55. <div>
  56. <span class="num">{{ equipNum }}</span>
  57. <span class="spec">台</span>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <scanModal ref="modalView" />
  63. </div>
  64. </template>
  65. <script setup name="Index">
  66. import {equipTotal,scanTotal,planTotal,scanTime,scanLog} from '@/api/base/home'
  67. import { computed,getCurrentInstance,ref,markRaw,shallowRef,defineEmits } from "vue";
  68. const { proxy } = getCurrentInstance();
  69. import * as echarts from 'echarts';
  70. import scanModal from './components/scanModal.vue';
  71. const scanNum = ref(0);
  72. const time = ref('');
  73. const adNum = ref(0);
  74. const equipNum = ref(0);
  75. const suc = ref(0)
  76. const dis = ref(0)
  77. const select = ref('month')
  78. const options = ref([
  79. {
  80. label:'日',
  81. value:'day'
  82. },
  83. {
  84. label:'月',
  85. value:'month'
  86. },
  87. {
  88. label:'年',
  89. value:'year'
  90. }
  91. ])
  92. const showHandle = () => {
  93. proxy.$refs.modalView.setShow(true)
  94. }
  95. const initLine = data => {
  96. let chartDom = document.getElementById('line-index');
  97. let myChart = echarts.init(chartDom);
  98. let option;
  99. let dataX = [];
  100. let dataY = [];
  101. for(let i = data.length - 1; i >= 0; i--){
  102. let item = data[i];
  103. dataX.push(item.time);
  104. dataY.push(item.count)
  105. }
  106. option = {
  107. xAxis: {
  108. type: 'category',
  109. data: dataX
  110. },
  111. yAxis: {
  112. type: 'value'
  113. },
  114. tooltip: {
  115. trigger: 'axis'
  116. },
  117. series: [
  118. {
  119. data: dataY,
  120. type: 'line'
  121. }
  122. ]
  123. };
  124. option && myChart.setOption(option);
  125. }
  126. const getEquip = () => {
  127. scanTotal().then(res => {
  128. scanNum.value = res.data.total;
  129. time.value = res.data.time;
  130. }).catch(() =>{})
  131. }
  132. const getAdCount = () => {
  133. planTotal().then(res => {
  134. adNum.value = res.data.total;
  135. time.value = res.data.time;
  136. }).catch(() =>{})
  137. }
  138. const getEquipTotal = () => {
  139. equipTotal().then(res => {
  140. equipNum.value = res.data.total;
  141. dis.value = res.data[1]
  142. suc.value = res.data[0]
  143. }).catch(() =>{})
  144. }
  145. const loadLine = () => {
  146. scanTime({option:select.value}).then(res => {
  147. initLine(res.data)
  148. }).catch(() =>{})
  149. }
  150. getEquip();
  151. loadLine();
  152. getAdCount();
  153. getEquipTotal();
  154. </script>
  155. <style scoped lang="scss">
  156. .home {
  157. width: calc(100% - 64px);
  158. height: calc(100% - 64px);
  159. box-sizing: border-box;
  160. margin: 32px;
  161. .box01{
  162. width: 100%;
  163. height: calc(60% - 16px);
  164. box-sizing: border-box;
  165. padding: 0 24px 24px;
  166. margin-bottom: 16px;
  167. border: solid 1px #BBB;
  168. .top-main{
  169. width: 100%;
  170. height: 70px;
  171. display: flex;
  172. align-items: center;
  173. justify-content: space-between;
  174. border-bottom: solid 1px #BBB;
  175. box-sizing: border-box;
  176. margin-bottom: 16px;
  177. >span{
  178. font-size: 28px;
  179. font-weight: 700;
  180. }
  181. }
  182. .chart-box{
  183. width: 100%;
  184. height: calc(100% - 86px);
  185. display: flex;
  186. .l01{
  187. width: 40%;
  188. height: 100%;
  189. box-sizing: border-box;
  190. border-right: solid 1px #BBB;
  191. }
  192. .line{
  193. width: 60%;
  194. height: calc(100% - 50px);
  195. box-sizing: border-box;
  196. padding-left: 24px;
  197. .line-chart{
  198. height: 100%;
  199. width: 100%;
  200. }
  201. }
  202. }
  203. }
  204. .box02{
  205. width: 100%;
  206. height: 40%;
  207. box-sizing: border-box;
  208. padding: 16px;
  209. border: solid 1px #BBB;
  210. display: flex;
  211. .eqiup-state{
  212. font-size: 12px;
  213. .success{
  214. color: #00AE66;
  215. padding-bottom: 8px;
  216. }
  217. .disad{
  218. color: #f00;
  219. }
  220. }
  221. .con{
  222. width: 50%;
  223. height: 100%;
  224. box-sizing: border-box;
  225. .spec{
  226. font-size: 18px;
  227. padding-left: 16px;
  228. }
  229. }
  230. .con:first-child{
  231. padding-right: 24px;
  232. border-right: solid 1px #BBB;
  233. }
  234. .con:last-child{
  235. padding-left: 24px;
  236. }
  237. }
  238. .title{
  239. height: 50px;
  240. display: flex;
  241. align-items: center;
  242. justify-content: space-between;
  243. width: 100%;
  244. >span{
  245. font-size: 18px;
  246. }
  247. }
  248. .show-main{
  249. height: calc(100% - 50px);
  250. width: 100%;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. .num{
  255. font-size: 72px;
  256. }
  257. .msg{
  258. font-size: 14px;
  259. color: #666;
  260. }
  261. }
  262. .col{
  263. flex-direction: column;
  264. }
  265. }
  266. </style>