Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop

This commit is contained in:
杨航
2026-03-09 19:35:46 +08:00
6 changed files with 227 additions and 222 deletions
+9 -2
View File
@@ -14,10 +14,10 @@
<view class="item-info-item inline-item">
<view class="bg-block inline-item">
<view class="bg-gray">
<view class="bg-blue" :style="`width: ${ dataInfo.progress }%;`"></view>
<view class="bg-blue" :style="`width: ${ progress };`"></view>
</view>
</view>
<view class="color-blue inline-item">{{dataInfo.progress}}%</view>
<view class="color-blue inline-item">{{progress}}</view>
</view>
</view>
<view class="item-btn">做任务</view>
@@ -25,6 +25,7 @@
</template>
<script setup>
import {computed } from 'vue';
const props = defineProps({
dataInfo: {
default: () => ({
@@ -33,6 +34,12 @@
type: Object
}
})
const progress = computed(() => {
const total = props.dataInfo.sumCrs ?? props.dataInfo.taskNumber ?? 0;
if (total === 0) return '0%';
const completed = props.dataInfo.finishCrs ?? props.dataInfo.learnedNumber ?? 0;
return Math.min(Math.round((completed / total) * 1000) / 10, 100) + '%';
});
</script>
<style lang="scss" scoped>
+211 -213
View File
@@ -1,233 +1,231 @@
<template>
<view class="module_title_div">
<view class="icon icon_1">
<!-- <image class="img" :src="icon"></image> -->
</view>
<view class="text font_pf">我的待办</view>
</view>
<view class="cont-box">
<!-- {{activeDate}} -->
<calendarCom ref="calendarComRef" @change="changeDate" />
<view class="table-list">
<todoItem
v-for="(item, index) in tableData"
:dataInfo="item"
:class="index === tableData.length - 1 ? 'last-item' : ''"
@click="handleDetail(item)"
></todoItem>
<view class="empty-box" v-show="tableData.length === 0">暂无数据</view>
</view>
<view class="more-btn" v-show="showMoreBtn" @click="getMoreData">点击加载更多</view>
</view>
<view class="module_title_div">
<view class="icon icon_1">
<!-- <image class="img" :src="icon"></image> -->
</view>
<view class="text font_pf">我的待办</view>
</view>
<view class="cont-box">
<!-- {{activeDate}} -->
<calendarCom ref="calendarComRef" @change="changeDate" />
<view class="table-list">
<todoItem v-for="(item, index) in tableData" :dataInfo="item" :class="index === tableData.length - 1 ? 'last-item' : ''" @click="handleDetail(item)"></todoItem>
<view class="empty-box" v-show="tableData.length === 0">暂无数据</view>
</view>
<view class="more-btn" v-show="showMoreBtn" @click="getMoreData">点击加载更多</view>
</view>
</template>
<script setup>
import { ref, onMounted, computed } from 'vue';
import calendarCom from './calendar.vue';
import todoItem from './todo-item.vue';
import common from '@/common/common.js';
import { queryHaveToDo } from '@/api/index';
import { queryTraExamPapersByPapersId } from '@/api/examination.js';
import { queryTestPapers, queryOrgTree } from '@/api/competition.js';
import { checkTraPartnerInfoById } from '@/api/sparring.js';
import { queryTraUserAnonyByUserId } from '@/api/user.js';
const activeDate = ref('');
const tableData = ref([]);
const pageObj = ref({
totalNum: 0,
page: 1,
limit: 10
});
const calendarComRef = ref(null)
const changeDate = (date) => {
activeDate.value = date;
getDataList(date, 1);
};
const showMoreBtn = computed(() => {
return pageObj.value.totalNum > pageObj.value.page * pageObj.value.limit;
});
const getMoreData = () => {
pageObj.value.page += 1;
getDataList(activeDate.value);
};
const initCalendar = () => {
calendarComRef.value && calendarComRef.value.initDate()
}
const getDataList = (date, flag) => {
common.loading();
if (flag === 1) {
tableData.value = [];
pageObj.value = {
totalNum: 0,
page: 1,
limit: 10
};
}
queryHaveToDo({
date,
...pageObj.value
})
.then((res) => {
let _arr = res.body || [];
pageObj.value.totalNum = res.total;
tableData.value = tableData.value.concat(_arr);
})
.finally(() => {
common.hideLoading();
});
};
const handleDetail = (item) => {
console.log(item);
switch (item.type) {
case '00':
common.navigateTo('/pages/courseDetail/index?crsId=' + item.id);
break;
case '01':
toSparringDetail(item);
break;
case '02':
toPKDetail(item);
break;
case '03':
toExaminationDetail(item);
break;
case '04':
common.setPageCache('learning_tasks_details', {
...item,
taskId: item.id,
taskName: item.name
});
common.navigateTo('/pages/learningTasks/details?taskId=' + item.id);
break;
default:
break;
}
};
// 去PK
const toPKDetail = async (item) => {
const comId = item.id;
common.loading();
const result = Promise.all([queryTestPapers({ comId }), queryTraUserAnonyByUserId(), queryOrgTree()]);
result
.then((res) => {
const papersId = res[0].body;
common.setPageCache('competition_list', {
papersId: papersId, // 试卷id
isAnony: res[1].body.isAnony, // 是否匿名 Y是N否
ruleDesc: item.ruleDesc, // 规则说明
comName: item.comName, // 标题
comId: comId
});
common.setValue('orgTree', res[2].body ?? []);
common.hideLoading();
common.navigateTo(`/pages/competition/matching?papersId=${papersId}&comId=${comId}`);
})
.catch(() => {
common.msg('网络繁忙,请稍后再试!');
});
};
// 去考试
const toExaminationDetail = async (item) => {
common.loading();
queryTraExamPapersByPapersId({
papersId: item.id
})
.then((res) => {
common.setPageCache('testing_hall_details', res.body);
common.navigateTo('/pages/testingHall/details');
})
.catch(() => {})
.finally(() => {
common.hideLoading();
});
};
// 跳转 课程详情
const toSparringDetail = (item) => {
if (item.id) {
checkTraPartnerInfoById({
traId: item.id
}).then((res) => {
if (res.body.inRange) {
common.navigateTo('/pages/sparring/detail?traId=' + item.id);
} else {
common.show('提示', res.body.message, false);
}
});
}
};
defineExpose({initCalendar})
import { ref, onMounted, computed } from 'vue'
import calendarCom from './calendar.vue'
import todoItem from './todo-item.vue'
import common from '@/common/common.js'
import { queryHaveToDo } from '@/api/index'
import { queryTraExamPapersByPapersId } from '@/api/examination.js'
import { queryTestPapers, queryOrgTree } from '@/api/competition.js'
import { checkTraPartnerInfoById } from '@/api/sparring.js'
import { queryTraUserAnonyByUserId } from '@/api/user.js'
const activeDate = ref('')
const tableData = ref([])
const pageObj = ref({
totalNum: 0,
page: 1,
limit: 10
})
const calendarComRef = ref(null)
const changeDate = date => {
activeDate.value = date
getDataList(date, 1)
}
const showMoreBtn = computed(() => {
return pageObj.value.totalNum > pageObj.value.page * pageObj.value.limit
})
const getMoreData = () => {
pageObj.value.page += 1
getDataList(activeDate.value)
}
const initCalendar = () => {
calendarComRef.value && calendarComRef.value.initDate()
}
const getDataList = (date, flag) => {
common.loading()
if (flag === 1) {
tableData.value = []
pageObj.value = {
totalNum: 0,
page: 1,
limit: 10
}
}
queryHaveToDo({
date,
...pageObj.value
})
.then(res => {
let _arr = res.body || []
pageObj.value.totalNum = res.total
tableData.value = tableData.value.concat(_arr)
})
.finally(() => {
common.hideLoading()
})
}
const handleDetail = item => {
console.log(item)
switch (item.type) {
case '00':
common.navigateTo('/pages/courseDetail/index?crsId=' + item.id)
break
case '01':
toSparringDetail(item)
break
case '02':
toPKDetail(item)
break
case '03':
toExaminationDetail(item)
break
case '04':
common.setPageCache('learning_tasks_details', {
...item,
taskId: item.id,
taskName: item.name,
taskSums: item.planPersionNumber,
taskFinishSums: item.realPersionNumber,
ossAddr: item.ossKey
})
common.navigateTo('/pages/learningTasks/details?taskId=' + item.id)
break
default:
break
}
}
// 去PK
const toPKDetail = async item => {
const comId = item.id
common.loading()
const result = Promise.all([queryTestPapers({ comId }), queryTraUserAnonyByUserId(), queryOrgTree()])
result
.then(res => {
const papersId = res[0].body
common.setPageCache('competition_list', {
papersId: papersId, // 试卷id
isAnony: res[1].body.isAnony, // 是否匿名 Y是N否
ruleDesc: item.ruleDesc, // 规则说明
comName: item.comName, // 标题
comId: comId
})
common.setValue('orgTree', res[2].body ?? [])
common.hideLoading()
common.navigateTo(`/pages/competition/matching?papersId=${papersId}&comId=${comId}`)
})
.catch(() => {
common.msg('网络繁忙,请稍后再试!')
})
}
// 去考试
const toExaminationDetail = async item => {
common.loading()
queryTraExamPapersByPapersId({
papersId: item.id
})
.then(res => {
common.setPageCache('testing_hall_details', res.body)
common.navigateTo('/pages/testingHall/details')
})
.catch(() => {})
.finally(() => {
common.hideLoading()
})
}
// 跳转 课程详情
const toSparringDetail = item => {
if (item.id) {
checkTraPartnerInfoById({
traId: item.id
}).then(res => {
if (res.body.inRange) {
common.navigateTo('/pages/sparring/detail?traId=' + item.id)
} else {
common.show('提示', res.body.message, false)
}
})
}
}
defineExpose({ initCalendar })
</script>
<style lang="scss" scoped>
$bg-margin-left: 30rpx;
$bg-margin-left: 30rpx;
.module_title_div {
display: flex;
margin: 30rpx $bg-margin-left;
align-items: center;
.module_title_div {
display: flex;
margin: 30rpx $bg-margin-left;
align-items: center;
.icon {
margin-right: 6rpx;
}
.icon {
margin-right: 6rpx;
}
.icon_1 {
.img {
width: 31rpx;
height: 36rpx;
}
}
.icon_1 {
.img {
width: 31rpx;
height: 36rpx;
}
}
.icon_2 {
margin-top: 10rpx;
.icon_2 {
margin-top: 10rpx;
.img {
width: 38rpx;
height: 38rpx;
}
}
.img {
width: 38rpx;
height: 38rpx;
}
}
.icon_3 {
// margin-top: 10rpx;
.img {
width: 38rpx;
height: 31rpx;
}
}
.icon_3 {
// margin-top: 10rpx;
.img {
width: 38rpx;
height: 31rpx;
}
}
.title {
font-size: 34rpx;
color: #323e57;
font-weight: 700;
line-height: 46rpx;
text-align: left;
}
}
.title {
font-size: 34rpx;
color: #323e57;
font-weight: 700;
line-height: 46rpx;
text-align: left;
}
}
.cont-box {
margin: 0 $bg-margin-left;
background-color: #fff;
border-radius: 22rpx;
padding: 20rpx;
.cont-box {
margin: 0 $bg-margin-left;
background-color: #fff;
border-radius: 22rpx;
padding: 20rpx;
.table-list {
padding: 16rpx;
.table-list {
padding: 16rpx;
.last-item {
border-bottom: 0 !important;
}
}
.last-item {
border-bottom: 0 !important;
}
}
.more-btn {
color: rgb(144, 147, 153);
text-align: center;
font-size: 23rpx;
}
}
.more-btn {
color: rgb(144, 147, 153);
text-align: center;
font-size: 23rpx;
}
}
.empty-box {
text-align: center;
color: #999;
font-size: 24rpx;
line-height: 120rpx;
}
.empty-box {
text-align: center;
color: #999;
font-size: 24rpx;
line-height: 120rpx;
}
</style>
@@ -49,7 +49,7 @@
const total = item.value.sumCrs ?? item.value.taskNumber ?? 0;
if (total === 0) return '0%';
const completed = item.value.finishCrs ?? item.value.learnedNumber ?? 0;
return Math.min(Math.round((completed / total) * 10000) / 100, 100) + '%';
return Math.min(Math.round((completed / total) * 1000) / 10, 100) + '%';
});
const getStatusClass = (item) => {
if (item.isFinish === '02') return 'completed';
@@ -65,7 +65,7 @@
return common.msg('任务已结束');
}
}
setPageCache('learning_tasks_details', item);
common.navigateTo('/pages/learningTasks/details?taskId=' + item.taskId);
};
@@ -96,7 +96,7 @@
} else {
styleArray.push('not_unlocked');
}
console.log('styleArray', styleArray);
// console.log('styleArray', styleArray);
return styleArray;
});
+2 -3
View File
@@ -94,13 +94,12 @@
const data_list = ref([]);
const total = ref(-1);
const taskId = ref('');
// const progress = computed(() => '30%');
const progress = computed(() => {
// 计算进度百分比(保留两位小数)
const total = detailData.sumCrs ?? detailData.taskNumber ?? 0;
if (total === 0) return '0%';
const completed = detailData.finishCrs ?? detailData.learnedNumber ?? 0;
return Math.min(Math.round((completed / total) * 10000) / 100, 100) + '%';
return Math.min(Math.round((completed / total) * 1000) / 10, 100) + '%';
});
const queryList = async (pageNo, pageSize, from) => {
const requests = [queryAllTraTaskCrsInfo({ taskId: taskId.value })];
@@ -217,7 +216,7 @@
onMounted(() => {
pagingRef.value.reload();
});
onShow(() => {});
onLoad((e) => {
taskId.value = e.taskId;
const learning_tasks_details = getPageCache('learning_tasks_details');