Commit 9e810b75 by Lin

feat: 销售列表接口联调

1 parent 81446f6c
......@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布
* 5cdptest
*/
let index = 0;
let index = 1;
const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion;
......
......@@ -66,4 +66,9 @@ module.exports = {
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
import { getSummaryInfo,querySceneRefByShop, getStatistics, getReplyList, getApplyLatest, createSalaryapply } from './api'
import comApi from '~/api/api'
import { getSummaryInfo, getStatistics, getReplyList, getApplyLatest, createSalaryapply,getEmployeeAllList } from './api'
Page({
/**
......@@ -81,7 +80,7 @@ Page({
// if (!this.data.staffOptions || this.data.staffOptions.length === 0) {
wx.showLoading({ title: '加载中...', mask: true })
try {
await this.getStaffList()
await this.getEmployeeAllList()
wx.hideLoading()
this.setData({
showStaffPopup: true
......@@ -118,12 +117,12 @@ Page({
const { value, option } = e.detail
console.log("e", e.detail);
console.log("onStaffSelectConfirm", value, option);
this.setData({
currentStaffName: option.text,
currentStaffId: value,
showStaffPopup: false
})
console.log("currentStaffId", this.data.currentStaffId);
// 根据选择的员工重新加载数据
// 获取概览信息
......@@ -133,90 +132,35 @@ Page({
// 获取申诉答复记录
this.getStaffReplyList()
},
/**
* 获取员工列表:先查询园区店,再获取员工列表
*/
async getStaffList() {
try {
// 获取商户ID
const userInfo = wx.$util.getUserInfo()
const merchantId = userInfo?.default4SStoreInfo?.merchantId || userInfo?.merchantId || ''
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
async getEmployeeAllList() {
const userInfo = wx.$util.getUserInfo()
const res = await getEmployeeAllList({
screen: userInfo?.sceneType
})
const { code, data, message } = res
if (code != 0) {
wx.$util.message(message || '获取员工列表失败')
return []
}
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月"
......@@ -411,22 +355,23 @@ Page({
async onLoad(options) {
// 获取用户信息并设置商户名称
this.initOrderObj()
// 获取概览信息
this.getStaffInfo()
// 获取订单统计信息
this.getOrderStatistics()
// 获取申诉答复记录
this.getStaffReplyList()
// 月份相关的初始化逻辑已移至组件内部处理
// 页面加载时自动获取员工列表并设置第一条数据
// 仅仅对超管和区域运营(区域经理)开放员工选择功能
// this.getEmployeeAllList()
// // 月份相关的初始化逻辑已移至组件内部处理
const userInfo = wx.$util.getUserInfo()
this.setData({
staffAbled: userInfo?.isSuper || userInfo?.loginRole == 3
})
if (userInfo?.isSuper || userInfo?.loginRole == 3) {
try {
await this.getStaffList()
await this.getEmployeeAllList()
// 获取概览信息
this.getStaffInfo()
// 获取订单统计信息
this.getOrderStatistics()
// 获取申诉答复记录
this.getStaffReplyList()
// 获取所有销售列表
} catch (error) {
console.error('页面加载时获取员工列表失败:', error)
}
......@@ -435,7 +380,7 @@ Page({
async getOrderStatistics() {
const userInfo = wx.$util.getUserInfo()
const res = await getStatistics({
staffPhone: userInfo?.phone,
staffPhone: this.data.currentStaffId,
appealMonth: this.data.currentMonth,
sceneType: userInfo?.sceneType
})
......@@ -484,7 +429,7 @@ Page({
async getStaffReplyList() {
const userInfo = wx.$util.getUserInfo()
const res = await getReplyList({
staffPhone: userInfo?.phone,
staffPhone: this.data.currentStaffId,
appealMonth: this.data.currentMonth
})
......@@ -517,7 +462,7 @@ Page({
const userInfo = wx.$util.getUserInfo()
// 先查4s店对应的园区店,再用园区店查员工
const res = await getSummaryInfo({
staffPhone: userInfo?.phone,
staffPhone: this.data.currentStaffId,
appealMonth: this.data.currentMonth
})
console.log(res, 'getStaffInfo')
......@@ -543,25 +488,21 @@ Page({
return `-${amount}元`
}
// 格式化数值显示(如 "26天"、"12条")
const formatValue = (value, unit) => {
if (value === null || value === undefined) {
return `0${unit}`
}
return `${value}${unit}`
}
// 更新attendance项(实际出勤天数)
const attendanceIndex = salaryItems.findIndex(item => item.id === 'attendance')
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
}
// 更新daily项(日报完成天数)
const dailyIndex = salaryItems.findIndex(item => item.id === 'daily')
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].bottomDays = formatMissingDates(apiData.missingDailyReportDates)
salaryItems[dailyIndex].btnAble = apiData.dailyReportable || false
......@@ -570,7 +511,9 @@ Page({
// 更新recording项(平板录音总数)
const recordingIndex = salaryItems.findIndex(item => item.id === 'recording')
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].btnAble = apiData.padAppealable || false
}
......
import { envIndex } from '~/config'
import {
envIndex
} from "~/config";
// console.log(envIndex, 'envIndex')
const secretKey_items = {
ip: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
prod: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
},
preRelease: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
cdptest: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
}
}
ip: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
dev: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
uat: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
prod: {
appKey: "d7ffc3346fc9a45bccaaa35300d59022",
secret: "4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353",
},
preRelease: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
cdptest: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
};
const scrmSecretKey_items = {
ip: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
prod: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
preRelease: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
cdptest: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
}
}
ip: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
dev: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
uat: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
prod: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
preRelease: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
cdptest: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
},
};
const domain_items = {
ip: {
// dj: 'http://192.168.1.165:8292',
// dj: 'http://192.168.1.117:8292', //叶立庆
// dj: "http://192.168.1.86:8594", //蔡远明
// dj: 'http://192.168.1.104:8292',//范富荣
// dj: 'http://192.168.1.89:8292', //周杭
// dj: 'http://192.168.1.76:8292', //璐琦
dj: 'http://192.168.1.122:8292', //庞善天
// dj: 'http://192.168.1.227:8292',//陈希
// dj: 'http://192.168.1.67:8292',//周立明
// dj: 'http://192.168.148.235:8292',// 熊正顺
// dj: 'http://192.168.148.221:8292',
// scrm: 'http://192.168.1.165:8292'
scrm: 'https://scrm.dev.glsx.com.cn'
},
dev: {
dj: 'http://dj.dev.glsx.com.cn',
// dj: 'http://192.168.3.226:9711',
scrm: 'https://scrm.dev.glsx.com.cn',
merchants: 'http://rop-merchant.dev.glsx.com.cn',
AI: 'http://192.168.3.191:7864'
},
ip: {
// dj: 'http://192.168.1.165:8292',
// dj: 'http://192.168.1.117:8292', //叶立庆
// dj: "http://192.168.1.86:8594", //蔡远明
// dj: 'http://192.168.1.104: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.227:8292',//陈希
// dj: 'http://192.168.1.67:8292',//周立明
// dj: 'http://192.168.148.235:8292',// 熊正顺
// dj: 'http://192.168.148.221:8292',
// scrm: 'http://192.168.1.165:8292'
scrm: "https://scrm.dev.glsx.com.cn",
},
dev: {
dj: "http://dj.dev.glsx.com.cn",
// dj: 'http://192.168.3.226:9711',
scrm: "https://scrm.dev.glsx.com.cn",
merchants: "http://rop-merchant.dev.glsx.com.cn",
AI: 'http://192.168.3.191:7864',
},
uat: {
dj: 'https://dj.test.glsx.com.cn',
scrm: 'https://scrm.test.glsx.com.cn',
AI: 'https://aipractice.test.glsx.com.cn',
merchants: 'https://rop-merchant.test.glsx.com.cn'
},
prod: {
dj: 'https://dj.glsx.com.cn',
scrm: 'https://scrm.glsx.com.cn',
AI: 'https://aipractice.glsx.com.cn',
merchants: 'https://commodity.glsx.com.cn'
},
preRelease: {
dj: 'https://dj.beta.glsx.com.cn',
scrm: 'https://scrm.beta.glsx.com.cn',
merchants: 'https://rop-merchant.beta.glsx.com.cn',
AI: 'https://aipractice.beta.glsx.com.cn'
},
cdptest: {
dj: 'https://cdptest.glsx.com.cn',
scrm: 'https://cdptest.glsx.com.cn'
}
}
uat: {
dj: "https://dj.test.glsx.com.cn",
scrm: "https://scrm.test.glsx.com.cn",
AI: 'https://aipractice.test.glsx.com.cn',
merchants: "https://rop-merchant.test.glsx.com.cn",
},
prod: {
dj: "https://dj.glsx.com.cn",
scrm: "https://scrm.glsx.com.cn",
AI: 'https://aipractice.glsx.com.cn',
merchants: "https://commodity.glsx.com.cn",
},
preRelease: {
dj: "https://dj.beta.glsx.com.cn",
scrm: "https://scrm.beta.glsx.com.cn",
merchants: "https://rop-merchant.beta.glsx.com.cn",
AI: 'https://aipractice.beta.glsx.com.cn',
},
cdptest: {
dj: "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 = {
domain: domain_items[target[envIndex]],
secretKey: {
dj: secretKey_items[target[envIndex]],
scrm: scrmSecretKey_items[target[envIndex]],
merchants: scrmSecretKey_items[target[envIndex]],
clue: scrmSecretKey_items[target[envIndex]]
}
}
domain: domain_items[target[envIndex]],
secretKey: {
dj: secretKey_items[target[envIndex]],
scrm: scrmSecretKey_items[target[envIndex]],
merchants: scrmSecretKey_items[target[envIndex]],
clue: scrmSecretKey_items[target[envIndex]]
},
};
\ 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!