index.vue 11 KB

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