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.
 
 
 
 
 
 

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