asd/asd-wx/tablePackage/pages/answerDetail.vue
愉快的大福 340a467ba1 init
2024-11-21 11:32:11 +08:00

1186 lines
34 KiB
Vue
Raw Permalink 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="content">
<view class="header">
<image src="../../static/images/test-bg.png"></image>
</view>
<template v-if="tableAlias == 'table1'">
<view class="ques-con">
<view class="music-img" v-if="showImg">
<image src='@/static/images/yuyin.gif' v-if="showMusic" @click="pauseMusic"></image>
<image src='@/static/images/pause.jpg' v-else @click="playMusic"></image>
</view>
<view class="ques-answer-con">
<view class="answer" v-for="(item,index) in table.questionInfo" :key="index">
<view class="answer-option" :id="'question-'+index">{{item.sceneName}}
</view>
<view class="answer-text">A. {{item.optionA}}</view>
<view class="tip">答案: </view>
<view>
<radio-group class="assess-list" @change="selectAssess(item.id,$event,
'optionA',item.listorder)">
<label class="one-assess" v-for="(data,index) in assessList" :key="index">
<view>{{data.value}} </view>
<radio :value="data.score.toString()" style="transform:scale(0.7)"
:checked="getScoreChecked(item.id,data.score.toString(),'optionA')" />
<!-- :checked="getScoreChecked(item.id,data.score.toString(),'optionA')" -->
</label>
</radio-group>
</view>
<view class="answer-text">B. {{item.optionB}}</view>
<view class="tip">答案: </view>
<view>
<radio-group class="assess-list" @change="selectAssess(item.id,$event,
'optionB',item.listorder)">
<label class="one-assess" v-for="(data,index) in assessList" :key="index">
<view>{{data.value}} </view>
<radio :value="data.score.toString()" style="transform:scale(0.7)"
:checked="getScoreChecked(item.id,data.score.toString(),'optionB')" />
</label>
</radio-group>
</view>
<view class="answer-text">C. {{item.optionC}}</view>
<view class="tip">答案: </view>
<view>
<radio-group class="assess-list" @change="selectAssess(item.id,$event,
'optionC',item.listorder)">
<label class="one-assess" v-for="(data,index) in assessList" :key="index">
<view>{{data.value}} </view>
<radio :value="data.score.toString()" style="transform:scale(0.7)"
:checked="getScoreChecked(item.id,data.score.toString(),'optionC')" />
</label>
</radio-group>
</view>
<view class="answer-text">D. {{item.optionD}}</view>
<view class="tip">答案: </view>
<view>
<radio-group class="assess-list" @change="selectAssess(item.id,$event,
'optionD',item.listorder)">
<label class="one-assess" v-for="(data,index) in assessList" :key="index">
<view>{{data.value}} </view>
<radio :value="data.score.toString()" style="transform:scale(0.7)"
:checked="getScoreChecked(item.id,data.score.toString(),'optionD')" />
</label>
</radio-group>
</view>
<view class="tip">请选择以上哪个条目是最符合您的孩子的描述? </view>
<view>
<radio-group class="option-con" @change="changeOption(item.id,$event,item.listorder)">
<label class="option-label" v-for="option,optionIndex in optionList"
:key="optionIndex">{{option}}
<radio :value="option" class="one-radio"
:checked="getOptionChecked(item.id,option)" />
</label>
</radio-group>
</view>
<u-divider text="分割线" lineColor="#2979ff" textColor="#2979ff" :dot="true"></u-divider>
</view>
</view>
<view class="bottom">
<view class="btn" @click="submit">提交问卷</view>
</view>
</view>
</template>
<template v-if="tableAlias == 'table2'">
<view v-for="(item,index) in table.questionInfo" :key="index"
v-if="currentQuestionlistorder == item.listorder">
<u-transition :show="true" mode="fade-right">
<view class="ques-con" style="margin-top: 20rpx;">
<view class="music-img" v-if="showImg">
<image src='@/static/images/yuyin.gif' v-if="showMusic" @click="pauseMusic"></image>
<image src='@/static/images/pause.jpg' v-else @click="playMusic"></image>
</view>
<view class="tip" v-if="index == 0">请仔细阅读以下题目,考虑你有多同意或不同意题目中的表述,选择最适合的答案。 </view>
<view class="ques-title-con">
<view class="ques-num">
<text class="current-num">{{item.listorder}}</text>/
<text class="all-num">{{table.questionInfo.length}}</text>
</view>
</view>
<view class="ques-title">{{item.sceneName}}</view>
<view class="ques-answer-con">
<radio-group class="option-con-table2"
@change="changeOption(item.id,$event,item.listorder)">
<label :class="['one-answer',selected(item.id,option.value)]"
v-for="option,optionIndex in optionListTable2"
:key="optionIndex">{{option.value +'. ' + option.label}}
<radio :value="option.value" class="one-radio" style="display: none;" />
</label>
</radio-group>
</view>
</view>
<view class="bottom">
<view class="btn" @click="toNext(item.listorder)"
v-if="currentQuestionlistorder !== table.questionInfo.length">下一题</view>
<view class="btn" @click="submit" v-else>提交问卷</view>
</view>
</u-transition>
</view>
</template>
<template v-if="tableAlias == 'table3'">
<view style="margin-top: -40rpx;" v-for="(item,index) in table.questionInfo" :key="index"
v-if="currentQuestionlistorder == item.listorder">
<u-transition :show="true" mode="fade-right">
<view class="ques-con" style="margin-top: 20rpx;">
<view class="music-img" v-if="showImg">
<image src='@/static/images/yuyin.gif' v-if="showMusic" @click="pauseMusic"></image>
<image src='@/static/images/pause.jpg' v-else @click="playMusic"></image>
</view>
<view class="tip" v-if="index == 0">请仔细阅读以下题目,考虑你有多同意或不同意题目中的表述,选择最适合的答案。 </view>
<view class="ques-title-con">
<view class="ques-num">
<text class="current-num">{{item.listorder}}</text>/
<text class="all-num">{{table.questionInfo.length}}</text>
</view>
</view>
<view class="ques-title">{{item.sceneName}}</view>
<view class="ques-answer-con">
<radio-group class="option-con-table2"
@change="changeOption(item.id,$event,item.listorder)">
<label :class="['one-answer',selected(item.id,option.value)]"
v-for="option,optionIndex in optionListTable3"
:key="optionIndex">{{option.value +'. ' + option.label}}
<radio :value="option.value" class="one-radio" style="display: none;" />
</label>
</radio-group>
</view>
</view>
<view class="bottom">
<view class="btn" @click="toNext(item.listorder)"
v-if="currentQuestionlistorder !== table.questionInfo.length">下一题</view>
<view class="btn" @click="submit" v-else>提交问卷</view>
</view>
</u-transition>
</view>
</template>
<u-loading-icon text="加载中" textSize="18" :show="loading"></u-loading-icon>
</view>
</template>
<script>
// let music = uni.createInnerAudioContext(); //创建播放器对象
export default {
data() {
return {
deptId: uni.getStorageSync('CodeDeptId') ? uni.getStorageSync('CodeDeptId') : "",
music: null,
showImg: false,
showMusic: true,
loading: false,
recordId: null, // 答题记录id
tableAlias: null, // 量表别名 table1 table2 table3
selectedChildId: null, // 儿童Id
table: {}, // 量表内容
optionList: [ // 量表1选项
'A', 'B', 'C', 'D'
],
assessList: [{ // 量表1选项的程度 赋分
value: '从不',
score: 0
}, {
value: '极少',
score: 1
}, {
value: '较少',
score: 2
}, {
value: '有时',
score: 3
}, {
value: '经常',
score: 4
}, {
value: '频繁',
score: 5
}, {
value: '总是',
score: 6
}],
optionListTable2: [ //量表2选项
{
label: '总是',
value: 'A'
},
{
label: '经常',
value: 'B'
},
{
label: '有时',
value: 'C'
},
{
label: '偶尔',
value: 'D'
},
{
label: '从不',
value: 'E'
},
],
optionListTable3: [ //量表2选项
{
label: '完全同意',
value: 'A'
},
{
label: '少许同意',
value: 'B'
},
{
label: '少许不同意',
value: 'C'
},
{
label: '完全不同意',
value: 'D'
}
],
selectedAnswer: [], // 用户问卷回答信息 数组
currentQuestionlistorder: 1, // 当前问卷题目的序号
timer: null,
timeUse: 0
}
},
onLoad(option) {
uni.setStorageSync('selectedAnswer',[]);
if (!option.selectedChildId || uni.$u.test.isEmpty(option.alias) || uni.$u.test.isEmpty(
JSON.parse(uni.getStorageSync(option.alias)))) {
return uni.switchTab({
url: '/pages/tabbar/home/Home'
})
}
this.selectedChildId = option.selectedChildId;
this.tableAlias = option.alias;
this.table = JSON.parse(uni.getStorageSync(option.alias));
uni.setNavigationBarTitle({
title: this.table.tableInfo.tableName + '测试'
})
// 量表1 要判断10周岁 加载不同题目
if (option.alias == 'table1') {
this.ageHandle();
}
// 检查是否有未完成的测试
this.checkRecord()
if (this.table.tableInfo.tableBgmusic != null) {
this.showImg = true;
this.music = uni.createInnerAudioContext();
this.music.onPlay(() => {
});
this.music.onCanplay(() => {
});
this.music.onError((res) => {
});
this.playBgMusic(this.table.tableInfo.tableBgmusic);
} else {
this.showImg = false;
}
},
onHide() {
this.music.stop();
},
onUnload() {
this.music.stop();
if (this.timer) {
clearTimeout(this.timer);
this.timer = null;
}
this.music.destroy();
},
watch:{
selectedAnswer(newData, oldData) {
// 监听 count 的变化
console.log('selectedAnswer 变化了', newData,oldData);
if(!this.selectedAnswer){
this.selectedAnswer = uni.getStorageSync('selectedAnswer')
}else{
uni.setStorageSync('selectedAnswer',this.selectedAnswer);
}
},
},
methods: {
playBgMusic(url) {
if (url) {
url = this.baseUrl + url;
this.music.src = url; //选择播放的音频
this.music.loop = true;
this.music.play(); //执行播放
}
},
pauseMusic() {
this.showMusic = false;
this.music.stop();
},
playMusic() {
this.showMusic = true;
this.music.play()
},
// 计时
timeUseStart() {
this.timer = setInterval(() => {
this.timeUse = this.timeUse + 1
}, 1000);
},
// 检查当前用户,当前儿童,当前量表 是否有未完成的测试 selectedChildId tableAlias
async checkRecord() {
const res = await this.$myRequest({
url: '/system/record/listByUserId',
data: {
childrenId: this.selectedChildId,
tableType: this.tableAlias
}
})
try{
if (!uni.$u.test.isEmpty(res.data.data)&&res.data.data[0].recordId) {
uni.showModal({
content: '您有一份问卷测评未做完,是否继续?\n 时间:' + res.data.data[0].createTime.replace('T', ' ')
.replace('.000+08:00', ' '),
cancelText: '重新测评',
cancelColor: '#FF0000',
confirmText: '继续测评',
success: (resModal) => {
if (resModal.confirm) {
this.loadUnOverAnswer(res.data.data[0].answer)
this.recordId = res.data.data[0].recordId
this.timeUse = res.data.data[0].timeUse
this.timeUseStart()
} else {
this.delUnOverAnswer(res.data.data[0].recordId)
this.addRecord()
}
}
})
} else {
uni.showLoading()
this.addRecord()
}
}catch(err){
uni.showLoading()
this.addRecord()
}
},
// 重新测评 删除历史测评记录
async delUnOverAnswer(recordId) {
const res = await this.$myRequest({
url: '/system/record/delUnOverAnswer/' + recordId,
method: 'DELETE'
})
},
// 增加测评记录
async addRecord() {
const res = await this.$myRequest({
url: '/system/record',
method: 'POST',
data: {
childrenId: this.selectedChildId,
tableType: this.tableAlias,
scanDeptId: this.deptId
}
})
this.recordId = res.data.data
this.timeUseStart()
uni.hideLoading()
},
// 加载历史测评记录
async loadUnOverAnswer(answer) {
try{
this.selectedAnswer = JSON.parse(answer); // 已填写的答案列表
this.currentQuestionlistorder = this.selectedAnswer[this.selectedAnswer.length - 1].listorder + 1;
}catch(err){
console.log(err,405);
this.selectedAnswer =[]
this.currentQuestionlistorder = 1
}
},
// 根据年龄 加载不同的题
async ageHandle() {
const resChild = await this.$myRequest({
url: '/system/children/userChildrenById/' + this.selectedChildId,
})
let age = this.getCurrentAgeByBirthDate(resChild.data.data.birthday);
this.table.questionInfo.splice(this.table.questionInfo.findIndex((item) => {
return age >= 10 ? item.questionType == 'kid' : item.questionType == 'boy';
}), 1)
},
// 跳转下一题
toNext(listorder) {
// 查找该题是否已被选择
let find = this.selectedAnswer.findIndex((item) => {
return item.listorder == listorder;
})
if (find == -1) {
return uni.showToast({
icon: 'error',
title: '请选择答案'
})
}
this.currentQuestionlistorder++;
},
// 选择 选项 ABCD
changeOption(questionId, e, listorder) {
let label = "";
if (this.tableAlias == 'table2') {
if (e.detail.value == "A") {
label = "总是"
} else if (e.detail.value == "B") {
label = "经常"
} else if (e.detail.value == "C") {
label = "有时"
} else if (e.detail.value == "D") {
label = "偶尔"
} else if (e.detail.value == "E") {
label = "从不"
}
} else if (this.tableAlias == 'table3') {
if (e.detail.value == "A") {
label = "完全同意"
} else if (e.detail.value == "B") {
label = "少许同意"
} else if (e.detail.value == "C") {
label = "少许不同意"
} else if (e.detail.value == "D") {
label = "完全不同意"
}
}
let oneOption = {
questionId,
qustionOption: e.detail.value,
listorder,
score: []
};
if (label) {
oneOption.optionLabel = label
}
// table2 3 获取分数
if (this.tableAlias != 'table1') {
let findScoreRow = this.table.questionInfo.find((item) => {
return item.id == questionId
})
let score = findScoreRow['option' + e.detail.value]
oneOption.score = score
}
let findIndex = this.selectedAnswer.findIndex((item) => {
return item.questionId == questionId;
});
if (findIndex == -1) {
this.selectedAnswer.push(oneOption);
} else {
this.selectedAnswer[findIndex].qustionOption = e.detail.value;
if (this.tableAlias != 'table1') {
this.selectedAnswer[findIndex].score = oneOption.score;
this.selectedAnswer[findIndex].optionLabel = label;
}
};
this.updateRecord(this.selectedAnswer)
},
/**
* 选择 程度/分 0-6
* @param questionId 问题id
* @param e 程度分数
* @param option 选项 字符串
* @param listorder 顺序号
*/
selectAssess(questionId, e, option, listorder) {
let label = "";
if (e.detail.value == "0") {
label = "从不"
} else if (e.detail.value == "1") {
label = "极少"
} else if (e.detail.value == "2") {
label = "较少"
} else if (e.detail.value == "3") {
label = "有时"
} else if (e.detail.value == "4") {
label = "经常"
} else if (e.detail.value == "5") {
label = "频繁"
} else if (e.detail.value == "6") {
label = "总是"
}
let oneAnswer = {
questionId,
score: [{
option,
optionScore: e.detail.value,
optionLabel: label
}],
listorder
};
// 两次查找 首选判断已选答案中是否有这个题,无 新增,有进入二次判断
let findQuestionIndex = this.selectedAnswer.findIndex(item => {
return item.questionId == questionId
})
if (findQuestionIndex == -1) {
this.selectedAnswer.push(oneAnswer)
} else {
// 判断这个题的回答中,是否有这个程度,有的话说明是切换,对分数替换;没有的话新增
let findOptionIndex = this.selectedAnswer[findQuestionIndex].score.findIndex(item => {
return item.option == option
})
if (findOptionIndex == -1) {
this.selectedAnswer[findQuestionIndex].score.push({
option,
optionScore: e.detail.value,
optionLabel: label
})
} else {
this.selectedAnswer[findQuestionIndex].score[findOptionIndex].optionScore = e.detail.value
this.selectedAnswer[findQuestionIndex].score[findOptionIndex].optionLabel = label
}
}
this.updateRecord(this.selectedAnswer)
},
// 完成测评 提交答案
submit() {
this.loading = true;
if(!this.selectedAnswer){
this.selectedAnswer = uni.getStorageSync('selectedAnswer')
this.loading = false;
return uni.showToast({
icon: 'error',
title: '出现异常,请检查作答并重新提交'
})
}
if (this.selectedAnswer.length == 0) {
this.loading = false;
return uni.showToast({
icon: 'error',
title: '请填写问卷'
})
}
if (this.selectedAnswer.length != this.table.questionInfo.length) {
this.loading = false;
return uni.showToast({
icon: 'error',
title: '尚有问题未做选择'
})
}
for (let i = 0; i < this.selectedAnswer.length; i++) {
if (uni.$u.test.isEmpty(this.selectedAnswer[i].qustionOption)) {
this.loading = false;
return uni.showToast({
icon: 'error',
title: '第' + (i + 1) + '题目,未选择 条目'
})
}
}
if (this.tableAlias == 'table1') {
for (let i = 0; i < this.selectedAnswer.length; i++) {
if (this.selectedAnswer[i].score.length != 4) {
this.loading = false;
return uni.showToast({
icon: 'error',
title: '第' + (i + 1) + '题目,未选择 答案'
})
}
}
}
this.updateRecord(this.selectedAnswer, 1).then(() => {
uni.redirectTo({
url: `/tablePackage/pages/testRecord?recordId=${this.recordId}`
})
this.loading = false;
})
},
getOptionIndex(questionId, option) {
let questionRow = this.table.questionInfo.find(item => {
return item.id == questionId
})
let optionIndex = option + 'Index';
return questionRow[optionIndex]
},
// 更新测评记录 isOver==1 结束
async updateRecord(answer, isOver) {
// 结束生成 报告指标分布 reportData 总分数 totalScore
if (isOver == 1) {
if (this.tableAlias == 'table1') {
answer.forEach(item => {
item.score.forEach(s => {
s.optionIndex = this.getOptionIndex(item.questionId, s.option);
})
})
let groups = {}
answer.forEach(item => {
if (item.questionId != 6 && item.questionId != 11) {
// 过滤掉量表1的 混淆题
item.score.forEach((s => {
let value = s['optionIndex'];
groups[value] = groups[value] || [];
groups[value].push(s)
}))
}
})
// 报告指标分布 reportData
var reportData = [];
for (let key in groups) {
let totalScore = countTotalScore(groups[key]);
reportData.push({
optionIndex: key,
score: totalScore
})
}
function countTotalScore(arr) {
let total = 0;
for (let i = 0; i < arr.length; i++) {
total += parseInt(arr[i].optionScore)
}
return total
}
} else {
// 用户答案与指标结合成新数组
for (let i = 0; i < answer.length; i++) {
for (let j = 0; j < this.table.questionInfo.length; j++) {
if (answer[i].questionId == this.table.questionInfo[j].id) {
let optionIndex = 'option' + answer[i].qustionOption + 'Index';
answer[i].optionIndex = this.table.questionInfo[j][optionIndex]
}
}
}
// 对结果按指标分组 并过滤掉混淆题 形成 groups 对象
let groups = {}
answer.forEach(item => {
// 过滤掉量表1的 混淆题
if (!item['optionIndex'] || item['optionIndex'] == '') {
return
}
let value = item['optionIndex'];
groups[value] = groups[value] || [];
groups[value].push(item)
})
// 报告指标分布 reportData
var reportData = [];
for (let key in groups) {
let totalScore = this.countTotalScore(groups[key]);
reportData.push({
optionIndex: key,
score: totalScore
})
}
}
// 排序 按指标分数高低
reportData = this.compareFN(reportData, "score")
// 总分数 totalScore
var totalScore = 0;
for (let i = 0; i < reportData.length; i++) {
totalScore += reportData[i].score
}
// 报告结果 reportResult
var reportResult = '';
if (this.tableAlias == 'table1') {
// 判断无效报告
// 1、|情景1选项A得分-混淆题选项C得分|+|情景1选项B得分-混淆题选项D得分|+|情景1选项C得分-混淆题选项B得分|+|情景1选项D得分-混淆题选项A得分|>2
// 2、所有题目选项得分相同呈现无效报告
// 3、所有题目选项得分全部>=5或所有题目选项得分全部<=1呈现无效报告
if (Math.abs(parseInt(answer[0].score[0].optionScore) - parseInt(answer[5].score[2]
.optionScore)) +
Math.abs(parseInt(answer[0].score[1].optionScore) - parseInt(answer[5].score[3]
.optionScore)) +
Math.abs(parseInt(answer[0].score[2].optionScore) - parseInt(answer[5].score[1]
.optionScore)) +
Math.abs(parseInt(answer[0].score[3].optionScore) - parseInt(answer[5].score[0]
.optionScore)) > 24) {
reportResult = "无效类型"
} else if (isAllEqual(answer)) {
reportResult = "无效类型"
} else if (isAllGe5(answer)) {
reportResult = "无效类型"
} else if (isAllLe1(answer)) {
reportResult = "无效类型"
} else if (reportData[0].score == reportData[1].score &&
reportData[0].score == reportData[2].score) {
reportResult = "无效类型"
} else {
reportResult = this.createReportResult(this.tableAlias, reportData, totalScore)
}
} else {
reportResult = this.createReportResult(this.tableAlias, reportData, totalScore)
}
function isAllEqual(array) {
let newArr = [];
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array[i].score.length; j++) {
newArr.push(array[i].score[j].optionScore)
}
}
if (newArr.length > 0) {
return !newArr.some(function(value, index) {
return value !== newArr[0];
});
} else {
return true;
}
}
function isAllGe5(array) {
let newArr = [];
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array[i].score.length; j++) {
newArr.push(array[i].score[j].optionScore)
}
}
if (newArr.length > 0) {
return newArr.every(function(value, index) {
return parseInt(value) >= 5;
});
} else {
return false;
}
}
function isAllLe1(array) {
let newArr = [];
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array[i].score.length; j++) {
newArr.push(array[i].score[j].optionScore)
}
}
if (newArr.length > 0) {
return newArr.every(function(value, index) {
return parseInt(value) <= 1;
});
} else {
return false;
}
}
}
answer = JSON.stringify(answer);
reportData = reportData ? JSON.stringify(reportData) : '{}';
const res = await this.$myRequest({
url: '/system/record',
method: 'PUT',
data: {
recordId: this.recordId,
answer,
isOver,
reportData,
totalScore,
reportResult,
timeUse: this.timeUse
}
})
if (res.data.code == 200) {
}
},
// 分类求和
countTotalScore(arr) {
let total = 0;
for (var i = 0; i < arr.length; i++) {
total += parseInt(arr[i].score)
}
return total
},
// 计算指标
compareFN(arr, property) {
var i = 0;
var j = 0;
let t;
for (i = 0; i < arr.length; i++) {
for (j = 0; j < arr.length; j++) {
if (arr[i][property] > arr[j][property]) {
t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
}
}
return arr
},
// 量表1 判断结果
createReportResult(tableAlias, reportData, totalScore) {
let reportResult = "";
if (tableAlias == 'table1') {
// 第一项指标分数最高时,结果就是第一项
if (reportData[0].score > reportData[1].score) {
switch (reportData[0].optionIndex) {
case "主动":
reportResult = "主动但怪异型";
break;
case "冷漠":
reportResult = "冷漠型";
break;
case "被动":
reportResult = "被动型";
break;
case "正常":
reportResult = "正常型";
break;
default:
break;
}
}
// 第一项指标分数和第二项指标分数相同时,结果就是第一项+第二项组合 !!只有三种组合
// if (reportData[0].score == reportData[1].score) {
// if ((reportData[0].optionIndex == "主动" && reportData[1].optionIndex == "正常") || (
// reportData[0]
// .optionIndex == "正常" && reportData[1].optionIndex == "主动")) {
// reportResult = "主动但怪异型或正常型"
// }
// if ((reportData[0].optionIndex == "主动" && reportData[1].optionIndex == "被动") || (
// reportData[0]
// .optionIndex == "被动" && reportData[1].optionIndex == "主动")) {
// reportResult = "主动但怪异型或被动型"
// }
// if ((reportData[0].optionIndex == "冷漠" && reportData[1].optionIndex == "被动") || (
// reportData[0]
// .optionIndex == "被动" && reportData[1].optionIndex == "冷漠")) {
// reportResult = "冷漠或被动型"
// }
// }
//
// 第一项指标分数和第二项指标分数相同时,结果就是第一项+第二项组合 !!只有三种组合
if (reportData[0].score == reportData[1].score) {
if ((reportData[0].optionIndex == "主动" && reportData[1].optionIndex == "正常") || (
reportData[0]
.optionIndex == "正常" && reportData[1].optionIndex == "主动")) {
reportResult = "主动但怪异型或正常型"
} else if ((reportData[0].optionIndex == "主动" && reportData[1].optionIndex == "被动") || (
reportData[0]
.optionIndex == "被动" && reportData[1].optionIndex == "主动")) {
reportResult = "主动但怪异型或被动型"
} else if ((reportData[0].optionIndex == "主动" && reportData[1].optionIndex == "冷漠") || (
reportData[0]
.optionIndex == "冷漠" && reportData[1].optionIndex == "主动")) {
reportResult = "主动但怪异型或冷漠型"
} else if ((reportData[0].optionIndex == "冷漠" && reportData[1].optionIndex == "被动") || (
reportData[0]
.optionIndex == "被动" && reportData[1].optionIndex == "冷漠")) {
reportResult = "冷漠型或被动型"
} else if ((reportData[0].optionIndex == "冷漠" && reportData[1].optionIndex == "正常") || (
reportData[0]
.optionIndex == "正常" && reportData[1].optionIndex == "冷漠")) {
reportResult = "冷漠型或正常型"
} else if ((reportData[0].optionIndex == "被动" && reportData[1].optionIndex == "正常") || (
reportData[0]
.optionIndex == "正常" && reportData[1].optionIndex == "被动")) {
reportResult = "被动型或正常型"
} else {
reportResult = "无效类型"
}
}
}
if (tableAlias == 'table2') {
reportResult = totalScore > 53 ? `需要警惕` : '正常范围内'
}
if (tableAlias == 'table3') {
reportResult = totalScore > 26 ? `需要警惕` : '正常范围内'
}
return reportResult;
},
// 生日 to 周岁
getCurrentAgeByBirthDate(strBirthday) {
const strBirthdayArr = strBirthday.split("-")
const birthYear = strBirthdayArr[0]
const birthMonth = strBirthdayArr[1]
const birthDay = strBirthdayArr[2]
const d = new Date()
const nowYear = d.getFullYear()
const nowMonth = d.getMonth() + 1
const nowDay = d.getDate()
if (nowYear === birthYear) return 0
const ageDiff = nowYear - birthYear;
if (ageDiff < 0) return -1
if (nowMonth !== birthMonth) {
const monthDiff = nowMonth - birthMonth;
return monthDiff < 0 ? ageDiff - 1 : ageDiff
}
const dayDiff = nowDay - birthDay;
return dayDiff < 0 ? ageDiff - 1 : ageDiff
}
},
computed: {
selected() {
this.selectedAnswer = this.selectedAnswer || [];
return (questionId, qustionOption) => {
let findIndex = this.selectedAnswer.findIndex((item) => {
return item.questionId == questionId && item.qustionOption == qustionOption;
});
return findIndex != -1 ? 'selected' : 'sss'
}
},
getOptionChecked() {
this.selectedAnswer = this.selectedAnswer || [];
return (questionId, qustionOption) => {
let qustionOptionIndex = this.selectedAnswer.findIndex((item) => {
return item.questionId == questionId && item.qustionOption == qustionOption;
});
return qustionOptionIndex != -1 ? true : false
}
},
getScoreChecked() {
this.selectedAnswer = this.selectedAnswer || [];
//this.selectedAnswer.score = this.selectedAnswer.score || [];
return (questionId, score, option) => {
let questionIndex = this.selectedAnswer.findIndex((item) => {
return item.questionId == questionId
});
if (questionIndex != -1) {
if (!this.selectedAnswer[questionIndex].score) {
return false
}
let scoreIndex = this.selectedAnswer[questionIndex].score.findIndex((item) => {
return item.optionScore == score && item.option == option
});
return questionIndex != -1 && scoreIndex != -1 ? true : false
} else {
return false
}
}
}
},
}
</script>
<style lang="less">
.content {
.header {
width: 100%;
image {
width: 100%;
}
}
.ques-con {
text-align: left;
width: 92%;
margin: 0 auto;
margin-top: -20rpx;
line-height: 40rpx;
border-radius: 20rpx;
background-color: rgba(255, 255, 255, 1);
text-align: center;
border: 5px solid rgba(40, 123, 206, 1);
padding: 40rpx;
image {
width: 80rpx;
height: 80rpx;
float: right;
}
.ques-title-con {
display: flex;
align-items: center;
}
.ques-title {
font-size: 16px;
font-weight: bold;
padding-top: 5px;
text-align: left;
margin-top: 10rpx;
margin-bottom: 10rpx;
}
.ques-num {
margin-right: 10rpx;
display: flex;
align-items: center;
}
.current-num {
color: rgba(16, 16, 16, 1);
font-size: 33rpx;
text-align: left;
font-weight: 600;
}
.all-num {
color: rgba(16, 16, 16, 1);
font-size: 25rpx;
text-align: left;
}
.ques-answer-con {
.one-answer {
padding: 20rpx 40rpx;
margin-top: 20rpx;
border-radius: 52rpx;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
font-size: 32rpx;
text-align: left;
font-family: Arial;
border: 2px solid rgba(187, 187, 187, 1);
&.selected {
background-color: rgba(40, 123, 206, 1);
color: #fff;
border: 2px solid rgba(40, 123, 206, 1);
}
}
.answer {
text-align: left;
.answer-option {
font-weight: bold;
margin-top: 20rpx;
}
.answer-text {
// font-weight: ;
margin: 20rpx 0;
}
.assess-list {
display: flex;
.one-assess {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
width: 100rpx;
font-size: 24rpx;
padding: 6rpx;
border: 1px solid #ddd;
}
.one-assess:nth-child(2n) {
// background-color: #eee;
border-left: none;
border-right: none;
}
}
}
.tip {
margin: 20rpx 0rpx;
font-size: 28rpx;
text-align: left;
}
.option-con {
display: flex;
justify-content: space-around;
align-items: center;
margin: 20rpx 0;
.option-label {
display: flex;
align-items: center;
}
.one-radio {
margin-left: 10rpx;
}
}
}
}
.bottom {
display: flex;
justify-content: center;
margin-top: 50rpx;
.btn {
width: 700rpx;
height: 100rpx;
border-radius: 50rpx;
background-color: rgba(40, 123, 206, 1);
color: rgba(255, 255, 255, 1);
font-size: 14px;
text-align: center;
line-height: 100rpx;
margin-bottom: 50rpx;
}
}
}
.tip {
margin: 20rpx 0rpx;
font-size: 30rpx;
text-align: left;
}
.option-con-table2 {
display: flex;
flex-direction: column;
}
/deep/ .uni-radio-input {
margin-right: 0 !important;
}
</style>