holidayCanvas.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <template>
  2. <div>
  3. <div class="node_info">
  4. <div>节点说明:</div>
  5. <div class="dis_flex" v-for="item in nodeColor">
  6. <div class="node_class" :style="{backgroundColor: item.nodeback}"></div>
  7. {{ item.name }}
  8. </div>
  9. </div>
  10. <div v-show="true" id="containerHolidayDetails" style="width: 100%"></div>
  11. </div>
  12. </template>
  13. <script>
  14. import * as echarts from 'echarts'
  15. const lineStyle = {
  16. color: '#999999',
  17. width: 2,
  18. type: 'dotted'
  19. }
  20. const redLinestyle = {
  21. color: 'red',
  22. width: 2
  23. }
  24. const node = [ // 节点
  25. {
  26. name: '申请人发起',
  27. nodeKey: 'curr_user',
  28. value: [0, 500],
  29. symbol: 'image://' + require('../asste/huifangkuai.png'),
  30. symbolSize: [110, 60]
  31. },
  32. {
  33. name: '直接上级审核',
  34. value: [80, 500],
  35. nodeKey: 'dept_superior_1_0_1',
  36. symbol: 'image://' + require('../asste/huifangkuai.png'),
  37. symbolSize: [110, 60]
  38. },
  39. {
  40. name: '部门负责人审核',
  41. value: [160, 500],
  42. nodeKey: 'dept_head_1_0_1',
  43. symbol: 'image://' + require('../asste/huifangkuai.png'),
  44. symbolSize: [110, 60]
  45. },
  46. {
  47. label: {
  48. show: true,
  49. color: '#777777' // 节点文字颜色
  50. },
  51. name: '假别仅有\n调休假',
  52. nodeKey: 'only_tiaoxiujia',
  53. value: [240, 500],
  54. symbol: 'image://' + require('../asste/lingxing.png'),
  55. symbolSize: [80, 80]
  56. },
  57. {
  58. label: {
  59. show: true,
  60. color: 'red', // 节点文字颜色
  61. backgroundColor: 'rgb(0,0,0,0)'
  62. },
  63. itemStyle: {
  64. color: 'rgb(0,0,0,0)'
  65. },
  66. name: '是',
  67. value: [280, 500],
  68. symbolSize: [20, 20]
  69. },
  70. {
  71. label: {
  72. show: true,
  73. color: '#777777' // 节点文字颜色
  74. },
  75. nodeKey: 'less_3day',
  76. name: '请假天数',
  77. value: [240, 375],
  78. symbol: 'image://' + require('../asste/lingxing.png'),
  79. symbolSize: [80, 80]
  80. },
  81. {
  82. name: '分管领导\n审核',
  83. value: [310, 225],
  84. nodeKey: 'flow_fgld_1_0_1',
  85. symbol: 'image://' + require('../asste/huifangkuai.png'),
  86. symbolSize: [110, 60]
  87. },
  88. {
  89. name: '上级分管领导\n审核',
  90. value: [390, 225],
  91. nodeKey: 'flow_sjfgld_1_0_1',
  92. symbol: 'image://' + require('../asste/huifangkuai.png'),
  93. symbolSize: [110, 60]
  94. },
  95. {
  96. name: '主要领导\n审核',
  97. value: [480, 225],
  98. nodeKey: 'flow_zyld_1_0_1',
  99. symbol: 'image://' + require('../asste/huifangkuai.png'),
  100. symbolSize: [110, 60]
  101. },
  102. {
  103. name: '结束',
  104. nodeKey: 'isPass',
  105. value: [570, 500],
  106. symbol: 'image://' + require('../asste/huifangkuai.png'),
  107. symbolSize: [110, 60]
  108. },
  109. {
  110. label: {
  111. show: true,
  112. color: 'red' // 节点文字颜色
  113. //backgroundColor: '#f5f5f5'
  114. },
  115. itemStyle: {
  116. color: 'rgb(0,0,0,0)'
  117. },
  118. nodeKey: 'less_3day',
  119. name: '假期天数合计≤3天',
  120. value: [380, 375],
  121. symbolSize: [20, 20]
  122. },
  123. {
  124. label: {
  125. show: true,
  126. color: 'red' // 节点文字颜色
  127. //backgroundColor: '#f5f5f5'
  128. },
  129. itemStyle: {
  130. color: 'rgb(0,0,0,0)'
  131. },
  132. name: '假期天数合计>3天',
  133. value: [240, 275],
  134. symbolSize: [20, 20]
  135. },
  136. {
  137. label: {
  138. show: true,
  139. color: 'red' // 节点文字颜色
  140. // //backgroundColor: '#f5f5f5'
  141. },
  142. itemStyle: {
  143. color: 'rgb(0,0,0,0)'
  144. },
  145. nodeKey: 'dept_head_1_0_11',
  146. name: ' 退回发起人',
  147. value: [100, 150],
  148. symbolSize: [20, 20]
  149. },
  150. {
  151. label: {
  152. show: true,
  153. color: 'red' // 节点文字颜色
  154. //backgroundColor: '#f5f5f5'
  155. },
  156. itemStyle: {
  157. color: 'rgb(0,0,0,0)'
  158. },
  159. name: ' 退回发起人 ',
  160. value: [150, 100],
  161. symbolSize: [20, 20]
  162. },
  163. {
  164. label: {
  165. show: true,
  166. color: 'red' // 节点文字颜色
  167. //backgroundColor: '#f5f5f5'
  168. },
  169. itemStyle: {
  170. color: 'rgb(0,0,0,0)'
  171. },
  172. name: ' 退回发起人 ',
  173. value: [200, 50],
  174. symbolSize: [20, 20]
  175. },
  176. {
  177. label: {
  178. show: true,
  179. color: 'red' // 节点文字颜色
  180. //backgroundColor: '#f5f5f5'
  181. },
  182. itemStyle: {
  183. color: 'rgb(0,0,0,0)'
  184. },
  185. name: ' 退回发起人 ',
  186. value: [45, 400],
  187. symbolSize: [20, 20]
  188. },
  189. {
  190. label: {
  191. show: true,
  192. color: 'red' // 节点文字颜色
  193. //backgroundColor: '#f5f5f5'
  194. },
  195. itemStyle: {
  196. color: 'rgb(0,0,0,0)'
  197. },
  198. name: ' 退回发起人 ',
  199. value: [85, 350],
  200. symbolSize: [20, 20]
  201. }
  202. ]
  203. const linesData = [ // 连线
  204. {
  205. nodeKey: 'curr_user',
  206. lineStyle: lineStyle,
  207. coords: [[0, 500], [60, 500]]
  208. },
  209. {
  210. nodeKey: 'dept_head_1_0_1',
  211. lineStyle: lineStyle,
  212. coords: [[80, 500], [140, 500]]
  213. },
  214. {
  215. nodeKey: 'only_tiaoxiujia1',
  216. lineStyle: lineStyle,
  217. coords: [[160, 500], [227, 500]]
  218. },
  219. {
  220. name: '是',
  221. nodeKey: 'only_tiaoxiujia',
  222. lineStyle: lineStyle,
  223. itemStyle: {
  224. color: 'rgb(0,0,0,0)'
  225. },
  226. coords: [[260, 500], [550, 500]]
  227. },
  228. {
  229. name: '假期天数合计小于三天线',
  230. lineStyle: lineStyle,
  231. nodeKey: 'less_3day2',
  232. coords: [[260, 375], [575, 375]],
  233. symbol: 'none'
  234. },
  235. {
  236. nodeKey: 'flow_fgld_1_0_1',
  237. lineStyle: lineStyle,
  238. name: '假期天数合计>3线',
  239. coords: [[244, 335], [244, 225]],
  240. symbol: 'none'
  241. },
  242. {
  243. lineStyle: lineStyle,
  244. nodeKey: 'flow_fgld_1_0_1',
  245. coords: [[244, 225], [293, 225]]
  246. },
  247. {
  248. nodeKey: 'flow_sjfgld_1_0_1',
  249. lineStyle: lineStyle,
  250. coords: [[293, 225], [372, 225]]
  251. },
  252. {
  253. nodeKey: 'flow_zyld_1_0_1',
  254. lineStyle: lineStyle,
  255. coords: [[372, 225], [463, 225]]
  256. },
  257. {
  258. lineStyle: lineStyle,
  259. nodeKey: 'flow_zyld_1_0_1',
  260. coords: [[463, 225], [575, 225]]
  261. },
  262. {
  263. nodeKey: 'flow_zyld_1_0_1',
  264. lineStyle: lineStyle,
  265. coords: [[575, 225], [575, 375]],
  266. symbol: 'none'
  267. },
  268. {
  269. lineStyle: lineStyle,
  270. nodeKey: 'less_3day3',
  271. key: 'less_3day3',
  272. coords: [[575, 375], [575, 470]]
  273. },
  274. {
  275. lineStyle: lineStyle,
  276. nodeKey: 'flow_fgld_1_0_11',
  277. coords: [[315, 225], [315, 150]],
  278. symbol: 'none'
  279. },
  280. {
  281. lineStyle: lineStyle,
  282. nodeKey: 'flow_fgld_1_0_11',
  283. coords: [[315, 150], [5, 150]],
  284. symbol: 'none'
  285. },
  286. {
  287. // name: '直接上级审核的退回发起线',
  288. nodeKey: 'flow_fgld_1_0_11',
  289. lineStyle: { ...lineStyle, color: 'rgba(0,0,0,0)' },
  290. coords: [[5, 150], [5, 470]]
  291. },
  292. {
  293. name: '',
  294. lineStyle: lineStyle,
  295. coords: [[395, 225], [395, 100]],
  296. symbol: 'none'
  297. },
  298. {
  299. // name: '直接上级审核的退回发起线',
  300. nodeKey: 'dept_superior_1_0_11',
  301. lineStyle: { ...lineStyle, color: 'rgba(0,0,0,0)' },
  302. coords: [[5, 400], [5, 470]]
  303. },
  304. {
  305. name: '发起人退回',
  306. lineStyle: lineStyle,
  307. coords: [[5, 50], [5, 470]]
  308. },
  309. {
  310. name: '',
  311. lineStyle: lineStyle,
  312. coords: [[5, 100], [395, 100]],
  313. symbol: 'none'
  314. },
  315. {
  316. name: '',
  317. lineStyle: lineStyle,
  318. coords: [[480, 225], [480, 50]],
  319. symbol: 'none'
  320. },
  321. {
  322. name: '',
  323. lineStyle: lineStyle,
  324. coords: [[480, 50], [5, 50]],
  325. symbol: 'none'
  326. },
  327. {
  328. name: '直接上级审核的退回发起线',
  329. nodeKey: 'dept_superior_1_0_11',
  330. lineStyle: lineStyle,
  331. coords: [[85, 500], [85, 400]],
  332. symbol: 'none'
  333. },
  334. {
  335. name: '直接上级审核的退回发起线',
  336. nodeKey: 'dept_superior_1_0_11',
  337. lineStyle: lineStyle,
  338. coords: [[85, 400], [5, 400]],
  339. symbol: 'none'
  340. },
  341. {
  342. name: '',
  343. lineStyle: lineStyle,
  344. nodeKey: 'dept_head_1_0_11',
  345. coords: [[165, 500], [165, 350]],
  346. symbol: 'none'
  347. },
  348. {
  349. name: '',
  350. nodeKey: 'dept_head_1_0_11',
  351. lineStyle: lineStyle,
  352. coords: [[165, 350], [5, 350]],
  353. symbol: 'none'
  354. },
  355. {
  356. name: '',
  357. nodeKey: 'dept_head_1_0_11',
  358. lineStyle: lineStyle,
  359. coords: [[5, 350], [5, 470]],
  360. symbol: 'none'
  361. },
  362. {
  363. name: '',
  364. nodeKey: 'less_3day1',
  365. lineStyle: lineStyle,
  366. coords: [[243.9, 465], [243.9, 415]]
  367. }
  368. //
  369. ]
  370. export default {
  371. name: 'holidayCanvas',
  372. data() {
  373. return {
  374. linesData: [],
  375. node: [],
  376. nodeColor: [
  377. { name: '审核通过', nodeback: '#2A3980' },
  378. { name: '未经过', nodeback: '#999999' },
  379. { name: '退回', nodeback: '#E04242' },
  380. { name: '审核中', nodeback: '#E08E42' },
  381. { name: '撤回', nodeback: '#4294E0' }
  382. ]
  383. }
  384. },
  385. mounted() {
  386. },
  387. methods: {
  388. baseRequest1(prefix, opUrl, postData) {
  389. return this.$channel.globleRequest(prefix, opUrl, postData, 'project task')
  390. },
  391. async createNodeCanvas(row) {
  392. this.linesData = JSON.parse(JSON.stringify(linesData))
  393. this.node = JSON.parse(JSON.stringify(node))
  394. // return
  395. const { data } = await this.baseRequest1('FlowMainController', 'getIMGFlowHistroyByFlowMainId', { flowMainId: row.id })
  396. console.log(data)
  397. this.linesData = [...linesData]
  398. this.node = [...node]
  399. for (let i = 0; i < data.length; i++) {
  400. let index = this.node.findIndex((e) => e.nodeKey == data[i].nodeKey)
  401. switch (data[i].nodeKey) {
  402. case 'curr_user':
  403. if (data[i].type == 1) {
  404. this.getImgUrl(index, data[i].type)
  405. this.getLineStyle(data[i].nodeKey)
  406. }
  407. break
  408. case 'dept_superior_1_0_1':
  409. if (data[i].type == 1 || data[i].type == 3) {
  410. this.getLineStyle(data[i].nodeKey)
  411. this.getImgUrl(index, data[i].type)
  412. }
  413. if (data[i].type === 2) {
  414. this.getLineStyle(data[i].nodeKey)
  415. this.getLineStyle('dept_superior_1_0_11')
  416. this.getImgUrl(index, data[i].type)
  417. }
  418. break
  419. case 'dept_head_1_0_1':
  420. if (data[i].type == 1 || data[i].type == 3) {
  421. this.getLineStyle(data[i].nodeKey)
  422. console.log(data[i].nodeKey)
  423. this.getImgUrl(index, data[i].type)
  424. }
  425. if (data[i].type == 2) {
  426. this.getLineStyle(data[i].nodeKey)
  427. this.getLineStyle('dept_head_1_0_11')
  428. this.getImgUrl(index, data[i].type)
  429. }
  430. if (data[i].type == '1') {
  431. this.getLineStyle('only_tiaoxiujia1')
  432. this.getLineStyle('only_tiaoxiujia1')
  433. let index2 = this.node.findIndex((e) => e.nodeKey == 'isPass')
  434. console.log(this.node, index2)
  435. this.node[index2].symbol = 'image://' + require('../asste/lanfangkuai.png')
  436. }
  437. break
  438. case 'only_tiaoxiujia':
  439. if (data[i].type == 1 || data[i].type == 3) {
  440. this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  441. this.getLineStyle(data[i].nodeKey)
  442. }
  443. if (data[i].type == 1) {
  444. let endIndex = this.node.findIndex((e) => e.name == '结束')
  445. console.log('endIndex', endIndex)
  446. this.getImgUrl(endIndex, '1')
  447. }
  448. break
  449. case 'less_3day':
  450. if (data[i].type == 1) {
  451. this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  452. this.reductionLineStyle('only_tiaoxiujia')
  453. this.getLineStyle('only_tiaoxiujia1')
  454. this.getLineStyle(data[i].nodeKey)
  455. this.getLineStyle('less_3day1')
  456. this.getLineStyle('less_3day2')
  457. this.getLineStyle('less_3day3')
  458. }
  459. break
  460. case 'flow_fgld_1_0_1':
  461. this.getLineStyle('less_3day1')
  462. this.reductionLineStyle('less_3day2')
  463. this.reductionLineStyle('less_3day3')
  464. this.getLineStyle('only_tiaoxiujia1')
  465. this.getLineStyle(data[i].nodeKey)
  466. this.getImgUrl(index, data[i].type)
  467. if (data[i].type == 2) {
  468. this.getLineStyle('flow_fgld_1_0_11')
  469. // this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  470. }
  471. break
  472. case 'flow_sjfgld_1_0_1':
  473. this.getLineStyle('less_3day1')
  474. this.reductionLineStyle('less_3day2')
  475. this.reductionLineStyle('less_3day3')
  476. this.getLineStyle('flow_sjfgld_1_0_1')
  477. this.getLineStyle(data[i].nodeKey)
  478. this.getImgUrl(index, data[i].type)
  479. if (data[i].type == 2) {
  480. this.getLineStyle('flow_sjfgld_1_0_11')
  481. // this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  482. }
  483. break
  484. case 'flow_zyld_1_0_1':
  485. this.getLineStyle('less_3day1')
  486. this.reductionLineStyle('less_3day2')
  487. this.reductionLineStyle('less_3day3')
  488. if (data[i].type == 1) {
  489. this.getLineStyle('flow_sjfgld_1_0_1')
  490. this.getLineStyle(data[i].nodeKey)
  491. this.getImgUrl(index, data[i].type)
  492. this.getLineStyle('less_3day3')
  493. let endIndex = this.node.findIndex((e) => e.name == '结束')
  494. console.log('endIndex', endIndex)
  495. this.getImgUrl(endIndex, '1')
  496. }
  497. if (data[i].type == 2) {
  498. this.getLineStyle('flow_sjfgld_1_0_11')
  499. // this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  500. }
  501. break
  502. //
  503. default:
  504. }
  505. }
  506. this.getNode()
  507. // this.createNodeCanvas()
  508. },
  509. reductionLineStyle(nodeKey) {
  510. for (let i = 0; i < this.linesData.length; i++) {
  511. if (this.linesData[i].nodeKey == nodeKey) {
  512. this.linesData[i].lineStyle = lineStyle
  513. }
  514. }
  515. },
  516. getLineStyle(nodeKey) {
  517. for (let i = 0; i < this.linesData.length; i++) {
  518. if (this.linesData[i].nodeKey == nodeKey) {
  519. this.linesData[i].lineStyle = {
  520. color: '#2A3980',
  521. width: 2
  522. }
  523. }
  524. }
  525. },
  526. getImgUrl(index, type) {
  527. switch (type) {
  528. case '1':
  529. this.node[index].symbol = 'image://' + require('../asste/lanfangkuai.png')
  530. break
  531. case '2':
  532. this.node[index].symbol = 'image://' + require('../asste/hongfangkuai.jpg')
  533. break
  534. case '3':
  535. this.node[index].symbol = 'image://' + require('../asste/huangfanmgkuai.png')
  536. break
  537. case '4' || '5':
  538. this.node[index].symbol = 'image://' + require('../asste/qianlanfangkuai.jpg')
  539. break
  540. default:
  541. }
  542. },
  543. getNode() {
  544. this.$nextTick(() => {
  545. let chartDom = document.getElementById('containerHolidayDetails')
  546. let myCharts = null
  547. myCharts = echarts.init(chartDom)
  548. let charts = {
  549. nodes: this.node,
  550. linesData: this.linesData
  551. }
  552. let option = {
  553. xAxis: {
  554. min: 0,
  555. max: 600,
  556. padding: [0, 50, 0, 50],
  557. show: false,
  558. type: 'value'
  559. },
  560. yAxis: {
  561. min: 0,
  562. max: 600,
  563. show: false,
  564. type: 'value'
  565. },
  566. grid: {
  567. left: 50,
  568. right: 0,
  569. bottom: 0,
  570. top: 0
  571. },
  572. series: [
  573. {
  574. type: 'graph',
  575. coordinateSystem: 'cartesian2d',
  576. symbol: 'rect',
  577. symbolSize: [80, 40],
  578. symbolOffset: [10, 0],
  579. // force: {
  580. // edgeLength: 100,//连线的长度
  581. // repulsion: 200 //子节点之间的间距
  582. // },
  583. label: {
  584. show: true,
  585. color: 'white' // 节点文字颜色
  586. },
  587. data: charts.nodes
  588. },
  589. {
  590. type: 'lines',
  591. polyline: false,
  592. coordinateSystem: 'cartesian2d',
  593. symbol: ['', 'arrow'],
  594. symbolSize: 10,
  595. data: charts.linesData
  596. }
  597. ]
  598. }
  599. myCharts.clear()
  600. myCharts.setOption(option)
  601. window.addEventListener('resize', () => {
  602. myCharts.resize()
  603. })
  604. })
  605. }
  606. }
  607. }
  608. </script>
  609. <style>
  610. .dis_flex {
  611. display: flex;
  612. }
  613. .node_info {
  614. width: 100%;
  615. display: block;
  616. margin: 0 auto;
  617. display: flex;
  618. padding-top: 10px;
  619. justify-content: center;
  620. background: #F5F5F5;
  621. }
  622. .node_class {
  623. height: 15px;
  624. width: 15px;
  625. background: white;
  626. margin: 0 10px;
  627. border-radius: 0.2rem;
  628. }
  629. </style>