新增用户角色切换、订单复核

This commit is contained in:
zm2000 2026-05-16 17:59:39 +08:00
parent c8a229fb32
commit f1ec04c102
4 changed files with 633 additions and 61 deletions

View File

@ -3,19 +3,26 @@
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录"
"titleNView": false
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app"
"titleNView": false
}
},
{
"path": "pages/order/index",
"style": {
"titleNView": false,
"navigationBarTitleText": "订单复核1"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarTitleText": "wms_worker_station",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
}

View File

@ -2,15 +2,64 @@
<view class="page" @click="closeMinePopup">
<view class="top-nav" @click.stop>
<image class="top-nav-logo" src="http://192.168.11.56:5174/public/logo/1.png" mode="heightFix"></image>
<view class="top-nav-menu-wrap" v-if="getTopMenus().length">
<view
v-for="menu in getTopMenus()"
:key="menu.path || menu.name"
:class="['top-nav-menu-item', isMenuActive(menu) ? 'top-nav-menu-item--active' : '']"
@click="handleMenuClick(menu)"
>
<text class="top-nav-menu-text">{{ getMenuTitle(menu) }}</text>
</view>
</view>
<view class="top-nav-right">
<text class="top-nav-mine" @click="openMinePopup">我的</text>
<view class="top-nav-mine" @click="openMinePopup">
<view class="top-nav-mine-icon" aria-hidden="true">
<view class="top-nav-mine-icon-head"></view>
<view class="top-nav-mine-icon-body"></view>
</view>
<text class="top-nav-mine-name">{{ getTopNavRealName() }}</text>
</view>
<view v-if="showMinePopup" class="popup-card" @click.stop>
<view class="popup-user-info" v-if="currentUser && currentUser.employees && currentUser.employees.length">
<view
v-for="employee in currentUser.employees"
:key="employee.id"
:class="['popup-user-item', isCurrentRole(employee) ? 'popup-user-item--current' : '']"
@click="handleChangeRole(employee)"
>
<text class="popup-user-text">{{ employee.store_name }} | {{ employee.real_name }}</text>
</view>
</view>
<button class="logout-btn" type="warn" @click="handleLogout">退出登录</button>
<button class="close-btn" @click="closeMinePopup">关闭</button>
</view>
</view>
</view>
<view class="content-wrap" v-if="activeMenuPath === '/order'">
<view class="order-module">
<view class="order-search-bar">
<input
class="order-search-input"
v-model="orderKeyword"
placeholder="请输入订单号/客户名"
confirm-type="search"
@confirm="handleOrderSearch"
/>
<button class="order-search-btn" type="primary" @click="handleOrderSearch">搜索</button>
</view>
<view class="order-result-list">
<view v-if="displayOrders.length === 0" class="order-empty">暂无匹配订单</view>
<view v-else v-for="order in displayOrders" :key="order.orderNo" class="order-item">
<text class="order-item-text">订单号:{{ order.orderNo }}</text>
<text class="order-item-text">客户:{{ order.customer }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
@ -22,20 +71,190 @@ export default {
uni.reLaunch({
url: '/pages/login/login',
})
return
}
this.loadCurrentUserInfo(token)
},
data() {
return {
showMinePopup: false,
currentUser: null,
activeMenuPath: '',
orderKeyword: '',
displayOrders: [],
allOrders: [
{ orderNo: 'ORD20260516001', customer: '张三' },
{ orderNo: 'ORD20260516002', customer: '李四' },
{ orderNo: 'ORD20260516003', customer: '王五' },
],
}
},
methods: {
getTopMenus() {
const menus = this.currentUser?.menus
if (!Array.isArray(menus)) {
return []
}
return menus.filter((menu) => !menu?.hidden)
},
getMenuTitle(menu) {
return menu?.meta?.title || menu?.name || '未命名菜单'
},
normalizeMenuPath(menu) {
const rawPath = (menu?.path || '').trim()
if (!rawPath) {
return ''
}
return rawPath.startsWith('/') ? rawPath : `/${rawPath}`
},
isMenuActive(menu) {
const path = this.normalizeMenuPath(menu)
return !!path && this.activeMenuPath === path
},
handleMenuClick(menu) {
const rawPath = (menu?.path || '').trim()
if (!rawPath) {
uni.showToast({
title: '菜单路径为空',
icon: 'none',
})
return
}
const normalizedPath = this.normalizeMenuPath(menu)
const routeMap = {
'/order': '/pages/order/index',
}
const url = routeMap[normalizedPath] || normalizedPath
if (normalizedPath === '/order') {
this.activeMenuPath = '/order'
this.orderKeyword = ''
this.displayOrders = this.allOrders
return
}
this.activeMenuPath = ''
if (url === '/pages/index/index') {
return
}
uni.navigateTo({
url,
fail: () => {
uni.showToast({
title: '页面跳转失败',
icon: 'none',
})
},
})
},
handleOrderSearch() {
const query = this.orderKeyword.trim().toLowerCase()
if (!query) {
this.displayOrders = this.allOrders
return
}
this.displayOrders = this.allOrders.filter((order) => {
return (
String(order.orderNo || '').toLowerCase().includes(query) ||
String(order.customer || '').toLowerCase().includes(query)
)
})
},
getTopNavRealName() {
const employees = this.currentUser?.employees || []
if (employees.length && employees[0]?.real_name) {
return employees[0].real_name
}
return this.currentUser?.real_name || '未命名用户'
},
isCurrentRole(employee) {
return Number(employee?.is_primary) === 1
},
handleChangeRole(employee) {
const employeeId = employee?.id
const token = uni.getStorageSync('token')
if (!employeeId || !token) {
return
}
uni.request({
url: `http://192.168.11.56:6060/system?method=user.changeRole&v=1.0&timestamp=${Date.now()}`,
method: 'POST',
header: {
accept: 'application/json, text/plain, */*',
'content-type': 'application/json',
platform: 'workerstation',
project: 'warehouse',
token,
Authorization: `Bearer ${token}`,
},
data: {
roleId: employeeId,
device: 'workerstation',
project: 'warehouse',
},
success: (res) => {
const body = res?.data || {}
const isSuccess = body?.code === 0 || body?.success === true || body?.status === 1
if (!isSuccess && (body?.msg || body?.message)) {
uni.showToast({
title: body?.msg || body?.message,
icon: 'none',
})
return
}
this.loadCurrentUserInfo(token)
uni.showToast({
title: '角色切换成功',
icon: 'success',
})
},
fail: () => {
uni.showToast({
title: '角色切换失败',
icon: 'none',
})
},
})
},
openMinePopup() {
this.showMinePopup = true
},
closeMinePopup() {
this.showMinePopup = false
},
loadCurrentUserInfo(token) {
uni.request({
url: `http://192.168.11.56:6060/system?method=user.info&v=1.0&timestamp=${Date.now()}`,
method: 'POST',
header: {
accept: 'application/json, text/plain, */*',
platform: 'workerstation',
project: 'warehouse',
token,
Authorization: `Bearer ${token}`,
},
data: {
device: 'workerstation',
project: 'warehouse',
},
success: (res) => {
const body = res?.data || {}
this.currentUser = body?.data || body?.result || body || null
},
})
},
finishLogout() {
uni.removeStorageSync('token')
uni.showToast({
@ -81,11 +300,10 @@ export default {
min-height: 100vh;
min-width: 960px;
box-sizing: border-box;
padding: 56rpx;
background-color: #2fbf71;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
align-items: stretch;
justify-content: flex-start;
}
@ -95,25 +313,89 @@ export default {
margin: 0 0 24rpx;
padding: 18rpx 28rpx;
box-sizing: border-box;
border-radius: 16rpx;
background-color: #2f7dff;
display: flex;
align-items: center;
justify-content: space-between;
justify-content: flex-start;
position: relative;
}
.top-nav-right {
position: relative;
margin-left: auto;
}
.top-nav-logo {
height: 90rpx;
}
.top-nav-menu-wrap {
display: flex;
align-items: center;
margin-left: 36rpx;
gap: 14rpx;
flex-wrap: wrap;
}
.top-nav-menu-item {
padding: 10rpx 18rpx;
}
.top-nav-menu-item--active {
box-shadow: inset 0 -4rpx 0 #fff;
}
.top-nav-menu-text {
font-size: 32rpx;
color: #fff;
line-height: 1;
}
.top-nav-mine {
font-size: 30rpx;
font-weight: 600;
display: flex;
align-items: center;
gap: 10rpx;
}
.top-nav-mine-icon {
width: 44rpx;
height: 44rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-radius: 999rpx;
background-color: rgba(255, 255, 255, 0.2);
box-sizing: border-box;
}
.top-nav-mine-icon-head {
width: 12rpx;
height: 12rpx;
border: 2rpx solid #fff;
border-radius: 50%;
box-sizing: border-box;
}
.top-nav-mine-icon-body {
width: 20rpx;
height: 10rpx;
margin-top: 4rpx;
border: 2rpx solid #fff;
border-top: none;
border-radius: 0 0 12rpx 12rpx;
box-sizing: border-box;
}
.top-nav-mine-icon,
.top-nav-mine-icon-head,
.top-nav-mine-icon-body {
color: #fff;
}
.top-nav-mine-name {
font-size: 32rpx;
line-height: 1;
color: #fff;
}
@ -130,6 +412,39 @@ export default {
box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.14);
}
.popup-user-info {
margin-bottom: 18rpx;
}
.popup-user-item {
padding: 12rpx 10rpx;
border-bottom: 1rpx solid #eef2f7;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
}
.popup-user-item:last-child {
border-bottom: none;
}
.popup-user-item--current {
background-color: #eef5ff;
border-radius: 8rpx;
}
.popup-user-text {
display: block;
font-size: 24rpx;
color: #333;
line-height: 1.5;
}
.popup-user-item--current .popup-user-text {
color: #2f7dff;
}
.logout-btn,
.close-btn {
width: 100%;
@ -150,10 +465,70 @@ export default {
color: #333;
}
.content-wrap {
padding: 0 28rpx 24rpx;
}
.order-module {
background-color: #fff;
border-radius: 16rpx;
padding: 24rpx;
}
.order-search-bar {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 18rpx;
}
.order-search-input {
flex: 1;
height: 72rpx;
border: 1rpx solid #e5e5e5;
border-radius: 10rpx;
padding: 0 18rpx;
font-size: 28rpx;
}
.order-search-btn {
width: 150rpx;
height: 72rpx;
line-height: 72rpx;
font-size: 26rpx;
}
.order-result-list {
display: flex;
flex-direction: column;
gap: 12rpx;
}
.order-item {
background-color: #fafbfe;
border: 1rpx solid #edf0f5;
border-radius: 10rpx;
padding: 16rpx;
}
.order-item-text {
display: block;
font-size: 26rpx;
color: #333;
line-height: 1.5;
}
.order-empty {
text-align: center;
color: #999;
font-size: 26rpx;
padding: 20rpx 0;
}
@media screen and (max-width: 1024px) {
.page {
min-width: 760px;
padding: 36rpx;
padding: 0;
}
.top-nav {
@ -161,6 +536,19 @@ export default {
padding: 16rpx 20rpx;
}
.top-nav-menu-wrap {
margin-left: 24rpx;
gap: 10rpx;
}
.top-nav-menu-item {
padding: 8rpx 14rpx;
}
.top-nav-menu-text {
font-size: 22rpx;
}
.top-nav-logo {
height: 78rpx;
}
@ -177,5 +565,9 @@ export default {
line-height: 58rpx;
font-size: 24rpx;
}
.content-wrap {
padding: 0 20rpx 18rpx;
}
}
</style>

View File

@ -22,54 +22,56 @@
</view>
</view>
<view v-if="loginMode === 'scan'" class="panel">
<text class="scan-tip-top">打开微信,扫描二维码登录</text>
<view class="scan-box">
<image
v-if="scanQrImage"
class="scan-image"
:src="scanQrImage"
mode="aspectFit"
@error="handleScanImageError"
></image>
<text v-else class="scan-placeholder">{{ scanCode || '二维码区域' }}</text>
<view class="panel-stage">
<view v-show="loginMode === 'scan'" class="panel panel--scan panel--mode">
<text class="scan-tip-top">打开微信,扫描二维码登录</text>
<view class="scan-box">
<image
v-if="scanQrImage"
class="scan-image"
:src="scanQrImage"
mode="aspectFit"
@error="handleScanImageError"
></image>
<text v-else class="scan-placeholder">{{ scanCode || '二维码区域' }}</text>
</view>
<text class="scan-tip-bottom">{{ scanStatus }}</text>
</view>
<text class="scan-tip-bottom">{{ scanStatus }}</text>
</view>
<view v-else class="panel">
<view :class="['input-wrap', focusedField === 'username' ? 'input-wrap--focused' : '']">
<input
class="input input--with-clear"
v-model="form.username"
placeholder="请输入账号"
@focus="handleFocus('username')"
@blur="handleBlur"
/>
<view v-if="form.username" class="clear-trigger" @click="clearField('username')">
<text class="clear-trigger__icon">×</text>
</view>
</view>
<view :class="['password-wrap', focusedField === 'password' ? 'input-wrap--focused' : '']">
<input
class="input password-input"
v-model="form.password"
placeholder="请输入密码"
:password="!showPassword"
@focus="handleFocus('password')"
@blur="handleBlur"
/>
<view v-if="form.password" class="clear-trigger clear-trigger--password" @click="clearField('password')">
<text class="clear-trigger__icon">×</text>
</view>
<view class="toggle-password" @click="togglePassword">
<view class="eye-icon" :class="showPassword ? 'eye-icon--open' : 'eye-icon--closed'">
<view class="eye-pupil"></view>
<view class="eye-lid"></view>
<view v-show="loginMode === 'account'" class="panel panel--account panel--mode">
<view :class="['input-wrap', focusedField === 'username' ? 'input-wrap--focused' : '']">
<input
class="input input--with-clear"
v-model="form.username"
placeholder="请输入账号"
@focus="handleFocus('username')"
@blur="handleBlur"
/>
<view v-if="form.username" class="clear-trigger" @click="clearField('username')">
<text class="clear-trigger__icon">×</text>
</view>
</view>
<view :class="['password-wrap', focusedField === 'password' ? 'input-wrap--focused' : '']">
<input
class="input password-input"
v-model="form.password"
placeholder="请输入密码"
:password="!showPassword"
@focus="handleFocus('password')"
@blur="handleBlur"
/>
<view v-if="form.password" class="clear-trigger clear-trigger--password" @click="clearField('password')">
<text class="clear-trigger__icon">×</text>
</view>
<view class="toggle-password" @click="togglePassword">
<view class="eye-icon" :class="showPassword ? 'eye-icon--open' : 'eye-icon--closed'">
<view class="eye-pupil"></view>
<view class="eye-lid"></view>
</view>
</view>
</view>
<button class="primary-btn" type="primary" @click="handleAccountLogin">登录</button>
</view>
<button class="primary-btn" type="primary" @click="handleAccountLogin">登录</button>
</view>
</view>
</view>
@ -247,7 +249,6 @@ export default {
const fallbackUrl = this.buildFallbackQrImageUrlByPageUrl(this.scanMiniProgramUrl)
if (fallbackUrl && this.scanQrImage !== fallbackUrl) {
this.scanQrImage = fallbackUrl
this.scanStatus = '主二维码通道受限,已切换备用通道'
return
}
@ -490,7 +491,6 @@ export default {
.visual-side {
width: 45%;
min-height: 720rpx;
display: flex;
flex-direction: column;
align-items: center;
@ -520,6 +520,8 @@ export default {
width: 55%;
box-sizing: border-box;
padding: 64rpx 56rpx;
display: flex;
flex-direction: column;
}
.header {
@ -575,14 +577,41 @@ export default {
padding: 28rpx;
}
.panel-stage {
position: relative;
min-height: 560rpx;
}
.panel--mode {
position: static;
}
.panel--scan {
padding: 20rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.panel--account {
display: flex;
flex-direction: column;
}
.panel--account .primary-btn {
margin-top: 86rpx;
}
.scan-box {
height: 360rpx;
width: 320rpx;
height: 320rpx;
border: 2rpx dashed #d9d9d9;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
margin: 0 auto 16rpx;
}
.scan-image {
@ -648,6 +677,10 @@ export default {
box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.08);
}
.password-wrap {
margin-top: 16rpx;
}
.password-input {
margin-bottom: 0;
padding-right: 156rpx;
@ -750,7 +783,8 @@ export default {
}
.primary-btn {
margin-top: 12rpx;
width: 100%;
margin-top: 24rpx;
}
.scan-login-btn {
@ -774,7 +808,6 @@ export default {
.visual-side {
width: 45%;
min-height: 660rpx;
padding: 64rpx 40rpx;
}
@ -782,5 +815,9 @@ export default {
width: 55%;
padding: 56rpx 40rpx;
}
.panel-stage {
min-height: 520rpx;
}
}
</style>

136
src/pages/order/index.vue Normal file
View File

@ -0,0 +1,136 @@
<template>
<view class="page">
<view class="container">
<text class="title">订单复核1</text>
<view class="search-bar">
<input
class="search-input"
v-model="keyword"
placeholder="请输入快递号/商品条码/拣货车/数量等关键词搜索订单"
confirm-type="search"
@confirm="handleSearch"
/>
<button class="search-btn" type="primary" @click="handleSearch">搜索</button>
</view>
<view class="result-list">
<view v-if="displayOrders.length === 0" class="empty">暂无匹配订单</view>
<view v-else v-for="order in displayOrders" :key="order.orderNo" class="order-item">
<text class="order-no">订单号:{{ order.orderNo }}</text>
<text class="order-user">客户:{{ order.customer }}</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'OrderReviewOne',
data() {
return {
keyword: '',
displayOrders: [],
allOrders: [
{ orderNo: 'ORD20260516001', customer: '张三' },
{ orderNo: 'ORD20260516002', customer: '李四' },
{ orderNo: 'ORD20260516003', customer: '王五' },
],
}
},
onLoad() {
this.displayOrders = this.allOrders
},
methods: {
handleSearch() {
const query = this.keyword.trim().toLowerCase()
if (!query) {
this.displayOrders = this.allOrders
return
}
this.displayOrders = this.allOrders.filter((order) => {
return (
String(order.orderNo || '').toLowerCase().includes(query) ||
String(order.customer || '').toLowerCase().includes(query)
)
})
},
},
}
</script>
<style>
.page {
min-height: 100vh;
padding: 32rpx;
box-sizing: border-box;
background-color: #f8f8f8;
}
.container {
background: #fff;
border-radius: 16rpx;
padding: 28rpx;
}
.title {
font-size: 36rpx;
color: #333;
font-weight: 600;
margin-bottom: 24rpx;
}
.search-bar {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 24rpx;
}
.search-input {
flex: 1;
height: 72rpx;
border: 1rpx solid #e5e5e5;
border-radius: 10rpx;
padding: 0 20rpx;
font-size: 28rpx;
background-color: #fff;
}
.search-btn {
width: 160rpx;
height: 72rpx;
line-height: 72rpx;
font-size: 28rpx;
}
.result-list {
display: flex;
flex-direction: column;
gap: 12rpx;
}
.order-item {
padding: 20rpx;
border: 1rpx solid #edf0f5;
border-radius: 10rpx;
background-color: #fafbfe;
}
.order-no,
.order-user {
display: block;
font-size: 26rpx;
color: #333;
line-height: 1.5;
}
.empty {
text-align: center;
color: #999;
font-size: 26rpx;
padding: 24rpx 0;
}
</style>