payCanvas.vue 15 KB

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