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.
 
 
 
 
 
 

220 lines
6.3 KiB

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