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.
 
 
 
 
 
 

249 lines
7.3 KiB

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