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.
 
 
 
 
 
 

248 lines
7.3 KiB

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