Files
medicine_app/pages/miniClass/taskDetailForMan.vue
@fawn-nine 57d5beaa72 暂存
2024-08-23 18:10:27 +08:00

870 lines
22 KiB
Vue

<template>
<view>
<public-module></public-module>
<z-nav-bar :title="pageType+'详情'"></z-nav-bar>
<!-- <view class="" style="background-color: #f4f7ff; min-height: calc(100vh - 200rpx);"> -->
<view class="mainContent" v-if="thisTask.id">
<view class="" style="height:40rpx;">
</view>
<view class="taskBox">
<h3>题目内容</h3>
<view class="taskTitle">
{{thisTask.title}}
</view>
<view class="imgBox flex_box" v-if="FileList11.length > 0">
<view class="item" v-for="(item, index) in FileList11" :key="index">
<image @click="previewImage(item.url)" :src="item.url" mode="widthFix"></image>
</view>
</view>
<view class="taskContent" v-html="thisTask.content">
</view>
<!-- <view class="editBtn" @click="goEdit" v-if="
( classState == 0 && taskType == 0 || taskType != 0) && zuoyeList.length == 0 && (roleCode.includes('1') || roleCode.includes('2'))"> -->
<view class="editBtn" v-if="taskType != '0' && classState == '1' && zuoyeList.length == 0 && (roleCode.includes('1') || roleCode.includes('2'))">
<text @click="goEdit" class="border_radius_10 small_btn edit">修改</text>
<text @click="delTask" class="border_radius_10 small_btn del">删除</text>
</view>
</view>
<!-- 提交记录 -->
<view>
<uni-section class="mb-10 nobg" title="提交记录" type="line"></uni-section>
<view class="zuoyeListBox" v-if="zuoyeList.length > 0">
<view class="newBox">
<view class="item " v-for="(item, index) in zuoyeList" @click="editOrAdd(item)">
<view class="leve1 flex_box" style="justify-content: space-between;">
<view class="flex_box" style="justify-items: center;">
<view class="classmateImg">
<image v-if="item.createUser.avatar != null && item.createUser.avatar != ''"
:src="item.createUser.avatar" mode="aspectFit"></image>
<image v-else src="/static/icon/morenAvavter.png" mode="aspectFit"></image>
</view>
<view class="userName flex_box">
<text
v-if="item.createUser.nickname != '' && item.createUser.nickname != null">{{item.createUser.nickname}}</text>
<text v-else>匿名用户</text>
</view>
</view>
</view>
<view class="leve2">
<view class="">
{{item.content}}
</view>
<view class="" style="margin-top: 20rpx;">
<view class="score" v-if="item.scoreSuccess == 1">
分数:{{item.score}}
</view>
<view class="score noscore" v-else-if="item.scoreInfo != ''">
<text v-show="item.scoreInfos < 2 && item.haveGiveScore">等待其他评分员评分</text>
<text v-show="item.scoreInfos < 2 && !item.haveGiveScore && roleCode.includes('4')">请您评分</text>
<!-- <button v-show="item.scoreInfos >= 2" class="getScore" @click.stop="getRealScore(item.id)" >生成成绩</button> -->
</view>
<view class="score noscore" v-else>未开始评分</view>
<view class="date">
{{item.createTime}}
</view>
</view>
</view>
</view>
</view>
</view>
<u-divider v-show="status == 2" text="已加载全部"></u-divider>
<u-divider v-show="status == 3" text="暂无数据"></u-divider>
<u-divider v-show="status == 1" text="加载中..."></u-divider>
</view>
</view>
<u-popup key="1" :show="showEditBlank" :round="10" @close="closePup" ref="" z-index="998" overlay-style="z-index:998">
<view class="" style="padding: 40rpx; max-height: 80vh; overflow-y:scroll">
<view class="anserBox">
<h3>提交的内容</h3>
<view class="" style="border-bottom: 1px solid #eee; padding-bottom: 20rpx; margin-bottom: 20rpx;">
<view class="anserContent" v-html="curReplay.content">
</view>
<view class="">
<view class="imgBox flex_box" v-if="fileList1.length > 0">
<view class="item" v-for="(item, index) in fileList1" :key="index">
<image @click="previewImage(item.url)" :src="item.url" mode="widthFix"></image>
</view>
</view>
</view>
</view>
<view class="date">
日期:{{curReplay.createTime}}
</view>
<view class="" v-if="curReplay.createUser" style="color: #999;padding: 10rpx 0; font-size: 26rpx;">
学员信息:{{curReplay.createUser.nickname != null && curReplay.createUser.nickname != '' ? curReplay.createUser.nickname : '匿名用户'}}
/ {{curReplay.createUser.tel}}
</view>
<view class="score" v-show="curReplay.scoreSuccess != 0">
分数:{{curReplay.score}}
</view>
<view class="score noscore" v-show="curReplay.scoreSuccess == 0">
未生成成绩
</view>
<template v-if="roleCode.includes('4') || roleCode.includes('5') && curReplay.scoreSuccess < 2">
<view class="" style=" padding: 10rpx 10rpx; margin-top: 20rpx;">
<view class="scoreBox flex_box">
<text>分数</text>
<text v-for="(item, index) in scoreList" @click="setScore(item)" :class="[item == form.score ?'active' : '' ]">
{{item}} 分
</text>
</view>
</view>
<view class="btn_box ">
<button class="submit" @click="onSubmit">提 交</button>
</view>
</template>
</view>
</view>
</u-popup>
<z-navigation></z-navigation>
</view>
</template>
<script>
// const taskinfo1 = require('@/data/manTaskInfo.json')
import $http from '@/config/requestConfig.js';
import {
mapState
} from "vuex";
export default {
data() {
return {
showEditBlank: false,
zuoyeList: [],
loadFlag: false,
thisTask: {},
status: 88,
TaskId: undefined,
userMes: undefined,
FileList11: [],
fileList1: [],
pPage: 0,
form: {
score: undefined, //分数
id: undefined,
},
// ispreviewImage :false,
curReplay: {},
rules: {
score: {
rules: [{
required: true,
errorMessage: '请输入分数',
}
]
},
},
listDisplay: '1', // 提交记录展示类型 0 全部 1 自己的
roleCode:'',
pageType:'',
classState:undefined,
taskType:undefined,
scoreList:[
0,0.5,1,1.5,2,2.5
],
}
},
onLoad(e) {
uni.hideTabBar();
this.classState = e.classState
// this.thisTask = JSON.parse(e.options)
console.log('e', e)
this.roleCode = e.roleCode
this.taskType = e.type
console.log('e', this.taskType,e)
if (e.id) {
this.thisTask.id = e.id
this.getReplayList()
}
if(e.type == 0){
// this.form.renwuId = e.renwuId
this.pageType = '作业'
}else if(e.type == 1){
this.pageType = '医案'
}else if( e.type == 2){
this.pageType = '心得'
}
// console.log('this.FileList', this.FileList)
// this.TaskId = e.id
this.getUserInfo()
},
onReachBottom() {
if (this.status != 2 && this.status != 3) {
this.getReplayList()
}
},
onPullDownRefresh() {
this.pPage = 0
this.zuoyeList = []
this.getReplayList()
// this.getTaskInfo()
uni.stopPullDownRefresh()
},
onShow() {
this.form.taskId = this.thisTask.id
// console.log('this.ispreviewImage',this.ispreviewImage);
// if(this.ispreviewImage){
// this.showEditBlank = true
// this.ispreviewImage = false
// }
this.FileList11 = []
this.getTaskInfo()
},
computed: {
...mapState(["userInfo"]),
},
methods: {
delTask(){
$http.request({
url: "common/class/delClassTask",
method: "POST",
data: {
"taskId": this.thisTask.id
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if(res.code == 0){
uni.showToast({
title:'删除成功',
icon:'success'
})
setTimeout(()=>{
uni.navigateTo({
url: `/pages/miniClass/taskList?classId=${this.thisTask.classId}&type=${this.thisTask.type}&roleCode=${this.roleCode}&classState=${this.classState}`
// classId=${classId}&type=${type}&roleCode=${this.roleCode}
})
},2000)
}else{
uni.showToast({
title:'删除失败',
icon:'error'
})
}
})
.catch(e => {
uni.showToast({
title:'删除失败',
icon:'error'
})
})
},
setScore(val){
// if(this.form.score == val) return
this.form.score = val
console.log('this.form.score',this.form.score);
},
// 生成成绩
getRealScore(id){
uni.showLoading({
title:'正在处理'
})
$http.request({
url: "common/class/generateScore",
method: "POST",
data: {
"replyId": id
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if (res.code == 0) {
uni.showToast({
title: '成绩已生成',
icon: 'success'
})
}
setTimeout(()=>{
this.closePup()
this.pPage = 0
this.zuoyeList = []
this.getReplayList()
uni.hideLoading()
},500)
}).catch(e => {
uni.hideLoading()
console.log(e, '数据报错')
// this.status = 3
uni.showToast({
title: '成绩生成失败',
icon: 'error'
})
});
},
// 获取医案任务详情
getTaskInfo() {
$http.request({
url: "common/class/getClassTaskInfo",
method: "POST",
data: {
"taskId": this.thisTask.id
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if (res.code == 0) {
// that.isHave = true
// console.log(res)
this.thisTask = res.result.classTask
// this.zuoyeList = res.result.userList
// this.thisTask = taskinfo1.classTask
this.fileList11 = []
if (this.thisTask.img != '') {
var imgs = this.thisTask.img.split(',')
imgs = imgs.forEach((item, index) => {
this.FileList11.push({
url: item
})
})
}
console.log('thisTask', this.thisTask);
}
}).catch(e => {
console.log(e, '数据报错')
// this.status = 3
uni.showToast({
title: e.msg,
icon: 'error'
})
});
},
closePup() {
this.showEditBlank = false
this.form = {
score: undefined,
id: undefined,
}
this.curReplay = {}
this.fileList1 = []
},
deletePic(event) {
this.fileList1.splice(event.index, 1)
},
getHomeWorkDetail(id){
uni.showLoading({
title:"加载中"
})
$http.request({
url: 'common/class/getClassTaskAndQuesReplyInfo',
method: "POST",
data: {
"replyId":id, //0全部作业1我的作业
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if(res.classTaskAndQuesReply){
console.log('作业详情res',res);
this.curReplay = res.classTaskAndQuesReply
this.form.id = res.classTaskAndQuesReply.id
this.fileList1 = []
if(res.classTaskAndQuesReply.img != ''){
var _imgList = res.classTaskAndQuesReply.img.split(',')
_imgList.forEach(item => {
this.fileList1.push({url:item})
})
}
if(res.classTaskAndQuesReply.scoreInfo != ''){
this.curReplay.scoreInfo = JSON.parse(res.classTaskAndQuesReply.scoreInfo)
}else{
this.curReplay.scoreInfo = {}
}
if(this.curReplay.scoreInfo != {}){
for (let k in this.curReplay.scoreInfo){
console.log(k)
if(k == this.userInfo.id){
this.form.score = this.curReplay.scoreInfo[k]
this.form.hasGiveScore = true
break
}
// console.log(this.curReplay.scoreInfo[k])
}
}
console.log('this.curReplay.scoreInfo',this.curReplay.scoreInfo);
this.showEditBlank = true
}else{
this.curReplay = {}
this.closePup()
}
uni.hideLoading()
}).catch(e => {
this.showEditBlank = false
uni.hideLoading()
uni.showToast({
title: '获取数据失败',
icon:'none'
})
})
},
editOrAdd(item) {
// console.log('item', item);
this.getHomeWorkDetail(item.id)
},
radioChange1(e) {
this.listDisplay = e.detail.value
console.log('点了', e);
this.pPage = 0
this.zuoyeList = []
this.getReplayList()
},
previewImage(url) {
console.log(url);
// this.ispreviewImage = true
// this.showEditBlank = false
uni.previewImage({
urls: [url],
longPressActions: {
itemList: ["很抱歉,暂不支持保存图片到本地"],
success: function(res) {
// console.log(res,'+++++')
},
},
});
},
getReplayList() {
this.status = 1;
if (this.loadFlag) {
console.log("有未完成的进程");
return;
}
uni.showLoading({
title: '加载中'
})
this.loadFlag = true;
this.pPage++;
$http.request({
url: 'common/class/getReplyListByTaskId',
method: "POST",
data: {
"limit": 10,
"page": this.pPage,
"taskId": this.thisTask.id
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if (res.page.records.length > 0) {
var list = res.page.records
list.forEach(item => {
item.scoreInfos = 0
item.haveGiveScore = false
item.fileList = []
if (item.img != '') {
var _urs = item.img.split(',')
_urs.forEach(item1 => {
item.fileList.push({
url: item1
})
})
}
console.log('item.scoreInfo',item.scoreInfo);
if(item.scoreInfo != ""){
var i = 0
for(var kk in JSON.parse(item.scoreInfo)){
console.log(kk);
if(kk == this.userInfo.id){
item.haveGiveScore = true
}
i++
}
item.scoreInfos = i
}
console.log('item.scoreInfos',item.scoreInfos, item.haveGiveScore);
})
this.zuoyeList = this.zuoyeList.concat(list)
console.log('chulihoude ', this.zuoyeList);
if (res.page.pages > this.pPage) {
this.status = 0;
} else {
this.status = 2;
}
} else {
this.status = 3; // 暂无数据
}
this.loadFlag = false;
console.log('res', res);
uni.hideLoading()
}).catch(e => {
uni.hideLoading()
this.loadFlag = false;
// console.log('表单错误信息:', err);
uni.showToast({
title: '获取作业列表失败',
icon: 'none'
})
})
},
goEdit(){
uni.navigateTo({
url:`/pages/miniClass/addHomeWork?id=${this.thisTask.id}&type=${this.thisTask.type}`
})
},
getUserInfo() {
// 获取个人信息
if (this.userInfo.id != undefined) {
this.$http.post("common/user/getUserInfo").then((res) => {
this.userMes = res.result
}).catch(e => {
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
});
}
},
// 跳转
onPageJump(url, id, modeType) {
uni.navigateTo({
url: `${url}?id=${id}&type=${modeType}`
});
},
onSubmit() {
// this.$refs.form.validate().then(res => {
if(!this.form.score){
uni.showToast({
title:'请选择分值',
icon:'none'
})
return
}
var _url = "common/class/editScore"
var data = {
"score": this.form.score,
"replyId": this.form.id
}
console.log('data后台提交数据', data);
$http.request({
url: _url,
method: "POST",
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
uni.showToast({
title: '操作成功!',
icon: 'success'
})
this.FileList = []
setTimeout(()=>{
this.closePup()
this.pPage = 0
this.zuoyeList = []
this.getReplayList()
},1000)
}).catch(e => {
uni.showToast({
title: '操作失败',
icon: 'error'
})
});
// }).catch(err => {
// console.log('表单错误信息:', err);
// uni.showToast({
// title: '页面有未填写的内容哦',
// icon: 'none'
// })
// })
},
clickStudents(item) {
console.log('item', item);
},
addPic(e) {
let that = this;
console.log("添加图片", that.fileList1);
for (var i = 0; i < e.file.length; i++) {
console.log(i, e.file[i].url)
uni.uploadFile({
url: this.$baseUrl + "oss/fileoss",
filePath: e.file[i].url,
//files:e.file,
name: "file",
formData: {},
success: (res) => {
// console.log("添加图片", this.fileList1);
that.fileList1.push({
url: JSON.parse(res.data).url,
});
console.log(that.fileList1, "that.uploadPicLIst");
},
fail: (error) => {
console.log("上传失败", error);
},
});
}
},
async checkPermision() {
var result = await permission.premissionCheck("CAMERA_EXTERNAL_STORAGE")
if (result != 1) {
return false
}
},
radioChange(e) {
this.form.display = e.detail.value
console.log('点了', this.form.display, e);
}
}
}
</script>
<style lang="scss" scoped>
@import "@/style/mixin.scss";
::v-deep .uni-forms-item{margin-bottom: 0 !important;}
// .btn_box{ justify-content: space-between;
// button{display: block; width: 46%;}
// }
.getScore{
display: inline-block; font-weight: normal; color: #fff; padding: 4rpx 10rpx; height: 60rpx;
line-height: 50rpx; font-size: 28rpx;
background-color: #ffaa7f !important;
}
.flexbox {
display: flex;
}
i {
color: red;
padding-right: 20rpx;
}
.noanser {
padding: 20rpx;
text-align: center;
// border-bottom: 1px solid #eee;
.btn {
display: inline-block;
border-radius: 20rpx;
padding: 10rpx 20rpx;
background-color: $themeColor;
color: #fff;
}
}
.in {
border: 1rpx solid #eeeeee;
border-radius: 8rpx;
padding: 8rpx;
margin-top: 10rpx;
}
.editBtn{text-align: center; margin-top: 20rpx;
.edit{border:1px solid $themeColor; color: $themeColor;}
.del{color: #ff557f; border: 1px solid #ff557f; margin-left: 20rpx;}
}
.zuoyeListBox {
margin-top: 40rpx;
// background-color: #fff;
border-radius: 20rpx;
}
.scoreBox{
text{display: inline-block; font-size: 26rpx; width: 100%; border: 1px solid #ddd; text-align: center; line-height:60rpx; border-right: none;}
text:last-child{border-right: 1px solid #ddd;}
text.active{background-color: #55aaff; color: #fff; border-color: #55aaff;}
}
.btn_box {
margin-top: 70rpx;
padding-bottom: 20rpx;
button {
font-size: 32rpx;
@include theme('btn_bg') color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
}
.fabBox {}
.taskBox {
border: 4rpx dotted #bad7f0;
padding: 20rpx;
padding-top: 0;
background-color: #fff;
border-radius: 20rpx;
overflow: hidden;
h3 {
line-height: 80rpx;
width: 50%;
margin: 0 auto;
text-align: center;
color: #fff;
border-radius: 0 0 20rpx 20rpx;
background-color: $themeColor;
}
}
.anserBox {
border: 4rpx dotted #2bb447;
margin-top: 30rpx;
padding: 20rpx;
background-color: #fff;
border-radius: 20rpx;
overflow: hidden;
padding-top: 0;
.anserContent{line-height: 50rpx; padding: 20rpx 0; display: block;}
h3 {
line-height: 80rpx;
width: 50%;
margin: 0 auto;
text-align: center;
color: #fff;
background-color: #2bb447;
border-radius: 0 0 20rpx 20rpx;
}
}
.nobg {
background: transparent;
}
.taskTitle {
font-size: 30rpx;
margin: 20rpx 0;
}
.redBorder {
border: 1px solid #ff8f8f !important;
}
.blueBorder {
border: 1px solid #9111aa !important;
}
.greenBorder {
border: 1px solid #55aa00 !important;
}
.newBox {
justify-content: start;
padding: 10rpx 10rpx 0 10rpx;
.classmateImg {
width: 60rpx !important;
height: 60rpx !important;
margin-right: 20rpx;
image {
width: 60rpx !important;
height: 60rpx;
}
}
.item {
background-color: #fff;
border-radius: 20rpx;
box-shadow: none !important;
padding: 20rpx;
margin-bottom: 30rpx;
// border-bottom: 1px solid #eee;
// border-radius: 0 !important;
.leve1 {
align-items: center;
border-bottom: 1px dashed #eee;
padding-bottom: 20rpx;
margin-bottom: 20rpx;
}
.leve2 { overflow: hidden;
.score{float: left;}
.date{float: right;}
}
}
}
.taskContent {
font-size: 30rpx; line-height: 50rpx;
margin-top: 20rpx;
}
.date {
color: #999;
text-align: right;
font-size: 26rpx;
}
.score{color: #55aaff; font-size: 30rpx !important; font-weight: bold;}
.noscore{color: #ffaa7f;}
.imgBox {
flex-wrap: wrap;
.item {
width: 20%;
margin-right: 10rpx;
border: 1px solid #eee;
padding: 0 !important;
image {
width: 100%;
}
}
}
.manBtnBox {
justify-content: center;
text {
width: 30%;
font-size: 28rpx;
padding: 20rpx 0;
border-radius: 10rpx;
display: block;
margin: 0 20rpx;
color: #fff;
}
.edit {
background-color: $themeColor;
}
.del {
background-color: #ffa4a6;
}
.set {
background-color: #ffca7e;
}
}
.mainContent {
display: block;
color: #333;
padding: 0 20rpx;
padding-bottom: 120rpx;
background-image: linear-gradient(30deg, #d4eaf0 0%, #d4eaf0 50%, #fdf0ed 100%);
min-height: 100vh;
}
</style>