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.

single.vue 14 KiB

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