Commit 7253a473 by 岑成威

feat: 新增事项

1 parent 55166662
...@@ -99,6 +99,10 @@ page { ...@@ -99,6 +99,10 @@ page {
margin-top: 24rpx; margin-top: 24rpx;
} }
.reply-card .reply-info-list {
padding-top: 0;
}
.card-title { .card-title {
font-size: 28rpx; font-size: 28rpx;
font-weight: 600; font-weight: 600;
...@@ -160,12 +164,6 @@ page { ...@@ -160,12 +164,6 @@ page {
word-break: break-all; word-break: break-all;
} }
.reply-time-row {
margin-top: 24rpx;
padding-top: 24rpx;
border-top: 2rpx dashed #f0f1f5;
}
.handle-page--readonly .reply-card { .handle-page--readonly .reply-card {
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
...@@ -37,18 +37,25 @@ ...@@ -37,18 +37,25 @@
</view> </view>
</view> </view>
<view class="card reply-card"> <view class="card reply-card" wx:if="{{ task }}">
<view class="card-title">
专项任务回复<text class="required" wx:if="{{ !isReadonly }}">*</text>
</view>
<block wx:if="{{ isReadonly }}"> <block wx:if="{{ isReadonly }}">
<view class="reply-text">{{ task.replyText || '-' }}</view> <view class="info-list reply-info-list">
<view class="info-row flex reply-time-row"> <view class="info-row flex">
<view class="info-label">回复时间</view> <view class="info-label">专项任务回复</view>
<view class="info-value">{{ task.replyTimeText || '-' }}</view> <view class="info-value info-value--multiline reply-text">
{{ task.replyText || '-' }}
</view>
</view>
<view class="info-row flex">
<view class="info-label">回复时间</view>
<view class="info-value">{{ task.replyTimeText || '-' }}</view>
</view>
</view> </view>
</block> </block>
<block wx:else> <block wx:else>
<view class="card-title">
专项任务回复<text class="required">*</text>
</view>
<view class="textarea-wrap"> <view class="textarea-wrap">
<gl-textarea <gl-textarea
bindinput="onReplyInput" bindinput="onReplyInput"
......
...@@ -13,6 +13,8 @@ const BUSINESS_OPTIONS = [ ...@@ -13,6 +13,8 @@ const BUSINESS_OPTIONS = [
{ businessType: 3, businessName: '权益' }, { businessType: 3, businessName: '权益' },
] ]
const DESCRIPTION_MAX_LENGTH = 200
Page({ Page({
data: { data: {
navBarHeight: 0, navBarHeight: 0,
...@@ -26,6 +28,7 @@ Page({ ...@@ -26,6 +28,7 @@ Page({
supervisorDisplayText: '选择门店和业务后自动填充', supervisorDisplayText: '选择门店和业务后自动填充',
supervisorLoading: false, supervisorLoading: false,
description: '', description: '',
descriptionMaxLength: DESCRIPTION_MAX_LENGTH,
submitting: false, submitting: false,
merchantPopupShow: false, merchantPopupShow: false,
merchantKeyword: '', merchantKeyword: '',
...@@ -35,7 +38,6 @@ Page({ ...@@ -35,7 +38,6 @@ Page({
staffPopupShow: false, staffPopupShow: false,
staffOptions: [], staffOptions: [],
staffLoading: false, staffLoading: false,
staffSelectedCount: 0,
}, },
navbarReady(e) { navbarReady(e) {
...@@ -76,11 +78,12 @@ Page({ ...@@ -76,11 +78,12 @@ Page({
const params = {} const params = {}
if (kw) params.keyword = kw if (kw) params.keyword = kw
const res = await api.getStrategyShopMerchantList(params) const res = await api.getStrategyShopMerchantList(params)
if (res?.code !== '0' && res?.code !== 0) { const merchantList = parseStrategyShopMerchantList(res)
wx.showToast({ title: res?.message || '加载门店失败', icon: 'none' }) if (!merchantList.length && !isStrategyApiSuccess(res)) {
wx.showToast({ title: res?.message || '加载失败', icon: 'none' })
this.setData({ merchantList: [], merchantIndex: null })
return return
} }
const merchantList = parseStrategyShopMerchantList(res.data || {})
const { merchantId } = this.data const { merchantId } = this.data
let merchantIndex = null let merchantIndex = null
if (merchantId) { if (merchantId) {
...@@ -91,7 +94,8 @@ Page({ ...@@ -91,7 +94,8 @@ Page({
} }
this.setData({ merchantList, merchantIndex }) this.setData({ merchantList, merchantIndex })
} catch (e) { } catch (e) {
wx.showToast({ title: '加载门店失败', icon: 'none' }) console.error('loadMerchantList', e)
wx.showToast({ title: '网络异常', icon: 'none' })
} finally { } finally {
this.setData({ merchantLoading: false }) this.setData({ merchantLoading: false })
} }
...@@ -187,22 +191,16 @@ Page({ ...@@ -187,22 +191,16 @@ Page({
}, },
pickStaff() { pickStaff() {
const { merchantId, staffList } = this.data const { merchantId } = this.data
if (!merchantId && merchantId !== 0) { if (!merchantId && merchantId !== 0) {
wx.showToast({ title: '请先选择归属门店', icon: 'none' }) wx.showToast({ title: '请先选择归属门店', icon: 'none' })
return return
} }
const staffSelectedCount = (staffList || []).length this.setData({ staffPopupShow: false }, () => {
this.setData({ staffPopupShow: false, staffSelectedCount }, () => {
this.setData({ staffPopupShow: true }, () => this.loadStaffList()) this.setData({ staffPopupShow: true }, () => this.loadStaffList())
}) })
}, },
syncStaffSelectedCount(staffOptions) {
const staffSelectedCount = (staffOptions || []).filter((i) => i.checked).length
this.setData({ staffSelectedCount })
},
async loadStaffList() { async loadStaffList() {
const { merchantId, staffList } = this.data const { merchantId, staffList } = this.data
this.setData({ staffLoading: true, staffOptions: [] }) this.setData({ staffLoading: true, staffOptions: [] })
...@@ -213,12 +211,14 @@ Page({ ...@@ -213,12 +211,14 @@ Page({
) )
const staffOptions = parseStrategyShopMerchantStaffList(res).map((item) => ({ const staffOptions = parseStrategyShopMerchantStaffList(res).map((item) => ({
...item, ...item,
checked: selectedPhones.has(String(item.userPhone)), checked: item.userPhone
? selectedPhones.has(String(item.userPhone))
: false,
})) }))
if (!staffOptions.length && !isStrategyApiSuccess(res)) { if (!staffOptions.length && !isStrategyApiSuccess(res)) {
wx.showToast({ title: res?.message || '加载人员失败', icon: 'none' }) wx.showToast({ title: res?.message || '加载人员失败', icon: 'none' })
} }
this.setData({ staffOptions }, () => this.syncStaffSelectedCount(staffOptions)) this.setData({ staffOptions })
} catch (e) { } catch (e) {
wx.showToast({ title: '加载人员失败', icon: 'none' }) wx.showToast({ title: '加载人员失败', icon: 'none' })
} finally { } finally {
...@@ -234,7 +234,7 @@ Page({ ...@@ -234,7 +234,7 @@ Page({
...staffOptions[index], ...staffOptions[index],
checked: !staffOptions[index].checked, checked: !staffOptions[index].checked,
} }
this.setData({ staffOptions }, () => this.syncStaffSelectedCount(staffOptions)) this.setData({ staffOptions })
}, },
cancelStaffPopup() { cancelStaffPopup() {
...@@ -254,7 +254,6 @@ Page({ ...@@ -254,7 +254,6 @@ Page({
userName, userName,
})), })),
staffNames: staffList.map((s) => s.userName).join(','), staffNames: staffList.map((s) => s.userName).join(','),
staffSelectedCount: staffList.length,
}) })
}, },
...@@ -284,7 +283,7 @@ Page({ ...@@ -284,7 +283,7 @@ Page({
return return
} }
if (!staffList?.length) { if (!staffList?.length) {
wx.showToast({ title: '请选择需带教驻店人员', icon: 'none' }) wx.showToast({ title: '请选择员工', icon: 'none' })
return return
} }
if (supervisorLoading) { if (supervisorLoading) {
...@@ -301,13 +300,13 @@ Page({ ...@@ -301,13 +300,13 @@ Page({
wx.showToast({ title: '请填写申请描述', icon: 'none' }) wx.showToast({ title: '请填写申请描述', icon: 'none' })
return return
} }
if (content.length > 800) { if (content.length > DESCRIPTION_MAX_LENGTH) {
wx.showToast({ title: '申请描述不能超过800字', icon: 'none' }) wx.showToast({ title: `申请描述不能超过${DESCRIPTION_MAX_LENGTH}字`, icon: 'none' })
return return
} }
const invalidStaff = staffList.some( const invalidStaff = staffList.some(
(s) => !(s.userPhone || '').trim() || !(s.userName || '').trim() (s) => !(s.userName || '').trim() || !(s.userPhone || '').trim()
) )
if (invalidStaff) { if (invalidStaff) {
wx.showToast({ title: '驻店人员信息不完整', icon: 'none' }) wx.showToast({ title: '驻店人员信息不完整', icon: 'none' })
......
...@@ -182,14 +182,7 @@ page { ...@@ -182,14 +182,7 @@ page {
} }
.picker-list--staff { .picker-list--staff {
height: calc(100% - 56rpx); height: 100%;
}
.picker-multi-tip {
margin-bottom: 12rpx;
font-size: 24rpx;
color: #979797;
text-align: center;
} }
.picker-tip { .picker-tip {
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<view class="textarea-wrap"> <view class="textarea-wrap">
<gl-textarea <gl-textarea
bindinput="onDescInput" bindinput="onDescInput"
maxlength="{{ 800 }}" maxlength="{{ descriptionMaxLength }}"
showWordLimit showWordLimit
value="{{ description }}" value="{{ description }}"
placeholder="请简单描述申请信息" placeholder="请简单描述申请信息"
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</view> </view>
<popup <popup
title="选择归属门店" title="选择门店"
show="{{ merchantPopupShow }}" show="{{ merchantPopupShow }}"
height="85%" height="85%"
bindconfirm="confirmMerchantPopup" bindconfirm="confirmMerchantPopup"
...@@ -115,15 +115,12 @@ ...@@ -115,15 +115,12 @@
</popup> </popup>
<popup <popup
title="选择需带教驻店人员(可多选)" title="选择员工"
show="{{ staffPopupShow }}" show="{{ staffPopupShow }}"
height="70%" height="70%"
bindconfirm="confirmStaffPopup" bindconfirm="confirmStaffPopup"
bindcancel="cancelStaffPopup" bindcancel="cancelStaffPopup"
> >
<view class="picker-multi-tip" wx:if="{{ staffOptions.length && !staffLoading }}">
已选 {{ staffSelectedCount }} 人,点击可多选
</view>
<scroll-view scroll-y class="picker-list picker-list--staff" enhanced show-scrollbar="{{ false }}"> <scroll-view scroll-y class="picker-list picker-list--staff" enhanced show-scrollbar="{{ false }}">
<block wx:if="{{ staffLoading }}"> <block wx:if="{{ staffLoading }}">
<view class="picker-tip">加载中...</view> <view class="picker-tip">加载中...</view>
...@@ -132,7 +129,7 @@ ...@@ -132,7 +129,7 @@
<view <view
class="picker-item {{ item.checked ? 'active' : '' }}" class="picker-item {{ item.checked ? 'active' : '' }}"
wx:for="{{ staffOptions }}" wx:for="{{ staffOptions }}"
wx:key="userPhone" wx:key="index"
catchtap="toggleStaff" catchtap="toggleStaff"
data-index="{{ index }}" data-index="{{ index }}"
> >
......
...@@ -74,6 +74,10 @@ page { ...@@ -74,6 +74,10 @@ page {
padding-top: 24rpx; padding-top: 24rpx;
} }
.head-card .info-list {
padding-top: 24rpx;
}
.info-row { .info-row {
margin-bottom: 12rpx; margin-bottom: 12rpx;
font-size: 26rpx; font-size: 26rpx;
......
...@@ -130,61 +130,98 @@ export function parseTeachingApplicationPageData(resOrData = {}) { ...@@ -130,61 +130,98 @@ export function parseTeachingApplicationPageData(resOrData = {}) {
function pickList(data) { function pickList(data) {
if (Array.isArray(data)) return data if (Array.isArray(data)) return data
if (data && Array.isArray(data.data)) return data.data if (data && Array.isArray(data.data)) return data.data
if (data?.data && typeof data.data === 'object' && Array.isArray(data.data.list)) {
return data.data.list
}
return data?.list || [] return data?.list || []
} }
/** 策略接口成功判断(兼容直接返回 data 数组) */ /** 策略列表 data 提取(数组 / data[] / data.list / list) */
export function isStrategyApiSuccess(res) { export function extractStrategyList(res) {
if (Array.isArray(res)) return true
return res?.code === '0' || res?.code === 0 || res?.code == 0
}
/** 策略接口 data 提取(兼容 data 为数组) */
export function getStrategyApiData(res) {
if (Array.isArray(res)) return res if (Array.isArray(res)) return res
if (Array.isArray(res?.data)) return res.data if (Array.isArray(res?.data)) return res.data
if (res?.data && typeof res.data === 'object' && Array.isArray(res.data.list)) {
return res.data.list
}
if (Array.isArray(res?.list)) return res.list
if (typeof res?.data === 'string') { if (typeof res?.data === 'string') {
try { try {
const parsed = JSON.parse(res.data) const parsed = JSON.parse(res.data)
return Array.isArray(parsed) ? parsed : [] if (Array.isArray(parsed)) return parsed
if (Array.isArray(parsed?.list)) return parsed.list
} catch (e) { } catch (e) {
return [] // ignore
} }
} }
return [] return pickList(res)
}
/** 策略接口成功判断(兼容直接返回 data 数组) */
export function isStrategyApiSuccess(res) {
if (Array.isArray(res)) return true
return res?.code === '0' || res?.code === 0 || res?.code == 0
}
/** 策略接口 data 提取(兼容 data 为数组) */
export function getStrategyApiData(res) {
return extractStrategyList(res)
}
function resolveStaffPhone(item = {}) {
return (
item.userPhone ??
item.staffPhone ??
item.phone ??
item.mobilePhone ??
item.mobile ??
item.staffMobile ??
''
)
} }
/** 解析策略-归属门店列表 */ function resolveStaffName(item = {}) {
export function parseStrategyShopMerchantList(data = {}) { return (
return pickList(data) item.userName ??
item.staffName ??
item.name ??
item.realName ??
item.employeeName ??
''
)
}
/** 解析策略-门店列表 */
export function parseStrategyShopMerchantList(resOrData = {}) {
return extractStrategyList(resOrData)
.map((item) => ({ .map((item) => ({
merchantId: item.merchantId ?? item.shopMerchantId, merchantId:
merchantName: item.merchantName ?? item.shopMerchantName ?? '', item.merchantId ??
item.shopMerchantId ??
item.storeId ??
item.id,
merchantName:
item.merchantName ??
item.shopMerchantName ??
item.storeName ??
item.name ??
'',
})) }))
.filter((item) => item.merchantId != null && item.merchantId !== '') .filter((item) => item.merchantId != null && item.merchantId !== '')
} }
/** 解析策略-驻店人员列表(兼容 { code, data: [] } / 直接数组) */ /** 解析策略-驻店人员列表 */
export function parseStrategyShopMerchantStaffList(resOrData = {}) { export function parseStrategyShopMerchantStaffList(resOrData = {}) {
let raw = pickList(resOrData) return extractStrategyList(resOrData)
if (!raw.length && resOrData && !Array.isArray(resOrData)) {
raw = getStrategyApiData(resOrData)
}
return raw
.map((item) => ({ .map((item) => ({
userPhone: item.userPhone ?? item.staffPhone ?? item.phone ?? '', userPhone: String(resolveStaffPhone(item) || '').trim(),
userName: item.userName ?? item.staffName ?? item.name ?? '', userName: String(resolveStaffName(item) || '').trim(),
})) }))
.filter((item) => item.userPhone && item.userName) .filter((item) => item.userName)
} }
/** 解析策略-区域督导列表(兼容 { code, data: [] } / 直接数组) */ /** 解析策略-区域督导列表 */
export function parseStrategyShopMerchantSupervisorList(resOrData = {}) { export function parseStrategyShopMerchantSupervisorList(resOrData = {}) {
let raw = pickList(resOrData) return extractStrategyList(resOrData)
if (!raw.length && resOrData && !Array.isArray(resOrData)) {
raw = getStrategyApiData(resOrData)
}
return raw
.map((item) => ({ .map((item) => ({
merchantId: item.merchantId, merchantId: item.merchantId,
directorType: item.directorType, directorType: item.directorType,
...@@ -195,10 +232,10 @@ export function parseStrategyShopMerchantSupervisorList(resOrData = {}) { ...@@ -195,10 +232,10 @@ export function parseStrategyShopMerchantSupervisorList(resOrData = {}) {
.filter((item) => item.directorName) .filter((item) => item.directorName)
} }
/** 多个督导 directorName 用中文逗号拼接 */ /** 多个督导 directorName 用 / 拼接 */
export function formatDirectorNames(list = []) { export function formatDirectorNames(list = []) {
return list return list
.map((item) => item.directorName) .map((item) => item.directorName)
.filter(Boolean) .filter(Boolean)
.join(',') .join('/')
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!