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.
 
 
 
 
 
 

321 lines
9.8 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, 'MeetingTitle') }}
  15. </view>
  16. <view class="customlist-item-field">
  17. <text class="customlist-item-field-title">会议地点:</text>
  18. {{ displayListItem(item, 'MeetingPlace') }}
  19. </view>
  20. <view class="customlist-item-field">
  21. <text class="customlist-item-field-title">开始时间:</text>
  22. {{ displayListItem(item, 'BeginTime') }}
  23. </view>
  24. <view class="customlist-item-field">
  25. <text class="customlist-item-field-title">结束时间:</text>
  26. {{ displayListItem(item, 'EndTime') }}
  27. </view>
  28. <view class="customlist-item-field">
  29. <text class="customlist-item-field-title">申请人:</text>
  30. {{ displayListItem(item, 'CreateUser') }}
  31. </view>
  32. <view class="customlist-item-field">
  33. <text class="customlist-item-field-title">会议记录者:</text>
  34. {{ displayListItem(item, 'RecordPerson') }}
  35. </view>
  36. <view class="customlist-item-field">
  37. <text class="customlist-item-field-title">会议内容:</text>
  38. {{ displayListItem(item, 'Content') }}
  39. </view>
  40. <view class="customlist-item-field">
  41. <text class="customlist-item-field-title">附件上传:</text>
  42. {{ displayListItem(item, 'Files') }}
  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-input
  57. v-model="queryData.MeetingTitle"
  58. @change="searchChange"
  59. title ="会议主题"
  60. placeholder="按会议主题查询"
  61. />
  62. <l-select
  63. v-model="queryData.MeetingPlace"
  64. @change="searchChange"
  65. :range="dataSource.MeetingPlace"
  66. title ="会议地点"
  67. placeholder="按会议地点查询"
  68. />
  69. <l-organize-picker
  70. v-model="queryData.CreateUser"
  71. @change="searchChange"
  72. type="user"
  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-2021 上海力软信息技术有限公司
  89. * 创建人:超级管理员
  90. * 日 期:2021-02-21 10:07
  91. * 描 述:会议管理
  92. */
  93. /**
  94. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  95. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  96. * { "path": "pages/PersonnelManagement/MeetingManagement/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. MeetingTitle: { type: 'text' },
  112. MeetingPlace: { type: 'select', dataSource: '0' },
  113. BeginTime: { type: 'datetime', dateformat: '0' },
  114. EndTime: { type: 'datetime', dateformat: '0' },
  115. RecordPerson: { type: 'organize', dataType: 'user' },
  116. Content: { type: 'texteditor' },
  117. Files: { type: 'upload' },
  118. CreateUser: { type: 'organize', dataType: 'user' },
  119. },
  120. // 查询条件
  121. searchData: {},
  122. defaultQueryData: {},
  123. queryData: {
  124. MeetingTitle: '',
  125. MeetingPlace: '',
  126. CreateUser: '',
  127. },
  128. // 数据源
  129. dataSource: {
  130. MeetingPlace: [],
  131. },
  132. // 页面相关参数
  133. ready: false,
  134. tips: '加载中...',
  135. loadState: '向下翻以加载更多',
  136. sideOpen: false,
  137. // 列表与分页信息
  138. page: 1,
  139. total: 2,
  140. list: []
  141. }
  142. },
  143. async onLoad() {
  144. await this.init()
  145. },
  146. onUnload() {
  147. this.OFF('PersonnelManagementMeetingManagement-list-change')
  148. },
  149. methods: {
  150. // 页面初始化
  151. async init() {
  152. this.ON('PersonnelManagementMeetingManagement-list-change', this.refreshList)
  153. // 拉取加载列表和数据源
  154. await Promise.all([
  155. () => {}
  156. ])
  157. await this.fetchList()
  158. // 初始化查询条件
  159. this.defaultQueryData = this.COPY(this.queryData)
  160. this.ready = true
  161. },
  162. // 拉取列表
  163. async fetchList() {
  164. if (this.page > this.total) { return }
  165. const result = await this.HTTP_GET(
  166. '/PersonnelManagement/MeetingManagement/pagelist',
  167. {
  168. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  169. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  170. pagination: { rows: 10, page: this.page, sidx: 'Id', sord: 'DESC' },
  171. queryJson: JSON.stringify(this.searchData)
  172. },
  173. '加载数据时出错'
  174. )
  175. if (!result) { return }
  176. this.total = result.total
  177. this.page = result.page + 1
  178. this.list = this.list.concat(result.rows)
  179. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  180. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  181. },
  182. // 刷新清空列表
  183. async refreshList() {
  184. this.page = 1
  185. this.total = 2
  186. this.list = []
  187. await this.fetchList()
  188. },
  189. // 列表下拉
  190. pullDown() {
  191. this.refreshList().then(() => {
  192. this.$refs.list.stopPullDown()
  193. })
  194. },
  195. // 设置搜索条件
  196. async searchChange() {
  197. const result = {}
  198. // 将其他查询项添加到查询 JSON 中
  199. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  200. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  201. this.searchData = result
  202. await this.refreshList()
  203. },
  204. // 点击「清空查询条件」按钮
  205. reset() {
  206. this.queryData = this.COPY(this.defaultQueryData)
  207. this.searchChange()
  208. },
  209. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  210. async action(type, id = '') {
  211. switch (type) {
  212. case 'view':
  213. this.NAV_TO(`./single?type=view&id=${id}`)
  214. return
  215. case 'add':
  216. this.NAV_TO('./single?type=create')
  217. return
  218. case 'edit':
  219. this.NAV_TO(`./single?type=edit&id=${id}`)
  220. return
  221. case 'delete':
  222. if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  223. return
  224. }
  225. this.HTTP_POST('/PersonnelManagement/MeetingManagement/delete', id, '删除失败').then(success => {
  226. if(!success) { return }
  227. this.TOAST('删除成功', 'success')
  228. this.refreshList()
  229. })
  230. return
  231. default:
  232. return
  233. }
  234. },
  235. // 显示列表中的标题项
  236. displayListItem(item, field) {
  237. const fieldItem = this.scheme[field]
  238. const value = item[field]
  239. switch (fieldItem.type) {
  240. case 'currentInfo':
  241. case 'organize':
  242. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  243. case 'radio':
  244. case 'select':
  245. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  246. return get(selectItem, 'text', '')
  247. case 'checkbox':
  248. if (!value || value.split(',').length <= 0) { return '' }
  249. const checkboxItems = value.split(',')
  250. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  251. case 'datetime':
  252. if (!value) { return '' }
  253. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  254. default: return value === null || value === undefined ? '' : value
  255. }
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="less" scoped>
  261. @import '~@/common/css/sidepage.less';
  262. @import '~@/common/css/customlist.less';
  263. </style>