Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
fcd6ffbf88
@ -20,7 +20,7 @@ export function getQuestion(id) {
|
||||
// 新增问卷基本信息
|
||||
export function addQuestion(data) {
|
||||
return request({
|
||||
url: '/system/question',
|
||||
url: '/system/question/add',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -29,8 +29,8 @@ export function addQuestion(data) {
|
||||
// 修改问卷基本信息
|
||||
export function updateQuestion(data) {
|
||||
return request({
|
||||
url: '/system/question',
|
||||
method: 'put',
|
||||
url: '/system/question/edit',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
<div class="options">
|
||||
<span>选项: </span>
|
||||
<div>
|
||||
<el-select v-model="item.optionNumber" placeholder="请选择"
|
||||
<el-select v-model="item.optionCount" placeholder="请选择"
|
||||
@change="selectchange($event, item)" style="padding-left:10px">
|
||||
<el-option v-for="item in optionlist" :key="item.value"
|
||||
:label="item.label" :value="item.value">
|
||||
@ -161,11 +161,11 @@
|
||||
</div>
|
||||
<div class="more">
|
||||
<el-radio-group>
|
||||
<el-radio :label="1" disabled v-if="item.optionNumber > 0">1</el-radio>
|
||||
<el-radio :label="2" disabled v-if="item.optionNumber > 1">2</el-radio>
|
||||
<el-radio :label="3" disabled v-if="item.optionNumber > 2">3</el-radio>
|
||||
<el-radio :label="4" disabled v-if="item.optionNumber > 3">4</el-radio>
|
||||
<el-radio :label="5" disabled v-if="item.optionNumber > 4">5</el-radio>
|
||||
<el-radio :label="1" disabled v-if="item.optionCount > 0">1</el-radio>
|
||||
<el-radio :label="2" disabled v-if="item.optionCount > 1">2</el-radio>
|
||||
<el-radio :label="3" disabled v-if="item.optionCount > 2">3</el-radio>
|
||||
<el-radio :label="4" disabled v-if="item.optionCount > 3">4</el-radio>
|
||||
<el-radio :label="5" disabled v-if="item.optionCount > 4">5</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
@ -237,7 +237,7 @@
|
||||
<span>选项: </span>
|
||||
<div>
|
||||
<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"
|
||||
clearable>
|
||||
</el-input>
|
||||
@ -311,7 +311,7 @@
|
||||
<div class="options">
|
||||
<span>选项: </span>
|
||||
<div>
|
||||
<el-select v-model="aitem.optionNumber" placeholder="请选择"
|
||||
<el-select v-model="aitem.optionCount" placeholder="请选择"
|
||||
@change="selectchange($event, aitem)" style="padding-left:10px">
|
||||
<el-option v-for="yitem in optionlist" :key="yitem.value"
|
||||
:label="yitem.label" :value="yitem.value">
|
||||
@ -322,15 +322,15 @@
|
||||
<div class="more">
|
||||
<el-radio-group>
|
||||
<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
|
||||
v-if="aitem.optionNumber > 1">2</el-radio>
|
||||
v-if="aitem.optionCount > 1">2</el-radio>
|
||||
<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
|
||||
v-if="aitem.optionNumber > 3">4</el-radio>
|
||||
v-if="aitem.optionCount > 3">4</el-radio>
|
||||
<el-radio :label="5" disabled
|
||||
v-if="aitem.optionNumber > 4">5</el-radio>
|
||||
v-if="aitem.optionCount > 4">5</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
@ -384,7 +384,7 @@
|
||||
</div>
|
||||
<div class="totalScore">
|
||||
<div class="totalscore-title">
|
||||
总分:0分
|
||||
总分:{{ questionnaireTotalScore }}分
|
||||
</div>
|
||||
<div class="totalscore-title" style="font-size:14px">
|
||||
Q{{ questionitem.index + 1 }}
|
||||
@ -443,7 +443,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getQuestion } from "@/api/system/question";
|
||||
import { getQuestion, addQuestion, updateQuestion } from "@/api/system/question";
|
||||
import draggable from 'vuedraggable'
|
||||
export default {
|
||||
name: "addQuestionnaire",
|
||||
@ -514,7 +514,7 @@ export default {
|
||||
list: {
|
||||
questionnaireName: undefined,
|
||||
questionnaireDescription: undefined,
|
||||
questionnaireTotalScore: undefined, //总分
|
||||
questionnaireTotalScore: 0, //总分
|
||||
questionSubjectList: [],
|
||||
},
|
||||
//题目arr
|
||||
@ -545,15 +545,45 @@ export default {
|
||||
watch: {
|
||||
},
|
||||
created() {
|
||||
if(this.$route.query.id){
|
||||
if (this.$route.query.id) {
|
||||
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: {
|
||||
addquestion(item) {
|
||||
this.id++
|
||||
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('请填写完在继续添加');
|
||||
}
|
||||
}
|
||||
@ -569,7 +599,6 @@ export default {
|
||||
disabled: false,
|
||||
//计分方式
|
||||
scoringMethod: '',
|
||||
optionCount: 0, //选项个数
|
||||
questionSubjectOptionList: [{
|
||||
optionid: ++this.optionid,
|
||||
optionName: '',
|
||||
@ -640,6 +669,7 @@ export default {
|
||||
//是否计分
|
||||
whetherScore: false,
|
||||
disabled: false,
|
||||
optionCount: '',
|
||||
//计分方式
|
||||
scoringMethod: '',
|
||||
questionSubjectOptionList: [],
|
||||
@ -828,7 +858,7 @@ export default {
|
||||
id: this.id++,
|
||||
questionName: '',
|
||||
questionDescription: '',
|
||||
optionNumber: '',
|
||||
optionCount: '',
|
||||
title: '打分题',
|
||||
//是否计分
|
||||
whetherScore: false,
|
||||
@ -840,7 +870,7 @@ export default {
|
||||
questionType: 'COMBINATION_SCORING_SUBJECT',
|
||||
id: this.id++,
|
||||
questionDescription: '',
|
||||
optionNumber: '',
|
||||
optionCount: '',
|
||||
questionName: '',
|
||||
title: '打分题',
|
||||
//是否计分
|
||||
@ -861,7 +891,6 @@ export default {
|
||||
title: '日期填空题',
|
||||
//是否计分
|
||||
whetherScore: false,
|
||||
optionCount: 0, //选项个数
|
||||
disabled: true,
|
||||
})
|
||||
} else if (item.id == 'TIME_BLANKS_SUBJECT') {
|
||||
@ -872,7 +901,6 @@ export default {
|
||||
questionName: '',
|
||||
title: '时间填空题',
|
||||
//是否计分
|
||||
optionCount: 0, //选项个数
|
||||
whetherScore: false,
|
||||
disabled: true,
|
||||
})
|
||||
@ -991,11 +1019,71 @@ export default {
|
||||
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() {
|
||||
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]
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@ -154,6 +154,9 @@ export default {
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.$router.push({
|
||||
path: "/question/addQuestionnaire",
|
||||
});
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user