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.
 
 
 
 
 
 

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