|
@@ -169,6 +169,21 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
+
|
|
|
+ <!-- 新增答案对话框 -->
|
|
|
+ <el-dialog :visible.sync="addAnswerDialogVisible" title="新增答案" width="30%">
|
|
|
+ <el-form :model="newAnswerForm" ref="newAnswerForm" :rules="newAnswerRules" label-width="100px">
|
|
|
+ <el-form-item label="答案" prop="answer">
|
|
|
+ <el-input v-model="newAnswerForm.answer" placeholder="请输入答案"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="handleAddAnswer">确定</el-button>
|
|
|
+ <el-button @click="addAnswerDialogVisible = false">取消</el-button>
|
|
|
+
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<!-- 审核 -->
|
|
|
<el-dialog :title="title" :visible.sync="open1" width="700px" append-to-body>
|
|
|
<el-form ref="form1" :model="form1" label-width="100px">
|
|
@@ -204,13 +219,20 @@
|
|
|
<el-form-item label="图片" prop="path">
|
|
|
<image-upload v-model="form1.path"/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="答案列表">
|
|
|
- <ul>
|
|
|
- <li v-for="(answer, index) in form1.answerList" :key="index">
|
|
|
- <p>{{ answer.answer }}</p>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </el-form-item>
|
|
|
+
|
|
|
+ <!-- 新增答案按钮 -->
|
|
|
+ <el-button type="primary" @click="addAnswerDialogVisible = true">新增答案</el-button>
|
|
|
+ <!-- 答案列表 -->
|
|
|
+ <el-form :model="form1" ref="form1" :rules="rules" label-width="100px">
|
|
|
+ <el-form-item label="答案列表">
|
|
|
+ <ul>
|
|
|
+ <li v-for="(answer, index) in form1.answerList" :key="index">
|
|
|
+ <p>{{ answer.answer }}</p>
|
|
|
+ <el-button type="danger" icon="el-icon-delete" @click="removeAnswer(index)">删除</el-button>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button v-if="form1.a == '1'" type="primary" @click="through(1)">通 过</el-button>
|
|
@@ -222,7 +244,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listQuestion, getQuestion, delQuestion, addQuestion, updateQuestion, listType,through } from "@/api/asking/question";
|
|
|
+import { listQuestion, getQuestion, delQuestion, addQuestion, updateQuestion, listType,through,addAnswer,delAnswer } from "@/api/asking/question";
|
|
|
+import {addType, updateType} from "@/api/asking/type";
|
|
|
|
|
|
export default {
|
|
|
name: "Question",
|
|
@@ -241,6 +264,8 @@ export default {
|
|
|
showSearch: true,
|
|
|
// 总条数
|
|
|
total: 0,
|
|
|
+ newAnswer: { answer: '' }, // 新增答案对象
|
|
|
+ addAnswerDialogVisible: false, // 控制新增答案对话框的显示状态
|
|
|
// 问答列-问题表格数据
|
|
|
questionList: [],
|
|
|
//类型配置
|
|
@@ -250,6 +275,7 @@ export default {
|
|
|
// 是否显示弹出层
|
|
|
open: false,
|
|
|
open1: false,
|
|
|
+ open2: false,
|
|
|
// 查询参数
|
|
|
queryParams: {
|
|
|
pageNum: 1,
|
|
@@ -268,7 +294,10 @@ export default {
|
|
|
form: {
|
|
|
whetherShow:'N'
|
|
|
},
|
|
|
- form1:{},
|
|
|
+ newAnswerForm:{},
|
|
|
+ form1:{
|
|
|
+ answerList: [], // 存放答案列表
|
|
|
+ },
|
|
|
// 表单校验
|
|
|
rules: {
|
|
|
title: [
|
|
@@ -283,7 +312,9 @@ export default {
|
|
|
score: [
|
|
|
{ required: true, message: "悬赏积分不能为空", trigger: "blur" }
|
|
|
],
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ newAnswerRules: { answer: [{ required: true, message: '请输入答案', trigger: 'blur' }] }, // 新增答案的校验规则
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -321,6 +352,7 @@ export default {
|
|
|
cancel() {
|
|
|
this.open = false;
|
|
|
this.open1 = false;
|
|
|
+ this.open2 = false;
|
|
|
this.reset();
|
|
|
},
|
|
|
// 表单重置
|
|
@@ -355,7 +387,9 @@ export default {
|
|
|
delFlag: null
|
|
|
};
|
|
|
this.resetForm("form1");
|
|
|
+
|
|
|
},
|
|
|
+
|
|
|
/** 搜索按钮操作 */
|
|
|
handleQuery() {
|
|
|
this.queryParams.pageNum = 1;
|
|
@@ -378,6 +412,20 @@ export default {
|
|
|
this.open = true;
|
|
|
this.title = "添加问答列-问题";
|
|
|
},
|
|
|
+
|
|
|
+ //新增答案
|
|
|
+ handleAddAnswer() {
|
|
|
+ this.$refs["newAnswerForm"].validate(valid => {
|
|
|
+ this.newAnswerForm.questionId = this.form1.id;
|
|
|
+ addAnswer(this.newAnswerForm).then(response => {
|
|
|
+ this.form1.answerList.push(this.newAnswerForm);
|
|
|
+ this.newAnswer.answer = ''; // 清空输入框
|
|
|
+ this.addAnswerDialogVisible = false; // 关闭新增答案对话框
|
|
|
+ this.$message.success('新增答案成功');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
this.reset();
|
|
@@ -447,6 +495,23 @@ export default {
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
+
|
|
|
+ // 删除答案
|
|
|
+ removeAnswer(index) {
|
|
|
+ const answer = this.form1.answerList[index];
|
|
|
+ console.log("this.form1",this.form1)
|
|
|
+ const id = answer.id; // 假设答案对象有一个id字段来标识唯一性
|
|
|
+ delAnswer(id)
|
|
|
+ .then(() => {
|
|
|
+ this.form1.answerList.splice(index, 1);
|
|
|
+ this.$message.success('删除答案成功');
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('删除答案失败:', error);
|
|
|
+ this.$message.error('删除答案失败,请重试');
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
/** 导出按钮操作 */
|
|
|
handleExport() {
|
|
|
this.download('asking/question/export', {
|