examQusetionCreateTrueOrFalse.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div class="app-container">
  3. <div class="common-card exam-question-create-body">
  4. <a-spin :spinning="loading">
  5. <a-form
  6. :form="loginForm"
  7. @submit="handleLoginFun"
  8. style="width: 500px;"
  9. :loading="loading"
  10. >
  11. <a-form-item
  12. label="题目内容"
  13. :label-col="labelCol"
  14. :wrapper-col="wrapperCol"
  15. >
  16. <a-textarea
  17. placeholder="题目内容"
  18. :auto-size="{ minRows: 3, maxRows: 5 }"
  19. :maxLength="20"
  20. v-decorator="[
  21. 'content',
  22. {
  23. rules: [{ required: true, message: 'Please input content!' }],
  24. },
  25. ]"
  26. />
  27. </a-form-item>
  28. <div class="question-option">
  29. <span class="question-option-title">题目选项:</span>
  30. </div>
  31. <div
  32. class="question-option-list-row"
  33. v-for="(item, index) in optionsList"
  34. :key="index"
  35. >
  36. <span
  37. v-if="optionsList.length > 2"
  38. class="question-option-list-row-delete"
  39. @click="questionOptionDeleteFun(index)"
  40. >删除</span
  41. >
  42. <a-form-item
  43. :label="index | formatQuestionIndex"
  44. :label-col="labelCol"
  45. :wrapper-col="wrapperCol"
  46. >
  47. <a-input
  48. v-model="item.value"
  49. placeholder="选项内容"
  50. disabled
  51. :maxLength="200"
  52. />
  53. </a-form-item>
  54. </div>
  55. <a-form-item
  56. label="正确答案"
  57. :label-col="labelCol"
  58. :wrapper-col="wrapperCol"
  59. >
  60. <a-input
  61. placeholder="答案格式为大写字母"
  62. :maxLength="200"
  63. v-decorator="[
  64. 'finalAnswer',
  65. {
  66. rules: [{ required: true, message: 'Please input content!' }],
  67. },
  68. ]"
  69. />
  70. </a-form-item>
  71. <a-form-item
  72. label="必学日期"
  73. :label-col="labelCol"
  74. :wrapper-col="wrapperCol"
  75. >
  76. <a-date-picker
  77. @change="onDateChange"
  78. placeholder="请选择日期"
  79. v-decorator="[
  80. 'studyDate',
  81. {
  82. rules: [{ required: true, message: 'Please selete date!' }],
  83. },
  84. ]"
  85. />
  86. </a-form-item>
  87. <a-form-item
  88. label="工种类别"
  89. :label-col="labelCol"
  90. :wrapper-col="wrapperCol"
  91. >
  92. <a-select
  93. v-decorator="[
  94. 'engineeringWorkChooseValue',
  95. {
  96. rules: [{ required: false, message: 'Please selete date!' }],
  97. initialValue: engineeringWorkChooseValue,
  98. },
  99. ]"
  100. >
  101. <a-select-option
  102. :value="item.value"
  103. v-for="(item, index) in engineeringWorkList"
  104. :key="index"
  105. >
  106. {{ item.title }}
  107. </a-select-option>
  108. </a-select>
  109. </a-form-item>
  110. <a-form-item>
  111. <a-button
  112. type="primary"
  113. html-type="submit"
  114. style="width: 100%;margin-top: 20px;"
  115. >提交</a-button
  116. >
  117. </a-form-item>
  118. </a-form>
  119. </a-spin>
  120. </div>
  121. </div>
  122. </template>
  123. <script>
  124. import { ENGINEERING_WORK_LIST } from '@/common/Constant';
  125. export default {
  126. name: 'examQusetionCreateTrueOrFalse',
  127. props: {},
  128. components: {},
  129. data() {
  130. return {
  131. loading: false, // 是否显示加载动画
  132. labelCol: { span: 6 }, // 表单行中label的占位
  133. wrapperCol: { span: 18 }, // 表单行中内容的占位
  134. loginForm: this.$form.createForm(this, {
  135. name: 'examQusetionAddPanDuan',
  136. }),
  137. questionType: 'PanDuan', // 题目类型:判断题
  138. optionsList: [{ value: '正确' }, { value: '错误' }], // 选项列表
  139. engineeringWorkList: [], // 工种数据列表
  140. engineeringWorkChooseValue: '', // 所选工种
  141. studyDate: '', // 开考时间
  142. };
  143. },
  144. created() {
  145. this.initDataFun(); // 初始化数据
  146. },
  147. mounted() {},
  148. beforeDestroy() {},
  149. watch: {},
  150. computed: {},
  151. methods: {
  152. // 初始化数据
  153. initDataFun() {
  154. // 工种类别
  155. this.engineeringWorkList = [
  156. { title: '不限工种', value: '' },
  157. ...ENGINEERING_WORK_LIST,
  158. ];
  159. this.engineeringWorkChooseValue = this.engineeringWorkList[0].value;
  160. },
  161. // 操作:删除选项
  162. questionOptionDeleteFun(index) {
  163. this.optionsList.splice(index, 1);
  164. },
  165. // 操作:选择日期
  166. onDateChange(date, dateString) {
  167. if (date) {
  168. this.studyDate = dateString;
  169. } else {
  170. this.studyDate = '';
  171. }
  172. },
  173. // 操作:表单提交
  174. handleLoginFun(e) {
  175. e.preventDefault();
  176. this.loginForm.validateFields((err, values) => {
  177. if (!err) {
  178. let params = {
  179. ...values,
  180. };
  181. params.studyDate = this.studyDate;
  182. this.httpQuestFun(params);
  183. }
  184. });
  185. },
  186. // 表单提交请求
  187. httpQuestFun(params) {
  188. this.loading = true;
  189. console.log(params);
  190. setTimeout(() => {
  191. this.loading = false;
  192. }, 2000);
  193. // this.$_http
  194. // .post(this.$_API.INTERFACE_POST_EXAMS_QUESTION_ADD, params)
  195. // .then((res) => {
  196. // console.log(res);
  197. // })
  198. // .catch((err) => {
  199. // console.log(err);
  200. // })
  201. // .finally(() => {
  202. // this.loading = false;
  203. // });
  204. },
  205. },
  206. };
  207. </script>
  208. <style lang="less"></style>
  209. <style lang="less" scoped>
  210. @import '~@/styles/common/variable.less';
  211. </style>