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.
 
 
 
 
 
 

209 lines
5.9 KiB

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