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

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