feat: #10000 表格数据加载显示优化

This commit is contained in:
赵世界 2022-09-19 11:10:05 +08:00
parent a853e1ecf4
commit 5f3c64ed88
9 changed files with 64 additions and 47 deletions

View File

@ -4,54 +4,55 @@ import NProgress from "nprogress";
import "nprogress/nprogress.css"; import "nprogress/nprogress.css";
import { Message } from "element-ui"; import { Message } from "element-ui";
var instance = axios.create({ var instance = axios.create({
timeout: 10000, timeout: 10000,
}); });
instance.interceptors.request.use( instance.interceptors.request.use(
(config) => { (config) => {
// config.headers['content-type'] = 'application/json' // config.headers['content-type'] = 'application/json'
// config.headers['Shop-Id'] = localStorage.getItem('shopId') || 1 // config.headers['Shop-Id'] = localStorage.getItem('shopId') || 1
// 在发送请求之前做些什么 // 在发送请求之前做些什么
// config.headers['content-type'] = 'application/json' // config.headers['content-type'] = 'application/json'
config.headers.Authorization = "Bearer " + getToken(); // 请求头 config.headers.Authorization = "Bearer " + getToken(); // 请求头
NProgress.start(); NProgress.start();
return config; return config;
}, },
(error) => { (error) => {
// 对请求错误做些什么 // 对请求错误做些什么
return Promise.reject(error); return Promise.reject(error);
} }
); );
// 添加响应拦截器 // 添加响应拦截器
instance.interceptors.response.use( instance.interceptors.response.use(
(response) => { (response) => {
NProgress.done(); NProgress.done();
const res = response.status; const res = response.status;
// 对响应数据做点什么 // 对响应数据做点什么
if (res === 200 || res === 201) { if (res === 200 || res === 201) {
return response; return response;
} }
}, },
(error) => { (error) => {
// 对响应错误做点什么 NProgress.done();
if (error.response.status === 400) { // 对响应错误做点什么
Message({ if (error.response.status === 400) {
message: error.response.data.errorMessage, Message({
type: "error", message: error.response.data.errorMessage,
}); type: "error",
} });
}
if (error.response.status === 500) { if (error.response.status === 500) {
Message({ Message({
message: error.response.data.message, message: error.response.data.message,
type: "error", type: "error",
}); });
}
return Promise.reject(error);
} }
return Promise.reject(error);
}
); );
export default instance; export default instance;

View File

@ -75,8 +75,8 @@
</div> </div>
<!-- 表格 --> <!-- 表格 -->
<el-table ref="multipleTable" :data="tableData" class="table" tooltip-effect="dark" style="width: 100%" <el-table v-loading="loading" ref="multipleTable" :data="tableData" class="table" tooltip-effect="dark"
@selection-change="handleSelectionChange" max-height="1500"> style="width: 100%" @selection-change="handleSelectionChange" max-height="1500">
<!-- 多选框 --> <!-- 多选框 -->
<el-table-column type="selection"></el-table-column> <el-table-column type="selection"></el-table-column>
<el-table-column label="商品信息" width="300"> <el-table-column label="商品信息" width="300">
@ -385,6 +385,7 @@ export default {
radio: "", // radio: "", //
brand: [], // brand: [], //
cate: [], // cate: [], //
loading: true,
tableData: [], // tableData: [], //
shopsData: [], // shopsData: [], //
sku_code: {}, // sku_code: {}, //
@ -524,6 +525,7 @@ export default {
this.sku_code = { this.sku_code = {
sku_code: this.shopsData, sku_code: this.shopsData,
}; };
this.loading = false;
}); });
}, },

View File

@ -5,7 +5,7 @@
<!-- 列表 --> <!-- 列表 -->
<div class="table" style="margin-top: 10px"> <div class="table" style="margin-top: 10px">
<el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" <el-table v-loading="loading" ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange">
<el-table-column prop="name" label="商品种类"> </el-table-column> <el-table-column prop="name" label="商品种类"> </el-table-column>
<el-table-column prop="" label="操作"> <el-table-column prop="" label="操作">
@ -64,6 +64,7 @@ export default {
data() { data() {
return { return {
id: "", //id id: "", //id
loading: true,
tableData: [], tableData: [],
multipleSelection: [], multipleSelection: [],
dialogFormVisible: false, dialogFormVisible: false,
@ -174,6 +175,7 @@ export default {
this.tableData = res.data.data; this.tableData = res.data.data;
this.Paginationdata = res.data.meta; this.Paginationdata = res.data.meta;
}); });
this.loading = false;
}, },
}, },
}; };

View File

@ -50,7 +50,7 @@
<!-- 表格 --> <!-- 表格 -->
<el-card style="margin-top: 10px" class="box-card"> <el-card style="margin-top: 10px" class="box-card">
<el-table :data="tableData" border style="width: 100%"> <el-table v-loading="loading" :data="tableData" border style="width: 100%">
<el-table-column prop="id" label="序号" width="75"> </el-table-column> <el-table-column prop="id" label="序号" width="75"> </el-table-column>
<el-table-column prop="module" label="模块" width="70"> </el-table-column> <el-table-column prop="module" label="模块" width="70"> </el-table-column>
<el-table-column prop="action" label="操作" width="70"> </el-table-column> <el-table-column prop="action" label="操作" width="70"> </el-table-column>
@ -292,7 +292,7 @@ export default {
userId: "",//id() userId: "",//id()
}, },
value1: "", // value1: "", //
loading: true,
tableData: [], // tableData: [], //
Paginationdata: {}, // Paginationdata: {}, //
current_page: 1, // current_page: 1, //
@ -310,6 +310,7 @@ export default {
this.tableData = res.data.data; this.tableData = res.data.data;
this.Paginationdata = res.data.meta; this.Paginationdata = res.data.meta;
}); });
this.loading = false;
}, },
// //

View File

@ -44,7 +44,7 @@
<!-- 表格 --> <!-- 表格 -->
<el-card style="margin-top: 10px"> <el-card style="margin-top: 10px">
<el-table :data="tableData" style="width: 100%" border> <el-table v-loading="loading" :data="tableData" style="width: 100%" border>
<el-table-column prop="id" label="序号" width="70"> </el-table-column> <el-table-column prop="id" label="序号" width="70"> </el-table-column>
<el-table-column prop="created_at" label="时间" width="200"> <el-table-column prop="created_at" label="时间" width="200">
</el-table-column> </el-table-column>
@ -109,6 +109,7 @@ export default {
userId: "", userId: "",
}, },
value1: "", // value1: "", //
loading: true,
tableData: [], // tableData: [], //
Paginationdata: {}, // Paginationdata: {}, //
current_page: 1, // current_page: 1, //
@ -133,6 +134,7 @@ export default {
this.tableData = res.data.data; this.tableData = res.data.data;
this.Paginationdata = res.data.meta; this.Paginationdata = res.data.meta;
}); });
this.loading = false;
}, },
// //

View File

@ -27,7 +27,7 @@
</el-card> </el-card>
<el-card style="margin-top: 10px"> <el-card style="margin-top: 10px">
<el-table ref="multipleTable" :data="tableData" style="width: 100%"> <el-table v-loading="loading" ref="multipleTable" :data="tableData" style="width: 100%">
<el-table-column label="店铺名称"> <el-table-column label="店铺名称">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.shop.name }} {{ scope.row.shop.name }}
@ -76,6 +76,7 @@ export default {
goods_name: "", goods_name: "",
shop_id: "", shop_id: "",
}, },
loading: true,
tableData: [], tableData: [],
Paginationdata: {}, // Paginationdata: {}, //
current_page: 1, // current_page: 1, //
@ -107,6 +108,7 @@ export default {
storeList(page).then((res) => { storeList(page).then((res) => {
this.shops = res.data.data; this.shops = res.data.data;
}); });
this.loading = false;
}, },
// //
handleSizeChange(val) { handleSizeChange(val) {

View File

@ -4,7 +4,7 @@
<el-button type="primary" @click="handAdd">新增</el-button> <el-button type="primary" @click="handAdd">新增</el-button>
<div class="table" style="margin-top: 10px"> <div class="table" style="margin-top: 10px">
<el-table :data="tableData" style="width: 100%"> <el-table v-loading="loading" :data="tableData" style="width: 100%">
<el-table-column prop="id" label="ID" width="180"> </el-table-column> <el-table-column prop="id" label="ID" width="180"> </el-table-column>
<el-table-column prop="name" label="店铺名称" width="180"> <el-table-column prop="name" label="店铺名称" width="180">
</el-table-column> </el-table-column>
@ -79,6 +79,7 @@ export default {
plat_id: "", plat_id: "",
}, },
storeId: [], // id storeId: [], // id
loading: true,
tableData: [], tableData: [],
Paginationdata: {}, // Paginationdata: {}, //
current_page: 1, // current_page: 1, //
@ -123,6 +124,7 @@ export default {
this.tableData = res.data.data; this.tableData = res.data.data;
this.Paginationdata = res.data.meta; this.Paginationdata = res.data.meta;
}); });
this.loading = false
}, },
// //

View File

@ -22,7 +22,7 @@
<!-- 角色列表 --> <!-- 角色列表 -->
<div class="table" style="margin-top: 10px"> <div class="table" style="margin-top: 10px">
<el-table :data="tableList" style="width: 100%"> <el-table v-loading="loading" :data="tableList" style="width: 100%">
<el-table-column prop="id" label="ID"> </el-table-column> <el-table-column prop="id" label="ID"> </el-table-column>
<el-table-column prop="name" label="角色名称"> </el-table-column> <el-table-column prop="name" label="角色名称"> </el-table-column>
<el-table-column label="权限内容"> <el-table-column label="权限内容">
@ -63,6 +63,7 @@ export default {
data() { data() {
return { return {
id: "", //id id: "", //id
loading: true,
tableList: [], // tableList: [], //
rolePermissions: [], rolePermissions: [],
newrole: "", //input newrole: "", //input
@ -90,6 +91,7 @@ export default {
roleList().then((res) => { roleList().then((res) => {
this.tableList = res.data.data; this.tableList = res.data.data;
}); });
this.loading = false;
}, },
// //
@ -156,4 +158,5 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>

View File

@ -77,7 +77,7 @@
<!-- 用户列表 --> <!-- 用户列表 -->
<div class="table" style="margin-top: 10px"> <div class="table" style="margin-top: 10px">
<template> <template>
<el-table :data="tableList" style="width: 100%"> <el-table v-loading="loading" :data="tableList" style="width: 100%">
<el-table-column prop="id" label="ID"></el-table-column> <el-table-column prop="id" label="ID"></el-table-column>
<el-table-column prop="name" label="姓名"></el-table-column> <el-table-column prop="name" label="姓名"></el-table-column>
<el-table-column label="角色"> <el-table-column label="角色">
@ -119,6 +119,7 @@ export default {
id: "", id: "",
dialogVisible: false, // dialogVisible: false, //
editVisible: false, // editVisible: false, //
loading: true,
tableList: [], // tableList: [], //
from: { from: {
// //
@ -168,6 +169,7 @@ export default {
this.tableList = res.data.data; this.tableList = res.data.data;
this.Paginationdata = res.data.meta; this.Paginationdata = res.data.meta;
}); });
this.loading = false;
}, },
// //