家属管理及其接口的开发
接口的开发:
查询家属的所有信息
-
其中设计到单张表(TbFamily表)
-
后台管理,直接显示出所有家属信息列表
-
Controller
-
/**
* 查询家属的所有信息
* @return
*/
-
添加家属后台管理
-
其中设计到单张表(TbFamily表)
-
后台管理对其中的家属做一个添加的功能
-
Controller
-
/**
* 添加家属后台管理
* @param tbFamily
* @return
*/
-
修改家属信息
-
其中设计到单张表(TbFamily表)
-
后台管理的家属的信息有误,就要进行修改
-
Controller
-
/**
* 修改家属信息
* @param tbFamily
* @return
*/
-
模糊查询
-
其中设计到单张表(TbFamily表)
-
我在后台管理的中有一个功能是查询功能,这里就涉及到这个模糊的查询,填写的参数有两个
-
Controller
-
/**
* 模糊查询
* @param name
* @param phonenumber
* @return
*/
-
删除家属
-
其中设计到单张表(TbFamily表)
-
后台管理的中有一个家属的信息资料进行删除(相当于注销了这个账号)
-
Controller
-
/**
* 删除家属
* @param familyId
* @return
*/
return AjaxResult.success(remove1 && remove && save);
}
-
问题及解决
没有出现bug一切顺利
学习重点及理解
查询家属列表
-
family.js
-
// 查询家属列表
export function listFamily(query) {
return request({
url: '/system/family/list',
method: 'get',
params: query
})
}
-
-
family.vue
-
/** 查询家属列表 */
getList() {
this.loading = true;
listFamily(this.queryParams).then(response => {
this.familyList = response.data.slice((this.queryParams.pageNum-1)*this.queryParams.pageSize,(this.queryParams.pageNum-1)*this.queryParams.pageSize+this.queryParams.pageSize);;
this.total = response.total;
this.loading = false;
});
},
-
新增家属
-
amily.js
-
// 新增家属
export function addFamily(params) {
return request({
url: '/system/family',
method: 'post',
params
})
}
-
-
family.vue
-
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if(this.form.familyId == null){
addFamily({name: this.form.name, sex: this.form.sex, phonenumber: this.form.phonenumber,
accountNumber: this.form.accountNumber,password: this.form.password});
this.$modal.msgSuccess("新增成功");
this.open = false;
setTimeout(() => {this.getList();}, 500);
}else{
updateFamily({name: this.form.name, sex: this.form.sex, phonenumber: this.form.phonenumber,
accountNumber: this.form.accountNumber,password: this.form.password,familyId: this.form.familyId});
this.$modal.msgSuccess("修改成功");
this.open = false;
setTimeout(() => {this.getList();}, 500);
}
});
},
-
修改家属
-
amily.js
-
// 修改家属
export function updateFamily(params) {
return request({
url: '/system/family',
method: 'put',
params
})
}
-
-
family.vue
-
/** 修改按钮操作 数据回显*/
handleUpdate(row) {
this.reset();
const familyId = row.familyId || this.ids
const name = row.name || this.ids
const sex = row.sex || this.ids
const phonenumber = row.phonenumber || this.ids
const accountNumber = row.accountNumber || this.ids
const password = row.password || this.ids
// getFamily(familyId).then(response => {
this.form.familyId = familyId;
this.form.name = name;
this.form.sex = sex;
this.form.phonenumber = phonenumber;
this.form.accountNumber = accountNumber;
this.form.password = password;
this.open = true;
this.title = "修改家属";
// });
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if(this.form.familyId == null){
addFamily({name: this.form.name, sex: this.form.sex, phonenumber: this.form.phonenumber,
accountNumber: this.form.accountNumber,password: this.form.password});
this.$modal.msgSuccess("新增成功");
this.open = false;
setTimeout(() => {this.getList();}, 500);
}else{
updateFamily({name: this.form.name, sex: this.form.sex, phonenumber: this.form.phonenumber,
accountNumber: this.form.accountNumber,password: this.form.password,familyId: this.form.familyId});
this.$modal.msgSuccess("修改成功");
this.open = false;
setTimeout(() => {this.getList();}, 500);
}
});
},
-
模糊查询
-
amily.js
-
// 模糊查询详细
export function getFamily(params) {
return request({
url: '/system/family/like',
method: 'get',
params
})
}
-
-
family.vue
-
likeList(name,phonenumber){
this.loading = true;
getFamily({name: name,phonenumber: phonenumber}).then(response => {
this.familyList = response.data.slice((this.queryParams.pageNum-1)*this.queryParams.pageSize,(this.queryParams.pageNum-1)*this.queryParams.pageSize+this.queryParams.pageSize);
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.likeList(this.queryParams.name,this.queryParams.phonenumber)
},
-
删除家属
-
amily.js
-
// 删除家属
export function delFamily(params) {
return request({
url: '/system/family',
method: 'delete',
params
})
}
-
-
family.vue
-
/** 删除按钮操作 */
handleDelete(row) {
const familyIds = row.familyId || this.ids;
this.$modal.confirm('是否确认删除编号为"' + familyIds + '"的数据项?').then(function() {
return delFamily({familyId: familyIds});
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
-
总结
今天的学习的状态是不错的,家属管理我现在才发现,把这个家属端给忽略了,我直接去数据库添加相应的表,又到user表中添加一个家属的ID。关于家属的接口都没有开发,但是很多的接口都是可以重复利用的。我在对后台管理页面,将自己需要的接口自己开发。

浙公网安备 33010602011771号