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.
 
 
 
 
 
 

273 lines
8.4 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.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. await Promise.all([
  112. () => {}
  113. ])
  114. await this.fetchList()
  115. // 初始化查询条件
  116. this.defaultQueryData = this.COPY(this.queryData)
  117. this.ready = true
  118. },
  119. // 拉取列表
  120. async fetchList() {
  121. if (this.page > this.total) { return }
  122. const result = await this.HTTP_GET(
  123. 'learun/adms/EducationalAdministration/Journal/pagelist',
  124. {
  125. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  126. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  127. pagination: { rows: 10, page: this.page, sidx: 'JournalSendId', sord: 'DESC' },
  128. queryJson: JSON.stringify(this.searchData)
  129. },
  130. '加载数据时出错'
  131. )
  132. if (!result) { return }
  133. this.total = result.total
  134. this.page = result.page + 1
  135. this.list = this.list.concat(result.rows)
  136. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  137. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  138. },
  139. // 刷新清空列表
  140. async refreshList() {
  141. this.page = 1
  142. this.total = 2
  143. this.list = []
  144. await this.fetchList()
  145. },
  146. // 列表下拉
  147. pullDown() {
  148. this.refreshList().then(() => {
  149. this.$refs.list.stopPullDown()
  150. })
  151. },
  152. // 设置搜索条件
  153. async searchChange() {
  154. const result = {}
  155. // 将其他查询项添加到查询 JSON 中
  156. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  157. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  158. this.searchData = result
  159. await this.refreshList()
  160. },
  161. // 点击「清空查询条件」按钮
  162. reset() {
  163. this.queryData = this.COPY(this.defaultQueryData)
  164. this.searchChange()
  165. },
  166. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  167. async action(type, id = '') {
  168. switch (type) {
  169. case 'view':
  170. this.NAV_TO(`./single?type=view&id=${id}`)
  171. return
  172. case 'add':
  173. this.NAV_TO('./single?type=create')
  174. return
  175. case 'edit':
  176. this.NAV_TO(`./single?type=edit&id=${id}`)
  177. return
  178. case 'delete':
  179. if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  180. return
  181. }
  182. this.HTTP_POST('learun/adms/EducationalAdministration/Journal/delete', id, '删除失败').then(success => {
  183. if(!success) { return }
  184. this.TOAST('删除成功', 'success')
  185. this.refreshList()
  186. })
  187. return
  188. default:
  189. return
  190. }
  191. },
  192. // 显示列表中的标题项
  193. displayListItem(item, field) {
  194. const fieldItem = this.scheme[field]
  195. const value = item[field]
  196. switch (fieldItem.type) {
  197. case 'currentInfo':
  198. case 'organize':
  199. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  200. case 'radio':
  201. case 'select':
  202. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  203. return get(selectItem, 'text', '')
  204. case 'checkbox':
  205. if (!value || value.split(',').length <= 0) { return '' }
  206. const checkboxItems = value.split(',')
  207. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  208. case 'datetime':
  209. if (!value) { return '' }
  210. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  211. default: return value === null || value === undefined ? '' : value
  212. }
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="less" scoped>
  218. @import '~@/common/css/sidepage.less';
  219. @import '~@/common/css/customlist.less';
  220. </style>