lxWorkCanvas.vue 16 KB

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