Commit 1f3cefba by chenwq

feat(validReferralCount): 添加详情组件并实现状态区分展示

添加detailItem组件用于展示已提交状态的引荐数据
修改editItem组件样式并提取公共按钮样式
根据item.status在referraCountEdit页面区分展示编辑和详情视图
更新mock数据以测试不同状态下的展示效果
1 parent a0e101e8
// packageWorkspace/pages/validReferralCount/components/detailItem/detailItem.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
Component({
properties: {
item: {
type: Object,
value: {},
observer(newVal) {
if (newVal) {
this.initData(newVal);
}
}
}
},
data: {
IMG_URL,
// 业务场景:1-精品升级(轻改);2-会员权益(广联权益);3-单延保;
sceneMap: {
1: '轻改',
2: '广联权益',
3: '单延保'
},
fileList: []
},
methods: {
initData(item) {
if (item.imageUrls) {
const urls = item.imageUrls.split(',').filter(i => i);
const fileList = urls.map(url => ({
fileUrl: url,
}));
this.setData({ fileList });
} else {
this.setData({ fileList: [] });
}
},
previewImage(e) {
const { index } = e.currentTarget.dataset;
const { fileList } = this.data;
const urls = fileList.map(v => v.fileUrl);
wx.previewImage({
urls: urls,
current: urls[index]
});
}
}
})
/* packageWorkspace/pages/validReferralCount/components/detailItem/detailItem.wxss */
.detail-item-container {
background-color: #fff;
border-radius: 16rpx;
// padding: 24rpx; // Assuming padding inside container
}
.header {
margin-bottom: 20rpx;
}
.title-bar {
display: flex;
align-items: center;
font-weight: 500;
margin: 16rpx 0;
image {
width: 6rpx;
height: 24rpx;
margin-right: 16rpx;
}
}
.title {
font-size: 30rpx;
font-weight: bold;
color: #333;
}
.brand-list {
margin-bottom: 30rpx;
}
.brand-item {
margin-bottom: 30rpx;
&:last-child {
margin-bottom: 0;
}
}
.data-grid {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.grid-col {
display: flex;
flex-direction: column;
padding-right: 28rpx;
&:first-child {
width: 184rpx;
}
&:last-child {
flex-shrink: 0;
width: 252rpx;
padding-right: 0;
}
}
.label-text {
font-size: 24rpx;
color: #999;
margin-bottom: 12rpx;
line-height: 1.2;
}
.value-text {
font-size: 32rpx;
color: #1989fa; // Blue color
font-weight: 500;
}
.section {
margin-bottom: 30rpx;
}
.section-title {
margin-bottom: 20rpx;
}
.label {
font-size: 28rpx;
color: #333;
font-weight: 600;
}
.image-list {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
}
.image-item {
width: 192rpx;
height: 192rpx;
border-radius: 8rpx;
background-color: #f0f0f0;
}
.remark-content {
font-size: 28rpx;
color: #333;
line-height: 1.5;
text-align: justify;
word-break: break-all;
}
<!--packageWorkspace/pages/validReferralCount/components/detailItem/detailItem.wxml-->
<wxs module="utils">
var formatBrandName = function(name) {
if (!name) return '';
if (name.length > 10) {
return name.substring(0, 10) + '...';
}
return name;
}
module.exports = {
formatBrandName: formatBrandName
}
</wxs>
<view class="detail-item-container">
<!-- Title -->
<view class="header">
<view class="title-bar">
<image src="{{IMG_URL}}title_icon.png" mode=""/>
<text class="title">{{sceneMap[item.sceneType] || '未知业务'}}</text>
</view>
</view>
<!-- List of Brands -->
<view class="brand-list">
<block wx:for="{{item.effectiveReferralCountDTOS}}" wx:key="brandType" wx:for-item="dto">
<view class="brand-item">
<!-- Grid Layout -->
<view class="data-grid">
<!-- Column 1: Delivery Count -->
<view class="grid-col">
<view class="label-text">{{utils.formatBrandName(dto.brandName)}}交车数</view>
<view class="value-text">{{dto.deliveryCount}}</view>
</view>
<!-- Column 2: Effective Referral Count -->
<view class="grid-col">
<view class="label-text">有效引荐数</view>
<view class="value-text">{{dto.effectiveReferralCount}}</view>
</view>
<!-- Column 3: Reviewed Effective Count -->
<view class="grid-col">
<view class="label-text">运营修正有效引荐数</view>
<view class="value-text">{{dto.reviewedEffectiveCount || '-'}}</view>
</view>
</view>
</view>
</block>
</view>
<!-- Evidence -->
<view class="section" wx:if="{{fileList.length > 0}}">
<view class="section-title label">凭证</view>
<view class="image-list">
<block wx:for="{{fileList}}" wx:key="index">
<image
class="image-item"
src="{{item.fileUrl}}"
mode="aspectFill"
data-index="{{index}}"
bindtap="previewImage"
/>
</block>
</view>
</view>
<!-- Remark -->
<view class="section" style="margin: 0;">
<view class="section-title label">备注</view>
<view class="remark-content">
<text>{{item.remark || '-'}}</text>
</view>
</view>
</view>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
} }
.brand-item { .brand-item {
border-bottom: 1rpx solid #e6e7eb;
border-radius: 16rpx 16rpx 0 0;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
...@@ -56,6 +58,11 @@ ...@@ -56,6 +58,11 @@
font-weight: 600; font-weight: 600;
} }
.label-tip {
font-size: 28rpx;
color: #999999;
}
.brand-name { .brand-name {
display: inline-block; display: inline-block;
max-width: 372rpx; max-width: 372rpx;
...@@ -107,15 +114,18 @@ ...@@ -107,15 +114,18 @@
margin-right: 24rpx; margin-right: 24rpx;
} }
.btn {
height: 64rpx !important;
border-radius: 16rpx !important;
border: none !important;
}
.btn-draft { .btn-draft {
background-color: #e8f0fe !important; background-color: #e8f0fe !important;
color: #2C66F7 !important; color: #2C66F7 !important;
border: none !important;
border-radius: 16rpx !important;
} }
.btn-submit { .btn-submit {
border-radius: 16rpx !important;
background-color: #2C66F7 !important; background-color: #2C66F7 !important;
color: #fff !important; color: #fff !important;
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
input-align="right" input-align="right"
custom-class="field-no-padding" custom-class="field-no-padding"
> >
<view slot="label"> <view slot="label" class="label-tip">
有效引荐数<text style="color: #ee0a24; margin-left: 8rpx;">*</text> 有效引荐数<text style="color: #ee0a24; margin-left: 8rpx;">*</text>
</view> </view>
</van-field> </van-field>
...@@ -80,10 +80,10 @@ ...@@ -80,10 +80,10 @@
<!-- Footer Buttons --> <!-- Footer Buttons -->
<view class="footer"> <view class="footer">
<view class="btn-wrapper"> <view class="btn-wrapper">
<van-button type="default" block custom-class="btn-draft" bind:click="onDraft">存草稿</van-button> <van-button type="default" block custom-class="btn btn-draft" bind:click="onDraft">存草稿</van-button>
</view> </view>
<view class="btn-wrapper"> <view class="btn-wrapper">
<van-button type="info" block custom-class="btn-submit" bind:click="onSubmit">提交</van-button> <van-button type="info" block custom-class="btn btn-submit" bind:click="onSubmit">提交</van-button>
</view> </view>
</view> </view>
</view> </view>
...@@ -29,24 +29,49 @@ Page({ ...@@ -29,24 +29,49 @@ Page({
merchantName: "7777", merchantName: "7777",
sceneTypeEffectiveReferrals: [ sceneTypeEffectiveReferrals: [
{ {
"sceneType": 1, // 精品升级(轻改) sceneType: 1, // 精品升级(轻改)
"effectiveReferralCountDTOS": [ effectiveReferralCountDTOS: [
{ "brandType": 0, "brandName": "问界23213123132132132132132132132132132", "deliveryCount": 10, "effectiveReferralCount": '' }, {
{ "brandType": 1, "brandName": "智界", "deliveryCount": 5, "effectiveReferralCount": '' } brandType: 0,
brandName: "问界",
deliveryCount: 10,
effectiveReferralCount: "",
},
{
brandType: 1,
brandName: "智界",
deliveryCount: 5,
effectiveReferralCount: "",
},
], ],
"imageUrls": "", status: 0, // 0-未提交
"remark": "" imageUrls: "",
remark: "",
}, },
{ {
"sceneType": 2, // 会员权益(广联权益) sceneType: 2, // 会员权益(广联权益)
"effectiveReferralCountDTOS": [ effectiveReferralCountDTOS: [
{ "brandType": 0, "brandName": "问界", "deliveryCount": 20, "effectiveReferralCount": '' }, {
{ "brandType": 2, "brandName": "享界", "deliveryCount": 8, "effectiveReferralCount": '' } 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: "",
},
], ],
"imageUrls": "",
"remark": ""
}
]
}; };
this.setData({ this.setData({
......
{ {
"navigationBarTitleText": "编辑门店引荐数", "navigationBarTitleText": "编辑门店引荐数",
"usingComponents": { "usingComponents": {
"edit-item": "../components/editItem/editItem" "edit-item": "../components/editItem/editItem",
"detail-item": "../components/detailItem/detailItem"
} }
} }
...@@ -2,11 +2,24 @@ ...@@ -2,11 +2,24 @@
<view class="container"> <view class="container">
<view wx:for="{{mockData.sceneTypeEffectiveReferrals}}" class="edit-box"> <view wx:for="{{mockData.sceneTypeEffectiveReferrals}}" class="edit-box">
<view class="merchant-name" wx:if="{{index == 0}}">{{mockData.merchantName}}</view> <view class="merchant-name" wx:if="{{index == 0}}">{{mockData.merchantName}}</view>
<!-- Render Detail View if status is 2 (Submitted) -->
<block wx:if="{{item.status == 2}}">
<detail-item
item="{{item}}"
class="edit-item-wrapper"
/>
</block>
<!-- Render Edit View if status is 0 (Unsubmitted) or 1 (Draft) -->
<block wx:else>
<edit-item <edit-item
item="{{item}}" item="{{item}}"
bind:draft="onDraft" bind:draft="onDraft"
bind:submit="onSubmitItem" bind:submit="onSubmitItem"
class="edit-item-wrapper" class="edit-item-wrapper"
/> />
</block>
</view> </view>
</view> </view>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!