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.
 
 
 
 
 
 

270 lines
8.7 KiB

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