factory_web/src/config/table.js

71 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//数据表格配置
import tool from '@/utils/tool'
export default {
successCode: 200, //请求完成代码
pageSize: 20, //表格每一页条数
pageSizes: [1, 10, 20, 30, 40, 50,100,200], //表格可设置的一页条数
paginationLayout: "total, sizes, prev, pager, next, jumper", //表格分页布局,可设置"total, sizes, prev, pager, next, jumper"
parseData: function (res) { //数据分析
return {
data: res, //分析无分页的数据字段结构
rows: res.results, //分析行数据字段结构
total: res.count, //分析总数字段结构
summary: res.summary, //分析合计行字段结构
// msg: res.err_msg, //分析描述字段结构
// code: res.err_code //分析状态字段结构
}
},
request: { //请求规定字段
page: 'page', //规定当前分页字段
pageSize: 'page_size', //规定一页条数字段
prop: 'prop', //规定排序字段名字段
order: 'ordering' //规定排序规格字段
},
/**
* 自定义列保存处理
* @tableName scTable组件的props->tableName
* @column 用户配置好的列
*/
columnSettingSave: function (tableName, column) {
return new Promise((resolve) => {
setTimeout(()=>{
//这里为了演示使用了session和setTimeout演示开发时应用数据请求
tool.session.set(tableName, column)
resolve(true)
},1000)
})
},
/**
* 获取自定义列
* @tableName scTable组件的props->tableName
* @column 组件接受到的props->column
*/
columnSettingGet: function (tableName, column) {
return new Promise((resolve) => {
//这里为了演示使用了session和setTimeout演示开发时应用数据请求
const userColumn = tool.session.get(tableName)
if(userColumn){
resolve(userColumn)
}else{
resolve(column)
}
})
},
/**
* 重置自定义列
* @tableName scTable组件的props->tableName
* @column 组件接受到的props->column
*/
columnSettingReset: function (tableName, column) {
return new Promise((resolve) => {
//这里为了演示使用了session和setTimeout演示开发时应用数据请求
setTimeout(()=>{
tool.session.remove(tableName)
resolve(column)
},1000)
})
}
}