manager.vue.bak 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div style="height: 100%">
  3. <div
  4. class="panel"
  5. style="padding:0;height: 50px;margin-bottom: 5px;line-height: 50px;"
  6. >
  7. <a-form
  8. style="display: inline-block;margin-right: 5px;margin-left: 10px;"
  9. v-if="$route.path.indexOf('entity_v2') > -1"
  10. >
  11. <a-form-item>
  12. <a-input
  13. placeholder="请输入实体名称"
  14. v-model="searchValue"
  15. style="width: 280px;margin-right: 10px"
  16. />
  17. <button class="ant-btn ant-btn-primary mr-5" @click="handleSearch">
  18. 查询实体名称
  19. </button>
  20. <button class="ant-btn ant-btn-primary" @click="clearSearch">
  21. 清空查询
  22. </button>
  23. </a-form-item>
  24. </a-form>
  25. <a-row style="display: inline-block">
  26. <a-button
  27. style="margin-right: 5px;margin-left: 10px;"
  28. type="primary"
  29. @click="entClsImport"
  30. v-if="editable && OWL_IMPORT"
  31. >
  32. <a-icon type="upload" />实体类导入
  33. </a-button>
  34. <!-- <a-button style="margin-right: 5px" type="primary" @click="entClsExportModal" v-if="editable && OWL_EXPORT">
  35. <a-icon type="export" />实体类导出
  36. </a-button> -->
  37. <a-button
  38. style="margin-right: 5px"
  39. type="primary"
  40. v-if="editable && ENTCLS_GRAPH_VIEW"
  41. @click="entClsChart"
  42. >
  43. <a-icon type="dot-chart" />
  44. 实体类可视化
  45. </a-button>
  46. <a-button
  47. style="margin-right: 5px"
  48. type="primary"
  49. @click="entImportModal"
  50. v-if="!editable && BF_ENT_IMPORT"
  51. >
  52. <a-icon type="upload" />集成访问服务导入
  53. </a-button>
  54. <a-button
  55. type="primary"
  56. @click="entExportModal"
  57. v-if="!editable && BF_ENT_EXPORT"
  58. >
  59. <a-icon type="export" />集成访问服务导出
  60. </a-button>
  61. </a-row>
  62. </div>
  63. <div
  64. class="flex-row"
  65. :style="{
  66. height:
  67. $route.path.indexOf('entity_v2') > -1 ? 'calc(100% - 60px)' : '100%',
  68. }"
  69. >
  70. <div id="leftPanel" class="flex-col" style="overflow-y: hidden">
  71. <div class="flex1 flex-col panel">
  72. <b class="panel-header">
  73. <a-icon type="deployment-unit" />&nbsp;实体类
  74. </b>
  75. <a-spin
  76. tip="Loading..."
  77. :spinning="spinning"
  78. class="select-input flex1"
  79. >
  80. <ent-cls-list
  81. :searchResult="searchResult"
  82. :searchValue="searchValue"
  83. @emitId="getEntClsId"
  84. :activeId="$route.params.classId"
  85. v-if="
  86. $route.path.indexOf('entity') > -1 && searchResult.length > 0
  87. "
  88. ></ent-cls-list>
  89. </a-spin>
  90. <z-tree
  91. class="select-input flex1"
  92. :editable="editable"
  93. style="margin-top:10px;"
  94. v-if="searchResult.length == 0 && spinning == false"
  95. @nodeSelected="entityClassNodeSelected"
  96. @getAllRootList="entClsRootList"
  97. ></z-tree>
  98. <!--<keep-alive include="ent-cls-ztree">-->
  99. <!--<router-view class="select-input flex1" name="treeList" :editable="editable"-->
  100. <!--@nodeSelected="entityClassNodeSelected" @getAllRootList="entClsRootList"-->
  101. <!--:key="treeKey1"/>-->
  102. <!--</keep-alive>-->
  103. </div>
  104. <router-view
  105. v-if="$route.path.indexOf('entity_v2') === -1"
  106. class="flex1 panel"
  107. name="entityList"
  108. :key="treeKey"
  109. />
  110. </div>
  111. <router-view
  112. id="rightPanel"
  113. name="main"
  114. class="flex1 panel flex-col"
  115. :key="key"
  116. :seaValue="searchValue"
  117. :activeId="$route.params.classId"
  118. />
  119. </div>
  120. </div>
  121. </template>
  122. <script>
  123. import ClassTree from "@/views/knowledge/graphClass/entityClassTree";
  124. import zTree from "@/views/knowledge/graphClass/entityClassZtree";
  125. import entClsList from "@/views/knowledge/graphClass/entClsList";
  126. import { searchEntClsByEntName } from "@/api/graph/entity"
  127. import { getEntityClass } from "@/api/graph/entityClass"
  128. const isTemplateVersion = true;
  129. export default {
  130. name: "manager",
  131. components: {
  132. ClassTree,
  133. zTree,
  134. entClsList,
  135. },
  136. data() {
  137. return {
  138. // 功能权限控制
  139. OWL_IMPORT: true,
  140. OWL_EXPORT: true,
  141. ENTCLS_GRAPH_VIEW: true,
  142. BF_ENT_IMPORT: true,
  143. BF_ENT_EXPORT: true,
  144. baseUrl: window.global.baseUrl(),
  145. searchValue: "", // 搜索的实体名称字符串
  146. searchResult: [],
  147. spinning: false,
  148. rootEntClsList: [], // 根节点实体类列表
  149. editable: true, // 判断左侧树是否显示操作按钮
  150. };
  151. },
  152. events: {
  153. /**
  154. * 新建实体类成功,打开新建的实体类
  155. * @param classId 实体类id
  156. */
  157. ["entityClass:nodeCreated"](classId) {
  158. this.entityClassNodeSelected({
  159. entClsID: classId,
  160. });
  161. // this.$router.push({name: 'ECM_item', params: {classId}})
  162. },
  163. /**
  164. * 删除实体类成功,关闭打开的实体类
  165. * @param classId 实体类id
  166. */
  167. ["entityClass:nodeDestroyed"](classId) {
  168. if (this.$route.params.classId === classId) {
  169. this.$router.push({ name: "ECM_home" });
  170. }
  171. },
  172. /**
  173. * 新建实体成功,打开新建的实体
  174. * @param entityId 实体类id
  175. */
  176. ["entity:nodeCreated"](entityId) {
  177. this.$router.push({ name: "e_base", params: { entityId } });
  178. },
  179. /**
  180. * 删除实体成功,关闭打开的实体
  181. * @param entityId 实体类id
  182. */
  183. ["entity:nodeDestroyed"](entityId) {
  184. if (this.$route.params.entityId === entityId) {
  185. this.$router.push({ name: "class_entity" });
  186. }
  187. },
  188. /**
  189. * 新建实体成功,打开新建的实体类
  190. * @param relationId 关系类id
  191. */
  192. ["relationClass:nodeCreated"](relationId) {
  193. this.$router.push({ name: "relation_edit", params: { relationId } });
  194. },
  195. /**
  196. * 删除关系类成功,关闭打开的关系类
  197. * @param relationId 关系类id
  198. */
  199. ["relationClass:nodeDestroyed"](relationId) {
  200. if (this.$route.params.relationId === relationId) {
  201. this.$router.push({ name: "relation" });
  202. }
  203. },
  204. /**
  205. * 清空搜索,让左侧树恢复
  206. */
  207. ["entityClass:clearSearch"]() {
  208. this.searchValue = "";
  209. this.searchResult = [];
  210. this.spinning = false
  211. },
  212. },
  213. mounted() {
  214. // 获取用户功能权限
  215. // if (this.$const.authorityControl) {
  216. // this.OWL_IMPORT = !!this.authMap["OWL_IMPORT"];
  217. // this.OWL_EXPORT = !!this.authMap["OWL_EXPORT"];
  218. // this.ENTCLS_GRAPH_VIEW = !!this.authMap["ENTCLS_GRAPH_VIEW"];
  219. // this.BF_ENT_IMPORT = !!this.authMap["BF_ENT_IMPORT"];
  220. // this.BF_ENT_EXPORT = !!this.authMap["BF_ENT_EXPORT"];
  221. // }
  222. const searchValue = this.$route.query.searchValue;
  223. if (typeof searchValue !== "undefined") {
  224. this.searchValue = searchValue
  225. this.handleSearch()
  226. }
  227. },
  228. methods: {
  229. getEntClsId(id) {
  230. const vm = this;
  231. if (vm.$route.path.indexOf("entity_v2") > -1) {
  232. vm.$router.push({
  233. name: "class_entity_v2",
  234. params: { classId: id },
  235. query: {
  236. searchValue: vm.searchValue,
  237. },
  238. });
  239. } else {
  240. vm.$router.push({
  241. name: "class_entity",
  242. params: { classId: id, entClsName: vm.searchValue },
  243. });
  244. }
  245. },
  246. // 清空搜索
  247. clearSearch() {
  248. this.searchValue = "";
  249. this.searchResult = [];
  250. this.$router.push({ path: "/mng/class/unknow/entity_v2" });
  251. },
  252. // 搜索
  253. handleSearch() {
  254. if (this.searchValue === "") {
  255. this.$message.error("请输入要搜索的实体名称");
  256. return;
  257. }
  258. this.spinning = true;
  259. // this.$router.push({path: '/mng/class/unknow/entity_v2'})
  260. searchEntClsByEntName(this.searchValue).then((res) => {
  261. let item = { entClsID: "uknow", entClsName: "全部" };
  262. res.unshift(item);
  263. this.searchResult = res;
  264. this.spinning = false;
  265. });
  266. },
  267. // 要导出的根节点实体类列表
  268. entClsRootList(list) {
  269. this.rootEntClsList = list;
  270. },
  271. entityClassNodeSelected(node) {
  272. if (this.$route.path.indexOf("entity") === -1) {
  273. // 实体类大标题下跳转
  274. getEntityClass(node.entClsID).then((data) => {
  275. if (
  276. data.entClsAllowAttrType &&
  277. data.entClsAllowAttrType.includes("ELEM")
  278. ) {
  279. this.$router.push({
  280. name: "base",
  281. params: { classId: node.entClsID },
  282. }); // 有基础属性跳到基础属性
  283. } else {
  284. this.$router.push({
  285. name: "relation",
  286. params: { classId: node.entClsID },
  287. }); // 否则调到关系属性
  288. }
  289. });
  290. } else {
  291. // 实体大标题下跳转
  292. if (this.$route.path.indexOf("entity_v2") > -1) {
  293. if (isTemplateVersion) {
  294. // 如果是带实体模板的版本
  295. this.$router.push({
  296. name: "class_entity_v2",
  297. params: { classId: node.entClsID },
  298. query: { clsName: node.name },
  299. });
  300. } else {
  301. this.$router.push({
  302. name: "class_entity_v2",
  303. params: { classId: node.entClsID },
  304. });
  305. }
  306. } else {
  307. this.$router.push({
  308. name: "class_entity",
  309. params: { classId: node.entClsID },
  310. });
  311. }
  312. }
  313. },
  314. /**
  315. * 导入模态框
  316. */
  317. entClsImport() {
  318. this.$open("entClsImportModal", {}, function() {
  319. // 刷新左侧树
  320. this.$router.push("/mng/class");
  321. });
  322. },
  323. entClsChart() {
  324. this.$router.push("/sta/entity_class_view");
  325. },
  326. /**
  327. * 导出模态框
  328. */
  329. entClsExportModal() {
  330. this.$open(
  331. "entClsExportModal",
  332. {
  333. rootEntClsList: this.rootEntClsList, // 根节点实体类列表
  334. },
  335. function() {}
  336. );
  337. },
  338. // 实体导入
  339. entImportModal() {
  340. this.$open("uploadZipServiceModal", {});
  341. },
  342. // 实体导出
  343. entExportModal() {
  344. this.$open("entClsServiceExportModal", {});
  345. },
  346. },
  347. beforeCreate() {
  348. if (this.$route.name === "manager") {
  349. this.$router.push("/mng/class");
  350. }
  351. },
  352. beforeRouteUpdate(to, from, next) {
  353. const path = to.path;
  354. if (path.indexOf("entity") > -1) {
  355. this.editable = false;
  356. } else {
  357. this.editable = true;
  358. this.searchResult.length = 0;
  359. this.searchValue = "";
  360. this.spinning = false;
  361. }
  362. next();
  363. },
  364. beforeRouteEnter(to, from, next) {
  365. next((vm) => {
  366. const path = vm.$route.path;
  367. if (path.indexOf("entity") > -1) {
  368. vm.editable = false;
  369. } else {
  370. vm.editable = true;
  371. }
  372. });
  373. },
  374. computed: {
  375. treeKey1() {
  376. var key =
  377. this.$route.path + this.$route.params ? this.$route.params.classId : "";
  378. return key;
  379. },
  380. treeKey() {
  381. var key =
  382. this.$route.path + this.$route.params ? this.$route.params.classId : "";
  383. return key;
  384. },
  385. key() {
  386. var key =
  387. this.$route.path + this.$route.params
  388. ? this.$route.params.classId + this.$route.params.entityId
  389. : "";
  390. return key;
  391. },
  392. },
  393. };
  394. </script>
  395. <style scoped>
  396. .rela-box {
  397. display: block;
  398. width: 230px;
  399. overflow: hidden;
  400. text-overflow: ellipsis;
  401. white-space: nowrap;
  402. }
  403. #leftPanel {
  404. height: 100%;
  405. min-width: 300px;
  406. overflow: auto;
  407. }
  408. </style>