perf: 待办目录: 处理订单重复

dev/ckeditor
Lei OT 1 month ago
parent fdfd633ecf
commit f1bc44da07

@ -171,7 +171,7 @@ export const getEmailDirAction = async (params = { opi_sn: '' }) => {
return errcode === 0 ? tree : []; return errcode === 0 ? tree : [];
}; };
export const getTodoOrdersAction = async (params) => { export const getTodoOrdersAction = async (params) => {
const opi_arr = params.opisn.split(','); const opi_arr = params.opisn.split(',')
const defaultStickyTree = opi_arr.reduce( const defaultStickyTree = opi_arr.reduce(
(a, ele) => ({ (a, ele) => ({
...a, ...a,
@ -204,16 +204,18 @@ export const getTodoOrdersAction = async (params) => {
{}, {},
) )
const { errcode, result } = await fetchJSON(`${API_HOST}/getwlorder`, params) const { errcode, result } = await fetchJSON(`${API_HOST}/getwlorder`, params)
const orderList = errcode === 0 ? result : []; const _result_unique = uniqWith(result, (a, b) => a.COLI_SN === b.COLI_SN)
const byOPI = groupBy(orderList, 'OPI_SN'); const orderList = errcode === 0 ? _result_unique : []
const byOPI = groupBy(orderList, 'OPI_SN')
const byState = Object.keys(byOPI).reduce((acc, key) => { const byState = Object.keys(byOPI).reduce((acc, key) => {
const sticky = groupBy(byOPI[key], (ele) => ([1, 2, 6].includes(ele.coli_ordertype) ? 0 : ([3,4,5].includes(ele.coli_ordertype) ? 1 : 2))) const sticky = groupBy(byOPI[key], (ele) => ([1, 2, 6].includes(ele.coli_ordertype) ? 0 : [3, 4, 5].includes(ele.coli_ordertype) ? 1 : 2))
const treeNode = [ const treeNode = [
{ {
key: key + '-today', key: key + '-today',
title: '今日任务', title: '今日任务',
getMails: false,iconIndex: 'star', getMails: false,
_raw: {COLI_SN: 0, IsTrue: 0,}, iconIndex: 'star',
_raw: { COLI_SN: 0, IsTrue: 0 },
children: (sticky[0] || []).map((o) => ({ children: (sticky[0] || []).map((o) => ({
key: `today-${o.COLI_SN}`, key: `today-${o.COLI_SN}`,
title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`,
@ -221,14 +223,15 @@ export const getTodoOrdersAction = async (params) => {
parent: key + '-today', parent: key + '-today',
parentTitle: '今日任务', parentTitle: '今日任务',
parentIconIndex: 'star', parentIconIndex: 'star',
_raw: { ...o, VKey: o.COLI_SN, VName: o.COLI_ID, VParent:-1, IsTrue: 0, ApplyDate: '', OrderSourceType: 227001, parent: -1 }, _raw: { ...o, VKey: o.COLI_SN, VName: o.COLI_ID, VParent: -1, IsTrue: 0, ApplyDate: '', OrderSourceType: 227001, parent: -1 },
})), })),
}, },
{ {
key: key + '-todo', key: key + '-todo',
title: '待办任务', title: '待办任务',
getMails: false,iconIndex: 'calendar', getMails: false,
_raw: {COLI_SN: 0, IsTrue: 0,}, iconIndex: 'calendar',
_raw: { COLI_SN: 0, IsTrue: 0 },
children: (sticky[2] || []).map((o) => ({ children: (sticky[2] || []).map((o) => ({
key: `todo-${o.COLI_SN}`, key: `todo-${o.COLI_SN}`,
title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`,
@ -236,14 +239,17 @@ export const getTodoOrdersAction = async (params) => {
parent: key + '-todo', parent: key + '-todo',
parentTitle: '待办任务', parentTitle: '待办任务',
parentIconIndex: 'calendar', parentIconIndex: 'calendar',
_raw: { ...o, VKey: o.COLI_SN, VName: o.COLI_ID, VParent:-1, IsTrue: 0, ApplyDate: '', OrderSourceType: 227001, parent: -1 }, _raw: { ...o, VKey: o.COLI_SN, VName: o.COLI_ID, VParent: -1, IsTrue: 0, ApplyDate: '', OrderSourceType: 227001, parent: -1 },
})), })),
}, },
...(!isEmpty(sticky[1] || []) ? [{ ...(!isEmpty(sticky[1] || [])
? [
{
key: key + '-reminder', key: key + '-reminder',
title: '催信', title: '催信',
getMails: false,iconIndex: 'reminder', getMails: false,
_raw: {COLI_SN: 0, IsTrue: 0,}, iconIndex: 'reminder',
_raw: { COLI_SN: 0, IsTrue: 0 },
children: (sticky[1] || []).map((o) => ({ children: (sticky[1] || []).map((o) => ({
key: `reminder-${o.COLI_SN}`, key: `reminder-${o.COLI_SN}`,
title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`,
@ -251,13 +257,15 @@ export const getTodoOrdersAction = async (params) => {
parent: key + '-reminder', parent: key + '-reminder',
parentTitle: '催信', parentTitle: '催信',
parentIconIndex: 'reminder', parentIconIndex: 'reminder',
_raw: { ...o, VKey: o.COLI_SN, VName: o.COLI_ID, VParent:-1, IsTrue: 0, ApplyDate: '', OrderSourceType: 227001, parent: -1 }, _raw: { ...o, VKey: o.COLI_SN, VName: o.COLI_ID, VParent: -1, IsTrue: 0, ApplyDate: '', OrderSourceType: 227001, parent: -1 },
})), })),
}] : []), },
]
: []),
] ]
return { ...acc, [key]: treeNode } return { ...acc, [key]: treeNode }
}, defaultStickyTree) }, defaultStickyTree)
return errcode === 0 ? byState : defaultStickyTree; return errcode === 0 ? byState : defaultStickyTree
}; };
/** /**
* 获取待办目录和邮箱目录 * 获取待办目录和邮箱目录

Loading…
Cancel
Save