Commit 065ff0ca by chenwq

feat(validReferralCount): 完善门店有效引荐数功能

- 新增门店有效引荐数详情、提交及考勤列表API
- 重构详情页数据绑定,移除mock数据,对接真实接口
- 优化编辑组件验证逻辑,当有效引荐数与交车数不一致时,要求必须上传凭证并填写备注
- 修复列表页数据渲染问题,调整数据结构并修复状态显示
- 实现草稿保存与提交功能,并添加加载状态防止重复提交
- 将考勤列表页从mock数据切换为真实接口调用
1 parent ff297f3d
...@@ -413,10 +413,31 @@ module.exports = { ...@@ -413,10 +413,31 @@ module.exports = {
return api.post('dj.api.smartcarlife.vehicle.damage.upgrade.quotation.outputValueStatistics', data) return api.post('dj.api.smartcarlife.vehicle.damage.upgrade.quotation.outputValueStatistics', data)
}, },
/** 门店有效引荐数列表*/ /** 门店有效引荐数列表 */
getReferralList(data) { getReferralList(data) {
return api.post('dj.api.staff.miniprogram.effective.referral.store.list', data, return api.post('dj.api.staff.miniprogram.effective.referral.store.list', data,
[], [],
'/rop-dj-staff-miniprogram/router') '/rop-dj-staff-miniprogram/router')
}, },
/** 门店有效引荐数详情 */
getReferralDetail(data) {
return api.post('dj.api.staff.miniprogram.effective.referral.store.detail', data,
[],
'/rop-dj-staff-miniprogram/router')
},
/** 门店有效引荐数提交 */
referralSubmit(data) {
return api.post('dj.api.staff.miniprogram.effective.referral.store.submit', data,
[],
'/rop-dj-staff-miniprogram/router')
},
/** 考勤列表 */
getStaffAttendanceList(data) {
return api.post('dj.staff.api.attendance.list', data,
[],
'/rop-dj-staff-miniprogram/router')
},
}; };
// packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.js // packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.js
import api from '../../../api'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -43,76 +44,30 @@ Page({ ...@@ -43,76 +44,30 @@ Page({
search() { search() {
this.setData({ this.setData({
list: [], list: [],
pageNum: 1,
flag: false,
nothing: false, nothing: false,
}); });
// 模拟接口请求 this.getList();
setTimeout(() => {
this.getList();
}, 500);
}, },
/** /**
* 获取列表数据 (Mock) * 获取列表数据 (Mock)
*/ */
getList() { getList() {
// 模拟数据 // this.setData({
const mockList = [ // list: [filteredList], // 二维数组结构,保持与referralCountList一致的渲染逻辑 if needed, but simple list is better.
{ // // Checking referralCountList.wxml: <block wx:for="{{ list }}" ...><block wx:for="{{ item }}" ...>
id: 1, // // It seems referralCountList uses a 2D array for pagination pages. I will mimic that structure for consistency.
mobilePhone: "", // triggered: false,
name: "张三222222222222222222222222222222dddddddddddddddddd", // nothing: true, // Mocking end of list
merchantId: 1001, // });
merchantAttendanceListId: 2001, let { pageNum, nothing, searchObj } = this.data;
attendanceMonth: "2026-01", let userInfo = wx.$util.getUserInfo();
expectedAttendanceDays: 27, if (nothing) return;
actualAttendanceDays: 27,
appealAttendanceDays: 0,
attendanceDays: 27,
superiorLeaderMobilePhone: "",
},
{
id: 2,
mobilePhone: "",
name: "张树",
merchantId: 1002,
merchantAttendanceListId: 2002,
attendanceMonth: "2025-12",
expectedAttendanceDays: 27,
actualAttendanceDays: 27,
appealAttendanceDays: 0,
attendanceDays: 27,
superiorLeaderMobilePhone: "",
},
{
id: 3,
mobilePhone: "",
name: "张上分",
merchantId: 1003,
merchantAttendanceListId: 2003,
attendanceMonth: "2025-01",
expectedAttendanceDays: 27,
actualAttendanceDays: 27,
appealAttendanceDays: 0,
attendanceDays: 27,
superiorLeaderMobilePhone: "",
},
];
// 简单的本地过滤模拟
let filteredList = mockList;
// const { name, attendanceMonth } = this.data.searchObj;
this.setData({
list: [filteredList], // 二维数组结构,保持与referralCountList一致的渲染逻辑 if needed, but simple list is better.
// Checking referralCountList.wxml: <block wx:for="{{ list }}" ...><block wx:for="{{ item }}" ...>
// It seems referralCountList uses a 2D array for pagination pages. I will mimic that structure for consistency.
triggered: false,
nothing: true, // Mocking end of list
});
return
wx.$util.showLoading(); wx.$util.showLoading();
api api
.getReferralList({ .getStaffAttendanceList({
...searchObj, ...searchObj,
pageNum, pageNum,
pageSize: 10, pageSize: 10,
......
...@@ -25,6 +25,7 @@ Component({ ...@@ -25,6 +25,7 @@ Component({
}, },
isRemarkRequired: false, isRemarkRequired: false,
fileList: [], // For uploader fileList: [], // For uploader
fileMaxLen: 15
}, },
lifetimes: { lifetimes: {
...@@ -103,9 +104,9 @@ Component({ ...@@ -103,9 +104,9 @@ Component({
// Upload Images // Upload Images
uploadImages() { uploadImages() {
let _this = this let _this = this
let { fileList } = _this.data let { fileList, fileMaxLen } = _this.data
wx.chooseMedia({ wx.chooseMedia({
count: 15 - fileList.length, count: fileMaxLen - fileList.length,
sizeType: ['original'], sizeType: ['original'],
mediaType: ['image'], mediaType: ['image'],
success(res) { success(res) {
...@@ -179,27 +180,37 @@ Component({ ...@@ -179,27 +180,37 @@ Component({
// Validate Referral Counts // Validate Referral Counts
validateReferralCounts() { validateReferralCounts() {
const { effectiveReferralCountDTOS, remark } = this.data.item; const { effectiveReferralCountDTOS, remark } = this.data.item;
const { isRemarkRequired } = this.data; const { isRemarkRequired, fileList } = this.data;
if (effectiveReferralCountDTOS && effectiveReferralCountDTOS.length > 0) { if (effectiveReferralCountDTOS && effectiveReferralCountDTOS.length > 0) {
for (const dto of effectiveReferralCountDTOS) { for (const dto of effectiveReferralCountDTOS) {
const val = dto.effectiveReferralCount; const val = dto.effectiveReferralCount;
if (val == null || val == undefined || val == '') { if (val == null || val == undefined || val == "") {
wx.showToast({ wx.showToast({
title: `${dto.brandName}交车数有效引荐数未填`, title: `${dto.brandName}交车数有效引荐数未填`,
icon: 'none' icon: "none",
}); });
return false; return false;
} }
} }
} }
if (isRemarkRequired && !remark) { if (isRemarkRequired) {
wx.showToast({ if (fileList.length === 0) {
title: '有效引荐数与交车数不一致,请填写备注', wx.showToast({
icon: 'none' title: "有效引荐数与交车数不一致,请上传凭证",
}); icon: "none",
return false; });
return false;
}
if (!remark) {
wx.showToast({
title: "有效引荐数与交车数不一致,请填写备注",
icon: "none",
});
return false;
}
} }
return true; return true;
......
...@@ -46,16 +46,18 @@ ...@@ -46,16 +46,18 @@
<!-- Uploader --> <!-- Uploader -->
<view class="section"> <view class="section">
<view class="section-title label">上传凭证</view> <view class="section-title label">
上传凭证<text wx:if="{{isRemarkRequired}}" style="color: #ee0a24; margin-left: 8rpx;">*</text>
</view>
<view class="upload_box"> <view class="upload_box">
<view class="content_box"> <view class="content_box">
<view class="image_content" wx:for="{{fileList}}" wx:key="index"> <view class="image_content" wx:for="{{fileList}}" wx:key="index">
<image bindtap="previewImage" class="image_box" data-url="{{fileList}}" data-index="{{index}}" src="{{item.fileUrl}}"/> <image bindtap="previewImage" class="image_box" data-url="{{fileList}}" data-index="{{index}}" src="{{item.fileUrl}}"/>
<image class="del_icon" src="{{IMG_URL}}zy_paf_del_icon.png" mode="" bindtap="deleteFile" data-index="{{index}}" /> <image class="del_icon" src="{{IMG_URL}}zy_paf_del_icon.png" mode="" bindtap="deleteFile" data-index="{{index}}" />
</view> </view>
<view class="upload_content" bindtap="uploadImages" wx:if="{{fileList.length < 15}}"> <view class="upload_content" bindtap="uploadImages" wx:if="{{fileList.length < fileMaxLen}}">
<image src="{{IMG_URL}}zy-upload_icon.png"></image> <image src="{{IMG_URL}}zy-upload_icon.png"></image>
<text class="text">{{fileList.length}} / 15</text> <text class="text">{{fileList.length}}/{{fileMaxLen}}</text>
</view> </view>
</view> </view>
</view> </view>
......
// packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit.js // packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit.js
import api from '../../../api'
Page({ Page({
/** /**
...@@ -6,7 +7,8 @@ Page({ ...@@ -6,7 +7,8 @@ Page({
*/ */
data: { data: {
routerParams: {}, routerParams: {},
mockData: {} detailInfo: {},
loading: false
}, },
/** /**
...@@ -16,110 +18,94 @@ Page({ ...@@ -16,110 +18,94 @@ Page({
this.setData({ this.setData({
routerParams: options routerParams: options
}); });
this.fetchData(); console.log(options, 'options----')
this.getDetail();
}, },
// Simulate fetching data from backend defaultFillVal(data) {
fetchData() { data.sceneTypeEffectiveReferrals.forEach(item => {
// In a real scenario, you would make a request using this.data.routerParams // 状态:0-未提交,1-草稿,2-已提交
// For now, using the structure provided in the prompt if (item.status == 0) {
if (item.effectiveReferralCountDTOS && item.effectiveReferralCountDTOS.length) {
// Simulating API response item.effectiveReferralCountDTOS.forEach(k => {
const mockData = { k.effectiveReferralCount = k.deliveryCount || '0'
merchantName: "7777", })
sceneTypeEffectiveReferrals: [ }
{ }
sceneType: 1, // 精品升级(轻改) })
effectiveReferralCountDTOS: [ return data || []
{ },
brandType: 0,
brandName: "问界",
deliveryCount: 10,
effectiveReferralCount: "",
},
{
brandType: 1,
brandName: "智界",
deliveryCount: 5,
effectiveReferralCount: "",
},
],
status: 0, // 0-未提交
imageUrls: "",
remark: "",
},
{
sceneType: 2, // 会员权益(广联权益)
effectiveReferralCountDTOS: [
{
brandType: 0,
brandName: "问界",
deliveryCount: 20,
effectiveReferralCount: "20",
reviewedEffectiveCount: "18",
},
{
brandType: 2,
brandName: "享界享界享界享界享界享界享界享界享界享界享界享界",
deliveryCount: 8,
effectiveReferralCount: "8",
reviewedEffectiveCount: "8",
},
],
status: 2, // 2-已提交
imageUrls:
"https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/zy_paf_del_icon.png,https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/zy_paf_del_icon.png,https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/zy_paf_del_icon.png,https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/zy_paf_del_icon.png,https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/zy_paf_del_icon.png", // Example URL
remark: "",
},
],
};
this.setData({ // Simulate fetching data from backend
mockData: mockData getDetail() {
}); let { merchantId } = this.data.routerParams
const params = {
merchantId
}
api.getReferralDetail(params).then(res => {
let { code, data, message } = res;
console.log(data)
if (code == 0) {
let list = this.defaultFillVal(data)
this.setData({
detailInfo: list
})
}
})
}, },
// Handle Save Draft // Handle Save Draft
onDraft(e) { onDraft(e) {
const updatedItem = e.detail; const updatedItem = e.detail;
console.log('Save Draft:', updatedItem); console.log('Save Draft:', updatedItem);
// Logic to save draft to backend this.updateLocalList('draft', updatedItem);
// You might want to update the local list with the new item data
this.updateLocalList(updatedItem);
wx.showToast({
title: '草稿已保存',
icon: 'success'
});
}, },
// Handle Submit // Handle Submit
onSubmitItem(e) { onSubmitItem(e) {
const updatedItem = e.detail; const updatedItem = e.detail;
console.log('Submit Item:', updatedItem); console.log('Submit Item:', updatedItem);
// Validation Logic (Basic check if needed) this.updateLocalList('submit', updatedItem);
// The component might do some validation, but parent can also enforce rules.
// Logic to submit to backend
this.updateLocalList(updatedItem);
wx.showToast({
title: '提交成功',
icon: 'success'
});
}, },
// Helper to update the specific item in the list based on sceneType /** typeStatus: 草稿(draft),提交(submit) */
updateLocalList(updatedItem) { updateLocalList(typeStatus, updatedItem) {
const list = this.data.mockData.sceneTypeEffectiveReferrals; let { loading } = this.data
if (loading) {
return
}
const list = this.data.detailInfo.sceneTypeEffectiveReferrals;
const index = list.findIndex(item => item.sceneType === updatedItem.sceneType); const index = list.findIndex(item => item.sceneType === updatedItem.sceneType);
if (index !== -1) { const tipsObj = {
const key = `mockData.sceneTypeEffectiveReferrals[${index}]`; 'draft': '草稿',
this.setData({ 'submit': '提交',
[key]: updatedItem
});
} }
console.log(list, 'list----')
console.log(index, 'index----')
const params = {
// 1-草稿,2-已提交
...list[index],
status: typeStatus == 'submit' ? 2 : 1
}
console.log(params, 'params---')
wx.$util.showLoading()
this.setData({
loading: true
})
api.referralSubmit(params).then(res => {
wx.showToast({
// title: `${tipsObj[typeStatus]}`,
title: '操作成功',
icon: 'success'
});
this.getDetail()
}).finally(() => {
wx.hideLoading();
this.setData({
loading: false
})
})
}, },
/** /**
......
<!--packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit.wxml--> <!--packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit.wxml-->
<view class="container"> <view class="container">
<view wx:for="{{mockData.sceneTypeEffectiveReferrals}}" class="edit-box"> <view wx:for="{{detailInfo.sceneTypeEffectiveReferrals}}" class="edit-box">
<view class="merchant-name" wx:if="{{index == 0}}">{{mockData.merchantName}}</view> <view class="merchant-name" wx:if="{{index == 0}}">{{detailInfo.merchantName}}</view>
<!-- Render Detail View if status is 2 (Submitted) --> <!-- Render Detail View if status is 2 (Submitted) -->
<block wx:if="{{item.status == 2}}"> <block wx:if="{{item.status == 2}}">
......
...@@ -107,7 +107,7 @@ Page({ ...@@ -107,7 +107,7 @@ Page({
}) })
.then((res) => { .then((res) => {
wx.$util.hideLoading(); wx.$util.hideLoading();
let total = 0; // let total = 0;
let list = []; let list = [];
let { code, data, message } = res; let { code, data, message } = res;
console.log(data) console.log(data)
...@@ -123,6 +123,7 @@ Page({ ...@@ -123,6 +123,7 @@ Page({
// }); // });
// } // }
this.setData({ this.setData({
list: list,
// total, // total,
flag: true, flag: true,
triggered: false, triggered: false,
...@@ -164,6 +165,7 @@ Page({ ...@@ -164,6 +165,7 @@ Page({
handleDetail(e) { handleDetail(e) {
let { target } = e.currentTarget.dataset; let { target } = e.currentTarget.dataset;
console.log(target)
wx.navigateTo({ wx.navigateTo({
url: url:
"/packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit?merchantId=" + "/packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit?merchantId=" +
......
...@@ -15,33 +15,33 @@ ...@@ -15,33 +15,33 @@
<scroll-view scroll-y enable-back-to-top refresher-enabled="{{ true }}" bindrefresherrefresh="search" bindscrolltolower="scrollonReachBottom" class="list" style="height:calc(100vh - var(--fontSize184));" refresher-threshold="104" refresher-triggered="{{ triggered }}"> <scroll-view scroll-y enable-back-to-top refresher-enabled="{{ true }}" bindrefresherrefresh="search" bindscrolltolower="scrollonReachBottom" class="list" style="height:calc(100vh - var(--fontSize184));" refresher-threshold="104" refresher-triggered="{{ triggered }}">
<block wx:if="{{ list.length > 0 }}"> <block wx:if="{{ list.length > 0 }}">
<view class="empty-box"></view> <view class="empty-box"></view>
<block wx:for="{{ list }}" wx:key="index"> <!-- <block wx:for="{{ list }}" wx:key="index"> -->
<block wx:for="{{ item }}" wx:for-item="li" wx:for-index="ind" wx:key="ind"> <block wx:for="{{ list }}" wx:for-index="ind" wx:key="ind">
<view data-ind="{{ ind }}" data-index="{{ index }}"> <view data-ind="{{ ind }}" data-index="{{ index }}">
<view class="item content" data-ind="{{ ind }}" data-index="{{ index }}" data-item="{{ li }}"> <view class="item content" data-ind="{{ ind }}" data-index="{{ index }}" data-item="{{ item }}">
<view class="item-top"> <view class="item-top">
<view class="code"> <view class="code">
<text class="code-text">{{li.merchantName}}</text> <text class="code-text">{{item.merchantName}}</text>
</view>
<view class="status text-center" style="color:{{ orderStatusMap[li.submitStatus].color }};background-color:{{orderStatusMap[li.submitStatus].background }};">
{{orderStatusMap[li.submitStatus].name }}
</view>
</view>
<view class="order-list flex">
<view wx:for="{{ orderItem }}" wx:key="sindex" wx:for-index="sindex" wx:for-item="i">
<view class="order">
<view class="order-label">{{i.label}}</view>
<view class="order-value">{{singleSubmitStatusMap[li[i.key]]}}</view>
</view>
</view>
</view> </view>
<view class="btn-box flex"> <view class="status text-center" style="color:{{ orderStatusMap[item.submitStatus].color }};background-color:{{orderStatusMap[item.submitStatus].background }};">
<view bindtap="handleDetail" data-target="{{li}}" class="btn {{li.submitStatus == 0 ? 'primary' : ''}}">{{li.submitStatus == 0 ? '编辑' : '查看'}}</view> {{orderStatusMap[item.submitStatus].name }}
</view> </view>
</view> </view>
<view class="order-list flex">
<block wx:for="{{ orderItem }}" wx:for-index="sindex" wx:for-item="i">
<view class="order" wx-if="{{ item[i.key] != null }}" wx:key="sindex">
<view class="order-label">{{i.label}}</view>
<view class="order-value">{{singleSubmitStatusMap[item[i.key]]}}</view>
</view>
</block>
</view>
<view class="btn-box flex">
<view bindtap="handleDetail" data-target="{{item}}" class="btn {{item.submitStatus == 0 ? 'primary' : ''}}">{{item.submitStatus == 0 ? '编辑' : '查看'}}</view>
</view>
</view> </view>
</block> </view>
</block> </block>
<!-- </block> -->
<block wx:if="{{ nothing }}"> <block wx:if="{{ nothing }}">
<view class="list-nothing">到底了~</view> <view class="list-nothing">到底了~</view>
</block> </block>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!