|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <template>
- <view class="page">
- <view v-if="ready">
- <l-date-picker
- @input="setValue('StuInfoBasic.Birthday', $event)"
- :value="getValue('StuInfoBasic.Birthday')"
- :disabled="!edit"
- title="出生日期"
- />
- <l-select
- @input="setValue('StuInfoBasic.PartyFaceNo', $event)"
- :value="getValue('StuInfoBasic.PartyFaceNo')"
- :disabled="!edit"
- :range="dataSource.StuInfoBasic.PartyFaceNo"
- title="政治面貌"
- />
- <l-select
- @input="setValue('StuInfoBasic.NationalityNo', $event)"
- :value="getValue('StuInfoBasic.NationalityNo')"
- :disabled="!edit"
- :range="dataSource.StuInfoBasic.NationalityNo"
- title="民族"
- />
- <l-select
- @input="setValue('StuInfoBasic.ResidenceNo', $event)"
- :value="getValue('StuInfoBasic.ResidenceNo')"
- :disabled="!edit"
- :range="dataSource.StuInfoBasic.ResidenceNo"
- title="户口分类"
- />
- <l-upload-file
- @input="setValue('StuInfoBasic.Photo', $event)"
- :value="getValue('StuInfoBasic.Photo')"
- :readonly="!edit"
- :number="3"
- title="照片"
- />
- <l-input
- @input="setValue('StuInfoBasic.mobile', $event)"
- :value="getValue('StuInfoBasic.mobile')"
- :disabled="!edit"
- title="联系电话"
- />
- <l-input
- @input="setValue('StuInfoBasic.EMail', $event)"
- :value="getValue('StuInfoBasic.EMail')"
- :disabled="!edit"
- title="邮箱"
- />
- <l-input
- @input="setValue('StuInfoBasic.MailAddress', $event)"
- :value="getValue('StuInfoBasic.MailAddress')"
- :disabled="!edit"
- title="通信地址"
- />
- <l-input
- @input="setValue('StuInfoBasic.PostalCode', $event)"
- :value="getValue('StuInfoBasic.PostalCode')"
- :disabled="!edit"
- title="邮政编码"
- />
- <l-input
- @input="setValue('StuInfoBasic.FatherUnit', $event)"
- :value="getValue('StuInfoBasic.FatherUnit')"
- :disabled="!edit"
- title="户口所在地"
- />
- <l-input
- @input="setValue('StuInfoBasic.MatherUnit', $event)"
- :value="getValue('StuInfoBasic.MatherUnit')"
- :disabled="!edit"
- title="档案所在地"
- />
- <l-input
- @input="setValue('StuInfoBasic.FatherName', $event)"
- :value="getValue('StuInfoBasic.FatherName')"
- :disabled="!edit"
- title="父亲名字"
- />
- <l-input
- @input="setValue('StuInfoBasic.FatherPhone', $event)"
- :value="getValue('StuInfoBasic.FatherPhone')"
- :disabled="!edit"
- title="父亲电话"
- required
- />
- <l-input
- @input="setValue('StuInfoBasic.MatherName', $event)"
- :value="getValue('StuInfoBasic.MatherName')"
- :disabled="!edit"
- title="母亲名字"
- />
- <l-input
- @input="setValue('StuInfoBasic.MatherPhone', $event)"
- :value="getValue('StuInfoBasic.MatherPhone')"
- :disabled="!edit"
- title="母亲电话"
- />
- <l-select
- @input="setValue('StuInfoBasic.FamilyOriginNo', $event)"
- :value="getValue('StuInfoBasic.FamilyOriginNo')"
- :disabled="!edit"
- :range="dataSource.StuInfoBasic.FamilyOriginNo"
- title="家庭出生"
- />
- <l-select
- @input="setValue('StuInfoBasic.OverseasChineseNo', $event)"
- :value="getValue('StuInfoBasic.OverseasChineseNo')"
- :disabled="!edit"
- :range="dataSource.StuInfoBasic.OverseasChineseNo"
- title="港澳台侨"
- />
- <l-select
- @input="setValue('StuInfoBasic.GraduateNo', $event)"
- :value="getValue('StuInfoBasic.GraduateNo')"
- :disabled="!edit"
- :range="dataSource.StuInfoBasic.GraduateNo"
- title="本专科"
- />
- <l-input
- @input="setValue('StuInfoBasic.InSchoolAddress', $event)"
- :value="getValue('StuInfoBasic.InSchoolAddress')"
- :disabled="!edit"
- title="校内地址"
- />
- <l-input
- @input="setValue('StuInfoBasic.InSchoolTelephone', $event)"
- :value="getValue('StuInfoBasic.InSchoolTelephone')"
- :disabled="!edit"
- title="校内电话"
- />
- <l-input
- @input="setValue('StuInfoBasic.QQ', $event)"
- :value="getValue('StuInfoBasic.QQ')"
- :disabled="!edit"
- title="QQ"
- />
- <l-textarea
- @input="setValue('StuInfoBasic.GoodAt', $event)"
- :value="getValue('StuInfoBasic.GoodAt')"
- :readonly="!edit"
- title="特长"
- />
- </view>
-
- <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
- <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
- 提交保存
- </l-button>
- <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
- 编辑本页
- </l-button>
- <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
- 取消编辑
- </l-button>
- <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block>
- 删除
- </l-button>
- </view>
- </view>
- </template>
-
-
- <script>
- /*
- * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
- * Copyright (c) 2013-2020 上海力软信息技术有限公司
- * 创建人:超级管理员
- * 日 期:2020-10-15 10:16
- * 描 述:个人信息
- */
-
- /**
- * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
- * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
- * { "path": "pages/EducationalAdministration/StuInfoBasic/single", "style": { "navigationBarTitleText": "表单详情页" } }
- *
- * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
- * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
- */
-
- import get from 'lodash/get'
- import set from 'lodash/set'
- import moment from 'moment'
- import customPageMixins from '@/common/custompage.js'
-
- export default {
- mixins: [customPageMixins],
-
- data() {
- return {
- // 页面相关参数
- id: null,
- mode: null,
- edit: null,
- ready: false,
-
- // 表单数据
- current: {},
- origin: {},
-
- // 表单项数据结构
- scheme: {
- StuInfoBasic: {
- Birthday: { type: 'text', title: '出生日期', dateformat: '0' },
- PartyFaceNo: { type: 'select', title: '政治面貌', dataSource: '1', dataSourceId: 'BCdPartyFace,partyface,partyfaceno' },
- NationalityNo: { type: 'select', title: '民族', itemCode: 'National', dataSource: '0' },
- ResidenceNo: { type: 'select', title: '户口分类', itemCode: 'ResidenceNo', dataSource: '0' },
- Photo: { type: 'upload', title: '照片' },
- mobile: { type: 'text', title: '联系电话' },
- EMail: { type: 'text', title: '邮箱' },
- MailAddress: { type: 'text', title: '通信地址' },
- PostalCode: { type: 'text', title: '邮政编码' },
- FatherUnit: { type: 'text', title: '户口所在地' },
- MatherUnit: { type: 'text', title: '档案所在地' },
- FatherName: { type: 'text', title: '父亲名字' },
- FatherPhone: { type: 'text', title: '父亲电话', verify: 'PhoneOrNull' },
- MatherName: { type: 'text', title: '母亲名字' },
- MatherPhone: { type: 'text', title: '母亲电话' },
- FamilyOriginNo: { type: 'select', title: '家庭出生', dataSource: '1', dataSourceId: 'BCdFamilyOrigin,familyorigin,familyoriginno' },
- OverseasChineseNo: { type: 'select', title: '港澳台侨', dataSource: '1', dataSourceId: 'BCdOverseasChinese,overseaschinesename,overseaschineseno' },
- GraduateNo: { type: 'select', title: '本专科', itemCode: 'CollegeType', dataSource: '0' },
- InSchoolAddress: { type: 'text', title: '校内地址' },
- InSchoolTelephone: { type: 'text', title: '校内电话' },
- QQ: { type: 'text', title: 'QQ' },
- GoodAt: { type: 'textarea', title: '特长' },
- },
-
- },
-
- // 数据源
- dataSource: {
- StuInfoBasic: {
- PartyFaceNo: [],
- NationalityNo: Object.values(this.GET_GLOBAL('dataDictionary').National).map(t => ({ value: t.value, text: t.text })),
- ResidenceNo: Object.values(this.GET_GLOBAL('dataDictionary').ResidenceNo).map(t => ({ value: t.value, text: t.text })),
- FamilyOriginNo: [],
- OverseasChineseNo: [],
- GraduateNo: Object.values(this.GET_GLOBAL('dataDictionary').CollegeType).map(t => ({ value: t.value, text: t.text })),
- },
-
- }
- }
- },
-
- async onLoad({ type, id }) {
- let account=this.GET_GLOBAL('loginUser').account;
- console.log(this.GET_GLOBAL('loginUser'));
- let stuInfo = await this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/stuinfo', account)
- id=stuInfo.StuId;
-
- await this.init(type, id)
- // this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/stuinfo', account).then(res => {
- // console.log(res)
- // })
- },
-
- methods: {
- // 页面初始化
- async init(type, id) {
- this.LOADING('加载数据中...')
-
- this.id = id
- this.mode = type
- this.edit = ['create', 'edit'].includes(this.mode)
-
- // 拉取表单数据,同时拉取所有来自数据源的选单数据
- await Promise.all([
- this.FETCH_DATASOURCE('BCdPartyFace').then(result => {
- this.dataSource.StuInfoBasic.PartyFaceNo = result.data.map(t => ({ text: t.partyface, value: t.partyfaceno }))
- }),
- this.FETCH_DATASOURCE('BCdFamilyOrigin').then(result => {
- this.dataSource.StuInfoBasic.FamilyOriginNo = result.data.map(t => ({ text: t.familyorigin, value: t.familyoriginno }))
- }),
- this.FETCH_DATASOURCE('BCdOverseasChinese').then(result => {
- this.dataSource.StuInfoBasic.OverseasChineseNo = result.data.map(t => ({ text: t.overseaschinesename, value: t.overseaschineseno }))
- }),
-
-
- () => {}
- ])
- await this.fetchForm()
-
- this.ready = true
- this.HIDE_LOADING()
- },
-
- // 加载表单数据
- async fetchForm() {
- if (this.mode === 'create') {
- this.origin = await this.getDefaultForm()
- } else {
- const result = await this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/form', this.id)
- this.origin = await this.formatFormData(result)
- }
- this.current = this.COPY(this.origin)
- },
-
- // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
- async action(type) {
- switch (type) {
- case 'edit':
- this.edit = true
- break
-
- case 'reset':
- this.current = this.COPY(this.origin)
- this.edit = false
- break
-
- case 'save':
- const verifyResult = this.verifyForm()
- if (verifyResult.length > 0) {
- this.CONFIRM('表单验证失败', verifyResult.join('\n'))
- return
- }
-
- if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
- return
- }
-
- this.LOADING('正在提交...')
- const postData = await this.getPostData(this.id)
-
- this.HTTP_POST('learun/adms/EducationalAdministration/StuInfoBasic/save', postData, '表单提交保存失败').then(success => {
- this.HIDE_LOADING()
- if (!success) {
- return
- }
-
- this.EMIT('EducationalAdministrationStuInfoBasic-list-change')
- this.NAV_BACK()
- this.TOAST('提交保存成功')
- })
- break
-
- case 'delete':
- if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
- return
- }
-
- this.LOADING('提交删除中...')
- this.HTTP_POST('learun/adms/EducationalAdministration/StuInfoBasic/delete', this.id, '删除失败').then(success => {
- this.HIDE_LOADING()
- if (!success) {
- return
- }
-
- this.EMIT('EducationalAdministrationStuInfoBasic-list-change')
- this.NAV_BACK()
- this.this.TOAST('删除成功', 'success')
- })
- break
-
- default: break
- }
- },
-
- // 获取表单值
- getValue(path) {
- return get(this.current, path)
- },
-
- // 设置表单值
- setValue(path, val) {
- set(this.current, path, val)
- }
- }
- }
- </script>
|