新增
查询
{{item.fraction}}
修改
删除
:page-sizes="sizes" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="total">
成绩
删除
保存学生
新增科目
成绩
删除
修改
新增科目
export default {
data() {
return {
editDalogVisible: false,
formInline: {
name: '',
cname: ''
},
tableData: [],
zcj: [],
cousesName: ['语文', '数学', '英语', '物理', '化学', '生物'],
insertDalogVisible: false,
insertForm: {
stuNo: '',
name: '',
houseList: [{
name: '',
fraction: ''
}],
},
total: 0,
page: 1,
size: 3,
sizes: [2, 3, 5],
editForm: {
stuNo: '',
name: '',
houseList: [{
name: '',
fraction: ''
}],
},
}
},
created: function() {
this.initData();
},
methods: {
openEdit(row) {
console.log(row);
this.editDalogVisible = true;
Object.assign(this.editForm, row);
},
onSubmit() {
console.log(this.formInline);
this.initData();
},
handleSizeChange(val) {
this.size = val;
this.initData();
},
handleCurrentChange(val) {
this.page = val;
this.initData();
},
addStus() {
if (this.insertDalogVisible) {
console.log(this.insertForm);
this.axios.post('http://localhost:8800/api/student/insert', this.insertForm).then((res) => {
if (res.data.result) {
this.$message.success('添加成功');
this.insertDalogVisible = false;
this.initData();
}
});
} else if (this.editDalogVisible) {
console.log(this.editForm);
this.axios.post('http://localhost:8800/api/student/insert', this.editForm).then((res) => {
if (res.data.result) {
this.$message.success('修改成功');
this.editDalogVisible = false;
this.initData();
}
});
}
},
removeDomain(item) {
if (this.insertDalogVisible) {
var index = this.insertForm.houseList.indexOf(item)
if (index !== -1) {
this.insertForm.houseList.splice(index, 1)
}
} else if (this.editDalogVisible) {
var index = this.editForm.houseList.indexOf(item)
if (index !== -1) {
this.editForm.houseList.splice(index, 1)
}
}
},
addDomain() {
if (this.insertDalogVisible) {
this.insertForm.houseList.push({
name: '',
fraction: ''
});
} else if (this.editDalogVisible) {
this.editForm.houseList.push({
name: '',
fraction: ''
});
}
},
initData() {
this.axios.get('http://localhost:8800/api/student/list', {
params: {
page: this.page,
size: this.size,
name: this.formInline.name,
cname: this.formInline.cname
}
}).then((res) => {
console.log(res);
this.tableData = res.data.result.content;
this.total = res.data.result.totalElements;
var arr = [];
for (var i = 0; i < this.tableData.length; i++) {
arr[i] = 0;
for (var j = 0; j < this.tableData[i].houseList.length; j++) {
arr[i] += this.tableData[i].houseList[j].fraction;
}
this.tableData[i].zfen = arr[i];
}
console.log(this.tableData);
});
}
}
}