Files
xgy-oa/klp-ui/src/api/l2/roller.js

75 lines
1.7 KiB
JavaScript
Raw Normal View History

2025-10-10 14:40:29 +08:00
import axios from 'axios'
export default function createFetch(url) {
const l2Request = axios.create({
baseURL: url,
headers: {
'Content-Type': 'application/json'
},
timeout: 10000,
// 自定义响应数据转换处理大整数ID精度问题
transformResponse: [data => {
// 在JSON解析前将所有id数值转换为字符串避免大整数精度丢失
const modifiedData = data.replace(/"id":\s*(\d+)/g, '"id": "$1"');
return JSON.parse(modifiedData);
}]
})
l2Request.interceptors.response.use(response => {
return response.data
})
return {
getRollIdList: () => {
return l2Request({
method: 'get',
url: '/api/roller/history/rollid'
})
},
getChangeIdList: () => {
return l2Request({
method: 'get',
url: '/api/roller/history/changeid'
})
},
getRollHistorytList: (params) => {
return l2Request({
method: 'post',
data: params,
url: '/api/roller/history/list'
})
},
backupRoll: (data) => {
return l2Request({
method: 'post',
data,
url: '/api/roller/change/standby'
})
},
onlineRoll: (data) => {
return l2Request({
method: 'post',
data,
url: '/api/roller/change/online'
})
},
getOnlineRollList: () => {
return l2Request({
method: 'get',
url: '/api/roller/data/online'
})
},
getOfflineRollList: (position, type) => {
return l2Request({
method: 'get',
url: `/api/roller/data/ready/${position}/${type}`
})
},
getReadyRollList: () => {
return l2Request({
method: 'get',
url: '/api/roller/data/standby'
})
}
}
}