348 lines
9.8 KiB
Vue
348 lines
9.8 KiB
Vue
<template>
|
||
<view class="content">
|
||
<view class="app">
|
||
<view class="item" v-for="(item, index) in questiondata.questionSubjectList" :key="index">
|
||
<view class="title">
|
||
{{Number(index)+1}}、{{item.questionName}}
|
||
<span v-if="item.questionType == 'MULTIPLE_CHOICE'">(单选题)</span>
|
||
<span v-if="item.questionType == 'MULTIPLE_CHOICE_QUESTIONS'">(多选题)</span>
|
||
<span v-if="item.questionType == 'SCORING_QUESTIONS'">(打分题)</span>
|
||
<span v-if="item.questionType == 'COMBINATION_RADIO_SUBJECT'">(组合单选题)</span>
|
||
<span v-if="item.questionType == 'COMBINATION_MULTIPLE_SUBJECT'">(组合多选题)</span>
|
||
<span v-if="item.questionType == 'COMBINATION_BLANKS_SUBJECT'">(组合填空题)</span>
|
||
<span v-if="item.questionType == 'FILL_IN_THE_BLANKS'">(填空题)</span>
|
||
<span v-if="item.questionType == 'COMBINATION_SCORING_SUBJECT'">(组合打分题)</span>
|
||
<span v-if="item.questionType == 'DATE_BLANKS_SUBJECT'">(日期填空题)</span>
|
||
<span v-if="item.questionType == 'TIME_BLANKS_SUBJECT'">(时间填空题)</span>
|
||
</view>
|
||
<!-- 单选。组合单选 -->
|
||
<u-radio-group v-if="
|
||
item.questionType == 'MULTIPLE_CHOICE' ||
|
||
item.questionType == 'COMBINATION_RADIO_SUBJECT' ||
|
||
item.questionType == 'SCORING_QUESTIONS' ||
|
||
item.questionType == 'COMBINATION_SCORING_SUBJECT'
|
||
" v-model="item.checked" @change="radioGroupChange($event,item)">
|
||
<u-radio @change="radioChange($event, aitem, index)"
|
||
v-for="(aitem, aindex) in item.questionSubjectOptionList" :key="aindex" :name="aitem.id">
|
||
{{aitem.optionName}}
|
||
</u-radio>
|
||
</u-radio-group>
|
||
<!-- 多选 -->
|
||
<u-checkbox-group v-if="
|
||
item.questionType == 'MULTIPLE_CHOICE_QUESTIONS' ||
|
||
item.questionType == 'COMBINATION_MULTIPLE_SUBJECT'
|
||
">
|
||
<u-checkbox @change="radioChangecheck($event, aitem, index, aindex)" v-model="aitem.checked"
|
||
v-for="(aitem, aindex) in item.questionSubjectOptionList" :key="aindex"
|
||
:name="aitem.id">{{aitem.optionName}}</u-checkbox>
|
||
</u-checkbox-group>
|
||
<!-- 填空题、组合填空 -->
|
||
<view class="" v-if="
|
||
item.questionType == 'FILL_IN_THE_BLANKS' ||
|
||
item.questionType == 'COMBINATION_BLANKS_SUBJECT'
|
||
">
|
||
<u-input placeholder="请输入" v-model="item.fillBlanksAnswer" type="textarea" :height="100"
|
||
:customStyle="{lineHeight: '30px'}" placeholder-style="color: #8E8E8E" />
|
||
</view>
|
||
<!-- 日期填空题、 -->
|
||
<view class="datatime" v-if="item.questionType == 'DATE_BLANKS_SUBJECT'" @tap="showtap(index)">
|
||
<text v-if="!item.fillBlanksAnswer">请选择出生日期</text>
|
||
<text v-else class="testitem">{{item.fillBlanksAnswer}}</text>
|
||
<image src="@/static/huijiantou.png" mode=""></image>
|
||
</view>
|
||
<!-- 时间填空题 -->
|
||
<view class="datatime" v-if="item.questionType == 'TIME_BLANKS_SUBJECT'" @tap="showtimetap(index)">
|
||
<text v-if="!item.fillBlanksAnswer">请选择时间</text>
|
||
<text v-else class="testitem">{{item.fillBlanksAnswer}}</text>
|
||
<image src="@/static/huijiantou.png" mode=""></image>
|
||
</view>
|
||
|
||
<u-calendar v-model="show" :value="index" :mode="mode" @change="change($event)"></u-calendar>
|
||
<u-picker mode="time" @confirm="Changepicker($event)" :value="index" :params="params"
|
||
v-model="showtime">
|
||
</u-picker>
|
||
</view>
|
||
<view class="btns" @tap='updata'>
|
||
提交
|
||
</view>
|
||
</view>
|
||
|
||
<u-toast ref="uToast" />
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
selectQuestion,
|
||
updateTaskExecuteRecord
|
||
} from '@/api/questionnaire/questionnaire.js'
|
||
export default {
|
||
data() {
|
||
return {
|
||
item: null,
|
||
showindex: '', //日期
|
||
showtimeindex: '', //时间
|
||
templateId: '',
|
||
questiondata: {},
|
||
checkeddata: [],
|
||
checked: false,
|
||
params: {
|
||
// year: true,
|
||
// month: true,
|
||
// day: true,
|
||
hour: true,
|
||
minute: true,
|
||
// second: true,
|
||
// timestamp: true
|
||
},
|
||
time: '',
|
||
showtime: false,
|
||
show: false,
|
||
mode: 'date',
|
||
questions: null,
|
||
timer: null,
|
||
};
|
||
},
|
||
onLoad(options) {
|
||
this.item = JSON.parse(decodeURIComponent(options.item))
|
||
console.log(this.item, 'this.item')
|
||
// console.log(options, 'option')
|
||
|
||
this.selectScriptInfodata()
|
||
|
||
},
|
||
methods: {
|
||
// 日期
|
||
showtap(index) {
|
||
this.show = true
|
||
this.showindex = index
|
||
|
||
},
|
||
// 时间
|
||
showtimetap(index) {
|
||
this.showtime = true
|
||
this.showtimeindex = index
|
||
},
|
||
selectScriptInfodata() {
|
||
selectQuestion(this.item.templateId).then(res => {
|
||
this.questiondata = res.data;
|
||
this.questiondata.questionInfoId = this.item.templateId;
|
||
this.questiondata.questionSubjectList.forEach(e => {
|
||
if (e.questionType == 'MULTIPLE_CHOICE' || e.questionType ==
|
||
'MULTIPLE_CHOICE_QUESTIONS' || e.questionType == 'SCORING_QUESTIONS' || e
|
||
.questionType == 'COMBINATION_RADIO_SUBJECT' || e.questionType ==
|
||
'COMBINATION_MULTIPLE_SUBJECT' || e.questionType ==
|
||
'COMBINATION_SCORING_SUBJECT') {
|
||
e.whetherScore = '1'
|
||
} else {
|
||
e.whetherScore = '0'
|
||
}
|
||
e.questionSubjectOptionList.forEach(el => {
|
||
el.questionNumber = e.questionNumber
|
||
if (e.questionType == 'MULTIPLE_CHOICE_QUESTIONS' || e.questionType ==
|
||
'COMBINATION_MULTIPLE_SUBJECT') {
|
||
el.optionChooseSign = '1'
|
||
}
|
||
})
|
||
})
|
||
})
|
||
},
|
||
// 选中某个单选框时,由radio时触发
|
||
radioChange(e, item, index) {
|
||
this.questiondata.questionSubjectList[index].questionSubjectOptionList.forEach(el => {
|
||
if (el.id == item.id) {
|
||
el.optionChooseSign = '0'
|
||
} else {
|
||
el.optionChooseSign = '1'
|
||
}
|
||
})
|
||
},
|
||
// 复选框
|
||
radioChangecheck(e, item, index, aindex) {
|
||
if (e.value == true) {
|
||
this.questiondata.questionSubjectList[index].questionSubjectOptionList[aindex].optionChooseSign = '0'
|
||
} else {
|
||
this.questiondata.questionSubjectList[index].questionSubjectOptionList[aindex].optionChooseSign = '1'
|
||
}
|
||
},
|
||
// 日期
|
||
change(e) {
|
||
this.questiondata.questionSubjectList[this.showindex].fillBlanksAnswer = e.result
|
||
},
|
||
// 时间
|
||
Changepicker(e) {
|
||
this.time = e.hour + ':' + e.minute
|
||
this.questiondata.questionSubjectList[this.showtimeindex].fillBlanksAnswer = this.time
|
||
},
|
||
// 提交
|
||
updata() {
|
||
if(uni.getStorageSync('patientId')){
|
||
this.questiondata.residentId=uni.getStorageSync('patientId')
|
||
}
|
||
// console.log(this.questiondata, 'this.questiondata提交')
|
||
// 对象.新名字=对象.原数组
|
||
this.$delete(this.questiondata, 'updateBy', )
|
||
this.$delete(this.questiondata, 'updateTime', )
|
||
this.questiondata.manageRouteNodeId=this.item.manageRouteNodeId
|
||
this.questiondata.subjectResultDTOList = this.questiondata.questionSubjectList
|
||
this.obj = JSON.parse(JSON.stringify(this.questiondata))
|
||
delete this.obj.questionSubjectList;
|
||
this.obj.subjectResultDTOList.forEach(e => {
|
||
e.optionResultList = e.questionSubjectOptionList
|
||
if (e.optionResultList.optionSubmitAnswer) {
|
||
e.optionResultList.optionSubmitAnswer = e.optionResultList.optionSubmitAnswer
|
||
}
|
||
delete e.questionSubjectOptionList;
|
||
});
|
||
console.log(this.obj, 'obj')
|
||
// return
|
||
updateTaskExecuteRecord(this.obj).then(res => {
|
||
if(res.code==200){
|
||
this.$refs.uToast.show({
|
||
title: '提交成功',
|
||
type: 'success',
|
||
})
|
||
this.timer = setTimeout(e => {
|
||
uni.navigateBack({ // 返回上一页
|
||
delta: 1
|
||
})
|
||
}, 2000)
|
||
uni.$emit('refresh')
|
||
|
||
}else{
|
||
this.$refs.uToast.show({
|
||
title: res.msg,
|
||
type: 'error',
|
||
})
|
||
|
||
}
|
||
|
||
})
|
||
},
|
||
// 选中任一radio时,由radio-group触发
|
||
radioGroupChange(e) {
|
||
// console.log(e);
|
||
}
|
||
},
|
||
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.content {
|
||
height: 100vh;
|
||
background-color: #F7F5F5;
|
||
padding: 30rpx 0 0 0;
|
||
overflow: scroll;
|
||
|
||
.app {
|
||
::v-deep u-radio__icon-wrap--disabled {
|
||
background-color: #2979ff;
|
||
}
|
||
width: 96%;
|
||
margin: 16rpx auto;
|
||
background: #FFFFFF;
|
||
box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
|
||
border-radius: 5rpx;
|
||
padding-bottom: 200rpx;
|
||
|
||
.btns {
|
||
width: 90%;
|
||
margin: 100rpx auto;
|
||
background-color: #26A888;
|
||
text-align: center;
|
||
line-height: 60rpx;
|
||
height: 60rpx;
|
||
color: #fff;
|
||
}
|
||
|
||
.item {
|
||
width: 90%;
|
||
margin: 0 auto;
|
||
// padding: 30rpx 0;
|
||
|
||
.datatime {
|
||
width: 636rpx;
|
||
height: 63rpx;
|
||
background: #F6F6F6;
|
||
margin: 12rpx auto;
|
||
border-radius: 5rpx;
|
||
display: flex;
|
||
position: relative;
|
||
|
||
.testitem {
|
||
font-size: 26rpx;
|
||
font-family: Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #000000;
|
||
}
|
||
|
||
text {
|
||
padding-left: 20rpx;
|
||
line-height: 63rpx;
|
||
font-size: 22rpx;
|
||
font-family: Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #8E8E8E;
|
||
}
|
||
|
||
image {
|
||
width: 9rpx;
|
||
height: 17rpx;
|
||
position: absolute;
|
||
right: 40rpx;
|
||
top: 50%;
|
||
-webkit-transform: translateY(-50%);
|
||
transform: translateY(-50%);
|
||
}
|
||
}
|
||
|
||
::v-deep .u-input__textarea.data-v-fdbb9fe6 {
|
||
background: #F6F6F6 !important;
|
||
padding-left: 10rpx;
|
||
}
|
||
|
||
::v-deep .u-input {
|
||
width: 636rpx;
|
||
// height: 63rpx;
|
||
background: #F6F6F6;
|
||
margin: 12rpx auto;
|
||
border: none;
|
||
border-radius: 5rpx;
|
||
|
||
}
|
||
|
||
::v-deep .u-input__input.data-v-fdbb9fe6 {
|
||
font-size: 26rpx !important;
|
||
}
|
||
|
||
|
||
::v-deep .u-radio-group {
|
||
display: inline-grid;
|
||
}
|
||
|
||
::v-deep .u-checkbox-group {
|
||
display: inline-grid;
|
||
}
|
||
|
||
::v-deep .u-checkbox {
|
||
padding: 20rpx;
|
||
|
||
}
|
||
|
||
::v-deep .u-radio {
|
||
padding: 20rpx;
|
||
}
|
||
|
||
.title {
|
||
padding: 40rpx 0 20rpx;
|
||
font-size: 28rpx;
|
||
font-weight: 400;
|
||
color: #333333;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|