update: 更新权限管理对接
This commit is contained in:
parent
9ddfeecae0
commit
ee042a1b33
|
@ -50,14 +50,22 @@
|
||||||
:title="item.name"
|
:title="item.name"
|
||||||
>
|
>
|
||||||
<view v-if="item.childrenList">
|
<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>{{ 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>
|
<view v-else>
|
||||||
<u-empty mode="data">
|
<u-empty mode="data"> </u-empty>
|
||||||
</u-empty>
|
|
||||||
</view>
|
</view>
|
||||||
</u-collapse-item>
|
</u-collapse-item>
|
||||||
</u-collapse>
|
</u-collapse>
|
||||||
|
@ -79,7 +87,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ProfileApi, StockCardApi } from "@/services";
|
import { ProfileApi, StockCardApi } from "@/services";
|
||||||
import { formatDate } from "@/utils";
|
import { deleteBaseKey, formatDate } from "@/utils";
|
||||||
import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
|
import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import _ from "underscore";
|
import _ from "underscore";
|
||||||
|
@ -102,6 +110,7 @@ const rules = ref({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const contrlModalParams = reactive<any>({
|
const contrlModalParams = reactive<any>({
|
||||||
|
checkedMap: {},
|
||||||
menu: {
|
menu: {
|
||||||
list: [],
|
list: [],
|
||||||
},
|
},
|
||||||
|
@ -109,7 +118,7 @@ const contrlModalParams = reactive<any>({
|
||||||
|
|
||||||
const formAttrList = reactive<any>([
|
const formAttrList = reactive<any>([
|
||||||
{
|
{
|
||||||
name: "姓名",
|
name: "角色名称",
|
||||||
key: "roleName",
|
key: "roleName",
|
||||||
type: "input",
|
type: "input",
|
||||||
},
|
},
|
||||||
|
@ -122,38 +131,68 @@ const formAttrList = reactive<any>([
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleSelect = (key: string, v: any) => {
|
// const handleSelect = (key: string, v: any) => {
|
||||||
contrlModalParams[key].isShow = false;
|
// contrlModalParams[key].isShow = false;
|
||||||
if (key === "role") {
|
// if (key === "role") {
|
||||||
model1.formData.roleName = v.name;
|
// model1.formData.roleName = v.name;
|
||||||
model1.formData.roleIds = [v.id];
|
// model1.formData.roleIds = [v.id];
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const save = () => {
|
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) {
|
if (model1.formData.id) {
|
||||||
StockCardApi.updateStockCard(model1.formData).then((res) => {
|
ProfileApi.updateRole({...deleteBaseKey(model1.formData), list}).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pagesApp/stockCard", // 要跳转到的页面路径
|
url: "/pagesApp/role", // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ProfileApi.addUser({ userType: 1, ...model1.formData }).then((res) => {
|
ProfileApi.addRole({ ...model1.formData, list }).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pagesApp/user", // 要跳转到的页面路径
|
url: "/pagesApp/role", // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获得所有菜单
|
||||||
const getRoleList = () => {
|
const getRoleList = () => {
|
||||||
ProfileApi.getMenuList({}).then((res) => {
|
ProfileApi.getMenuList({}).then((res) => {
|
||||||
if (res.code === 200) {
|
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;
|
const title = (option as any).title;
|
||||||
model1.formData = JSON.parse((option as any).item);
|
model1.formData = JSON.parse((option as any).item);
|
||||||
if (model1.formData.type === 1) {
|
if (model1.formData.id) {
|
||||||
model1.formData.typeName = "出库卡";
|
getMenusRole(model1.formData.id);
|
||||||
} else if (model1.formData.type === 2) {
|
|
||||||
model1.formData.typeName = "入库卡";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置页面标题;
|
// 设置页面标题;
|
||||||
if (title) {
|
if (title) {
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
|
@ -212,4 +250,7 @@ onLoad((option) => {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
.flex-box + .flex-box {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -109,7 +109,7 @@ export const addMenusRole = (data: {
|
||||||
|
|
||||||
// 查询角色菜单权限
|
// 查询角色菜单权限
|
||||||
export const getMenusRole = (data: any) => {
|
export const getMenusRole = (data: any) => {
|
||||||
return http({
|
return http<[]>({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/api/role/getMenusRole",
|
url: "/api/role/getMenusRole",
|
||||||
data
|
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