代码更新
This commit is contained in:
@@ -25,21 +25,25 @@
|
||||
<view>
|
||||
<text style="color: red;">*</text>员工账号
|
||||
</view>
|
||||
<input type="text" v-model="datas.formData.account" placeholder="请填写员工账号,建议使用手机号" />
|
||||
<input type="text" v-model="datas.formData.accountName" placeholder="请填写员工账号,建议使用手机号" />
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
登录密码
|
||||
</view>
|
||||
<input type="text" v-model="datas.formData.password" placeholder="请输入登录密码,不填写默认123456" />
|
||||
<view style="margin: 24rpx 0;display: flex;justify-content: space-between;align-items: center;">
|
||||
<input type="text" v-model="datas.formData.accountPwd" @change="datas.isPassword = true" placeholder="请输入登录密码,不填写默认123456" />
|
||||
<view style="color: #2979ff;" @click="datas.isPassword = true">重置密码</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view>
|
||||
<view>
|
||||
<view style="margin-bottom: 24rpx;">
|
||||
优惠类型
|
||||
</view>
|
||||
<up-radio-group v-model="datas.formData.discountType" placement="row">
|
||||
<up-radio label="折扣" name="1"></up-radio>
|
||||
<up-radio style="margin: 18px 10px;" label="金额" name="0"></up-radio>
|
||||
<up-radio-group v-model="datas.formData.discountType" placement="row" >
|
||||
<up-radio label="折扣" name="1"></up-radio>
|
||||
<up-radio label="金额" name="0"></up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
<view>
|
||||
@@ -55,11 +59,11 @@
|
||||
<view>
|
||||
<text style="color: red;">*</text> 角色
|
||||
</view>
|
||||
<view @tap="show=true" style="height: 50rpx;font-size: 28rpx;color: #999999;">{{datas.rolesdata }}</view>
|
||||
<view @tap="show=true" style="height: 50rpx;font-size: 28rpx;color: #999999;margin-top: 24rpx;">{{datas.rolesdata }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="h7">员工权限设置</view>
|
||||
<view class="contentBottom" v-for="item in datas.formData.permissions" :key="item.id">
|
||||
<view class="contentBottom" v-for="item in datas.permissions" :key="item.id">
|
||||
<view>
|
||||
{{item.label}}
|
||||
</view>
|
||||
@@ -73,9 +77,7 @@
|
||||
<view class="bottomBotton" @tap="sumbitEvent">
|
||||
保存
|
||||
</view>
|
||||
<!-- <view class="bottomBotton2" @tap="toUrl">
|
||||
取消
|
||||
</view> -->
|
||||
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
<!-- 角色选择器 -->
|
||||
@@ -97,12 +99,10 @@
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
tbShopPermissionList,
|
||||
getroles,
|
||||
tbPlussShopStaff,
|
||||
tbPlussShopStaffDetail
|
||||
} from "@/http/yskApi/requestAll.js"
|
||||
|
||||
import { shopStaffDetail,getShopStaffPermission,shopStaffAdd,shopStaffPut } from "@/api/staff.js"
|
||||
import { getShopPermission } from "@/api/index.js"
|
||||
import { getRoleList } from "@/api/role.js"
|
||||
const currentInstance = getCurrentInstance()
|
||||
const props = defineProps({
|
||||
type: {
|
||||
@@ -114,11 +114,13 @@
|
||||
})
|
||||
let datas = reactive({
|
||||
formData: {
|
||||
permissions: [],
|
||||
shopPermissionIds: [],
|
||||
maxDiscountAmount: 0,
|
||||
discountType: 0
|
||||
},
|
||||
isPassword: false,
|
||||
rolesList: [],
|
||||
permissions: [],
|
||||
columns: [],
|
||||
rolesdata: '请选择角色'
|
||||
})
|
||||
@@ -127,26 +129,79 @@
|
||||
]);
|
||||
const show = ref(false)
|
||||
onShow(() => {
|
||||
|
||||
|
||||
init()
|
||||
})
|
||||
|
||||
async function init () {
|
||||
// 获取角色信息
|
||||
getrolesEvent()
|
||||
|
||||
})
|
||||
|
||||
function gettbPlussShopStaffDetail(id) {
|
||||
tbPlussShopStaffDetail(id).then(res => {
|
||||
//获取权限列表
|
||||
let res = await getShopPermission()
|
||||
datas.permissions = res
|
||||
if (props.type == 'edit') {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑员工'
|
||||
})
|
||||
// 调用id查询接口和编辑接口
|
||||
getShopStaffDetail(props.id)
|
||||
getStaffPermission(props.id)
|
||||
} else {
|
||||
datas.isPassword = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色列表
|
||||
*/
|
||||
function getrolesEvent() {
|
||||
getRoleList({page: 1,size: 999}).then((res) => {
|
||||
datas.rolesList = res.records
|
||||
res.records.forEach(ele => {
|
||||
columns[0].push(ele.name)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色列表
|
||||
*/
|
||||
function getStaffPermission(id) {
|
||||
getShopStaffPermission({id: id}).then((res2) => {
|
||||
|
||||
datas.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
console.log(res)
|
||||
res2.forEach(v => {
|
||||
if (res.id == v ) {
|
||||
res.hasPermission = 1
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
console.log(datas.permissions)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户详情
|
||||
* @param {Object} id
|
||||
*/
|
||||
function getShopStaffDetail(id) {
|
||||
shopStaffDetail({id:id}).then(res => {
|
||||
datas.formData = res
|
||||
if (datas.rolesList) {
|
||||
let rolefilter = datas.rolesList.filter(ele => ele.id == res.roleId)
|
||||
datas.rolesdata = rolefilter[0].name
|
||||
|
||||
console.log(res, '编辑员工后的提示')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sumbitEvent() {
|
||||
async function sumbitEvent() {
|
||||
// 效验
|
||||
if (!datas.formData.name || !datas.formData.phone || !datas.formData.code || !datas.formData.account) {
|
||||
if (!datas.formData.name || !datas.formData.phone || !datas.formData.code || !datas.formData.accountPwd) {
|
||||
currentInstance.ctx.$refs.uToastRef.show({
|
||||
message: "请填写必填项",
|
||||
type: 'default',
|
||||
@@ -160,27 +215,34 @@
|
||||
return
|
||||
}
|
||||
datas.formData.roleId = rolesId[0].id
|
||||
datas.formData.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
if (res.hasPermission) {
|
||||
res.hasPermission = 1
|
||||
}
|
||||
if(datas.permissions){
|
||||
datas.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
if (res.hasPermission) {
|
||||
res.hasPermission = 1
|
||||
datas.formData.shopPermissionIds.push(res.id)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
tbPlussShopStaff({
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
...datas.formData
|
||||
}).then(res => {
|
||||
go.back()
|
||||
})
|
||||
}
|
||||
|
||||
function getList() {
|
||||
tbShopPermissionList().then((res) => {
|
||||
datas.formData.permissions = res
|
||||
})
|
||||
}
|
||||
if ( !datas.isPassword ) {
|
||||
delete datas.formData.accountPwd;
|
||||
}
|
||||
let res;
|
||||
if( props.type == 'add'){
|
||||
res = await shopStaffAdd({...datas.formData})
|
||||
} else {
|
||||
res = await shopStaffPut({...datas.formData})
|
||||
}
|
||||
go.back()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 优惠金额限制
|
||||
* @param {Object} d
|
||||
*/
|
||||
function maxdisinput(d) {
|
||||
let num = d.detail.value * 1
|
||||
if (num >= 1) {
|
||||
@@ -190,32 +252,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getrolesEvent() {
|
||||
getroles().then((res) => {
|
||||
datas.rolesList = res.content
|
||||
res.content.forEach(ele => {
|
||||
columns[0].push(ele.name)
|
||||
})
|
||||
if (props.type == 'add') {
|
||||
getList()
|
||||
} else {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑员工'
|
||||
})
|
||||
// 调用id查询接口和编辑接口
|
||||
gettbPlussShopStaffDetail(props.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色选择
|
||||
* @param {Object} e
|
||||
*/
|
||||
function confirm(e) {
|
||||
datas.rolesdata = e.value[0]
|
||||
show.value = false
|
||||
}
|
||||
|
||||
function toUrl() {
|
||||
go.to('PAGES_STAFF')
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
page {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="liststyle">
|
||||
<view v-for="item in datas.list " :key="item.id">
|
||||
<view v-for="item in pageData.list " :key="item.id">
|
||||
<view class="">
|
||||
<view class="">
|
||||
<span style="font-size: 28rpx;color: #333333; ">{{item.name}} </span>
|
||||
@@ -13,12 +13,12 @@
|
||||
<view class="">
|
||||
<view style="display: flex;justify-content: center;align-items: center;">
|
||||
<span style="font-size: 28rpx;color: #999999;">是否启用</span>
|
||||
<up-switch :activeValue="1" :inactiveValue="0" v-model="item.status" size="18"
|
||||
<up-switch :activeValue="true" :inactiveValue="false" v-model="item.status" size="18"
|
||||
@change="switch2Change($event,item)"></up-switch>
|
||||
</view>
|
||||
<view class="df">
|
||||
<up-button size="small" shape="circle" style="border-radius: 28rpx 28rpx 28rpx 28rpx;"
|
||||
@tap="datas.show = true;datas.rolesId=item.id" text="删除"></up-button>
|
||||
@tap="pageData.show = true;pageData.rolesId=item.id" text="删除"></up-button>
|
||||
<up-button type="primary" shape="circle" plain size="small"
|
||||
style="border-radius: 28rpx 28rpx 28rpx 28rpx;margin-left: 16rpx;" @tap="toUrl(item)"
|
||||
text="编辑"></up-button>
|
||||
@@ -27,7 +27,7 @@
|
||||
</view>
|
||||
<view style="background-color: rgba(0,0,0,0);"></view>
|
||||
</view>
|
||||
<view v-if="datas.list.length==0" style="text-align: center;">
|
||||
<view v-if="pageData.list.length==0" style="text-align: center;">
|
||||
<image src="./bg.png" style="width: 325rpx;height: 335rpx;" mode=""></image>
|
||||
<view style="font-size: 28rpx;color: #999;">暂无员工</view>
|
||||
</view>
|
||||
@@ -35,50 +35,72 @@
|
||||
添加员工
|
||||
</view>
|
||||
<!-- 删除确认框 -->
|
||||
<up-modal :show="datas.show" contentTextAlign="center" showCancelButton @confirm='delTableHandle'
|
||||
@cancel='datas.show=false' content='是否确认删除?'></up-modal>
|
||||
<up-modal :show="pageData.show" contentTextAlign="center" showCancelButton @confirm='delTableHandle'
|
||||
@cancel='pageData.show=false' content='是否确认删除?'></up-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
onShow
|
||||
} from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch, onMounted } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
rolesGet,
|
||||
shopStaffDelete,
|
||||
updateStatus
|
||||
} from "@/http/yskApi/requestAll.js"
|
||||
let datas = reactive({
|
||||
list: [],
|
||||
import { shopStaffList,shopStaffDel,shopStaffPut } from "@/api/staff.js"
|
||||
|
||||
let pageData = reactive({
|
||||
show: false,
|
||||
// 删除员工id
|
||||
rolesId: ""
|
||||
list: [],
|
||||
rolesId: "" // 删除员工id
|
||||
})
|
||||
onShow(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 获取员工列表
|
||||
*/
|
||||
function getList() {
|
||||
shopStaffList({
|
||||
page: 0,
|
||||
size: 100
|
||||
}).then((res) => {
|
||||
pageData.list = res.records
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 员工状态修改
|
||||
* @param {Object} e
|
||||
* @param {Object} d
|
||||
*/
|
||||
function switch2Change(e, d) {
|
||||
shopStaffPut({
|
||||
id: d.id,
|
||||
status: e
|
||||
}).then(res => {
|
||||
setTimeout(() => {
|
||||
getList()
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工
|
||||
*/
|
||||
function delTableHandle() {
|
||||
shopStaffDelete(
|
||||
[datas.rolesId]
|
||||
)
|
||||
datas.show = false
|
||||
shopStaffDel({id:pageData.rolesId})
|
||||
pageData.show = false
|
||||
setTimeout(() => {
|
||||
getList()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
/**
|
||||
* 前往新增/修改
|
||||
* @param {Object} d
|
||||
*/
|
||||
function toUrl(d) {
|
||||
if (d.id) {
|
||||
go.to('PAGES_ADD_STAFF', {
|
||||
type: '',
|
||||
type: 'edit',
|
||||
id: d.id
|
||||
})
|
||||
} else {
|
||||
@@ -88,26 +110,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
function switch2Change(e, d) {
|
||||
updateStatus({
|
||||
id: d.id,
|
||||
status: e
|
||||
}).then(res => {
|
||||
setTimeout(() => {
|
||||
getList()
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
function getList() {
|
||||
rolesGet({
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
page: 0,
|
||||
size: 100
|
||||
}).then((res) => {
|
||||
datas.list = res.content
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
page {
|
||||
@@ -115,13 +119,6 @@
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped>
|
||||
// * {
|
||||
// padding: 0;
|
||||
// margin: 0;
|
||||
// text-decoration: none;
|
||||
// outline: none;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user