addWorkCanvas.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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_fgld_1_0_1',
  48. name: '分管领导审核',
  49. value: [285, 100],
  50. symbol: 'image://' + require('../asste/huifangkuai.png'),
  51. symbolSize: [110, 60]
  52. },
  53. {
  54. name: '上级分管领导\n审核',
  55. nodeKey: 'flow_sjfgld_1_0_1',
  56. value: [365, 100],
  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, 100],
  64. symbol: 'image://' + require('../asste/huifangkuai.png'),
  65. symbolSize: [110, 60]
  66. },
  67. {
  68. name: '结束',
  69. value: [525, 100],
  70. symbol: 'image://' + require('../asste/huifangkuai.png'),
  71. symbolSize: [110, 60]
  72. },
  73. {
  74. label: {
  75. show: true,
  76. color: 'red', // 节点文字颜色
  77. backgroundColor: '#f5f5f5'
  78. },
  79. itemStyle: {
  80. color: '#f5f5f5'
  81. },
  82. name: '退回发起人',
  83. value: [350, 400],
  84. symbolSize: [70, 20]
  85. },
  86. {
  87. label: {
  88. show: true,
  89. color: 'red', // 节点文字颜色
  90. backgroundColor: '#f5f5f5'
  91. },
  92. itemStyle: {
  93. color: '#f5f5f5'
  94. },
  95. name: ' 退回发起人 ',
  96. value: [300, 350],
  97. symbolSize: [20, 20]
  98. },
  99. {
  100. label: {
  101. show: true,
  102. color: 'red', // 节点文字颜色
  103. backgroundColor: '#f5f5f5'
  104. },
  105. itemStyle: {
  106. color: '#f5f5f5'
  107. },
  108. name: ' 退回发起人 ',
  109. value: [250, 300],
  110. symbolSize: [20, 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: [250, 300],
  123. symbolSize: [20, 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: [175, 250],
  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: [100, 200],
  149. symbolSize: [20, 20]
  150. }
  151. ]
  152. const linesData = [ // 连线
  153. {
  154. nodeKey: 'curr_user',
  155. lineStyle: lineStyle,
  156. coords: [[45, 100], [105, 100]]
  157. },
  158. {
  159. nodeKey: 'dept_superior_1_0_1',
  160. lineStyle: lineStyle,
  161. coords: [[125, 100], [185, 100]]
  162. },
  163. {
  164. nodeKey: 'dept_head_1_0_1',
  165. lineStyle: lineStyle,
  166. coords: [[205, 100], [265, 100]]
  167. },
  168. {
  169. nodeKey: 'flow_fgld_1_0_1',
  170. lineStyle: lineStyle,
  171. coords: [[285, 100], [345, 100]]
  172. },
  173. {
  174. nodeKey: 'flow_sjfgld_1_0_1',
  175. lineStyle: lineStyle,
  176. coords: [[365, 100], [425, 100]]
  177. },
  178. {
  179. nodeKey: 'flow_zyld_1_0_1',
  180. lineStyle: lineStyle,
  181. coords: [[445, 100], [505, 100]]
  182. },
  183. {
  184. nodeKey: 'flow_zyld_1_0_1_back',
  185. lineStyle: lineStyle,
  186. coords: [[450, 100], [450, 400]],
  187. symbol: 'none'
  188. },
  189. {
  190. nodeKey: 'flow_sjfgld_1_0_1_back',
  191. lineStyle: lineStyle,
  192. coords: [[370, 100], [370, 350]],
  193. symbol: 'none'
  194. },
  195. {
  196. nodeKey: 'flow_fgld_1_0_1_back',
  197. lineStyle: lineStyle,
  198. coords: [[290, 100], [290, 300]],
  199. symbol: 'none'
  200. },
  201. {
  202. nodeKey: 'dept_head_1_0_1_back',
  203. lineStyle: lineStyle,
  204. coords: [[210, 100], [210, 250]],
  205. symbol: 'none'
  206. },
  207. {
  208. nodeKey: 'dept_superior_1_0_1_back',
  209. lineStyle: lineStyle,
  210. coords: [[130, 100], [130, 200]],
  211. symbol: 'none'
  212. },
  213. // {
  214. // lineStyle: redLinestyle,
  215. // coords: [[50, 100], [50, 400]],
  216. // symbol: 'none'
  217. // },
  218. {
  219. nodeKey: 'flow_zyld_1_0_1_back',
  220. lineStyle: lineStyle,
  221. coords: [[50, 100], [50, 400]],
  222. symbol: 'none'
  223. },
  224. {
  225. nodeKey: 'flow_sjfgld_1_0_1_back',
  226. lineStyle: lineStyle,
  227. coords: [[50, 100], [50, 350]],
  228. symbol: 'none'
  229. },
  230. {
  231. nodeKey: 'flow_fgld_1_0_1_back',
  232. lineStyle: lineStyle,
  233. coords: [[50, 100], [50, 300]],
  234. symbol: 'none'
  235. },
  236. {
  237. nodeKey: 'dept_head_1_0_1_back',
  238. lineStyle: lineStyle,
  239. coords: [[50, 100], [50, 250]],
  240. symbol: 'none'
  241. },
  242. {
  243. nodeKey: 'dept_superior_1_0_1_back',
  244. lineStyle: lineStyle,
  245. coords: [[50, 100], [50, 200]],
  246. symbol: 'none'
  247. },
  248. {
  249. lineStyle: lineStyle,
  250. nodeKey: 'flow_zyld_1_0_1_back',
  251. coords: [[450, 400], [50, 400]],
  252. symbol: 'none'
  253. },
  254. {
  255. nodeKey: 'flow_sjfgld_1_0_1_back',
  256. lineStyle: lineStyle,
  257. coords: [[370, 350], [50, 350]],
  258. symbol: 'none'
  259. },
  260. {
  261. nodeKey: 'flow_fgld_1_0_1_back',
  262. lineStyle: lineStyle,
  263. coords: [[290, 300], [50, 300]],
  264. symbol: 'none'
  265. },
  266. {
  267. nodeKey: 'dept_head_1_0_1_back',
  268. lineStyle: lineStyle,
  269. coords: [[210, 250], [50, 250]],
  270. symbol: 'none'
  271. },
  272. {
  273. nodeKey: 'dept_superior_1_0_1_back',
  274. lineStyle: lineStyle,
  275. coords: [[130, 200], [50, 200]],
  276. symbol: 'none'
  277. },
  278. {
  279. lineStyle: lineStyle,
  280. coords: [[50, 150], [50, 150]],
  281. symbol: 'none'
  282. }
  283. ]
  284. export default {
  285. name: 'addWorkCanvas',
  286. data() {
  287. return {
  288. linesData: [],
  289. node: [],
  290. nodeColor: [
  291. { name: '审核通过', nodeback: '#2A3980' },
  292. { name: '未经过', nodeback: '#999999' },
  293. { name: '退回', nodeback: '#E04242' },
  294. { name: '审核中', nodeback: '#E08E42' },
  295. { name: '撤回', nodeback: '#4294E0' }
  296. ]
  297. }
  298. },
  299. mounted() {
  300. },
  301. methods: {
  302. baseRequest1(prefix, opUrl, postData) {
  303. return this.$channel.globleRequest(prefix, opUrl, postData, 'project task')
  304. },
  305. async createNodeCanvas(row) {
  306. this.linesData = JSON.parse(JSON.stringify(linesData))
  307. this.node = JSON.parse(JSON.stringify(node))
  308. const { data } = await this.baseRequest1('FlowMainController', 'getIMGFlowHistroyByFlowMainId', { flowMainId: row.id })
  309. console.log(data)
  310. for (let i = 0; i < data.length; i++) {
  311. let index = this.node.findIndex((e) => e.nodeKey == data[i].nodeKey)
  312. switch (data[i].nodeKey) {
  313. case 'curr_user':
  314. if (data[i].type == 1) {
  315. this.getImgUrl(index, data[i].type)
  316. this.getLineStyle(data[i].nodeKey)
  317. }
  318. break
  319. case 'dept_superior_1_0_1':
  320. if (data[i].type == 1 || data[i].type == 3) {
  321. this.getImgUrl(index, data[i].type)
  322. }
  323. if (data[i].type == 1) {
  324. this.getLineStyle(data[i].nodeKey)
  325. }
  326. if (data[i].type == 2) {
  327. this.getLineStyle('dept_superior_1_0_1_back')
  328. this.getImgUrl(index, data[i].type)
  329. }
  330. break
  331. case 'dept_head_1_0_1':
  332. if (data[i].type == 1 || data[i].type == 3) {
  333. this.getImgUrl(index, data[i].type)
  334. }
  335. if (data[i].type == 1) {
  336. this.getLineStyle(data[i].nodeKey)
  337. }
  338. if (data[i].type == 2) {
  339. this.getLineStyle('dept_head_1_0_1_back')
  340. this.getImgUrl(index, data[i].type)
  341. }
  342. if (data[i].isPass == '1') {
  343. this.getLineStyle('only_tiaoxiujia1')
  344. let index2 = this.node.findIndex((e) => e.nodeKey == 'isPass')
  345. console.log(this.node, index2)
  346. this.node[index2].symbol = 'image://' + require('../asste/lanfangkuai.png')
  347. }
  348. break
  349. case 'only_tiaoxiujia':
  350. if (data[i].type == 1 || data[i].type == 3) {
  351. this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  352. this.getLineStyle(data[i].nodeKey)
  353. }
  354. case 'flow_fgld_1_0_1':
  355. this.getImgUrl(index, data[i].type)
  356. if (data[i].type == 1) {
  357. this.getLineStyle('flow_fgld_1_0_1')
  358. }
  359. if (data[i].type == 2) {
  360. this.getLineStyle('flow_fgld_1_0_1_back')
  361. }
  362. break
  363. case 'flow_sjfgld_1_0_1':
  364. this.getLineStyle(data[i].nodeKey)
  365. this.getImgUrl(index, data[i].type)
  366. if (data[i].type == 2) {
  367. this.getLineStyle('flow_sjfgld_1_0_1_back')
  368. // this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  369. }
  370. break
  371. case 'flow_zyld_1_0_1':
  372. this.getLineStyle('less_3day1')
  373. if (data[i].type == 1) {
  374. this.getLineStyle('flow_sjfgld_1_0_1')
  375. this.getLineStyle(data[i].nodeKey)
  376. this.getImgUrl(index, data[i].type)
  377. this.getLineStyle('less_3day3')
  378. let endIndex = this.node.findIndex((e) => e.name == '结束')
  379. this.getImgUrl(endIndex, '1')
  380. }
  381. if (data[i].type == 2) {
  382. this.getLineStyle('flow_zyld_1_0_1_back')
  383. // this.node[index].symbol = 'image://' + require('../asste/lanselingxin.jpg')
  384. }
  385. break
  386. //
  387. default:
  388. }
  389. }
  390. this.getNode()
  391. },
  392. reductionLineStyle(nodeKey) {
  393. for (let i = 0; i < this.linesData.length; i++) {
  394. if (this.linesData[i].nodeKey == nodeKey) {
  395. this.linesData[i].lineStyle = lineStyle
  396. }
  397. }
  398. },
  399. getLineStyle(nodeKey) {
  400. for (let i = 0; i < this.linesData.length; i++) {
  401. if (this.linesData[i].nodeKey == nodeKey) {
  402. this.linesData[i].lineStyle = {
  403. color: '#2A3980',
  404. width: 2
  405. }
  406. }
  407. }
  408. },
  409. getImgUrl(index, type) {
  410. if (index == -1) return
  411. switch (type) {
  412. case '1':
  413. console.log(index)
  414. console.log(this.node[index])
  415. this.node[index].symbol = 'image://' + require('../asste/lanfangkuai.png')
  416. break
  417. case '2':
  418. this.node[index].symbol = 'image://' + require('../asste/hongfangkuai.jpg')
  419. break
  420. case '3':
  421. this.node[index].symbol = 'image://' + require('../asste/huangfanmgkuai.png')
  422. break
  423. case '4' || '5':
  424. this.node[index].symbol = 'image://' + require('../asste/qianlanfangkuai.jpg')
  425. break
  426. default:
  427. }
  428. },
  429. getNode() {
  430. this.$nextTick(() => {
  431. let chartDom = document.getElementById('containeraddworkdetail')
  432. let myCharts = null
  433. myCharts = echarts.init(chartDom)
  434. let charts = {
  435. nodes: this.node,
  436. linesData: this.linesData
  437. }
  438. let option = {
  439. xAxis: {
  440. min: 0,
  441. max: 600,
  442. padding: [0, 50, 0, 50],
  443. show: false,
  444. type: 'value'
  445. },
  446. yAxis: {
  447. min: 0,
  448. max: 450,
  449. show: false,
  450. type: 'value'
  451. },
  452. grid: {
  453. left: 50,
  454. right: 0,
  455. bottom: 0,
  456. top: 0
  457. },
  458. series: [
  459. {
  460. type: 'graph',
  461. coordinateSystem: 'cartesian2d',
  462. symbol: 'rect',
  463. symbolSize: [80, 40],
  464. itemStyle: {
  465. color: 'rgb(225,7,7)'
  466. },
  467. symbolOffset: [10, 0],
  468. // force: {
  469. // edgeLength: 100,//连线的长度
  470. // repulsion: 200 //子节点之间的间距
  471. // },
  472. label: {
  473. show: true,
  474. color: 'white' // 节点文字颜色
  475. },
  476. data: charts.nodes
  477. },
  478. {
  479. type: 'lines',
  480. polyline: false,
  481. coordinateSystem: 'cartesian2d',
  482. symbol: ['', 'arrow'],
  483. symbolSize: 10,
  484. data: charts.linesData
  485. }
  486. ]
  487. }
  488. myCharts.clear()
  489. myCharts.setOption(option)
  490. window.addEventListener('resize', () => {
  491. myCharts.resize()
  492. })
  493. })
  494. }
  495. }
  496. }
  497. </script>
  498. <style scoped>
  499. </style>