update: 人员权限更新

This commit is contained in:
admin 2024-03-19 10:15:47 +08:00
parent 92a2a38e18
commit 824b4de324
9 changed files with 432 additions and 38 deletions

View File

@ -353,6 +353,12 @@
"navigationBarTitleText": "人员管理" "navigationBarTitleText": "人员管理"
} }
}, },
{
"path": "role",
"style": {
"navigationBarTitleText": "权限管理"
}
},
{ {
"path": "components/addSupplierType", "path": "components/addSupplierType",
"style": { "style": {
@ -406,6 +412,12 @@
"style": { "style": {
"navigationBarTitleText": "新增人员" "navigationBarTitleText": "新增人员"
} }
},
{
"path": "components/addRole",
"style": {
"navigationBarTitleText": "新增权限"
}
} }
] ]
} }

View File

@ -0,0 +1,215 @@
<template>
<view class="c-card">
<u-form
labelPosition="left"
:model="model1"
:rules="rules"
ref="form"
:labelWidth="100"
:labelStyle="{ padding: '0rpx 10rpx' }"
>
<u-form-item
:prop="`formData[${item.key}]`"
:label="item.name"
:required="item.required"
v-for="(item, index) in formAttrList"
:key="index"
@click="item.fn"
>
<u-textarea
v-if="item.type === 'textarea'"
v-model="(model1.formData as any)[item.key]"
:placeholder="`请输入${item.name}`"
></u-textarea>
<u-input
v-if="item.type === 'select' || item.type === 'input'"
:password="item.name === 'password'"
v-model="(model1.formData as any)[item.key]"
:placeholder="`${item.type === 'select' ? '选择' : '输入'}${
item.name
}`"
:clearable="true"
:customStyle="{}"
border="none"
>
<template #suffix>
<text>
{{ item.unit }}
</text>
</template>
</u-input>
<template #right v-if="item.type === 'select'">
<u-icon name="arrow-right"></u-icon>
</template>
</u-form-item>
</u-form>
<u-collapse>
<u-collapse-item
v-for="item in contrlModalParams.menu.list"
:key="item.id"
:title="item.name"
>
<view v-if="item.childrenList">
<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 v-else>
<u-empty mode="data">
</u-empty>
</view>
</u-collapse-item>
</u-collapse>
<!-- <block v-for="(item, index) in formAttrList" :key="index">
<u-action-sheet
v-if="item.type === 'select'"
:actions="contrlModalParams[item.childKey].list"
:title="contrlModalParams[item.childKey].title"
:show="contrlModalParams[item.childKey].isShow"
@select="(v: any) => handleSelect(item.childKey, v)"
@close="contrlModalParams[item.childKey].isShow = false"
:closeOnClickAction="true"
></u-action-sheet>
</block> -->
</view>
<view class="btn-box">
<u-button type="primary" text="保存" @click="save()"></u-button>
</view>
</template>
<script setup lang="ts">
import { ProfileApi, StockCardApi } from "@/services";
import { formatDate } from "@/utils";
import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
import { onLoad } from "@dcloudio/uni-app";
import _ from "underscore";
const model1 = reactive<any>({
formData: {},
});
const rules = ref({
"userInfo.userName": {
type: "string",
required: true,
message: "请输入手机号",
trigger: ["blur", "change"],
},
"userInfo.password": {
type: "string",
required: true,
message: "请输入密码",
trigger: ["blur", "change"],
},
});
const contrlModalParams = reactive<any>({
menu: {
list: [],
},
});
const formAttrList = reactive<any>([
{
name: "姓名",
key: "roleName",
type: "input",
},
{
name: "权限配置",
key: "config",
type: "text",
childKey: "menu",
fn: () => {},
},
]);
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 = () => {
if (model1.formData.id) {
StockCardApi.updateStockCard(model1.formData).then((res) => {
if (res.code === 200) {
uni.redirectTo({
url: "/pagesApp/stockCard", //
});
}
});
} else {
ProfileApi.addUser({ userType: 1, ...model1.formData }).then((res) => {
if (res.code === 200) {
uni.redirectTo({
url: "/pagesApp/user", //
});
}
});
}
};
const getRoleList = () => {
ProfileApi.getMenuList({}).then((res) => {
if (res.code === 200) {
contrlModalParams.menu.list = res.data;
}
});
};
onMounted(() => {
getRoleList();
});
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 (title) {
uni.setNavigationBarTitle({
title: title,
});
}
});
</script>
<style lang="scss" scoped>
.c-card {
background: #ffffff;
// box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx;
margin: 30rpx 25rpx;
padding: 10rpx 20rpx;
::v-deep .u-form-item {
height: auto;
}
::v-deep .u-form-item + .u-form-item {
border-top: 1rpx solid rgba(233, 233, 233, 0.76);
}
}
.btn-box {
margin-top: 60rpx;
display: flex;
background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 56, 93, 0.12);
border-radius: 13rpx 13rpx 0rpx 0rpx;
padding: 25rpx 50rpx;
position: sticky;
bottom: 0rpx;
z-index: 999;
::v-deep button {
border-radius: 43rpx;
}
}
.flex-box {
display: flex;
align-items: center;
justify-content: space-between;
}
</style>

View File

@ -23,6 +23,7 @@
></u-textarea> ></u-textarea>
<u-input <u-input
v-if="item.type === 'select' || item.type === 'input'" v-if="item.type === 'select' || item.type === 'input'"
:password="item.name === 'password'"
v-model="(model1.formData as any)[item.key]" v-model="(model1.formData as any)[item.key]"
:placeholder="`${item.type === 'select' ? '选择' : '输入'}${ :placeholder="`${item.type === 'select' ? '选择' : '输入'}${
item.name item.name
@ -59,7 +60,7 @@
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { StockCardApi } from "@/services"; import { ProfileApi, StockCardApi } from "@/services";
import { formatDate } from "@/utils"; import { 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";
@ -83,69 +84,79 @@ const rules = ref({
}, },
}); });
const contrlModalParams = reactive<any>({ const contrlModalParams = reactive<any>({
cardType: { role: {
isShow: false,
title: "标题",
list: [],
},
gender: {
isShow: false, isShow: false,
title: "标题", title: "标题",
list: [{ list: [{
id: 1, id: 1,
name: '出库卡' name: '男'
},{ },
{
id: 2, id: 2,
name: '入库卡' name: ''
}], }],
} },
}); });
const formAttrList = reactive<any>([ const formAttrList = reactive<any>([
{ {
name: "姓名", name: "姓名",
key: "cardCode", key: "name",
type: "input", type: "input",
}, },
{ {
name: "性别", name: "性别",
key: "typeName", key: "genderName",
type: "select", type: "select",
childKey: "cardType", childKey: "gender",
fn: () => { fn: () => {
contrlModalParams.cardType.isShow = true; contrlModalParams.gender.isShow = true;
contrlModalParams.cardType.title = "库存卡类型"; contrlModalParams.gender.title = "选择性别";
}, },
}, },
{ {
name: "用户角色", name: "用户角色",
key: "typeName", key: "roleName",
type: "select", type: "select",
childKey: "cardType", childKey: "role",
fn: () => { fn: () => {
contrlModalParams.cardType.isShow = true; contrlModalParams.role.isShow = true;
contrlModalParams.cardType.title = "库存卡类型"; contrlModalParams.role.title = "选择角色";
}, },
}, },
{ {
name: "用户名", name: "用户名",
key: "cardCode", key: "userName",
type: "input", type: "input",
required: true, required: true,
}, },
{ {
name: "密码", name: "密码",
key: "cardCode", key: "password",
type: "input", type: "input",
required: true, required: true,
}, },
{ {
name: "联系手机", name: "联系手机",
key: "cardCode", key: "phone",
type: "input", type: "input",
}, },
]); ]);
const handleSelect = (key: string, v: any) => { const handleSelect = (key: string, v: any) => {
contrlModalParams[key].isShow = false; contrlModalParams[key].isShow = false;
if (key === "cardType") { if (key === "role") {
model1.formData.typeName = v.name; model1.formData.roleName = v.name;
model1.formData.type = v.id; model1.formData.roleIds = [v.id];
}
if (key === "gender") {
model1.formData.genderName = v.name;
model1.formData.genderId = v.id;
} }
}; };
@ -159,30 +170,46 @@ const save = () => {
} }
}); });
} else { } else {
StockCardApi.addStockCard(model1.formData).then((res) => { ProfileApi.addUser({userType: 1, ...model1.formData}).then((res) => {
if (res.code === 200) { if (res.code === 200) {
uni.redirectTo({ uni.redirectTo({
url: "/pagesApp/stockCard", // url: "/pagesApp/user", //
}); });
} }
}); });
} }
}; };
const getRoleList = () => {
ProfileApi.getRoleList().then((res) => {
if (res.code === 200) {
contrlModalParams.role.list = (res.data as any).map((item: any) => {
return { ...item, name: item.roleName };
});
console.log(contrlModalParams.role.list);
}
});
};
onMounted(() => {
getRoleList();
});
onLoad((option) => { 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.type === 1) {
model1.formData.typeName = '出库卡' model1.formData.typeName = "出库卡";
}else if (model1.formData.type === 2) { } else if (model1.formData.type === 2) {
model1.formData.typeName = '入库卡' model1.formData.typeName = "入库卡";
} }
// // ;
if (title) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: title, title: title,
}); });
}
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

138
src/pagesApp/role.vue Normal file
View File

@ -0,0 +1,138 @@
<template>
<view class="c-card">
<view class="search">
<u-search
placeholder="请输入角色名称"
v-model="state.name"
:showAction="false"
:bgColor="'#fff'"
:borderColor="'rgba(0, 0, 0, 0.1)'"
:placeholderColor="'#C1C1C1'"
@search="handleSearch()"
></u-search>
<view class="btn" @click="add"> 新增 </view>
</view>
<view class="box">
<view v-for="(item, index) in pageList.list" :key="index">
<view>
<view>{{ item.roleName }}</view>
</view>
<view class="op-box">
<view class="btn" @click="edit(item)"> 编辑 </view>
<view class="btn" @click="deleteCustomer(item)"> 删除
</view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ProfileApi, StockCardApi } from "@/services";
import { StockCardType } from "@/utils/enum";
const keyword = ref("");
const state = reactive<any>({
name: "",
});
const pageList: PageResult<{
roleName: string
}> = reactive({
total: 0,
list: [],
pageNum: 1,
pageSize: 10,
});
const add = () => {
uni.navigateTo({
url: "/pagesApp/components/addRole", //
});
};
const edit = (item: any) => {
uni.navigateTo({
url:
"/pagesApp/components/addRole?title=新增角色&item=" +
JSON.stringify(item), //
});
};
const deleteCustomer = (item: any) => {
StockCardApi.updateStockCard({ isDeleted: true, id: item.id }).then((res) => {
if (res.code === 200) {
getList();
}
});
};
const handleSearch = () => {
getList();
};
const getList = () => {
let params: any = {
roleName: state.name,
};
ProfileApi.getRoleList(params).then((res) => {
if (res.code === 200) {
if (res.code === 200) {
(pageList as any).list = (res.data as any);
}
}
});
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.c-card {
margin: 30rpx 25rpx;
.search {
display: flex;
align-items: center;
justify-content: space-between;
.btn {
background: #00dcee;
border-radius: 24rpx;
border: 1px solid #00dcee;
font-weight: 500;
font-size: 26rpx;
color: #ffffff;
margin-left: 50rpx;
padding: 6rpx 30rpx;
}
}
.box {
background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx;
padding: 10rpx 25rpx;
font-weight: 400;
font-size: 26rpx;
color: #000000;
line-height: 41rpx;
margin-top: 30rpx;
> view {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0rpx;
.op-box {
display: flex;
.btn + .btn {
margin-left: 20rpx;
}
.btn {
background: #ff9d55;
border-radius: 24rpx;
font-weight: 500;
font-size: 26rpx;
color: #ffffff;
padding: 6rpx 30rpx;
}
}
}
> view + view {
border-top: 1px solid rgba(233, 233, 233, 0.76);
}
}
}
</style>

View File

@ -21,7 +21,8 @@
</view> </view>
<view class="op-box"> <view class="op-box">
<view class="btn" @click="edit(item)"> 编辑 </view> <view class="btn" @click="edit(item)"> 编辑 </view>
<view class="btn" @click="deleteCustomer(item)"> 删除 </view> <view class="btn" @click="deleteCustomer(item)"> 下线
</view>
</view> </view>
</view> </view>
</view> </view>

View File

@ -426,9 +426,9 @@ const appList = reactive([
icon: "15.png", icon: "15.png",
title: "权限管理", title: "权限管理",
fn: () => { fn: () => {
// uni.navigateTo({ uni.navigateTo({
// url: "/pagesApp/supplierMgt", // url: "/pagesApp/role", //
// }); });
}, },
}, },
{ {

View File

@ -409,7 +409,7 @@ const save = () => {
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 56, 93, 0.12); box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 56, 93, 0.12);
border-radius: 13rpx 13rpx 0rpx 0rpx; border-radius: 13rpx 13rpx 0rpx 0rpx;
padding: 25rpx 50rpx; padding: 25rpx 50rpx;
position: fixed; position: sticky;
bottom: 0rpx; bottom: 0rpx;
z-index: 999; z-index: 999;
::v-deep button { ::v-deep button {

View File

@ -72,10 +72,11 @@ export const updateRole = (data: {
}; };
// 查询角色列表 // 查询角色列表
export const getRoleList = () => { export const getRoleList = (data: any) => {
return http({ return http({
method: "GET", method: "GET",
url: "/api/role/getRoleList", url: "/api/role/getRoleList",
data
}); });
}; };

View File

@ -32,6 +32,6 @@ body {
} }
.u-action-sheet > view:nth-child(2) { .u-action-sheet > view:nth-child(2) {
height: 600rpx; max-height: 600rpx;
overflow-y: auto; overflow-y: auto;
} }