update: 更新权限管理对接
This commit is contained in:
parent
9ddfeecae0
commit
ee042a1b33
|
@ -50,14 +50,22 @@
|
|||
:title="item.name"
|
||||
>
|
||||
<view v-if="item.childrenList">
|
||||
<view v-for="cItem in item.childrenList" :key="cItem.id" class="flex-box">
|
||||
<view
|
||||
v-for="cItem in item.childrenList"
|
||||
:key="cItem.id"
|
||||
class="flex-box"
|
||||
>
|
||||
<view>{{ cItem.name }}</view>
|
||||
<view><u-switch size="18" activeColor="#00D2E3" v-model="cItem.checked"></u-switch></view>
|
||||
</view></view
|
||||
>
|
||||
<view>
|
||||
<u-switch
|
||||
size="18"
|
||||
activeColor="#00D2E3"
|
||||
v-model="cItem.checked"
|
||||
></u-switch
|
||||
></view> </view
|
||||
></view>
|
||||
<view v-else>
|
||||
<u-empty mode="data">
|
||||
</u-empty>
|
||||
<u-empty mode="data"> </u-empty>
|
||||
</view>
|
||||
</u-collapse-item>
|
||||
</u-collapse>
|
||||
|
@ -79,7 +87,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ProfileApi, StockCardApi } from "@/services";
|
||||
import { formatDate } from "@/utils";
|
||||
import { deleteBaseKey, formatDate } from "@/utils";
|
||||
import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import _ from "underscore";
|
||||
|
@ -102,6 +110,7 @@ const rules = ref({
|
|||
},
|
||||
});
|
||||
const contrlModalParams = reactive<any>({
|
||||
checkedMap: {},
|
||||
menu: {
|
||||
list: [],
|
||||
},
|
||||
|
@ -109,7 +118,7 @@ const contrlModalParams = reactive<any>({
|
|||
|
||||
const formAttrList = reactive<any>([
|
||||
{
|
||||
name: "姓名",
|
||||
name: "角色名称",
|
||||
key: "roleName",
|
||||
type: "input",
|
||||
},
|
||||
|
@ -122,38 +131,68 @@ const formAttrList = reactive<any>([
|
|||
},
|
||||
]);
|
||||
|
||||
const handleSelect = (key: string, v: any) => {
|
||||
contrlModalParams[key].isShow = false;
|
||||
if (key === "role") {
|
||||
model1.formData.roleName = v.name;
|
||||
model1.formData.roleIds = [v.id];
|
||||
}
|
||||
};
|
||||
// const handleSelect = (key: string, v: any) => {
|
||||
// contrlModalParams[key].isShow = false;
|
||||
// if (key === "role") {
|
||||
// model1.formData.roleName = v.name;
|
||||
// model1.formData.roleIds = [v.id];
|
||||
// }
|
||||
// };
|
||||
|
||||
const save = () => {
|
||||
let list: any = [];
|
||||
contrlModalParams.menu.list.forEach((item: any) => {
|
||||
item.childrenList.forEach((c: any) => {
|
||||
if (c.checked) {
|
||||
list.push({ menusId: c.id, state: c.checked ? 1 : 0 });
|
||||
}
|
||||
});
|
||||
});
|
||||
if (model1.formData.id) {
|
||||
StockCardApi.updateStockCard(model1.formData).then((res) => {
|
||||
ProfileApi.updateRole({...deleteBaseKey(model1.formData), list}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesApp/stockCard", // 要跳转到的页面路径
|
||||
url: "/pagesApp/role", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ProfileApi.addUser({ userType: 1, ...model1.formData }).then((res) => {
|
||||
ProfileApi.addRole({ ...model1.formData, list }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesApp/user", // 要跳转到的页面路径
|
||||
url: "/pagesApp/role", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 获得所有菜单
|
||||
const getRoleList = () => {
|
||||
ProfileApi.getMenuList({}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
contrlModalParams.menu.list = res.data;
|
||||
contrlModalParams.menu.list = (res.data as any).map((item: any) => {
|
||||
item.childrenList = item.childrenList.map((cItem: any) => {
|
||||
console.log(contrlModalParams.checkedMap[cItem.id]);
|
||||
return {
|
||||
...cItem,
|
||||
checked: contrlModalParams.checkedMap[cItem.id] ? true : false,
|
||||
};
|
||||
});
|
||||
return { ...item };
|
||||
});
|
||||
|
||||
console.log(contrlModalParams.menu.list);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getMenusRole = (roleId: number) => {
|
||||
ProfileApi.getMenusRole({ roleId }).then((res) => {
|
||||
if (res.data) {
|
||||
res.data.forEach((item: any) => {
|
||||
contrlModalParams.checkedMap[item.menusId] = item.state === 1;
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -166,11 +205,10 @@ onLoad((option) => {
|
|||
// 接收传递的标题参数;
|
||||
const title = (option as any).title;
|
||||
model1.formData = JSON.parse((option as any).item);
|
||||
if (model1.formData.type === 1) {
|
||||
model1.formData.typeName = "出库卡";
|
||||
} else if (model1.formData.type === 2) {
|
||||
model1.formData.typeName = "入库卡";
|
||||
if (model1.formData.id) {
|
||||
getMenusRole(model1.formData.id);
|
||||
}
|
||||
|
||||
// 设置页面标题;
|
||||
if (title) {
|
||||
uni.setNavigationBarTitle({
|
||||
|
@ -212,4 +250,7 @@ onLoad((option) => {
|
|||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.flex-box + .flex-box {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -109,7 +109,7 @@ export const addMenusRole = (data: {
|
|||
|
||||
// 查询角色菜单权限
|
||||
export const getMenusRole = (data: any) => {
|
||||
return http({
|
||||
return http<[]>({
|
||||
method: "GET",
|
||||
url: "/api/role/getMenusRole",
|
||||
data
|
||||
|
|
|
@ -55,3 +55,12 @@ export function getCurrentYearStartAndEnd() {
|
|||
};
|
||||
}
|
||||
|
||||
export function deleteBaseKey(obj: any) {
|
||||
delete obj.createTime;
|
||||
delete obj.createUserId;
|
||||
delete obj.createUserName;
|
||||
delete obj.updateTime;
|
||||
delete obj.updateUserId;
|
||||
delete obj.updateUserName;
|
||||
return obj
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue