pic2.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. <template>
  2. <div class="root">
  3. <div class="container1">
  4. <el-col :span="24">
  5. <div class="itemBox" :span="24">
  6. <el-row :gutter="10" class="flex-box">
  7. <el-col :span="6">
  8. <span class="label">标签名称</span>
  9. <el-autocomplete v-model="searchParam.searchLabel" :fetch-suggestions="getLabelList" placeholder="请输入标签名"
  10. @select="handleSelect" class="el-select"></el-autocomplete>
  11. </el-col>
  12. <el-col :span="2" class="mt10">
  13. <el-checkbox v-model="searchParam.radioTime" @change="isShowTimeinfo">显示时间</el-checkbox>
  14. </el-col>
  15. <el-col :span="2" class="mt10">
  16. <el-checkbox v-model="searchParam.radioItemStatus" @change="isShowItemStatus">显示状态</el-checkbox>
  17. </el-col>
  18. <div class="crumb-nav2">
  19. <template v-for="(nav, index) in crumbNavs">
  20. {{ index > 0 ? '>' : '' }}
  21. <!-- <el-button type="primary" :key="nav.id" @click="changeNode(nav)">{{ nav.label }}</el-button>-->
  22. <span class="nav-text" @click="changeNode(nav)">{{ nav.label }}</span>
  23. </template>
  24. </div>
  25. </el-row>
  26. </div>
  27. <div class="canvaBox">
  28. <div class="minimap">
  29. </div>
  30. <!-- 树图相关 -->
  31. <div id="treeDiv" class="whr100">
  32. <div class="text">安泰安全管理模块展示</div>
  33. </div>
  34. <!-- 重命名节点Dialog -->
  35. <el-dialog title="提示" :visible.sync="renameDialogVisible" width="30%" :before-close="editDialogClose">
  36. <el-input v-model="inputLabel.name" placeholder="请输入"></el-input>
  37. <span slot="footer" class="dialog-footer">
  38. <el-button @click="renameDialogVisible = false">取 消</el-button>
  39. <el-button type="primary" @click="renameSubmit">确 定</el-button>
  40. </span>
  41. </el-dialog>
  42. <!-- 删除dialog -->
  43. <el-dialog title="提示" :visible.sync="delDialogVisible" width="20%" :before-close="delDialogClose">
  44. <div class="title">是否确认删除?</div>
  45. <span slot="footer" class="dialog-footer">
  46. <el-button @click="delDialogVisible = false">取 消</el-button>
  47. <el-button type="primary" @click="delSubmit">确 定</el-button>
  48. </span>
  49. </el-dialog>
  50. </div>
  51. </el-col>
  52. <el-drawer title="节点信息" :visible.sync="dataInfoDrawerVisible" class="dataInfo-drawer-dialog" @close="dataInfoClose"
  53. size="50%">
  54. <el-form ref="dataInfoForm" :model="dataInfoForm" label-width="90px">
  55. <el-form-item label="节点名称">
  56. <el-col :span="11">
  57. <el-input v-model="dataInfoForm.name"></el-input>
  58. </el-col>
  59. </el-form-item>
  60. <el-form-item label="详细情况">
  61. <el-col :span="11">
  62. <el-input v-model="dataInfoForm.content"></el-input>
  63. </el-col>
  64. </el-form-item>
  65. </el-form>
  66. <div class="dataInfoFootDiv">
  67. <el-button @click="dataInfoDrawerVisible = false">取 消</el-button>
  68. <el-button type="primary" @click="dataInfoSubmit">保 存</el-button>
  69. </div>
  70. </el-drawer>
  71. <el-dialog title="文件预览" :visible.sync="dialogVisible" destroy-on-close width="90%" top="6vh" height="90%">
  72. <el-button size="small" type="primary" icon="el-icon-download" @click="downloadFile(chart.fileData)"
  73. :loading="loading" style="position: absolute; right: 100px; top: 20px;">
  74. 点击保存
  75. </el-button>
  76. <iframe :src="previewUrl" width="100%" :height="singleTableHeight"></iframe>
  77. </el-dialog>
  78. </div>
  79. <!-- 上传器 -->
  80. <el-dialog title="文件重新上传" :visible.sync="dialogVisible2" destroy-on-close width="15%" top="6vh" height="90%">
  81. <el-upload class="upload-demo" ref="upload2" action="" :http-request="del_fileName" :loading="uploadloading"
  82. :auto-upload="true">
  83. <el-button slot="trigger" size="small" type="primary" :loading="loading" icon="el-icon-plus">选取文件
  84. </el-button>
  85. </el-upload>
  86. </el-dialog>
  87. <el-dialog title="文件上传" :visible.sync="dialogVisible1" destroy-on-close width="15%" top="6vh" height="90%">
  88. <el-upload class="upload-demo" ref="upload1" :file-list="fileList" action=""
  89. :loading="loading" :auto-upload="false" :on-change="handleChange" :on-remove="handleRemove">
  90. <el-button slot="trigger" size="small" type="primary" :loading="loading" icon="el-icon-plus">选取文件
  91. </el-button>
  92. <el-button size="small" type="primary" icon="el-icon-bottom-right" @click="beforeUpload">上传
  93. </el-button>
  94. <div slot="tip" class="el-upload__tip">上传文件总和请不要超过10mb</div>
  95. </el-upload>
  96. </el-dialog>
  97. <el-dialog title="文件信息预览" :visible.sync="dialogVisible3" destroy-on-close width="85%" top="6vh" height="90%" >
  98. <el-table :data="tableData" border style="width: 100%" max-height="500" stripe = "true">
  99. <el-table-column prop="createtime" label="上传时间" width="180">
  100. </el-table-column>
  101. <el-table-column prop="createman" label="上传人" width="80">
  102. </el-table-column>
  103. <el-table-column prop="filepath" label="文件地址" width="350">
  104. </el-table-column>
  105. <el-table-column prop="filename" label="文件名">
  106. </el-table-column>
  107. <el-table-column label="操作" width="200">
  108. <template slot-scope="scope">
  109. <el-button @click="preview(scope.row)">预 览</el-button>
  110. <el-button type="primary" @click="test3(scope.row)">重新上传</el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. import moment from "moment";
  119. import { Message } from "element-ui";
  120. import G6 from "@antv/g6";
  121. import insertCss from "insert-css";
  122. const { Util, TreeGraph, registerNode, Menu, Tooltip, Minimap } = G6;
  123. let graph = {};
  124. //节点类型颜色
  125. const nodeType2Color = {
  126. 0: "#BBDAFB",
  127. 100: "#FFFFCC",
  128. 200: "#FBD4D4",
  129. 300: "#BCF2DA",
  130. 400: "#CCFF99",
  131. 500: "#FBD4D4",
  132. 600: "#BBDAFB",
  133. };
  134. //根据节点状态颜色
  135. const itemStatusColor = {
  136. 0: "#5B8FF9",
  137. 100: "#EEBC20",
  138. 200: "#5BD8A6",
  139. 300: "#F46649",
  140. };
  141. export default {
  142. name: "root",
  143. data() {
  144. return {
  145. rowNodeid: '',
  146. rowDataid: '',
  147. pageNum: 1,
  148. pageSize: 100,
  149. fileList: [],
  150. tableData: [],
  151. dialogVisible3: false,
  152. graph: null,
  153. thereDataId: '',
  154. crumbNavs: [],
  155. canvasWidth: 0, // 画布宽度
  156. canvasHeight: 0,// 画布高度
  157. singleTableHeight: '720px',
  158. previewUrl: '',
  159. activeMenu: '',
  160. nodeid: '',
  161. NodeData: {
  162. },
  163. selectFileType: "",
  164. uploadData: [],
  165. uploadIf: true,
  166. tableHeight: 500,
  167. uploadStop: false,
  168. dialogVisible: false,
  169. dialogVisible1: false,
  170. dialogVisible2: false,
  171. loading: false,
  172. loading2: false,
  173. uploadloading: false,
  174. tableLoading: false,
  175. chart: {
  176. height: '1024px',
  177. show: false,
  178. fileData: {
  179. fileName: '',
  180. fileUrl: ''
  181. },
  182. option: {
  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: 15
  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. initTinymce: {
  226. language: "zh_CN", //语言
  227. height: 300, //编辑器高度
  228. branding: false, //是否禁用“Powered by TinyMCE”
  229. menubar: false, //顶部菜单栏显示
  230. },
  231. renameDialogVisible: false,
  232. delDialogVisible: false,
  233. dataInfoDrawerVisible: false,
  234. dataInfoForm: {
  235. id: "",
  236. name: "",
  237. itemtype: "",
  238. itemstatus: "",
  239. content: "",
  240. createtime: "",
  241. tlevel: "",
  242. parentid: "",
  243. filename: ""
  244. },
  245. file: {
  246. id: "",
  247. filename: ""
  248. },
  249. itemStatusList: {
  250. 100: "无文件",
  251. 200: "有文件",
  252. },
  253. dataList: [],
  254. itemTypeList: {
  255. 100: "项目准备工作相关",
  256. 200: "项目程序制作",
  257. 300: "项目测试相关"
  258. },
  259. dataInfo: [],
  260. selectLabelList: [],
  261. findLabeltimeout: false,
  262. lastSelectedNodeArr: [], // 上次选中节点
  263. itemNode: {}, // 右键菜单项 点击时的节点
  264. inputLabel: {
  265. name: "",
  266. },
  267. treeData: [],
  268. treeData1: [],
  269. listData: [],
  270. searchParam: {
  271. searchLabel: "",
  272. searchItemStatus: "",
  273. itemtype: "",
  274. radioItemStatus: "",
  275. },
  276. };
  277. },
  278. created() {
  279. // this.treeData3();
  280. this.getGxNameData();
  281. },
  282. mounted() {
  283. },
  284. methods: {
  285. changeNode(node) {
  286. if (node) {
  287. console.log('casdasd', node)
  288. if (node.tlevel === 1) {
  289. this.crumbNavs = null;
  290. }
  291. graph.changeData(node);
  292. //graph.changeData(JSON.parse(JSON.stringify(node)));
  293. graph.fitView([140, 40, 20, 40]);
  294. } else {
  295. console.log("没有数据")
  296. }
  297. },
  298. treeData3() {
  299. //获取tree数据
  300. // this.treeData = require('../securitys/treeData2.json');
  301. let that = this;
  302. // 根据tree获取平级数组../
  303. const treeData = JSON.parse(JSON.stringify(this.treeData));
  304. this.listData = this.treeToList(treeData);
  305. // select数据
  306. this.listData.forEach((item) => {
  307. this.selectLabelList.push({
  308. value: item.name,
  309. name: item.name,
  310. id: item.id,
  311. levle: item.tlevel
  312. });
  313. });
  314. this.$nextTick(() => {
  315. this.treeInit();
  316. });
  317. },
  318. treeInit() {
  319. const that = this;
  320. that.styleCss(); // 样式函数
  321. // 创建G6右键菜单
  322. const menu = new Menu({
  323. itemTypes: ["node"],
  324. getContent(evt) {
  325. const model = evt.item.getModel();
  326. let menuHtml = `
  327. <div class="contextmenu__item" id="addLabel">新建标签</div>
  328. <div class="contextmenu__item" id="editLabel">重命名</div>
  329. <div class="contextmenu__item" id="delLabel">删除</div>
  330. <div class="contextmenu__item" id="beforeUpload">上传文件</div>`;
  331. return menuHtml;
  332. },
  333. handleMenuClick(target, item) {
  334. if (target.id == "addLabel") {
  335. // 新建
  336. that.itemNode = item;
  337. Object.keys(that.dataInfoForm).forEach((key) => {
  338. that.dataInfoForm[key] = "";
  339. });
  340. that.dataInfoDrawerVisible = true;
  341. } else if (target.id == "editLabel") {
  342. // 重命名
  343. that.itemNode = item;
  344. that.renameDialog();
  345. } else if (target.id == "beforeUpload") {
  346. // 上传文件
  347. that.itemNode = item;
  348. that.dialogVisible1 = true;
  349. console.log('fileitemNode', that.itemNode)
  350. }else if (target.id == "delLabel") {
  351. // 删除
  352. that.itemNode = item;
  353. that.delDialogVisible = true;
  354. } else if (target.id == "dataInfoLabel") {
  355. } else if (target.id == "detailLabel") {
  356. // 修改
  357. that.itemNode = item;
  358. that.dataInfoForm = that.itemNode.getModel();
  359. that.dataInfoForm.content = that.dataInfoForm.content.toString();
  360. that.dataInfoDrawerVisible = true;
  361. }
  362. },
  363. });
  364. //弹出层
  365. const tooltip = new Tooltip({
  366. getContent(e) {
  367. var tooltipHtml = "";
  368. const model = e.item.getModel();
  369. if (model.content && model.content.toString().length > 0) {
  370. tooltipHtml =
  371. `
  372. <div class="tooltip-header" >` +
  373. model.createtime +
  374. `(` +
  375. model.itemStatusName +
  376. `)</div>
  377. <div class="tooltip-content" ><h3>` +
  378. model.name +
  379. `</h3>` +
  380. model.content +
  381. `</div> `;
  382. }
  383. return tooltipHtml;
  384. },
  385. shouldBegin(e) {
  386. //设置条件,没有内容不显示tooltip
  387. const model = e.item.getModel();
  388. return model.content ? true : false;
  389. },
  390. itemTypes: ["node"],
  391. offsetX: 1,
  392. offsetY: 0,
  393. fixToNode: false,
  394. offset: 10,
  395. });
  396. // 实例化 minimap 插件
  397. const minimap = new Minimap({
  398. container: document.querySelector(".minimap"),
  399. size: [200, 200],
  400. });
  401. // G6增加自定义节点信息;
  402. registerNode(
  403. "rNode",
  404. {
  405. drawShape: (cfg, group) => {
  406. const {
  407. id,
  408. name,
  409. itemtype,
  410. style,
  411. size,
  412. itemstatus,
  413. itemStatusName,
  414. createtime,
  415. tlevel,
  416. file_name,
  417. file_url
  418. } = cfg;
  419. const rect = group.addShape("rect", {
  420. attrs: {
  421. ...style,
  422. x: -size[0] / 2,
  423. y: -size[1] / 2,
  424. width: size[0],
  425. height: size[1],
  426. fill: nodeType2Color[itemtype],
  427. },
  428. name: "rect",
  429. });
  430. // text time
  431. group.addShape("text", {
  432. attrs: {
  433. text: that.searchParam.radioTime
  434. ? moment(createtime).format("YYYY-MM-DD")
  435. : "",
  436. x: -size[0] / 2,
  437. y: -size[1] / 2 - 15,
  438. opacity: 1,
  439. fill: "#999",
  440. textBaseline: "top",
  441. },
  442. name: "rect-shape-text1",
  443. });
  444. // text itemStatusName
  445. group.addShape("text", {
  446. attrs: {
  447. text: that.searchParam.radioItemStatus ? "(" + itemStatusName + ")" : "",
  448. x: size[0] / 2 - 70,
  449. y: size[1] / 2 - 46,
  450. opacity: 1,
  451. fill: itemStatusColor[itemstatus],
  452. textBaseline: "top",
  453. },
  454. name: "rect-shape-text2",
  455. });
  456. return rect;
  457. },
  458. update: (cfg, item) => {
  459. const { id, name, createtime, itemstatus, itemStatusName } = cfg;
  460. const group = item.getContainer();
  461. // 更新节点名
  462. const label = group.find((e) => e.get("name") === "text-shape");
  463. label.attr("text", this.formatLabel(name));
  464. // 更新时间
  465. const text1 = group.find((e) => e.get("name") === "rect-shape-text1");
  466. text1.attr(
  467. "text",
  468. that.searchParam.radioTime
  469. ? moment(createtime).format("YYYY-MM-DD")
  470. : ""
  471. );
  472. // 更新状态及样式
  473. const text2 = group.find((e) => e.get("name") === "rect-shape-text2");
  474. text2.attr({
  475. text: that.searchParam.radioItemStatus ? "(" + itemStatusName + ")" : "",
  476. fill: itemStatusColor[itemstatus],
  477. });
  478. },
  479. },
  480. "rect"
  481. );
  482. const treeDiv = document.querySelector("#treeDiv");
  483. graph = new TreeGraph({
  484. plugins: [menu, minimap, tooltip],
  485. container: "treeDiv",
  486. width: window.innerWidth - 100,
  487. height: window.innerHeight - 100,
  488. fitView: true,
  489. pixelRatio: 2,
  490. modes: {
  491. // 内置行为参考 https://antv-g6.gitee.io/zh/docs/manual/middle/states/defaultBehavior
  492. default: ["collapse-expand", "drag-canvas", "zoom-canvas", "drag-node"],
  493. },
  494. // 设置一些状态时节点变化
  495. nodeStateStyles: {
  496. mouseenter: {
  497. // 鼠标划入样式设置
  498. shadowColor: "#CCC",
  499. shadowBlur: 1,
  500. },
  501. clicked: {
  502. // 选中样式设置
  503. stroke: "#409EFF",
  504. lineWidth: 2,
  505. shadowColor: "#409EFF",
  506. shadowBlur: 10
  507. },
  508. },
  509. // 节点类型及样式
  510. defaultNode: {
  511. size: [100, 30],
  512. type: "rNode",
  513. style: {
  514. // 节点阴影颜色和宽度
  515. shadowColor: "#CCC",
  516. shadowBlur: 20,
  517. // 阴影偏移量
  518. shadowOffsetX: 5,
  519. shadowOffsetY: 5,
  520. // 边框颜色和宽度
  521. stroke: "",
  522. lineWidth: 0,
  523. },
  524. },
  525. // 连线类型及样式
  526. defaultEdge: {
  527. type: "polyline",
  528. style: {
  529. // 节点阴影颜色和宽度
  530. shadowColor: "#CCC",
  531. shadowBlur: 10,
  532. // 阴影偏移量
  533. shadowOffsetX: 5,
  534. shadowOffsetY: 5,
  535. // 颜色和宽度
  536. stroke: "#999",
  537. lineWidth: 2,
  538. },
  539. },
  540. //布局和绘图类型
  541. layout: {
  542. type: "mindmap",
  543. direction: "H",
  544. getHeight: function getHeight() {
  545. return 40;
  546. },
  547. getWidth: function getWidth() {
  548. return 150;
  549. },
  550. getVGap: function getVGap() {
  551. return 10;
  552. },
  553. getHGap: function getHGap() {
  554. return 80;
  555. },
  556. },
  557. });
  558. // 格式化tree数据
  559. Util.traverseTree(this.treeData, (item) => {
  560. if (item.tlevel >= 2) {
  561. item.collapsed = true;
  562. }
  563. Object.keys(that.itemStatusList).forEach(function (k) {
  564. if (k == item.itemstatus) {
  565. item.itemStatusName = that.itemStatusList[k];
  566. }
  567. });
  568. item.label = that.formatLabel(item.name);
  569. });
  570. graph.read(this.treeData);
  571. if (typeof window !== "undefined")
  572. window.onresize = () => {
  573. this.$nextTick(() => {
  574. if (!graph || graph.get("destroyed")) return;
  575. if (!treeDiv || !treeDiv.scrollWidth || !treeDiv.scrollHeight) return;
  576. graph.changeSize(treeDiv.scrollWidth, treeDiv.scrollHeight);
  577. graph.render();
  578. graph.fitView();
  579. });
  580. };
  581. graph.on("node:click", function (event) {
  582. const { item } = event;
  583. const nodeItem = event.item // 获取被点击的节点元素对象
  584. const nodeModel = item.getModel();
  585. that.tableData = [];
  586. if (nodeModel.itemtype === 200) {
  587. that.dialogVisible3 = true;
  588. let arg = {
  589. fileUrl: nodeModel.file_url,
  590. fileName: nodeModel.file_name
  591. }
  592. //that.preview(arg);
  593. that.gettableData(nodeModel.id);
  594. }
  595. that.findNodesByModels([nodeModel]);
  596. that.crumbNavs = [];
  597. that.getParentNodes(that.treeData, nodeModel, nodeModel.id);
  598. that.changeDat(nodeModel);
  599. // if (nodeModel.tlevel > 1) {
  600. // graph.changeData(nodeModel),
  601. // graph.fitView([230, 240, 390, 390]);
  602. // }
  603. });
  604. // 鼠标点击画布,显示所有节点和边
  605. graph.on('canvas:click', function (event) {
  606. const nodes = graph.getNodes();
  607. const edges = graph.getEdges();
  608. nodes.forEach((node) => {
  609. node.show();
  610. });
  611. edges.forEach((edge) => {
  612. edge.show();
  613. });
  614. graph.paint();
  615. });
  616. // 鼠标移入节点 node:mouseenter
  617. graph.on("node:mouseenter", (evt) => {
  618. const { item } = evt;
  619. graph.setItemState(item, "mouseenter", true);
  620. // // 获得当前鼠标操作的目标节点
  621. // const node = item;
  622. // // 获得目标节点的所有相关边
  623. // const edges = node.getEdges();
  624. // // 将所有相关边的 running 状态置为 true,此时将会触发自定义节点的 setState 函数
  625. // edges.forEach((edge) => graph.setItemState(edge, "running", true));
  626. });
  627. // 鼠标移出节点 node:mouseleave
  628. graph.on("node:mouseleave", (evt) => {
  629. const { item } = evt;
  630. graph.setItemState(item, "mouseenter", false);
  631. // // 获得当前鼠标操作的目标节点
  632. // const node = item;
  633. // // 获得目标节点的所有相关边
  634. // const edges = node.getEdges();
  635. // // 将所有相关边的 running 状态置为 false,此时将会触发自定义节点的 setState 函数
  636. // edges.forEach((edge) => graph.setItemState(edge, "running", false));
  637. });
  638. },
  639. gettableData(id) {
  640. let that = this;
  641. let pageNum = 0;
  642. let params = {
  643. nodeId: id
  644. }
  645. that.pageNum = pageNum || that.pageNum;
  646. let url =
  647. "pass/ems/v1/tfileoperates/?pageNum=" +
  648. that.pageNum +
  649. "&pageSize=" +
  650. that.pageSize;
  651. that.axios.get(url, {
  652. params: params
  653. }).then(res => {
  654. if (res.code === '0') {
  655. let arr = [];
  656. for (let e of res.data.list) {
  657. arr.push({
  658. createman: e.createman,
  659. createtime: e.createtime,
  660. filename: e.fileName,
  661. filepath: e.filePath,
  662. NodeId: e.nodeId,
  663. bz: e.bz,
  664. type: e.fileType,
  665. updateman: e.updateman,
  666. updatetime: e.updatetime,
  667. id: e.id,
  668. });
  669. }
  670. that.tableData = arr;
  671. console.log(res);
  672. } else {
  673. that.$message.error(res.message);
  674. }
  675. })
  676. },
  677. getParentNodes(data, node) {
  678. let no1 = 0;
  679. //如果点击的是第二层,只显示导航到第一层
  680. if (node.tlevel === 2) {
  681. this.crumbNavs.push(data);
  682. }
  683. //如果点击的是第三层,只显示导航到第二层和第一层
  684. if (node.tlevel === 3) {
  685. no1 = 1;
  686. const $id = node.parentid;
  687. const $node = data.children.find(item => item.id === $id);
  688. if ($node) {
  689. this.crumbNavs.push($node);
  690. this.thereData = $node.id;
  691. }
  692. }
  693. //如果点击的是第四层,只显示导航到第二层和第一层还有第三层
  694. if (node.tlevel === 4) {
  695. no1 = 1;
  696. const $id = node.parentid;
  697. const $node = data.children.find(item => item.id === this.thereData);
  698. const $node2 = $node.children.find(item => item.id === $id)
  699. if ($node2) {
  700. this.crumbNavs.push($node2);
  701. this.crumbNavs.push($node);
  702. this.fiveData = $node2.id;
  703. }
  704. }
  705. if (node.tlevel === 5) {
  706. no1 = 1;
  707. const $id = node.parentid;
  708. const $node = data.children.find(item => item.id === this.thereData);
  709. console.log('$node', $node)
  710. const $node2 = $node.children.find(item => item.id ===this.fiveData)
  711. const $node3 = $node2.children.find(item => item.id === $id)
  712. if ($node3) {
  713. this.crumbNavs.push($node3);
  714. this.crumbNavs.push($node2);
  715. this.crumbNavs.push($node);
  716. }
  717. }
  718. if (no1 === 1) {
  719. this.crumbNavs.push(data);//第一层
  720. }
  721. },
  722. // 获取节点结构数据
  723. getGxNameData() {
  724. let that = this
  725. let url = 'pass/ems/v1/emssecuernodes/findAll';
  726. that.axios.post(url)
  727. .then(res => {
  728. if (res.code === '0') {
  729. that.treeData = res.data[0];
  730. that.treeData3();
  731. } else {
  732. that.$message.error(res.message);
  733. }
  734. })
  735. },
  736. //changeDat
  737. changeDat(node) {
  738. if (node) {
  739. if (node.tlevel > 1 && node.tlevel<6) {
  740. //graph.changeData(JSON.parse(JSON.stringify(node))),
  741. graph.changeData(node)
  742. graph.fitView([230, 240, 390, 390]);
  743. } else {
  744. console.log("没有数据")
  745. }
  746. }
  747. },
  748. // 获取节点结构数据
  749. getGxNameData3() {
  750. let that = this
  751. let url = 'pass/ems/v1/emssecuernodes/findAll';
  752. that.axios.post(url)
  753. .then(res => {
  754. if (res.code === '0') {
  755. that.treeData = res.data[0];
  756. } else {
  757. that.$message.error(res.message);
  758. }
  759. })
  760. },
  761. getGxNameData2(id) {
  762. let that = this
  763. let url = `pass/ems/v1/emssecuernodes/${id}`;
  764. that.axios.get(url)
  765. .then(res => {
  766. if (res.code === '0') {
  767. that.nodeid = res.data.id;
  768. that.test();
  769. } else {
  770. that.$message.error(res.message);
  771. }
  772. })
  773. },
  774. //查询是否有文件信息
  775. getFileMeg(id) {
  776. let that = this
  777. let url = `pass/ems/v1/uploadfiles/${id}`;
  778. that.axios.get(url)
  779. .then(res => {
  780. if (res.code === '0') {
  781. if (res.fileName) {
  782. that.selectFileType = "1";
  783. }
  784. } else {
  785. that.$message.error(res.message);
  786. }
  787. })
  788. },
  789. //搜索相关
  790. getLabelList(queryString, cb) {
  791. var selectLabelList = this.selectLabelList;
  792. var results = queryString
  793. ? selectLabelList.filter(this.createStateFilter(queryString))
  794. : selectLabelList;
  795. clearTimeout(this.findLabeltimeout);
  796. this.findLabeltimeout = setTimeout(() => {
  797. cb(results);
  798. }, 100);
  799. },
  800. createStateFilter(queryString) {
  801. return (searchLabel) => {
  802. return searchLabel.value.toLowerCase().indexOf(queryString.toLowerCase()) != -1;
  803. };
  804. },
  805. handleSelect(item) {
  806. // 清空searchLabel
  807. this.searchParam.searchItemStatus = "";
  808. const node = graph.findById(item.id);
  809. graph.focusItem(node, true, {
  810. easing: "easeCubic",
  811. duration: 500,
  812. });
  813. graph.translate(0, -200);
  814. this.findNodesByModels([item]);
  815. },
  816. initTree(data) {
  817. // 文本超出隐藏 (字段, 最大长度, 字体大小)
  818. const fittingString = (str, maxWidth, fontSize) => {
  819. const ellipsis = '...';
  820. const ellipsisLength = G6.Util.getTextSize(ellipsis, fontSize)[0];
  821. let currentWidth = 0;
  822. let res = str;
  823. const pattern = new RegExp('[\u4E00-\u9FA5]+'); // distinguish the Chinese charactors and letters
  824. str.split('').forEach((letter, i) => {
  825. if (currentWidth > maxWidth - ellipsisLength) return;
  826. if (pattern.test(letter)) {
  827. // Chinese charactors
  828. currentWidth += fontSize;
  829. } else {
  830. // get the width of single letter according to the fontSize
  831. currentWidth += G6.Util.getLetterWidth(letter, fontSize);
  832. }
  833. if (currentWidth > maxWidth - ellipsisLength) {
  834. res = `${str.substr(0, i)}${ellipsis}`;
  835. }
  836. });
  837. return res;
  838. };
  839. },
  840. findNodesByModels(arr) {
  841. // 查询是否有被选中节点,并清除样式
  842. if (this.lastSelectedNodeArr) {
  843. this.lastSelectedNodeArr.map((val) => {
  844. graph.setItemState(val.id, "clicked", false);
  845. });
  846. this.lastSelectedNodeArr = [];
  847. }
  848. // arr为空,就不走下面选中逻辑了
  849. if (arr) {
  850. arr.map((item) => {
  851. let findobj = graph.findById(item.id);
  852. if (findobj) {
  853. // 保存选中节点
  854. this.lastSelectedNodeArr.push(findobj.getModel());
  855. // 修改选中节点样式
  856. graph.setItemState(item.id, "clicked", true);
  857. }
  858. });
  859. }
  860. },
  861. // 重置条件
  862. searchResetFn() {
  863. Object.keys(this.searchParam).forEach((key) => {
  864. this.searchParam[key] = "";
  865. });
  866. this.findNodesByModels();
  867. },
  868. searchFn() {
  869. // 清空searchLabel
  870. this.searchParam.searchLabel = "";
  871. console.log('searchParam', this.searchParam)
  872. //搜索状态fn
  873. let searchNodes = [];
  874. let searchNodeModels = [];
  875. //获取选中状态的所有节点
  876. searchNodes = graph.findAll("node", (node) => {
  877. return node.get("model").itemstatus == this.searchParam.searchItemStatus;
  878. });
  879. //获取选中状态的所有model
  880. searchNodes.forEach((item) => {
  881. searchNodeModels.push(item.get("model"));
  882. });
  883. this.findNodesByModels(searchNodeModels);
  884. },
  885. isShowTimeinfo() {
  886. graph.render();
  887. graph.fitView();
  888. },
  889. isShowItemStatus() {
  890. graph.render();
  891. graph.fitView();
  892. },
  893. renameDialog() {
  894. this.inputLabel.name = this.itemNode._cfg.model.name;
  895. this.renameDialogVisible = true;
  896. },
  897. dataInfoSubmit() {
  898. let that = this;
  899. if (this.dataInfoForm.name == "") {
  900. Message.error("请输入名称");
  901. return;
  902. }
  903. //add 新建子节点
  904. if (!this.dataInfoForm.id) {
  905. //this.dataInfoForm.id = `n-${Math.random()}`;
  906. this.dataInfoForm.label = this.formatLabel(this.dataInfoForm.name);
  907. this.dataInfoForm.itemtype = this.itemNode._cfg.model.itemtype;
  908. this.dataInfoForm.itemstatus = 0;
  909. this.dataInfoForm.tlevel = this.itemNode._cfg.model.tlevel + 1;
  910. this.dataInfoForm.parentid = this.itemNode._cfg.model.id;
  911. this.addGxNameData(this.dataInfoForm)
  912. const model = this.itemNode.getModel();
  913. if (!model.children) {
  914. model.children = [];
  915. }
  916. this.dataInfoForm.id = that.nodeid;
  917. console.log('that.nodeid', that.nodeid)
  918. model.children.push(this.dataInfoForm);
  919. graph.updateChild(model, model.id);
  920. } else {
  921. //修改节点
  922. const model = this.itemNode.getModel();
  923. const originStyle = this.itemNode.get("originStyle");
  924. let updateModel = {
  925. ...model,
  926. ...this.dataInfoForm,
  927. itemstatus: 0,
  928. itemStatusName: "已保存",
  929. name: this.dataInfoForm.name,
  930. };
  931. const nodeItem = graph.findById(model.id);
  932. graph.updateItem(nodeItem, updateModel);
  933. }
  934. this.dataInfoDrawerVisible = false;
  935. Message.success("新建成功");
  936. },
  937. test() {
  938. //this.dataInfoForm.id = `n-${Math.random()}`;
  939. let that = this;
  940. this.dataInfoForm.label = this.formatLabel(this.dataInfoForm.name);
  941. this.dataInfoForm.itemtype = this.itemNode._cfg.model.itemtype;
  942. this.dataInfoForm.itemstatus = 0;
  943. this.dataInfoForm.tlevel = this.itemNode._cfg.model.tlevel + 1;
  944. this.dataInfoForm.parentid = this.itemNode._cfg.model.id;
  945. const model = this.itemNode.getModel();
  946. if (!model.children) {
  947. model.children = [];
  948. }
  949. this.dataInfoForm.id = that.nodeid;
  950. console.log('that.nodeid', that.nodeid)
  951. model.children.push(this.dataInfoForm);
  952. graph.updateChild(model, model.id);
  953. },
  954. test3(row) {
  955. let that = this;
  956. that.dialogVisible2 = true;
  957. that.rowDataid = row.id;
  958. that.rowNodeid = row.NodeId;
  959. },
  960. renameSubmit() {
  961. const model = this.itemNode.getModel();
  962. const updateModel = {
  963. ...model,
  964. name: this.inputLabel.name,
  965. label: this.formatLabel(this.inputLabel.name),
  966. };
  967. const updateModel2 = {
  968. name: this.inputLabel.name,
  969. content: this.inputLabel.content
  970. };
  971. let id = model.id;
  972. this.updateNameData(id, updateModel2);
  973. console.log('renanme model', id)
  974. this.itemNode.update(updateModel);
  975. Message.success("修改成功");
  976. this.renameDialogVisible = false;
  977. },
  978. delSubmit() {
  979. this.delDialogVisible = false;
  980. const model = this.itemNode.getModel();
  981. if (model.depth != 0) {
  982. //根节点不能删除,这里写删除访问后台接口逻辑
  983. let id = model.id;
  984. this.getFileMeg(id);
  985. if (this.selectFileType === '1') {
  986. this.open1();
  987. }
  988. this.but_del_plural(id);
  989. graph.removeChild(model.id);
  990. //停止缩进动画,不加就像收起节点一样,视觉显示错误
  991. graph.stopAnimate();
  992. Message.success("删除成功");
  993. }
  994. },
  995. updateDatepicker(arr) {
  996. //时间更新
  997. this.dataInfoForm = {
  998. ...this.dataInfoForm,
  999. startTime: arr[0],
  1000. endTime: arr[1],
  1001. };
  1002. },
  1003. downloadImage() {
  1004. graph.downloadFullImage('tree');
  1005. },
  1006. editDialogClose() {
  1007. this.renameDialogVisible = false;
  1008. },
  1009. delDialogClose() {
  1010. this.renameDialogVisible = false;
  1011. },
  1012. dataInfoClose() {
  1013. this.dataInfoDrawerVisible = false;
  1014. },
  1015. //格式化label
  1016. formatLabel(str) {
  1017. return str.length > 20 ? str.substr(0, 20) + "..." : str;
  1018. },
  1019. // js实现文件下载而不直接打开
  1020. saveAs(data, fileName) {
  1021. this.loading = true;
  1022. let urlObject = window.URL || window.webkitURL || window;
  1023. // 将二进制流转为blob
  1024. let exportBlob = new Blob([data]);
  1025. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  1026. // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  1027. window.navigator.msSaveBlob(exportBlob, decodeURI(fileName));
  1028. this.loading = false;
  1029. } else {
  1030. // 创建新的URL并指向File对象或者Blob对象的地址
  1031. let blobURL = urlObject.createObjectURL(exportBlob);
  1032. let saveLink = document.createElement('a');
  1033. // 兼容:某些浏览器不支持HTML5的download属性
  1034. if (typeof saveLink.download === 'undefined') {
  1035. saveLink.setAttribute('target', '_blank');
  1036. } else {
  1037. saveLink.download = fileName;
  1038. }
  1039. // 创建新的URL并指向File对象或者Blob对象的地址
  1040. saveLink.href = blobURL;
  1041. saveLink.click();
  1042. // 释放blob URL地址
  1043. urlObject.revokeObjectURL(exportBlob);
  1044. this.loading = false;
  1045. // let blob = new Blob([data])
  1046. // let fileURL = urlObject.createObjectURL(blob);
  1047. // 下载代码
  1048. // let downEle = document.createElement('a')
  1049. // let fname = `download` //下载文件的名字
  1050. // downEle.href = fileURL
  1051. // downEle.setAttribute('download', fname)
  1052. // document.body.appendChild(downEle)
  1053. // downEle.click()
  1054. // window.open(fileURL);
  1055. }
  1056. },
  1057. // 文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用,function(file, fileList)
  1058. handleChange(file, fileList) {
  1059. this.fileList = fileList
  1060. let size = 0;
  1061. this.fileList.forEach((item)=>{
  1062. size +=item.size
  1063. })
  1064. let fileSize = size/1024/1024 < 10 ?0:1
  1065. if(fileSize===1){
  1066. this.$message.error("上传文件大小请不要超过10MB!")
  1067. }
  1068. console.log(fileSize ===1)
  1069. },
  1070. // 删除文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止删除。function(file, fileList)
  1071. handleRemove(file, fileList) {
  1072. this.fileList = fileList
  1073. },
  1074. // 新增节点结构数据
  1075. addGxNameData(arr1) {
  1076. let that = this
  1077. let url = 'pass/ems/v1/emssecuernodes/';
  1078. that.axios.post(url, arr1)
  1079. .then(res => {
  1080. if (res.code === '0') {
  1081. let id = res.data.id;
  1082. that.getGxNameData2(id);
  1083. } else {
  1084. that.$message.error(res.message);
  1085. }
  1086. })
  1087. },
  1088. // 更改节点名称
  1089. updateNameData(arr1, arr2) {
  1090. let that = this
  1091. let url = `pass/ems/v1/emssecuernodes/${arr1}`;
  1092. that.axios.put(url, arr2)
  1093. .then(res => {
  1094. if (res.code === '0') {
  1095. console.log('res', res)
  1096. } else {
  1097. that.$message.error(res.message);
  1098. }
  1099. })
  1100. },
  1101. // 更改文件信息
  1102. updateNameData2(arr1, arr2) {
  1103. let that = this
  1104. let url = `pass/ems/v1/emssecuernodes/${arr1}`;
  1105. that.axios.put(url, arr2)
  1106. .then(res => {
  1107. if (res.code === '0') {
  1108. console.log('res', res)
  1109. } else {
  1110. that.$message.error(res.message);
  1111. }
  1112. })
  1113. },
  1114. //删除提示
  1115. open1() {
  1116. const h = this.$createElement;
  1117. this.$notify({
  1118. title: '删除警告',
  1119. message: h('i', { style: 'color: teal' }, '该节点存在文件,请确认是否永久删除!!!')
  1120. });
  1121. },
  1122. //上传文件
  1123. beforeUpload() {
  1124. let that = this;
  1125. // that.uploadloading = true;
  1126. let foorData = new FormData();
  1127. that.fileList.forEach((file => {
  1128. foorData.append('files', file.raw);
  1129. }))
  1130. //foorData.append('files', file.file);
  1131. foorData.append('id', that.itemNode._cfg.id);
  1132. //foorData.append('name', that.itemNode._cfg.model.label);
  1133. that.axios.post('pass/ems/v1/tfileoperates/fileUpload', foorData, {
  1134. headers: {
  1135. 'Content-Type': 'multipart/form-data'
  1136. }
  1137. }).then(function (res) {
  1138. if (res.code === '0') {
  1139. that.$message({
  1140. message: '上传成功',
  1141. type: 'success'
  1142. });
  1143. let arr2 = {
  1144. itemstatus: 200,
  1145. itemtype: 200
  1146. }
  1147. that.updateNameData2(that.itemNode._cfg.id, arr2);
  1148. that.uploadloading = false;
  1149. that.$refs.upload1.clearFiles();
  1150. that.getGxNameData();
  1151. graph.changeData();
  1152. location.reload();
  1153. }
  1154. else {
  1155. that.$message.error(res.message);
  1156. that.$refs.upload1.clearFiles();
  1157. }
  1158. that.tableLoading = false;
  1159. that.uploadloading = false;
  1160. that.fileList = [];
  1161. })
  1162. },
  1163. //重新上传文件
  1164. beforeUpload2(file) {
  1165. console.log('beforeUpload2', file)
  1166. let that = this;
  1167. that.uploadloading = true;
  1168. let foorData = new FormData();
  1169. foorData.append('files', file.file);
  1170. foorData.append('id', that.rowDataid);
  1171. //foorData.append('name', that.itemNode._cfg.model.label);
  1172. // that.del_fileName(that.itemNode._cfg.id);
  1173. that.axios.post('pass/ems/v1/tfileoperates/fileUploa2', foorData, {
  1174. headers: {
  1175. 'Content-Type': 'multipart/form-data'
  1176. }
  1177. }).then(function (res) {
  1178. if (res.code === '0') {
  1179. that.$message({
  1180. message: '修改成功',
  1181. type: 'success'
  1182. });
  1183. that.loading = false;
  1184. that.dialogVisible2 = false;
  1185. that.$refs.upload2.clearFiles();
  1186. console.log(that.rowNodeid);
  1187. that.gettableData(that.rowNodeid);
  1188. graph.changeData();
  1189. }
  1190. else {
  1191. that.$message.error(res.message);
  1192. that.$refs.upload2.clearFiles();
  1193. }
  1194. that.tableLoading = false;
  1195. that.loading = false;
  1196. that.uploadloading = false;
  1197. })
  1198. },
  1199. // 删除上传的文件
  1200. del_fileName(file) {
  1201. let that = this;
  1202. let id = that.rowDataid;
  1203. if (id) {
  1204. that.axios.delete('pass/ems/v1/tfileoperates/' + id)
  1205. .then(function (res) {
  1206. if (res.code === '0') {
  1207. that.$message({
  1208. message: '上传成功',
  1209. type: 'success'
  1210. });
  1211. that.beforeUpload2(file);
  1212. } else {
  1213. if (res.code === '51') {
  1214. }
  1215. that.$message.error(res.message);
  1216. }
  1217. }).catch(function () {
  1218. });
  1219. }
  1220. },
  1221. // 删除节点
  1222. but_del_plural(val1) {
  1223. let that = this;
  1224. if (val1) {
  1225. that.axios.delete('pass/ems/v1/emssecuernodes/' + val1)
  1226. .then(function (res) {
  1227. if (res.code === '0') {
  1228. that.$message({
  1229. message: '删除成功',
  1230. type: 'success'
  1231. });
  1232. } else {
  1233. if (res.code === '51') {
  1234. }
  1235. that.$message.error(res.message);
  1236. }
  1237. }).catch(function () {
  1238. });
  1239. }
  1240. },
  1241. //预览文件
  1242. preview(data) {
  1243. let that = this;
  1244. that.loading = true;
  1245. that.chart.fileData = data;
  1246. console.log(data)
  1247. let SubmitData = {
  1248. fileName: data.filename,
  1249. fileUrl: data.filepath
  1250. };
  1251. let urla = 'pass/ems/v1/uploadfiles/getfile/';
  1252. let type = 'text/html';
  1253. let responseType = 'application/json';
  1254. if (data.filename !== null) {
  1255. let fileExtension = data.filename.substring(data.filename.lastIndexOf('.') + 1);
  1256. if (fileExtension === 'pdf') {
  1257. urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  1258. type = 'application/pdf';
  1259. responseType = 'blob';
  1260. }
  1261. that.axios.get(urla, {
  1262. params: SubmitData,
  1263. responseType: responseType
  1264. }).then(function (res) {
  1265. console.log('111');
  1266. let urlObject = window.URL || window.webkitURL || window;
  1267. // 将二进制流转为blob
  1268. let blob = new Blob([res], {
  1269. type: type
  1270. });
  1271. if (fileExtension !== 'pdf') {
  1272. blob = new Blob([res.data], {
  1273. type: type
  1274. });
  1275. }
  1276. // if (typeof window.navigator.msSaveBlob !== 'undefined') {
  1277. // // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  1278. // window.navigator.msSaveBlob(blob, decodeURI(fileName))
  1279. // } else {
  1280. // 创建新的URL并指向File对象或者Blob对象的地址
  1281. let blobURL = urlObject.createObjectURL(blob);
  1282. that.dialogVisible = true;
  1283. that.previewUrl = blobURL;
  1284. that.tableLoading = false;
  1285. that.loading = false;
  1286. // 'https://file.keking.cn/onlinePreview?url=' + encodeURIComponent(blobURL)
  1287. // http://view.officeapps.live.com/op/view.aspx?src' + blobURL;
  1288. // 创建a标签,用于跳转至下载链接
  1289. // let tempLink = document.createElement('a')
  1290. // tempLink.style.display = 'none'
  1291. // tempLink.href = blobURL;
  1292. // tempLink.setAttribute('download', decodeURI(fileName))
  1293. // 兼容:某些浏览器不支持HTML5的download属性
  1294. // if (typeof tempLink.download === 'undefined') {
  1295. // tempLink.setAttribute('target', '_blank')
  1296. // }
  1297. // // 挂载a标签
  1298. // document.body.appendChild(tempLink)
  1299. // tempLink.click()
  1300. // // 销毁a标签
  1301. // document.body.removeChild(tempLink)
  1302. // 释放blob URL地址
  1303. // urlObject.revokeObjectURL(blobURL);
  1304. setTimeout(() => {
  1305. urlObject.revokeObjectURL(blobURL);
  1306. }, 1000)
  1307. }).catch(function () {
  1308. //that.tableLoading = false;
  1309. that.$message.error('预览失败');
  1310. that.loading = true;
  1311. })
  1312. }
  1313. },
  1314. //下载文件
  1315. downloadFile(data) {
  1316. let that = this;
  1317. let SubmitData = {
  1318. fileName: data.filename,
  1319. fileUrl: data.filepath
  1320. };
  1321. that.loading = true;
  1322. let urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  1323. that.axios.get(urla, {
  1324. params: SubmitData,
  1325. responseType: 'blob'
  1326. }).then(function (res) {
  1327. that.saveAs(res, data.filename);
  1328. that.$message({
  1329. message: '下载成功',
  1330. type: 'success'
  1331. });
  1332. that.loading = false;
  1333. }).catch(function () {
  1334. that.$message.error('下载失败');
  1335. that.loading = false;
  1336. })
  1337. },
  1338. /* tree转化平级数组 */
  1339. treeToList(tree) {
  1340. var queen = [];
  1341. var out = [];
  1342. queen = queen.concat(tree);
  1343. while (queen.length) {
  1344. var first = queen.shift();
  1345. if (first.children) {
  1346. queen = queen.concat(first.children);
  1347. delete first["children"];
  1348. }
  1349. out.push(first);
  1350. }
  1351. return out;
  1352. },
  1353. back() {
  1354. this.$router.go(-1);
  1355. },
  1356. // 浮框样式
  1357. styleCss() {
  1358. insertCss(`
  1359. .g6-component-tooltip {
  1360. max-width: 600px;
  1361. max-height: 500px;
  1362. overflow-y: auto;
  1363. position: absolute;
  1364. left: -150px;
  1365. z-index: 5;
  1366. border: 1px solid #e2e2e2;
  1367. border-radius: 4px;
  1368. font-size: 14px;
  1369. color: #545454;
  1370. background-color: rgba(255, 255, 255, 0.9);
  1371. padding: 10px 8px;
  1372. box-shadow: rgb(174, 174, 174) 0px 0px 10px;
  1373. text-align: justify;
  1374. text-justify: newspaper;
  1375. word-break: break-all;
  1376. }
  1377. .contextmenu__item {
  1378. display: block;
  1379. line-height: 34px;
  1380. text-align: center;
  1381. }
  1382. .contextmenu__item:not(:last-child) {
  1383. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  1384. }
  1385. .g6-component-contextmenu {
  1386. width: 150px;
  1387. }
  1388. .contextmenu__item:hover {
  1389. cursor: pointer;
  1390. background: #66b1ff;
  1391. border-color: #66b1ff;
  1392. color: #fff;
  1393. }
  1394. .tooltip-header{
  1395. padding:5px;
  1396. text-align: left;
  1397. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  1398. font-size: 14px;
  1399. }
  1400. .tooltip-content{
  1401. line-height:26px;
  1402. font-size: 14px;
  1403. padding:5px;
  1404. text-align: left;
  1405. }
  1406. `);
  1407. },
  1408. },
  1409. };
  1410. </script>
  1411. <style rel="stylesheet/scss" lang="scss" scoped>
  1412. .root {
  1413. width: 100%;
  1414. height: 100%;
  1415. left: 0;
  1416. top: 0;
  1417. right: 0;
  1418. bottom: 0;
  1419. position: absolute;
  1420. }
  1421. .minimap {
  1422. position: absolute;
  1423. top: 0;
  1424. left: 0;
  1425. z-index: 1;
  1426. border: 1px solid #994343;
  1427. background-color: #e0f0e9;
  1428. }
  1429. .container1 {
  1430. border: 1px solid #305d91;
  1431. height: 100%;
  1432. position: relative;
  1433. overflow: visible;
  1434. .top {
  1435. display: flex;
  1436. justify-content: space-between;
  1437. width: 100%;
  1438. height: 50px;
  1439. background-color: rgb(43, 104, 137);
  1440. padding: 0 20px;
  1441. display: flex;
  1442. align-items: center;
  1443. justify-content: space-between;
  1444. margin-bottom: 10px;
  1445. .cursor {
  1446. cursor: pointer;
  1447. font-size: 20px;
  1448. }
  1449. .el-button {
  1450. min-width: 70px;
  1451. }
  1452. }
  1453. .itemBox {
  1454. background-color: white;
  1455. padding: 15px;
  1456. font-size: 14px;
  1457. .form-item {
  1458. display: flex;
  1459. align-items: center;
  1460. justify-content: space-between;
  1461. ::v-deep {
  1462. .el-form-item {
  1463. padding-bottom: 10px !important;
  1464. }
  1465. }
  1466. }
  1467. span {
  1468. color: rgba(0, 0, 0, 0.65);
  1469. }
  1470. }
  1471. .dataInfoFootDiv {
  1472. text-align: center;
  1473. margin-bottom: 20px;
  1474. ::v-deep {
  1475. .el-button {
  1476. width: 100px;
  1477. margin-right: 30px;
  1478. }
  1479. }
  1480. }
  1481. .el-form-item {
  1482. margin-bottom: 10px;
  1483. }
  1484. .flex-box {
  1485. padding-bottom: 15px;
  1486. border-bottom: 1px solid rgba(151, 151, 151, 0.35);
  1487. .el-row {
  1488. display: flex;
  1489. align-items: center;
  1490. margin-bottom: 15px;
  1491. }
  1492. .el-col {
  1493. display: flex;
  1494. align-items: center;
  1495. }
  1496. .label {
  1497. margin-right: 5px;
  1498. }
  1499. .el-select,
  1500. .el-input,
  1501. .el-autocomplete,
  1502. .el-date-editor {
  1503. width: 80%;
  1504. }
  1505. }
  1506. .canvaBox {
  1507. height: 100%;
  1508. position: relative;
  1509. background: url(../../../../assets/img/img/filebg8.jpg) center bottom no-repeat;
  1510. background-size: 100% 100%;
  1511. }
  1512. .whr100 {
  1513. width: 100%;
  1514. height: 100%;
  1515. position: relative;
  1516. }
  1517. .mt10 {
  1518. margin-top: 10px;
  1519. }
  1520. }
  1521. ::v-deep {
  1522. .dataInfo-drawer-dialog {
  1523. :focus {
  1524. outline: 0;
  1525. }
  1526. .el-drawer__header {
  1527. border-bottom: 1px solid rgba(151, 151, 151, 0.35);
  1528. padding-bottom: 10px;
  1529. margin-bottom: 10px;
  1530. }
  1531. .el-drawer__body {
  1532. padding: 0 5px;
  1533. }
  1534. }
  1535. .el-progress-bar__outer,
  1536. .el-progress-bar__inner {
  1537. border-radius: 0;
  1538. }
  1539. .el-date-editor--daterange.el-input__inner {
  1540. width: 394px;
  1541. }
  1542. }
  1543. .uploader-example {
  1544. width: 880px;
  1545. padding: 15px;
  1546. margin: 40px auto 0;
  1547. font-size: 12px;
  1548. box-shadow: 0 0 10px rgba(0, 0, 0, .4);
  1549. }
  1550. .uploader-example .uploader-btn {
  1551. margin-right: 4px;
  1552. }
  1553. .uploader-example .uploader-list {
  1554. max-height: 440px;
  1555. overflow: auto;
  1556. overflow-x: hidden;
  1557. overflow-y: auto;
  1558. }
  1559. .crumb-nav {
  1560. position: absolute;
  1561. top: 20px;
  1562. left: 40px;
  1563. background: #73bf8f;
  1564. border-radius: 4px;
  1565. color: #fff;
  1566. margin-left: 500px;
  1567. }
  1568. .nav-text {
  1569. display: inline-block;
  1570. height: 36px;
  1571. line-height: 36px;
  1572. margin: 0 10px;
  1573. cursor: pointer;
  1574. }
  1575. .crumb-nav2 {
  1576. height: 36px;
  1577. line-height: 36px;
  1578. margin: 0 10px;
  1579. cursor: pointer;
  1580. margin-left: 800px;
  1581. }
  1582. .text {
  1583. margin-left: 550px;
  1584. font-size: 50px;
  1585. position: absolute;
  1586. top: 60px;
  1587. }
  1588. </style>