index.vue 10 KB

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