终端培训增加验证,项目基本信息增加字典查询培训种类

This commit is contained in:
Yuanjianghong 2021-11-15 17:05:46 +08:00
parent ec171306ab
commit c550abd36d
2 changed files with 70 additions and 48 deletions

View File

@ -13,7 +13,7 @@
<a-col :md="24" :sm="24">
<a-form-model-item label="培训种类">
<a-select v-model="form.trainClass" placeholder="--请选择--">
<a-select-option value="shanghai"> 参数待替换 </a-select-option>
<a-select-option v-for="entity in trainClass" :key="entity.value"> {{ entity.name }} </a-select-option>
</a-select>
<!-- <a-button type="primary" @click="$refs.classList.list()"> 新增种类 </a-button> -->
</a-form-model-item>
@ -122,13 +122,14 @@
<script>
import { dictGet } from '@/api/project/project'
import ClassList from '../classAdd/ClassList.vue'
import { classList } from '@/api/project/class'
export default {
props: {
form: {
type: Object,
default: () => ({}),
},
// form: {
// type: Object,
// default: () => ({}),
// },
},
data() {
return {
@ -138,15 +139,19 @@ export default {
modalTitle: '新增项目',
visible: false,
confirmLoading: false,
trainClass: [],
form: {},
}
},
components: {
dictGet,
ClassList,
classList,
},
created(ClassList) {
console.log('第一个表单创建了')
this.fetchTemplateData()
this.getTrainClass()
},
methods: {
add(type) {
@ -156,7 +161,7 @@ export default {
},
//,
fetchTemplateData() {
let formData = { type: 1 }
let formData = { type: 2 }
dictGet(formData).then((res) => {
console.log(res)
if (res.code == 200) {
@ -167,6 +172,25 @@ export default {
name: r.name,
})
})
// console.log("111111111111111111111111111",this.personType)
}
})
},
//
getTrainClass() {
let formData = { type: 1 }
dictGet(formData).then((res) => {
console.log(res)
if(res.code == 200){
const result = res.data
result.forEach((r)=>{
this.trainClass.push({
value: r.id,
name: r.name,
})
})
// console.log("222222222222222222222222222",this.trainClass)
}
})
},

View File

@ -2,32 +2,31 @@
<a-card :bordered="false" :title="titleName">
<a-form-model
ref="trainForm"
@submit="handleSubmit"
:rules="rules"
:model="form"
:layout="layout"
:labelCol="{ span: 2 }"
:wrapperCol="{ span: 10 }"
>
<a-form-model-item label="培训名称" prop="name">
<a-form-model-item label="培训名称" prop="trainName">
<a-input v-model="form.trainName" />
</a-form-model-item>
<a-form-model-item label="培训时间" style="margin-bottom: 0" porp="date" >
<a-form-model-item :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }" prop="date1">
<a-form-model-item label="培训时间" style="margin-bottom: 0">
<a-form-model-item :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }" prop="trainSdate">
<a-date-picker v-model="form.trainSdate" style="width: 100%" valueFormat="YYYY-MM-DD HH:mm:ss" />
</a-form-model-item>
<span :style="{ display: 'inline-block', width: '24px', textAlign: 'center' }"> - </span>
<a-form-model-item :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }" prop="date2">
<a-form-model-item :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }" prop="trainEdate">
<a-date-picker v-model="form.trainEdate" style="width: 100%" valueFormat="YYYY-MM-DD HH:mm:ss" />
</a-form-model-item>
</a-form-model-item>
<a-form-model-item label="主持人" prop="host">
<a-input v-model="form.host" />
</a-form-model-item>
<a-form-model-item label="会议人数" prop="number">
<a-input-number v-model="form.personNum" />
<a-form-model-item label="会议人数" prop="personNum">
<a-input-number v-model="form.personNum" :min="1"/>
</a-form-model-item>
<a-form-model-item label="学习内容" prop="content">
<a-form-model-item label="学习内容" prop="learningContent">
<a-input v-model="form.learningContent" type="textarea" />
</a-form-model-item>
<a-form-model-item label="联系人" prop="contact">
@ -36,16 +35,16 @@
<a-form-model-item label="联系方式" prop="phone">
<a-input v-model="form.phone" />
</a-form-model-item>
<a-form-model-item label="备注" prop="remark">
<a-form-model-item label="备注">
<a-input v-model="form.remark" type="textarea" />
</a-form-model-item>
<a-form-model-item>
<a-button
htmlType="submit"
type="primary"
@click="
() => {
this.form.status = 1
handleSubmit()
}
"
style="border-left: 200px"
@ -53,11 +52,11 @@
保存
</a-button>
<a-button
htmlType="submit"
type="primary"
@click="
() => {
this.form.status = 2
handleSubmit()
}
"
>
@ -100,12 +99,12 @@ export default {
titleName: '终端培训表单',
layout: 'horizontal',
rules: {
name: [{ required: true, message: '培训名称不能为空', trigger: 'blur' }],
date1: [{ required: true, message: '培训开始时间不能为空', trigger: 'change'}],
date2: [{ required: true, message: '培训结束时间不能为空', trigger: 'change'}],
trainName: [{ required: true, message: '培训名称不能为空', trigger: 'blur' }],
trainSdate: [{ required: true, message: '培训开始时间不能为空', trigger: 'change' }],
trainEdate: [{ required: true, message: '培训结束时间不能为空', trigger: 'change' }],
host: [{ required: true, message: '主持人不能为空', trigger: 'blur' }],
number: [{ required: true, message: '会议人数不能为空', trigger: 'blur' }],
content: [{ required: true, message: '学习内容不能为空', trigger: 'blur' }],
personNum: [{ required: true, message: '会议人数不能为空', trigger: 'blur' }],
learningContent: [{ required: true, message: '学习内容不能为空', trigger: 'blur' }],
contact: [{ required: true, message: '联系人不能为空', trigger: 'blur' }],
phone: [{ required: true, message: '联系方式不能为空', trigger: 'blur' }],
},
@ -118,37 +117,36 @@ export default {
//
methods: {
handleSubmit(e) {
this.$refs.trainForm.validate(valid => {
this.$refs.trainForm.validate((valid) => {
if (valid) {
alert('submit!');
console.log('提交的数据', this.form)
terminalTrainEdit(this.form).then((res) => {
if (res.code == 200) {
this.$message.success('保存成功!')
this.$router.push({
//list
path: '/project/project/terminalTrain/list',
query: {
terminalTrainName: this.$route.query.terminalTrainName,
terminalTrainStatus: this.$route.query.terminalTrainStatus,
terminalTrainStartDate: this.$route.query.terminalTrainStartDate,
terminalTrainEndDate: this.$route.query.terminalTrainEndDate,
terminalTrainPageNum: this.$route.query.terminalTrainPageNum,
},
})
} else {
console.log('error submit!!');
return false;
this.$message.error('保存失败:' + res.msg)
}
});
// console.log('', this.form)
// terminalTrainEdit(this.form).then((res) => {
// if (res.code == 200) {
// this.$message.success('')
// this.$router.push({
// //list
// path: '/project/project/terminalTrain/list',
// query: {
// terminalTrainName: this.$route.query.terminalTrainName,
// terminalTrainStatus: this.$route.query.terminalTrainStatus,
// terminalTrainStartDate: this.$route.query.terminalTrainStartDate,
// terminalTrainEndDate: this.$route.query.terminalTrainEndDate,
// terminalTrainPageNum: this.$route.query.terminalTrainPageNum,
// },
// })
// } else {
// this.$message.error('' + res.msg)
// }
// })
})
} else {
console.log('error submit!!')
return false
}
})
},
},
created() {
console.log('1---', this.$store.state.user)
console.log('1---', this.$store.state.user.info.name)
if (this.$route.query.id) {
this.form = terminalTrainGet(this.$route.query.id).then((res) => {
if (res.code == 200) {