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 8.0 KiB

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