data.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. // 引入Day.js库
  2. // const dayjs = require('dayjs');
  3. // var quarterOfYear = require('dayjs/plugin/quarterOfYear');
  4. // dayjs.extend(quarterOfYear);
  5. // // 获取本月日期列表的函数
  6. // function getDatesInMonth() {
  7. // let year = dayjs().year()
  8. // let month = dayjs().month()
  9. // const dates = [];
  10. // const startDate = dayjs(new Date(year, month, 1));
  11. // const endDate = dayjs(new Date(year, month + 1, 1)).subtract(1, 'day');
  12. // let currentDate = startDate;
  13. // while (currentDate.isBefore(endDate) || currentDate.isSame(endDate, 'day')) {
  14. // dates.push(currentDate.format('YYYY-MM-DD'));
  15. // currentDate = currentDate.add(1, 'day');
  16. // }
  17. // return dates;
  18. // }
  19. // // 获取当前日期
  20. // // 获取季度 (1-4)
  21. // function getQuarter() {
  22. // const now = dayjs();
  23. // const quarter = now.quarter();
  24. // const dates = [];
  25. // let start = (quarter - 1) * 3 + 1
  26. // for (let i = 0; i <= 2; i++) {
  27. // dates.push((start + i) + '月')
  28. // }
  29. // console.log(dates)
  30. // return dates;
  31. // }
  32. function getRandomNumber(type) {
  33. let arr = [];
  34. let j = type == 1 ? 5 : type == 2 ? 4 : 12;
  35. for (let i = 0; i < j; i++) {
  36. arr.push(Math.floor(Math.random() * 60));
  37. }
  38. return arr;
  39. }
  40. export const repaireOptions = [
  41. {
  42. title: '巡点检工单',
  43. imgUrl: require('../../assets/vector.png'),
  44. total: 0,
  45. num: 0
  46. },
  47. {
  48. title: '保养工单',
  49. imgUrl: require('../../assets/vector.png'),
  50. total: 0,
  51. num: 0
  52. },
  53. {
  54. title: '维修工单',
  55. imgUrl: require('../../assets/vector.png'),
  56. total: 0,
  57. num: 0
  58. },
  59. {
  60. title: '校准校验工单',
  61. imgUrl: require('../../assets/vector.png'),
  62. total: 0,
  63. num: 0
  64. }
  65. ];
  66. export const statusList = [
  67. {
  68. title: '运行',
  69. titleUrl: require('../../assets/title3.png'),
  70. numUrl: require('../../assets/num3.png'),
  71. color: '#07AF2E ',
  72. num: 0,
  73. code: 'runNumber'
  74. },
  75. {
  76. title: '维修',
  77. color: '#9F9F9F',
  78. titleUrl: require('../../assets/title1.png'),
  79. numUrl: require('../../assets/num1.png'),
  80. code: 'repairNumber',
  81. num: 0
  82. },
  83. {
  84. title: '故障',
  85. color: '#C14E4D ',
  86. titleUrl: require('../../assets/title2.png'),
  87. numUrl: require('../../assets/num2.png'),
  88. code: 'faultNumber',
  89. num: 0
  90. },
  91. {
  92. title: '停机',
  93. color: '#F4C15E',
  94. titleUrl: require('../../assets/title4.png'),
  95. numUrl: require('../../assets/num4.png'),
  96. code: 'shutdownNumber',
  97. num: 0
  98. }
  99. ];
  100. export const rankList = [
  101. {
  102. label: '排名',
  103. prop: 'rank',
  104. width: '20%'
  105. },
  106. {
  107. prop: 'name',
  108. label: '备品备件名称',
  109. width: '50%'
  110. },
  111. {
  112. prop: 'num',
  113. label: '消耗数量',
  114. width: '30%'
  115. }
  116. ];
  117. // export const planList = [
  118. // {
  119. // label: '类型',
  120. // prop: 'type',
  121. // width: '13%',
  122. // },
  123. // {
  124. // prop: 'code',
  125. // label: '编码',
  126. // width: '30%',
  127. // },
  128. // {
  129. // prop: 'title',
  130. // label: '标题',
  131. // width: '30%',
  132. // },
  133. // {
  134. // prop: 'userName',
  135. // label: '申请人',
  136. // width: '17%',
  137. // },
  138. // {
  139. // prop: 'action',
  140. // label: '操作',
  141. // width: '10%',
  142. // },
  143. // ];
  144. export const barOption = (data, itemStyle = {}) => {
  145. return {
  146. tooltip: {
  147. formatter: '{b}:{c}' + '个',
  148. trigger: 'item'
  149. },
  150. color: ['#398f4e'],
  151. xAxis: {
  152. type: 'category',
  153. data: data.map((item) => item.name),
  154. axisLabel: {
  155. fontSize: window.innerHeight * 0.012
  156. }
  157. },
  158. yAxis: {
  159. type: 'value',
  160. name: '(个)',
  161. nameTextStyle: {
  162. align: 'center',
  163. color: '#333',
  164. fontSize: window.innerHeight * 0.012,
  165. padding: [0, 20, -3, 0]
  166. }
  167. },
  168. series: [
  169. {
  170. // showBackground: true,
  171. barWidth: '20%',
  172. data: data.map((item) => item.value),
  173. type: 'bar',
  174. itemStyle
  175. }
  176. ]
  177. };
  178. };
  179. export const pieOption = (data) => {
  180. return {
  181. color: ['#398f4e', '#458ef7', '#fdc537', '#fe6869', '#975fe6'],
  182. tooltip: {
  183. formatter: '{b}:{c}' + '%',
  184. trigger: 'item'
  185. },
  186. legend: {
  187. orient: 'vertical',
  188. left: 'right',
  189. right: '15%',
  190. top: '10%',
  191. itemGap: window.innerHeight * 0.014,
  192. textStyle: {
  193. fontSize: window.innerHeight * 0.013
  194. }
  195. },
  196. series: [
  197. {
  198. center: ['30%', '50%'],
  199. label: {
  200. position: 'inside',
  201. // show: true,
  202. formatter: '{c}' + '%',
  203. fontSize: window.innerHeight * 0.013,
  204. color: '#fff'
  205. },
  206. labelLine: {
  207. show: false
  208. },
  209. type: 'pie',
  210. radius: '85%',
  211. itemStyle: {
  212. borderWidth: 0,
  213. shadowBlur: 10,
  214. shadowColor: 'rgba(0, 0, 0, 0.5)'
  215. },
  216. data
  217. }
  218. ]
  219. };
  220. };
  221. export const pieOption1 = (data) => {
  222. return {
  223. // color: ['#398f4e', '#458ef7', '#fdc537', '#fe6869', '#975fe6'],
  224. tooltip: {
  225. formatter: '{b}:{c}' + '%',
  226. trigger: 'item'
  227. },
  228. legend: {
  229. orient: 'horizontal',
  230. left: 'center',
  231. // right: '15%',
  232. bottom: '5%',
  233. itemGap: window.innerHeight * 0.014,
  234. textStyle: {
  235. fontSize: window.innerHeight * 0.013
  236. }
  237. },
  238. series: [
  239. {
  240. center: ['50%', '45%'],
  241. label: {
  242. position: 'outside',
  243. show: true,
  244. formatter: (item) => {
  245. console.log(item,'item')
  246. return item.name + ':' + item.percent + '%';
  247. },
  248. fontSize: window.innerHeight * 0.0125,
  249. color: '#333'
  250. },
  251. labelLine: {
  252. show: true
  253. },
  254. type: 'pie',
  255. radius: ['50%', '65%'],
  256. itemStyle: {
  257. borderWidth: 0,
  258. shadowBlur: 10,
  259. shadowColor: 'rgba(0, 0, 0, 0.5)'
  260. },
  261. data
  262. }
  263. ]
  264. };
  265. };
  266. export const lineOption = (data,time) => {
  267. console.log(time,'time')
  268. return {
  269. tooltip: {
  270. formatter: (item) => {
  271. return item.name + ' ' + item.seriesName + ':' + item.value + '';
  272. },
  273. trigger: 'item'
  274. },
  275. legend: {
  276. // bottom: '2%',
  277. itemGap: window.innerHeight * 0.014,
  278. textStyle: {
  279. fontSize: window.innerHeight * 0.013
  280. }
  281. },
  282. xAxis: {
  283. type: 'category',
  284. axisLabel: {
  285. fontSize: window.innerHeight * 0.012
  286. },
  287. data:time
  288. // type == 1
  289. // ? [2020, 2021, 2022, 2023, 2024]
  290. // : type == 2
  291. // ? ['1季度', '2季度', '3季度', '4季度']
  292. // : [
  293. // '1月',
  294. // '2月',
  295. // '3月',
  296. // '4月',
  297. // '5月',
  298. // '6月',
  299. // '7月',
  300. // '8月',
  301. // '9月',
  302. // '10月',
  303. // '11月',
  304. // '12月'
  305. // ]
  306. },
  307. yAxis: {
  308. type: 'value'
  309. },
  310. series: data
  311. // [
  312. // {
  313. // name: '班组一',
  314. // data: getRandomNumber(type),
  315. // type: 'line',
  316. // smooth: true
  317. // },
  318. // {
  319. // name: '班组二',
  320. // data: getRandomNumber(type),
  321. // type: 'line',
  322. // smooth: true
  323. // },
  324. // {
  325. // name: '班组三',
  326. // data: getRandomNumber(type),
  327. // type: 'line',
  328. // smooth: true
  329. // },
  330. // {
  331. // name: '班组四',
  332. // data: getRandomNumber(type),
  333. // }
  334. // ]
  335. };
  336. };