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.
 
 
 
 
 
 

332 lines
12 KiB

  1. <template>
  2.   <view class="page">
  3.     <view v-if="ready">
  4.       <l-input
  5.         @input="setValue('StuConsumption.ID', $event)"
  6.         :value="getValue('StuConsumption.ID')"
  7.         :disabled="!edit"
  8.         title="记录序号"
  9.       />
  10.       <l-input
  11.         @input="setValue('StuConsumption.ECODE', $event)"
  12.         :value="getValue('StuConsumption.ECODE')"
  13.         :disabled="!edit"
  14.         title="企业代码"
  15.       />
  16.       <l-input
  17.         @input="setValue('StuConsumption.NOTECASE', $event)"
  18.         :value="getValue('StuConsumption.NOTECASE')"
  19.         :disabled="!edit"
  20.         title="钱包类型"
  21.       />
  22.       <l-input
  23.         @input="setValue('StuConsumption.CUSTOMERID', $event)"
  24.         :value="getValue('StuConsumption.CUSTOMERID')"
  25.         :disabled="!edit"
  26.         title="一卡通账号"
  27.       />
  28.       <l-input
  29.         @input="setValue('StuConsumption.OUTID', $event)"
  30.         :value="getValue('StuConsumption.OUTID')"
  31.         :disabled="!edit"
  32.         title="学工号"
  33.       />
  34.       <l-input
  35.         @input="setValue('StuConsumption.CARDSN', $event)"
  36.         :value="getValue('StuConsumption.CARDSN')"
  37.         :disabled="!edit"
  38.         title="持卡序号"
  39.       />
  40.       <l-input
  41.         @input="setValue('StuConsumption.OPCOUNT', $event)"
  42.         :value="getValue('StuConsumption.OPCOUNT')"
  43.         :disabled="!edit"
  44.         title="消费卡操作计数"
  45.       />
  46.       <l-date-picker
  47.         @input="setValue('StuConsumption.OPDT', $event)"
  48.         :value="getValue('StuConsumption.OPDT')"
  49.         :disabled="!edit"
  50.         title="操作时间"
  51.       />
  52.       <l-input
  53.         @input="setValue('StuConsumption.ODDFARE', $event)"
  54.         :value="getValue('StuConsumption.ODDFARE')"
  55.         :disabled="!edit"
  56.         title="余额"
  57.       />
  58.       <l-input
  59.         @input="setValue('StuConsumption.OPFARE', $event)"
  60.         :value="getValue('StuConsumption.OPFARE')"
  61.         :disabled="!edit"
  62.         title="操作额"
  63.       />
  64.       <l-input
  65.         @input="setValue('StuConsumption.MNGFARE', $event)"
  66.         :value="getValue('StuConsumption.MNGFARE')"
  67.         :disabled="!edit"
  68.         title="管理费"
  69.       />
  70.       <l-input
  71.         @input="setValue('StuConsumption.ACCCODE', $event)"
  72.         :value="getValue('StuConsumption.ACCCODE')"
  73.         :disabled="!edit"
  74.         title="科目代码"
  75.       />
  76.       <l-input
  77.         @input="setValue('StuConsumption.DSCRP', $event)"
  78.         :value="getValue('StuConsumption.DSCRP')"
  79.         :disabled="!edit"
  80.         title="科目描述"
  81.       />
  82.       <l-input
  83.         @input="setValue('StuConsumption.TERMID', $event)"
  84.         :value="getValue('StuConsumption.TERMID')"
  85.         :disabled="!edit"
  86.         title="终端编号"
  87.       />
  88.       <l-input
  89.         @input="setValue('StuConsumption.RECNO', $event)"
  90.         :value="getValue('StuConsumption.RECNO')"
  91.         :disabled="!edit"
  92.         title="终端记录流水号"
  93.       />
  94.       <l-input
  95.         @input="setValue('StuConsumption.UPLOADDATE', $event)"
  96.         :value="getValue('StuConsumption.UPLOADDATE')"
  97.         :disabled="!edit"
  98.         title="上传时间"
  99.       />
  100.       <l-input
  101.         @input="setValue('StuConsumption.SAMCARDNO', $event)"
  102.         :value="getValue('StuConsumption.SAMCARDNO')"
  103.         :disabled="!edit"
  104.         title="SAM卡号"
  105.       />
  106.       <l-input
  107.         @input="setValue('StuConsumption.SAMTRADENO', $event)"
  108.         :value="getValue('StuConsumption.SAMTRADENO')"
  109.         :disabled="!edit"
  110.         title="SAM卡交易流水号"
  111.       />
  112.       <l-input
  113.         @input="setValue('StuConsumption.TRADECARDTYPE', $event)"
  114.         :value="getValue('StuConsumption.TRADECARDTYPE')"
  115.         :disabled="!edit"
  116.         title="交易卡类型"
  117.       />
  118.       <l-input
  119.         @input="setValue('StuConsumption.TAC', $event)"
  120.         :value="getValue('StuConsumption.TAC')"
  121.         :disabled="!edit"
  122.         title="验证码"
  123.       />
  124.       <l-input
  125.         @input="setValue('StuConsumption.ASN', $event)"
  126.         :value="getValue('StuConsumption.ASN')"
  127.         :disabled="!edit"
  128.         title="卡应用序列号"
  129.       />
  130.     </view>
  131.   
  132.     <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  133.       <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  134.         提交保存
  135.       </l-button>
  136.       <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
  137.         编辑本页
  138.       </l-button>
  139.       <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  140.         取消编辑
  141.       </l-button>
  142.       <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block>
  143.         删除
  144.       </l-button>
  145.     </view>
  146.   </view>
  147. </template>
  148.   
  149.   
  150. <script>
  151. /*
  152.  * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  153.  * Copyright (c) 2013-2020 上海力软信息技术有限公司
  154.  * 创建人:超级管理员
  155.  * 日  期:2020-10-16 15:16
  156.  * 描  述:学生消费信息
  157.  */
  158.   
  159. /**
  160.  * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  161.  * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  162.  * { "path": "pages/EducationalAdministration/StuConsumption/single", "style": { "navigationBarTitleText": "表单详情页" } }
  163.  * 
  164.  * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  165.  * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  166.  */
  167.   
  168. import get from 'lodash/get'
  169. import set from 'lodash/set'
  170. import moment from 'moment'
  171. import customPageMixins from '@/common/custompage.js'
  172.   
  173. export default {
  174.   mixins: [customPageMixins],
  175.   
  176.   data() {
  177.     return {
  178.       // 页面相关参数
  179.       id: null,
  180.       mode: null,
  181.       edit: null,
  182.       ready: false,
  183.   
  184.       // 表单数据
  185.       current: {},
  186.       origin: {},
  187.   
  188.       // 表单项数据结构
  189.       scheme: {
  190.         StuConsumption: {
  191.           ID: { type: 'text', title: '记录序号' },
  192.           ECODE: { type: 'text', title: '企业代码' },
  193.           NOTECASE: { type: 'text', title: '钱包类型' },
  194.           CUSTOMERID: { type: 'text', title: '一卡通账号' },
  195.           OUTID: { type: 'text', title: '学工号' },
  196.           CARDSN: { type: 'text', title: '持卡序号' },
  197.           OPCOUNT: { type: 'text', title: '消费卡操作计数' },
  198.           OPDT: { type: 'datetime', title: '操作时间', dateformat: '0' },
  199.           ODDFARE: { type: 'text', title: '余额' },
  200.           OPFARE: { type: 'text', title: '操作额' },
  201.           MNGFARE: { type: 'text', title: '管理费' },
  202.           ACCCODE: { type: 'text', title: '科目代码' },
  203.           DSCRP: { type: 'text', title: '科目描述' },
  204.           TERMID: { type: 'text', title: '终端编号' },
  205.           RECNO: { type: 'text', title: '终端记录流水号' },
  206.           UPLOADDATE: { type: 'text', title: '上传时间' },
  207.           SAMCARDNO: { type: 'text', title: 'SAM卡号' },
  208.           SAMTRADENO: { type: 'text', title: 'SAM卡交易流水号' },
  209.           TRADECARDTYPE: { type: 'text', title: '交易卡类型' },
  210.           TAC: { type: 'text', title: '验证码' },
  211.           ASN: { type: 'text', title: '卡应用序列号' },
  212.         },
  213.   
  214.       },
  215.   
  216.       // 数据源
  217.       dataSource: {
  218.         StuConsumption: {
  219.         },
  220.   
  221.       }
  222.     }
  223.   },
  224.   
  225.   async onLoad({ type, id }) {
  226.     await this.init(type, id)
  227.   },
  228.   
  229.   methods: {
  230.     // 页面初始化
  231.     async init(type, id) {
  232.       this.LOADING('加载数据中...')
  233.   
  234.       this.id = id
  235.       this.mode = type
  236.       this.edit = ['create', 'edit'].includes(this.mode)
  237.   
  238.       // 拉取表单数据,同时拉取所有来自数据源的选单数据
  239.       await Promise.all([
  240.   
  241.   
  242.         () => {}
  243.       ])
  244.       await this.fetchForm()
  245.   
  246.       this.ready = true
  247.       this.HIDE_LOADING()
  248.     },
  249.   
  250.     // 加载表单数据
  251.     async fetchForm() {
  252.       if (this.mode === 'create') {
  253.         this.origin = await this.getDefaultForm()
  254.       } else {
  255.         const result = await this.HTTP_GET('/EducationalAdministration/StuConsumption/form', this.id)
  256.         this.origin = await this.formatFormData(result)
  257.       }
  258.       this.current = this.COPY(this.origin)
  259.     },
  260.   
  261.     // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  262.     async action(type) {
  263.       switch (type) {
  264.         case 'edit':
  265.           this.edit = true
  266.           break
  267.   
  268.         case 'reset':
  269.           this.current = this.COPY(this.origin)
  270.           this.edit = false
  271.           break
  272.   
  273.         case 'save':
  274.           const verifyResult = this.verifyForm()
  275.           if (verifyResult.length > 0) {
  276.             this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  277.             return
  278.           }
  279.   
  280.           if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  281.             return
  282.           }
  283.   
  284.           this.LOADING('正在提交...')
  285.           const postData = await this.getPostData(this.id)
  286.   
  287.           this.HTTP_POST('/EducationalAdministration/StuConsumption/save', postData, '表单提交保存失败').then(success => {
  288.             this.HIDE_LOADING()
  289.             if (!success) {
  290.               return
  291.             }
  292.   
  293.             this.EMIT('EducationalAdministrationStuConsumption-list-change')
  294.             this.NAV_BACK()
  295.             this.TOAST('提交保存成功')
  296.           })
  297.           break
  298.   
  299.         case 'delete':
  300.           if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  301.             return
  302.           }
  303.   
  304.           this.LOADING('提交删除中...')
  305.           this.HTTP_POST('/EducationalAdministration/StuConsumption/delete', this.id, '删除失败').then(success => {
  306.             this.HIDE_LOADING()
  307.             if (!success) {
  308.               return
  309.             }
  310.   
  311.             this.EMIT('EducationalAdministrationStuConsumption-list-change')
  312.             this.NAV_BACK()
  313.             this.this.TOAST('删除成功', 'success')
  314.           })
  315.           break
  316.   
  317.         default: break
  318.       }
  319.     },
  320.   
  321.     // 获取表单值
  322.     getValue(path) {
  323.       return get(this.current, path)
  324.     },
  325.   
  326.     // 设置表单值
  327.     setValue(path, val) {
  328.       set(this.current, path, val)
  329.     }
  330.   }
  331. }
  332. </script>