xinelu-applet-ui/questionnaire/diabetes/diabetes.vue

141 lines
3.2 KiB
Vue
Raw Normal View History

2023-10-27 09:36:30 +08:00
<template>
<view class="app" v-if='list'>
<view class="item" v-for="(item,index) in list.questions" :key="index">
<view class="title">
{{Number(index)+1}}{{item.questionName}}
</view>
<u-radio-group v-model="list.answers[index].optionContent" @change="radioGroupChange($event,item)">
<u-radio @change="radioChange($event,aitem,index)" v-for="(aitem, aindex) in item.options" :key="aindex"
:name="aitem.optionName">
{{aitem.optionName}}
</u-radio>
</u-radio-group>
</view>
<view class="btns" @tap='updata'>
提交
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
2023-10-27 14:06:42 +08:00
import {
submit
} from '@/api/questionnaire/index.js'
2023-10-27 09:36:30 +08:00
export default {
data() {
return {
list: null,
2023-11-14 15:27:08 +08:00
timer: null,
2023-10-27 09:36:30 +08:00
};
},
methods: {
updata() {
this.list.answers.forEach(e => {
if (!e.optionId) {
this.$refs.uToast.show({
title: '请选择完全部选项',
type: 'error',
})
return
}
})
var truelist = this.list.answers.filter(e => e.optionContent == '是')
if (truelist.length > 0) {
this.list.evaluateResult = '您可能存在糖尿病高危风险,建议每年至医疗机构进行一次糖尿病筛查。'
} else if (truelist.length == 0) {
this.list.evaluateResult = '您没有糖尿病高危风险,请继续保持!'
}
2023-11-14 15:27:08 +08:00
clearInterval(this.timer);
2023-10-27 14:06:42 +08:00
submit(this.list).then(res => {
2023-11-14 15:27:08 +08:00
this.$refs.uToast.show({
title: '提交成功',
type: 'success',
})
this.timer = setTimeout(e => {
2023-10-27 14:06:42 +08:00
uni.redirectTo({
2023-11-14 15:27:08 +08:00
url: `/questionnaire/prescription/prescription?code=1002&truelistlength=${truelist.length}&list=${encodeURIComponent(JSON.stringify(this.list))}`
2023-10-27 14:06:42 +08:00
})
2023-11-14 15:27:08 +08:00
}, 2000)
2023-10-27 14:06:42 +08:00
})
2023-10-27 09:36:30 +08:00
},
// 选中某个单选框时由radio时触发
radioChange(e, item, index) {
this.list.answers[index].optionId = item.id
},
// 选中任一radio时由radio-group触发
radioGroupChange(e) {
// console.log(e);
}
},
onLoad(options) {
let list = JSON.parse(decodeURIComponent(options.item))
list.answers = []
list.questions.forEach(e => {
e.name = '请选择'
var obj = {
"questionId": e.id,
"optionId": null,
"optionContent": null,
}
list.answers.push(obj)
})
this.list = {
userId: uni.getStorageSync('patientId'),
surveyId: list.id,
surveySubject: list.surveySubject,
evaluateResult: null,
advice: null,
questions: list.questions,
answers: list.answers
}
}
}
</script>
<style lang="scss">
.app {
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;
::v-deep .u-radio {
padding: 20rpx;
}
.title {
padding: 40rpx 0 20rpx;
font-size: 28rpx;
font-weight: 400;
color: #333333;
}
::v-deep .uni-picker-container {
width: 100%;
height: 63rpx;
background: #A7A7A7;
line-height: 63rpx;
opacity: 0.1;
border-radius: 5rpx;
}
}
}
</style>