Commit 7253a473 by 岑成威

feat: 新增事项

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