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.
 
 
 
 
 
 

332 lines
13 KiB

  1. <template>
  2.   <view class="page">
  3.     <!-- 主列表页 -->
  4.     <view :class="sideOpen ? 'show' : ''" class="mainpage" style="padding-top: 80rpx;">
  5.       <!-- 顶部条目/分页信息栏 -->
  6.       <l-customlist-banner @buttonClick="sideOpen = true">{{ tips }}</l-customlist-banner>
  7.   
  8.       <!-- 滚动列表,跨端支持上拉/下拉 -->
  9.       <l-scroll-list v-if="ready" @pullDown="pullDown" @toBottom="fetchList()" ref="list">
  10.         <l-customlist :tips="loadState" showTips>
  11.           <!-- 单条记录 -->
  12.           <view class="customlist-item" v-for="item of list" :key="item.ID">
  13.   
  14.             <view class="customlist-item-field">
  15.               <text class="customlist-item-field-title">姓名:</text>
  16.               {{ displayListItem(item, 'Name') }}
  17.             </view>
  18.   
  19.             <view class="customlist-item-field">
  20.               <text class="customlist-item-field-title">性别:</text>
  21.               {{ displayListItem(item, 'Gender') }}
  22.             </view>
  23.   
  24.             <view class="customlist-item-field">
  25.               <text class="customlist-item-field-title">联系方式:</text>
  26.               {{ displayListItem(item, 'Mobile') }}
  27.             </view>
  28.   
  29.             <view class="customlist-item-field">
  30.               <text class="customlist-item-field-title">身份证:</text>
  31.               {{ displayListItem(item, 'IDCard') }}
  32.             </view>
  33.   
  34.             <view class="customlist-item-field">
  35.               <text class="customlist-item-field-title">隔离方式:</text>
  36.               {{ displayListItem(item, 'QTType') }}
  37.             </view>
  38.   
  39.             <view class="customlist-item-field">
  40.               <text class="customlist-item-field-title">隔离地点:</text>
  41.               {{ displayListItem(item, 'QTAddress') }}
  42.             </view>
  43.   
  44.             <view class="customlist-item-field">
  45.               <text class="customlist-item-field-title">隔离时间:</text>
  46.               {{ displayListItem(item, 'QTContactTime') }}
  47.             </view>
  48.   
  49.             <view class="customlist-item-field">
  50.               <text class="customlist-item-field-title">是否发热:</text>
  51.               {{ displayListItem(item, 'Fever') }}
  52.             </view>
  53.   
  54.   
  55.             <l-customlist-action showEdit @edit="action('edit', item.ID)" showDelete @delete="action('delete', item.ID)" @view="action('view', item.ID)" />
  56.           </view>
  57.         </l-customlist>
  58.       </l-scroll-list>
  59.     </view>
  60.   
  61.     <!-- 关闭侧边抽屉按钮 -->
  62.     <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose">
  63.       <l-icon type="pullright" color="blue" />
  64.     </view>
  65.   
  66.     <!-- 侧边栏,用于设置查询条件 -->
  67.     <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  68.       <view v-if="ready" class="padding">
  69.   
  70.         <l-customlist-sidepage-datefilter
  71.           v-model="dateRange"
  72.           @change="searchChange"
  73.           title="按时间日期查询: "
  74.           ref="datefilter"
  75.           class="margin-bottom"
  76.         />
  77.   
  78.         <l-input
  79.           v-model="queryData.Name"
  80.           @change="searchChange"
  81.           title ="姓名"
  82.           placeholder="按姓名查询"
  83.         />
  84.         <l-select
  85.           v-model="queryData.Fever"
  86.           @change="searchChange"
  87.           :range="dataSource.Fever"
  88.           title ="是否发热"
  89.           placeholder="按是否发热查询"
  90.         />
  91.   
  92.         <!-- 重置查询条件按钮 -->
  93.         <view class="padding-tb">
  94.           <l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button>
  95.         </view>
  96.       </view>
  97.     </scroll-view>
  98.   
  99.     <l-customlist-add v-if="!sideOpen" @click="action('add')" />
  100.   
  101.   </view>
  102. </template>
  103.   
  104.   
  105. <script>
  106. /*
  107.  * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  108.  * Copyright (c) 2013-2020 上海力软信息技术有限公司
  109.  * 创建人:超级管理员
  110.  * 日  期:2020-10-21 09:49
  111.  * 描  述:疫情详细信息
  112.  */
  113.   
  114. /**
  115.  * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  116.  * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  117.  * { "path": "pages/PersonnelManagement/ContactsDetails/list", "style": { "navigationBarTitleText": "表单列表页" } }
  118.  * 
  119.  * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  120.  * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  121.  */
  122. import moment from 'moment'
  123. import get from 'lodash/get'
  124. import set from 'lodash/set'
  125. import pickBy from 'lodash/pickBy'
  126. import mapValues from 'lodash/mapValues'
  127.   
  128. export default {
  129.   data() {
  130.     return {
  131.       // 数据项的数据类型、结构
  132.       scheme: {
  133.         Name: { type: 'text' },
  134.         Gender: { type: 'select', itemCode: 'usersex', dataSource: '0' },
  135.         Mobile: { type: 'text' },
  136.         IDCard: { type: 'text' },
  137.         QTType: { type: 'select', itemCode: 'QuarantineType', dataSource: '0' },
  138.         QTAddress: { type: 'text' },
  139.         QTContactTime: { type: 'datetime', dateformat: '0' },
  140.         Fever: { type: 'select', itemCode: 'YesOrNoInt', dataSource: '0' },
  141.       },
  142.   
  143.       // 查询条件
  144.       searchData: {},
  145.       defaultQueryData: {},
  146.       queryData: {
  147.         Name: '',
  148.         Fever: '',
  149.       },
  150.   
  151.       // 数据源
  152.       dataSource: {
  153.         Gender: Object.values(this.GET_GLOBAL('dataDictionary').usersex).map(t => ({ value: t.value, text: t.text })),
  154.         QTType: Object.values(this.GET_GLOBAL('dataDictionary').QuarantineType).map(t => ({ value: t.value, text: t.text })),
  155.         Fever: Object.values(this.GET_GLOBAL('dataDictionary').YesOrNoInt).map(t => ({ value: t.value, text: t.text })),
  156.       },
  157.   
  158.       // 时间查询参数
  159.       dateRange: null,
  160.   
  161.       // 页面相关参数
  162.       ready: false,
  163.       tips: '加载中...',
  164.       loadState: '向下翻以加载更多',
  165.       sideOpen: false,
  166.   
  167.       // 列表与分页信息
  168.       page: 1,
  169.       total: 2,
  170.       list: []
  171.     }
  172.   },
  173.   
  174.   async onLoad() {
  175.     await this.init()
  176.   },
  177.   onUnload() {
  178.     this.OFF('PersonnelManagementContactsDetails-list-change')
  179.   },
  180.   
  181.   methods: {
  182.     // 页面初始化
  183.     async init() {
  184.       this.ON('PersonnelManagementContactsDetails-list-change', this.refreshList)
  185.   
  186.       // 拉取加载列表和数据源
  187.       await Promise.all([
  188.   
  189.   
  190.         () => {}
  191.       ])
  192.       await this.fetchList()
  193.       // 初始化查询条件
  194.       this.defaultQueryData = this.COPY(this.queryData)
  195.       this.ready = true
  196.     },
  197.   
  198.     // 拉取列表
  199.     async fetchList() {
  200.       if (this.page > this.total) { return }
  201.   
  202.       const result = await this.HTTP_GET(
  203.         '/PersonnelManagement/ContactsDetails/pagelist',
  204.         {
  205.           // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  206.           // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  207.           pagination: { rows: 10, page: this.page, sidx: 'ID', sord: 'DESC' },
  208.           queryJson: JSON.stringify(this.searchData)
  209.         },
  210.         '加载数据时出错'
  211.       )
  212.   
  213.       if (!result) { return }
  214.   
  215.       this.total = result.total
  216.       this.page = result.page + 1
  217.       this.list = this.list.concat(result.rows)
  218.   
  219.       this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  220.       this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  221.     },
  222.   
  223.     // 刷新清空列表
  224.     async refreshList() {
  225.       this.page = 1
  226.       this.total = 2
  227.       this.list = []
  228.   
  229.       await this.fetchList()
  230.     },
  231.   
  232.     // 列表下拉
  233.     pullDown() {
  234.       this.refreshList().then(() => {
  235.         this.$refs.list.stopPullDown()
  236.       })
  237.     },
  238.   
  239.     // 设置搜索条件
  240.     async searchChange() {
  241.       const result = {}
  242.   
  243.       // 时间查询相关参数
  244.       if (this.dateRange) {
  245.         result.StartTime = this.dateRange.start
  246.         result.EndTime = this.dateRange.end
  247.       }
  248.   
  249.       // 将其他查询项添加到查询 JSON 中
  250.       const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  251.       Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  252.   
  253.       this.searchData = result
  254.       await this.refreshList()
  255.     },
  256.   
  257.     // 点击「清空查询条件」按钮
  258.     reset() {
  259.       this.$refs.datefilter.changeDateRange('all')
  260.       this.queryData = this.COPY(this.defaultQueryData)
  261.       this.searchChange()
  262.     },
  263.   
  264.     // 点击「编辑」、「查看」、「添加」、「删除」按钮
  265.     async action(type, id = '') {
  266.       switch (type) {
  267.         case 'view':
  268.           this.NAV_TO(`./single?type=view&id=${id}`)
  269.           return
  270.   
  271.         case 'add':
  272.           this.NAV_TO('./single?type=create')
  273.           return
  274.   
  275.         case 'edit':
  276.           this.NAV_TO(`./single?type=edit&id=${id}`)
  277.           return
  278.   
  279.         case 'delete':
  280.           if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  281.             return
  282.           }
  283.   
  284.           this.HTTP_POST('/PersonnelManagement/ContactsDetails/delete', id, '删除失败').then(success => {
  285.             if(!success) { return }
  286.             this.TOAST('删除成功', 'success')
  287.             this.refreshList()
  288.           })
  289.           return
  290.   
  291.         default:
  292.           return
  293.       }
  294.     },
  295.   
  296.     // 显示列表中的标题项
  297.     displayListItem(item, field) {
  298.       const fieldItem = this.scheme[field]
  299.       const value = item[field]
  300.   
  301.       switch (fieldItem.type) {
  302.         case 'currentInfo':
  303.         case 'organize':
  304.           return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  305.   
  306.         case 'radio':
  307.         case 'select':
  308.           const selectItem = this.dataSource[field].find(t => t.value === String(value))
  309.           return get(selectItem, 'text', '')
  310.   
  311.         case 'checkbox':
  312.           if (!value || value.split(',').length <= 0) { return '' }
  313.           const checkboxItems = value.split(',')
  314.           return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  315.   
  316.         case 'datetime':
  317.           if (!value) { return '' }
  318.           return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  319.   
  320.         default: return value === null || value === undefined ? '' : value
  321.       }
  322.     }
  323.   
  324.   }
  325. }
  326. </script>
  327.   
  328.   
  329. <style lang="less" scoped>
  330. @import '~@/common/css/sidepage.less';
  331. @import '~@/common/css/customlist.less';
  332. </style>