角色管理及人员管理的排序功能
Showing
4 changed files
with
113 additions
and
48 deletions
1 | /* | ||
2 | * @Author: yangwei | ||
3 | * @Date: 2023-02-24 15:12:45 | ||
4 | * @LastEditors: yangwei | ||
5 | * @LastEditTime: 2023-03-14 10:45:11 | ||
6 | * @FilePath: \bdcjg-web\src\api\authorityManage.js | ||
7 | * @Description: | ||
8 | * | ||
9 | * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. | ||
10 | */ | ||
1 | 11 | ||
2 | import { getParams } from './util' | 12 | import { getParams } from './util' |
3 | import { | 13 | import { |
... | @@ -8,16 +18,16 @@ import { | ... | @@ -8,16 +18,16 @@ import { |
8 | } from './manageApi' | 18 | } from './manageApi' |
9 | /** 角色管理开始 */ | 19 | /** 角色管理开始 */ |
10 | // 获取角色列表 by categoryId | 20 | // 获取角色列表 by categoryId |
11 | export const getRolesById = categoryId => { | 21 | export const getRolesById = categoryIdList => { |
12 | const conditionGroup = { | 22 | const conditionGroup = { |
13 | conditions: [ | 23 | conditions: [ |
14 | { | 24 | { |
15 | property: 'category', | 25 | property: 'category', |
16 | value: categoryId, | 26 | value: categoryIdList, |
17 | operator: 'EQ' | 27 | operator: 'IN' |
18 | } | 28 | } |
19 | ], | 29 | ], |
20 | queryRelation: 'AND' | 30 | queryRelation: 'AND', |
21 | } | 31 | } |
22 | const params = getParams(conditionGroup) | 32 | const params = getParams(conditionGroup) |
23 | return getAction(api.roles, params) | 33 | return getAction(api.roles, params) | ... | ... |
src/api/orders.js
0 → 100644
1 | import request from '@/utils/request' | ||
2 | import SERVER from './config' | ||
3 | |||
4 | /* | ||
5 | 更新排序 | ||
6 | record-排序整条数据 | ||
7 | operate-BOTTOM(置底), DOWN(向下), TOP(置顶), UP(向上) | ||
8 | */ | ||
9 | export function updateOrder(url, record, operate, swapId) { | ||
10 | return request({ | ||
11 | url: SERVER.MANAGEMENTAPI + url + "/" + record.id + "/orders", | ||
12 | method: "put", | ||
13 | params: { | ||
14 | operate: operate, | ||
15 | swapId: swapId, | ||
16 | }, | ||
17 | }); | ||
18 | } |
... | @@ -38,6 +38,7 @@ | ... | @@ -38,6 +38,7 @@ |
38 | import EditDialog from "./edit-dialog.vue"; | 38 | import EditDialog from "./edit-dialog.vue"; |
39 | import Roleslistdiglog from "./roleslistdiglog.vue"; | 39 | import Roleslistdiglog from "./roleslistdiglog.vue"; |
40 | import { mapGetters } from "vuex"; | 40 | import { mapGetters } from "vuex"; |
41 | import {updateOrder} from "@/api/orders" | ||
41 | export default { | 42 | export default { |
42 | name: "menus", | 43 | name: "menus", |
43 | mixins: [tableMixin], | 44 | mixins: [tableMixin], |
... | @@ -107,7 +108,7 @@ | ... | @@ -107,7 +108,7 @@ |
107 | .concat([ | 108 | .concat([ |
108 | { | 109 | { |
109 | label: "排序", | 110 | label: "排序", |
110 | width: 100, | 111 | width: 200, |
111 | render: (h, scope) => { | 112 | render: (h, scope) => { |
112 | return ( | 113 | return ( |
113 | <div> | 114 | <div> |
... | @@ -115,7 +116,16 @@ | ... | @@ -115,7 +116,16 @@ |
115 | type="text" | 116 | type="text" |
116 | disabled={scope.row.isTop} | 117 | disabled={scope.row.isTop} |
117 | onClick={() => { | 118 | onClick={() => { |
118 | this.moveUpward(scope.$index, scope.row); | 119 | this.updateOrder(scope.row,'TOP'); |
120 | }} | ||
121 | > | ||
122 | 置顶 | ||
123 | </el-button> | ||
124 | <el-button | ||
125 | type="text" | ||
126 | disabled={scope.row.isTop} | ||
127 | onClick={() => { | ||
128 | this.updateOrder(scope.row,'UP'); | ||
119 | }} | 129 | }} |
120 | > | 130 | > |
121 | 上移 | 131 | 上移 |
... | @@ -124,11 +134,20 @@ | ... | @@ -124,11 +134,20 @@ |
124 | type="text" | 134 | type="text" |
125 | disabled={scope.row.isBottom} | 135 | disabled={scope.row.isBottom} |
126 | onClick={() => { | 136 | onClick={() => { |
127 | this.moveDown(scope.$index, scope.row); | 137 | this.updateOrder(scope.row,'DOWN'); |
128 | }} | 138 | }} |
129 | > | 139 | > |
130 | 下移 | 140 | 下移 |
131 | </el-button> | 141 | </el-button> |
142 | <el-button | ||
143 | type="text" | ||
144 | disabled={scope.row.isBottom} | ||
145 | onClick={() => { | ||
146 | this.updateOrder(scope.row,'BOTTOM'); | ||
147 | }} | ||
148 | > | ||
149 | 置底 | ||
150 | </el-button> | ||
132 | </div> | 151 | </div> |
133 | ); | 152 | ); |
134 | }, | 153 | }, |
... | @@ -225,20 +244,10 @@ | ... | @@ -225,20 +244,10 @@ |
225 | methods: { | 244 | methods: { |
226 | // 获取角色列表 | 245 | // 获取角色列表 |
227 | getTableData () { | 246 | getTableData () { |
228 | let Builtinrole = []; | 247 | getRolesById([1,2]) |
229 | let Publicrole = []; | ||
230 | |||
231 | getRolesById(1) | ||
232 | .then((res) => { | 248 | .then((res) => { |
233 | Builtinrole = res.content; | 249 | this.listdata = res.content; |
234 | getRolesById(2) | 250 | this.listdata = judgeSort(this.listdata); |
235 | .then((res) => { | ||
236 | Publicrole = res.content; | ||
237 | |||
238 | this.listdata = Builtinrole.concat(Publicrole); | ||
239 | this.listdata = judgeSort(this.listdata); | ||
240 | }) | ||
241 | .catch((e) => console.error(e)); | ||
242 | }) | 251 | }) |
243 | .catch((e) => console.error(e)); | 252 | .catch((e) => console.error(e)); |
244 | }, | 253 | }, |
... | @@ -397,20 +406,24 @@ | ... | @@ -397,20 +406,24 @@ |
397 | this.$refs.addEditDialog.showAddEditDialog = true; | 406 | this.$refs.addEditDialog.showAddEditDialog = true; |
398 | this.$refs.addEditDialog.dialogTitle = value.id ? "修改" : "新增"; | 407 | this.$refs.addEditDialog.dialogTitle = value.id ? "修改" : "新增"; |
399 | }, | 408 | }, |
400 | // 上移下移 | 409 | //排序 |
401 | moveUpward (index, row) { | 410 | updateOrder(record, operate){ |
402 | realMove(row.dictid, "UP", this.listdata); | 411 | const findIndex = this.listdata.findIndex(item => item.id === record.id) |
403 | this.key++; | 412 | let swapId = '' |
404 | let id = findParents(this.listdata, row.dictid); | 413 | if (operate === 'UP') { |
405 | this.keyList = id; | 414 | swapId = this.listdata[findIndex - 1].id |
406 | }, | 415 | } else if (operate === 'DOWN') { |
407 | moveDown (index, row) { | 416 | swapId = this.listdata[findIndex + 1].id |
408 | realMove(row.dictid, "DOWN", this.listdata); | 417 | } |
409 | this.key++; | 418 | updateOrder('/rest/roles', record, operate, swapId).then(res => { |
410 | let id = findParents(this.listdata, row.dictid); | 419 | if (res.status === 1) { |
411 | this.keyList = id; | 420 | this.$message.success({ message: res.message, showClose: true }) |
421 | this.getTableData(); | ||
422 | } else { | ||
423 | this.$message.error({ message: res.message, showClose: true }) | ||
424 | } | ||
425 | }) | ||
412 | }, | 426 | }, |
413 | |||
414 | // 删除 | 427 | // 删除 |
415 | handleDelete: function (id, content = "") { | 428 | handleDelete: function (id, content = "") { |
416 | this.$confirm( | 429 | this.$confirm( | ... | ... |
... | @@ -46,6 +46,7 @@ | ... | @@ -46,6 +46,7 @@ |
46 | import { deleteDomStr } from '@/utils/proDomStr' | 46 | import { deleteDomStr } from '@/utils/proDomStr' |
47 | import tableMixin from "@/mixins/tableMixin.js"; | 47 | import tableMixin from "@/mixins/tableMixin.js"; |
48 | import EditDialog from "./edit-dialog.vue"; | 48 | import EditDialog from "./edit-dialog.vue"; |
49 | import {updateOrder} from "@/api/orders" | ||
49 | export default { | 50 | export default { |
50 | name: "menus", | 51 | name: "menus", |
51 | mixins: [tableMixin], | 52 | mixins: [tableMixin], |
... | @@ -109,7 +110,7 @@ | ... | @@ -109,7 +110,7 @@ |
109 | }, | 110 | }, |
110 | { | 111 | { |
111 | label: "排序", | 112 | label: "排序", |
112 | width: 100, | 113 | width: 200, |
113 | render: (h, scope) => { | 114 | render: (h, scope) => { |
114 | return ( | 115 | return ( |
115 | <div> | 116 | <div> |
... | @@ -117,7 +118,16 @@ | ... | @@ -117,7 +118,16 @@ |
117 | type="text" | 118 | type="text" |
118 | disabled={scope.row.isTop} | 119 | disabled={scope.row.isTop} |
119 | onClick={() => { | 120 | onClick={() => { |
120 | this.moveUpward(scope.$index, scope.row); | 121 | this.updateOrder(scope.row,'TOP'); |
122 | }} | ||
123 | > | ||
124 | 置顶 | ||
125 | </el-button> | ||
126 | <el-button | ||
127 | type="text" | ||
128 | disabled={scope.row.isTop} | ||
129 | onClick={() => { | ||
130 | this.updateOrder(scope.row,'UP'); | ||
121 | }} | 131 | }} |
122 | > | 132 | > |
123 | 上移 | 133 | 上移 |
... | @@ -126,11 +136,20 @@ | ... | @@ -126,11 +136,20 @@ |
126 | type="text" | 136 | type="text" |
127 | disabled={scope.row.isBottom} | 137 | disabled={scope.row.isBottom} |
128 | onClick={() => { | 138 | onClick={() => { |
129 | this.moveDown(scope.$index, scope.row); | 139 | this.updateOrder(scope.row,'DOWN'); |
130 | }} | 140 | }} |
131 | > | 141 | > |
132 | 下移 | 142 | 下移 |
133 | </el-button> | 143 | </el-button> |
144 | <el-button | ||
145 | type="text" | ||
146 | disabled={scope.row.isBottom} | ||
147 | onClick={() => { | ||
148 | this.updateOrder(scope.row,'BOTTOM'); | ||
149 | }} | ||
150 | > | ||
151 | 置底 | ||
152 | </el-button> | ||
134 | </div> | 153 | </div> |
135 | ); | 154 | ); |
136 | }, | 155 | }, |
... | @@ -257,18 +276,23 @@ | ... | @@ -257,18 +276,23 @@ |
257 | }) | 276 | }) |
258 | .catch(() => { }) | 277 | .catch(() => { }) |
259 | }, | 278 | }, |
260 | // 上移下移 | 279 | //排序 |
261 | moveUpward (index, row) { | 280 | updateOrder(record, operate){ |
262 | realMove(row.dictid, "UP", this.tableData.data); | 281 | const findIndex = this.tableData.data.findIndex(item => item.id === record.id) |
263 | this.key++; | 282 | let swapId = '' |
264 | let id = findParents(this.tableData.data, row.dictid); | 283 | if (operate === 'UP') { |
265 | this.keyList = id; | 284 | swapId = this.tableData.data[findIndex - 1].id |
266 | }, | 285 | } else if (operate === 'DOWN') { |
267 | moveDown (index, row) { | 286 | swapId = this.tableData.data[findIndex + 1].id |
268 | realMove(row.dictid, "DOWN", this.tableData.data); | 287 | } |
269 | this.key++; | 288 | updateOrder('/rest/users', record, operate, swapId).then(res => { |
270 | let id = findParents(this.tableData.data, row.dictid); | 289 | if (res.status === 1) { |
271 | this.keyList = id; | 290 | this.$message.success({ message: res.message, showClose: true }) |
291 | this.getTableList(); | ||
292 | } else { | ||
293 | this.$message.error({ message: res.message, showClose: true }) | ||
294 | } | ||
295 | }) | ||
272 | }, | 296 | }, |
273 | // 修改人员信息 | 297 | // 修改人员信息 |
274 | handleEdit (row) { | 298 | handleEdit (row) { | ... | ... |
-
Please register or sign in to post a comment