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.
 
 
 
 
 
 

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