Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

266 lignes
8.0 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 主列表页 -->
  4. <view :class="sideOpen ? 'show' : ''" class="mainpage" style="padding-top: 80rpx;">
  5. <!-- 顶部条目/分页信息栏 -->
  6. <l-customlist-banner >{{ 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, 'CommunityId') }}
  15. </view> -->
  16. <view class="customlist-item-field">
  17. <text class="customlist-item-field-title">社团名称:</text>
  18. {{ displayListItem(item, 'CommunityId') }}
  19. </view>
  20. <view class="customlist-item-field">
  21. <text class="customlist-item-field-title">加入时间:</text>
  22. {{ displayListItem(item, 'JoinTime') }}
  23. </view>
  24. <!-- <l-customlist-action @view="action('view', item.Id)" /> -->
  25. </view>
  26. </l-customlist>
  27. </l-scroll-list>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. /*
  33. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  34. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  35. * 创建人:超级管理员
  36. * 日 期:2020-10-14 16:08
  37. * 描 述:社团管理
  38. */
  39. /**
  40. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  41. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  42. * { "path": "pages/PersonnelManagement/CommunityInfo/list", "style": { "navigationBarTitleText": "表单列表页" } }
  43. *
  44. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  45. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  46. */
  47. import moment from 'moment'
  48. import get from 'lodash/get'
  49. import set from 'lodash/set'
  50. import pickBy from 'lodash/pickBy'
  51. import mapValues from 'lodash/mapValues'
  52. export default {
  53. data() {
  54. return {
  55. // 数据项的数据类型、结构
  56. scheme: {
  57. CommunityId: { type: 'select' },
  58. CommunityName: { type: 'text' },
  59. Sort: { type: 'text' },
  60. JoinTime: { type: 'text' },
  61. },
  62. // 查询条件
  63. searchData: {},
  64. defaultQueryData: {},
  65. queryData: {
  66. },
  67. // 数据源
  68. dataSource: {
  69. CommunityId: [],
  70. CommunityName: []
  71. },
  72. // 页面相关参数
  73. ready: false,
  74. tips: '加载中...',
  75. loadState: '向下翻以加载更多',
  76. sideOpen: false,
  77. // 列表与分页信息
  78. page: 1,
  79. total: 2,
  80. list: []
  81. }
  82. },
  83. async onLoad() {
  84. await this.init()
  85. },
  86. onUnload() {
  87. this.OFF('PersonnelManagementCommunityCode-list-change')
  88. },
  89. methods: {
  90. // 页面初始化
  91. async init() {
  92. this.ON('PersonnelManagementCommunityCode-list-change', this.refreshList)
  93. // 拉取加载列表和数据源
  94. await Promise.all([
  95. this.FETCH_DATASOURCE('CommunityInfo').then(data => {
  96. console.log(data)
  97. this.dataSource.CommunityId = data.data.map(t => ({
  98. text: t.communityname,
  99. value: t.id
  100. }));
  101. }),
  102. () => {}
  103. ])
  104. await this.fetchList()
  105. // 初始化查询条件
  106. this.defaultQueryData = this.COPY(this.queryData)
  107. this.ready = true
  108. },
  109. // 拉取列表
  110. async fetchList() {
  111. if (this.page > this.total) { return }
  112. const result = await this.HTTP_GET(
  113. 'learun/adms/PersonnelManagement/CommunityInfo/communityMemberpagelist',
  114. {
  115. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  116. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  117. pagination: { rows: 10, page: this.page, sidx: 'Id', sord: 'DESC' },
  118. queryJson: JSON.stringify(this.searchData)
  119. },
  120. '加载数据时出错'
  121. )
  122. if (!result) { return }
  123. this.total = result.total
  124. this.page = result.page + 1
  125. this.list = this.list.concat(result.rows)
  126. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  127. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  128. },
  129. // 刷新清空列表
  130. async refreshList() {
  131. this.page = 1
  132. this.total = 2
  133. this.list = []
  134. await this.fetchList()
  135. },
  136. // 列表下拉
  137. pullDown() {
  138. this.refreshList().then(() => {
  139. this.$refs.list.stopPullDown()
  140. })
  141. },
  142. // 设置搜索条件
  143. async searchChange() {
  144. const result = {}
  145. // 将其他查询项添加到查询 JSON 中
  146. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  147. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  148. this.searchData = result
  149. await this.refreshList()
  150. },
  151. // 点击「清空查询条件」按钮
  152. reset() {
  153. this.queryData = this.COPY(this.defaultQueryData)
  154. this.searchChange()
  155. },
  156. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  157. async action(type, id = '') {
  158. switch (type) {
  159. case 'view':
  160. this.NAV_TO(`./single?type=view&id=${id}`)
  161. return
  162. case 'add':
  163. this.NAV_TO('./single?type=create')
  164. return
  165. case 'edit':
  166. this.NAV_TO(`./single?type=edit&id=${id}`)
  167. return
  168. case 'join':
  169. if (!(await this.CONFIRM('申请加入', '确定要申请加入该社团吗?', true))) {
  170. return
  171. }
  172. this.HTTP_POST('learun/adms/PersonnelManagement/CommunityInfo/join', id, '加入失败').then(success => {
  173. if(!success) { return }
  174. this.TOAST('加入成功', 'success')
  175. this.refreshList()
  176. })
  177. return
  178. case 'delete':
  179. if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  180. return
  181. }
  182. this.HTTP_POST('learun/adms/PersonnelManagement/CommunityInfo/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>