您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

275 行
8.6 KiB

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