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.
 
 
 
 
 
 

255 line
7.6 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-select
  5. @input="setValue('StuMail.LeaveType', $event)"
  6. :value="getValue('StuMail.LeaveType')"
  7. :disabled="!edit"
  8. :range="dataSource.StuMail.LeaveType"
  9. title="请假类型"
  10. />
  11. <l-datetime-picker
  12. @input="setValue('StuMail.StartTime', $event)"
  13. :value="getValue('StuMail.StartTime')"
  14. :disabled="!edit"
  15. :range="dataSource.StuMail.StartTime"
  16. title="请假时间"
  17. />
  18. <l-datetime-picker
  19. @input="setValue('StuMail.EndTime', $event)"
  20. :value="getValue('StuMail.EndTime')"
  21. :disabled="!edit"
  22. :range="dataSource.StuMail.EndTime"
  23. title="返校时间"
  24. />
  25. <l-input
  26. @input="setValue('StuMail.LeaveDay', $event)"
  27. :value="getValue('StuMail.LeaveDay')"
  28. :disabled="!edit"
  29. title="请假天数"
  30. />
  31. <!-- <l-input
  32. @input="setValue('StuMail.num', $event)"
  33. :value="getValue('StuMail.num')"
  34. :disabled="!edit"
  35. title="未销假次数"
  36. /> -->
  37. <l-upload-file
  38. @input="setValue('StuMail.Files', $event)"
  39. :value="getValue('StuMail.Files')"
  40. :readonly="!edit"
  41. :number="9"
  42. title="附件上传"
  43. tableName="StuMail"
  44. fieldName="Files"
  45. />
  46. <l-textarea
  47. @input="setValue('StuMail.LeaveReason', $event)"
  48. :value="getValue('StuMail.LeaveReason')"
  49. :readonly="!edit"
  50. title="请假事由"
  51. />
  52. <!-- <l-select
  53. @input="setValue('StuMail.CheckStatus', $event)"
  54. :value="getValue('StuMail.CheckStatus')"
  55. :disabled="!edit"
  56. :range="dataSource.StuMail.CheckStatus"
  57. title="审核状态"
  58. /> -->
  59. </view>
  60. <view v-if="ready && edit" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  61. <template v-if="edit">
  62. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  63. 保存草稿
  64. </l-button>
  65. <!-- <l-button v-if="edit&&getValue('StuMail.CheckStatus') === '0'" @click="action('save','1')" size="lg" color="blue" class="block margin-top" block>
  66. 提交申请
  67. </l-button> -->
  68. </template>
  69. <!-- <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
  70. 编辑本页
  71. </l-button>
  72. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  73. 取消编辑
  74. </l-button>
  75. <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block>
  76. 删除
  77. </l-button> -->
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. /*
  83. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  84. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  85. * 创建人:超级管理员
  86. * 日 期:2020-10-20 15:34
  87. * 描 述:aaa
  88. */
  89. /**
  90. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  91. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  92. * { "path": "pages/EducationalAdministration/StuMail/single", "style": { "navigationBarTitleText": "表单详情页" } }
  93. *
  94. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  95. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  96. */
  97. import get from 'lodash/get'
  98. import set from 'lodash/set'
  99. import moment from 'moment'
  100. import customPageMixins from '@/common/custompage.js'
  101. export default {
  102. mixins: [customPageMixins],
  103. data() {
  104. return {
  105. // 页面相关参数
  106. id: null,
  107. mode: null,
  108. edit: null,
  109. ready: false,
  110. // 表单数据
  111. current: {},
  112. origin: {},
  113. // 表单项数据结构
  114. scheme: {
  115. StuMail: {
  116. LeaveType:{ type: 'select', title: '请假类型', verify: 'NotNull' },
  117. StartTime:{ type: 'datetime', title: '开始时间', dateformat: '1' },
  118. EndTime:{ type: 'datetime', title: '返校时间', dateformat: '1' },
  119. LeaveDay:{ title: '请假天数', verify: 'Num' },
  120. Files:{ type: 'upload', title: '附件上传'},
  121. LeaveReason:{ type: 'textarea', title: '请假事由'},
  122. CheckStatus:{ type: 'select', title: '审核状态' },
  123. },
  124. },
  125. // 数据源
  126. dataSource: {
  127. StuMail: {
  128. LeaveType: Object.values(this.GET_GLOBAL('dataDictionary').LeaveTypeOfStu).map(t => ({ value: t.value, text: t.text })),
  129. CheckStatus:[{text:'草稿',value:'0'},{text:'审核中',value:'1'},{text:'通过',value:'2'},{text:'不通过',value:'3'}]
  130. },
  131. }
  132. }
  133. },
  134. async onLoad({ type, id }) {
  135. await this.init(type, id)
  136. },
  137. methods: {
  138. // 页面初始化
  139. async init(type, id) {
  140. this.LOADING('加载数据中...')
  141. this.id = id
  142. this.mode = type
  143. this.edit = ['create', 'edit'].includes(this.mode)
  144. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  145. await Promise.all([
  146. () => {}
  147. ])
  148. await this.fetchForm()
  149. this.ready = true
  150. this.HIDE_LOADING()
  151. },
  152. // 加载表单数据
  153. async fetchForm() {
  154. if (this.mode === 'create') {
  155. this.origin = await this.getDefaultForm()
  156. } else {
  157. const result = await this.HTTP_GET('learun/adms/stuleavemanagement/form', this.id)
  158. this.origin = await this.formatFormData(result)
  159. }
  160. this.current = this.COPY(this.origin)
  161. },
  162. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  163. async action(type,checkType) {
  164. switch (type) {
  165. case 'edit':
  166. this.edit = true
  167. break
  168. case 'reset':
  169. this.current = this.COPY(this.origin)
  170. this.edit = false
  171. break
  172. case 'save':
  173. const verifyResult = this.verifyForm()
  174. console.log(this.scheme)
  175. if (verifyResult.length > 0) {
  176. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  177. return
  178. }
  179. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  180. return
  181. }
  182. this.LOADING('正在提交...')
  183. const postData = await this.getPostData(this.id)
  184. this.HTTP_POST('learun/adms/stuleavemanagement/save', postData, '表单提交保存失败').then(success => {
  185. this.HIDE_LOADING()
  186. if (!success) {
  187. return
  188. }
  189. this.EMIT('EducationalAdministrationStuAttendanceLeave-list-change')
  190. this.NAV_BACK()
  191. this.TOAST('提交保存成功')
  192. })
  193. break
  194. case 'delete':
  195. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  196. return
  197. }
  198. this.LOADING('提交删除中...')
  199. this.HTTP_POST('learun/adms/stuleavemanagement/delete', this.id, '删除失败').then(success => {
  200. this.HIDE_LOADING()
  201. if (!success) {
  202. return
  203. }
  204. this.EMIT('EducationalAdministrationStuAttendanceLeave-list-change')
  205. this.NAV_BACK()
  206. this.this.TOAST('删除成功', 'success')
  207. })
  208. break
  209. default: break
  210. }
  211. },
  212. // 获取表单值
  213. getValue(path) {
  214. return get(this.current, path)
  215. },
  216. // 设置表单值
  217. setValue(path, val) {
  218. set(this.current, path, val)
  219. }
  220. }
  221. }
  222. </script>