Commit 3c59ac5f by 岑成威

fix: 修复事项bug

1 parent 7253a473
......@@ -31,7 +31,9 @@ Component({
},
setTab(index = 0) {
if (this.data.tabIndex === index) {
index = Number(index)
if (Number.isNaN(index)) index = 0
if (Number(this.data.tabIndex) === index) {
this.triggerEvent('click', index)
return
}
......
import api from '~/api/api'
import { MATTER_DETAIL_FIELDS, normalizeMatterItem } from '~/utils/matterItem'
import { getMatterDetailFields, normalizeMatterItem } from '~/utils/matterItem'
Page({
data: {
navBarHeight: 0,
task: null,
reply: '',
detailFields: MATTER_DETAIL_FIELDS,
detailFields: [],
submitting: false,
isReadonly: false,
loading: true,
......@@ -39,6 +39,7 @@ Page({
const task = normalizeMatterItem(res.data || {}, 0)
this.setData({
task,
detailFields: getMatterDetailFields(task.taskType),
isReadonly: task.completed,
reply: task.replyText || '',
loading: false,
......@@ -103,14 +104,19 @@ Page({
},
onSubmitSuccess() {
const { task } = this.data
wx.hideLoading()
this.setData({ submitting: false })
wx.showToast({ title: '提交成功', icon: 'success' })
this.notifyRefresh()
setTimeout(() => {
wx.redirectTo({
url: '/pages/mattersSubmitResult/mattersSubmitResult',
})
if (task?.taskType === 'staff-replace-access') {
wx.redirectTo({
url: '/pages/mattersSubmitResult/mattersSubmitResult',
})
return
}
wx.navigateBack()
}, 1000)
},
......
// pages/tab/matters/matters.js
import api from '~/api/api'
import {
MATTER_LIST_COMPLETED_FIELDS,
MATTER_LIST_FIELDS,
parseTaskCenterCountStat,
parseTaskCenterPageData,
} from '~/utils/matterItem'
......@@ -19,8 +17,6 @@ Page({
keyword: '',
tabList: ['待完成(0)', '已完成(0)', '全部(0)'],
tabIndex: 0,
matterItems: MATTER_LIST_FIELDS,
completedMatterItems: MATTER_LIST_COMPLETED_FIELDS,
displayList: [],
pageNum: 1,
pageSize: PAGE_SIZE,
......@@ -38,19 +34,44 @@ Page({
},
onShow() {
this.refreshAll()
if (this._pendingRefresh) {
this._pendingRefresh = false
this._returnedFromDetail = false
this.refreshAll()
return
}
if (this._returnedFromDetail) {
this._returnedFromDetail = false
return
}
if (!this._loaded) {
this._loaded = true
this.refreshAll()
return
}
this.fetchTabCounts()
},
onHide() {
this._returnedFromDetail = !!this._openingDetail
this._openingDetail = false
},
getKeyword() {
return String(this.data.keyword ?? '').trim()
},
input(e) {
onKeywordInput(e) {
this.setData({ keyword: e.detail.value })
},
clear() {
this.setData({ keyword: '' }, () => this.reloadList())
clearKeyword() {
this.setData({ keyword: '' }, () => this.refreshAll())
},
search() {
this.reloadList()
search(e) {
const keyword = String(e?.detail?.value ?? this.data.keyword ?? '').trim()
this.setData({ keyword }, () => this.refreshAll())
},
onRefresh() {
......@@ -61,8 +82,9 @@ Page({
},
tabClick(e) {
const tabIndex = e.detail
if (tabIndex === this.data.tabIndex) return
const tabIndex = Number(e.detail)
if (Number.isNaN(tabIndex)) return
if (tabIndex === Number(this.data.tabIndex)) return
this.setData({ tabIndex }, () => this.reloadList())
},
......@@ -73,29 +95,31 @@ Page({
},
getStatusByTab(tabIndex) {
if (tabIndex === 0) return 0
if (tabIndex === 1) return 1
const index = Number(tabIndex)
if (index === 0) return 0
if (index === 1) return 1
return undefined
},
buildListParams(pageNum) {
const { tabIndex, keyword, pageSize } = this.data
buildListParams(pageNum, tabIndex = this.data.tabIndex) {
const index = Number(tabIndex)
const { pageSize } = this.data
const params = this.buildTaskQueryParams({ pageNum, pageSize })
const status = this.getStatusByTab(tabIndex)
const status = this.getStatusByTab(index)
if (status !== undefined) params.status = status
return params
},
/** 与列表接口相同的查询条件(不含 status,用于统计) */
buildTaskQueryParams({ pageNum = 1, pageSize } = {}) {
const { keyword, pageSize: defaultPageSize } = this.data
const params = {
const { pageSize: defaultPageSize } = this.data
const keyWord = this.getKeyword()
return {
pageNum,
pageSize: pageSize ?? defaultPageSize,
keyWord,
keyword: keyWord,
}
const kw = (keyword || '').trim()
if (kw) params.keyword = kw
return params
},
updateTabListLabels(tabCounts) {
......@@ -112,9 +136,7 @@ Page({
async fetchTabCounts() {
try {
const res = await api.getTaskCenterCountStat(
this.buildTaskQueryParams({ pageNum: 1, pageSize: 1 })
)
const res = await api.getTaskCenterCountStat(this.buildTaskQueryParams())
if (res?.code !== '0' && res?.code !== 0) return
this.updateTabListLabels(parseTaskCenterCountStat(res.data || {}))
} catch (e) {
......@@ -123,22 +145,40 @@ Page({
},
async refreshAll() {
await Promise.all([this.fetchTabCounts(), this.reloadList()])
},
async reloadList() {
this.setData({ pageNum: 1, hasMore: true, displayList: [] })
await this.loadList(true)
},
async loadList(reset = true) {
if (this.data.loading) return
await this.fetchTabCounts()
await this.reloadList()
},
async reloadList(clearList = true) {
this._loadSeq = (this._loadSeq || 0) + 1
const seq = this._loadSeq
const patch = { pageNum: 1, hasMore: true, loading: true }
if (clearList) patch.displayList = []
this.setData(patch)
await this.loadList(true, seq)
},
async loadList(reset = true, seq) {
if (!reset) {
if (this.data.loading) return
seq = seq || this._loadSeq
} else if (!seq) {
this._loadSeq = (this._loadSeq || 0) + 1
seq = this._loadSeq
this.setData({ loading: true })
}
const pageNum = reset ? 1 : this.data.pageNum
this.setData({ loading: true })
const requestTabIndex = Number(this.data.tabIndex)
if (!reset) this.setData({ loading: true })
try {
const res = await api.getTaskCenterPage(this.buildListParams(pageNum))
const res = await api.getTaskCenterPage(
this.buildListParams(pageNum, requestTabIndex)
)
if (seq !== this._loadSeq) return
if (Number(this.data.tabIndex) !== requestTabIndex) return
if (res?.code !== '0' && res?.code !== 0) {
wx.showToast({
title: res?.message || '加载失败',
......@@ -161,6 +201,7 @@ Page({
loading: false,
})
} catch (e) {
if (seq !== this._loadSeq) return
wx.showToast({ title: '加载失败', icon: 'none' })
this.setData({
loading: false,
......@@ -179,10 +220,13 @@ Page({
openMatterDetail(e) {
const { item } = e.currentTarget.dataset
if (!item?.id) return
this._openingDetail = true
wx.navigateTo({
url: `/pages/mattersHandle/mattersHandle?id=${item.id}`,
events: {
refreshList: () => this.refreshAll(),
refreshList: () => {
this._pendingRefresh = true
},
},
})
},
......
......@@ -59,18 +59,28 @@ page {
flex-shrink: 0;
}
.search-clear-wrap {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 0 var(--fontSize26) 0 var(--fontSize10);
position: relative;
z-index: 2;
}
.search-clear {
width: var(--fontSize36);
height: var(--fontSize36);
margin: 0 var(--fontSize26) 0 var(--fontSize10);
flex-shrink: 0;
display: block;
}
.input {
flex: 1;
min-width: 0;
font-size: var(--fontSize28);
height: var(--fontSize38);
line-height: var(--fontSize38);
width: calc(100% - var(--fontSize136));
}
.input-placeholder {
......@@ -94,51 +104,58 @@ page {
/* 与 orderApprovalList 列表一致 */
.list .empty-box {
width: 100%;
height: 24rpx;
height: var(--fontSize20);
}
.list .item {
margin: 0 24rpx 24rpx;
border-radius: 32rpx;
background: #ffffff;
padding: 24rpx 32rpx;
box-sizing: border-box;
background: #ffffff;
padding: var(--fontSize32);
position: relative;
margin: 0 var(--fontSize20) var(--fontSize20);
box-shadow: 0 var(--fontSize4) var(--fontSize20) 0 #0000001a;
border-radius: var(--fontSize32);
font-size: var(--fontSize24);
}
.list .item-top {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 -24rpx;
padding: 0 24rpx 24rpx;
font-size: 26rpx;
margin-bottom: var(--fontSize28);
font-size: var(--fontSize24);
font-weight: 400;
color: #292d33;
}
.list .code {
color: #292d33;
font-size: var(--fontSize32);
font-weight: 500;
color: #666666;
border-bottom: 2rpx dashed #f0f1f5;
}
.list .code-text {
color: #222222;
margin-left: 16rpx;
font-size: var(--fontSize24);
font-weight: 400;
color: #292d33;
margin-left: var(--fontSize12);
}
.list .status {
height: 48rpx;
line-height: 48rpx;
border-radius: 8rpx;
padding: 0 12rpx;
font-size: 24rpx;
padding: var(--fontSize4) var(--fontSize8);
font-size: var(--fontSize24);
flex-shrink: 0;
}
.list .order-list {
padding: 24rpx 0;
padding: 0;
}
.list .order {
margin-bottom: 12rpx;
font-size: 26rpx;
color: #222222;
display: flex;
margin-bottom: var(--fontSize16);
font-size: var(--fontSize24);
color: #292d33;
}
.list .order:last-child {
......@@ -146,27 +163,28 @@ page {
}
.list .order-label {
width: 184rpx;
margin-right: 32rpx;
color: #999999;
width: var(--fontSize160);
flex-shrink: 0;
color: #999ea8;
}
.list .order-value {
flex: 1;
word-break: break-all;
min-width: 0;
color: #292d33;
display: flex;
align-items: center;
}
.list .order-value--ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
display: block;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: nowrap;
}
.list .btn-box {
margin-top: var(--fontSize24);
justify-content: space-between;
font-weight: 500;
}
......
......@@ -16,14 +16,18 @@
type="text"
placeholder="关键词"
class="input"
value="{{ keyword }}"
model:value="{{ keyword }}"
placeholder-class="input-placeholder"
bindinput="input"
bindinput="onKeywordInput"
bindconfirm="search"
/>
<block wx:if="{{ keyword }}">
<image src="/images/clear.png" class="search-clear" bindtap="clear" />
</block>
<view
wx:if="{{ keyword }}"
class="search-clear-wrap"
catchtap="clearKeyword"
>
<image src="/images/clear.png" class="search-clear" />
</view>
</view>
</view>
<view class="tab_box" wx:if="{{ tabList.length }}">
......@@ -64,8 +68,8 @@
</view>
<view class="order-list">
<view
class="order flex"
wx:for="{{ item.completed ? completedMatterItems : matterItems }}"
class="order"
wx:for="{{ item.completed ? item.completedListFields : item.listFields }}"
wx:key="key"
wx:for-item="field"
>
......@@ -97,7 +101,7 @@
</scroll-view>
</view>
<view class="teach-entry" bindtap="goTeachApply">
<!-- <view class="teach-entry" bindtap="goTeachApply">
<image class="teach-entry__icon" src="/images/daijiao.png" mode="aspectFit" />
<text class="teach-entry__text">带教申请</text>
</view>
\ No newline at end of file
</view> -->
\ No newline at end of file
......@@ -36,16 +36,21 @@ Page({
this.refreshAll()
},
input(e) {
getKeyword() {
return String(this.data.keyword ?? '').trim()
},
onKeywordInput(e) {
this.setData({ keyword: e.detail.value })
},
clear() {
this.setData({ keyword: '' }, () => this.reloadList())
clearKeyword() {
this.setData({ keyword: '' }, () => this.refreshAll())
},
search() {
this.reloadList()
search(e) {
const keyword = String(e?.detail?.value ?? this.data.keyword ?? '').trim()
this.setData({ keyword }, () => this.refreshAll())
},
onRefresh() {
......@@ -67,21 +72,26 @@ Page({
this.loadList(false)
},
buildListParams(pageNum) {
const { tabIndex, keyword, pageSize } = this.data
const params = { pageNum, pageSize }
const kw = (keyword || '').trim()
if (kw) params.keyword = kw
if (tabIndex === 0) params.tab = 0
buildQueryParams({ pageNum, pageSize, tab } = {}) {
const { tabIndex, pageSize: defaultPageSize } = this.data
const keyWord = this.getKeyword()
const params = {
pageNum: pageNum ?? 1,
pageSize: pageSize ?? defaultPageSize,
keyWord,
keyword: keyWord,
}
const tabVal = tab !== undefined ? tab : tabIndex === 0 ? 0 : undefined
if (tabVal === 0) params.tab = 0
return params
},
buildListParams(pageNum) {
return this.buildQueryParams({ pageNum })
},
buildCountParams(tab) {
const params = { pageNum: 1, pageSize: 1 }
const kw = (this.data.keyword || '').trim()
if (kw) params.keyword = kw
if (tab === 0) params.tab = 0
return params
return this.buildQueryParams({ pageNum: 1, pageSize: 1, tab })
},
updateTabListLabels(pending, all) {
......
......@@ -55,18 +55,28 @@ page {
flex-shrink: 0;
}
.search-clear-wrap {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 0 var(--fontSize26) 0 var(--fontSize10);
position: relative;
z-index: 2;
}
.search-clear {
width: var(--fontSize36);
height: var(--fontSize36);
margin: 0 var(--fontSize26) 0 var(--fontSize10);
flex-shrink: 0;
display: block;
}
.input {
flex: 1;
min-width: 0;
font-size: var(--fontSize28);
height: var(--fontSize38);
line-height: var(--fontSize38);
width: calc(100% - var(--fontSize136));
}
.input-placeholder {
......
......@@ -18,14 +18,18 @@
type="text"
placeholder="关键词"
class="input"
value="{{ keyword }}"
model:value="{{ keyword }}"
placeholder-class="input-placeholder"
bindinput="input"
bindinput="onKeywordInput"
bindconfirm="search"
/>
<block wx:if="{{ keyword }}">
<image src="/images/clear.png" class="search-clear" bindtap="clear" />
</block>
<view
wx:if="{{ keyword }}"
class="search-clear-wrap"
catchtap="clearKeyword"
>
<image src="/images/clear.png" class="search-clear" />
</view>
</view>
</view>
<view class="tab_box" wx:if="{{ tabList.length }}">
......
......@@ -4,9 +4,12 @@ export const MATTER_STATUS_MAP = {
1: { name: '已完成', color: '#35C376', background: '#35C3761a' },
}
/** 人员更换评估:列表/详情展示问题驻店销售 */
export const STAFF_REPLACE_ACCESS_TYPE = 'staff-replace-access'
/** taskType 枚举(接口文档) */
export const TASK_TYPE_NAME_MAP = {
'staff-replace-access': '人员更换评估',
[STAFF_REPLACE_ACCESS_TYPE]: '人员更换评估',
'policy-update-access': '商务政策更新评估',
'scene-expand': '多品类扩张',
'traffic-optimize': '流量问题改善',
......@@ -48,6 +51,52 @@ function resolveTaskTypeName(item) {
return item.taskType || '-'
}
export const MATTER_DETAIL_FIELDS = [
{ label: '归属门店', key: 'merchantName' },
{ label: '归属业务', key: 'businessName' },
{ label: '创建人', key: 'creatorName' },
{ label: '创建时间', key: 'createTimeText' },
{ label: '任务描述', key: 'descriptionText', multiline: true },
]
export const MATTER_LIST_FIELDS = [
{ label: '归属门店', key: 'merchantName' },
{ label: '归属业务', key: 'businessName' },
{ label: '创建人', key: 'creatorName' },
{ label: '创建时间', key: 'createTimeText' },
{ label: '任务描述', key: 'descriptionText', ellipsis: true },
]
export const MATTER_LIST_COMPLETED_FIELDS = [
{ label: '归属门店', key: 'merchantName' },
{ label: '归属业务', key: 'businessName' },
{ label: '创建人', key: 'creatorName' },
{ label: '任务描述', key: 'descriptionText', ellipsis: true },
{ label: '专项任务回复', key: 'replyText', ellipsis: true },
]
const STAFF_NAMES_LIST_FIELD = { label: '问题驻店销售', key: 'staffNames' }
/** 列表展示字段:仅 staff-replace-access 含问题驻店销售 */
export function getMatterListFields(taskType, completed = false) {
const base = completed ? MATTER_LIST_COMPLETED_FIELDS : MATTER_LIST_FIELDS
const fields = base.map((f) => ({ ...f }))
if (taskType !== STAFF_REPLACE_ACCESS_TYPE) return fields
fields.splice(2, 0, {
...STAFF_NAMES_LIST_FIELD,
ellipsis: !completed,
})
return fields
}
/** 详情展示字段:仅 staff-replace-access 含问题驻店销售 */
export function getMatterDetailFields(taskType) {
const fields = MATTER_DETAIL_FIELDS.map((f) => ({ ...f }))
if (taskType !== STAFF_REPLACE_ACCESS_TYPE) return fields
fields.splice(2, 0, { ...STAFF_NAMES_LIST_FIELD })
return fields
}
/**
* 归一化 TaskInfoDTO(列表项 / 分页 condition 同结构)
* @param {object} dto TaskInfoDTO
......@@ -88,6 +137,8 @@ export function normalizeMatterItem(dto = {}, index = 0) {
completed,
showAction: !completed,
showView: completed,
listFields: getMatterListFields(dto.taskType, false),
completedListFields: getMatterListFields(dto.taskType, true),
}
}
......@@ -156,28 +207,3 @@ export function parseTaskCenterPageData(data = {}) {
pageSize: data.pageSize,
}
}
export const MATTER_DETAIL_FIELDS = [
{ label: '归属门店', key: 'merchantName' },
{ label: '归属业务', key: 'businessName' },
{ label: '问题驻店销售', key: 'staffNames' },
{ label: '创建人', key: 'creatorName' },
{ label: '创建时间', key: 'createTimeText' },
{ label: '任务描述', key: 'descriptionText', multiline: true },
]
export const MATTER_LIST_FIELDS = [
{ label: '归属门店', key: 'merchantName' },
{ label: '归属业务', key: 'businessName' },
{ label: '创建人', key: 'creatorName' },
{ label: '创建时间', key: 'createTimeText' },
{ label: '任务描述', key: 'descriptionText', ellipsis: true },
]
export const MATTER_LIST_COMPLETED_FIELDS = [
{ label: '归属门店', key: 'merchantName' },
{ label: '归属业务', key: 'businessName' },
{ label: '创建人', key: 'creatorName' },
{ label: '任务描述', key: 'descriptionText', ellipsis: true },
{ label: '专项任务回复', key: 'replyText', ellipsis: true },
]
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!