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.
 
 
 
 
 
 

222 lines
6.4 KiB

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