a
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
|
||||
v-model="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataFormRef" @keyup.enter="dataFormSubmit"
|
||||
label-width="140px">
|
||||
|
||||
<el-form-item label="招生计划" prop="groupId">
|
||||
@@ -106,187 +106,212 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()" v-if="canSubmit">确定</el-button>
|
||||
</span>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit" v-if="canSubmit">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {addObj, getObj, putObj,getCityPlan} from '@/api/recruit/recruitplanmajor'
|
||||
import {getDeptList} from "@/api/basic/basicclass";
|
||||
import {getDictByType} from "@/api/contract/contract";
|
||||
import {list} from "@/api/recruit/recruitstudentplangroup";
|
||||
import {getMajorNameList} from "@/api/basic/major";
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick } from 'vue'
|
||||
import { ElNotification } from 'element-plus'
|
||||
import { addObj, getObj, putObj, getCityPlan } from '@/api/recruit/recruitplanmajor'
|
||||
import { getDeptList } from "@/api/basic/basicclass"
|
||||
import { getDictByType } from "@/api/contract/contract"
|
||||
import { list } from "@/api/recruit/recruitstudentplangroup"
|
||||
import { getMajorNameList } from "@/api/basic/major"
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
canSubmit: false,
|
||||
dataForm: {
|
||||
id: "",
|
||||
groupId: "",
|
||||
zydm: "",
|
||||
zymc: "",
|
||||
zygfmc: "",
|
||||
deptCode: "",
|
||||
xz: "",
|
||||
cc: "",
|
||||
isZd: "0",
|
||||
isOrder: "0",
|
||||
remarks: "",
|
||||
offcialZydm: "",
|
||||
isUnion:"0",
|
||||
tuitionFee:0,
|
||||
cityPlanId:null
|
||||
},
|
||||
cityPlanIdList:[],
|
||||
offcialZydmList: [],
|
||||
planList: [],
|
||||
yeNoList: [],
|
||||
deptList: [],
|
||||
ccList: [],
|
||||
majorYears: [],
|
||||
dataRule: {
|
||||
zydm: [
|
||||
{required: true, message: '专业代码不能为空', trigger: 'blur'},
|
||||
{min: 1, max: 6, message: '专业代码长度不大于6个字符', trigger: 'blur'}
|
||||
],
|
||||
tuitionFee: [
|
||||
{required: true, message: '学费不能为空', trigger: 'blur'}
|
||||
],
|
||||
zymc: [
|
||||
{required: true, message: '专业名称不能为空', trigger: 'blur'},
|
||||
{min: 1, max: 200, message: '专业名称长度不大于200个字符', trigger: 'blur'}
|
||||
// Emits
|
||||
const emit = defineEmits<{
|
||||
(e: 'refreshDataList'): void
|
||||
}>()
|
||||
|
||||
],
|
||||
zygfmc: [
|
||||
{required: true, message: '专业规范名称不能为空', trigger: 'blur'},
|
||||
{min: 1, max: 200, message: '专业规范名称长度不大于200个字符', trigger: 'blur'}
|
||||
],
|
||||
groupId: [
|
||||
{required: true, message: '招生计划不能为空', trigger: 'blur'}
|
||||
],
|
||||
xz: [
|
||||
{required: true, message: '学制不能为空', trigger: 'blur'}
|
||||
],
|
||||
deptCode: [
|
||||
{required: true, message: '学院不能为空', trigger: 'blur'}
|
||||
],
|
||||
cc: [
|
||||
{required: true, message: '层次不能为空', trigger: 'blur'}
|
||||
],
|
||||
isOrder: [
|
||||
{required: true, message: '订单班不能为空', trigger: 'blur'}
|
||||
],
|
||||
isZd: [
|
||||
{required: true, message: '订单班不能为空', trigger: 'blur'}
|
||||
],
|
||||
isUnion: [
|
||||
{required: true, message: '联院班不能为空', trigger: 'blur'}
|
||||
],
|
||||
remarks: [
|
||||
{min: 1, max: 100, message: '备注长度不大于100个字符', trigger: 'blur'}
|
||||
],
|
||||
}
|
||||
// 表单引用
|
||||
const dataFormRef = ref()
|
||||
|
||||
// 响应式数据
|
||||
const visible = ref(false)
|
||||
const canSubmit = ref(false)
|
||||
const cityPlanIdList = ref<any[]>([])
|
||||
const offcialZydmList = ref<any[]>([])
|
||||
const planList = ref<any[]>([])
|
||||
const yesNoList = ref<any[]>([])
|
||||
const deptList = ref<any[]>([])
|
||||
const ccList = ref<any[]>([])
|
||||
const majorYears = ref<any[]>([])
|
||||
|
||||
const dataForm = reactive({
|
||||
id: "",
|
||||
groupId: "",
|
||||
zydm: "",
|
||||
zymc: "",
|
||||
zygfmc: "",
|
||||
deptCode: "",
|
||||
xz: "",
|
||||
cc: "",
|
||||
isZd: "0",
|
||||
isOrder: "0",
|
||||
remarks: "",
|
||||
offcialZydm: "",
|
||||
isUnion: "0",
|
||||
tuitionFee: 0,
|
||||
cityPlanId: null as string | null,
|
||||
cityPlanIds: [] as string[],
|
||||
cityPlanName: "",
|
||||
cityPlanYear: "",
|
||||
sort: 0
|
||||
})
|
||||
|
||||
const dataRule = {
|
||||
zydm: [
|
||||
{ required: true, message: '专业代码不能为空', trigger: 'blur' },
|
||||
{ min: 1, max: 6, message: '专业代码长度不大于6个字符', trigger: 'blur' }
|
||||
],
|
||||
tuitionFee: [
|
||||
{ required: true, message: '学费不能为空', trigger: 'blur' }
|
||||
],
|
||||
zymc: [
|
||||
{ required: true, message: '专业名称不能为空', trigger: 'blur' },
|
||||
{ min: 1, max: 200, message: '专业名称长度不大于200个字符', trigger: 'blur' }
|
||||
],
|
||||
zygfmc: [
|
||||
{ required: true, message: '专业规范名称不能为空', trigger: 'blur' },
|
||||
{ min: 1, max: 200, message: '专业规范名称长度不大于200个字符', trigger: 'blur' }
|
||||
],
|
||||
groupId: [
|
||||
{ required: true, message: '招生计划不能为空', trigger: 'blur' }
|
||||
],
|
||||
xz: [
|
||||
{ required: true, message: '学制不能为空', trigger: 'blur' }
|
||||
],
|
||||
deptCode: [
|
||||
{ required: true, message: '学院不能为空', trigger: 'blur' }
|
||||
],
|
||||
cc: [
|
||||
{ required: true, message: '层次不能为空', trigger: 'blur' }
|
||||
],
|
||||
isOrder: [
|
||||
{ required: true, message: '订单班不能为空', trigger: 'blur' }
|
||||
],
|
||||
isZd: [
|
||||
{ required: true, message: '订单班不能为空', trigger: 'blur' }
|
||||
],
|
||||
isUnion: [
|
||||
{ required: true, message: '联院班不能为空', trigger: 'blur' }
|
||||
],
|
||||
remarks: [
|
||||
{ min: 1, max: 100, message: '备注长度不大于100个字符', trigger: 'blur' }
|
||||
],
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断市平台招生专业是否占用,占用不可选
|
||||
*/
|
||||
const isCityDisable = (id: string) => {
|
||||
if (!dataForm.cityPlanIds || !Array.isArray(dataForm.cityPlanIds)) {
|
||||
return false
|
||||
}
|
||||
return dataForm.cityPlanIds.some(e => e == id)
|
||||
}
|
||||
|
||||
// 初始化数据
|
||||
const initData = () => {
|
||||
// 查询二级学院信息
|
||||
getDeptList().then((data: any) => {
|
||||
deptList.value = data.data
|
||||
})
|
||||
list().then((data: any) => {
|
||||
planList.value = data.data
|
||||
if (!dataForm.id) {
|
||||
dataForm.groupId = planList.value[0]?.id || ""
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || null;
|
||||
this.visible = true;
|
||||
this.canSubmit = true;
|
||||
this.initData();
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
getObj(this.dataForm.id).then(response => {
|
||||
this.dataForm = response.data.data
|
||||
//获取市平台对应年份下的招生计划
|
||||
getCityPlan({id:this.dataForm.id}).then(data =>{
|
||||
this.cityPlanIdList = data.data.data
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 判断市平台招生专业是否占用,占用不可选
|
||||
* @param notBedNo
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isCityDisable(id){
|
||||
var returnFlag = false;
|
||||
this.dataForm.cityPlanIds.forEach(e=>{
|
||||
if(e == id){
|
||||
returnFlag = true;
|
||||
}
|
||||
})
|
||||
return returnFlag;
|
||||
},
|
||||
initData() {
|
||||
//查询二级学院信息
|
||||
getDeptList().then(data => {
|
||||
this.deptList = data.data.data
|
||||
})
|
||||
list().then(data => {
|
||||
this.planList = data.data.data
|
||||
if (!this.dataForm.id) {
|
||||
this.dataForm.groupId = this.planList[0].id;
|
||||
}
|
||||
});
|
||||
getMajorNameList().then(data =>{
|
||||
this.offcialZydmList = data.data.data
|
||||
})
|
||||
//获取数据字典
|
||||
getDictByType("yes_no").then(res => {
|
||||
this.yesNoList = res.data.data
|
||||
})
|
||||
getDictByType("basic_major_years").then(res => {
|
||||
this.majorYears = res.data.data
|
||||
})
|
||||
getDictByType("basic_major_level").then(res => {
|
||||
this.ccList = res.data.data
|
||||
})
|
||||
})
|
||||
getMajorNameList().then((data: any) => {
|
||||
offcialZydmList.value = data.data
|
||||
})
|
||||
// 获取数据字典
|
||||
getDictByType("yes_no").then((res: any) => {
|
||||
yesNoList.value = res.data
|
||||
})
|
||||
getDictByType("basic_major_years").then((res: any) => {
|
||||
majorYears.value = res.data
|
||||
})
|
||||
getDictByType("basic_major_level").then((res: any) => {
|
||||
ccList.value = res.data
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
if(this.dataForm.cityPlanId !=null){
|
||||
this.cityPlanIdList.forEach(e=>{
|
||||
if(e.id == this.dataForm.cityPlanId){
|
||||
this.dataForm.cityPlanName = e.schoolMajorName;
|
||||
this.dataForm.cityPlanYear = e.educational;
|
||||
}
|
||||
// 表单提交
|
||||
const dataFormSubmit = () => {
|
||||
if (dataForm.cityPlanId != null) {
|
||||
cityPlanIdList.value.forEach(e => {
|
||||
if (e.id == dataForm.cityPlanId) {
|
||||
dataForm.cityPlanName = e.schoolMajorName
|
||||
dataForm.cityPlanYear = e.educational
|
||||
}
|
||||
})
|
||||
}
|
||||
dataFormRef.value?.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
canSubmit.value = false
|
||||
if (dataForm.id) {
|
||||
putObj(dataForm).then(() => {
|
||||
ElNotification.success({
|
||||
title: '成功',
|
||||
message: '修改成功'
|
||||
})
|
||||
visible.value = false
|
||||
emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
canSubmit.value = true
|
||||
})
|
||||
} else {
|
||||
addObj(dataForm).then(() => {
|
||||
ElNotification.success({
|
||||
title: '成功',
|
||||
message: '添加成功'
|
||||
})
|
||||
visible.value = false
|
||||
emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
canSubmit.value = true
|
||||
})
|
||||
}
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.canSubmit = false;
|
||||
if (this.dataForm.id) {
|
||||
putObj(this.dataForm).then(data => {
|
||||
this.$notify.success('修改成功')
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
this.canSubmit = true;
|
||||
});
|
||||
} else {
|
||||
addObj(this.dataForm).then(data => {
|
||||
this.$notify.success('添加成功')
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
this.canSubmit = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化方法
|
||||
const init = (id: string | null) => {
|
||||
dataForm.id = id || ""
|
||||
visible.value = true
|
||||
canSubmit.value = true
|
||||
initData()
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields()
|
||||
if (dataForm.id) {
|
||||
getObj(dataForm.id).then((response: any) => {
|
||||
Object.assign(dataForm, response.data)
|
||||
// 获取市平台对应年份下的招生计划
|
||||
getCityPlan({ id: dataForm.id }).then((data: any) => {
|
||||
cityPlanIdList.value = data.data
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
init
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user