当前位置:网站首页>Async get and post request interface data (add, delete, modify and query pages)
Async get and post request interface data (add, delete, modify and query pages)
2022-06-21 13:44:00 【m0_ fifty-four million eight hundred and fifty thousand eight h】
1.async get Request interface data
async xzlist() {
const { data: res } = await this.$http_message.post(
"/shift_change_log/list",
this.queryList
);
if (res.code == 0) {
console.log(res.data);
this.list = res.data.rows;
this.total = res.data.total;
} else {
return this.$message.error(" Failed to get user information !");
}
},
queryList You may be confused when you see here
Here we put the requested parameters ID name Or paging parameters
for example :
queryList: {
asc: true,
orderBy: "id",
pageNum: 1,
pageSize: 10,
regDateBeginTime: "2001-01-01",
regDateEndTime: "2001-01-01",
shiftId: 0,
status: 1,
teamId: 10,
},
xzlist This is the event name We can do it in mounted perhaps created To mount .
created() {
// Enter the page to call the Department user information
this.xzlist();
},
We can do it in console.log() Print it. Let's look at it on the console 
At the same time, it is more convenient for us to be backstage network It is more convenient to view the interface request information .
So our data will pass list The array is rendered to the page 
To add, we use post request
As above, put the requested parameters into addForm in
// New Department
async addDepartment() {
const { data: res } = await this.$http_message.post(
"/fault_info/create",
this.addForm
);
console.log(res.data);
if (res.code == 0) {
this.$message.success(res.msg);
this.ediDialogVisible = false;
this.xzlist();
} else {
return this.$message.error(" Failed to add Department !");
}
},
To edit, we first click the Edit button to get the current id The data of The echo
// Revision Department
async showEditDialog(id) {
this.addDialogVisible = true;
const { data: res } = await this.$http_message.get(
"fault_info/getDataById?id=" + id
);
if (res.code == 0) {
console.log(res.data);
this.ediForm = res.data;
} else {
console.log(" Failure ");
}
},
The second is the edit and modify page pop-up box
async eidtUserInfo() {
const { data: res } = await this.$http_base.post(
"parameters/main/update",
this.ediForm
);
if (res.code == 0) {
this.$message.success(" Department modified successfully ");
this.addDialogVisible = false;
this.xzlist();
} else {
console.log(" Failure ");
return this.$message.error(" Failed to modify Department !");
}
},
Someone may be right **$http_base** This is a stranger This is our server request
Because we have several servers In order to distinguish between 
Configure a to request back-end services api
It's no stranger to delete Maybe my favorite thing is to delete Directly through id Delete
// Delete user
async removeUserById(id) {
const confirmResult = await this.$confirm(
" Are you sure you want to delete the current user ",
" Delete ",
{
confirmButtonText: " determine ",
cancelButtonText: " Cancel ",
type: "warning",
}
).catch((err) => {
return err;
});
if (confirmResult !== "confirm") {
return this.$message.info(" Cancel deletion succeeded ");
} else {
const { data: res } = await this.$http_message.get(
"fault_info/delete?id=" + id,
this.delete
);
if (res.code == 0) {
this.$message.success(" Delete user succeeded ");
this.xzlist();
} else {
return this.$message.error(" Failed to delete user !");
}
}
},
Paging is also an essential part (html department )
<p style="margin-top: 20px; color: #fff"> common {
{ total }} Bar record </p>
<div class="fenye">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="queryList.page"
:page-sizes="[5, 10, 15]"
:page-size="queryList.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
></el-pagination>
</div>
methods: Write events in it
handleSizeChange(newSize) {
console.log(newSize);
this.queryList.pageSize = newSize;
this.xzlist();
},
handleCurrentChange(newpage) {
console.log(newpage);
this.queryList.pageNum = newpage;
this.xzlist();
},
a fly in the ointment Please give me more suggestions
《 Front end interview questions of first-line large factories + Develop learning notes + The latest architecture explanation video + Handout of the event station project 》
【https://docs.qq.com/doc/DQVJzbnRIWWNtcVR4】 Full content open source sharing
边栏推荐
- . Net synchronization mechanism and application examples
- Setting of Seaborn drawing style
- How to guarantee the test coverage
- 17 commonly used o & M monitoring systems
- 基于STM32电压检测和电流检测
- Please, don't use pessimistic locks in high concurrency scenarios!
- Declare war on uncivilized code II
- 4. procedure flow structure
- How to write test cases
- 3D slicer saves segmentation results
猜你喜欢

MySQL - table constraints

MySQL - adding, deleting, querying and modifying tables

Navigation bar switching, message board, text box losing focus

Unbounded territory won the title of innovative brand of digital culture industry in 2022

Visualization strategy of Seaborn data overall distribution

如何阅读AI顶会论文?

使用seaborn绘制热图

Automatic operation and maintenance 2 - common modules in ansible

MySQL - user management
![[in depth understanding of tcapulusdb technology] tcapulusdb construction data](/img/83/200cd9705138583eee6b3db55135ff.png)
[in depth understanding of tcapulusdb technology] tcapulusdb construction data
随机推荐
Unbounded territory won the title of innovative brand of digital culture industry in 2022
[course assignment] floating point operation analysis and precision improvement
应用配置管理,基础原理分析
How to guarantee the test coverage
Analysis on the wallet system architecture of Baidu trading platform
Master the basic usage of SQLite3
微证券开户正规安全吗,怎么操作开户?
Babbitt yuancosmos daily must read: wechat may ban a official account for the first time on the grounds of "involving secondary transactions in digital collections", and the new regulations of the pla
3. operator
17 commonly used o & M monitoring systems
Automatic operation and maintenance 3 - using playbook in ansible
The new plan for national treasures - the exclusive digital collection of the four museums is coming!
MySQL - table constraints
启牛商学院app下载证券开户,是安全的吗?有风险嘛?
Is it safe to open a securities account by downloading the app of qiniu business school? Is there a risk?
Explanation of vim, makefile and GDB tools
如何使用搜索引擎?
Visualization strategy of Seaborn data overall distribution
C language elementary level (IX) enumeration
Write efficient defect reports