examQusetionCreateGapFilling.vue 5.8 KB

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