|
- <template>
- <view class="page">
- <view v-if="ready">
- <l-select
- @input="setValue('StuGraduateStatistic.GraduateGo', $event)"
- :value="getValue('StuGraduateStatistic.GraduateGo')"
- :disabled="!edit"
- :range="dataSource.StuGraduateStatistic.GraduateGo"
- title="毕业去向"
- required
- />
- <l-input
- @input="setValue('StuGraduateStatistic.EnterUniversityName', $event)"
- :value="getValue('StuGraduateStatistic.EnterUniversityName')"
- :disabled="!edit"
- title="升入高校名称"
- />
- <l-select
- @input="setValue('StuGraduateStatistic.UniversityLevel', $event)"
- :value="getValue('StuGraduateStatistic.UniversityLevel')"
- :disabled="!edit"
- :range="dataSource.StuGraduateStatistic.UniversityLevel"
- title="大学层次"
- />
- <l-input
- @input="setValue('StuGraduateStatistic.EmployerName', $event)"
- :value="getValue('StuGraduateStatistic.EmployerName')"
- :disabled="!edit"
- title="就业单位名称"
- />
- <l-select
- @input="setValue('StuGraduateStatistic.EmployerProvince', $event)"
- :value="getValue('StuGraduateStatistic.EmployerProvince')"
- :disabled="!edit"
- :range="dataSource.StuGraduateStatistic.EmployerProvince"
- @change="EmployerProvinceChange"
- title="就业单位所属省"
- />
- <l-select
- @input="setValue('StuGraduateStatistic.EmployerCity', $event)"
- :value="getValue('StuGraduateStatistic.EmployerCity')"
- :disabled="!edit"
- :range="dataSource.StuGraduateStatistic.EmployerCity"
- @change="EmployerCityChange"
- title="就业单位所属市"
- />
- <l-select
- @input="setValue('StuGraduateStatistic.EmployerCountry', $event)"
- :value="getValue('StuGraduateStatistic.EmployerCountry')"
- :disabled="!edit"
- :range="dataSource.StuGraduateStatistic.EmployerCountry"
- title="就业单位所属县"
- />
-
- <l-textarea
- @input="setValue('StuGraduateStatistic.Remark', $event)"
- :value="getValue('StuGraduateStatistic.Remark')"
- :disabled="!edit"
- title="备注"
- >
- </l-textarea>
- </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('reset')" 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 上海力软信息技术有限公司
- * 创建人:超级管理员
- * 日 期:2022-09-23 15:16
- * 描 述:毕业信息统计
- */
-
- /**
- * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
- * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
- * { "path": "pages/EducationalAdministration/StuGraduateStatistic/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: {
- StuGraduateStatistic: {
- GraduateGo: { type: 'select', title: '毕业去向', itemCode: 'GraduateGo', dataSource: '0', verify: 'NotNull' },
- EnterUniversityName: { type: 'text', title: '升入高校名称' },
- UniversityLevel: { type: 'select', title: '大学层次', itemCode: 'UniversityLevel', dataSource: '0' },
- EmployerName: { type: 'text', title: '就业单位名称' },
- EmployerProvince: { type: 'select', title: '就业单位所属省', dataSource: '1', dataSourceId: 'DIC_PROVINCE,pname,pcode' },
- EmployerCity: { type: 'select', title: '就业单位所属市', dataSource: '1', dataSourceId: 'DIC_CITY,cname,ccode' },
- EmployerCountry: { type: 'select', title: '就业单位所属县(区)', dataSource: '1', dataSourceId: 'DIC_AREA,aname,acode' },
- Remark: { type: 'textarea' , title: '备注'},
- },
-
- },
-
- // 数据源
- dataSource: {
- StuGraduateStatistic: {
- GraduateGo: Object.values(this.GET_GLOBAL('dataDictionary').GraduateGo).map(t => ({ value: t.value, text: t.text })),
- UniversityLevel: Object.values(this.GET_GLOBAL('dataDictionary').GraduateLevel).map(t => ({ value: t.value, text: t.text })),
- EmployerProvince: [],
- EmployerCity: [],
- EmployerCountry: [],
- },
-
- }
- }
- },
-
- async onLoad({ type, id }) {
- await this.init(type, id)
- },
-
- 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('DIC_PROVINCE').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerProvince = result.data.map(t => ({ text: t.pname, value: t.pcode }))
- }),
- this.FETCH_DATASOURCE('DIC_CITY').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerCity = result.data.map(t => ({ text: t.cname, value: t.ccode }))
- }),
- this.FETCH_DATASOURCE('DIC_AREA').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerCountry = result.data.map(t => ({ text: t.aname, value: t.acode }))
- }),
-
- () => {}
- ])
- 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/StuGraduateStatistic/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/StuGraduateStatistic/save', postData, '表单提交保存失败').then(success => {
- this.HIDE_LOADING()
- if (!success) {
- return
- }
-
- this.EMIT('EducationalAdministrationStuGraduateStatistic-list-change')
- this.NAV_BACK()
- this.TOAST('提交保存成功')
- })
- break
-
- case 'delete':
- if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
- return
- }
-
- this.LOADING('提交删除中...')
- this.HTTP_POST('learun/adms/EducationalAdministration/StuGraduateStatistic/delete', this.id, '删除失败').then(success => {
- this.HIDE_LOADING()
- if (!success) {
- return
- }
-
- this.EMIT('EducationalAdministrationStuGraduateStatistic-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)
- },
-
- //多条件查询:省改变事件
- async EmployerProvinceChange(){
- if (this.getValue('StuGraduateStatistic.EmployerProvince') != null && this.getValue('StuGraduateStatistic.EmployerProvince') !=undefined && this.getValue('StuGraduateStatistic.EmployerProvince') != "") {
- this.FETCH_DATASOURCE('DIC_CITY').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerCity = result.data.filter(t=>t.cparent===this.getValue('StuGraduateStatistic.EmployerProvince') ).map(t => ({ text: t.cname, value: t.ccode }))
- })
- }else{
- this.FETCH_DATASOURCE('DIC_CITY').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerCity = result.data.map(t => ({ text: t.cname, value: t.ccode }))
- })
- }
- },
- //多条件查询:市改变事件
- async EmployerCityChange(){
- if (this.getValue('StuGraduateStatistic.EmployerCity') != null && this.getValue('StuGraduateStatistic.EmployerCity')!=undefined && this.getValue('StuGraduateStatistic.EmployerCity')!= "") {
- this.FETCH_DATASOURCE('DIC_AREA').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerCountry = result.data.filter(t=>t.aparent===this.getValue('StuGraduateStatistic.EmployerCity')).map(t => ({ text: t.aname, value: t.acode }))
- })
- }else{
- this.FETCH_DATASOURCE('DIC_AREA').then(result => {
- this.dataSource.StuGraduateStatistic.EmployerCountry = result.data.map(t => ({ text: t.aname, value: t.acode }))
- })
- }
- },
-
- }
- }
- </script>
|