index.vue 7.6 KB

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