Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

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