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.
 
 
 
 
 
 

217 lines
6.4 KiB

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