Files
klp-oa/klp-ui/src/api/l2/stop.js
2025-10-10 14:40:29 +08:00

43 lines
1.1 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 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 {
updateStoppage: (params) => l2Request({
method: 'put',
data: params,
url: '/api/stoppage/update'
}),
listStoppage: (data) => l2Request({
method: 'post',
data,
url: '/api/stoppage/list'
}),
deleteStoppage: (stopid) => l2Request({
method: 'delete',
url: `/api/stoppage/delete/${stopid}`
}),
getStoppageSummary: (data) => l2Request({
method: 'post',
data,
url: '/api/stoppage/calc'
})
}
}