xinelu-applet-ui/questionnaire/cerebralapoplexy/cerebralapoplexy.vue
2023-10-27 14:06:42 +08:00

145 lines
3.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>
import {
submit
} from '@/api/questionnaire/index.js'
export default {
data() {
return {
list: null,
};
},
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) {
if (truelist.length >= 3) {
this.list.evaluateResult = `本次评估结果为${truelist.length}分3分及以上者为脑卒中高危人群请尽早到医疗机构进行专业评估和干预。`
} else {
this.list.evaluateResult = `本次评估结果为${truelist.length}分3分以下者没有脑卒中高危风险请继续保持`
}
} else if (truelist.length == 0) {
this.list.evaluateResult = '本次评估结果为0分3分以下者没有脑卒中高危风险请继续保持'
}
submit(this.list).then(res => {
if (truelist.length >= 3) {
uni.redirectTo({
url: `/questionnaire/prescription/prescription?code=1003`
})
} else {
this.$refs.uToast.show({
title: '提交成功',
type: 'success',
back: 1
})
}
})
},
// 选中某个单选框时由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>