154 lines
3.5 KiB
JavaScript
154 lines
3.5 KiB
JavaScript
// 等级
|
||
export const levelTypeMenu = [
|
||
{ value: "HIGH", label: "高危/高等级告警" },
|
||
{ value: "MEDIUM", label: "中危/中等级告警" },
|
||
{ value: "LOW", label: "低危/恢复/普通状态变化" },
|
||
{ value: "INFO", label: "信息/普通事件" },
|
||
];
|
||
// 唯一码状态
|
||
export const statusMenu = [
|
||
{
|
||
value: 0,
|
||
label: "初始化创建",
|
||
},
|
||
{
|
||
value: 1,
|
||
label: "入库单开单",
|
||
},
|
||
{
|
||
value: 2,
|
||
label: "已入库",
|
||
},
|
||
{
|
||
value: 3,
|
||
label: "出库单开单",
|
||
},
|
||
{
|
||
value: 4,
|
||
label: "已出库",
|
||
},
|
||
{
|
||
value: 9,
|
||
label: "已作废",
|
||
},
|
||
];
|
||
// 入库单、出库单状态
|
||
const billTypeMenu = [
|
||
{
|
||
value: "0",
|
||
label: "已提交",
|
||
},
|
||
{
|
||
value: "1",
|
||
label: "已完成",
|
||
},
|
||
{
|
||
value: "4",
|
||
label: "已取消",
|
||
},
|
||
];
|
||
|
||
// 订单状态为0时 再查一次
|
||
const billStatueMenu = [
|
||
{
|
||
value: "0",
|
||
label: "库单已提交",
|
||
},
|
||
{
|
||
value: "1",
|
||
label: "全部入库",
|
||
},
|
||
{
|
||
value: "2",
|
||
label: "物料部分",
|
||
},
|
||
];
|
||
/**
|
||
* 根据传入数组和id,找到他的label
|
||
* @param {String} deptId value
|
||
* @param {Array} list 映射数组
|
||
* @param {Object} info 映射数组对应的label、name字段名
|
||
* @returns {String} label
|
||
*/
|
||
export const getDictLabel = (
|
||
deptId,
|
||
list,
|
||
info = { name: "label", value: "value" },
|
||
) => {
|
||
const { name, value } = info;
|
||
return list.find((i) => `${i?.[value]}` === `${deptId}`)?.[name] || "-";
|
||
};
|
||
/**
|
||
* 根据部门ID,递归查找它的完整层级ID路径 [祖先..., 自己]
|
||
* @param {Array} tree 部门树
|
||
* @param {Number} targetDeptId 要找的部门ID
|
||
* @returns {Array} 完整ID路径
|
||
*/
|
||
export function getDeptIdPath(tree, targetDeptId) {
|
||
for (const item of tree) {
|
||
// 如果当前就是目标,返回自己
|
||
if (item.deptId === targetDeptId) {
|
||
return [item.deptId];
|
||
}
|
||
// 如果有子节点,递归找
|
||
if (item.children && item.children.length) {
|
||
const res = getDeptIdPath(item.children, targetDeptId);
|
||
if (res.length) {
|
||
return [item.deptId, ...res];
|
||
}
|
||
}
|
||
}
|
||
return [];
|
||
}
|
||
|
||
/**
|
||
* 获取入库/出库单状态展示文本
|
||
* @param {any} val - 状态
|
||
* @param {string|number} status - 物料状态
|
||
* @param {number} flag - 1=出库 0=入库
|
||
* @returns {string} 状态文本
|
||
*/
|
||
export const getBillType = (val, status, flag) => {
|
||
const valStr = String(val);
|
||
const statusStr = String(status);
|
||
|
||
if (valStr === "0") {
|
||
const statusItem = billStatueMenu.find((item) => item.value === statusStr);
|
||
if (!statusItem) return "";
|
||
|
||
const isOut = flag === 1;
|
||
const stateVal = statusItem.value;
|
||
|
||
// 状态 0:前缀拼接 入/出
|
||
if (stateVal === "0") {
|
||
return isOut ? "出" + statusItem.label : "入" + statusItem.label;
|
||
}
|
||
|
||
// 状态 2:后缀拼接 入库/出库
|
||
if (stateVal === "2") {
|
||
return isOut ? statusItem.label + "出库" : statusItem.label + "入库";
|
||
}
|
||
|
||
// 其他状态直接返回
|
||
return statusItem.label;
|
||
}
|
||
|
||
// 非0:走普通单据类型菜单
|
||
return billTypeMenu.find((item) => item.value === valStr)?.label || "";
|
||
};
|
||
// 获取出入库单的状态以及tag颜色
|
||
export const getColor = (val, status) => {
|
||
if (val == "0") {
|
||
if (status == "0") {
|
||
return "color:#e6a23c;font-weight:500;font-size:12px;";
|
||
}
|
||
if (status == "2") {
|
||
return "color:#C0C0C0;font-weight:500;font-size:12px;";
|
||
}
|
||
} else if (val == "1") {
|
||
return "color:#67c23a;font-weight:500;font-size:12px;";
|
||
} else {
|
||
return "color:#f56c6c;font-weight:500;font-size:12px;";
|
||
}
|
||
};
|