feat: 自主项目编辑BUG

This commit is contained in:
cgd_mac 2021-12-24 10:57:05 +08:00
parent 4311ece0f4
commit 1e1970327b
1 changed files with 51 additions and 43 deletions

View File

@ -35,7 +35,13 @@
</a-row>
<a-card :bordered="false" title="组卷策略详情">
<a-table :columns="columns" :data-source="tableData" bordered :position="{ disabled: false }" :pagination="false">
<a-table
:columns="columns"
:data-source="tableData"
bordered
:position="{ disabled: false }"
:pagination="false"
>
<template slot="topicNum" slot-scope="text, record">
<a-input-number style="margin: -5px 0" v-model="record.topicNum" :min="0" :max="record.totalNum" />
</template>
@ -43,10 +49,10 @@
<a-input-number style="margin: -5px 0" v-model="record.topicScore" :min="0" />
</template>
<template slot="totalScore" slot-scope="text, record">
<p>{{record.topicScore}}</p>
<p>{{ record.topicScore }}</p>
</template>
<template slot="footer" :style="{ float:'left' }">
<p class="right">总分数{{form.totalScore}} </p>
<template slot="footer" :style="{ float: 'left' }">
<p class="right">总分数{{ form.totalScore }} </p>
</template>
</a-table>
</a-card>
@ -69,8 +75,8 @@ export default {
components: {},
props: {
projectForm: {
type: Object,
},
type: Object
}
},
data() {
//
@ -85,7 +91,7 @@ export default {
projectName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
trainClass: [{ required: true, message: '请选择培训分类', trigger: 'blur' }],
projectName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
trainClass: [{ required: true, message: '请选择培训分类', trigger: 'blur' }],
trainClass: [{ required: true, message: '请选择培训分类', trigger: 'blur' }]
},
columns: [
{ title: '序号', key: 'i', dataIndex: 'i', width: 70, scopedSlots: { customRender: 'serial' } },
@ -99,7 +105,7 @@ export default {
if (text == 3) return '判断题'
if (text == 4) return '简答题'
if (text == 5) return '填空题'
},
}
},
{ title: '总题量', dataIndex: 'totalNum', key: 'totalNum' },
{
@ -107,54 +113,55 @@ export default {
dataIndex: 'topicNum',
width: 100,
key: 'topicNum',
scopedSlots: { customRender: 'topicNum' },
scopedSlots: { customRender: 'topicNum' }
},
{
title: '单题分值',
dataIndex: 'topicScore',
width: 100,
key: 'topicScore',
scopedSlots: { customRender: 'topicScore' },
scopedSlots: { customRender: 'topicScore' }
},
{
title: '总分',
dataIndex: 'totalScore',
key: 'total',
customRender: (value, row, index) => {
if (!row.topicNum || !row.topicScore) return '';
return (row.topicNum * row.topicScore) + '分'
},
},
if (!row.topicNum || !row.topicScore) return ''
return row.topicNum * row.topicScore + '分'
}
}
],
tableData: [],
totalScore: 0,
tableData: [],
totalScore: 0
}
},
// data
computed: {},
// data
watch: {
tableData: function () {
let sum = 0;
tableData: function() {
let sum = 0
this.tableData.forEach(element => {
if(element.totalScore){
console.log('单条总分数',element.totalScore)
sum = sum + element.totalScore;
if (element.totalScore) {
console.log('单条总分数', element.totalScore)
sum = sum + element.totalScore
}
});
this.form.totalScore = sum;
})
this.form.totalScore = sum
}
},
//
methods: {
//
toSave() {
this.form.testPaperTactics = this.tableData;
this.form.testPaperTactics = { ...this.tableData }
this.form.projectStatus = 1
this.$emit('executeSave', this.form)
},
//
toIssue() {
this.form.testPaperTactics = this.tableData;
this.form.testPaperTactics = { ...this.tableData }
this.form.projectStatus = 2
this.$emit('executeIssue', this.form)
},
@ -163,17 +170,18 @@ export default {
this.$emit('prevStep', this.form)
},
initTable() {
let ids = this.form.lessonIds.map((t) => {
return parseInt(t.ids);
let ids = this.form.lessonIds.map(t => {
return parseInt(t.ids)
})
getQuestionNumByCourseIds({ ids: ids }).then((res) => {
getQuestionNumByCourseIds({ ids: ids }).then(res => {
this.tableData = res.data
if(this.tableData && this.form.testPaperTactics){
this.tableData.forEach(t1 => {
if (this.tableData && this.form.testPaperTactics) {
this.tableData.forEach((t1, t1Index) => {
this.form.testPaperTactics.forEach(t2 => {
if(t1.topicType === t2.topicType){
t1.topicNum = t2.topicNum
t1.topicScore = t2.topicScore
if (t1.topicType === t2.topicType) {
this.$set(this.tableData[t1Index], 'topicNum', t2.topicNum)
this.$set(this.tableData[t1Index], 'topicScore', t2.topicScore)
}
})
})
@ -183,24 +191,24 @@ export default {
},
// - 访this
created() {
this.initTable();
this.initTable()
},
// - 访DOM
mounted() { },
mounted() {},
// -
beforeCreate() { },
beforeCreate() {},
// -
beforeMount() { },
beforeMount() {},
// -
beforeUpdate() { },
beforeUpdate() {},
// -
updated() { },
updated() {},
// -
beforeDestroy() { },
beforeDestroy() {},
// -
destroyed() { },
destroyed() {},
// keep-alive
activated() {},
activated() {}
}
</script>
<style scoped>