1.实现前端显示后端数据
学生页面
created() {
const _this = this;
axios.get('http://localhost:8181/teacher/findAll').then(function(resp){
console.log(resp);
let cnt = 0;
while(resp.data[cnt]) {
_this.infoData[cnt].tea_id = resp.data[cnt].teaId;
_this.infoData[cnt].tea_name = resp.data[cnt].teaName;
_this.infoData[cnt].mail_address = resp.data[cnt].mailAddress;
_this.infoData[cnt].tea_gender = resp.data[cnt].teaGender;
_this.infoData[cnt].tea_dname = resp.data[cnt].teaDname;
_this.infoData[cnt].person_intro = resp.data[cnt].personIntro;
cnt++;
var list ={
tea_id: '',
tea_name: '',
mail_address: '',
tea_gender: '',
tea_dname: '',
person_intro: ''
};
_this.infoData.push(list);
}
_this.infoData.pop();
});
老师页面
created() {
const _this = this;
axios.get('http://localhost:8181/teacher/findAll').then(function(resp){
console.log(resp);
let cnt = 0;
while(resp.data[cnt]) {
_this.tableData[cnt].tea_id = resp.data[cnt].teaId;
_this.tableData[cnt].tea_name = resp.data[cnt].teaName;
_this.tableData[cnt].date = resp.data[cnt].teaBirthday;
_this.tableData[cnt].tea_doc_time = resp.data[cnt].teaDocTime;
_this.tableData[cnt].position = resp.data[cnt].position;
_this.tableData[cnt].highest_edu = resp.data[cnt].highestEdu;
_this.tableData[cnt].tea_master_time = resp.data[cnt].teaMasterTime;
_this.tableData[cnt].search_direction = resp.data[cnt].searchDirection;
_this.tableData[cnt].mail_address = resp.data[cnt].mailAddress;
_this.tableData[cnt].tea_gender = resp.data[cnt].teaGender;
_this.tableData[cnt].tea_dname = resp.data[cnt].teaDname;
_this.tableData[cnt].person_intro = resp.data[cnt].personIntro;
cnt++;
var list ={
tea_id: '',
tea_name: '',
tea_gender: '',
date:'',
position:'',
search_direction:'',
mail_address:'',
highest_edu:'',
tea_doc_time:'',
tea_master_time:'',
tea_dname:'',
person_intro:''
};
_this.tableData.push(list);
}
_this.tableData.pop();
});
},
2.实现前端与后端连接部分的查功能
handleSearch() {
const _this = this;
while(_this.tableData[0])_this.tableData.pop();
var list ={
tea_id: '',
tea_name: '',
tea_gender: '',
date:'',
position:'',
search_direction:'',
mail_address:'',
highest_edu:'',
tea_doc_time:'',
tea_master_time:'',
tea_dname:'',
person_intro:''
};
_this.tableData.push(list);
axios.get('http://localhost:8181/teacher/findByName?tea_name='+_this.filters.number).then(function(resp){
_this.tableData[0].tea_id = resp.data.teaId;
_this.tableData[0].tea_name = resp.data.teaName;
_this.tableData[0].date = resp.data.teaBirthday;
_this.tableData[0].tea_doc_time = resp.datateaDocTime;
_this.tableData[0].position = resp.data.position;
_this.tableData[0].highest_edu = resp.data.highestEdu;
_this.tableData[0].tea_master_time = resp.data.teaMasterTime;
_this.tableData[0].search_direction = resp.data.searchDirection;
_this.tableData[0].mail_address = resp.data.mailAddress;
_this.tableData[0].tea_gender = resp.data.teaGender;
_this.tableData[0].tea_dname = resp.data.teaDname;
_this.tableData[0].person_intro = resp.data.personIntro;
});
},
3.实现增功能
//添加老师
addTeacher(){
var _this = this;
console.log(_this.form.tea_doc_time);
axios.post('http://localhost:8181/teacher/addTea?'+'tea_id='+_this.form.tea_id+'&tea_name='+_this.form.tea_name+'&tea_gender='+_this.form.tea_gender+'&final_edu='+ _this.form.final_edu+
'&position='+ _this.form.position+'&tea_tel_num='+ _this.form.position+'&search_direction='+ _this.form.search_direction+'&mail_address='+ _this.form.mail_address+
'&highest_edu='+ _this.form.highest_edu+'&tea_doc_time='+ _this.form.tea_doc_time+'&tea_master_time='+ _this.form.tea_master_time+'&tea_dname='+ _this.form.tea_dname+'&person_intro='+ _this.form.person_intro).then(function(resp){
console.log(resp);
if(resp.data.msg =='操作成功')
_this.$alert('添加成功!', '消息', {
confirmButtonText: '确定',
})
})
},