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.
 
 
 
 
 
 

214 rivejä
6.1 KiB

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