Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

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