table/tableSelect/upload 配置抽离
This commit is contained in:
parent
4f002e2cb4
commit
520eb35c59
|
|
@ -36,6 +36,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import config from "@/config/table";
|
||||
import columnSetting from './columnSetting'
|
||||
|
||||
export default {
|
||||
|
|
@ -71,7 +72,7 @@
|
|||
emptyText: "暂无数据",
|
||||
toggleIndex: 0,
|
||||
tableData: [],
|
||||
pageSize: 20,
|
||||
pageSize: config.pageSize,
|
||||
total: 0,
|
||||
currentPage: 1,
|
||||
loading: false,
|
||||
|
|
@ -111,7 +112,8 @@
|
|||
async getData(){
|
||||
this.loading = true;
|
||||
var reqData = {
|
||||
page: this.currentPage
|
||||
[config.request.page]: this.currentPage,
|
||||
[config.request.pageSize]: this.pageSize
|
||||
}
|
||||
Object.assign(reqData, this.tableParams)
|
||||
try {
|
||||
|
|
@ -121,10 +123,16 @@
|
|||
this.emptyText = error.statusText;
|
||||
return false;
|
||||
}
|
||||
this.emptyText = "暂无数据";
|
||||
this.tableData = res.data;
|
||||
this.total = res.count;
|
||||
var response = config.parseData(res);
|
||||
if(response.code != 200){
|
||||
this.loading = false;
|
||||
this.emptyText = response.msg;
|
||||
}else{
|
||||
this.emptyText = "暂无数据";
|
||||
this.tableData = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
//分页点击
|
||||
reload(){
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import config from "@/config/tableSelect";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
modelValue: null,
|
||||
|
|
@ -44,15 +46,15 @@
|
|||
keyword: null,
|
||||
defaultValue: [],
|
||||
tableData: [],
|
||||
pageSize: 20,
|
||||
pageSize: config.pageSize,
|
||||
total: 0,
|
||||
currentPage: 1,
|
||||
defaultProps: {
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
page: 'page',
|
||||
pageSize: 'pageSize',
|
||||
keyword: 'keyword'
|
||||
label: config.props.label,
|
||||
value: config.props.value,
|
||||
page: config.request.page,
|
||||
pageSize: config.request.pageSize,
|
||||
keyword: config.request.keyword
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -92,8 +94,9 @@
|
|||
[this.defaultProps.keyword]: this.keyword
|
||||
}
|
||||
var res = await this.apiObj.get(reqData);
|
||||
this.tableData = res.data.rows;
|
||||
this.total = res.data.total;
|
||||
var parseData = config.parseData(res)
|
||||
this.tableData = parseData.rows;
|
||||
this.total = parseData.total;
|
||||
this.loading = false;
|
||||
//表格默认赋值
|
||||
this.$nextTick(() => {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import API from "@/api";
|
||||
import config from "@/config/upload";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
action: { type: String, default: "" },
|
||||
apiObj: { type: Object, default: () => {} },
|
||||
accept: { type: String, default: ".jpg, .png, .jpeg, .gif" },
|
||||
maxSize: { type: Number, default: 10 },
|
||||
maxSize: { type: Number, default: config.maxSize },
|
||||
title: { type: String, default: "" },
|
||||
icon: { type: String, default: "el-icon-plus" },
|
||||
onSuccess: { type: Function, default: () => { return true } }
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
before(file){
|
||||
const maxSize = file.size / 1024 / 1024 < this.maxSize;
|
||||
if (!maxSize) {
|
||||
this.$message.warning('上传文件大小不能超过 10MB!');
|
||||
this.$message.warning(`上传文件大小不能超过 ${this.maxSize}MB!`);
|
||||
return false;
|
||||
}
|
||||
this.isImg(file.name)
|
||||
|
|
@ -89,10 +89,11 @@
|
|||
if(os!=undefined && os==false){
|
||||
return false;
|
||||
}
|
||||
if(res.code != 200){
|
||||
this.$message.warning(res.message || "上传文件未知错误")
|
||||
var response = config.parseData(res);
|
||||
if(response.code != 200){
|
||||
this.$message.warning(response.msg || "上传文件未知错误")
|
||||
}else{
|
||||
this.img = res.data.src;
|
||||
this.img = response.src;
|
||||
}
|
||||
},
|
||||
error(err){
|
||||
|
|
@ -108,7 +109,7 @@
|
|||
this.img = ""
|
||||
},
|
||||
request(param){
|
||||
var apiObj = API.default.upload;
|
||||
var apiObj = config.apiObj;
|
||||
if(this.apiObj){
|
||||
apiObj = this.apiObj;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import API from "@/api";
|
||||
import config from "@/config/upload";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
action: { type: String, default: "" },
|
||||
apiObj: { type: Object, default: () => {} },
|
||||
accept: { type: String, default: ".jpg, .png, .jpeg, .gif" },
|
||||
maxSize: { type: Number, default: 10 },
|
||||
maxSize: { type: Number, default: config.maxSize },
|
||||
title: { type: String, default: "" },
|
||||
icon: { type: String, default: "el-icon-plus" }
|
||||
},
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
before(file){
|
||||
const maxSize = file.size / 1024 / 1024 < this.maxSize;
|
||||
if (!maxSize) {
|
||||
this.$message.warning('上传文件大小不能超过 10MB!');
|
||||
this.$message.warning(`上传文件大小不能超过 ${this.maxSize}MB!`);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
@ -131,7 +131,8 @@
|
|||
this.fileList = fileList
|
||||
},
|
||||
success(res, file){
|
||||
file.url = res.data.src
|
||||
var response = config.parseData(res);
|
||||
file.url = response.src
|
||||
},
|
||||
progress(){
|
||||
|
||||
|
|
@ -149,7 +150,7 @@
|
|||
this.fileList.splice(index, 1);
|
||||
},
|
||||
request(param){
|
||||
var apiObj = API.default.upload;
|
||||
var apiObj = config.apiObj;
|
||||
if(this.apiObj){
|
||||
apiObj = this.apiObj;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
//数据表格配置
|
||||
|
||||
export default {
|
||||
pageSize: 20, //表格每一页条数
|
||||
parseData: function (res) { //数据分析
|
||||
return {
|
||||
rows: res.data, //分析行数据字段结构
|
||||
total: res.count, //分析总数字段结构
|
||||
msg: res.message, //分析描述字段结构
|
||||
code: res.code //分析状态字段结构
|
||||
}
|
||||
},
|
||||
request: { //请求规定字段
|
||||
page: 'page', //规定当前分页字段
|
||||
pageSize: 'pageSize' //规定一页条数字段
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//表格选择器配置
|
||||
|
||||
export default {
|
||||
pageSize: 20, //表格每一页条数
|
||||
parseData: function (res) {
|
||||
return {
|
||||
rows: res.data.rows, //分析行数据字段结构
|
||||
total: res.data.total, //分析总数字段结构
|
||||
msg: res.message, //分析描述字段结构
|
||||
code: res.code //分析状态字段结构
|
||||
}
|
||||
},
|
||||
request: {
|
||||
page: 'page', //规定当前分页字段
|
||||
pageSize: 'pageSize', //规定一页条数字段
|
||||
keyword: 'keyword' //规定搜索字段
|
||||
},
|
||||
props: {
|
||||
label: 'label', //映射label显示字段
|
||||
value: 'value', //映射value值字段
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import API from "@/api";
|
||||
|
||||
//上传配置
|
||||
|
||||
export default {
|
||||
apiObj: API.default.upload, //上传请求API对象
|
||||
maxSize: 10, //最大文件大小 默认10MB
|
||||
parseData: function (res) {
|
||||
return {
|
||||
code: res.code, //分析状态字段结构
|
||||
src: res.data.src, //分析图片远程地址结构
|
||||
msg: res.message //分析描述字段结构
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue