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.
 
 
 
 
 
 

292 lines
7.7 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <view class="paper-title">
  5. {{formData.VTitle}}
  6. <view class="paper-time">
  7. {{formData.VStartTime}}
  8. -
  9. {{formData.VStopTime}}
  10. </view>
  11. </view>
  12. <view v-for="(item,index) in formData.Eval_Questions" :key="item.QID">
  13. <view class="questionTitle">
  14. <text style="color: red;">{{item.QMust?"* ":""}}</text>
  15. {{item.QTitle}}
  16. </view>
  17. <!-- 单选 -->
  18. <l-select
  19. v-if="item.QType == 1"
  20. v-model="item.IID"
  21. @change="(e)=>{checkBoxGroupChange(item.QID,e)}"
  22. :range="item.Eval_QuestionItems"
  23. title=""
  24. placeholder="请选择"
  25. :disabled="false"
  26. textField="ITitle"
  27. valueField="IID"
  28. />
  29. <!-- 多选 -->
  30. <view v-if="item.QType == 2">
  31. <checkbox-group v-model="item.checked" @change="(e)=>{checkBoxGroupChange(item.QID,e.detail.value)}">
  32. <view v-for="item1 in item.Eval_QuestionItems" :key="item1.IID">
  33. <l-checkbox :title="item1.ITitle" v-model="item1.isChecked" :checkboxValue="item1.IID.toString()" />
  34. <l-textarea
  35. simpleMode
  36. v-if="item1.QShowText&&
  37. checkBoxs[item.QID]&&
  38. checkBoxs[item.QID].includes(item1.IID)"
  39. v-model="uTexts[item1.IID]"
  40. style="margin-top: 6px;"
  41. placeholder="请输入"
  42. />
  43. </view>
  44. </checkbox-group>
  45. </view>
  46. <!-- 填空 -->
  47. <l-textarea v-if="item.QType == 3" v-model="item.QContent" placeholder="请输入" />
  48. <!-- 校验提示 -->
  49. <view v-if="validate[item.QID]" style="color: red;font-size: 12px;margin-bottom: 4px;padding-left: 12px;">
  50. {{validate[item.QID]}}
  51. </view>
  52. </view>
  53. <!-- <l-input v-model="text" disabled title="你说呢你说呢?"></l-input>
  54. <radio-group>
  55. <l-radio v-model="radioValue" title="单选框1" radioValue="1" />
  56. <l-radio v-model="radioValue" title="单选框2" radioValue="2" />
  57. </radio-group> -->
  58. </view>
  59. <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  60. <l-button v-if="edit" @click="action('save')" size="lg" style="background-color: #0C86D8;color: #fff;" class="block margin-top" block>
  61. 提交保存
  62. </l-button>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. /*
  68. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  69. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  70. * 创建人:超级管理员
  71. * 日 期:2020-10-16 15:39
  72. * 描 述:工作日志
  73. */
  74. /**
  75. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  76. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  77. * { "path": "pages/EducationalAdministration/JournalSend/single", "style": { "navigationBarTitleText": "表单详情页" } }
  78. *
  79. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  80. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  81. */
  82. import get from 'lodash/get'
  83. import set from 'lodash/set'
  84. import moment from 'moment'
  85. import customPageMixins from '@/common/custompage.js'
  86. export default {
  87. mixins: [customPageMixins],
  88. data() {
  89. return {
  90. aa:"",
  91. bbb:[],
  92. // 页面相关参数
  93. id: null,
  94. mode: null,
  95. edit: null,
  96. ready: false,
  97. ready: false,
  98. formData:{
  99. Eval_Questions:[]
  100. },
  101. submitParams:null,
  102. uTexts:{},
  103. checkBoxs:{},
  104. validate:{},
  105. }
  106. },
  107. async onLoad({ id,EmpNo,LessonNo }) {
  108. this.submitParams = {EmpNo,LessonNo}
  109. await this.init(id)
  110. },
  111. methods: {
  112. checkBoxGroupChange(id,value){
  113. this.checkBoxs[id] = value
  114. },
  115. // 页面初始化
  116. async init( id ) {
  117. this.LOADING('加载数据中...')
  118. this.id = id
  119. await this.fetchForm()
  120. this.ready = true
  121. this.HIDE_LOADING()
  122. },
  123. // 加载表单数据
  124. async fetchForm() {
  125. return this.HTTP_GET('learun/adms/eval/paper', {VID:this.id}, '加载数据时出错').then(success => {
  126. this.HIDE_LOADING()
  127. if (!success) {
  128. return
  129. }
  130. if(success){
  131. this.edit = true
  132. }
  133. this.formData = success
  134. })
  135. },
  136. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  137. async action(type) {
  138. switch (type) {
  139. case 'edit':
  140. this.edit = true
  141. break
  142. case 'reset':
  143. this.current = this.COPY(this.origin)
  144. this.edit = false
  145. break
  146. case 'save':
  147. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  148. return
  149. }
  150. this.LOADING('正在提交...')
  151. let postarray = []
  152. this.formData.Eval_Questions.map(item=>{
  153. let validate = {}
  154. switch (item.QType){
  155. case 1:
  156. if(item.QMust){
  157. validate[item.QID] = this.checkBoxs[item.QID]?'':'此项必填!'
  158. }
  159. this.validate = {...this.validate,...validate}
  160. postarray.push({
  161. QID:item.QID,
  162. IID:this.checkBoxs[item.QID]?this.checkBoxs[item.QID].toString():'',
  163. UText:item.UText||'',
  164. })
  165. break;
  166. case 2:
  167. if(item.QMust){
  168. validate[item.QID] = (this.checkBoxs[item.QID]&&this.checkBoxs[item.QID].length)?'':"此项必填!"
  169. this.validate = {...this.validate,...validate}
  170. }
  171. if(this.checkBoxs[item.QID]&&this.checkBoxs[item.QID].length){
  172. this.checkBoxs[item.QID].map(t=>{
  173. postarray.push({
  174. QID:item.QID,
  175. IID:t,
  176. UText:this.uTexts[t]||'',
  177. })
  178. })
  179. }
  180. break;
  181. case 3:
  182. if(item.QMust){
  183. validate[item.QID] = item.QContent?'':"此项必填"
  184. this.validate = {...this.validate,...validate}
  185. }
  186. if(this.checkBoxs[item.QID]&&this.checkBoxs[item.QID].length){
  187. this.checkBoxs[item.QID].map(t=>{
  188. postarray.push({
  189. QID:item.QID,
  190. IID:'',
  191. QContent:item.QContent||'',
  192. })
  193. })
  194. }
  195. break;
  196. }
  197. })
  198. let validataArr = Object.values(this.validate)
  199. if(validataArr.some(t=>t)){
  200. this.TOAST("请完善表单信息!")
  201. return
  202. }
  203. const postData = {
  204. VID:this.formData.VID,
  205. ...this.submitParams,
  206. postarray
  207. }
  208. console.log(postData)
  209. this.HTTP_POST('learun/adms/eval/savepaper', postData, '表单提交保存失败').then(success => {
  210. this.HIDE_LOADING()
  211. if (!success) {
  212. return
  213. }
  214. this.TOAST('提交保存成功')
  215. setTimeout(()=>{
  216. this.NAV_BACK()
  217. },200)
  218. })
  219. break
  220. case 'delete':
  221. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  222. return
  223. }
  224. this.LOADING('提交删除中...')
  225. this.HTTP_POST('learun/adms/EducationalAdministration/Journal/delete', this.id, '删除失败').then(success => {
  226. this.HIDE_LOADING()
  227. if (!success) {
  228. return
  229. }
  230. this.EMIT('EducationalAdministrationJournalSend-list-change')
  231. this.NAV_BACK()
  232. this.this.TOAST('删除成功', 'success')
  233. })
  234. break
  235. default: break
  236. }
  237. },
  238. // 获取表单值
  239. getValue(path) {
  240. return get(this.current, path)
  241. },
  242. // 设置表单值
  243. setValue(path, val) {
  244. set(this.current, path, val)
  245. }
  246. }
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .paper-title{
  251. font-size: 20px;
  252. color: #000;
  253. text-align: center;
  254. margin: 16px 0;
  255. }
  256. .paper-time{
  257. color: #606266;
  258. font-size: 12px;
  259. text-align: center;
  260. }
  261. .questionTitle{
  262. line-height: 18px;
  263. background-color: #fff;
  264. color: #000;
  265. margin-top: 8px;
  266. margin-bottom: 1px;
  267. padding: 16px 12px;
  268. }
  269. </style>