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