lxSjWorkCanvas.vue 17 KB

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