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

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