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.
 
 
 
 
 
 

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