Commit 1f6e1789 by chenwq

feat: 添加任务中心和专项任务详情页面,优化任务列表展示逻辑

1 parent 83659f0e
......@@ -9,4 +9,7 @@ export default {
getTaskDetailById(data) {
return api.post("dj.api.supervisor.mini.workbench.getTaskDetailById", data, "supervisorUrl");
},
getTaskCenterPageByUuid(data) {
return api.post("dj.api.supervisor.mini.taskCenter.pageByUuid", data, "supervisorUrl");
},
};
......@@ -39,6 +39,14 @@ export const teamWorkRoutes = [
title: "专项任务详情",
},
},
{
path: "taskCenterDetail",
name: "teamWork/taskCenterDetail",
component: () => import("@/views/teamWork/teamWork/taskCenterDetail.vue"),
meta: {
title: "专项任务详情",
},
},
],
},
];
<template>
<div class="strategy-task-list">
<TaskCardList v-if="list.length"
action-text="查看"
:card-config="cardConfig"
:list="list"
:status="getCardStatus"
:title="getCardTitle"
@action="viewDetail" />
<van-empty v-else description="暂无任务" />
</div>
</template>
<script>
import constantData from "../constantData.js";
import TaskCardList from "./TaskCardList.vue";
export default {
name: "StrategyTaskList",
components: {
TaskCardList,
},
props: {
list: {
type: Array,
default: () => [],
},
},
data() {
return {
cardConfig: constantData.SPECIAL_TASK_CARD_CONFIG,
};
},
methods: {
getCardTitle(task) {
return task.merchantName;
},
getCardStatus(task) {
return constantData.STATUS_MAP[task.taskStatus] || { name: "未知", color: "#999999", background: "#f5f5f5" };
},
viewDetail(task) {
sessionStorage.setItem("specialTaskDetailItem", JSON.stringify(task));
this.$router.push({ path: "/teamWork/specialTaskDetail" });
},
},
};
</script>
<template>
<div class="task-card-list">
<div v-for="(task, index) in list"
:key="index"
class="task-card">
<div class="card-header">
<span class="status-tag" :style="getStatusStyle(task)">
{{ getStatusName(task) }}
</span>
<span class="task-title">{{ getTitle(task) }}</span>
</div>
<div class="card-body">
<template v-for="(item, itemIndex) in cardConfig">
<div v-if="isFieldShow(task, item)"
:key="item.key || itemIndex"
class="info-row">
<van-icon class="icon" :name="item.icon" />
<div class="content-wrapper">
<span class="label">{{ getFieldLabel(task, item) }}</span>
<span class="value">{{ getFieldValue(task, item) }}</span>
</div>
</div>
</template>
</div>
<div v-if="actionText && isActionShow(task)" class="card-footer">
<div class="view-btn" @click="$emit('action', task)">
{{ actionText }}
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "TaskCardList",
props: {
list: {
type: Array,
default: () => [],
},
cardConfig: {
type: Array,
default: () => [],
},
title: {
type: [String, Function],
default: "",
},
status: {
type: Function,
default: null,
},
actionText: {
type: String,
default: "",
},
actionVisible: {
type: Function,
default: null,
},
},
methods: {
getTitle(task) {
return typeof this.title === "function" ? this.title(task) : this.title;
},
getStatus(task) {
return this.status ? this.status(task) : {};
},
getStatusName(task) {
return this.getStatus(task).name || "-";
},
getStatusStyle(task) {
const status = this.getStatus(task);
return {
color: status.color || "#2c66f7",
background: status.background || "#2c66f71a",
};
},
isFieldShow(task, item) {
return item.isShow ? item.isShow(task) : true;
},
getFieldLabel(task, item) {
return item.getLabel ? item.getLabel(task) : item.label;
},
getFieldValue(task, item) {
if (item.getValue)
return item.getValue(task) || "-";
return task[item.key] || "-";
},
isActionShow(task) {
return this.actionVisible ? this.actionVisible(task) : true;
},
},
};
</script>
<style lang="scss" scoped>
.task-card-list {
.task-card {
background: #ffffff;
border-radius: 8px;
padding: 16px;
margin-bottom: 12px;
.card-header {
display: flex;
align-items: center;
margin-bottom: 14px;
.status-tag {
font-size: 10px;
padding: 2px 6px;
border-radius: 4px;
margin-right: 8px;
flex-shrink: 0;
}
.task-title {
font-size: 14px;
font-weight: 600;
color: #000000e5;
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.card-body {
.info-row {
display: flex;
align-items: flex-start;
margin-bottom: 10px;
font-size: 12px;
color: #00000066;
&:last-child {
margin-bottom: 0;
}
.icon {
margin-top: 2px;
margin-right: 6px;
font-size: 14px;
color: #00000042;
}
.content-wrapper {
flex: 1;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.label,
.value {
display: inline;
}
}
}
}
.card-footer {
display: flex;
justify-content: flex-end;
margin-top: 12px;
.view-btn {
background: #f0f4ff;
color: #2c66f7;
font-size: 12px;
padding: 6px 16px;
border-radius: 14px;
}
}
}
}
</style>
<template>
<div class="task-center-list">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list v-if="list.length"
v-model="loading"
finished-text="到底了"
:finished="finished"
@load="onLoadMore">
<TaskCardList :card-config="cardConfig"
action-text="查看"
:action-visible="canViewDetail"
:list="list"
:status="getCardStatus"
:title="cardTitle"
@action="viewDetail" />
</van-list>
<van-empty v-if="!loading && !refreshing && list.length === 0"
description="暂无任务"
image-size="100" />
</van-pull-refresh>
</div>
</template>
<script>
import dayjs from "dayjs";
import api from "@/api/teamWork";
import util from "@/utils/util";
import constantData from "../constantData.js";
import TaskCardList from "./TaskCardList.vue";
const TASK_CENTER_CARD_TITLE = "专项带教";
function formatCompleteTime(value) {
if (!value)
return "-";
const date = dayjs(value);
return date.isValid() ? date.format("YYYY-MM-DD HH:mm:ss") : "-";
}
const TASK_CENTER_CARD_CONFIG = [
{
key: "taskMerchantName",
label: "归属门店:",
icon: `${constantData.BASE_IMG_URL}matter-icon.png`,
},
{
key: "completeTime",
label: "完成时间:",
icon: `${constantData.BASE_IMG_URL}time-icon.png`,
getValue: task => formatCompleteTime(task.completeTime),
},
];
export default {
name: "TaskCenterList",
components: {
TaskCardList,
},
props: {
startDate: {
type: String,
default: "",
},
endDate: {
type: String,
default: "",
},
taskData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
list: [],
pageNum: 1,
pageSize: 10,
total: 0,
loading: false,
refreshing: false,
finished: false,
cardTitle: TASK_CENTER_CARD_TITLE,
cardConfig: TASK_CENTER_CARD_CONFIG,
};
},
watch: {
startDate() {
this.onRefresh();
},
endDate() {
this.onRefresh();
},
taskData() {
this.onRefresh();
},
},
mounted() {
if (this.taskData.supervisorUuid)
this.onRefresh();
},
methods: {
getCardStatus(task) {
return { name: task.statusName || "-" };
},
canViewDetail(task) {
return task.statusName === "已完成";
},
viewDetail(task) {
sessionStorage.setItem("taskCenterDetailItem", JSON.stringify(task));
this.$router.push({ path: "/teamWork/taskCenterDetail" });
},
onRefresh() {
this.pageNum = 1;
this.finished = false;
this.list = [];
this.loadList();
},
onLoadMore() {
if (this.finished)
return;
this.loadList();
},
async loadList() {
if (!this.taskData.supervisorUuid) {
this.loading = false;
this.refreshing = false;
this.finished = true;
this.total = 0;
this.$emit("total-change", 0);
return;
}
this.loading = true;
util.showLoading();
try {
const res = await api.getTaskCenterPageByUuid({
supervisorUuid: this.taskData.supervisorUuid,
pageNum: this.pageNum,
pageSize: this.pageSize,
startDate: this.startDate,
endDate: this.endDate,
});
// const data = res || {};
const pageList = res?.list || [];
this.total = Number(res?.total) || 0;
this.list = this.pageNum === 1 ? pageList : this.list.concat(pageList);
this.$emit("total-change", this.total);
this.finished = pageList.length < this.pageSize || this.list.length >= this.total;
this.pageNum += 1;
} catch (error) {
this.finished = true;
} finally {
this.loading = false;
this.refreshing = false;
util.hideLoading();
}
},
},
};
</script>
<template>
<div class="special-task-list-page">
<div class="page-toolbar">
<div class="total-text">
共{{ currentTotal }}条数据
</div>
<div class="center-switch">
<button v-for="item in centerTabs"
:key="item.key"
class="switch-btn"
type="button"
:class="{ active: activeCenter === item.key }"
@click="activeCenter = item.key">
{{ item.name }}
</button>
</div>
</div>
<div class="list-container">
<template v-if="list.length > 0">
<div v-for="(task, index) in list"
:key="index"
class="task-card">
<div class="card-header">
<span class="status-tag" :style="{ color: getStatus(task.taskStatus).color, background: getStatus(task.taskStatus).background }">
{{ getStatus(task.taskStatus).name }}
</span>
<span class="merchant-name">{{ task.merchantName }}</span>
</div>
<div class="card-body">
<template v-for="(item, i) in cardConfig">
<div v-if="item.isShow(task)"
:key="i"
class="info-row">
<van-icon class="icon" :name="item.icon" />
<div class="content-wrapper">
<span class="label">{{ item.getLabel(task) }}</span>
<span class="value">{{ item.getValue(task) }}</span>
</div>
</div>
</template>
</div>
<div class="card-footer">
<div class="view-btn" @click="viewDetail(task)">
查看
</div>
</div>
</div>
</template>
<van-empty v-else description="暂无专项任务" />
<TaskCenterList v-if="activeCenter === 'task'"
:end-date="endDate"
:start-date="startDate"
:task-data="taskData"
@total-change="taskTotal = $event" />
<StrategyTaskList v-else :list="strategyList" />
</div>
</div>
</template>
<script>
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import constantData from "./constantData.js";
import StrategyTaskList from "./components/StrategyTaskList.vue";
import TaskCenterList from "./components/TaskCenterList.vue";
export default {
name: "SpecialTaskList",
mixins: [reportTrackFunMixin], // 导入混入
components: {
StrategyTaskList,
TaskCenterList,
},
mixins: [reportTrackFunMixin],
data() {
return {
title: "专项任务列表",
list: [],
cardConfig: constantData.SPECIAL_TASK_CARD_CONFIG,
activeCenter: "task",
centerTabs: [
{ key: "task", name: "任务中心" },
{ key: "strategy", name: "策略中心" },
],
taskData: {},
strategyList: [],
taskTotal: 0,
startDate: "",
endDate: "",
};
},
computed: {
currentTotal() {
return this.activeCenter === "task" ? this.taskTotal : this.strategyList.length;
},
},
created() {
this.title = this.$route.query.title || "专项任务列表";
this.startDate = this.$route.query.startDate || "";
this.endDate = this.$route.query.endDate || "";
this.setReportTrackData(0, "supervisor_h5_specificTask_list", {});
try {
const storedItem = sessionStorage.getItem("reportDetailItem");
if (storedItem) {
const itemData = JSON.parse(storedItem);
this.list = itemData.specialTaskList || [];
}
} catch (e) {
console.error("Failed to parse item data", e);
}
// 每次进入列表页时,清理掉详情页的临时缓存数据
this.loadStrategyList();
sessionStorage.removeItem("specialTaskDetailItem");
},
methods: {
onClickLeft() {
this.$router.go(-1);
},
getStatus(status) {
return constantData.STATUS_MAP[status] || { name: "未知", color: "#999999", background: "#f5f5f5" };
},
viewDetail(task) {
sessionStorage.setItem("specialTaskDetailItem", JSON.stringify(task));
this.$router.push({ path: "/teamWork/specialTaskDetail" });
loadStrategyList() {
try {
const storedItem = sessionStorage.getItem("reportDetailItem");
if (storedItem) {
const itemData = JSON.parse(storedItem);
this.taskData = itemData;
this.strategyList = itemData.specialTaskList || [];
}
} catch (e) {
console.error("Failed to parse item data", e);
}
},
},
};
......@@ -93,100 +92,44 @@ export default {
box-sizing: border-box;
padding-bottom: env(safe-area-inset-bottom);
.navigation-header {
:deep(.van-nav-bar__title) {
font-size: var(--fontSize34, 17px);
color: #000000e5;
font-weight: 600;
}
:deep(.van-icon) {
color: #000000e5;
}
}
.page-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 12px 0;
.list-container {
padding: 12px;
.total-text {
font-size: 12px;
color: #00000066;
}
.task-card {
.center-switch {
display: flex;
align-items: center;
padding: 2px;
border-radius: 16px;
background: #ffffff;
border-radius: 8px;
padding: 16px;
margin-bottom: 12px;
.card-header {
display: flex;
align-items: center;
margin-bottom: 16px;
.status-tag {
font-size: 10px;
padding: 2px 6px;
border-radius: 4px;
margin-right: 8px;
flex-shrink: 0;
}
.merchant-name {
font-size: 14px;
font-weight: 500;
color: #000000e5;
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.card-body {
.info-row {
display: flex;
align-items: flex-start;
margin-bottom: 10px;
font-size: 12px;
color: #00000066;
&:last-child {
margin-bottom: 0;
}
.icon {
margin-top: 2px;
margin-right: 6px;
font-size: 14px;
color: #00000042;
}
.content-wrapper {
flex: 1;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.label {
display: inline;
}
.value {
display: inline;
}
}
}
}
.card-footer {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
.view-btn {
background: #f0f4ff;
color: #2c66f7;
font-size: 12px;
padding: 6px 16px;
border-radius: 14px;
}
.switch-btn {
height: 26px;
padding: 0 10px;
border: 0;
border-radius: 14px;
background: transparent;
color: #00000099;
font-size: 12px;
&.active {
background: #f0f4ff;
color: #2c66f7;
font-weight: 500;
}
}
}
.list-container {
padding: 12px;
}
}
</style>
<template>
<div class="task-center-detail-page">
<van-nav-bar class="navigation-header"
title="专项任务详情"
fixed
left-arrow
placeholder
@click-left="onClickLeft" />
<div class="detail-list">
<div v-for="item in baseFields"
:key="item.label"
class="detail-item"
:class="{ 'tag-column': item.type === 'tags' || item.type === 'courseTags' }">
<div class="label">
{{ item.label }}
</div>
<div v-if="item.type === 'courseTags'" class="tag-list course-tag-list">
<span v-for="name in item.value"
:key="name"
class="name-tag">
{{ name }}
</span>
<span v-if="!item.value.length" class="value muted">-</span>
</div>
<div v-else-if="item.type === 'tags'" class="tag-list">
<span v-for="name in item.value"
:key="name"
class="name-tag">
{{ name }}
</span>
<span v-if="!item.value.length" class="value muted">-</span>
</div>
<div v-else
class="value"
:class="{ muted: !item.value }">
{{ item.value || '-' }}
</div>
</div>
<div class="content-card">
<div class="label">
带教内容摘要
</div>
<div class="summary-text">
{{ detail.assigneeDetail || '-' }}
</div>
</div>
<div class="content-card">
<div class="label">
带教照片佐证
</div>
<div v-if="imageList.length" class="image-list">
<van-image v-for="(url, index) in imageList"
:key="url"
class="evidence-image"
fit="cover"
:src="url"
@click="previewImage(index)" />
</div>
<div v-else class="empty-text">
-
</div>
</div>
</div>
</div>
</template>
<script>
import dayjs from "dayjs";
import { ImagePreview } from "vant";
export default {
name: "TaskCenterDetail",
data() {
return {
detail: {},
};
},
computed: {
baseFields() {
return [
{ label: "带教场景", value: this.detail.teachingSceneName },
{ label: "带教时间", value: this.formatToMinute(this.detail.teachingTime) },
{ label: "带教方式", value: this.detail.teachingMethodName },
{ label: "带教主题", value: this.detail.teachingTopicName },
{ label: "推送课程", value: this.courseNameList, type: "courseTags" },
{ label: "带教门店", value: this.merchantList, type: "tags" },
{ label: "参与人员", value: this.detail.taskStaffList || [], type: "tags" },
];
},
courseNameList() {
return (this.detail.bcCourseNameList || []).filter(Boolean);
},
merchantList() {
return this.detail.taskMerchantName ? [this.detail.taskMerchantName] : [];
},
imageList() {
return (this.detail.assigneeImages || []).slice(0, 9);
},
},
created() {
try {
const storedItem = sessionStorage.getItem("taskCenterDetailItem");
if (storedItem) {
this.detail = JSON.parse(storedItem);
}
} catch (e) {
console.error("Failed to parse task center detail item", e);
}
},
methods: {
onClickLeft() {
this.$router.go(-1);
},
previewImage(index) {
ImagePreview({
images: this.imageList,
startPosition: index,
});
},
formatToMinute(value) {
if (!value)
return "";
const date = dayjs(value);
return date.isValid() ? date.format("YYYY-MM-DD HH:mm") : String(value).slice(0, 16);
},
},
};
</script>
<style lang="scss" scoped>
.task-center-detail-page {
height: 100%;
overflow: auto;
background: #f2f3f7;
box-sizing: border-box;
padding: 0 12px calc(20px + env(safe-area-inset-bottom));
.navigation-header {
:deep(.van-nav-bar__title) {
font-size: var(--fontSize34, 17px);
color: #000000e5;
font-weight: 600;
}
:deep(.van-icon) {
color: #000000e5;
}
}
}
.detail-list {
padding-top: 8px;
}
.detail-item,
.content-card {
background: #fff;
border-radius: 6px;
padding: 0 12px;
margin-bottom: 8px;
box-sizing: border-box;
}
.detail-item {
min-height: 42px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
&.tag-column {
display: block;
padding-top: 12px;
padding-bottom: 12px;
}
}
.content-card {
padding-top: 12px;
padding-bottom: 12px;
}
.label {
flex-shrink: 0;
font-size: 13px;
color: #000000e5;
}
.value {
flex: 1;
text-align: right;
font-size: 13px;
color: #00000066;
line-height: 20px;
word-break: break-all;
&.muted {
color: #00000040;
}
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.course-tag-list {
flex-wrap: wrap;
.name-tag {
min-width: 0;
max-width: 100%;
box-sizing: border-box;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.name-tag {
line-height: 22px;
padding: 0 9px;
border-radius: 4px;
background: #f2f3f5;
font-size: 12px;
color: #000000a6;
}
.summary-text {
margin-top: 10px;
font-size: 13px;
line-height: 21px;
color: #00000066;
word-break: break-all;
white-space: pre-line;
}
.image-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
margin-top: 12px;
}
.evidence-image {
width: 100%;
aspect-ratio: 1;
border-radius: 4px;
overflow: hidden;
}
.empty-text {
margin-top: 10px;
font-size: 13px;
color: #00000040;
}
</style>
......@@ -252,6 +252,10 @@ export default {
sessionStorage.setItem("reportDetailItem", JSON.stringify(item));
const query = { detailType };
if (detailType === "specialTask") {
query.startDate = this.startStr;
query.endDate = this.endStr;
}
if (taskIdKey && item[taskIdKey]) {
query[taskIdKey] = item[taskIdKey];
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!