GraphSpaceManage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div>
  3. <div class="menu-title">
  4. 图谱管理
  5. </div>
  6. <div class="menu-content">
  7. <div>
  8. <el-form :inline="true" :model="qo" class="demo-form-inline">
  9. <el-form-item label="图谱名称:">
  10. <el-input v-model="qo.LIKES_name" placeholder="请输入图谱名称" style="width: 300px"></el-input>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="qo.pageNo=1;queryData()">搜 索</el-button>
  14. </el-form-item>
  15. </el-form>
  16. </div>
  17. <div style="margin: 0px 0 20px 0">
  18. <el-button type="primary" @click="createRow()" icon="el-icon-plus">新建知识图谱</el-button>
  19. </div>
  20. <div>
  21. <el-table :data="result.records" style="width: 100%">
  22. <el-table-column type="index" label="行号" width="100"></el-table-column>
  23. <el-table-column prop="name" label="图谱名称"></el-table-column>
  24. <el-table-column prop="comment" label="图谱描述"></el-table-column>
  25. <el-table-column prop="createTime" label="创建时间"></el-table-column>
  26. <el-table-column label="操作" width="250">
  27. <template slot-scope="scope">
  28. <el-button @click.native.prevent="detailRow(scope.row)" type="text" size="small">
  29. 查看图谱
  30. </el-button>
  31. <el-button @click.native.prevent="modifyRow(scope.row)" type="text" size="small">
  32. 编辑
  33. </el-button>
  34. <el-button @click.native.prevent="removeRow(scope.row)" type="text" size="small">
  35. 删除
  36. </el-button>
  37. <el-button @click.native.prevent="importRow(scope.row)" type="text" size="small" v-if="!scope.row.ontologyId">
  38. 导入本体
  39. </el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. </div>
  44. <div class="page-box">
  45. <el-pagination background
  46. @current-change="handleCurrentChange"
  47. :current-page="qo.pageNo"
  48. :page-size="qo.pageSize"
  49. layout="total, prev, pager, next"
  50. :total="result.total">
  51. </el-pagination>
  52. </div>
  53. </div>
  54. <el-dialog
  55. :title="dialogName"
  56. :visible.sync="cmdDialogVisible"
  57. width="40%">
  58. <el-form ref="cmd" label-width="100px" :rules="rules" :model="cmd">
  59. <el-form-item label="图谱名称" prop="name" v-if="dialogName == '新建'">
  60. <el-input v-model="cmd.name" placeholder="请输入图谱名称"></el-input>
  61. </el-form-item>
  62. <el-form-item label="图谱名称" prop="name" v-if="dialogName == '编辑'">
  63. <el-input v-model="cmd.name" placeholder="请输入图谱名称" :disabled="true"></el-input>
  64. </el-form-item>
  65. <el-form-item label="图谱描述" prop="comment">
  66. <el-input v-model="cmd.comment" placeholder="请输入图谱描述" type="textarea"></el-input>
  67. </el-form-item>
  68. </el-form>
  69. <span slot="footer" class="dialog-footer">
  70. <el-button @click="cmdDialogVisible = false">取 消</el-button>
  71. <el-button type="primary" @click="submitModify">确 定</el-button>
  72. </span>
  73. </el-dialog>
  74. <el-dialog title="导入本体"
  75. :visible.sync="importDialogVisible"
  76. width="40%">
  77. <el-form ref="cmd" label-width="100px" :rules="rules" :model="cmd">
  78. <el-form-item label="选择本体:" prop="ontologyId">
  79. <el-select v-model="cmd.ontologyId" placeholder="请选择本体" style="width: 100%">
  80. <el-option v-for="item in ontologyList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  81. </el-select>
  82. </el-form-item>
  83. </el-form>
  84. <span slot="footer" class="dialog-footer">
  85. <el-button @click="importDialogVisible = false">取 消</el-button>
  86. <el-button type="primary" @click="submitImport" :loading="loading">确 定</el-button>
  87. </span>
  88. </el-dialog>
  89. </div>
  90. </template>
  91. <script>
  92. import request from '@/utils/request';
  93. var _this;
  94. export default {
  95. name: "company",
  96. data() {
  97. return {
  98. qo: {
  99. pageNo: 1,
  100. pageSize: 10,
  101. LIKES_name: ''},
  102. result: {
  103. records: [],
  104. total: 0
  105. },
  106. dialogName: '编辑',
  107. cmdDialogVisible: false,
  108. cmd: {},
  109. rules: {
  110. name: [
  111. {required: true, message: '请输入图谱名称'}
  112. ],
  113. comment: [
  114. {required: true, message: '请输入图谱描述'}
  115. ],
  116. ontologyId: [
  117. {required: true, message: '请选择本体'}
  118. ],
  119. },
  120. ontologyList:[],
  121. importDialogVisible:false,
  122. loading:false
  123. }
  124. },
  125. mounted() {
  126. _this = this;
  127. let _pageNo = this.$route.query.pageNo;
  128. let _name = this.$route.query.name;
  129. if (_pageNo) {
  130. _this.qo.pageNo = parseInt(_pageNo);
  131. }
  132. if (_name) {
  133. _this.qo.LIKES_name = _name;
  134. }
  135. _this.queryData();
  136. _this.queryOntology();
  137. },
  138. methods: {
  139. queryData() {
  140. request({
  141. url: '/graph-case/query_pages',
  142. method: 'post',
  143. data: _this.qo
  144. }).then(res => {
  145. _this.result.records = res.data.records;
  146. _this.result.total = res.data.total;
  147. });
  148. },
  149. queryOntology() {
  150. request({
  151. url: `/ontology/query_list`,
  152. method: 'post',
  153. data: {EQI_sourceType: 1}
  154. }).then(res => {
  155. _this.ontologyList = res.data;
  156. });
  157. },
  158. handleCurrentChange(val) {
  159. _this.qo.pageNo = val;
  160. _this.queryData();
  161. },
  162. removeRow(item) {
  163. _this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
  164. confirmButtonText: '确定',
  165. cancelButtonText: '取消',
  166. type: 'warning'
  167. }).then(() => {
  168. request({
  169. url: '/graph-case/remove/' + item.id,
  170. method: 'post'
  171. }).then(res => {
  172. _this.$message.success("删除成功");
  173. _this.queryData();
  174. });
  175. }).catch(() => {
  176. });
  177. },
  178. detailRow(item) {
  179. this.$router.push({
  180. path: "/graphSpace_g",
  181. query: {pageNo: _this.qo.pageNo, name: _this.qo.LIKES_name, space: item.name,ontologyId:item.ontologyId,comment:item.comment}
  182. })
  183. },
  184. createRow() {
  185. _this.cmd = {
  186. name: '',
  187. comment: ''
  188. };
  189. _this.dialogName = '新建';
  190. _this.cmdDialogVisible = true;
  191. },
  192. modifyRow(item) {
  193. _this.cmd = JSON.parse(JSON.stringify(item));
  194. _this.dialogName = '编辑';
  195. _this.cmdDialogVisible = true;
  196. },
  197. submitModify() {
  198. this.$refs.cmd.validate((valid) => {
  199. if (valid) {
  200. if (_this.cmd.id) {
  201. request({
  202. url: '/graph-case/modify',
  203. method: 'post',
  204. data: _this.cmd
  205. }).then(res => {
  206. _this.$message.success("编辑成功");
  207. _this.queryData();
  208. _this.cmdDialogVisible = false;
  209. });
  210. } else { // 新建
  211. request({
  212. url: '/graph-case/create',
  213. method: 'post',
  214. data: _this.cmd
  215. }).then(res => {
  216. _this.$message.success("添加成功");
  217. _this.queryData();
  218. _this.cmdDialogVisible = false;
  219. });
  220. }
  221. }
  222. });
  223. },
  224. importRow(item){
  225. _this.cmd = item;
  226. _this.cmd.ontologyId = "";
  227. _this.importDialogVisible = true
  228. },
  229. submitImport(){
  230. this.$refs.cmd.validate((valid) => {
  231. if (valid) {
  232. _this.loading = true;
  233. request({
  234. url: '/graph-case/modify',
  235. method: 'post',
  236. data: _this.cmd
  237. }).then(res => {
  238. request({
  239. url: '/nebula_model/initgraphdatabase/' + _this.cmd.ontologyId + '/' + _this.cmd.name,
  240. method: 'get',
  241. data: {}
  242. }).then(res => {
  243. _this.$message.success("导入本体成功");
  244. _this.loading = false;
  245. _this.importDialogVisible = false;
  246. _this.queryData();
  247. });
  248. });
  249. }
  250. })
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss">
  256. .ca {
  257. color: rgb(51, 51, 51);
  258. }
  259. </style>