Commit fb4314e0 by chenwq

fix(任务页面): 优化任务卡片的状态显示和样式

1 parent 3c5b0ee6
......@@ -25,26 +25,27 @@
:finished="finished"
@load="onLoadMore">
<div v-for="(item, index) in list"
:key="getItemKey(item, index)"
:key="index"
class="task-card">
<div class="card-header">
<span class="status-tag" :class="getStatusClass(item)">
{{ getStatusText(item) }}
<span class="status-tag" :class="getApprovalStatus(item).className">
{{ getApprovalStatus(item).text }}
</span>
<span class="task-name text-hide">{{ getTaskName(item) }}</span>
</div>
<div class="time-row">
<van-icon name="clock" />
<!-- <van-icon class="icon" :name="`${BASE_IMG_URL}time-icon.png`" /> -->
<van-icon class="icon" name="https://img02.glsx.com.cn/weapp/resource/supervise-wecom/time-icon.png" />
<span>完成时间:</span>
<span>{{ getFinishTime(item) }}</span>
<span>{{ item.approvalTime || '-' }}</span>
</div>
<div class="card-footer">
<button class="action-btn"
type="button"
@click="handleTask(item)">
{{ getActionText(item) }}
{{ getApprovalStatus(item).actionText }}
</button>
</div>
</div>
......@@ -77,11 +78,19 @@ export default {
loading: false,
refreshing: false,
finished: false,
statusMap: {
0: { text: "待审批", className: "pending", actionText: "去审批" },
1: { text: "已通过", className: "approved", actionText: "查看" },
2: { text: "已驳回", className: "rejected", actionText: "查看" },
},
};
},
created() {
this.userInfo = util.getLocalStorage("ww_userInfo") || {};
},
mounted() {
this.getList();
},
methods: {
onRefresh() {
this.finished = false;
......@@ -98,7 +107,6 @@ export default {
this.loading = true;
const params = { pageNum: this.pageNum, pageSize: 10, phone: this.userInfo?.phone || "" };
api.getApprovalPage(params).then((res) => {
console.log("getList res:", res);
const rows = res.list || [];
const total = res.total || rows.length;
......@@ -113,38 +121,11 @@ export default {
this.refreshing = false;
});
},
// getRows(res) {
// const data = res?.data || res || {};
// const pageData = data.page || data.result || data;
// return pageData.records || pageData.list || pageData.rows || data.records || data.list || [];
// },
// getTotal(res, rows) {
// const data = res?.data || res || {};
// const pageData = data.page || data.result || data;
// return Number(pageData.total || data.total || rows.length || 0);
// },
getItemKey(item, index) {
return item.id || item.approvalId || item.taskId || index;
},
getTaskName(item) {
return item.approvalName || item.taskName || item.title || item.name || "专项带教审批";
},
getFinishTime(item) {
return item.finishTime || item.completedTime || item.completeTime || item.approvalTime || "-";
},
isDone(item) {
const status = item.status ?? item.approvalStatus ?? item.taskStatus ?? item.state;
const text = `${status || ""}${item.statusName || ""}${item.approvalStatusName || ""}`;
return item.completed === true || item.finished === true || ["1", "2", "done", "completed"].includes(String(status).toLowerCase()) || /已完成|完成|已审批/.test(text);
},
getStatusText(item) {
return item.statusName || item.approvalStatusName || (this.isDone(item) ? "已完成" : "待完成");
return "专项带教审批";
},
getStatusClass(item) {
return this.isDone(item) ? "done" : "pending";
},
getActionText(item) {
return this.isDone(item) ? "查看" : "去审批";
getApprovalStatus(item) {
return this.statusMap[Number(item.approvalStatus)] || this.statusMap[0];
},
handleTask(item) {
const url = item.approvalUrl || item.detailUrl || item.pageUrl || item.url || item.h5Url;
......@@ -238,10 +219,9 @@ export default {
.task-card {
background: #ffffff;
border-radius: 8px;
border-radius: 12px;
padding: 12px;
margin-bottom: 8px;
min-height: 86px;
margin-bottom: 12px;
box-sizing: border-box;
.card-header {
......@@ -254,18 +234,23 @@ export default {
flex-shrink: 0;
font-size: 10px;
line-height: 16px;
padding: 0 6px;
padding: 2px 6px;
border-radius: 4px;
margin-right: 8px;
margin-right: 6px;
&.pending {
color: #2c66f7;
background: #f0f4ff;
background: #f2f6ff;
}
&.approved {
color: #35c376;
background: #eaf9f1;
}
&.done {
color: #15c875;
background: #ecfff5;
&.rejected {
color: #000000e5;
background: #f3f3f4;
}
}
......@@ -284,8 +269,8 @@ export default {
color: #00000066;
.van-icon {
margin-right: 5px;
font-size: 13px;
margin: 2px 4px 0 0;
font-size: 14px;
color: #00000042;
}
}
......@@ -297,16 +282,14 @@ export default {
}
.action-btn {
min-width: 58px;
height: 24px;
padding: 0 14px;
min-width: 60px;
border: 0;
border-radius: 12px;
background: #f0f4ff;
padding: 6px 17px;
border-radius: 24px;
background: #f2f6ff;
color: #2c66f7;
font-size: 12px;
font-size: 13px;
font-weight: 600;
line-height: 24px;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!