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.

list.vue 15 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2.   <view class="page">
  3.     <view v-if="ready">
  4.       <l-date-picker
  5.         @input="setValue('StuInfoBasic.Birthday', $event)"
  6.         :value="getValue('StuInfoBasic.Birthday')"
  7.         :disabled="!edit"
  8.         title="出生日期"
  9.       />
  10.       <l-select
  11.         @input="setValue('StuInfoBasic.PartyFaceNo', $event)"
  12.         :value="getValue('StuInfoBasic.PartyFaceNo')"
  13.         :disabled="!edit"
  14.         :range="dataSource.StuInfoBasic.PartyFaceNo"
  15.         title="政治面貌"
  16.       />
  17.       <l-select
  18.         @input="setValue('StuInfoBasic.NationalityNo', $event)"
  19.         :value="getValue('StuInfoBasic.NationalityNo')"
  20.         :disabled="!edit"
  21.         :range="dataSource.StuInfoBasic.NationalityNo"
  22.         title="民族"
  23.       />
  24.       <l-select
  25.         @input="setValue('StuInfoBasic.ResidenceNo', $event)"
  26.         :value="getValue('StuInfoBasic.ResidenceNo')"
  27.         :disabled="!edit"
  28.         :range="dataSource.StuInfoBasic.ResidenceNo"
  29.         title="户口分类"
  30.       />
  31.       <l-upload-file
  32.         @input="setValue('StuInfoBasic.Photo', $event)"
  33.         :value="getValue('StuInfoBasic.Photo')"
  34.         :readonly="!edit"
  35.         :number="3"
  36.         title="照片"
  37.       />
  38.       <l-input
  39.         @input="setValue('StuInfoBasic.mobile', $event)"
  40.         :value="getValue('StuInfoBasic.mobile')"
  41.         :disabled="!edit"
  42.         title="联系电话"
  43.       />
  44.       <l-input
  45.         @input="setValue('StuInfoBasic.EMail', $event)"
  46.         :value="getValue('StuInfoBasic.EMail')"
  47.         :disabled="!edit"
  48.         title="邮箱"
  49.       />
  50.       <l-input
  51.         @input="setValue('StuInfoBasic.MailAddress', $event)"
  52.         :value="getValue('StuInfoBasic.MailAddress')"
  53.         :disabled="!edit"
  54.         title="通信地址"
  55.       />
  56.       <l-input
  57.         @input="setValue('StuInfoBasic.PostalCode', $event)"
  58.         :value="getValue('StuInfoBasic.PostalCode')"
  59.         :disabled="!edit"
  60.         title="邮政编码"
  61.       />
  62.       <l-input
  63.         @input="setValue('StuInfoBasic.FatherUnit', $event)"
  64.         :value="getValue('StuInfoBasic.FatherUnit')"
  65.         :disabled="!edit"
  66.         title="户口所在地"
  67.       />
  68.       <l-input
  69.         @input="setValue('StuInfoBasic.MatherUnit', $event)"
  70.         :value="getValue('StuInfoBasic.MatherUnit')"
  71.         :disabled="!edit"
  72.         title="档案所在地"
  73.       />
  74.       <l-input
  75.         @input="setValue('StuInfoBasic.FatherName', $event)"
  76.         :value="getValue('StuInfoBasic.FatherName')"
  77.         :disabled="!edit"
  78.         title="父亲名字"
  79.       />
  80.       <l-input
  81.         @input="setValue('StuInfoBasic.FatherPhone', $event)"
  82.         :value="getValue('StuInfoBasic.FatherPhone')"
  83.         :disabled="!edit"
  84.         title="父亲电话"
  85.         required
  86.       />
  87.       <l-input
  88.         @input="setValue('StuInfoBasic.MatherName', $event)"
  89.         :value="getValue('StuInfoBasic.MatherName')"
  90.         :disabled="!edit"
  91.         title="母亲名字"
  92.       />
  93.       <l-input
  94.         @input="setValue('StuInfoBasic.MatherPhone', $event)"
  95.         :value="getValue('StuInfoBasic.MatherPhone')"
  96.         :disabled="!edit"
  97.         title="母亲电话"
  98.       />
  99.       <l-select
  100.         @input="setValue('StuInfoBasic.FamilyOriginNo', $event)"
  101.         :value="getValue('StuInfoBasic.FamilyOriginNo')"
  102.         :disabled="!edit"
  103.         :range="dataSource.StuInfoBasic.FamilyOriginNo"
  104.         title="家庭出生"
  105.       />
  106.       <l-select
  107.         @input="setValue('StuInfoBasic.OverseasChineseNo', $event)"
  108.         :value="getValue('StuInfoBasic.OverseasChineseNo')"
  109.         :disabled="!edit"
  110.         :range="dataSource.StuInfoBasic.OverseasChineseNo"
  111.         title="港澳台侨"
  112.       />
  113.       <l-select
  114.         @input="setValue('StuInfoBasic.GraduateNo', $event)"
  115.         :value="getValue('StuInfoBasic.GraduateNo')"
  116.         :disabled="!edit"
  117.         :range="dataSource.StuInfoBasic.GraduateNo"
  118.         title="本专科"
  119.       />
  120.       <l-input
  121.         @input="setValue('StuInfoBasic.InSchoolAddress', $event)"
  122.         :value="getValue('StuInfoBasic.InSchoolAddress')"
  123.         :disabled="!edit"
  124.         title="校内地址"
  125.       />
  126.       <l-input
  127.         @input="setValue('StuInfoBasic.InSchoolTelephone', $event)"
  128.         :value="getValue('StuInfoBasic.InSchoolTelephone')"
  129.         :disabled="!edit"
  130.         title="校内电话"
  131.       />
  132.       <l-input
  133.         @input="setValue('StuInfoBasic.QQ', $event)"
  134.         :value="getValue('StuInfoBasic.QQ')"
  135.         :disabled="!edit"
  136.         title="QQ"
  137.       />
  138.       <l-textarea
  139.         @input="setValue('StuInfoBasic.GoodAt', $event)"
  140.         :value="getValue('StuInfoBasic.GoodAt')"
  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-15 10:16
  170.  * 描  述:个人信息
  171.  */
  172.   
  173. /**
  174.  * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  175.  * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  176.  * { "path": "pages/EducationalAdministration/StuInfoBasic/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.         StuInfoBasic: {
  205.           Birthday: { type: 'text', title: '出生日期', dateformat: '0' },
  206.           PartyFaceNo: { type: 'select', title: '政治面貌', dataSource: '1', dataSourceId: 'BCdPartyFace,partyface,partyfaceno' },
  207.           NationalityNo: { type: 'select', title: '民族', itemCode: 'National', dataSource: '0' },
  208.           ResidenceNo: { type: 'select', title: '户口分类', itemCode: 'ResidenceNo', dataSource: '0' },
  209.           Photo: { type: 'upload', title: '照片' },
  210.           mobile: { type: 'text', title: '联系电话' },
  211.           EMail: { type: 'text', title: '邮箱' },
  212.           MailAddress: { type: 'text', title: '通信地址' },
  213.           PostalCode: { type: 'text', title: '邮政编码' },
  214.           FatherUnit: { type: 'text', title: '户口所在地' },
  215.           MatherUnit: { type: 'text', title: '档案所在地' },
  216.           FatherName: { type: 'text', title: '父亲名字' },
  217.           FatherPhone: { type: 'text', title: '父亲电话', verify: 'PhoneOrNull' },
  218.           MatherName: { type: 'text', title: '母亲名字' },
  219.           MatherPhone: { type: 'text', title: '母亲电话' },
  220.           FamilyOriginNo: { type: 'select', title: '家庭出生', dataSource: '1', dataSourceId: 'BCdFamilyOrigin,familyorigin,familyoriginno' },
  221.           OverseasChineseNo: { type: 'select', title: '港澳台侨', dataSource: '1', dataSourceId: 'BCdOverseasChinese,overseaschinesename,overseaschineseno' },
  222.           GraduateNo: { type: 'select', title: '本专科', itemCode: 'CollegeType', dataSource: '0' },
  223.           InSchoolAddress: { type: 'text', title: '校内地址' },
  224.           InSchoolTelephone: { type: 'text', title: '校内电话' },
  225.           QQ: { type: 'text', title: 'QQ' },
  226.           GoodAt: { type: 'textarea', title: '特长' },
  227.         },
  228.   
  229.       },
  230.   
  231.       // 数据源
  232.       dataSource: {
  233.         StuInfoBasic: {
  234.           PartyFaceNo: [],
  235.           NationalityNo: Object.values(this.GET_GLOBAL('dataDictionary').National).map(t => ({ value: t.value, text: t.text })),
  236.           ResidenceNo: Object.values(this.GET_GLOBAL('dataDictionary').ResidenceNo).map(t => ({ value: t.value, text: t.text })),
  237.           FamilyOriginNo: [],
  238.           OverseasChineseNo: [],
  239.           GraduateNo: Object.values(this.GET_GLOBAL('dataDictionary').CollegeType).map(t => ({ value: t.value, text: t.text })),
  240.         },
  241.   
  242.       }
  243.     }
  244.   },
  245.   
  246.   async onLoad({ type, id }) {
  247. let account=this.GET_GLOBAL('loginUser').account;
  248. console.log(this.GET_GLOBAL('loginUser'));
  249. let stuInfo = await this.HTTP_GET('/EducationalAdministration/StuInfoBasic/stuinfo', account)
  250. id=stuInfo.StuId;
  251.     await this.init(type, id)
  252.   },
  253.   
  254.   methods: {
  255.     // 页面初始化
  256.     async init(type, id) {
  257.       this.LOADING('加载数据中...')
  258.   
  259.       this.id = id
  260.       this.mode = type
  261.       this.edit = ['create', 'edit'].includes(this.mode)
  262.   
  263.       // 拉取表单数据,同时拉取所有来自数据源的选单数据
  264.       await Promise.all([
  265.         this.FETCH_DATASOURCE('BCdPartyFace').then(result => {
  266.           this.dataSource.StuInfoBasic.PartyFaceNo = result.data.map(t => ({ text: t.partyface, value: t.partyfaceno }))
  267.         }),
  268.         this.FETCH_DATASOURCE('BCdFamilyOrigin').then(result => {
  269.           this.dataSource.StuInfoBasic.FamilyOriginNo = result.data.map(t => ({ text: t.familyorigin, value: t.familyoriginno }))
  270.         }),
  271.         this.FETCH_DATASOURCE('BCdOverseasChinese').then(result => {
  272.           this.dataSource.StuInfoBasic.OverseasChineseNo = result.data.map(t => ({ text: t.overseaschinesename, value: t.overseaschineseno }))
  273.         }),
  274.   
  275.   
  276.         () => {}
  277.       ])
  278.       await this.fetchForm()
  279.   
  280.       this.ready = true
  281.       this.HIDE_LOADING()
  282.     },
  283.   
  284.     // 加载表单数据
  285.     async fetchForm() {
  286.       if (this.mode === 'create') {
  287.         this.origin = await this.getDefaultForm()
  288.       } else {
  289.         const result = await this.HTTP_GET('/EducationalAdministration/StuInfoBasic/form', this.id)
  290.         this.origin = await this.formatFormData(result)
  291.       }
  292.       this.current = this.COPY(this.origin)
  293.     },
  294.   
  295.     // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  296.     async action(type) {
  297.       switch (type) {
  298.         case 'edit':
  299.           this.edit = true
  300.           break
  301.   
  302.         case 'reset':
  303.           this.current = this.COPY(this.origin)
  304.           this.edit = false
  305.           break
  306.   
  307.         case 'save':
  308.           const verifyResult = this.verifyForm()
  309.           if (verifyResult.length > 0) {
  310.             this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  311.             return
  312.           }
  313.   
  314.           if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  315.             return
  316.           }
  317.   
  318.           this.LOADING('正在提交...')
  319.           const postData = await this.getPostData(this.id)
  320.   
  321.           this.HTTP_POST('/EducationalAdministration/StuInfoBasic/save', postData, '表单提交保存失败').then(success => {
  322.             this.HIDE_LOADING()
  323.             if (!success) {
  324.               return
  325.             }
  326.   
  327.             this.EMIT('EducationalAdministrationStuInfoBasic-list-change')
  328.             this.NAV_BACK()
  329.             this.TOAST('提交保存成功')
  330.           })
  331.           break
  332.   
  333.         case 'delete':
  334.           if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  335.             return
  336.           }
  337.   
  338.           this.LOADING('提交删除中...')
  339.           this.HTTP_POST('/EducationalAdministration/StuInfoBasic/delete', this.id, '删除失败').then(success => {
  340.             this.HIDE_LOADING()
  341.             if (!success) {
  342.               return
  343.             }
  344.   
  345.             this.EMIT('EducationalAdministrationStuInfoBasic-list-change')
  346.             this.NAV_BACK()
  347.             this.this.TOAST('删除成功', 'success')
  348.           })
  349.           break
  350.   
  351.         default: break
  352.       }
  353.     },
  354.   
  355.     // 获取表单值
  356.     getValue(path) {
  357.       return get(this.current, path)
  358.     },
  359.   
  360.     // 设置表单值
  361.     setValue(path, val) {
  362.       set(this.current, path, val)
  363.     }
  364.   }
  365. }
  366. </script>