Files
hazardousWaste_app/pages/until.js

124 lines
2.7 KiB
JavaScript
Raw Normal View History

2026-04-03 08:38:34 +08:00
import dayjs from "dayjs";
import numeral from "numeral";
// 订单状态
// 0=入库申请,1=入库成功2=出库申请3=出库成功4=作废
const billTypeMenu = [
{
value: "0",
label: "入库单已提交",
},
{
value: "1",
label: "已完成",
},
{
value: "2",
label: "出库单已提交",
},
{
value: "3",
label: "已完成",
},
{
value: "4",
label: "已取消",
},
];
// 订单状态为0时 再查一次
const billStatueMenu = [
{
value: "0",
label: "入库单已提交",
},
{
value: "1",
label: "全部入库",
},
{
value: "2",
label: "物料部分入库",
},
];
// 物料状态
const materialType = [
{
value: "0",
label: "未提交",
},
{
value: "1",
label: "已提交",
},
];
// 入/出库单状态的label
export const getBillType = (val, status) => {
if (val === "0") {
return billStatueMenu.find((i) => i.value == `${status}`)?.label;
}
return billTypeMenu.find((i) => i.value == `${val}`)?.label;
};
// 获取出入库单的状态以及tag颜色
export const getColor = (val) => {
if (val == "0" || val == "2") {
return "color:#B8B8B8;font-weight:500;font-size:12px;";
} else if (val == "1" || val == "3") {
return "color:green;font-weight:500;font-size:12px;";
} else {
return "color:red;font-weight:500;font-size:12px;";
}
};
// 时间格式化
export const formatDate = (t, fmt = "YYYY-MM-DD HH:mm:ss") =>
t ? dayjs(t).format(fmt) : "-";
// 数字格式化
export const formatNum = (num, fmt = "0.00") =>
num ? numeral(num).format(fmt) : "-";
// 入库单/出库单:获取已入库、出库数量
// item:此列数据 type已入库、剩余数量
export const getStockQuantity = (item, type) => {
const num = item.quantity;
const status = item.status;
// 未入库
if (status == "0") {
if (type == "complete") {
return "0.000";
} else {
return formatNum(num, "0.00");
}
} else {
if (type == "complete") {
return formatNum(num, "0.000");
} else {
return "0.00";
}
}
};
// 清楚缓存 - 将所有需要清楚的缓存写入此处不要写登录信息
export const removeStorage = () => {
uni.removeStorageSync("app_warehousing");
uni.removeStorageSync("app_storageArea");
uni.removeStorageSync("app_billRemark");
uni.removeStorageSync("app_material");
uni.removeStorageSync("app_material_select_list");
};
// 对象转 URL 查询字符串 ?a=1&b=2
export const objectToQuery = (params) => {
if (!params || Object.keys(params).length === 0) return "";
const query = Object.entries(params)
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
.join("&");
return "?" + query;
};