選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

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