Commit dddd68ce by wangzhihui

feat(accountApproval): Implement new account approval feature

- Added account approval API with methods for fetching details and processing approvals.
- Created a new Vue component for account approval interface, including status display and action buttons.
- Updated routing to include account approval page.
- Enhanced state management for authorization and URL parameter handling.
- Added mock data for testing purposes.
- Included a new image asset for empty state representation.
1 parent 65f453a3
......@@ -25,7 +25,9 @@
// "source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
},
"[vue]": {},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"[javascript]": {},
"[javascriptreact]": {},
"i18n-ally.sourceLanguage": "zh-chs",
......
const url = '/rop-dj-car-boutique/router'
export default {
/** 新员工开账号审核-详情 */
getAccountApplyDetail(data = {}) {
data.method = 'dj.api.smartcarlife.staffBaseInfo.account.approval.detail'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/** 新员工开账号审核-审批处理 */
auditAccountApply(data = {}) {
data.method = 'dj.api.smartcarlife.staffAccountApproval.process'
return window.$HTTP({
url,
data,
returnAll: true
})
}
}
const url = '/rop-dj-smartcarlife/router'
const url = '/rop-dj-car-boutique/router'
export default {
/** 获取订单待审核详情 */
......@@ -12,7 +12,16 @@ export default {
},
/** 订单申请审核 */
auditOrderApply(data = {}) {
data.method = 'dj.api.smartcarlife.goodsOrderApplyRecord.audit.update'
data.method = 'dj.api.smartcarlife.goodsOrderApplyRecord.h5.audit.update'
return window.$HTTP({
url,
data,
returnAll: true
})
},
// 根据手机号查询员工信息,入参:phone
getStaffInfoByPhone(data = {}) {
data.method = 'dj.api.smartcarlife.query.staffInfoByPhone'
return window.$HTTP({
url,
data,
......
......@@ -120,6 +120,18 @@ const pages = {
showAction: true
}
}
],
accountApproval:[
{
name: 'index',
meta: {
keepAlive: true,
title: '新员工开账号审批',
noAuth: true,
backgroundColor: '#f7f8fa',
showAction: true
}
}
]
}
let routes = [
......
......@@ -21,6 +21,83 @@ const state = {
import router from '@/router'
const EVECTION_AUTH_PATHS = ['/department', '/personage', '/company']
const APPROVAL_AUTH_PATHS = ['/orderApproval', '/accountApproval']
function saveUrlParams() {
const { corpId, agentId, phone, name, id, orderCode, uuid } = util.getQuery()
if (phone) util.setLocalStorage('ww_params_phone', phone)
if (name) util.setLocalStorage('ww_params_name', name)
if (id) util.setLocalStorage('ww_params_id', id)
if (uuid) util.setLocalStorage('ww_params_uuid', uuid)
if (orderCode) util.setLocalStorage('ww_orderCode', orderCode)
if (corpId) {
const ww_storage_info = util.getLocalStorage('ww_storage_info') || {}
ww_storage_info.corpId = corpId
if (agentId && agentId != 'undefined') ww_storage_info.agentId = agentId
util.setLocalStorage('ww_storage_info', ww_storage_info)
}
}
function needWwAuth(href) {
const pushId = util.getQuery('pushId')
const isEvectionPath = EVECTION_AUTH_PATHS.some(keyword => href.includes(keyword))
const isApprovalPath = APPROVAL_AUTH_PATHS.some(keyword => href.includes(keyword))
if (isEvectionPath && pushId && pushId * 1 > 744) return true
if (isApprovalPath) return true
return false
}
async function handleWwLogin({ commit }) {
const { corpId, agentId } = util.getQuery()
const wwCode = util.getQuery('code')
const { loginUrl } = window.$fetchConfig
let userInfo = util.getLocalStorage('ww_userInfo') || ''
if (userInfo && userInfo.timestamp) {
if (Date.now() - userInfo.timestamp <= 1000 * 60 * 1440) {
commit('SET_AUTHORIZE_PAGE', true)
commit('SET_SHOW_WINDOW', true)
return
}
}
if (wwCode) {
const res = await ssoApi.login({ code: wwCode, corpId, getUserInfoFlag: false })
const { code, data, message } = res
if (code == '0') {
commit('SET_AUTHORIZE_PAGE', true)
commit('SET_SHOW_WINDOW', true)
const hrefUrl = window.location.href
const newUrl = hrefUrl.replace(/([?&])code=[^&]*/, (match, prefix) => (prefix === '?' ? '?' : ''))
window.history.replaceState({}, '', newUrl)
if (data.loginList && data.loginList.length) {
const [item] = data.loginList
if (item.loginList && item.loginList.length) {
const [loginUserInfo] = item.loginList
if (loginUserInfo.phone) util.setLocalStorage('ww_params_phone', loginUserInfo.phone)
loginUserInfo.timestamp = Date.now()
util.setLocalStorage('ww_userInfo', loginUserInfo)
return
}
}
throw new Error('登录失败或无权限')
}
Notify({ message })
commit('SET_SHOW_WINDOW', false)
commit('SET_AUTHORIZE_PAGE', false)
return
}
commit('SET_AUTHORIZE_PAGE', false)
const ua = navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) && ua.match(/wxwork/i)) {
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}&backLoginCode=BACKCODE`
} else {
Notify({ message: '请使用企业微信打开', duration: 72000000 })
}
}
const mutations = {
SET_PAGE_META(state, meta) {
state.pageMeta = meta
......@@ -49,97 +126,24 @@ const actions = {
// window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
},
login({ dispatch, commit, state }) {
//获取当前路由路径
const currentPath = window.location.href;
const pathKeywords = ['/department', '/personage', '/company'];
const isTargetPath = pathKeywords.some(keyword => currentPath.includes(keyword));
// const pathTitleMap = {
// '/department': '美团消费部门月度总结',
// '/personage': '美团消费个人月度总结',
// '/company': '美团消费公司月度总结'
// };
// const matchedPath = Object.keys(pathTitleMap).find(path => currentPath.includes(path));
// if (matchedPath) {
// document.title = pathTitleMap[matchedPath];
// }
const pushId = util.getQuery('pushId');
if (isTargetPath && (pushId && (pushId * 1) > 744)) {
try {
let { corpId, agentId } = util.getQuery();
const wwCode = util.getQuery('code');
let { loginUrl } = window.$fetchConfig;
let userInfo = util.getLocalStorage('ww_userInfo') || '';
if (userInfo && userInfo.timestamp) {
//判断用户时间戳是否过期12小时
if (userInfo.timestamp && (Date.now() - userInfo.timestamp) > (1000 * 60 * 1440)) {
console.log('用户登录过期');
} else {
console.log('用户已经登录');
commit('SET_AUTHORIZE_PAGE', true);
return commit('SET_SHOW_WINDOW', true);
}
}
if (wwCode) {
ssoApi.login({ code: wwCode, corpId, getUserInfoFlag: false }).then(res => {
const { code, data, message } = res;
if (code == "0") {
commit('SET_AUTHORIZE_PAGE', true);
commit('SET_SHOW_WINDOW', true);
const hrefUrl = window.location.href;
const newUrl = hrefUrl.replace(/([?&])code=[^&]*/, (match, prefix) => { return prefix === '?' ? '?' : ''; });
window.history.replaceState({}, '', newUrl);
if (data.loginList && data.loginList.length) {
let [item] = data.loginList
if (item.loginList && item.loginList.length) {
let [userInfo] = item.loginList,
{ phone } = userInfo
if (phone) util.setLocalStorage('ww_params_phone', phone)
//获取当前时间戳
userInfo.timestamp = Date.now();
util.setLocalStorage('ww_userInfo', userInfo);
} else throw ''
} else throw ''
} else {
Notify({ message: message })
commit('SET_SHOW_WINDOW', false);
commit('SET_AUTHORIZE_PAGE', false);
}
login({ commit }) {
// 缓存 corpId/agentId 等公共参数,再进入 OAuth
saveUrlParams()
const currentPath = window.location.href
if (needWwAuth(currentPath)) {
handleWwLogin({ commit }).catch(error => {
const message = error && error.message ? error.message : '登录失败或无权限'
Notify(message)
})
} else {
commit('SET_AUTHORIZE_PAGE', false);
//是否企微环境
const ua = navigator.userAgent.toLowerCase()
if (Boolean(ua.match(/MicroMessenger/i)) && Boolean(ua.match(/wxwork/i))) {
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}&backLoginCode=BACKCODE`
} else {
Notify({ message: '请使用企业微信打开', duration: 72000000 })
}
}
} catch (error) {
if (!error) error = '登录失败或无权限'
if (error) Notify(typeof error === 'string' ? error : error.toString())
}
} else {
commit('SET_AUTHORIZE_PAGE', true);
commit('SET_SHOW_WINDOW', true);
commit('SET_AUTHORIZE_PAGE', true)
commit('SET_SHOW_WINDOW', true)
}
},
navigation({ dispatch, commit }, to) {
let { corpId, agentId, phone, name, id ,orderCode} = util.getQuery(),
userInfo = util.getLocalStorage('ww_userInfo')
if (phone) util.setLocalStorage('ww_params_phone', phone)
if (name) util.setLocalStorage('ww_params_name', name)
if (id) util.setLocalStorage('ww_params_id', id)
if (orderCode) util.setLocalStorage('ww_orderCode', orderCode)
navigation({ dispatch, commit }) {
saveUrlParams()
const userInfo = util.getLocalStorage('ww_userInfo')
dispatch('registerHttp')
if (corpId) {
let ww_storage_info = {}
ww_storage_info.corpId = corpId
if (agentId && agentId != 'undefined') ww_storage_info.agentId = agentId
util.setLocalStorage('ww_storage_info', ww_storage_info)
}
if (userInfo) {
commit('SET_SHOW_WINDOW', true)
} else {
......
这是一个新员工开账号审核,页面样式跟src\views\orderApproval样式一模一样( 去掉商品信息)
基本信息的字段如下:
员工姓名:staffName
手机号:staffPhone
归属门店:merchantName
关联业务:staffSceneLabelText
驻店类型:stationType 门店常驻:1,临时调动支撑:2
区域运营:
提单时间:
后端接口还未提供,先用假数据显示当前页面,接口位置先提供,后期有的话我再替换
export default {
code: 0,
message: 'success',
data: {
id: 10001,
staffId: 20001,
staffName: '金晨',
staffPhone: '13893047470',
merchantId: 44212556,
merchantName: 'xxxx汽车销售服务有限公司',
sceneList: JSON.stringify([
{ sceneName: '权益' },
{ sceneName: '延保' }
]),
yqMerchantList: JSON.stringify([
{ yqMerchantName: 'D+西藏迅捷网界园区店', merchantId: 44212979 }
]),
createdSource: 1,
stationType: 2,
submitterAccount: 'glsadmin',
submitterName: '区域运营人员',
submitterPhone: '13800000000',
submitterUuid: 'uuid-001',
approvalStatus: 0,
approverUuid: null,
approverName: null,
approvalTime: null,
approvalRemark: null
}
}
......@@ -13,7 +13,7 @@
<div class="container">
<div class="label">
{{ infoData.label }}
<span v-if="infoData.type == 2" class="required-label">*</span>
<span v-if="infoData.type == 2 && rejectRemarkRequired" class="required-label">*</span>
</div>
<div class="textarea-wrap">
<van-field
......@@ -50,6 +50,10 @@ export default {
show: {
type: Boolean,
default: false
},
rejectRemarkRequired: {
type: Boolean,
default: false
}
},
data() {
......@@ -78,7 +82,7 @@ export default {
},
methods: {
onConfirm() {
if (this.infoData.type == 2 && !this.remark) {
if (this.rejectRemarkRequired && this.infoData.type == 2 && !this.remark) {
Toast('请输入驳回备注')
return
}
......
<template>
<div class="page-container">
<div>
<div v-show="!$store.state.app.authorizePage" class="page-container">
<div class="content-scroll" :class="{ 'has-footer': orderInfo.status == 1 }">
<!-- 审核状态 -->
<div v-if="currentStatus" class="status-section">
......@@ -13,12 +14,7 @@
<!-- 订单信息 -->
<div class="section">
<div class="section-title">订单信息</div>
<div
v-for="(item, index) in displayOrderForm"
:key="index"
class="info-item"
:class="{ 'flex-start': item.flexStart }"
>
<div v-for="(item, index) in displayOrderForm" :key="index" class="info-item" :class="{ 'flex-start': item.flexStart }">
<span class="info-label">{{ item.label }}</span>
<template v-if="item.format">
<div class="info-value">{{ djOrderTypeMap[orderInfo[item.key]] || '-' }}</div>
......@@ -32,12 +28,7 @@
</template>
<template v-else-if="item.image">
<div v-if="orderInfo[item.key] && orderInfo[item.key].length" class="image-value">
<div
v-for="(subItem, subIndex) in orderInfo[item.key]"
:key="subIndex"
class="image-item"
@click="previewImage(orderInfo[item.key], subIndex)"
>
<div v-for="(subItem, subIndex) in orderInfo[item.key]" :key="subIndex" class="image-item" @click="previewImage(orderInfo[item.key], subIndex)">
<van-image :src="subItem.payVoucher" fit="cover" width="56" height="56" radius="8" />
</div>
</div>
......@@ -45,24 +36,18 @@
</template>
<template v-else>
<span class="info-value">
<span v-if="item.unit" class="unit">{{ item.unit }}</span>{{ getFieldValue(item) }}
<span v-if="item.unit" class="unit">{{ item.unit }}</span>
{{ getFieldValue(item) }}
</span>
</template>
</div>
</div>
<!-- 原错误订单商品信息 -->
<goods-order-item
v-if="orderInfo.oldOrderCode"
title="原错误订单商品信息"
:goods-data="orderInfo.oldGoodsOrderDTO || {}"
/>
<goods-order-item v-if="orderInfo.oldOrderCode" title="原错误订单商品信息" :goods-data="orderInfo.oldGoodsOrderDTO || {}" />
<!-- 新订单 / 普通订单 -->
<goods-order-item
:title="orderInfo.oldOrderCode ? '新订单商品信息' : '商品信息'"
:goods-data="orderInfo.goodsOrderDTO || {}"
/>
<goods-order-item :title="orderInfo.oldOrderCode ? '新订单商品信息' : '商品信息'" :goods-data="orderInfo.goodsOrderDTO || {}" />
<!-- 审核日志 -->
<div v-if="orderInfo.status != 1 && orderInfo.applyLogList && orderInfo.applyLogList.length" class="section">
......@@ -74,18 +59,12 @@
<div class="dot-wrapper">
<div class="dot" :class="index == 0 ? 'step-active' : 'step-done'"></div>
</div>
<div
v-if="orderInfo.applyLogList.length > 1 && index != orderInfo.applyLogList.length - 1"
class="status-line step-done"
></div>
<div v-if="orderInfo.applyLogList.length > 1 && index != orderInfo.applyLogList.length - 1" class="status-line step-done"></div>
</div>
<div class="timeline-content">
<div class="log-status-text">
<span class="mar-r16">{{ statusForShow[item.beforeStatus] && statusForShow[item.beforeStatus].text }}</span>
<span
class="status mar-r16"
:class="item.afterStatus == 2 || item.afterStatus == 3 ? 'success' : 'error'"
>
<span class="status mar-r16" :class="item.afterStatus == 2 || item.afterStatus == 3 ? 'success' : 'error'">
{{ statusForShow[item.afterStatus] && statusForShow[item.afterStatus].status }}
</span>
<template v-if="item.afterStatus == 4">
......@@ -113,18 +92,14 @@
</div>
<!-- 底部操作按钮 -->
<div v-if="orderInfo.status == 1" class="footer-btn">
<div v-if="orderInfo.status == 2" class="footer-btn">
<div class="btn cancel" @click="reject">驳回</div>
<div class="btn confirm" @click="pass">通过</div>
</div>
<approval-popup
v-if="showPopup"
:show="showPopup"
:info-data="popupInfo"
@confirm="handlePopupConfirm"
@cancel="hidePopup"
/>
<approval-popup v-if="showPopup" :show="showPopup" :info-data="popupInfo" :reject-remark-required="true" @confirm="handlePopupConfirm" @cancel="hidePopup" />
</div>
<div v-show="$store.state.app.authorizePage" class="loading-box">正在登录授权中...</div>
</div>
</template>
......@@ -135,21 +110,21 @@ import orderApprovalApi from '@/api/orderApproval'
import mockOrderDetailRes from './mockData'
import GoodsOrderItem from './components/goodsOrderItem.vue'
import ApprovalPopup from './components/approvalPopup.vue'
import store from '@/store'
export default {
name: 'OrderApproval',
components: { GoodsOrderItem, ApprovalPopup },
data() {
return {
//getLocalStorage('ww_orderCode') ||
orderCode: '260601152927430',
orderCode: '',
orderInfo: {},
showPopup: false,
popupInfo: {},
submitFlag: false,
statusMap: {
1: { name: '待审核', tips: '请尽快处理', icon: 'more-o', color: '#FF9D0A' },
2: { name: '已审核', tips: '订单已流转至线上运营审核', icon: 'passed', color: '#35C376' },
2: { name: '待审核', tips: '请尽快处理', icon: 'more-o', color: '#FF9D0A' },
// 2: { name: '已审核', tips: '订单已流转至线上运营审核', icon: 'passed', color: '#35C376' },
3: { name: '已审核', tips: '订单已被线上运营审核通过', icon: 'passed', color: '#35C376' },
4: { name: '已驳回', tips: '订单已驳回', icon: 'warning-o', color: '#666666' }
},
......@@ -197,12 +172,39 @@ export default {
}
},
created() {
console.log(this.orderCode)
if (this.orderCode) {
// 先缓存链接业务参数,避免 OAuth 跳转后 orderCode 丢失
this.initPageParams()
// store.dispatch('login')
},
watch: {
'$store.state.app.authorizePage': {
immediate: true,
handler(val) {
if (val && this.orderCode) {
this.loadOrderDetail(this.orderCode)
this.loadStaffInfoByPhone(this.phone)
}
}
}
},
methods: {
initPageParams() {
const { orderCode } = this.$route.query
if (orderCode) this.setLocalStorage('ww_orderCode', orderCode)
// 授权回调后 URL 可能只剩 code,从缓存读取
this.orderCode = this.getLocalStorage('ww_orderCode') || ''
this.phone = this.getLocalStorage('ww_params_phone') || '15814019200'
if (this.phone) {
this.loadStaffInfoByPhone(this.phone)
}
this.loadOrderDetail(this.orderCode)
},
loadStaffInfoByPhone(phone) {
orderApprovalApi.getStaffInfoByPhone({ phone }).then(res => {
console.log(res)
this.userInfo = res.data
})
},
getFieldValue(item) {
const val = this.orderInfo[item.key]
return val || val === 0 ? val : '-'
......@@ -242,24 +244,20 @@ export default {
this.showLoading()
try {
// TODO: 联调时切换为真实接口
const res = mockOrderDetailRes
// const res = await orderApprovalApi.getOrderApplyDetail({ orderCode })
// const res = mockOrderDetailRes
const res = await orderApprovalApi.getOrderApplyDetail({ orderCode })
this.hideLoading()
const { code, data, message } = res
if (code == 0) {
const processedData = this.processOrderData(data || {})
if (data?.applyLogList) {
data.applyLogList.forEach(val => {
val.createdDateStr = val.createdDate
? dayjs(val.createdDate).format('YYYY-MM-DD HH:mm:ss')
: '-'
val.createdDateStr = val.createdDate ? dayjs(val.createdDate).format('YYYY-MM-DD HH:mm:ss') : '-'
})
}
this.orderInfo = {
...processedData,
applyDate: data.applyDate
? dayjs(data.applyDate).format('YYYY-MM-DD HH:mm:ss')
: '-',
applyDate: data.applyDate ? dayjs(data.applyDate).format('YYYY-MM-DD HH:mm:ss') : '-',
oldOrderCode: data?.oldGoodsOrderDTO?.orderCode || ''
}
} else {
......@@ -296,7 +294,8 @@ export default {
const res = await orderApprovalApi.auditOrderApply({
auditResult: this.popupInfo?.type,
orderCode: this.orderInfo.orderCode,
remark
remark,
operatorName: this.userInfo.staffName
})
this.hideLoading()
this.submitFlag = false
......@@ -317,6 +316,14 @@ export default {
</script>
<style scoped lang="scss">
.loading-box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #999999;
font-size: 14px;
}
.page-container {
position: absolute;
left: 0;
......@@ -499,6 +506,10 @@ export default {
color: #999999;
margin-right: 8px;
}
.value {
word-wrap: break-word;
word-break: break-all;
}
}
}
}
......
......@@ -9,7 +9,7 @@ export default {
"sellerName": "wql",
"merchantId": 44212556,
"merchantName": "0918测试1.1.2-门店",
"status": 2,
"status":1,
"applyDate": 1769671815000,
"orderRemark": "",
"outTradeNo": "4gfged",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!