CustomerWaybill.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <!-- 全月运单量图表 -->
  3. <div style="width: 100%;height: 100%;">
  4. <div class="head_headlineUrl">
  5. <div>{{title}}</div>
  6. <timingFrame @changeTimeType="changeTimeType" @changeMonthTime="changeMonthTime" @changeYearTime="changeYearTime">
  7. </timingFrame>
  8. </div>
  9. <div class="card_collect_customer">
  10. <div class="head_search_customer space_between_in">
  11. <div class="customer_switchover">
  12. <div class="customer_rol center_in text_prohibition" :class="item.flag ? 'customer_active' : ''"
  13. v-for="(item,index) in list" :key="index" @click="selectRol(item)">{{item.title}}</div>
  14. </div>
  15. </div>
  16. <div id="monthCustomer"></div>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import timingFrame from './timingFrame.vue'
  22. export default {
  23. name: 'CustomerWaybill',
  24. components: {
  25. timingFrame
  26. },
  27. props: {
  28. title: {
  29. type: String,
  30. default: () => '文字',
  31. },
  32. dataList: {
  33. type: Array,
  34. default: () => [],
  35. },
  36. },
  37. data() {
  38. return {
  39. value2: '',
  40. timeOut: null,
  41. list: [{
  42. id: 1,
  43. flag: true,
  44. title: '复核人',
  45. type: 'reCheck',
  46. }, {
  47. id: 2,
  48. flag: false,
  49. title: '配送员',
  50. type: 'delivery',
  51. }],
  52. myChart3: null,
  53. }
  54. },
  55. watch: {
  56. dataList: {
  57. handler(newVal) {
  58. if (newVal) {
  59. if (this.myChart3 && newVal.length > 0) {
  60. this.myChart3.clear()
  61. this.getCustomer(newVal)
  62. }
  63. }
  64. },
  65. deep: true, // 是否开启深度监听
  66. immediate: true,
  67. }
  68. },
  69. mounted() {
  70. this.getCustomer()
  71. },
  72. methods: {
  73. // 切换时间类型
  74. changeTimeType(event) {
  75. this.$emit('changeTimeType', event)
  76. },
  77. // 选择月
  78. changeMonthTime(event) {
  79. this.$emit('changeMonthTime', event)
  80. },
  81. // 选择年
  82. changeYearTime(event) {
  83. this.$emit('changeYearTime', event)
  84. },
  85. // 切换
  86. selectRol(event) {
  87. this.list.forEach(item => {
  88. if (item.id == event.id) {
  89. item.flag = true
  90. } else {
  91. item.flag = false
  92. }
  93. })
  94. this.$emit('changeUserType', event.type)
  95. this.$forceUpdate()
  96. },
  97. getCustomer(event) {
  98. var that = this
  99. var chartDom = document.getElementById('monthCustomer');
  100. that.myChart3 = that.$echarts.init(chartDom);
  101. let allData = [];
  102. if (event && event.length > 0) {
  103. allData = event
  104. }
  105. let showFlag = true
  106. if (allData.length > 0) {
  107. showFlag = false
  108. } else if (allData.length == 0) {
  109. showFlag = true
  110. }
  111. var option;
  112. option = {
  113. title: {
  114. show: showFlag,
  115. textStyle: {
  116. color: '#fff',
  117. fontSize: 16,
  118. },
  119. text: '暂无数据',
  120. left: 'center',
  121. top: 'center',
  122. },
  123. tooltip: {
  124. trigger: "axis",
  125. axisPointer: {
  126. type: "shadow"
  127. }
  128. },
  129. legend: {
  130. show: false
  131. },
  132. grid: {
  133. top: '0%',
  134. left: '20%',
  135. bottom: '6%',
  136. },
  137. // 加这块地方重点!!!!!!!
  138. dataZoom: [{
  139. yAxisIndex: 0, //这里是从X轴的0刻度开始
  140. show: false, //是否显示滑动条,不影响使用
  141. type: "slider", // 这个 dataZoom 组件是 slider 型 dataZoom 组件
  142. startValue: 0, // 从头开始。
  143. endValue: 7, // 一次性展示5个。
  144. }],
  145. xAxis: {
  146. type: "value",
  147. splitLine: {
  148. show: false
  149. },
  150. axisLabel: {
  151. color: '#fff',
  152. show: true
  153. },
  154. axisTick: {
  155. show: false
  156. },
  157. axisLine: {
  158. show: false
  159. }
  160. },
  161. yAxis: [{
  162. type: "category",
  163. inverse: true,
  164. axisLine: {
  165. show: false
  166. },
  167. axisTick: {
  168. show: false
  169. },
  170. axisPointer: {
  171. label: {
  172. show: true
  173. }
  174. },
  175. data: allData.map(item => item.name),
  176. axisLabel: {
  177. margin: 20,
  178. fontSize: 14,
  179. color: "#fff"
  180. }
  181. }, {
  182. type: "category",
  183. inverse: true,
  184. axisTick: "none",
  185. axisLine: "none",
  186. offset: -10,
  187. zlevel: 100,
  188. show: true,
  189. position: "left",
  190. axisLabel: {
  191. show: false,
  192. },
  193. data: allData.map(item => item.count)
  194. }],
  195. series: [{
  196. z: 2,
  197. name: "数量",
  198. type: "bar",
  199. align: "left",
  200. // barCategoryGap: '50%',
  201. data: allData
  202. .map(item => item.count)
  203. .map((item, i) => {
  204. return {
  205. value: item,
  206. itemStyle: {
  207. color: "rgba(3, 124, 213, 0.5)"
  208. }
  209. };
  210. }),
  211. label: {
  212. normal: {
  213. show: true,
  214. position: "right",
  215. color: "#fff",
  216. fontSize: 12,
  217. formatter: function(value) {
  218. let val = (value && value.data && value.data.value) || 0;
  219. return parseFloat(val);
  220. }
  221. }
  222. }
  223. }]
  224. };
  225. if (allData.length > 7) {
  226. autoMove()
  227. }
  228. function autoMove() {
  229. // 自动滚动:
  230. that.timeOut = setInterval(() => {
  231. if (option.dataZoom[0].endValue == allData.length) {
  232. option.dataZoom[0].endValue = 7;
  233. option.dataZoom[0].startValue = 0;
  234. } else {
  235. option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1;
  236. option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1;
  237. }
  238. that.myChart3.setOption(option);
  239. that.myChart3.on('mouseover', stop)
  240. that.myChart3.on('mouseout', goMove)
  241. }, 2000)
  242. }
  243. //停止滚动
  244. function stop() {
  245. clearInterval(that.timeOut)
  246. }
  247. //继续滚动
  248. function goMove() {
  249. autoMove()
  250. }
  251. that.myChart3.setOption(option);
  252. },
  253. getResize() {
  254. this.myChart3.resize();
  255. },
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. .head_headlineUrl {
  261. position: relative;
  262. display: flex;
  263. align-items: center;
  264. padding-left: 40px;
  265. margin-left: 10px;
  266. margin-right: 20px;
  267. width: calc(100% - 70px);
  268. height: 50px;
  269. font-size: 18px;
  270. color: #fff;
  271. background: url(../../src/assets/images/headlineUrl.png);
  272. background-size: 100% 100%;
  273. background-repeat: no-repeat;
  274. }
  275. .card_collect_customer {
  276. padding-left: 10px;
  277. width: calc(100% - 30px);
  278. height: calc(100% - 100px);
  279. }
  280. .head_search_customer {
  281. display: flex;
  282. align-items: center;
  283. width: 100%;
  284. height: 50px;
  285. }
  286. .customer_switchover {
  287. display: flex;
  288. align-items: center;
  289. }
  290. .customer_rol {
  291. cursor: pointer;
  292. width: 50px;
  293. height: 30px;
  294. font-size: 13px;
  295. color: #ffffff;
  296. background-color: rgba(7, 56, 78, 1);
  297. }
  298. .customer_active {
  299. background-color: rgba(4, 137, 170, 1);
  300. }
  301. #monthCustomer {
  302. width: 100%;
  303. height: 100%;
  304. }
  305. </style>