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.
 
 
 
 
 
 

253 lines
7.5 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. this.HTTP_GET("learun/adms/PersonnelManagement/MeetingManagement/conferenceroomlist",{},"获取会议场地出错").then(success=>{
  139. if(success){
  140. this.dataSource.MeetingManagement.MeetingPlace=success.map(t=>({text:t.Name,value:t.ID}));
  141. }
  142. }),
  143. () => {}
  144. ])
  145. await this.fetchForm()
  146. this.ready = true
  147. this.HIDE_LOADING()
  148. },
  149. // 加载表单数据
  150. async fetchForm() {
  151. if (this.mode === 'create') {
  152. this.origin = await this.getDefaultForm()
  153. } else {
  154. const result = await this.HTTP_GET('learun/adms/PersonnelManagement/MeetingManagement/form', this.id)
  155. this.origin = await this.formatFormData(result)
  156. }
  157. this.current = this.COPY(this.origin)
  158. },
  159. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  160. async action(type) {
  161. switch (type) {
  162. case 'edit':
  163. this.edit = true
  164. break
  165. case 'reset':
  166. this.current = this.COPY(this.origin)
  167. this.edit = false
  168. break
  169. case 'save':
  170. const verifyResult = this.verifyForm()
  171. if (verifyResult.length > 0) {
  172. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  173. return
  174. }
  175. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  176. return
  177. }
  178. this.LOADING('正在提交...')
  179. const postData = await this.getPostData(this.id)
  180. this.HTTP_POST('learun/adms/PersonnelManagement/MeetingManagement/save', postData, '表单提交保存失败').then(success => {
  181. this.HIDE_LOADING()
  182. if (!success) {
  183. return
  184. }
  185. this.EMIT('PersonnelManagementMeetingManagement-list-change')
  186. this.NAV_BACK()
  187. this.TOAST('提交保存成功')
  188. })
  189. break
  190. case 'delete':
  191. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  192. return
  193. }
  194. this.LOADING('提交删除中...')
  195. this.HTTP_POST('learun/adms/PersonnelManagement/MeetingManagement/delete', this.id, '删除失败').then(success => {
  196. this.HIDE_LOADING()
  197. if (!success) {
  198. return
  199. }
  200. this.EMIT('PersonnelManagementMeetingManagement-list-change')
  201. this.NAV_BACK()
  202. this.this.TOAST('删除成功', 'success')
  203. })
  204. break
  205. default: break
  206. }
  207. },
  208. // 获取表单值
  209. getValue(path) {
  210. return get(this.current, path)
  211. },
  212. // 设置表单值
  213. setValue(path, val) {
  214. set(this.current, path, val)
  215. }
  216. }
  217. }
  218. </script>