knowledgeUpdate.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. const $ = require("jquery");
  2. require("babel-polyfill");
  3. const echarts = require("echarts");
  4. require("./../css/knowledgeUpdate.less");
  5. require("./../css/common.less");
  6. // require("ztree");
  7. require('./../resources/images/icon.png');
  8. require('./../resources/images/iconOpen.png');
  9. require('./../resources/images/iconClose.png');
  10. require('./../resources/images/node.png');
  11. require('./../resources/images/radioUnSelect.png');
  12. require('./../resources/images/radioSelect.png');
  13. require('./../resources/images/iconSlideUp.png');
  14. require('./../resources/images/iconSlideDown.png');
  15. require('./../resources/images/iconSelect.png');
  16. require('./../resources/images/syflogo.png');
  17. require('./../resources/images/logo.png');
  18. require('./../resources/images/logo_shaoyifu.png');
  19. require('./../resources/zTree/js/jquery.ztree.core.min.js');
  20. require('./../resources/zTree/js/jquery.ztree.excheck.min.js')
  21. require('./../resources/zTree/css/zTreeStyle/zTreeStyle.css');
  22. const iconUp = require('./../resources/images/iconUp.png');
  23. const iconDown = require('./../resources/images/iconDown.png');
  24. const { post, api, ifHideLogo, getUrlArgObject } = require('./api.js');
  25. const { mapData, zTreeData, mapData3, zTreeData3 } = require('./data.js');
  26. const { drawGraph, updateTree, getGraph, getTree, getNode, getTab, renderTab, setTabBottomHei, expandProperty,
  27. setSelectName, hideHideTab, hideSlide, reDrawGraph } = require('./graphMap.js');
  28. /**右侧侧边栏折叠*/
  29. let isRightCollapse = false
  30. window.select_type = "疾病";
  31. window.select_type_noSearch = "疾病";
  32. window.refreshTree = true
  33. let disease = getUrlArgObject("disease")
  34. // 用来存储节点操作的数据
  35. window.knowledgeMapData = {}//当前右键节点数据
  36. window.graphMapUpdatedData = null //实时更新的关系图数据
  37. window.graphMap = null //当前关系图实例对象
  38. window.knowledgeMapSetting = {
  39. operation: "edit", //操作类型,修改
  40. draggable: true, //是否能拖拽节点
  41. zTree: false,//是否有zTree
  42. expandPropertyId: [],//存储展开属性的nodeId
  43. expandRelationshipsId: [],//存储展开关系的nodeId
  44. currentNodeId: -1,//存储右侧显示的节点的nodeId
  45. legends: [],//图例
  46. selected: {},//选中的数据
  47. showLegend: true, //是否显示图例
  48. showLegendNum: 0,//展示图例的数量
  49. showLegendAll: false,//是否展示全部图例
  50. records: [],//历史记录
  51. }
  52. setHei()
  53. ifHideLogo();
  54. function setHei() {
  55. const clientHei = $(window).height()
  56. const contentHei = 580
  57. $(".left").css("height", contentHei + 'px')
  58. $(".right").css("height", contentHei + 'px')
  59. if (select_type == "疾病") {
  60. setTabBottomHei(1)
  61. } else {
  62. setTabBottomHei(2)
  63. }
  64. $("#main").css("height", contentHei - 20 - 20 - 10 + 'px')
  65. }
  66. $(window).resize(function () {
  67. setHei()
  68. // getGraph(graphTxt,select_type);
  69. })
  70. //关系图
  71. getGraph(disease || "艾滋病", select_type, true);
  72. // getTree(1, 1, disease || "艾滋病");
  73. $('#searchInp').val(disease || "艾滋病")
  74. //选择类型
  75. $('.select').click(function (e) {
  76. e.stopPropagation();
  77. hideSlide('selectList')
  78. const selectListShow = $('.selectList').css('display')
  79. if (selectListShow == 'none') {
  80. $('.iconSlide').attr('src', './images/iconSlideUp.png')
  81. } else {
  82. $('.iconSlide').attr('src', './images/iconSlideDown.png')
  83. }
  84. $('.selectList').fadeToggle()
  85. })
  86. $('.search-type .selectList .selectItem').click(function () {
  87. select_type_noSearch = $(this).attr('data-id')
  88. const txt = $(this).text()
  89. const oldTxt = $(".selectedName").html()
  90. setSelectName(txt)
  91. $("#searchInp").attr("placeholder", `请输入${txt}名称`)
  92. if (txt != oldTxt) {
  93. $('#searchInp').val("")
  94. }
  95. })
  96. $('.dropdown').on('click', function (el) {
  97. el.stopPropagation();
  98. // hideSlide()
  99. $(".dropdown").not($(this)).find(".selectList").slideUp()
  100. $(this).find(".selectList").slideToggle()
  101. })
  102. $(".record .selectedData,.record").on("click", function (event) {
  103. // console.log("event-record", event)
  104. event.stopPropagation()
  105. // event.preventDefault()
  106. $(".record .selectList-record").slideToggle()
  107. $(".record .selectList-record .selectItem-record").on("click", function (event) {
  108. // event.stopPropagation()
  109. // console.log("eve")
  110. const name = $(this).attr("name")
  111. const label = $(this).attr("label")
  112. // reDrawGraph(name, label)
  113. getGraph(name, label)
  114. // $(".record .selectList-record").slideUp()
  115. })
  116. })
  117. //搜索节点名
  118. $("#searchInp").bind("input propertychange", function (event) {
  119. const val = $("#searchInp").val().trim()
  120. if (val) {
  121. getNode(val, select_type_noSearch)
  122. } else {
  123. $(".tabNameList").hide()
  124. }
  125. });
  126. //切换条目
  127. $('.radioItem').click(function (e) {
  128. const initDiag = disease || "艾滋病"
  129. const type = $(this).attr('data-type')
  130. // $(this).children('img').attr('src')
  131. $('.iconRadio').attr('src', '/images/radioUnSelect.png')
  132. $(this).children('img').attr('src', '/images/radioSelect.png')
  133. $('#searchInp').val(initDiag)
  134. getTree(type, 1, initDiag);
  135. getGraph(initDiag, select_type);
  136. // updateTree(initDiag)
  137. })
  138. //搜索
  139. $('#searchBtn').click(function (e) {
  140. e.stopPropagation()
  141. hideSlide()
  142. const val = $('#searchInp').val().trim()
  143. if (val) {
  144. const clientHei = $(window).height()
  145. const contentHei = clientHei - 80
  146. $(".tabNameList").hide()
  147. getGraph(val, select_type_noSearch).then(() => {
  148. if (!window.refreshTree) {
  149. return
  150. }
  151. select_type = select_type_noSearch
  152. if (select_type == '疾病') {
  153. // $('#searchInp').val("高血压3级")
  154. getTree(1, 1, val);
  155. } else if (select_type == '药品通用名') {
  156. getTree(0, 2, val);
  157. } else if (select_type == '症状') {
  158. getTree(0, 3, val);
  159. }
  160. // else if (select_type == '手术和操作') {
  161. // getTree(0, 4, val);
  162. // }
  163. else if (select_type == '实验室检查') {
  164. getTree(0, 5, val);
  165. } else if (select_type == '辅助检查') {
  166. getTree(0, 6, val);
  167. }
  168. if (select_type == '疾病') {
  169. $('.iconRadio').attr('src', '/images/radioUnSelect.png')
  170. $('.ICD10 img').attr('src', '/images/radioSelect.png')
  171. $(".radioList").show()
  172. setTabBottomHei(1)
  173. } else {
  174. $(".radioList").hide()
  175. setTabBottomHei(2)
  176. }
  177. let renderTabInfo = getTab(select_type)
  178. renderTab(renderTabInfo)
  179. })
  180. } else {
  181. $('.tabNameListNoSearch').show()
  182. }
  183. })
  184. let renderTabInfo = getTab("疾病")
  185. renderTab(renderTabInfo)
  186. $(".tabList").click(function (e) {
  187. e.stopPropagation()
  188. hideSlide()
  189. })
  190. $(".hideTabList").click(function (e) {
  191. e.stopPropagation()
  192. hideSlide()
  193. })
  194. //点击页面其他地方关闭下拉
  195. $('html').click(function () {
  196. hideSlide()
  197. // const selectListShow = $('.selectList').css('display')
  198. // const tabNameListShow = $('.tabNameList').css('display')
  199. // const tabNameListNoSearchShow = $('.tabNameListNoSearch').css('display')
  200. // const hideTabListShow = $('.hideTabList').css('display')
  201. // if(selectListShow == 'block'){
  202. // $('.selectList').hide()
  203. // $('.iconSlide').attr('src','./images/iconSlideDown.png')
  204. // }
  205. // if(tabNameListShow == 'block'){
  206. // $('.tabNameList').hide()
  207. // }
  208. // if(tabNameListNoSearchShow == 'block'){
  209. // $('.tabNameListNoSearch').hide()
  210. // }
  211. // if(hideTabListShow == 'block'){
  212. // hideHideTab()
  213. // }
  214. })
  215. let toggleTabHtml = ""
  216. $(".right-aside-collapse").on("click", function () {
  217. isRightCollapse = !isRightCollapse
  218. if (isRightCollapse) {
  219. toggleTabHtml = $("#tabList > .toggleTab").html()
  220. $("#tabList > .toggleTab").empty()
  221. // document.querySelector('.toggleTab').style.display = 'none';
  222. $(".right").animate({ "width": '110px' }, function () {
  223. })
  224. const contentWidth = $(".content").width()
  225. const leftWidth = (contentWidth - 110).toString() + 'px'
  226. // console.log("contentWidth", leftWidth);
  227. $(".content .left").animate({ 'width': leftWidth, }, function () {
  228. window.graphMap.resize()
  229. // console.log("graphMap", window.graphMap)
  230. })
  231. } else {
  232. $("#tabList > .toggleTab").html(toggleTabHtml)
  233. $(".right").animate({ "width": '394px' })
  234. const contentWidth = $(".content").width()
  235. const leftWidth = (contentWidth - 394).toString() + 'px'
  236. $(".content .left").animate({ 'width': leftWidth, }, function () {
  237. window.graphMap.resize()
  238. // console.log("graphMap", window.graphMap)
  239. })
  240. }
  241. })
  242. // 接收来自home.html的数据
  243. window.addEventListener("message", function (event) {
  244. // console.log("message", event.data);
  245. if (event.data.operation == "left-collapse") {
  246. const contentWidth = $(".content").width()
  247. // console.log("contentWidth", contentWidth)
  248. let leftWidth = 0
  249. if (isRightCollapse) {
  250. leftWidth = (contentWidth - 110).toString() + 'px'
  251. $(".content .left").css('width', leftWidth)
  252. } else {
  253. leftWidth = (contentWidth - 394).toString() + 'px'
  254. $(".content .left").css('width', leftWidth)
  255. }
  256. // console.log("leftWidth", leftWidth);
  257. window.graphMap.resize()
  258. }
  259. if (event.data.operation === 'update-graph') { //重新绘制关系图
  260. reDrawGraph()
  261. }
  262. })
  263. $("div[class*='contextmenu']").on("contextmenu", function (event) {
  264. event.preventDefault()
  265. })
  266. $("div[class*='contextmenu'] .contextmenu-item").on("click", function () {
  267. const opType = $(this).attr("data-id")
  268. const title = $(this).attr("title")
  269. const showFooter = true
  270. const dialogVisible = true
  271. const data = {
  272. opType, title, data: window.knowledgeMapData, showFooter, dialogVisible
  273. }
  274. menuOperation(opType, data)
  275. })
  276. $(".dropdown[select='off'] .selectList .selectItem").on("click", function () {
  277. const opType = $(this).attr("data-id")
  278. const title = $(this).attr("title")
  279. const showFooter = true
  280. const dialogVisible = true
  281. const data = {
  282. opType, title, showFooter, dialogVisible, data: {}
  283. }
  284. menuOperation(opType, data)
  285. })
  286. // 自定义的菜单和部分下拉框的操作
  287. function menuOperation(opType, data) {
  288. data.width = ""
  289. // console.log("menuOperationData", data);
  290. let selectedName = ""
  291. let searchInp = ""
  292. const parentURL = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/home.html";
  293. switch (opType) {
  294. case 'expandProperty': //展开属性
  295. expandProperty(data.data, true)
  296. break
  297. case 'modifyEntityName-dropdown':
  298. selectedName = $(".selectedName").html().trim()
  299. searchInp = $("#searchInp").val().trim()
  300. // console.log("modifyEntityName-dropdown", selectedName, searchInp);
  301. data.data = { selectedName, searchInp }
  302. window.parent.postMessage(data, parentURL);
  303. break
  304. case 'deleteEntity-dropdown':
  305. selectedName = $(".selectedName").html().trim()
  306. searchInp = $("#searchInp").val().trim()
  307. // console.log("modifyEntityName-dropdown", selectedName, searchInp);
  308. data.data = { selectedName, searchInp }
  309. window.parent.postMessage(data, parentURL);
  310. break
  311. case 'deleteRelationship':
  312. let endId = 0
  313. let endLabel = "string"
  314. let property = {}
  315. let relationshipType = "string"
  316. let startId = 0
  317. let startLabel = "string"
  318. window.graphMapUpdatedData.node.forEach((element, index) => {
  319. if (index == data.data.target) {
  320. endId = element.nodeId
  321. }
  322. });
  323. window.parent.postMessage(data, parentURL);
  324. break
  325. case "modifyRelationshipName-dropdown":
  326. data.showFooter = false
  327. window.parent.postMessage(data, parentURL);
  328. break
  329. case "modifyProperty-dropdown":
  330. data.showFooter = false
  331. window.parent.postMessage(data, parentURL);
  332. break
  333. case "expandRelationships": //右键展开关系
  334. if (data.data.name === 0 || data.data.expanded) return;
  335. post(api.getGraph, {
  336. "inputStr": data.data.properties.name,
  337. "labelName": data.data.type
  338. }).then(res => {
  339. const { code, msg } = res.data
  340. const nodeLength = window.graphMapUpdatedData.node.length
  341. // let selected = {}
  342. if (code === '0') {
  343. res.data.data.node.forEach(node => {
  344. if (!node.itemStyle.display && node.label && node.symbol == 'circle') {
  345. node.symbol = 'pin'
  346. }
  347. });
  348. const newNodeData = res.data.data
  349. //添加新的类
  350. // 判断有没有新添加的类型
  351. for (let i = 2; i < newNodeData.categories.length; i++) {
  352. let isCategory = false
  353. for (let j = 0; j < window.graphMapUpdatedData.categories.length; j++) {
  354. if (newNodeData.categories[i].name === window.graphMapUpdatedData.categories[j].name) {
  355. isCategory = true
  356. break
  357. }
  358. }
  359. if (!isCategory) {
  360. window.graphMapUpdatedData.categories.push(newNodeData.categories[i])
  361. window.knowledgeMapSetting.legends.push(newNodeData.categories[i])
  362. window.knowledgeMapSetting.selected[newNodeData.categories[i].name] = true
  363. }
  364. }
  365. newNodeData.node.forEach((node, index) => {
  366. let nodeIndex = -1
  367. if (index === 0) {
  368. nodeIndex = data.data.name
  369. //标志该节点已经展开过
  370. window.graphMapUpdatedData.node[nodeIndex].expanded = true
  371. } else {
  372. nodeIndex = nodeLength + index - 1
  373. node.name = nodeIndex
  374. for (let i = 0; i < window.graphMapUpdatedData.categories.length; i++) {
  375. if (newNodeData.categories[node.category].name === window.graphMapUpdatedData.categories[i].name) {
  376. // console.log(newNodeData.categories[node.category].name, window.graphMapUpdatedData.categories[i].name, i)
  377. node.category = i
  378. break
  379. }
  380. }
  381. window.graphMapUpdatedData.node.push(node)
  382. }
  383. })
  384. newNodeData.links.forEach(link => {
  385. if (link.source === 0) {
  386. link.source = data.data.name
  387. } else {
  388. link.source += (nodeLength - 1)
  389. }
  390. if (link.target === 0) {
  391. link.target = data.data.name
  392. } else {
  393. link.target += (nodeLength - 1)
  394. }
  395. })
  396. window.graphMapUpdatedData.links = window.graphMapUpdatedData.links.concat(newNodeData.links)
  397. // window.graphMapUpdatedData.links = [...window.graphMapUpdatedData.links, ...newNodeData.links]
  398. let legendData = null
  399. //重新计算showLegendNum
  400. reShowLegendNum()
  401. if (window.knowledgeMapSetting.showLegendAll) {
  402. legendData = window.knowledgeMapSetting.legends.map(el => el.name)
  403. } else {
  404. legendData = window.knowledgeMapSetting.legends.slice(0, window.knowledgeMapSetting.showLegendNum).map(el => el.name)
  405. }
  406. reNodeCloseAndExpand()
  407. window.graphMap.setOption({
  408. legend: [{
  409. selected: window.knowledgeMapSetting.selected,
  410. data: legendData,
  411. }],
  412. series: [{
  413. type: 'graph',
  414. categories: window.graphMapUpdatedData.categories,
  415. data: window.graphMapUpdatedData.node, // 更新节点数据
  416. links: window.graphMapUpdatedData.links, // 更新边数据
  417. }]
  418. }, false); // 仅更新指定的部分,不重绘图表
  419. }
  420. }).catch(err => {
  421. })
  422. break
  423. case "addRelationship-dropdown":
  424. window.parent.postMessage(data, parentURL);
  425. break
  426. case "closeAll":
  427. nodeAllCloseAndExpand(false)
  428. break
  429. case "expandAll":
  430. nodeAllCloseAndExpand(true)
  431. break
  432. default:
  433. window.parent.postMessage(data, parentURL);
  434. }
  435. }
  436. // 节点全部关闭和展开,flag为true代表全部展开,为false是全部关闭
  437. function nodeAllCloseAndExpand(flag) {
  438. let selected = window.knowledgeMapSetting.selected
  439. for (let key in selected) {
  440. if (key !== "中心词" && key !== "关系") {
  441. selected[key] = flag
  442. let targetIndex = -1
  443. let sourceIndex = -1
  444. let linkIndex = -1
  445. // 找到需要隐藏的节点
  446. for (let index = 0; index < window.graphMapUpdatedData.links.length; index++) {
  447. if (window.graphMapUpdatedData.links[index].value === key) {
  448. targetIndex = window.graphMapUpdatedData.links[index].target
  449. sourceIndex = window.graphMapUpdatedData.links[index].source
  450. linkIndex = index
  451. if (selected[key]) {
  452. window.graphMapUpdatedData.links[linkIndex].lineStyle = { opacity: 1 }
  453. window.graphMapUpdatedData.node[targetIndex].itemStyle = { opacity: 1 }
  454. window.graphMapUpdatedData.links[linkIndex].hideLabel = false
  455. } else {
  456. window.graphMapUpdatedData.links[linkIndex].lineStyle = { opacity: 0 }
  457. window.graphMapUpdatedData.links[linkIndex].hideLabel = true
  458. window.graphMapUpdatedData.node[targetIndex].itemStyle = { opacity: 0 }
  459. }
  460. targetIndex = -1
  461. sourceIndex = -1
  462. linkIndex = -1
  463. // break
  464. }
  465. }
  466. // console.log("key", key, "linkIndex", linkIndex)
  467. // if (!(linkIndex >= 0)) continue;
  468. }
  469. }
  470. window.graphMap.setOption({
  471. legend: [{ selected: selected, }],
  472. series: [{
  473. edgeLabel: {
  474. show: true,
  475. formatter: function (x) {
  476. if (x.data.hideLabel) {
  477. return " ";
  478. }
  479. else {
  480. return x.data.value; //横线关系
  481. }
  482. },
  483. },
  484. type: 'graph',
  485. data: window.graphMapUpdatedData.node, // 更新节点数据
  486. links: window.graphMapUpdatedData.links, // 更新边数据
  487. }]
  488. }, false); //
  489. }
  490. //重新隐藏之前的节点
  491. function reNodeCloseAndExpand() {
  492. let selected = window.knowledgeMapSetting.selected
  493. //隐藏(透明化)虚拟节点
  494. for (let name in selected) {
  495. // const name = obj.name
  496. let targetIndex = -1
  497. let sourceIndex = -1
  498. let linkIndex = -1
  499. for (let index = 0; index < window.graphMapUpdatedData.links.length; index++) {
  500. if (window.graphMapUpdatedData.links[index].value === name) {
  501. targetIndex = window.graphMapUpdatedData.links[index].target
  502. sourceIndex = window.graphMapUpdatedData.links[index].source
  503. linkIndex = index
  504. if (selected[name]) {
  505. window.graphMapUpdatedData.links[linkIndex].lineStyle = { opacity: 1 }
  506. window.graphMapUpdatedData.node[targetIndex].itemStyle = { opacity: 1 }
  507. window.graphMapUpdatedData.links[linkIndex].hideLabel = false
  508. } else {
  509. window.graphMapUpdatedData.links[linkIndex].lineStyle = { opacity: 0 }
  510. window.graphMapUpdatedData.links[linkIndex].hideLabel = true
  511. window.graphMapUpdatedData.node[targetIndex].itemStyle = { opacity: 0 }
  512. }
  513. targetIndex = -1
  514. sourceIndex = -1
  515. linkIndex = -1
  516. }
  517. }
  518. }
  519. }
  520. function reShowLegendNum() {
  521. window.knowledgeMapSetting.showLegendNum = 0;
  522. let sum = 0
  523. for (let i = 0; i < window.knowledgeMapSetting.legends.length; i++) {
  524. sum += 2 + window.knowledgeMapSetting.legends[i].name.length + 1
  525. if (sum <= 60) {
  526. window.knowledgeMapSetting.showLegendNum++
  527. }
  528. }
  529. if (window.knowledgeMapSetting.legends.length > window.knowledgeMapSetting.showLegendNum) {
  530. $('.legendSlideUp').toggleClass('legendSlideUp')
  531. $('.legendIcon').css('display', "block")
  532. } else {
  533. $('.legendSlideUp').toggleClass('legendSlideUp')
  534. $('.legendIcon').css('display', "none")
  535. }
  536. $(".category-num").html(`${window.knowledgeMapSetting.legends.length}`)
  537. }
  538. $(document).on("click", ".content .right .entity-node .box-content .text .select-sign span", function () {
  539. // $(this).attr("class", "icon-rect-select")
  540. if ($(this).hasClass("icon-rect-select")) {
  541. $(this).attr("class", "icon-rect-selected")
  542. // console.log("icon-rect-select")
  543. } else {
  544. $(this).attr("class", "icon-rect-select")
  545. // console.log("icon-rect-selected")
  546. }
  547. })
  548. // 右侧实体删除
  549. $(document).on("click", ".content .right .entity-node .delete-entity", function () {
  550. if (confirm("确定要删除选中的实体吗?")) {
  551. const entityNodeId = []
  552. $(".content .right .entity-node .box-content .text").each(function (textIndex, textElement) {
  553. if ($(textElement).find(".select-sign span").is(".icon-rect-selected")) {
  554. entityNodeId.push(Number($(textElement).attr("nodeId")))
  555. // $(textElement).remove()
  556. }
  557. })
  558. post(api.deleteEntity, entityNodeId).then(res => {
  559. const { data, code, msg } = res.data
  560. if (code == '0') {
  561. reDrawGraph()
  562. }
  563. }).catch(err => {
  564. console.log("deleteEntity接口报错", err)
  565. })
  566. // console.log("entityNodeId", entityNodeId)
  567. }
  568. })
  569. // 右侧实体合并
  570. $(document).on("click", ".content .right .entity-node .merge-entity", function () {
  571. const entityNode = []
  572. $(".content .right .entity-node .box-content .text").each(function (textIndex, textElement) {
  573. if ($(textElement).find(".select-sign span").is(".icon-rect-selected")) {
  574. entityNode.push(window.graphMapUpdatedData.node[Number($(textElement).attr("nodeIndex"))])
  575. // $(textElement).remove()
  576. }
  577. })
  578. if (entityNode.length !== 2) {
  579. alert("实体合并只能选择两个")
  580. } else if (entityNode[0].type !== entityNode[1].type) {
  581. alert("合并的两个实体需要类型相同")
  582. }
  583. else {
  584. const entityVO = {
  585. "firstId": entityNode[0].nodeId,
  586. "firstLabel": entityNode[0].type,
  587. "firstName": entityNode[0].properties.name,
  588. "newLabel": entityNode[0].type,
  589. "newName": "",
  590. "secondId": entityNode[1].nodeId,
  591. "secondLabel": entityNode[1].type,
  592. "secondName": entityNode[1].properties.name
  593. }
  594. const data = {
  595. opType: "merge-entity",
  596. showFooter: true,
  597. dialogVisible: true,
  598. data: entityVO,
  599. title: "实体合并提示",
  600. }
  601. // console.log("entityVO", entityVO)
  602. menuOperation(data.opType, data)
  603. }
  604. })
  605. $(document).on("click", ".link-entity", function () {
  606. const entityNode = []
  607. $(".content .right .entity-node .box-content .text").each(function (textIndex, textElement) {
  608. if ($(textElement).find(".select-sign span").is(".icon-rect-selected")) {
  609. entityNode.push(window.graphMapUpdatedData.node[Number($(textElement).attr("nodeIndex"))])
  610. // $(textElement).remove()
  611. }
  612. })
  613. // console.log("entityNode", entityNode)
  614. const data = {
  615. opType: "entityLink",
  616. showFooter: true,
  617. dialogVisible: true,
  618. data: {
  619. categories: window.graphMapUpdatedData.categories,
  620. entityNode: entityNode,
  621. },
  622. title: "实体链接提示",
  623. }
  624. menuOperation(data.opType, data)
  625. })
  626. module.exports = {
  627. getTab,
  628. renderTab
  629. }