Commit 187b6c59 by 张立顺

Merge branch 'SAAS+V5.7.3' into SAAS+V5.7.1

2 parents e2f0a3ad 04614c68
......@@ -2,7 +2,7 @@
// 使用 Prettier 作为默认格式化器
"editor.defaultFormatter": "esbenp.prettier-vscode",
// 保存时自动格式化
"editor.formatOnSave": true,
"editor.formatOnSave": false,
// 缩进设置:使用 tab,大小为 4
"editor.tabSize": 4,
"editor.insertSpaces": false,
......@@ -11,7 +11,7 @@
"scm.compactFolders": false,
"problems.decorations.enabled": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "HookyQR.beautify"
},
"[wxml]": {
"editor.defaultFormatter": "wechat.miniprogram.wxml-language-features"
......
......@@ -9,6 +9,7 @@
"pages/nothing/nothing",
"pages/webView/webView",
"pages/webView/h5Full",
"pages/webView/h5FullNoShare",
"pages/tabWorkOrder/pages/index/index",
"pages/tabMine/pages/index/index",
"pages/tabDateIndex/pages/tabDateIndex",
......
......@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布
* 5cdptest
*/
let index = 1;
let index = 2;
const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion;
......
......@@ -3,7 +3,7 @@ import newApi from '~/packageUsedCar/api'
import { setConfigInfo } from '~/store/index'
const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/"
import { checkDailyReport } from "~/packageUsedCar/ModalToQueueUsedCarControl";
function throttle(func, delay) {
function throttle(func, delay = 600) {
let timeoutId;
let lastExecTime = 0;
......@@ -230,7 +230,7 @@ Component({
merchantName: userInfo.shopMerchantName
};
const queryString = this.buildQuery(queryObj)
const finalPath = `${item.webviewUrl}?${queryString}`
const finalPath = `${item.webviewUrl}?${queryString}`
return wx.requestSubscribeMessage({
tmplIds: ["MgjDgIpo1Xm8keYIUUtVbMbMj-Ms4q-xfbk7kM-L8EE"],
success(res) {
......@@ -249,10 +249,10 @@ Component({
}
})
} else {
const targetUrl = `/pages/webView/h5Full?url=${encodeURIComponent(item.webviewUrl)}`
console.log('[navGo] webviewUrl:', item.webviewUrl, '=> navigateTo:', targetUrl)
wx.navigateTo({ url: targetUrl })
return
const targetUrl = `/pages/webView/h5FullNoShare?url=${encodeURIComponent(webviewUrl)}&openType=miniApp`
console.log('[navGo] webviewUrl:', webviewUrl, '=> navigateTo:', targetUrl)
wx.navigateTo({ url: targetUrl })
return
}
}
if (!item.path) {
......
......@@ -32,6 +32,14 @@ Component({
this._pendingStatus = newVal
}
}
},
/** 与列表查询条件同步,用于从首页进施工单等场景下勾选当前技师 */
presetTechnicianUuidList: {
type: Array,
value: [],
observer: function (newVal) {
this.applyPresetTechnicianFromParent(newVal)
}
}
},
......@@ -99,10 +107,17 @@ Component({
value: []
}]
if (respone?.code == 0) {
this.setData({
artificerList: respone.data || [],
'form.technicianUuidList': arr.concat(respone.data || [])
})
this.setData(
{
artificerList: respone.data || [],
'form.technicianUuidList': arr.concat(respone.data || [])
},
() => {
this.applyPresetTechnicianFromParent(
this.properties.presetTechnicianUuidList
)
}
)
}
})
this.init()
......@@ -112,6 +127,35 @@ Component({
* 组件的方法列表
*/
methods: {
applyPresetTechnicianFromParent(uuids) {
if (wx.$hasPermission.canSelectMultiStore(this.data.userInfo)) return
const uuidsNorm = Array.isArray(uuids) ? uuids.filter(Boolean) : []
const list = this.data.form?.technicianUuidList
if (!list?.length) return
const match = (a, b) =>
a != null && b != null && String(a) === String(b)
if (!uuidsNorm.length) {
list.forEach((item, idx) => {
item.active = idx === 0
})
} else {
let any = false
list.forEach((item, idx) => {
if (idx === 0) {
item.active = false
} else {
const on = uuidsNorm.some(u => match(u, item.uuid))
item.active = on
if (on) any = true
}
})
if (!any) list[0].active = true
}
this.setData({
'form.technicianUuidList': list,
isReset: false
})
},
setViewData() {
let { navBarHeight } = this.data
wx.$util.getViewInfo(
......
......@@ -23,6 +23,7 @@ Page({
pageNum: 1,
searchKey: '',
list: [],
userInfo: null,
orderObj: [
{
label: '技师姓名',
......@@ -54,6 +55,30 @@ Page({
]
},
syncUserContext(done) {
let userInfo = wx.$util.getUserInfo() || {}
let nextShopMerchantId = userInfo?.shopMerchantId || ''
let prevShopMerchantId = this.data.userInfo?.shopMerchantId || ''
let searchObj = { ...this.data.searchObj }
let merchantType =
userInfo?.merchantAccountList?.includes('6') ||
userInfo?.merchantAccountList?.includes('8')
let nextUserInfo = {
...userInfo,
merchantType
}
let updateData = {
userInfo: nextUserInfo
}
if (prevShopMerchantId && prevShopMerchantId !== nextShopMerchantId) {
delete searchObj.technicianUuidList
updateData.searchObj = searchObj
}
this.setData(updateData, () => {
typeof done === 'function' && done()
})
},
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
......@@ -64,7 +89,11 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
onLoad(options) {
this.fromMenu = false
this._repairOrderScreeningOpen = false
this.syncUserContext()
},
// tab切换
tabClick(e) {
let { searchObj } = this.data
......@@ -152,7 +181,7 @@ Page({
constructionStatus: statusObj[searchObj?.statusList],
startTime: searchObj?.startTime,
endTime: searchObj?.endTime,
merchantId: userInfo?.shopMerchantId,
merchantId: this.fromMenu ? undefined : userInfo?.shopMerchantId,
sellerMerchantId: !wx.$hasPermission?.isSuper?.(userInfo) ? userInfo?.merchantId : '',
technicianUuidList: searchObj?.technicianUuidList?.length
? searchObj?.technicianUuidList
......@@ -261,6 +290,8 @@ Page({
let { target } = e.currentTarget.dataset
let jumpUrl =
target?.electronicFlag == 1 ? 'repairOrderDetail' : 'confirmWorkOrder'
// navigateTo 时本页 onHide 可能早于子页入栈,不能用页面栈判断是否在打开详情
this._openingRepairSubPage = true
wx.$router.go(`tabRepairOrder.${jumpUrl}`, {
id: target.id,
constructionCode: target.constructionCode,
......@@ -269,6 +300,7 @@ Page({
},
// 筛选页面隐藏
back() {
this._repairOrderScreeningOpen = false
this.setData({
show_confirm: false
})
......@@ -276,6 +308,8 @@ Page({
},
// 显示筛选页面
showConfirm() {
/** page-container 展示可能触发 onHide,避免误清首页会话导致 fromMenu 变 false、查询被限制在本店 */
this._repairOrderScreeningOpen = true
this.setData({
showRendering: true,
show_confirm: true
......@@ -305,13 +339,59 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.search()
const g = getApp().globalData
/** 仅首页菜单首次进入时预填当前技师;详情返回等仅带会话标,不重写 technicianUuidList */
let presetTechnicianFromHomeMenu = false
if (g.repairOrderOpenFromHomeMenu) {
this.fromMenu = true
g.repairOrderListFromHomeSession = true
presetTechnicianFromHomeMenu = true
delete g.repairOrderOpenFromHomeMenu
} else if (g.repairOrderListFromHomeSession) {
this.fromMenu = true
} else {
this.fromMenu = false
}
this.syncUserContext(() => {
const userInfo = this.data.userInfo
const uid = userInfo?.subLoginUser?.uuid || userInfo?.uuid
if (
presetTechnicianFromHomeMenu &&
uid &&
wx.$hasPermission.isTechnician(userInfo)
) {
const searchObj = {
...this.data.searchObj,
technicianUuidList: [uid]
}
this.setData({ searchObj }, () => this.search())
} else if (!this.fromMenu) {
const searchObj = { ...this.data.searchObj }
if ('technicianUuidList' in searchObj) {
delete searchObj.technicianUuidList
this.setData({ searchObj }, () => this.search())
} else {
this.search()
}
} else {
this.search()
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
onHide() {
if (this._openingRepairSubPage) {
this._openingRepairSubPage = false
return
}
if (this._repairOrderScreeningOpen) {
return
}
delete getApp().globalData.repairOrderListFromHomeSession
},
/**
* 生命周期函数--监听页面卸载
......
......@@ -160,6 +160,7 @@
userInfo="{{ userInfo }}"
navBarHeight="{{ navBarHeight }}"
status="{{ searchObj.statusList }}"
presetTechnicianUuidList="{{ searchObj.technicianUuidList || [] }}"
/>
</view>
</page-container>
\ No newline at end of file
......@@ -608,11 +608,11 @@ Page({
},
init(userInfo) { },
syncUserContext() {
syncUserContext(done) {
let userInfo = wx.$util.getUserInfo() || {}
let nextShopMerchantId = userInfo?.shopMerchantId || ''
let prevShopMerchantId = this.data.userInfo?.shopMerchantId || ''
let searchObj = this.data.searchObj || {}
let searchObj = { ...(this.data.searchObj || {}) }
let merchantType =
userInfo?.merchantAccountList?.includes('6') ||
userInfo?.merchantAccountList?.includes('8')
......@@ -629,7 +629,9 @@ Page({
searchObj.merchantId = ''
updateData.searchObj = searchObj
}
this.setData(updateData)
this.setData(updateData, () => {
typeof done === 'function' && done()
})
},
search() {
wx.$orderListRefresh = false
......@@ -950,8 +952,9 @@ Page({
*/
onLoad: function (options) {
// this.test()
this.syncUserContext()
this.getCreateOrderSetting()
this.syncUserContext(() => {
this.getCreateOrderSetting()
})
},
/**
......@@ -963,9 +966,10 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.syncUserContext()
this.getCreateOrderSetting()
this.search()
this.syncUserContext(() => {
this.getCreateOrderSetting()
this.search()
})
},
/**
......
// pages/webView/h5FullNoShare.js — 全屏 web-view,无系统转发 / 朋友圈入口
import { createWebViewPageNoShare } from './webViewCommon'
Page(createWebViewPageNoShare())
{
"navigationStyle": "custom",
"usingComponents": {}
}
<!-- pages/webView/h5FullNoShare.wxml — 全屏 web-view,无分享能力 -->
<block wx:if="{{flag}}">
<web-view src="{{url}}" bindmessage="handleMessage"></web-view>
</block>
......@@ -10,7 +10,9 @@ export function createWebViewPage(sharePagePath) {
data: {
flag: true,
isH5Bind: false,
shareTitle: '报告详情'
shareTitle: '报告详情',
// isH5Bind: false,
shareDisabled: false
},
getBaseUrl(url) {
......@@ -46,9 +48,20 @@ export function createWebViewPage(sharePagePath) {
},
onLoad: function (options) {
const shareDisabled = options.noShare === '1' || options.noShare === 'true'
this.setData({ shareDisabled })
wx.$util.showLoading('加载中...')
let decodeUrl = decodeURIComponent(options.url)
const baseUrl = this.getBaseUrl(decodeUrl)
if (
options.openType &&
!/[?&#]openType=/.test(decodeUrl)
) {
decodeUrl = this.appendParamsToUrl(decodeUrl, {
openType: options.openType
})
}
// const baseUrl = this.getBaseUrl(decodeUrl)
try {
const stored = wx.getStorageSync(WEBVIEW_H5_TOKENS_KEY)
if (stored) {
......@@ -69,10 +82,18 @@ export function createWebViewPage(sharePagePath) {
url: decodeUrl
})
wx.hideLoading()
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
if (shareDisabled) {
// 无参 hideShareMenu 全端隐藏「转发」;带 menus 的能力在部分系统上为 Beta/仅 Android,不能单独依赖
wx.hideShareMenu()
wx.hideShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
} else {
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
}
if (param.needIntercept) {
wx.enableAlertBeforeUnload &&
wx.enableAlertBeforeUnload({
......@@ -114,6 +135,12 @@ export function createWebViewPage(sharePagePath) {
onReady: function () {},
onShow: function () {
if (this.data.shareDisabled) {
wx.hideShareMenu()
wx.hideShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
}
if (this.refresh) {
this.setData(
{
......@@ -186,6 +213,9 @@ export function createWebViewPage(sharePagePath) {
onShareAppMessage(options) {
const { url, shareTitle } = this.data
if (options.webviewUrl.includes('/vehicle-detail')) shareTitle = '车况信息'
// onShareAppMessage() {
if (this.data.shareDisabled) return
// const { url } = this.data
const encoded = encodeURIComponent(url || '')
return {
title: shareTitle,
......@@ -196,6 +226,8 @@ export function createWebViewPage(sharePagePath) {
onShareTimeline() {
const { url, shareTitle } = this.data
if (options.webviewUrl.includes('/vehicle-detail')) shareTitle = '车况信息'
if (this.data.shareDisabled) return
// const { url } = this.data
const encoded = encodeURIComponent(url || '')
return {
title: shareTitle,
......@@ -204,3 +236,19 @@ export function createWebViewPage(sharePagePath) {
}
}
}
/**
* 全屏 web-view,且不注册 onShareAppMessage / onShareTimeline。
* 微信规则:只有定义了这两个回调,右上角才会出现「转发 / 朋友圈」;
* 仅靠 return {} 或 hideShareMenu 在部分环境下仍可能可转发。
*/
export function createWebViewPageNoShare() {
const page = createWebViewPage('/pages/webView/h5FullNoShare')
delete page.onShareAppMessage
delete page.onShareTimeline
const origOnLoad = page.onLoad
page.onLoad = function (options) {
return origOnLoad.call(this, { ...options, noShare: '1' })
}
return page
}
{
"libVersion": "2.30.4",
"libVersion": "3.15.1",
"projectname": "dj-car-boutique-work-wechat",
"setting": {
"urlCheck": false,
......
......@@ -31,6 +31,28 @@ let time = null
let modalQueue = []
import commonApi from '~/api/api'
import dayjs from 'dayjs'
/** 技师首页仅展示「施工单」,与其它角色菜单逻辑解耦 */
const TECHNICIAN_HOME_MENU_ONLY = [
{
name: '施工单',
isRepairOrderTabFromMenu: true,
recordId: 20,
icon: 'business_data',
noCheckdailyReport: true
}
]
function applyTechnicianOnlyMenus(userInfo, menu, newMenu) {
if (!wx.$hasPermission?.isTechnician?.(userInfo)) {
return { menu, newMenu }
}
return {
menu: TECHNICIAN_HOME_MENU_ONLY.map(item => ({ ...item })),
newMenu: []
}
}
Page({
/**
* 页面的初始数据
......@@ -76,7 +98,7 @@ Page({
styleHight: 'auto',
ispopUp: true,
isPad: false,
isWait: false, //今日待办
isWait: false, // 今日待办等:非 canSelectMultiStore 且非技师(loginRole 7)
sceneObj: {},
showReportPopup: false,
reportTemplateList: [],
......@@ -158,8 +180,12 @@ Page({
checkStaffOrderStatus() {
// 开单预警弹框
return new Promise(resolve => {
let dateStaffPop = wx.$storage.get('dateStaffPop')
let userInfo = wx.$util.getUserInfo()
if (wx.$hasPermission?.isTechnician?.(userInfo)) {
resolve()
return
}
let dateStaffPop = wx.$storage.get('dateStaffPop')
let nowDate = new Date().format('yyyy-MM-dd')
let { sceneType, shopMerchantId: merchantId } = userInfo
let dayBoolean = dateStaffPop?.date && nowDate == dateStaffPop?.date
......@@ -522,6 +548,14 @@ Page({
this.openWorkReportTemp(item)
return
}
// 施工单是 tabBar 页,须 switchTab;switchTab 不能带参,用 globalData 传 fromMenu
if (item.isRepairOrderTabFromMenu) {
wx.$util.pointRecord(item.recordId)
app.globalData.repairOrderOpenFromHomeMenu = true
return wx.switchTab({
url: '/pages/tabRepairOrder/pages/index/index'
})
}
// 场景集市添加埋点
if (item.name == '场景集市') {
wx.$track.setTrackData(0, 'scenario_marketplace', {}, '', 1)
......@@ -920,6 +954,8 @@ Page({
},
getMerchantCouponList() {
let userInfo = wx.$util.getUserInfo()
if (wx.$hasPermission?.isTechnician?.(userInfo)) return
let {
orderByTypeEnum,
tableSort,
......@@ -1038,6 +1074,7 @@ Page({
getOutputValue(yqdInfo) {
let { dateObj, userInfo } = this.data
if (wx.$hasPermission?.isTechnician?.(userInfo)) return
let { subIndex, merchantRange } = yqdInfo
// yqMerchantId 不是全部就必要要带过去
// 1-超管 2-商户管理员 3-区域运营 4-驻店人员
......@@ -1202,10 +1239,13 @@ Page({
getYQInfo(userInfo).then(result => {
wx.$util.hideLoading()
this.totalListSet()
this.getMerchantCouponList()
this.initTime()
this.getUserStat(userInfo)
this.getOutputValue(result)
const isTech = wx.$hasPermission?.isTechnician?.(userInfo)
if (!isTech) {
this.getMerchantCouponList()
this.initTime()
this.getUserStat(userInfo)
this.getOutputValue(result)
}
if (this.data.isWait) this.getStaffRemindList()
// 是技师请求统计接口
// console.log('是技师请求统计接口')
......@@ -1376,7 +1416,9 @@ Page({
},
/**获取园区配置 */
async getYqStoreConfig() {
const { merchantId: yqMerchantId } = wx.$util.getUserInfo(),
const userInfo = wx.$util.getUserInfo()
if (wx.$hasPermission?.isTechnician?.(userInfo)) return
const { merchantId: yqMerchantId } = userInfo,
{ menu } = this.data,
{ data } = await commonApi.getYqStoreConfig({
yqMerchantId
......@@ -1433,6 +1475,7 @@ Page({
},
getStaffTargetTask() {
let userInfo = wx.$util.getUserInfo()
if (wx.$hasPermission?.isTechnician?.(userInfo)) return
let { menu } = this.data
if (wx.$hasPermission?.canSelectMultiStore?.(userInfo))
return
......@@ -1514,8 +1557,9 @@ Page({
})
},
getIsBusinessSchoolEnableCurrentUser() {
let { menu } = this.data
let userInfo = wx.$util.getUserInfo()
if (wx.$hasPermission?.isTechnician?.(userInfo)) return
let { menu } = this.data
if (wx.$hasPermission?.isSuper?.(userInfo) && menu.every(item => item.name != '工资绩效')) {
menu.push({
name: '工资绩效',
......@@ -1744,10 +1788,10 @@ Page({
})
}
api.extractCheck({}).then(res => {
// 新加话术萃取
if (
(wx.$hasPermission?.isSuper?.(userInfo) || res) &&
menu.every(item => item.name != '话术核验')
menu.every(item => item.name != '话术核验') &&
!wx.$hasPermission?.isTechnician?.(userInfo)
) {
menu.push({
name: '话术核验',
......@@ -1761,7 +1805,11 @@ Page({
}
})
// V5.6.1新增工资申诉模块
if (wx.$hasPermission?.isSuper?.(userInfo) && menu.every(item => item.name != '工资申诉')) {
if (
wx.$hasPermission?.isSuper?.(userInfo) &&
!wx.$hasPermission?.isTechnician?.(userInfo) &&
menu.every(item => item.name != '工资申诉')
) {
menu.push({
name: '工资申诉',
icon: 'salary_appeal_icon',
......@@ -1780,6 +1828,7 @@ Page({
merchantId: userInfo.shopMerchantId || userInfo.merchantId
})
.then(res => {
if (wx.$hasPermission?.isTechnician?.(userInfo)) return
let hasChange = false
if (res.data) {
if (
......@@ -1827,6 +1876,21 @@ Page({
recordId: 16
})
}
// 驻店(4)或员工显示施工单入口(loginRole 常在 subLoginUser 上)
const effectiveLoginRole =
userInfo?.subLoginUser?.loginRole ?? userInfo?.loginRole
if (
(effectiveLoginRole === 4 || app.globalData.isStaff) &&
menu.every(item => item.name != '施工单')
) {
menu.push({
name: '施工单',
isRepairOrderTabFromMenu: true,
recordId: 20,
icon: 'tabRepairOrder',
noCheckdailyReport: true
})
}
// 非冀联园区店的员工展示学习中心入口
if (
userInfo?.subLoginUser?.channelType != 9 &&
......@@ -1852,7 +1916,10 @@ Page({
})
.then(async res => {
if (res.data) {
if (menu.every(item => item.name != '接待缺失报备')) {
if (
!wx.$hasPermission?.isTechnician?.(userInfo) &&
menu.every(item => item.name != '接待缺失报备')
) {
menu.push({
name: '接待缺失报备',
path: 'packageEquity.missingReception',
......@@ -1897,6 +1964,7 @@ Page({
}
})
}
;({ menu, newMenu } = applyTechnicianOnlyMenus(userInfo, menu, newMenu))
this.setData(
{
menu,
......@@ -1978,7 +2046,9 @@ Page({
startDate,
endDate,
isStaff: app.globalData.isStaff,
isWait: !wx.$hasPermission?.canSelectMultiStore?.(userInfo)
isWait:
!wx.$hasPermission?.canSelectMultiStore?.(userInfo) &&
!wx.$hasPermission?.isTechnician?.(userInfo)
},
() => {
if (this.data.isWait) this.getStaffRemindList()
......@@ -2017,7 +2087,9 @@ Page({
this.setData(
{
isStaff: app.globalData.isStaff,
isWait: !wx.$hasPermission?.canSelectMultiStore?.(userInfo)
isWait:
!wx.$hasPermission?.canSelectMultiStore?.(userInfo) &&
!wx.$hasPermission?.isTechnician?.(userInfo)
},
() => {
if (this.data.isWait) {
......
......@@ -141,7 +141,7 @@
></view>
</view>
</view>
<view wx:if="{{ perm.hasPermission.isNotTechnician(userInfo) }}">
<view>
<block wx:if="{{ isWait&&(todoList.length>0 || missingRecordTodoList.length > 0) }}">
<view class="todo-list">
<view class="title">今日待办·{{todoList.length + missingRecordTodoList.length}}</view>
......@@ -213,7 +213,7 @@
</block>
</div>
</block>
<view class="myPerformance {{ loginRole==4?'mb':'' }}" wx:if="{{ isWait }}">
<view class="myPerformance {{ loginRole==4?'mb':'' }}" wx:if="{{ isWait && !perm.hasPerm(userInfo, 'isTechnician') }}">
<view class="title">
<view class="conTitle">我的绩效</view>
<CalendarMonthSingle
......@@ -324,8 +324,8 @@
</view>
</view>
</view>
<!-- 员工不给看统计数据 -->
<view class="content" wx:if="{{ userInfo.loginRole&&userInfo.loginRole!=4 }}">
<!-- 员工不给看统计数据;技师不展示业务数据 -->
<view class="content" wx:if="{{ userInfo.loginRole&&userInfo.loginRole!=4 && !perm.hasPerm(userInfo, 'isTechnician') }}">
<view class="box table">
<view class="table-control conTitle utils">
业务数据
......
......@@ -107,9 +107,6 @@ export default {
url: 'tabWorkOrder.supervisorDaily',
reportTypeAttr: 'monthly',
reportTypeVal: '3',
// params: {
// templateCode: 'qinggai-temp-001'
// },
recordId: 19,
noCheckdailyReport: true
}
......
/**
* 权限判断 WXS 模块,供 WXML 使用
* 用法:<wxs src="../../utils/permission.wxs" module="perm" />(按当前 wxml 相对路径调整)
* <view wx:if="{{ perm.canSelectMultiStore(userInfo) }}">...</view>
*
* 注意:userInfo 需从页面 data 传入
* loginRole 与 JS 侧一致:优先 subLoginUser.loginRole,再取顶层 loginRole
*/
var getLoginRole = function (u) {
if (!u) return null
var sub = u.subLoginUser
if (sub && sub.loginRole !== undefined && sub.loginRole !== null) {
return sub.loginRole
}
return u.loginRole
}
var hasPermission = {
isSuper: function (u) {
return u && u.isSuper
......@@ -12,62 +20,68 @@ var hasPermission = {
canSelectMultiStore: function (u) {
if (!u) return false
if (u.isSuper) return true
var r = u.loginRole
var r = getLoginRole(u)
return r == 3 || r == 5 || r == 6 || r == 8
},
canSelectMultiStoreForStaffDaily: function (u) {
if (!u) return false
if (u.isSuper) return true
var r = u.loginRole
var r = getLoginRole(u)
return r == 3 || r == 5 || r == 8
},
canSkipValidation: function (u) {
return u && (u.isSuper || u.loginRole == 3 || u.loginRole == 8)
if (!u) return false
var r = getLoginRole(u)
return u.isSuper || r == 3 || r == 8
},
canViewViolation: function (u) {
if (!u) return false
if (u.isSuper) return true
var r = u.loginRole
var r = getLoginRole(u)
return r == 3 || r == 6 || r == 8
},
staffAbled: function (u) {
return u && (u.isSuper || u.loginRole == 3 || u.loginRole == 8)
if (!u) return false
var r = getLoginRole(u)
return u.isSuper || r == 3 || r == 8
},
canViewMentorship: function (u) {
return u && (u.isSuper || u.loginRole == 6)
if (!u) return false
return u.isSuper || getLoginRole(u) == 6
},
canViewRecruit: function (u) {
return u && (u.loginRole == 3 || u.loginRole == 8)
if (!u) return false
var r = getLoginRole(u)
return r == 3 || r == 8
},
canSelectMultiStoreWithTechnician: function (u) {
if (!u) return false
if (u.isSuper) return true
var r = u.loginRole
var r = getLoginRole(u)
return r == 3 || r == 5 || r == 6 || r == 7 || r == 8
},
isNotMentor: function (u) {
return !u || u.loginRole != 6
return !u || getLoginRole(u) != 6
},
isNotTechnician: function (u) {
return !u || u.loginRole != 7
return !u || getLoginRole(u) != 7
},
isTechnician: function (u) {
return u && u.loginRole == 7
return u && getLoginRole(u) == 7
},
isNormalStaff: function (u) {
if (!u || u.isSuper) return false
var r = u.loginRole
var r = getLoginRole(u)
return r != 3 && r != 5 && r != 6 && r != 8
}
}
/**
* 优先使用 userInfo._perm(登录时预计算),否则回退到实时计算
* WXML 侧始终按当前 userInfo 实时算(含 subLoginUser.loginRole),避免 _perm 与账号字段不一致导致误判
*/
var hasPerm = function (u, key) {
if (!u) return false
if (u._perm && u._perm[key] !== undefined) return !!u._perm[key]
return !!hasPermission[key] && hasPermission[key](u)
return !!(hasPermission[key] && hasPermission[key](u))
}
module.exports = {
......
......@@ -22,6 +22,14 @@ export const LOGIN_ROLE = {
TECHNICIAN_SUPERVISOR: 8
}
/** 登录身份角色:多数账号在 subLoginUser.loginRole,需与顶层 loginRole 合并后再判权限 */
export function effectiveLoginRole(u) {
if (!u) return undefined
const sub = u.subLoginUser?.loginRole
if (sub !== undefined && sub !== null) return sub
return u.loginRole
}
/** 权限规则配置:key -> (userInfo) => boolean */
const PERMISSION_RULES = {
/** 超管 */
......@@ -29,43 +37,45 @@ const PERMISSION_RULES = {
/** 可多选门店/督导权限(工单筛选、商户列表等) */
canSelectMultiStore: (u) =>
!!u?.isSuper || [3, 5, 6, 8].includes(u?.loginRole),
!!u?.isSuper || [3, 5, 6, 8].includes(effectiveLoginRole(u)),
/** 驻店日报场景(不含飞行督导 6) */
canSelectMultiStoreForStaffDaily: (u) =>
!!u?.isSuper || [3, 5, 8].includes(u?.loginRole),
!!u?.isSuper || [3, 5, 8].includes(effectiveLoginRole(u)),
/** 超管+区域运维+技师督导,可跳过部分校验 */
canSkipValidation: (u) => !!u?.isSuper || [3, 8].includes(u?.loginRole),
canSkipValidation: (u) => !!u?.isSuper || [3, 8].includes(effectiveLoginRole(u)),
/** 可查看违规 */
canViewViolation: (u) => !!u?.isSuper || [3, 6, 8].includes(u?.loginRole),
canViewViolation: (u) =>
!!u?.isSuper || [3, 6, 8].includes(effectiveLoginRole(u)),
/** 工资申诉等管理权限 */
staffAbled: (u) => !!u?.isSuper || [3, 8].includes(u?.loginRole),
staffAbled: (u) => !!u?.isSuper || [3, 8].includes(effectiveLoginRole(u)),
/** 带教管理 */
canViewMentorship: (u) => !!u?.isSuper || u?.loginRole === 6,
canViewMentorship: (u) =>
!!u?.isSuper || effectiveLoginRole(u) === 6,
/** 招聘管理 */
canViewRecruit: (u) => [3, 8].includes(u?.loginRole),
canViewRecruit: (u) => [3, 8].includes(effectiveLoginRole(u)),
/** 技师相关(含 7) */
canSelectMultiStoreWithTechnician: (u) =>
!!u?.isSuper || [3, 5, 6, 7, 8].includes(u?.loginRole),
!!u?.isSuper || [3, 5, 6, 7, 8].includes(effectiveLoginRole(u)),
/** 非飞行督导(用于 onPageShow/onPageHide 等) */
isNotMentor: (u) => u?.loginRole !== 6,
isNotMentor: (u) => effectiveLoginRole(u) !== 6,
/** 非技师(用于隐藏技师相关 UI) */
isNotTechnician: (u) => u?.loginRole !== 7,
isNotTechnician: (u) => effectiveLoginRole(u) !== 7,
/** 技师角色(用于删除/上传等权限) */
isTechnician: (u) => u?.loginRole === 7,
isTechnician: (u) => effectiveLoginRole(u) === 7,
/** 非超管且非督导/销售/飞行督导/技师督导(普通员工) */
isNormalStaff: (u) =>
!u?.isSuper && ![3, 5, 6, 8].includes(u?.loginRole)
!u?.isSuper && ![3, 5, 6, 8].includes(effectiveLoginRole(u))
}
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!