1.交班新增选择是否打印商品销售数据

This commit is contained in:
gyq
2024-07-23 10:25:20 +08:00
parent a282636266
commit d2183eec37
16 changed files with 412 additions and 400 deletions

View File

@@ -40,9 +40,10 @@ export function clearNoNum(obj) {
* 保留小数n位不进行四舍五入
* num你传递过来的数字,
* decimal你保留的几位,默认保留小数后两位
* isInt 是否保留0
*/
export function formatDecimal(num, decimal = 2) {
num = num.toString();
export function formatDecimal(num, decimal = 2, isInt = false) {
num = num.toFixed(3).toString();
const index = num.indexOf(".");
if (index !== -1) {
num = num.substring(0, decimal + index + 1);
@@ -50,5 +51,9 @@ export function formatDecimal(num, decimal = 2) {
num = num.substring(0);
}
//截取后保留两位小数
return parseFloat(num).toFixed(decimal);
if (isInt) {
return parseFloat(num);
} else {
return parseFloat(num).toFixed(decimal);
}
}

61
src/utils/request_kp.js Normal file
View File

@@ -0,0 +1,61 @@
import axios from "axios";
import { ElMessage } from "element-plus";
import useStorage from "@/utils/useStorage";
import router from "@/router";
const service = axios.create({
baseURL:
import.meta.env.MODE == "development"
? "/kp/"
: import.meta.env.VITE_API_KP_URL,
// withCredentials: true, // 跨域请求时发送 cookies
timeout: 5000, // 请求超时
});
// 请求拦截器
service.interceptors.request.use(
(config) => {
// // 在发送请求之前做些什么 token
// if (useStorage.get("douyin") && useStorage.get("douyin").token) {
// config.headers["bausertoken"] = useStorage.get("douyin").token;
// // config.headers['Content-Type'] = 'application/json'
// }
config.headers["ispc"] = 1;
return config;
},
(error) => {
// 处理请求错误
return Promise.reject(error);
}
);
// 响应拦截器
service.interceptors.response.use(
(response) => {
// 对响应数据做点什么
if (+response.status === 200) {
if (+response.data.code == 1) {
return response.data.data;
} else {
// 响应错误
ElMessage.error(response.data.msg);
return Promise.reject(response.data);
}
}
},
(error) => {
// 对响应错误做点什么
if (error.message.indexOf("timeout") != -1) {
ElMessage.error("网络超时");
} else if (error.message == "Network Error") {
ElMessage.error("网络连接错误");
} else {
console.log(error);
if (error.response.data) ElMessage.error(error.response.statusText);
else ElMessage.error("接口路径找不到");
}
return Promise.reject(error);
}
);
export default service;