Commit 065ff0ca by chenwq

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

- 新增门店有效引荐数详情、提交及考勤列表API
- 重构详情页数据绑定,移除mock数据,对接真实接口
- 优化编辑组件验证逻辑,当有效引荐数与交车数不一致时,要求必须上传凭证并填写备注
- 修复列表页数据渲染问题,调整数据结构并修复状态显示
- 实现草稿保存与提交功能,并添加加载状态防止重复提交
- 将考勤列表页从mock数据切换为真实接口调用
1 parent ff297f3d
......@@ -413,10 +413,31 @@ module.exports = {
return api.post('dj.api.smartcarlife.vehicle.damage.upgrade.quotation.outputValueStatistics', data)
},
/** 门店有效引荐数列表*/
/** 门店有效引荐数列表 */
getReferralList(data) {
return api.post('dj.api.staff.miniprogram.effective.referral.store.list', data,
[],
'/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
import api from '../../../api'
Page({
/**
* 页面的初始数据
......@@ -43,76 +44,30 @@ Page({
search() {
this.setData({
list: [],
pageNum: 1,
flag: false,
nothing: false,
});
// 模拟接口请求
setTimeout(() => {
this.getList();
}, 500);
this.getList();
},
/**
* 获取列表数据 (Mock)
*/
getList() {
// 模拟数据
const mockList = [
{
id: 1,
mobilePhone: "",
name: "张三222222222222222222222222222222dddddddddddddddddd",
merchantId: 1001,
merchantAttendanceListId: 2001,
attendanceMonth: "2026-01",
expectedAttendanceDays: 27,
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
// 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
// });
let { pageNum, nothing, searchObj } = this.data;
let userInfo = wx.$util.getUserInfo();
if (nothing) return;
wx.$util.showLoading();
api
.getReferralList({
.getStaffAttendanceList({
...searchObj,
pageNum,
pageSize: 10,
......
......@@ -25,6 +25,7 @@ Component({
},
isRemarkRequired: false,
fileList: [], // For uploader
fileMaxLen: 15
},
lifetimes: {
......@@ -103,9 +104,9 @@ Component({
// Upload Images
uploadImages() {
let _this = this
let { fileList } = _this.data
let { fileList, fileMaxLen } = _this.data
wx.chooseMedia({
count: 15 - fileList.length,
count: fileMaxLen - fileList.length,
sizeType: ['original'],
mediaType: ['image'],
success(res) {
......@@ -179,27 +180,37 @@ Component({
// Validate Referral Counts
validateReferralCounts() {
const { effectiveReferralCountDTOS, remark } = this.data.item;
const { isRemarkRequired } = this.data;
const { isRemarkRequired, fileList } = this.data;
if (effectiveReferralCountDTOS && effectiveReferralCountDTOS.length > 0) {
for (const dto of effectiveReferralCountDTOS) {
const val = dto.effectiveReferralCount;
if (val == null || val == undefined || val == '') {
if (val == null || val == undefined || val == "") {
wx.showToast({
title: `${dto.brandName}交车数有效引荐数未填`,
icon: 'none'
icon: "none",
});
return false;
}
}
}
if (isRemarkRequired && !remark) {
wx.showToast({
title: '有效引荐数与交车数不一致,请填写备注',
icon: 'none'
});
return false;
if (isRemarkRequired) {
if (fileList.length === 0) {
wx.showToast({
title: "有效引荐数与交车数不一致,请上传凭证",
icon: "none",
});
return false;
}
if (!remark) {
wx.showToast({
title: "有效引荐数与交车数不一致,请填写备注",
icon: "none",
});
return false;
}
}
return true;
......
......@@ -46,16 +46,18 @@
<!-- Uploader -->
<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="content_box">
<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 class="del_icon" src="{{IMG_URL}}zy_paf_del_icon.png" mode="" bindtap="deleteFile" data-index="{{index}}" />
</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>
<text class="text">{{fileList.length}} / 15</text>
<text class="text">{{fileList.length}}/{{fileMaxLen}}</text>
</view>
</view>
</view>
......
// packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit.js
import api from '../../../api'
Page({
/**
......@@ -6,7 +7,8 @@ Page({
*/
data: {
routerParams: {},
mockData: {}
detailInfo: {},
loading: false
},
/**
......@@ -16,110 +18,94 @@ Page({
this.setData({
routerParams: options
});
this.fetchData();
console.log(options, 'options----')
this.getDetail();
},
// Simulate fetching data from backend
fetchData() {
// In a real scenario, you would make a request using this.data.routerParams
// For now, using the structure provided in the prompt
// Simulating API response
const mockData = {
merchantName: "7777",
sceneTypeEffectiveReferrals: [
{
sceneType: 1, // 精品升级(轻改)
effectiveReferralCountDTOS: [
{
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: "",
},
],
};
defaultFillVal(data) {
data.sceneTypeEffectiveReferrals.forEach(item => {
// 状态:0-未提交,1-草稿,2-已提交
if (item.status == 0) {
if (item.effectiveReferralCountDTOS && item.effectiveReferralCountDTOS.length) {
item.effectiveReferralCountDTOS.forEach(k => {
k.effectiveReferralCount = k.deliveryCount || '0'
})
}
}
})
return data || []
},
this.setData({
mockData: mockData
});
// Simulate fetching data from backend
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
onDraft(e) {
const updatedItem = e.detail;
console.log('Save Draft:', updatedItem);
// Logic to save draft to backend
// You might want to update the local list with the new item data
this.updateLocalList(updatedItem);
wx.showToast({
title: '草稿已保存',
icon: 'success'
});
this.updateLocalList('draft', updatedItem);
},
// Handle Submit
onSubmitItem(e) {
const updatedItem = e.detail;
console.log('Submit Item:', updatedItem);
// Validation Logic (Basic check if needed)
// 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'
});
this.updateLocalList('submit', updatedItem);
},
// Helper to update the specific item in the list based on sceneType
updateLocalList(updatedItem) {
const list = this.data.mockData.sceneTypeEffectiveReferrals;
/** typeStatus: 草稿(draft),提交(submit) */
updateLocalList(typeStatus, updatedItem) {
let { loading } = this.data
if (loading) {
return
}
const list = this.data.detailInfo.sceneTypeEffectiveReferrals;
const index = list.findIndex(item => item.sceneType === updatedItem.sceneType);
if (index !== -1) {
const key = `mockData.sceneTypeEffectiveReferrals[${index}]`;
this.setData({
[key]: updatedItem
});
const tipsObj = {
'draft': '草稿',
'submit': '提交',
}
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-->
<view class="container">
<view wx:for="{{mockData.sceneTypeEffectiveReferrals}}" class="edit-box">
<view class="merchant-name" wx:if="{{index == 0}}">{{mockData.merchantName}}</view>
<view wx:for="{{detailInfo.sceneTypeEffectiveReferrals}}" class="edit-box">
<view class="merchant-name" wx:if="{{index == 0}}">{{detailInfo.merchantName}}</view>
<!-- Render Detail View if status is 2 (Submitted) -->
<block wx:if="{{item.status == 2}}">
......
......@@ -107,7 +107,7 @@ Page({
})
.then((res) => {
wx.$util.hideLoading();
let total = 0;
// let total = 0;
let list = [];
let { code, data, message } = res;
console.log(data)
......@@ -123,6 +123,7 @@ Page({
// });
// }
this.setData({
list: list,
// total,
flag: true,
triggered: false,
......@@ -164,6 +165,7 @@ Page({
handleDetail(e) {
let { target } = e.currentTarget.dataset;
console.log(target)
wx.navigateTo({
url:
"/packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit?merchantId=" +
......
......@@ -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 }}">
<block wx:if="{{ list.length > 0 }}">
<view class="empty-box"></view>
<block wx:for="{{ list }}" wx:key="index">
<block wx:for="{{ item }}" wx:for-item="li" wx:for-index="ind" wx:key="ind">
<view data-ind="{{ ind }}" data-index="{{ index }}">
<view class="item content" data-ind="{{ ind }}" data-index="{{ index }}" data-item="{{ li }}">
<view class="item-top">
<view class="code">
<text class="code-text">{{li.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>
<!-- <block wx:for="{{ list }}" wx:key="index"> -->
<block wx:for="{{ list }}" wx:for-index="ind" wx:key="ind">
<view data-ind="{{ ind }}" data-index="{{ index }}">
<view class="item content" data-ind="{{ ind }}" data-index="{{ index }}" data-item="{{ item }}">
<view class="item-top">
<view class="code">
<text class="code-text">{{item.merchantName}}</text>
</view>
<view class="btn-box flex">
<view bindtap="handleDetail" data-target="{{li}}" class="btn {{li.submitStatus == 0 ? 'primary' : ''}}">{{li.submitStatus == 0 ? '编辑' : '查看'}}</view>
<view class="status text-center" style="color:{{ orderStatusMap[item.submitStatus].color }};background-color:{{orderStatusMap[item.submitStatus].background }};">
{{orderStatusMap[item.submitStatus].name }}
</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>
</block>
</view>
</block>
<!-- </block> -->
<block wx:if="{{ nothing }}">
<view class="list-nothing">到底了~</view>
</block>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!