CreatingQuestionCard.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <primary-question-card v-if="questionVO!==undefined" :question-v-o="questionVO" :cur-num="curNum" :total-num="totalNum">
  3. <template v-slot:button>
  4. <el-col :span="1">
  5. <el-button type="primary" icon="el-icon-check" circle @click="mockApproveQuestion"/>
  6. </el-col>
  7. <el-col :span="1">
  8. <el-button type="danger" icon="el-icon-close" circle @click="mockDisapproveQuestion"/>
  9. </el-col>
  10. </template>
  11. </primary-question-card>
  12. </template>
  13. <script>
  14. import PrimaryQuestionCard from '@/components/QuestionCard/PrimaryQuestionCard';
  15. export default {
  16. name: "CreatingQuestionCard",
  17. components: {
  18. PrimaryQuestionCard
  19. },
  20. data() {
  21. return {}
  22. },
  23. props: {
  24. questionVO: Object,
  25. curNum: Number,
  26. totalNum: Number
  27. },
  28. mounted() {
  29. },
  30. methods: {
  31. // 审核通过新建的题目
  32. approveQuestion() {
  33. const _this = this
  34. _this.questionVO.state = "APPROVED"
  35. let record = {
  36. userId: _this.$store.state.user.id,
  37. operationType: "Approve",
  38. }
  39. // 更新题目信息
  40. _this.$api.updateQuestion(this.questionVO)
  41. .then(async res => {
  42. console.log(res)
  43. _this.$message({
  44. type: "success",
  45. message: "新建审核通过",
  46. })
  47. record.questionId = res.data.result.id;
  48. record.time = new Date();
  49. // 添加新的操作记录
  50. await _this.$api.createRecord(record)
  51. .then(recordRes => {
  52. console.log(recordRes)
  53. })
  54. .catch(recordErr => {
  55. console.log(recordErr)
  56. })
  57. // 向父组件更新题目列表信息
  58. _this.$emit("approve")
  59. })
  60. .catch(err=>{
  61. _this.$message({
  62. type: "error",
  63. message: "新建审核不通过"
  64. })
  65. })
  66. },
  67. // 审核不通过新建的题目
  68. disapproveQuestion(){},
  69. mockApproveQuestion() {
  70. // TODO
  71. const _this = this
  72. _this.$message({
  73. type: "success",
  74. message: "新建审核通过"
  75. })
  76. _this.$emit("approve")
  77. },
  78. mockDisapproveQuestion() {
  79. // TODO
  80. const _this = this
  81. _this.$message({
  82. type: "error",
  83. message: "新建审核不通过"
  84. })
  85. },
  86. },
  87. emits:["approve"]
  88. }
  89. </script>
  90. <style scoped>
  91. </style>