index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
  4. <el-form-item label="实体类关系名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入实体类关系名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <!-- <el-form-item label="起点实体类" prop="startId">
  13. <el-input
  14. v-model="queryParams.startId"
  15. placeholder="请输入起点实体类"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="终点实体类" prop="endId">
  21. <el-input
  22. v-model="queryParams.endId"
  23. placeholder="请输入终点实体类"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item> -->
  28. <el-form-item>
  29. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  30. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="primary"
  37. plain
  38. icon="el-icon-plus"
  39. size="mini"
  40. @click="handleAdd"
  41. v-hasPermi="['neo4j:class_relation:add']"
  42. >新增</el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button
  46. type="success"
  47. plain
  48. icon="el-icon-edit"
  49. size="mini"
  50. :disabled="single"
  51. @click="handleUpdate"
  52. v-hasPermi="['neo4j:class_relation:edit']"
  53. >修改</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="danger"
  58. plain
  59. icon="el-icon-delete"
  60. size="mini"
  61. :disabled="multiple"
  62. @click="handleDelete"
  63. v-hasPermi="['neo4j:class_relation:remove']"
  64. >删除</el-button>
  65. </el-col>
  66. <!-- <el-col :span="1.5">
  67. <el-button
  68. type="warning"
  69. plain
  70. icon="el-icon-download"
  71. size="mini"
  72. @click="handleExport"
  73. v-hasPermi="['neo4j:class_relation:export']"
  74. >导出</el-button>
  75. </el-col> -->
  76. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  77. </el-row>
  78. <el-table v-loading="loading" :data="class_relationList" @selection-change="handleSelectionChange">
  79. <el-table-column type="selection" width="55" align="center" />
  80. <el-table-column label="实体类关系名称" align="center" prop="name" />
  81. <!-- <el-table-column label="实体类关系描述" align="center" prop="desc" /> -->
  82. <el-table-column label="起点实体类" align="center" prop="startName" />
  83. <el-table-column label="终点实体类" align="center" prop="endName" />
  84. <el-table-column label="实体类背景颜色" align="center" prop="backGroundColor" >
  85. <template slot-scope="scope">
  86. <el-color-picker v-model="scope.row.backGroundColor" size="mini" disabled></el-color-picker>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  90. <template slot-scope="scope">
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-edit"
  95. @click="handleUpdate(scope.row)"
  96. v-hasPermi="['neo4j:class_relation:edit']"
  97. >修改</el-button>
  98. <el-button
  99. size="mini"
  100. type="text"
  101. icon="el-icon-delete"
  102. @click="handleDelete(scope.row)"
  103. v-hasPermi="['neo4j:class_relation:remove']"
  104. >删除</el-button>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <pagination
  109. v-show="total>0"
  110. :total="total"
  111. :page.sync="queryParams.pageNum"
  112. :limit.sync="queryParams.pageSize"
  113. @pagination="getList"
  114. />
  115. <!-- 添加或修改实体类关系对话框 -->
  116. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  117. <el-form ref="form" :model="form" :rules="rules" label-width="140px">
  118. <el-form-item label="实体类关系名称" prop="name">
  119. <el-input v-model="form.name" placeholder="请输入实体类名称" />
  120. </el-form-item>
  121. <!-- <el-form-item label="实体类关系描述" prop="desc">
  122. <el-input v-model="form.desc" type="textarea" placeholder="请输入内容" />
  123. </el-form-item> -->
  124. <el-form-item label="起点实体类" prop="startId">
  125. <el-select v-model="form.startId" placeholder="请选择起点实体类" value-key="id" filterable >
  126. <el-option
  127. v-for="item in entityClassList"
  128. :key="item.id"
  129. :label="item.name"
  130. :value="item.id">
  131. </el-option>
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item label="终点实体类" prop="endId">
  135. <el-select v-model="form.endId" placeholder="请选择终点实体类" value-key="id" filterable >
  136. <el-option
  137. v-for="item in entityClassList"
  138. :key="item.id"
  139. :label="item.name"
  140. :value="item.id">
  141. </el-option>
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="背景颜色" prop="backGroundColor">
  145. <el-color-picker v-model="form.backGroundColor"></el-color-picker>
  146. </el-form-item>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button type="primary" @click="submitForm">确 定</el-button>
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. import { listClass_relation, getClass_relation, delClass_relation, addClass_relation, updateClass_relation } from "@/api/neo4j/class_relation";
  157. import { getEntityClassOption } from "@/api/neo4j/class";
  158. export default {
  159. name: "Class_relation",
  160. data() {
  161. return {
  162. // 遮罩层
  163. loading: true,
  164. // 选中数组
  165. ids: [],
  166. // 非单个禁用
  167. single: true,
  168. // 非多个禁用
  169. multiple: true,
  170. // 显示搜索条件
  171. showSearch: true,
  172. // 总条数
  173. total: 0,
  174. // 实体类关系表格数据
  175. class_relationList: [],
  176. // 弹出层标题
  177. title: "",
  178. // 是否显示弹出层
  179. open: false,
  180. // 查询参数
  181. queryParams: {
  182. pageNum: 1,
  183. pageSize: 10,
  184. name: null,
  185. desc: null,
  186. startId: null,
  187. endId: null,
  188. },
  189. // 表单参数
  190. form: {},
  191. // 表单校验
  192. rules: {
  193. },
  194. entityClassList: []
  195. };
  196. },
  197. created() {
  198. this.getList();
  199. this.getEntityClassOption();
  200. },
  201. activated(){
  202. this.tEntityClassOption();
  203. },
  204. methods: {
  205. /** 查询实体类关系列表 */
  206. getList() {
  207. this.loading = true;
  208. listClass_relation(this.queryParams).then(response => {
  209. this.class_relationList = response.rows;
  210. this.total = response.total;
  211. this.loading = false;
  212. });
  213. },
  214. // 取消按钮
  215. cancel() {
  216. this.open = false;
  217. this.reset();
  218. },
  219. // 表单重置
  220. reset() {
  221. this.form = {
  222. id: null,
  223. name: null,
  224. desc: null,
  225. backGroundColor: '#FFFFFF',
  226. startId: null,
  227. endId: null,
  228. createBy: null,
  229. createTime: null,
  230. updateBy: null,
  231. updateTime: null
  232. };
  233. this.resetForm("form");
  234. },
  235. /** 搜索按钮操作 */
  236. handleQuery() {
  237. this.queryParams.pageNum = 1;
  238. this.getList();
  239. },
  240. /** 重置按钮操作 */
  241. resetQuery() {
  242. this.resetForm("queryForm");
  243. this.handleQuery();
  244. },
  245. // 多选框选中数据
  246. handleSelectionChange(selection) {
  247. this.ids = selection.map(item => item.id)
  248. this.single = selection.length!==1
  249. this.multiple = !selection.length
  250. },
  251. /** 新增按钮操作 */
  252. handleAdd() {
  253. this.reset();
  254. this.open = true;
  255. this.title = "添加实体类关系";
  256. },
  257. /** 修改按钮操作 */
  258. handleUpdate(row) {
  259. this.reset();
  260. const id = row.id || this.ids
  261. getClass_relation(id).then(response => {
  262. this.form = response.data;
  263. this.open = true;
  264. this.title = "修改实体类关系";
  265. });
  266. },
  267. /** 提交按钮 */
  268. submitForm() {
  269. this.$refs["form"].validate(valid => {
  270. if (valid) {
  271. if (this.form.id != null) {
  272. updateClass_relation(this.form).then(response => {
  273. this.$modal.msgSuccess("修改成功");
  274. this.open = false;
  275. this.getList();
  276. });
  277. } else {
  278. addClass_relation(this.form).then(response => {
  279. this.$modal.msgSuccess("新增成功");
  280. this.open = false;
  281. this.getList();
  282. });
  283. }
  284. }
  285. });
  286. },
  287. /** 删除按钮操作 */
  288. handleDelete(row) {
  289. const ids = row.id || this.ids;
  290. this.$modal.confirm('是否确认删除实体类关系编号为"' + ids + '"的数据项?').then(function() {
  291. return delClass_relation(ids);
  292. }).then(() => {
  293. this.getList();
  294. this.$modal.msgSuccess("删除成功");
  295. }).catch(() => {});
  296. },
  297. /** 导出按钮操作 */
  298. handleExport() {
  299. this.download('neo4j/class_relation/export', {
  300. ...this.queryParams
  301. }, `class_relation_${new Date().getTime()}.xlsx`)
  302. },
  303. getEntityClassOption(){
  304. getEntityClassOption().then(resp => {
  305. this.entityClassList = resp.data
  306. console.info(resp)
  307. })
  308. }
  309. }
  310. };
  311. </script>