ccbc2d34 by yangwei

角色管理及人员管理的排序功能

1 parent 462add67
/*
* @Author: yangwei
* @Date: 2023-02-24 15:12:45
* @LastEditors: yangwei
* @LastEditTime: 2023-03-14 10:45:11
* @FilePath: \bdcjg-web\src\api\authorityManage.js
* @Description:
*
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
*/
import { getParams } from './util'
import {
......@@ -8,16 +18,16 @@ import {
} from './manageApi'
/** 角色管理开始 */
// 获取角色列表 by categoryId
export const getRolesById = categoryId => {
export const getRolesById = categoryIdList => {
const conditionGroup = {
conditions: [
{
property: 'category',
value: categoryId,
operator: 'EQ'
value: categoryIdList,
operator: 'IN'
}
],
queryRelation: 'AND'
queryRelation: 'AND',
}
const params = getParams(conditionGroup)
return getAction(api.roles, params)
......
import request from '@/utils/request'
import SERVER from './config'
/*
更新排序
record-排序整条数据
operate-BOTTOM(置底), DOWN(向下), TOP(置顶), UP(向上)
*/
export function updateOrder(url, record, operate, swapId) {
return request({
url: SERVER.MANAGEMENTAPI + url + "/" + record.id + "/orders",
method: "put",
params: {
operate: operate,
swapId: swapId,
},
});
}
......@@ -38,6 +38,7 @@
import EditDialog from "./edit-dialog.vue";
import Roleslistdiglog from "./roleslistdiglog.vue";
import { mapGetters } from "vuex";
import {updateOrder} from "@/api/orders"
export default {
name: "menus",
mixins: [tableMixin],
......@@ -107,7 +108,7 @@
.concat([
{
label: "排序",
width: 100,
width: 200,
render: (h, scope) => {
return (
<div>
......@@ -115,7 +116,16 @@
type="text"
disabled={scope.row.isTop}
onClick={() => {
this.moveUpward(scope.$index, scope.row);
this.updateOrder(scope.row,'TOP');
}}
>
置顶
</el-button>
<el-button
type="text"
disabled={scope.row.isTop}
onClick={() => {
this.updateOrder(scope.row,'UP');
}}
>
上移
......@@ -124,11 +134,20 @@
type="text"
disabled={scope.row.isBottom}
onClick={() => {
this.moveDown(scope.$index, scope.row);
this.updateOrder(scope.row,'DOWN');
}}
>
下移
</el-button>
<el-button
type="text"
disabled={scope.row.isBottom}
onClick={() => {
this.updateOrder(scope.row,'BOTTOM');
}}
>
置底
</el-button>
</div>
);
},
......@@ -225,20 +244,10 @@
methods: {
// 获取角色列表
getTableData () {
let Builtinrole = [];
let Publicrole = [];
getRolesById(1)
getRolesById([1,2])
.then((res) => {
Builtinrole = res.content;
getRolesById(2)
.then((res) => {
Publicrole = res.content;
this.listdata = Builtinrole.concat(Publicrole);
this.listdata = judgeSort(this.listdata);
})
.catch((e) => console.error(e));
this.listdata = res.content;
this.listdata = judgeSort(this.listdata);
})
.catch((e) => console.error(e));
},
......@@ -397,20 +406,24 @@
this.$refs.addEditDialog.showAddEditDialog = true;
this.$refs.addEditDialog.dialogTitle = value.id ? "修改" : "新增";
},
// 上移下移
moveUpward (index, row) {
realMove(row.dictid, "UP", this.listdata);
this.key++;
let id = findParents(this.listdata, row.dictid);
this.keyList = id;
},
moveDown (index, row) {
realMove(row.dictid, "DOWN", this.listdata);
this.key++;
let id = findParents(this.listdata, row.dictid);
this.keyList = id;
//排序
updateOrder(record, operate){
const findIndex = this.listdata.findIndex(item => item.id === record.id)
let swapId = ''
if (operate === 'UP') {
swapId = this.listdata[findIndex - 1].id
} else if (operate === 'DOWN') {
swapId = this.listdata[findIndex + 1].id
}
updateOrder('/rest/roles', record, operate, swapId).then(res => {
if (res.status === 1) {
this.$message.success({ message: res.message, showClose: true })
this.getTableData();
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
},
// 删除
handleDelete: function (id, content = "") {
this.$confirm(
......
......@@ -46,6 +46,7 @@
import { deleteDomStr } from '@/utils/proDomStr'
import tableMixin from "@/mixins/tableMixin.js";
import EditDialog from "./edit-dialog.vue";
import {updateOrder} from "@/api/orders"
export default {
name: "menus",
mixins: [tableMixin],
......@@ -109,7 +110,7 @@
},
{
label: "排序",
width: 100,
width: 200,
render: (h, scope) => {
return (
<div>
......@@ -117,7 +118,16 @@
type="text"
disabled={scope.row.isTop}
onClick={() => {
this.moveUpward(scope.$index, scope.row);
this.updateOrder(scope.row,'TOP');
}}
>
置顶
</el-button>
<el-button
type="text"
disabled={scope.row.isTop}
onClick={() => {
this.updateOrder(scope.row,'UP');
}}
>
上移
......@@ -126,11 +136,20 @@
type="text"
disabled={scope.row.isBottom}
onClick={() => {
this.moveDown(scope.$index, scope.row);
this.updateOrder(scope.row,'DOWN');
}}
>
下移
</el-button>
<el-button
type="text"
disabled={scope.row.isBottom}
onClick={() => {
this.updateOrder(scope.row,'BOTTOM');
}}
>
置底
</el-button>
</div>
);
},
......@@ -257,18 +276,23 @@
})
.catch(() => { })
},
// 上移下移
moveUpward (index, row) {
realMove(row.dictid, "UP", this.tableData.data);
this.key++;
let id = findParents(this.tableData.data, row.dictid);
this.keyList = id;
},
moveDown (index, row) {
realMove(row.dictid, "DOWN", this.tableData.data);
this.key++;
let id = findParents(this.tableData.data, row.dictid);
this.keyList = id;
//排序
updateOrder(record, operate){
const findIndex = this.tableData.data.findIndex(item => item.id === record.id)
let swapId = ''
if (operate === 'UP') {
swapId = this.tableData.data[findIndex - 1].id
} else if (operate === 'DOWN') {
swapId = this.tableData.data[findIndex + 1].id
}
updateOrder('/rest/users', record, operate, swapId).then(res => {
if (res.status === 1) {
this.$message.success({ message: res.message, showClose: true })
this.getTableList();
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
},
// 修改人员信息
handleEdit (row) {
......