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.
 
 
 
 
 
 

208 lines
6.0 KiB

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