Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
闫晓茹 2024-03-06 15:15:12 +08:00
commit fcd6ffbf88
3 changed files with 119 additions and 28 deletions

View File

@ -20,7 +20,7 @@ export function getQuestion(id) {
// 新增问卷基本信息 // 新增问卷基本信息
export function addQuestion(data) { export function addQuestion(data) {
return request({ return request({
url: '/system/question', url: '/system/question/add',
method: 'post', method: 'post',
data: data data: data
}) })
@ -29,8 +29,8 @@ export function addQuestion(data) {
// 修改问卷基本信息 // 修改问卷基本信息
export function updateQuestion(data) { export function updateQuestion(data) {
return request({ return request({
url: '/system/question', url: '/system/question/edit',
method: 'put', method: 'post',
data: data data: data
}) })
} }

View File

@ -151,7 +151,7 @@
<div class="options"> <div class="options">
<span>选项 </span> <span>选项 </span>
<div> <div>
<el-select v-model="item.optionNumber" placeholder="请选择" <el-select v-model="item.optionCount" placeholder="请选择"
@change="selectchange($event, item)" style="padding-left:10px"> @change="selectchange($event, item)" style="padding-left:10px">
<el-option v-for="item in optionlist" :key="item.value" <el-option v-for="item in optionlist" :key="item.value"
:label="item.label" :value="item.value"> :label="item.label" :value="item.value">
@ -161,11 +161,11 @@
</div> </div>
<div class="more"> <div class="more">
<el-radio-group> <el-radio-group>
<el-radio :label="1" disabled v-if="item.optionNumber > 0">1</el-radio> <el-radio :label="1" disabled v-if="item.optionCount > 0">1</el-radio>
<el-radio :label="2" disabled v-if="item.optionNumber > 1">2</el-radio> <el-radio :label="2" disabled v-if="item.optionCount > 1">2</el-radio>
<el-radio :label="3" disabled v-if="item.optionNumber > 2">3</el-radio> <el-radio :label="3" disabled v-if="item.optionCount > 2">3</el-radio>
<el-radio :label="4" disabled v-if="item.optionNumber > 3">4</el-radio> <el-radio :label="4" disabled v-if="item.optionCount > 3">4</el-radio>
<el-radio :label="5" disabled v-if="item.optionNumber > 4">5</el-radio> <el-radio :label="5" disabled v-if="item.optionCount > 4">5</el-radio>
</el-radio-group> </el-radio-group>
</div> </div>
</div> </div>
@ -237,7 +237,7 @@
<span>选项 </span> <span>选项 </span>
<div> <div>
<div v-for="(uitem, uindex) in aitem.questionSubjectOptionList" <div v-for="(uitem, uindex) in aitem.questionSubjectOptionList"
:key="uindex" style="display:flex"> :key="uindex" style="display:flex;margin-bottom:10px">
<el-input placeholder="请输入内容" v-model="uitem.optionName" <el-input placeholder="请输入内容" v-model="uitem.optionName"
clearable> clearable>
</el-input> </el-input>
@ -311,7 +311,7 @@
<div class="options"> <div class="options">
<span>选项 </span> <span>选项 </span>
<div> <div>
<el-select v-model="aitem.optionNumber" placeholder="请选择" <el-select v-model="aitem.optionCount" placeholder="请选择"
@change="selectchange($event, aitem)" style="padding-left:10px"> @change="selectchange($event, aitem)" style="padding-left:10px">
<el-option v-for="yitem in optionlist" :key="yitem.value" <el-option v-for="yitem in optionlist" :key="yitem.value"
:label="yitem.label" :value="yitem.value"> :label="yitem.label" :value="yitem.value">
@ -322,15 +322,15 @@
<div class="more"> <div class="more">
<el-radio-group> <el-radio-group>
<el-radio :label="1" disabled <el-radio :label="1" disabled
v-if="aitem.optionNumber > 0">1</el-radio> v-if="aitem.optionCount > 0">1</el-radio>
<el-radio :label="2" disabled <el-radio :label="2" disabled
v-if="aitem.optionNumber > 1">2</el-radio> v-if="aitem.optionCount > 1">2</el-radio>
<el-radio :label="3" disabled <el-radio :label="3" disabled
v-if="aitem.optionNumber > 2">3</el-radio> v-if="aitem.optionCount > 2">3</el-radio>
<el-radio :label="4" disabled <el-radio :label="4" disabled
v-if="aitem.optionNumber > 3">4</el-radio> v-if="aitem.optionCount > 3">4</el-radio>
<el-radio :label="5" disabled <el-radio :label="5" disabled
v-if="aitem.optionNumber > 4">5</el-radio> v-if="aitem.optionCount > 4">5</el-radio>
</el-radio-group> </el-radio-group>
</div> </div>
</div> </div>
@ -384,7 +384,7 @@
</div> </div>
<div class="totalScore"> <div class="totalScore">
<div class="totalscore-title"> <div class="totalscore-title">
总分0 总分{{ questionnaireTotalScore }}
</div> </div>
<div class="totalscore-title" style="font-size:14px"> <div class="totalscore-title" style="font-size:14px">
Q{{ questionitem.index + 1 }} Q{{ questionitem.index + 1 }}
@ -443,7 +443,7 @@
</template> </template>
<script> <script>
import { getQuestion } from "@/api/system/question"; import { getQuestion, addQuestion, updateQuestion } from "@/api/system/question";
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
export default { export default {
name: "addQuestionnaire", name: "addQuestionnaire",
@ -514,7 +514,7 @@ export default {
list: { list: {
questionnaireName: undefined, questionnaireName: undefined,
questionnaireDescription: undefined, questionnaireDescription: undefined,
questionnaireTotalScore: undefined, // questionnaireTotalScore: 0, //
questionSubjectList: [], questionSubjectList: [],
}, },
//arr //arr
@ -545,15 +545,45 @@ export default {
watch: { watch: {
}, },
created() { created() {
if(this.$route.query.id){ if (this.$route.query.id) {
this.info(); this.info();
} }
}, },
computed: {
questionnaireTotalScore: function () {
var score = 0
this.questionlist.forEach(e => {
if (!e.list) {
if (e.questionSubjectOptionList.length > 0) {
e.questionScore = e.questionSubjectOptionList[0].optionScore
e.questionSubjectOptionList.forEach(el => {
if (el.optionScore > e.questionScore) {
e.questionScore = el.optionScore
}
})
score += e.questionScore
}
} else {
e.list.forEach(el => {
el.questionScore = el.questionSubjectOptionList[0].optionScore
el.questionSubjectOptionList.forEach(ele => {
if (ele.optionScore > el.questionScore) {
el.questionScore = ele.optionScore
}
})
score += el.questionScore
})
}
})
this.list.questionnaireTotalScore = score
return score
},
},
methods: { methods: {
addquestion(item) { addquestion(item) {
this.id++ this.id++
if (this.questionlist.length > 0) { if (this.questionlist.length > 0) {
if (this.questionlist[this.questionlist.length - 1].questionName == '') { if (this.questionlist[this.questionlist.length - 1].questionName == '' || this.questionlist[this.questionlist.length - 1].questionDescription == '') {
return this.$message.error('请填写完在继续添加'); return this.$message.error('请填写完在继续添加');
} }
} }
@ -569,7 +599,6 @@ export default {
disabled: false, disabled: false,
// //
scoringMethod: '', scoringMethod: '',
optionCount: 0, //
questionSubjectOptionList: [{ questionSubjectOptionList: [{
optionid: ++this.optionid, optionid: ++this.optionid,
optionName: '', optionName: '',
@ -640,6 +669,7 @@ export default {
// //
whetherScore: false, whetherScore: false,
disabled: false, disabled: false,
optionCount: '',
// //
scoringMethod: '', scoringMethod: '',
questionSubjectOptionList: [], questionSubjectOptionList: [],
@ -828,7 +858,7 @@ export default {
id: this.id++, id: this.id++,
questionName: '', questionName: '',
questionDescription: '', questionDescription: '',
optionNumber: '', optionCount: '',
title: '打分题', title: '打分题',
// //
whetherScore: false, whetherScore: false,
@ -840,7 +870,7 @@ export default {
questionType: 'COMBINATION_SCORING_SUBJECT', questionType: 'COMBINATION_SCORING_SUBJECT',
id: this.id++, id: this.id++,
questionDescription: '', questionDescription: '',
optionNumber: '', optionCount: '',
questionName: '', questionName: '',
title: '打分题', title: '打分题',
// //
@ -861,7 +891,6 @@ export default {
title: '日期填空题', title: '日期填空题',
// //
whetherScore: false, whetherScore: false,
optionCount: 0, //
disabled: true, disabled: true,
}) })
} else if (item.id == 'TIME_BLANKS_SUBJECT') { } else if (item.id == 'TIME_BLANKS_SUBJECT') {
@ -872,7 +901,6 @@ export default {
questionName: '', questionName: '',
title: '时间填空题', title: '时间填空题',
// //
optionCount: 0, //
whetherScore: false, whetherScore: false,
disabled: true, disabled: true,
}) })
@ -991,11 +1019,71 @@ export default {
this.list.questionSubjectList.push(e) this.list.questionSubjectList.push(e)
} }
}) })
console.log(this.list) this.list.questionSubjectList.forEach(e => {
e.questionNumber = Number(e.questionNumber)
e.questionSubjectOptionList.forEach(el => {
el.questionNumber = Number(el.questionNumber)
})
})
this.list.questionCount = this.questionlist.length
if (this.$route.query.id) {
updateQuestion(this.list).then(res => {
})
} else {
addQuestion(this.list).then(res => {
})
}
}, },
info() { info() {
getQuestion(this.$route.query.id).then(res => { getQuestion(this.$route.query.id).then(res => {
this.list = res.data
res.data.questionSubjectList.forEach(e => {
if (e.questionType == 'MULTIPLE_CHOICE') {
e.title = '单选题'
this.questionlist.push(e)
} else if (e.questionType == 'MULTIPLE_CHOICE_QUESTIONS') {
e.title = '多选题'
this.questionlist.push(e)
} else if (e.questionType == 'FILL_IN_THE_BLANKS') {
e.title = '填空题'
this.questionlist.push(e)
} else if (e.questionType == 'SCORING_QUESTIONS') {
e.title = '打分题'
this.questionlist.push(e)
} else if (e.questionType == 'DATE_BLANKS_SUBJECT') {
e.title = '日期填空题'
this.questionlist.push(e)
} else if (e.questionType == 'TIME_BLANKS_SUBJECT') {
e.title = '时间填空题'
this.questionlist.push(e)
} else if (e.questionType == 'COMBINATION_RADIO_SUBJECT') {
e.title = '单选题'
} else if (e.questionType == 'COMBINATION_MULTIPLE_SUBJECT') {
e.title = '多选题'
} else if (e.questionType == 'COMBINATION_BLANKS_SUBJECT') {
e.title = '填空题'
} else if (e.questionType == 'COMBINATION_SCORING_SUBJECT') {
e.title = '打分题'
}
})
var data = res.data.questionSubjectList
var echararr = [];
for (var i = 0; i < data.length; i++) {
var arrindex = echararr.findIndex((item, index, arr) => { return item.questionDescription === data[i].questionDescription })//
if (arrindex == -1) {//
echararr.push({
title: data[i].questionType == 'COMBINATION_RADIO_SUBJECT' ? '组合单选题' : data[i].questionType == 'COMBINATION_MULTIPLE_SUBJECT' ? '组合多选题' : data[i].questionType == 'COMBINATION_BLANKS_SUBJECT' ? '组合填空题' : data[i].questionType == 'COMBINATION_SCORING_SUBJECT' ? '组合打分题' : '',
questionType: data[i].questionType,
id: this.id++,
questionDescription: data[i].questionDescription,
list: [data[i]]
});
} else {//
echararr[arrindex].list.push(data[i])
}
}
this.questionlist = [...this.questionlist, ...echararr]
}) })
}, },
} }

View File

@ -154,6 +154,9 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.$router.push({
path: "/question/addQuestionnaire",
});
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {