question.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-form ref="form" :model="form">
  6. <el-col :span="24" class="topTitle">
  7. {{ task.name }}
  8. </el-col>
  9. <el-col :span="24" v-for="(item, index) in task.question" :key="index">
  10. <el-form-item>
  11. <span slot="label">{{ index + 1 }} . {{ item.topic }}</span>
  12. </el-form-item>
  13. <template v-if="item.type === '0'">
  14. <el-col :span="24" v-for="(items, index) in item.option" :key="index">
  15. <el-radio v-model="item.answer" :label="items.opname">{{ items.opname }}</el-radio>
  16. </el-col>
  17. </template>
  18. <template v-else-if="item.type === '1'">
  19. <el-checkbox-group v-model="item.answer">
  20. <el-col :span="24" v-for="(items, index) in item.option" :key="index">
  21. <el-checkbox :label="items.opname">{{ items.opname }}</el-checkbox>
  22. </el-col>
  23. </el-checkbox-group>
  24. </template>
  25. <span v-else>
  26. <el-input
  27. type="textarea"
  28. placeholder="请输入内容"
  29. v-model="item.answer"
  30. :autosize="{ minRows: 4, maxRows: 6 }"
  31. maxlength="300"
  32. show-word-limit
  33. ></el-input>
  34. </span>
  35. </el-col>
  36. <el-col :span="24" class="btn">
  37. <el-button type="primary" @click="onSubmit">提交</el-button>
  38. </el-col>
  39. </el-form>
  40. </el-col>
  41. </el-row>
  42. </div>
  43. </template>
  44. <script>
  45. import _ from 'lodash';
  46. export default {
  47. name: 'index',
  48. props: {
  49. info: { type: Object, required: true },
  50. form: null,
  51. },
  52. components: {},
  53. data: () => ({
  54. task: {},
  55. }),
  56. created() {},
  57. computed: {},
  58. methods: {
  59. onSubmit() {
  60. this.$emit('submit', this.task);
  61. },
  62. },
  63. watch: {
  64. info: {
  65. handler(val) {
  66. if (_.get(val, `id`)) this.$set(this, `task`, val);
  67. },
  68. immediate: true,
  69. deep: true,
  70. },
  71. },
  72. };
  73. </script>
  74. <style lang="less" scoped>
  75. .style {
  76. min-height: 300px;
  77. padding: 0 40px;
  78. }
  79. .topTitle {
  80. text-align: center;
  81. height: 50px;
  82. line-height: 50px;
  83. border-bottom: 1px dashed #333;
  84. }
  85. /deep/.el-form-item {
  86. margin: 0;
  87. }
  88. /deep/.el-form-item__label {
  89. color: #389ff0;
  90. }
  91. .btn {
  92. text-align: center;
  93. padding: 30px 0;
  94. margin: 0 0 20px 0;
  95. }
  96. </style>