pic1.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. <template>
  2. <div class="root">
  3. <div id="headPanel">
  4. <!-- <span class="logo">G6 入门教程 - 脑图</span> -->
  5. <i class="gb-toggle-btn" />
  6. </div>
  7. <div class="crumb-nav" v-if="activeMenu + 'TITLE'">
  8. <template v-for="(nav, index) in crumbNavs">
  9. {{ index > 0 ? '>' : '' }}
  10. <span :key="nav.id" class="nav-text" @click="changeNode(nav)">{{ nav.label }}</span>
  11. </template>
  12. </div>
  13. <div class="text-nav">
  14. <span>{{ chart.option.title.text }}</span>
  15. </div>
  16. <!-- canvas 挂载节点 -->
  17. <div id="graph" />
  18. <!-- 输入框 -->
  19. <input v-show="showInput" id="input-controller" ref="inputController" v-model="inputValue" :style="{
  20. top: `${input.y}px`,
  21. left: `${input.x}px`,
  22. }" type="text" @blur="inputBlur">
  23. <el-dialog title="文件预览" :visible.sync="dialogVisible" destroy-on-close width="90%" top="6vh" height="90%">
  24. <el-button size="small" type="primary" icon="el-icon-download" v-privilege="activeMenu + 'DOWNLOAD'"
  25. @click="downloadFile(chart.fileData)" :loading="loading" style="position: absolute; right: 100px; top: 20px;">
  26. 点击保存
  27. </el-button>
  28. <iframe :src="previewUrl" width="100%" :height="singleTableHeight"></iframe>
  29. </el-dialog>
  30. </div>
  31. </template>
  32. <script>
  33. import G6 from 'G6-4.3.11';
  34. import registerEdge from './register-edge';
  35. import registerNode from './register-node';
  36. import formulaEditor from '~/components/zg/formulaEditor.vue';
  37. import {
  38. zCheckNumber1
  39. } from '~/utils/validator.js';
  40. import {
  41. formatDate
  42. } from '@/utils/util.js';
  43. import store from '@/store/index.js';
  44. export default {
  45. name: 'root',
  46. data() {
  47. return {
  48. multipleSelection: [],
  49. tableFormDataObj: {},
  50. form: {
  51. imgSavePath: '',
  52. },
  53. filterForm: {
  54. show: true,
  55. data: {
  56. uploadFileid: '',
  57. securityTypeid: '',
  58. securityTag: '',
  59. isprimary: '',
  60. version: formatDate(new Date(), 'yyyyMM00'),
  61. fileName: '',
  62. pattern: 'table'
  63. },
  64. rules: {},
  65. file: ''
  66. },
  67. listTopicTree: {
  68. show: true,
  69. loading: false,
  70. data: [],
  71. defaultProps: {
  72. children: 'children',
  73. label: 'securityName'
  74. }
  75. },
  76. pageNum: 1,
  77. pageSize: 20,
  78. total: 0,
  79. singleTableHeight: '720px',
  80. tableData: [],
  81. nameObj: {
  82. uploadFile: {
  83. obj: {},
  84. arr: []
  85. },
  86. securityType: {
  87. obj: {},
  88. arr: []
  89. },
  90. unitid: {
  91. obj: {},
  92. arr: []
  93. },
  94. roleList: {
  95. obj: {},
  96. arr: []
  97. }, // 角色信息
  98. securityTag: {
  99. obj: {},
  100. arr: []
  101. },
  102. pattern: {
  103. obj: {
  104. 'graphical': '图例',
  105. 'table': '表格'
  106. },
  107. arr: [{
  108. id: 'graphical',
  109. name: '图例'
  110. },
  111. {
  112. id: 'table',
  113. name: '表格'
  114. }
  115. ]
  116. }
  117. },
  118. loading: false,
  119. tableLoading: false,
  120. dialog: {
  121. editorBox: {
  122. show: false,
  123. fileType: '',
  124. form: {
  125. default: {
  126. workprocid: ''
  127. },
  128. data: {
  129. itemid: '',
  130. productid: '',
  131. workprocid: '',
  132. isprimary: '0',
  133. unitid: '',
  134. seqno: '',
  135. code: '',
  136. fileType: ''
  137. },
  138. rules: {
  139. productid: [{
  140. required: true,
  141. message: '该项不能为空',
  142. trigger: 'change'
  143. }],
  144. workprocid: [{
  145. required: true,
  146. message: '该项不能为空',
  147. trigger: 'change'
  148. }],
  149. seqno: [{
  150. validator: zCheckNumber1,
  151. trigger: 'change'
  152. }]
  153. }
  154. }
  155. },
  156. equationEditing: {
  157. show: false,
  158. form: {
  159. data: {
  160. clock: '',
  161. code: ''
  162. }
  163. }
  164. }
  165. },
  166. store,
  167. userInfo: {}, // 用户信息
  168. qrRole: [],
  169. userRoles: [],
  170. dialogVisible: false,
  171. previewUrl: '',
  172. chart: {
  173. height: '1024px',
  174. show: false,
  175. fileData: {
  176. fileName: '',
  177. fileUrl: ''
  178. },
  179. option: {
  180. title: {
  181. text: '集团应急管理体系'
  182. },
  183. tooltip: {
  184. trigger: 'item',
  185. triggerOn: 'mousemove'
  186. },
  187. toolbox: {
  188. feature: {
  189. saveAsImage: {}
  190. }
  191. },
  192. series: [{
  193. type: 'tree',
  194. data: [],
  195. top: '2%',
  196. left: '25%',
  197. bottom: '1%',
  198. right: '20%',
  199. symbolSize: 8,
  200. nodePadding: 50,
  201. label: {
  202. position: 'left',
  203. verticalAlign: 'bottom',
  204. align: 'right',
  205. fontSize: 14
  206. },
  207. leaves: {
  208. label: {
  209. position: 'right',
  210. verticalAlign: 'middle',
  211. align: 'left'
  212. }
  213. },
  214. emphasis: {
  215. focus: 'descendant'
  216. },
  217. initialTreeDepth: 2,
  218. expandAndCollapse: true,
  219. animationDuration: 550,
  220. animationDurationUpdate: 750,
  221. roam: true
  222. }]
  223. }
  224. },
  225. graph: null,
  226. showInput: false,
  227. inputValue: '',
  228. activeMenu: '',
  229. input: {
  230. x: 0,
  231. y: 0,
  232. },
  233. currentNode: {
  234. id: null,
  235. },
  236. crumbNavs: [],
  237. };
  238. },
  239. created() {
  240. this.activeMenu = window.localStorage.getItem('activeMenu');
  241. },
  242. mounted() {
  243. let that = this;
  244. that.getFileTreeData();
  245. },
  246. beforeDestroy() {
  247. this.graph.destroy();
  248. },
  249. methods: {
  250. createGraphic() {
  251. const vm = this;
  252. registerEdge(G6);
  253. registerNode(G6);
  254. const menu = new G6.Menu({
  255. offsetY: -20,
  256. itemTypes: ['node'],
  257. getContent(e) {
  258. return `
  259. <p class="menu-item" command="edit-node">编辑文本</p>
  260. <p class="menu-item" command="delete-node">删除节点</p>
  261. `;
  262. },
  263. handleMenuClick(target, item) {
  264. const command = target.getAttribute('command');
  265. switch (command) {
  266. case 'edit-node':
  267. vm.editNode(item);
  268. break;
  269. case 'delete-node':
  270. vm.deleteNode(item);
  271. break;
  272. }
  273. },
  274. });
  275. const graph = new G6.TreeGraph({
  276. container: document.getElementById('graph'),
  277. width: window.innerWidth - 10,
  278. height: window.innerHeight - 10,
  279. defaultNode: {
  280. type: 'tree-node',
  281. style: {
  282. width: 100,
  283. height: 30,
  284. radius: 4,
  285. fill: '#ffffff40',
  286. // stroke: '#999',
  287. stroke: '#161616',
  288. },
  289. labelCfg: {
  290. style: {
  291. fontSize: 14,
  292. },
  293. },
  294. },
  295. defaultEdge: {
  296. type: 'right-tree',
  297. },
  298. layout: {
  299. type: 'mindmap',
  300. direction: 'TB',
  301. getHeight: function getHeight() {
  302. return 16;
  303. },
  304. getWidth: function getWidth() {
  305. return 16;
  306. },
  307. getVGap: function getVGap() {
  308. return 20;
  309. },
  310. getHGap: function getHGap() {
  311. return 130;
  312. },
  313. },
  314. modes: {
  315. default: [
  316. 'drag-canvas',
  317. 'zoom-canvas',
  318. 'drag-node',
  319. // {
  320. // type: 'collapse-expand',
  321. // onChange(item, collapsed) {
  322. // const data = item.get('model');
  323. // data.collapsed = collapsed;
  324. // return true;
  325. // },
  326. // },
  327. ],
  328. },
  329. // plugins: [menu],
  330. fitView: true,
  331. fitViewPadding: [140,40,20,40],
  332. });
  333. // graph.data(vm.chart.option.series[0].data[0]);
  334. // gragh.render();
  335. graph.read({
  336. ...vm.chart.option.series[0].data[0]
  337. });
  338. graph.fitView([140,40,20,40]);
  339. this.graph = graph;
  340. this.bindEvents();
  341. },
  342. /*
  343. * 1: 1
  344. * 1-1: 1 1-1
  345. * 1-1-1: 1 1-1 1-1-1
  346. * 1-1-1-1: 1 1-1 1-1-1 1-1-1-1
  347. */
  348. getParentNodes(node, id, deep = 1) {
  349. if (id.substring(0, 1) === '1' && deep === 1) {
  350. this.crumbNavs.push(node);
  351. }
  352. if (id.length > 1) {
  353. const $id = id.substring(0, deep * 2 + 1);
  354. const $node = node.children.find(item => item.id === $id);
  355. if ($node) {
  356. this.crumbNavs.push($node);
  357. if ($node.children && $node.children.length > 0) {
  358. this.getParentNodes($node, id, deep + 1);
  359. }
  360. }
  361. }
  362. },
  363. bindEvents() {
  364. this.graph.on('node:click', e => {
  365. const model = e.item.getModel();
  366. if (e.target.cfg.name === 'node-icon-text') {
  367. /* 展开按钮的事件 */
  368. model.collapsed = !model.collapsed;
  369. this.graph.updateItem(e.item, model);
  370. this.graph.layout();
  371. this.graph.fitView([140,40,20,40]);
  372. } else {
  373. if (model.value) {
  374. let args = {
  375. fileName: model.label,
  376. fileUrl: model.value
  377. } //当前节点及其子节点的值
  378. this.preview(args);
  379. } else {
  380. if (model.id.length === 1) {
  381. // this.chart.option.title.text = '安泰控股集团';
  382. } else {
  383. // this.chart.option.title.text = model.label;
  384. }
  385. /* 节点点击事件 */
  386. // 记录当前节点 id
  387. model.collapsed = false;
  388. this.currentNode.id = model.id;
  389. this.crumbNavs = [];
  390. // 查找所有的节点路径
  391. this.getParentNodes(this.chart.option.series[0].data[0], model.id);
  392. this.graph.changeData(JSON.parse(JSON.stringify(model)));
  393. this.graph.fitView([140,40,20,40]);
  394. }
  395. }
  396. e.item.toFront();
  397. });
  398. },
  399. inputBlur() {
  400. this.showInput = false;
  401. const item = this.graph.findById(this.currentNode.id);
  402. const model = item.getModel();
  403. model.label = this.inputValue;
  404. this.graph.updateItem(item, model);
  405. },
  406. // 编辑节点
  407. editNode(item) {
  408. const model = item.getModel();
  409. const {
  410. cacheCanvasBBox
  411. } = item.get('group').cfg;
  412. this.showInput = true;
  413. this.inputValue = model.label;
  414. this.currentNode.id = model.id;
  415. this.input.x = cacheCanvasBBox.x;
  416. this.input.y = cacheCanvasBBox.y;
  417. this.$nextTick(() => {
  418. this.$refs.inputController.focus();
  419. });
  420. },
  421. deleteNode(item) {
  422. const id = item.get('id');
  423. if (id.length > 1) {
  424. const parentId = id.substring(0, id.length - 2);
  425. const parent = this.graph.findById(parentId);
  426. parent.toFront();
  427. }
  428. this.graph.removeChild(id);
  429. if (id.length > 1) {
  430. const parentId = id.substring(0, id.length - 2);
  431. const parent = this.graph.findById(parentId);
  432. const model = parent.get('model');
  433. if (model.children.length === 0) {
  434. const group = parent.get('group');
  435. const {
  436. children
  437. } = group.cfg;
  438. const icon = children.find(child => child.name === 'node-icon');
  439. const iconText = children.find(child => child.name === 'node-icon-text');
  440. if (icon) {
  441. icon.remove();
  442. iconText.remove();
  443. }
  444. }
  445. }
  446. },
  447. changeNode(node) {
  448. if (node.id.length === 1) {
  449. // this.chart.option.title.text = '安泰控股集团';
  450. } else {
  451. // this.chart.option.title.text = node.label;
  452. }
  453. node.collapsed = false;
  454. this.graph.changeData(JSON.parse(JSON.stringify(node)));
  455. this.graph.fitView([140,40,20,40]);
  456. },
  457. getFileTreeData() {
  458. let that = this,
  459. params = {
  460. fileName: that.filterForm.data.fileName,
  461. type: that.filterForm.data.securityTypeid,
  462. fileType: that.filterForm.data.securityTag.toString()
  463. };
  464. that.tableLoading = true;
  465. let url = 'pass/ems/v1/uploadfiles/getFileTree/?securityInfo=' + that.qrRole;
  466. that.axios.get(url, {
  467. params: params
  468. })
  469. .then(function(res) {
  470. if (res.code === '0') {
  471. let arr = [];
  472. // that.chart.height = res.data.length * 100 + 'px';
  473. arr = that.treeDataUtil1(res.data, '1');
  474. console.log(arr);
  475. // arr = that.getParentNodes(res.data, 1)
  476. arr[0].style = {
  477. fill: '#f79646'
  478. };
  479. arr[0].id = '1';
  480. arr[0].collapsed = false;
  481. that.chart.option.series[0].data = arr;
  482. // that.setGraphical();
  483. that.createGraphic();
  484. } else {
  485. that.$message.error(res.message);
  486. }
  487. that.tableLoading = false;
  488. }).catch(function() {
  489. that.tableLoading = false;
  490. });
  491. },
  492. treeDataUtil(treeData, id) {
  493. let that = this;
  494. let data = [];
  495. let children = [];
  496. let children1 = [];
  497. let i = 0;
  498. let k = 0;
  499. let j = 0;
  500. let g = 0;
  501. let name = '';
  502. let style = {};
  503. let labelCfg = {};
  504. switch (id.toString().split("-").length) {
  505. case 1:
  506. style = {
  507. fill: '#e6b9b8',
  508. };
  509. break;
  510. case 2:
  511. style = {
  512. fill: '#ffff66',
  513. };
  514. break;
  515. case 3:
  516. style = {
  517. fill: '#d9d9d9',
  518. };
  519. break;
  520. default:
  521. break;
  522. };
  523. for (let item of treeData) {
  524. i++;
  525. if (item.fileName === null) {
  526. g++;
  527. if (item.children !== null) {
  528. if (id == '') {
  529. children = that.treeDataUtil(item.children, i);
  530. } else {
  531. children = that.treeDataUtil(item.children, id + '-' + g);
  532. }
  533. };
  534. data.push({
  535. collapsed: true,
  536. id: id + '-' + g,
  537. nodeType: 'node',
  538. label: item.createMan,
  539. children: children,
  540. style: style,
  541. labelCfg: labelCfg,
  542. });
  543. children = [];
  544. } else {
  545. if (name === '' || i === 1) {
  546. name = item.createMan;
  547. } else if (name !== item.createMan) {
  548. g++;
  549. for (let ch of children1) {
  550. ch.id = id + '-' + g + ch.id.substring(ch.id.lastIndexOf("-"))
  551. }
  552. data.push({
  553. collapsed: true,
  554. id: id + '-' + g,
  555. nodeType: 'node',
  556. isCollapsed: true,
  557. label: name,
  558. children: children1,
  559. style: style,
  560. labelCfg: labelCfg,
  561. });
  562. j = 0;
  563. children1 = [];
  564. name = item.createMan;
  565. }
  566. j++;
  567. children1.push({
  568. id: id + '-' + g + '-' + j,
  569. label: item.fileName,
  570. value: item.fileUrl,
  571. children: [],
  572. });
  573. }
  574. if (i === treeData.length && children1.length !== 0) {
  575. g++;
  576. for (let ch of children1) {
  577. ch.id = id + '-' + g + ch.id.substring(ch.id.lastIndexOf("-"))
  578. }
  579. data.push({
  580. collapsed: true,
  581. id: id + '-' + g,
  582. nodeType: 'node',
  583. isCollapsed: true,
  584. label: name,
  585. children: children1,
  586. style: style,
  587. labelCfg: labelCfg,
  588. });
  589. }
  590. }
  591. return data;
  592. },
  593. downloadFile(data) {
  594. let that = this;
  595. let SubmitData = {
  596. fileName: data.fileName,
  597. fileUrl: data.fileUrl
  598. };
  599. // 不带token访问方式,留底后端修改shiroconfig.java,application.properties
  600. // let url = '/icore.icp.web/pass/ems/v1/uploadfiles/downloadFile/?fileName=' + that.tableFormDataObj[key].fileName + '&fileUrl=' + that.tableFormDataObj[key].fileUrl;
  601. // const xhr = new XMLHttpRequest();
  602. // xhr.open('GET', url, true);
  603. // xhr.responseType = 'blob';
  604. // xhr.onload = () => {
  605. // if (xhr.status === 200) {
  606. // var fileName = that.tableFormDataObj[key].fileName;
  607. // // 获取文件blob数据并保存
  608. // that.saveAs(xhr.response, fileName);
  609. // }
  610. // };
  611. // xhr.send();
  612. that.loading = true;
  613. let urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  614. that.axios.get(urla, {
  615. params: SubmitData,
  616. responseType: 'blob'
  617. }).then(function(res) {
  618. that.saveAs(res, data.fileName);
  619. that.$message({
  620. message: '下载成功',
  621. type: 'success'
  622. });
  623. that.loading = false;
  624. }).catch(function() {
  625. that.$message.error('下载失败');
  626. that.loading = false;
  627. })
  628. },
  629. // js实现文件下载而不直接打开
  630. saveAs(data, fileName) {
  631. this.loading = true;
  632. let urlObject = window.URL || window.webkitURL || window;
  633. // 将二进制流转为blob
  634. let exportBlob = new Blob([data]);
  635. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  636. // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  637. window.navigator.msSaveBlob(exportBlob, decodeURI(fileName));
  638. this.loading = false;
  639. } else {
  640. // 创建新的URL并指向File对象或者Blob对象的地址
  641. let blobURL = urlObject.createObjectURL(exportBlob);
  642. let saveLink = document.createElement('a');
  643. // 兼容:某些浏览器不支持HTML5的download属性
  644. if (typeof saveLink.download === 'undefined') {
  645. saveLink.setAttribute('target', '_blank');
  646. } else {
  647. saveLink.download = fileName;
  648. }
  649. // 创建新的URL并指向File对象或者Blob对象的地址
  650. saveLink.href = blobURL;
  651. saveLink.click();
  652. // 释放blob URL地址
  653. urlObject.revokeObjectURL(exportBlob);
  654. this.loading = false;
  655. // let blob = new Blob([data])
  656. // let fileURL = urlObject.createObjectURL(blob);
  657. // 下载代码
  658. // let downEle = document.createElement('a')
  659. // let fname = `download` //下载文件的名字
  660. // downEle.href = fileURL
  661. // downEle.setAttribute('download', fname)
  662. // document.body.appendChild(downEle)
  663. // downEle.click()
  664. // window.open(fileURL);
  665. }
  666. },
  667. preview(data) {
  668. let that = this;
  669. that.loading = true;
  670. that.chart.fileData = data;
  671. let SubmitData = {
  672. fileName: data.fileName,
  673. fileUrl: data.fileUrl
  674. };
  675. let urla = 'pass/ems/v1/uploadfiles/getfile/';
  676. let type = 'text/html';
  677. let responseType = 'application/json';
  678. let fileExtension = data.fileName.substring(data.fileName.lastIndexOf('.') + 1);
  679. if (fileExtension === 'pdf') {
  680. urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  681. type = 'application/pdf';
  682. responseType = 'blob';
  683. }
  684. that.tableLoading = true;
  685. that.axios.get(urla, {
  686. params: SubmitData,
  687. responseType: responseType
  688. }).then(function(res) {
  689. console.log('111');
  690. let urlObject = window.URL || window.webkitURL || window;
  691. // 将二进制流转为blob
  692. let blob = new Blob([res], {
  693. type: type
  694. });
  695. if (fileExtension !== 'pdf') {
  696. blob = new Blob([res.data], {
  697. type: type
  698. });
  699. }
  700. // if (typeof window.navigator.msSaveBlob !== 'undefined') {
  701. // // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  702. // window.navigator.msSaveBlob(blob, decodeURI(fileName))
  703. // } else {
  704. // 创建新的URL并指向File对象或者Blob对象的地址
  705. let blobURL = urlObject.createObjectURL(blob);
  706. that.dialogVisible = true;
  707. that.previewUrl = blobURL;
  708. that.tableLoading = false;
  709. that.loading = false;
  710. // 'https://file.keking.cn/onlinePreview?url=' + encodeURIComponent(blobURL)
  711. // http://view.officeapps.live.com/op/view.aspx?src' + blobURL;
  712. // 创建a标签,用于跳转至下载链接
  713. // let tempLink = document.createElement('a')
  714. // tempLink.style.display = 'none'
  715. // tempLink.href = blobURL;
  716. // tempLink.setAttribute('download', decodeURI(fileName))
  717. // 兼容:某些浏览器不支持HTML5的download属性
  718. // if (typeof tempLink.download === 'undefined') {
  719. // tempLink.setAttribute('target', '_blank')
  720. // }
  721. // // 挂载a标签
  722. // document.body.appendChild(tempLink)
  723. // tempLink.click()
  724. // // 销毁a标签
  725. // document.body.removeChild(tempLink)
  726. // 释放blob URL地址
  727. // urlObject.revokeObjectURL(blobURL);
  728. setTimeout(() => {
  729. urlObject.revokeObjectURL(blobURL);
  730. }, 1000)
  731. }).catch(function() {
  732. that.tableLoading = false;
  733. that.$message.error('预览失败');
  734. that.loading = false;
  735. })
  736. },
  737. treeDataUtil1(treeData, id) {
  738. let that = this;
  739. let data = [];
  740. let children = [];
  741. let children1 = [];
  742. let i = 0;
  743. let k = 0;
  744. let j = 0;
  745. let g = 0;
  746. let name = '';
  747. let style = {};
  748. let labelCfg = {};
  749. switch (id.toString().split("-").length) {
  750. case 2:
  751. style = {
  752. fill: '#e6b9b8',
  753. };
  754. break;
  755. case 3:
  756. style = {
  757. fill: '#ffff66',
  758. };
  759. break;
  760. case 4:
  761. style = {
  762. fill: '#d9d9d9',
  763. };
  764. break;
  765. default:
  766. break;
  767. };
  768. for (let item of treeData) {
  769. i++;
  770. if(item.children !== null) {
  771. if(id === ''){
  772. children = that.treeDataUtil1(item.children,i);
  773. } else{
  774. children = that.treeDataUtil1(item.children,id+'-'+ i);
  775. }
  776. name = item.createMan;
  777. }
  778. if(name===''){
  779. name = item.createMan;
  780. }
  781. if(item.fileName != null && item.createMan === name) {
  782. g++;
  783. children.push({
  784. id: id + '-' + i + '-' + (children.length+1),
  785. label: item.fileName,
  786. value: item.fileUrl,
  787. children: [],
  788. });
  789. }
  790. if( i < treeData.length-1 && treeData[i].createMan === name){
  791. continue;
  792. }
  793. data.push({
  794. collapsed: true,
  795. id: id + '-' + i,
  796. nodeType: 'node',
  797. isCollapsed: true,
  798. label: item.createMan,
  799. children: children,
  800. style: style,
  801. labelCfg: labelCfg,
  802. });
  803. children = [];
  804. name = '';
  805. }
  806. for (let ch of data) {
  807. ch.id = ch.id.slice(2);
  808. }
  809. return data;
  810. },
  811. },
  812. };
  813. </script>
  814. <style lang="scss">
  815. .root {
  816. background: url(../../../../assets/img/img/filebg8.jpg) center bottom no-repeat;
  817. background-size: 100% 100%;
  818. }
  819. .crumb-nav {
  820. position: absolute;
  821. top: 20px;
  822. left: 40px;
  823. background: #73bf8f;
  824. border-radius: 4px;
  825. color: #fff;
  826. }
  827. .nav-text {
  828. display: inline-block;
  829. height: 36px;
  830. line-height: 36px;
  831. margin: 0 10px;
  832. cursor: pointer;
  833. }
  834. .g6-component-contextmenu {
  835. width: 100px;
  836. padding: 6px 0;
  837. cursor: pointer;
  838. .menu-item {
  839. padding: 0 10px;
  840. line-height: 26px;
  841. &:hover {
  842. background: #f0f0f0;
  843. }
  844. }
  845. }
  846. #input-controller {
  847. position: absolute;
  848. top: 0;
  849. left: 0;
  850. z-index: 12;
  851. width: 100px;
  852. height: 30px;
  853. border: 1px solid #ccc;
  854. border-radius: 4px;
  855. padding-left: 6px;
  856. font-size: 14px;
  857. }
  858. .text-nav {
  859. background-color: #ffff00;
  860. position: absolute;
  861. top: 40px;
  862. left: 32%;
  863. font-size: 60px;
  864. font-weight: 600;
  865. // background: #73bf8f;
  866. // border-radius: 4px;
  867. color: #ff0000;
  868. padding: 36px 50px;
  869. }
  870. </style>