Commit 9e810b75 by Lin

feat: 销售列表接口联调

1 parent 81446f6c
...@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd"; ...@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 0; let index = 1;
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;
......
...@@ -66,4 +66,9 @@ module.exports = { ...@@ -66,4 +66,9 @@ module.exports = {
querySceneRefByShop(data) { querySceneRefByShop(data) {
return api.post('dj.api.scenemerchantref.querySceneRefByShop', data) return api.post('dj.api.scenemerchantref.querySceneRefByShop', data)
}, },
/** 获取所有销售列表 */
getEmployeeAllList(data) {
return api.post('dj.api.smartcarlife.employee.getAll', data)
},
} }
// packageEquity/pages/salaryAppeal/salaryAppeal.js // packageEquity/pages/salaryAppeal/salaryAppeal.js
import { getSummaryInfo,querySceneRefByShop, getStatistics, getReplyList, getApplyLatest, createSalaryapply } from './api' import { getSummaryInfo, getStatistics, getReplyList, getApplyLatest, createSalaryapply,getEmployeeAllList } from './api'
import comApi from '~/api/api'
Page({ Page({
/** /**
...@@ -81,7 +80,7 @@ Page({ ...@@ -81,7 +80,7 @@ Page({
// if (!this.data.staffOptions || this.data.staffOptions.length === 0) { // if (!this.data.staffOptions || this.data.staffOptions.length === 0) {
wx.showLoading({ title: '加载中...', mask: true }) wx.showLoading({ title: '加载中...', mask: true })
try { try {
await this.getStaffList() await this.getEmployeeAllList()
wx.hideLoading() wx.hideLoading()
this.setData({ this.setData({
showStaffPopup: true showStaffPopup: true
...@@ -118,12 +117,12 @@ Page({ ...@@ -118,12 +117,12 @@ Page({
const { value, option } = e.detail const { value, option } = e.detail
console.log("e", e.detail); console.log("e", e.detail);
console.log("onStaffSelectConfirm", value, option);
this.setData({ this.setData({
currentStaffName: option.text, currentStaffName: option.text,
currentStaffId: value, currentStaffId: value,
showStaffPopup: false showStaffPopup: false
}) })
console.log("currentStaffId", this.data.currentStaffId);
// 根据选择的员工重新加载数据 // 根据选择的员工重新加载数据
// 获取概览信息 // 获取概览信息
...@@ -133,90 +132,35 @@ Page({ ...@@ -133,90 +132,35 @@ Page({
// 获取申诉答复记录 // 获取申诉答复记录
this.getStaffReplyList() this.getStaffReplyList()
}, },
async getEmployeeAllList() {
/** const userInfo = wx.$util.getUserInfo()
* 获取员工列表:先查询园区店,再获取员工列表 const res = await getEmployeeAllList({
*/ screen: userInfo?.sceneType
async getStaffList() { })
try { const { code, data, message } = res
// 获取商户ID if (code != 0) {
const userInfo = wx.$util.getUserInfo() wx.$util.message(message || '获取员工列表失败')
const merchantId = userInfo?.default4SStoreInfo?.merchantId || userInfo?.merchantId || '' return []
if (!merchantId) {
wx.$util.showToast('商户ID不能为空')
return []
}
// 先查4s店对应的园区店,再用园区店查员工
const sceneRefResult = await querySceneRefByShop({
scene: 1,
merchantId: merchantId,
pageSize: 200
})
const { code, data, message } = sceneRefResult
if (code != 0) {
wx.$util.message(message || '查询园区店失败')
return []
}
// 检查是否有园区店数据
if (!data.yqMerchant?.merchantId) {
this.setData({
staffOptions: []
})
wx.$util.showToast('该4s店查无数据')
return []
}
// 使用园区店的merchantId获取员工列表
const res = await comApi.getConversionEmployeeList({
merchantId: data.yqMerchant.merchantId
})
const { code: employeeCode, data: employeeData, message: employeeMessage } = res
if (employeeCode != 0) {
wx.$util.showToast(employeeMessage || '获取员工列表失败')
return []
}
// 检查员工列表是否为空
if (!employeeData || !employeeData.length) {
this.setData({
staffOptions: [],
currentStaffId: ''
})
wx.$util.showToast('该门店没有员工')
return []
}
// 将响应数据转换为选项格式:text取staffName,value取uuid
const options = employeeData.map(item => ({
text: item.staffName || '',
value: item.uuid || '',
staffPhone: item.staffPhone || ''
}))
// 如果当前选中的员工信息为空,且员工列表有数据,则默认选中第一条
const updateData = {
staffOptions: options
}
if ((!this.data.currentStaffName || !this.data.currentStaffId) && options.length > 0) {
updateData.currentStaffName = options[0].text
updateData.currentStaffId = options[0].value
}
this.setData(updateData)
return options
} catch (error) {
console.error('获取员工列表失败:', error)
wx.$util.showToast('获取员工列表失败,请重试')
throw error
} }
console.log("getEmployeeAllList", res);
// 将响应数据转换为选项格式:text取staffName,value取uuid
const options = data.map(item => ({
text: item.staffName || '',
value: item.staffPhone || '',
staffPhone: item.staffPhone || ''
}))
// 默认选中第一个员工
const updateData = {
staffOptions: options
}
if (options && options.length > 0) {
updateData.currentStaffName = options[0].text
updateData.currentStaffId = options[0].value
}
this.setData(updateData)
}, },
/** /**
* 根据年月字符串获取该月的天数 * 根据年月字符串获取该月的天数
* @param {String} yearMonth 年月字符串,格式如 "2024-01" 或 "2024年01月" * @param {String} yearMonth 年月字符串,格式如 "2024-01" 或 "2024年01月"
...@@ -411,22 +355,23 @@ Page({ ...@@ -411,22 +355,23 @@ Page({
async onLoad(options) { async onLoad(options) {
// 获取用户信息并设置商户名称 // 获取用户信息并设置商户名称
this.initOrderObj() this.initOrderObj()
// 获取概览信息
this.getStaffInfo() // this.getEmployeeAllList()
// 获取订单统计信息 // // 月份相关的初始化逻辑已移至组件内部处理
this.getOrderStatistics()
// 获取申诉答复记录
this.getStaffReplyList()
// 月份相关的初始化逻辑已移至组件内部处理
// 页面加载时自动获取员工列表并设置第一条数据
// 仅仅对超管和区域运营(区域经理)开放员工选择功能
const userInfo = wx.$util.getUserInfo() const userInfo = wx.$util.getUserInfo()
this.setData({ this.setData({
staffAbled: userInfo?.isSuper || userInfo?.loginRole == 3 staffAbled: userInfo?.isSuper || userInfo?.loginRole == 3
}) })
if (userInfo?.isSuper || userInfo?.loginRole == 3) { if (userInfo?.isSuper || userInfo?.loginRole == 3) {
try { try {
await this.getStaffList() await this.getEmployeeAllList()
// 获取概览信息
this.getStaffInfo()
// 获取订单统计信息
this.getOrderStatistics()
// 获取申诉答复记录
this.getStaffReplyList()
// 获取所有销售列表
} catch (error) { } catch (error) {
console.error('页面加载时获取员工列表失败:', error) console.error('页面加载时获取员工列表失败:', error)
} }
...@@ -435,7 +380,7 @@ Page({ ...@@ -435,7 +380,7 @@ Page({
async getOrderStatistics() { async getOrderStatistics() {
const userInfo = wx.$util.getUserInfo() const userInfo = wx.$util.getUserInfo()
const res = await getStatistics({ const res = await getStatistics({
staffPhone: userInfo?.phone, staffPhone: this.data.currentStaffId,
appealMonth: this.data.currentMonth, appealMonth: this.data.currentMonth,
sceneType: userInfo?.sceneType sceneType: userInfo?.sceneType
}) })
...@@ -484,7 +429,7 @@ Page({ ...@@ -484,7 +429,7 @@ Page({
async getStaffReplyList() { async getStaffReplyList() {
const userInfo = wx.$util.getUserInfo() const userInfo = wx.$util.getUserInfo()
const res = await getReplyList({ const res = await getReplyList({
staffPhone: userInfo?.phone, staffPhone: this.data.currentStaffId,
appealMonth: this.data.currentMonth appealMonth: this.data.currentMonth
}) })
...@@ -517,7 +462,7 @@ Page({ ...@@ -517,7 +462,7 @@ Page({
const userInfo = wx.$util.getUserInfo() const userInfo = wx.$util.getUserInfo()
// 先查4s店对应的园区店,再用园区店查员工 // 先查4s店对应的园区店,再用园区店查员工
const res = await getSummaryInfo({ const res = await getSummaryInfo({
staffPhone: userInfo?.phone, staffPhone: this.data.currentStaffId,
appealMonth: this.data.currentMonth appealMonth: this.data.currentMonth
}) })
console.log(res, 'getStaffInfo') console.log(res, 'getStaffInfo')
...@@ -543,25 +488,21 @@ Page({ ...@@ -543,25 +488,21 @@ Page({
return `-${amount}元` return `-${amount}元`
} }
// 格式化数值显示(如 "26天"、"12条")
const formatValue = (value, unit) => {
if (value === null || value === undefined) {
return `0${unit}`
}
return `${value}${unit}`
}
// 更新attendance项(实际出勤天数) // 更新attendance项(实际出勤天数)
const attendanceIndex = salaryItems.findIndex(item => item.id === 'attendance') const attendanceIndex = salaryItems.findIndex(item => item.id === 'attendance')
if (attendanceIndex !== -1) { if (attendanceIndex !== -1) {
salaryItems[attendanceIndex].value = formatValue(apiData.actualAttendanceDays, '天') if (apiData.actualAttendanceDays !== null && apiData.actualAttendanceDays !== undefined) {
salaryItems[attendanceIndex].value = `${apiData.actualAttendanceDays}天`
}
salaryItems[attendanceIndex].btnAble = apiData.attendanceAppealable || false salaryItems[attendanceIndex].btnAble = apiData.attendanceAppealable || false
} }
// 更新daily项(日报完成天数) // 更新daily项(日报完成天数)
const dailyIndex = salaryItems.findIndex(item => item.id === 'daily') const dailyIndex = salaryItems.findIndex(item => item.id === 'daily')
if (dailyIndex !== -1) { if (dailyIndex !== -1) {
salaryItems[dailyIndex].value = formatValue(apiData.dailyReportDays, '天') if (apiData.dailyReportDays !== null && apiData.dailyReportDays !== undefined) {
salaryItems[dailyIndex].value = `${apiData.dailyReportDays}天`
}
salaryItems[dailyIndex].centerRightPrice = formatDeductionAmount(apiData.dailyReportDeductionAmount) salaryItems[dailyIndex].centerRightPrice = formatDeductionAmount(apiData.dailyReportDeductionAmount)
salaryItems[dailyIndex].bottomDays = formatMissingDates(apiData.missingDailyReportDates) salaryItems[dailyIndex].bottomDays = formatMissingDates(apiData.missingDailyReportDates)
salaryItems[dailyIndex].btnAble = apiData.dailyReportable || false salaryItems[dailyIndex].btnAble = apiData.dailyReportable || false
...@@ -570,7 +511,9 @@ Page({ ...@@ -570,7 +511,9 @@ Page({
// 更新recording项(平板录音总数) // 更新recording项(平板录音总数)
const recordingIndex = salaryItems.findIndex(item => item.id === 'recording') const recordingIndex = salaryItems.findIndex(item => item.id === 'recording')
if (recordingIndex !== -1) { if (recordingIndex !== -1) {
salaryItems[recordingIndex].value = formatValue(apiData.padRecordNum, '条') if (apiData.padRecordNum !== null && apiData.padRecordNum !== undefined) {
salaryItems[recordingIndex].value = `${apiData.padRecordNum}条`
}
salaryItems[recordingIndex].centerRightPrice = formatDeductionAmount(apiData.padDeductionAmount) salaryItems[recordingIndex].centerRightPrice = formatDeductionAmount(apiData.padDeductionAmount)
salaryItems[recordingIndex].btnAble = apiData.padAppealable || false salaryItems[recordingIndex].btnAble = apiData.padAppealable || false
} }
......
import { envIndex } from '~/config' import {
envIndex
} from "~/config";
// console.log(envIndex, 'envIndex') // console.log(envIndex, 'envIndex')
const secretKey_items = { const secretKey_items = {
ip: { ip: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
dev: { dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
uat: { uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
prod: { prod: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022', appKey: "d7ffc3346fc9a45bccaaa35300d59022",
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353' secret: "4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353",
}, },
preRelease: { preRelease: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
cdptest: { cdptest: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
} },
} };
const scrmSecretKey_items = { const scrmSecretKey_items = {
ip: { ip: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
dev: { dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
uat: { uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
prod: { prod: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
preRelease: { preRelease: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
}, },
cdptest: { cdptest: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
} },
} };
const domain_items = { const domain_items = {
ip: { ip: {
// dj: 'http://192.168.1.165:8292', // dj: 'http://192.168.1.165:8292',
// dj: 'http://192.168.1.117:8292', //叶立庆 // dj: 'http://192.168.1.117:8292', //叶立庆
// dj: "http://192.168.1.86:8594", //蔡远明 // dj: "http://192.168.1.86:8594", //蔡远明
// dj: 'http://192.168.1.104:8292',//范富荣 // dj: 'http://192.168.1.104:8292',//范富荣
// dj: 'http://192.168.1.89:8292', //周杭 // dj: 'http://192.168.1.89:8292', //周杭
// dj: 'http://192.168.1.76:8292', //璐琦 // dj: 'http://192.168.1.76:8292', //璐琦
dj: 'http://192.168.1.122:8292', //庞善天 // dj: 'http://192.168.1.76:8292', //璐琦
// dj: 'http://192.168.1.227:8292',//陈希 // dj: 'http://192.168.1.227:8292',//陈希
// dj: 'http://192.168.1.67:8292',//周立明 // dj: 'http://192.168.1.67:8292',//周立明
// dj: 'http://192.168.148.235:8292',// 熊正顺 // dj: 'http://192.168.148.235:8292',// 熊正顺
// dj: 'http://192.168.148.221:8292', // dj: 'http://192.168.148.221:8292',
// scrm: 'http://192.168.1.165:8292' // scrm: 'http://192.168.1.165:8292'
scrm: 'https://scrm.dev.glsx.com.cn' scrm: "https://scrm.dev.glsx.com.cn",
}, },
dev: { dev: {
dj: 'http://dj.dev.glsx.com.cn', dj: "http://dj.dev.glsx.com.cn",
// dj: 'http://192.168.3.226:9711', // dj: 'http://192.168.3.226:9711',
scrm: 'https://scrm.dev.glsx.com.cn', scrm: "https://scrm.dev.glsx.com.cn",
merchants: 'http://rop-merchant.dev.glsx.com.cn', merchants: "http://rop-merchant.dev.glsx.com.cn",
AI: 'http://192.168.3.191:7864' AI: 'http://192.168.3.191:7864',
}, },
uat: { uat: {
dj: 'https://dj.test.glsx.com.cn', dj: "https://dj.test.glsx.com.cn",
scrm: 'https://scrm.test.glsx.com.cn', scrm: "https://scrm.test.glsx.com.cn",
AI: 'https://aipractice.test.glsx.com.cn', AI: 'https://aipractice.test.glsx.com.cn',
merchants: 'https://rop-merchant.test.glsx.com.cn' merchants: "https://rop-merchant.test.glsx.com.cn",
}, },
prod: { prod: {
dj: 'https://dj.glsx.com.cn', dj: "https://dj.glsx.com.cn",
scrm: 'https://scrm.glsx.com.cn', scrm: "https://scrm.glsx.com.cn",
AI: 'https://aipractice.glsx.com.cn', AI: 'https://aipractice.glsx.com.cn',
merchants: 'https://commodity.glsx.com.cn' merchants: "https://commodity.glsx.com.cn",
}, },
preRelease: { preRelease: {
dj: 'https://dj.beta.glsx.com.cn', dj: "https://dj.beta.glsx.com.cn",
scrm: 'https://scrm.beta.glsx.com.cn', scrm: "https://scrm.beta.glsx.com.cn",
merchants: 'https://rop-merchant.beta.glsx.com.cn', merchants: "https://rop-merchant.beta.glsx.com.cn",
AI: 'https://aipractice.beta.glsx.com.cn' AI: 'https://aipractice.beta.glsx.com.cn',
}, },
cdptest: { cdptest: {
dj: 'https://cdptest.glsx.com.cn', dj: "https://cdptest.glsx.com.cn",
scrm: 'https://cdptest.glsx.com.cn' scrm: "https://cdptest.glsx.com.cn",
} },
} };
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease', 'cdptest'] const target = ["ip", "dev", "uat", "prod", "preRelease", "cdptest"];
module.exports = { module.exports = {
domain: domain_items[target[envIndex]], domain: domain_items[target[envIndex]],
secretKey: { secretKey: {
dj: secretKey_items[target[envIndex]], dj: secretKey_items[target[envIndex]],
scrm: scrmSecretKey_items[target[envIndex]], scrm: scrmSecretKey_items[target[envIndex]],
merchants: scrmSecretKey_items[target[envIndex]], merchants: scrmSecretKey_items[target[envIndex]],
clue: scrmSecretKey_items[target[envIndex]] clue: scrmSecretKey_items[target[envIndex]]
} },
} };
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!