Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

229 linhas
6.1 KiB

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