You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

single.vue 5.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <!-- <l-input v-model="text" disabled title="你说呢你说呢?"></l-input>
  5. <radio-group>
  6. <l-radio v-model="radioValue" title="单选框1" radioValue="1" />
  7. <l-radio v-model="radioValue" title="单选框2" radioValue="2" />
  8. </radio-group> -->
  9. <view v-for="(item,index) in formData.Eval_Questions" :key="item.QID">
  10. <view class="questionTitle">
  11. <text style="color: red;">{{item.QMust?"* ":""}}</text>
  12. {{item.QTitle}}
  13. </view>
  14. <!-- 单选 -->
  15. <l-select
  16. v-if="item.QType == 1"
  17. v-model="aa"
  18. :range="item.Eval_QuestionItems"
  19. title=""
  20. placeholder="请选择"
  21. :disabled="false"
  22. textField="ITitle"
  23. valueField="IID"
  24. />
  25. <!-- 多选 -->
  26. <!-- <l-checkbox
  27. v-if="item.QTypeString == 1"
  28. v-model="aa"
  29. @change="searchChange"
  30. :range="item.Eval_QuestionItems"
  31. title=""
  32. placeholder="请选择"
  33. :disabled="false"
  34. textField="ITitle"
  35. valueField="IID"
  36. /> -->
  37. <checkbox-group v-if="item.QType == 1">
  38. <l-checkbox v-for="item1 in item.Eval_QuestionItems" :key="item1.IID" v-model="bbb" :title="item1.ITitle" :checkboxValue="item1.IID.toString()" />
  39. </checkbox-group>
  40. <!-- 填空 -->
  41. <l-textarea v-if="item.QType == 1" v-model="aa" placeholder="请输入" />
  42. </view>
  43. <!-- <l-input v-model="text" disabled title="你说呢你说呢?"></l-input>
  44. <radio-group>
  45. <l-radio v-model="radioValue" title="单选框1" radioValue="1" />
  46. <l-radio v-model="radioValue" title="单选框2" radioValue="2" />
  47. </radio-group> -->
  48. </view>
  49. <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  50. <l-button v-if="edit" @click="action('save')" size="lg" style="background-color: #0C86D8;color: #fff;" class="block margin-top" block>
  51. 提交保存
  52. </l-button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import get from 'lodash/get'
  58. import set from 'lodash/set'
  59. import moment from 'moment'
  60. import customPageMixins from '@/common/custompage.js'
  61. export default {
  62. mixins: [customPageMixins],
  63. data() {
  64. return {
  65. aa:"",
  66. bbb:[],
  67. // 页面相关参数
  68. id: null,
  69. edit: null,
  70. ready: false,
  71. formData:{},
  72. submitParams:null
  73. }
  74. },
  75. async onLoad({ id,EmpNo,LessonNo }) {
  76. this.submitParams = {EmpNo,LessonNo}
  77. await this.init(id)
  78. },
  79. methods: {
  80. aaa(){
  81. console.log(this.bbb,this)
  82. },
  83. // 页面初始化
  84. async init( id ) {
  85. this.LOADING('加载数据中...')
  86. this.id = id
  87. await this.fetchForm()
  88. this.ready = true
  89. this.HIDE_LOADING()
  90. },
  91. // 加载表单数据
  92. async fetchForm() {
  93. return this.HTTP_GET('learun/adms/eval/paper', {VID:this.id}, '加载数据时出错').then(success => {
  94. this.HIDE_LOADING()
  95. if (!success) {
  96. return
  97. }
  98. if(success){
  99. this.edit = true
  100. }
  101. console.log(success)
  102. this.formData = success
  103. })
  104. },
  105. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  106. async action(type) {
  107. switch (type) {
  108. case 'edit':
  109. this.edit = true
  110. break
  111. case 'reset':
  112. this.current = this.COPY(this.origin)
  113. this.edit = false
  114. break
  115. case 'save':
  116. // const verifyResult = this.verifyForm()
  117. // if (verifyResult.length > 0) {
  118. // this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  119. // return
  120. // }
  121. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  122. return
  123. }
  124. this.LOADING('正在提交...')
  125. let postarray = this.formData.Eval_Questions.map(item=>{
  126. return {
  127. QID:item.QID,
  128. IID:item.IID.toString(),
  129. UText:item.UText,
  130. }
  131. })
  132. const postData = {
  133. VID:this.formData.VID,
  134. ...this.submitParams,
  135. postarray
  136. }
  137. this.HTTP_POST('learun/adms/EducationalAdministration/Journal/save', postData, '表单提交保存失败').then(success => {
  138. this.HIDE_LOADING()
  139. if (!success) {
  140. return
  141. }
  142. this.NAV_BACK()
  143. this.TOAST('提交保存成功')
  144. })
  145. break
  146. case 'delete':
  147. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  148. return
  149. }
  150. this.LOADING('提交删除中...')
  151. this.HTTP_POST('learun/adms/EducationalAdministration/Journal/delete', this.id, '删除失败').then(success => {
  152. this.HIDE_LOADING()
  153. if (!success) {
  154. return
  155. }
  156. this.EMIT('EducationalAdministrationJournalSend-list-change')
  157. this.NAV_BACK()
  158. this.this.TOAST('删除成功', 'success')
  159. })
  160. break
  161. default: break
  162. }
  163. },
  164. // 获取表单值
  165. getValue(path) {
  166. return get(this.current, path)
  167. },
  168. // 设置表单值
  169. setValue(path, val) {
  170. set(this.current, path, val)
  171. }
  172. }
  173. }
  174. </script>
  175. <style scoped lang="scss">
  176. .questionTitle{
  177. line-height: 18px;
  178. background-color: #fff;
  179. color: #000;
  180. margin-top: 8px;
  181. margin-bottom: 1px;
  182. padding: 16px 12px;
  183. }
  184. :deep(.cu-form-group){
  185. display: none;
  186. }
  187. </style>