Commit 187b6c59 by 张立顺

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

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