This commit is contained in:
2024-09-10 10:49:08 +08:00
parent b5fd06b800
commit dd4f5938da
6391 changed files with 722800 additions and 0 deletions

View File

@@ -0,0 +1,322 @@
<template>
<JeepayBackground>
<view class="page-wrapper jeepay-edit-form">
<JeepayCustomNavbar :title="vdata.sysUserId ? '修改' : '创建' " backCtrl="back" />
<uni-forms ref="formRef" :rules="rules" :model="vdata.formData" :label-width="140">
<uni-forms-item required label="姓名" name="realname">
<uni-easyinput v-model="vdata.formData.realname" placeholder="请输入姓名" :inputBorder="false"></uni-easyinput>
</uni-forms-item>
<uni-forms-item v-if="!vdata.sysUserId" required label="登录用户名" name="loginUsername">
<uni-easyinput v-model="vdata.formData.loginUsername" placeholder="6-18位字母开头且不包含符号" :inputBorder="false"></uni-easyinput>
</uni-forms-item>
<uni-forms-item required label="手机号" name="telphone">
<uni-easyinput v-model="vdata.formData.telphone" placeholder="请输入手机号" :inputBorder="false"></uni-easyinput>
</uni-forms-item>
<uni-forms-item required label="编号">
<uni-easyinput v-model="vdata.formData.userNo" placeholder="请输入用户编号" :inputBorder="false"></uni-easyinput>
</uni-forms-item>
<uni-forms-item required label="性别" name="sex">
<JeepayRadioPopupView label="请选择性别" v-model:value="vdata.formData.sex" :list="[{ label: '男', value: 1}, { label: '女', value: 2}]">
</JeepayRadioPopupView>
</uni-forms-item>
<view class="line"></view>
<!-- -->
<uni-forms-item required v-if="showUserType()" label="类型" name="userType">
<JeepayRadioPopupView label="请选择用户类型" v-model:value="vdata.formData.userType" :list="appendUserTypeList()" @change="changeUserTypeFunc">
</JeepayRadioPopupView>
</uni-forms-item>
<!-- 选择用户类型后需要显示当前已绑定的门店列表 -->
<uni-forms-item v-if="vdata.formData.userType && vdata.formData.userType != 1" required label="绑定门店" name="storeList">
<template #label>
<view class="f-label">绑定门店</view>
</template>
<view class="selected-sex" @tap="showStoreFunc">
<view class="selected-box">
<view v-for="(item) in vdata.selectedStoreList">{{item.storeName}} - {{item.storeId}}</view>
</view>
<image src="/pageDevice/static/devIconImg/icon-arrow-sex.svg" mode="scaleToFill" />
</view>
</uni-forms-item>
<view class="line"></view>
<uni-forms-item v-if="!vdata.sysUserId" required label="密码设置" name="pwdDefaultByPage">
<JeepayRadioPopupView label="请选择密码设置类型" v-model:value="vdata.formData.pwdDefaultByPage" :list="[{ label: '默认密码', value: 1}, { label: '自定义密码', value: 0}]">
</JeepayRadioPopupView>
</uni-forms-item>
<uni-forms-item v-if="vdata.formData.pwdDefaultByPage == 0" required label="自定义密码" name="loginPassword">
<uni-easyinput v-model="vdata.formData.loginPassword" placeholder="请输入自定义密码" :inputBorder="false"></uni-easyinput>
</uni-forms-item>
<view class="line"></view>
</uni-forms>
<template v-if="!vdata.sysUserId">
<JeepayTableListItem title="状态" subtitle="状态禁用后用户将无法登录APP和后台管理系统">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.formData.state" :showSwitchType="true" :confirm='false' />
</template>
</JeepayTableListItem>
<JeepayTableListItem title="开通提醒" subtitle="启用后,用户创建完成时,将发送开通提醒短信至用户手机号">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.formData.isNotify" :showSwitchType="true" :confirm='false' />
</template>
</JeepayTableListItem>
</template>
<view class="confirm-wrapper">
<view class="confirm-button flex-center" hover-class="touch-button" @tap="confirmFunc"> {{ vdata.sysUserId ? '确认修改' : '确认创建' }}</view>
</view>
</view>
<!-- 选择门店, 店长支持多选 -->
<JeepayPopupListSelect
ref="storeSelectRef"
:reqTableDataFunc="reqTableDataByStoreFunc"
:isCheckbox="vdata.formData.userType == 11"
searchInputName="storeName"
:fields="{ key: 'storeId', left: 'storeName', right: 'storeId' }"
/>
</JeepayBackground>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { $getPasswordRules, reqLoad, API_URL_SYS_USER_LIST, API_URL_MCH_STORE_LIST, API_URL_USER_BIND_STORE_LIST,$getBindStoreList } from '@/http/apiManager.js'
import infoBox from '@/commons/utils/infoBox.js';
import go from '@/commons/utils/go.js'
import formUtil from '@/commons/utils/formUtil.js'
import emit from '@/commons/utils/emit.js'
import storageManage from '@/commons/utils/storageManage.js'
const formRef = ref()
const storeSelectRef = ref()
onLoad((options) => {
// test() // 本地测试。
// 获取密码规则
$getPasswordRules().then(({bizData}) => {
vdata.passwordRules = bizData
})
// 修改页面
if(options.sysUserId){
vdata.sysUserId = options.sysUserId
reqLoad.getById(API_URL_SYS_USER_LIST, vdata.sysUserId).then(({bizData}) => {
vdata.formData = bizData
// 查询已绑定门店
reqLoad.list(API_URL_USER_BIND_STORE_LIST, {sysUserId: options.sysUserId, pageSize: -1}).then((storeRes) => {
vdata.selectedStoreList = storeRes.bizData.records
})
})
}
})
const rules = {
realname: {
rules:[ formUtil.rules.requiredInput() ],
},
loginUsername: {
rules:[ formUtil.rules.requiredInput(), formUtil.rules.patternRule('登录用户名', formUtil.regexp.loginUsername) ],
},
telphone: {
rules:[ formUtil.rules.requiredInput(), formUtil.rules.patternRule('联系人电话', formUtil.regexp.mobile) ],
},
sex: {
rules:[ formUtil.rules.requiredSelect('性别', 'number') ],
},
userType: {
rules:[ formUtil.rules.requiredSelect('用户类型', 'number') ],
},
pwdDefaultByPage: {
rules:[ formUtil.rules.requiredSelect('密码类型', 'number') ],
},
loginPassword: {
rules:[{ format: 'string', required: true, errorMessage: '请输入密码', validateFunction: function(rule,value,data,callback){
if(!new RegExp(vdata.passwordRules.regexpRules).test(value)){
callback(vdata.passwordRules.errTips)
return false;
}
return true;
}
}],
}
}
const vdata = reactive({
sysUserId: null, // 新建 or 修改
// 表单数据
formData: {
state: 1,
isNotify: 0,
pwdDefaultByPage: undefined, // 1-默认, 0-自定义 注意, 前端的值, 后端无需该字段
},
passwordRules: { }, // 密码验证规则
selectedStoreList: [], // 选择的门店
})
// 切换用户类型后, 绑定的门店取消。
function changeUserTypeFunc(){
vdata.selectedStoreList = []
}
function reqTableDataByStoreFunc(params) {
params.userType = vdata.formData.userType
return $getBindStoreList(params)
}
function showStoreFunc(){
// 选择门店
storeSelectRef.value.open().then((selected) => {
vdata.selectedStoreList = []
if(selected){
vdata.selectedStoreList = vdata.formData.userType == 11 ? selected : [selected]
}
storeSelectRef.value.close() //自行关闭
})
}
function confirmFunc(){
formUtil.validate(formRef.value).then(() => {
// 超管, 必须选择门店。
if(vdata.formData.userType != 1 && vdata.selectedStoreList.length <= 0){
infoBox.showToast("请选择绑定门店")
return Promise.reject()
}
// 处理选择门店
let reqData = Object.assign({}, vdata.formData)
let storeIdList = []
vdata.selectedStoreList.forEach(r => storeIdList.push(r.storeId) )
reqData.storeIdList = storeIdList.join() // 后端需要是 逗号拼接类型。
// 处理 密码
if(vdata.formData.pwdDefaultByPage == 1){
reqData.loginPassword = ""
}
return reqLoad.addOrUpdate(vdata.sysUserId, API_URL_SYS_USER_LIST, reqData)
})
.then(( {bizData} ) => {
emit.pageEmit(emit.ENAME_REF_SYS_USER_LIST) // 更新列表
go.back(1, emit.ENAME_REF_SYS_USER_DETAIL) // 返回详情 && 更新详情
})
}
function appendUserTypeList(){
// 店长 && 新增
if(storageManage.userInfo().userType == 11){
return [{ label: '店员', value: 12}]
}
return [{ label: '超级管理员', value: 1}, { label: '店长', value: 11}, { label: '店员', value: 12}]
}
function showUserType(){
// 新增页面都显示
if(!vdata.sysUserId){
return true;
}
// 店长 && 修改 不显示
if(storageManage.userInfo().userType == 11){
return false;
}
}
function test(){
let time = new Date().getTime()
vdata.formData.realname = '张三'
vdata.formData.loginUsername = 'A'+ time
vdata.formData.telphone = ('12' + time + '').substring(0, 11)
vdata.formData.userNo = 'A'+ time
vdata.formData.sex = 1
vdata.formData.userType = 12
vdata.formData.pwdDefaultByPage = 1
}
</script>
<style lang="scss" scoped>
input {
font-size: 32rpx;
}
.f-label {
width: 240rpx;
}
.selected-sex {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-top: 45rpx;
margin-bottom: 10rpx;
font-size: 32rpx;
color: #b3b3b3;
image {
width: 120rpx;
height: 120rpx;
margin-top: -40rpx;
}
.selected-box {
color: #000;
}
}
.confirm-wrapper {
padding: 50rpx 30rpx;
.confirm-button {
height: 110rpx;
color: #fff;
border-radius: 20rpx;
background: $jeepay-bg-primary;
}
}
</style>

View File

@@ -0,0 +1,249 @@
<template>
<JeepayBackground :bgColorStyle="{}">
<JeepayCustomNavbar textColor="#fff" bgDefaultColor="linear-gradient(270deg, rgba(72, 192, 255, 1) 0%, rgba(51, 157, 255, 1) 100%)" title="详情" backCtrl="back" />
<view class="sta-info">
<image class="sta-photo" :src="vdata.record.avatarUrl" mode="scaleToFill" />
<view class="info-main">
<view class="info-name">
{{ vdata.record.realname }}
<image src="/pageDevice/static/devIconImg/icon-more-white.svg" mode="scaleToFill" @tap="single.open('delete')" />
</view>
<view class="info-phone">{{ vdata.record.telphone }}</view>
</view>
</view>
<JeepayCard viewStyle="margin-top: 50rpx" editText="编辑信息" @editTap="go.to('PAGES_USER_EDIT', {sysUserId: vdata.record.sysUserId})">
<JeepayDescview>
<JeepayDescviewItem title="用户ID" :desc="vdata.record.sysUserId" />
<JeepayDescviewItem title="完整手机号" :desc="vdata.record.telphone" />
<JeepayDescviewItem title="用户登录名" :desc="vdata.record.loginUsername" />
<JeepayDescviewItem title="用户性别" >
<template #desc>
<view class="sex-info-text">
<template v-if="vdata.record.sex == 1">
<image src="/pageDevice/static/devIconImg/icon-man.svg" mode="scaleToFill" />
</template>
<template v-else-if="vdata.record.sex == 2">
<image src="/pageDevice/static/devIconImg/icon-woman.svg" mode="scaleToFill" />
</template>
<template v-else>
未知
</template>
</view>
</template>
</JeepayDescviewItem>
<JeepayDescviewItem title="用户编号" :desc="vdata.record.userNo" />
<JeepayDescviewItem title="用户类型" >
<template #desc>
<JeepayTag :type="datamap.userType(vdata.record.userType).type">{{ datamap.userType(vdata.record.userType).text }}</JeepayTag>
</template>
</JeepayDescviewItem>
<JeepayDescviewItem title="创建时间" :desc="vdata.record.createdAt" />
</JeepayDescview>
</JeepayCard>
<!-- 仅非超管显示 -->
<JeepayCard v-if="vdata.record.userType != 1" title="已绑定门店" viewStyle="margin-top: 40rpx">
<JeepayDescview>
<template v-for="(r) in vdata.selectedStoreList">
<JeepayDescviewItem :title="r.storeName" :desc="r.storeId" />
</template>
</JeepayDescview>
</JeepayCard>
<JeepayCard title="权限管理" viewStyle="margin-top: 40rpx">
<JeepayTableListItem v-if="ent.has('ENT_UR_USER_EDIT')" title="用户状态" subtitle="状态禁用后用户将无法登录APP和后台管理系统">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.record.state" :showSwitchType="true" :updateStateFunc="updateStateFunc"/>
</template>
</JeepayTableListItem>
<JeepayTableListItem v-if="vdata.record.userType == 11" title="门店编辑权限" subtitle="权限禁用后,该用户将不支持编辑门店信息功能">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.userRules['STORE']" :showSwitchType="true" :updateStateFunc="(state) => updateRuleFunc('STORE', state)"/>
</template>
</JeepayTableListItem>
<JeepayTableListItem v-if="vdata.record.userType == 12" title="收银权限" subtitle="权限禁用后,该用户将不支持快捷收银功能">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.userRules['QUICK_PAY']" :showSwitchType="true" :updateStateFunc="(state) => updateRuleFunc('QUICK_PAY', state)"/>
</template>
</JeepayTableListItem>
<JeepayTableListItem v-if="vdata.record.userType == 12" title="订单退款权限" subtitle="权限禁用后,该用户将不支持订单退款操作">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.userRules['REFUND']" :showSwitchType="true" :updateStateFunc="(state) => updateRuleFunc('REFUND', state)"/>
</template>
</JeepayTableListItem>
<JeepayTableListItem v-if="vdata.record.userType == 12" title="设备管理权限" subtitle="权限禁用后,该用户将不支持门店设备管理功能">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.userRules['DEVICE']" :showSwitchType="true" :updateStateFunc="(state) => updateRuleFunc('DEVICE', state)"/>
</template>
</JeepayTableListItem>
<JeepayTableListItem v-if="vdata.record.userType == 12" title="统计报表权限" subtitle="权限禁用后,该用户将不支持查看门店统计报表数据">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.userRules['STATS']" :showSwitchType="true" :updateStateFunc="(state) => updateRuleFunc('STATS', state)"/>
</template>
</JeepayTableListItem>
</JeepayCard>
<JSinglePopup ref="single" :list="list" activeColor="#FF5B4C" />
<JeepayPopupConfirm ref="jeepayPopupConfirmRef" />
</JeepayBackground>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import { reqLoad, API_URL_SYS_USER_LIST, API_URL_USER_BIND_STORE_LIST, $getUserEntRoles, $updateUserEntRoles } from '@/http/apiManager.js'
import datamap from '@/commons/utils/datamap.js'
import infoBox from '@/commons/utils/infoBox.js';
import go from '@/commons/utils/go.js'
import formUtil from '@/commons/utils/formUtil.js'
import emit from '@/commons/utils/emit.js'
import ent from '@/commons/utils/ent.js'
const single = ref()
const jeepayPopupConfirmRef = ref()
const list = reactive([
{ label: '删除用户', value: 'delete', fun: confirmFunc},
])
onLoad((options) => {
refData(options.sysUserId)
})
const vdata = reactive({
record : { },
selectedStoreList: [],
// 用户权限集合
userRules: {
"STORE": 0, "QUICK_PAY": 0, "REFUND": 0, "DEVICE": 0, "STATS": 0,
},
})
// 监听 更新事件
onUnload(() => uni.$off(emit.ENAME_REF_SYS_USER_DETAIL))
uni.$on(emit.ENAME_REF_SYS_USER_DETAIL, function(data){
refData(vdata.record.sysUserId)
})
function refData(sysUserId){
reqLoad.getById(API_URL_SYS_USER_LIST, sysUserId).then(({bizData}) => {
vdata.record = bizData
vdata.selectedStoreList = []
// 店长 or 店员。 查询权限
if(bizData.userType == 11 || bizData.userType == 12){
// 查询已绑定门店
reqLoad.list(API_URL_USER_BIND_STORE_LIST, {sysUserId: sysUserId, pageSize: -1}).then((storeRes) => {
vdata.selectedStoreList = storeRes.bizData.records
})
$getUserEntRoles(sysUserId).then(roleRes => {
let roleBizData = roleRes.bizData;
if(roleBizData && roleBizData.rules){
let ruleList = JSON.parse(roleBizData.rules)
Object.keys(vdata.userRules).forEach(k => {
vdata.userRules[k] = ruleList.indexOf(k) >= 0 ? 1: 0
})
}
})
}
})
}
function updateStateFunc(state){
return reqLoad.updateById(API_URL_SYS_USER_LIST, vdata.record.sysUserId, { state: state }).then(() => {
emit.pageEmit(emit.ENAME_REF_SYS_USER_LIST)
infoBox.showSuccessToast("修改成功");
})
}
// 修改用户权限。
function updateRuleFunc(ruleName, state){
return $updateUserEntRoles(vdata.record.sysUserId, ruleName, state).then(() => {
infoBox.showSuccessToast("修改成功",{mask:false});
})
}
function confirmFunc() {
jeepayPopupConfirmRef.value.open('确定删除用户?').then(() => {
deleteFunc()
}).catch(() => {
single.value.open('delete')
})
}
function deleteFunc(){
return reqLoad.delById(API_URL_SYS_USER_LIST, vdata.record.sysUserId).then(() => {
infoBox.showSuccessToast("删除成功");
go.back(1, emit.ENAME_REF_SYS_USER_LIST) // 返回页面 && 更新
})
}
</script>
<style lang="scss" scoped>
.sex-info-text {
image {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
}
.sta-info {
display: flex;
margin-top: 50rpx;
padding: 0 50rpx;
.sta-photo {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
image {
width: 100%;
height: 100%;
}
}
.info-main {
flex: 1;
margin-left: 30rpx;
color: #fff;
.info-name {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 33rpx;
font-weight: 400;
image {
width: 70rpx;
height: 70rpx;
}
}
.info-phone {
margin-top: 16rpx;
color: rgba(251, 252, 253, 0.7);
font-size: 25rpx;
font-weight: 400;
}
}
}
</style>

View File

@@ -0,0 +1,109 @@
<template>
<view class="page-wrapper">
<JeepayCustomNavbar title="成员管理" backCtrl="back" />
<view class="sta-input" @tap="go.toSearchPage('sysUser')">
<view class="input-main">
<image src="/static/iconImg/icon-search.svg" mode="scaleToFill" />
搜索成员姓名
</view>
<!-- <image class="icon-more" src="/static/iconImg/icon-more.svg" mode="scaleToFill" /> -->
</view>
<JeepayTableList ref="jeepayTableListRef" :reqTableDataFunc="reqTableDataFunc">
<template #tableBody="{ record }">
<SysUserRender :record="record" />
</template>
</JeepayTableList>
<view class="footer-wrapper">
<view class="footer-button footer-button-style">
<button hover-class="hover-button" hover-stay-time="150" class="flex-center" @tap="createStaff">创建</button>
</view>
</view>
</view>
<JeepayPopupConfirm ref="jeepayPopupConfirmRef" />
</template>
<script setup>
import { nextTick, reactive, ref } from 'vue';
import { onReachBottom, onShow, onUnload } from '@dcloudio/uni-app';
import go from '@/commons/utils/go.js';
import emit from '@/commons/utils/emit.js';
import { reqLoad, API_URL_SYS_USER_LIST } from '@/http/apiManager.js';
import SysUserRender from '@/pages/list/render/SysUserRender.vue';
const jeepayTableListRef = ref();
const jeepayPopupConfirmRef = ref();
onReachBottom(() => {});
// // 监听 更新事件
onUnload(() => uni.$off(emit.ENAME_REF_SYS_USER_LIST));
uni.$on(emit.ENAME_REF_SYS_USER_LIST, function (data) {
jeepayTableListRef.value.refTable(true);
});
// 请求
function reqTableDataFunc(params) {
// 不查询普通用户
params.isNotHasType2 = 1;
return reqLoad.list(API_URL_SYS_USER_LIST, params);
}
// 创建员工
const createStaff = () => {
go.to('PAGES_USER_EDIT');
};
</script>
<style lang="scss" scoped>
.sta-input {
display: flex;
align-items: center;
padding: 0 30rpx;
height: 110rpx;
background-color: $J-bg-ff;
.input-main {
flex: 1;
display: flex;
align-items: center;
height: 70rpx;
background-color: $J-bg-f5;
border-radius: $J-b-r12;
color: rgba(0, 0, 0, 0.35);
font-size: 27rpx;
font-weight: 400;
image {
padding: 22rpx;
width: 26rpx;
height: 26rpx;
}
}
.icon-more {
margin-left: 30rpx;
width: 70rpx;
height: 70rpx;
}
}
.footer-wrapper {
height: 170rpx;
background-color: transparent;
.footer-button {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 30rpx;
button {
height: 110rpx;
font-size: 33rpx;
font-weight: 500;
color: $J-color-tff;
border-radius: 20rpx;
background: $jeepay-bg-primary;
}
.hover-button {
opacity: 0.5;
}
}
}
</style>