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.
 
 
 
 
 
 

247 lines
7.7 KiB

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