rt-sim-training-client/src/views/competitionManage/bankList/question-create-page.vue

122 lines
3.1 KiB
Vue
Raw Normal View History

2020-05-26 15:59:11 +08:00
<template>
<div class="page">
<div class="page__container">
<el-card class="page__container-body">
2022-10-13 18:14:56 +08:00
<question-form ref="info" :option="formModel" :remove="true" @modify="doModify" @companyIdChange="companyIdChange" @tagsChange="tagsChange" />
2020-05-26 15:59:11 +08:00
</el-card>
<div class="page__container-footer">
<el-button type="primary" :is-create="true" @click="create"> </el-button>
<el-button @click="back"> </el-button>
</div>
</div>
<dialog-modify-rich ref="rich" />
</div>
</template>
<script>
import QuestionForm from './question-form.vue';
import DialogModifyRich from './dialog-modify-rich';
import { createQuestion } from '@/api/questionBank.js';
import * as authUtils from '@/utils/auth.js';
export default {
components: {
QuestionForm,
DialogModifyRich
},
data() {
return {
active: 0,
formModel: {
id: '',
topic: '',
type: 'select',
2022-10-13 18:14:56 +08:00
tags: '',
answer: '',
2020-05-26 15:59:11 +08:00
optionList: []
2020-10-27 10:43:55 +08:00
},
2022-10-13 18:14:56 +08:00
companyId: null,
tagsArr: []
2020-05-26 15:59:11 +08:00
};
},
computed: {
deviceId() {
return this.$route.params.deviceId;
},
path() {
return this.$route.path;
}
},
created() {
const value = authUtils.getSessionStorage(this.path);
if (value) {
const model = JSON.parse(value);
this.formModel.type = model.type;
}
},
methods: {
doBack() {
this.$router.go(-1);
},
doModify(node) {
this.$refs.rich.doShow(node);
},
2020-10-27 10:43:55 +08:00
companyIdChange(value) {
this.companyId = value;
},
2022-10-13 18:14:56 +08:00
tagsChange(list) {
this.tagsArr = list;
},
2020-05-26 15:59:11 +08:00
create() {
this.$refs.info.validate().then(valid => {
if (valid) {
2022-10-13 18:14:56 +08:00
// this.formModel.companyId = parseInt(this.companyId);
this.formModel.tags = this.tagsArr.join(',');
2020-05-26 15:59:11 +08:00
createQuestion(this.formModel).then(resp => {
authUtils.setSessionStorage(this.path, JSON.stringify({
type: this.formModel.type
}));
this.doBack();
}).catch(error => {
this.$message.error(`创建试题失败: ${error.message}`);
});
}
}).catch(error => { this.$message.warning(error.message); });
},
back() {
this.$router.go(-1);
}
}
};
</script>
<style lang="scss" scoped>
.page {
width: 100%;
&__container {
width: 55%;
margin: auto;
padding:20px 0px;
2020-05-26 15:59:11 +08:00
&-header {
margin-bottom: 10px;
.step-group {
margin: 10px 0;
.box {
display: flex;
justify-content: flex-end;
}
}
}
&-body {
padding: 40px;
}
&-footer {
margin-top: 20px;
display: flex;
justify-content: center;
}
}
}
</style>