index.vue 8.8 KB

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