summaryrefslogtreecommitdiff
path: root/lib/approval-line/utils
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-08-11 09:34:40 +0000
committerjoonhoekim <26rote@gmail.com>2025-08-11 09:34:40 +0000
commitbcd462d6e60871b86008e072f4b914138fc5c328 (patch)
treec22876fd6c6e7e48254587848b9dff50cdb8b032 /lib/approval-line/utils
parentcbb4c7fe0b94459162ad5e998bc05cd293e0ff96 (diff)
(김준회) 리치텍스트에디터 (결재템플릿을 위한 공통컴포넌트), command-menu 에러 수정, 결재 템플릿 관리, 결재선 관리, ECC RFQ+PR Item 수신시 비즈니스테이블(ProcurementRFQ) 데이터 적재, WSDL 오류 수정
Diffstat (limited to 'lib/approval-line/utils')
-rw-r--r--lib/approval-line/utils/format.ts53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/approval-line/utils/format.ts b/lib/approval-line/utils/format.ts
new file mode 100644
index 00000000..d74c7d1e
--- /dev/null
+++ b/lib/approval-line/utils/format.ts
@@ -0,0 +1,53 @@
+export interface SimpleApln {
+ seq: string
+ name?: string
+ emailAddress?: string
+ role: string
+}
+
+export function formatApprovalLine(aplns: SimpleApln[]): string {
+ if (!aplns || aplns.length === 0) return '결재자 없음'
+
+ const roleMap: Record<string, string> = {
+ '0': '기안',
+ '1': '결재',
+ '2': '합의',
+ '3': '후결',
+ '4': '병렬합의',
+ '7': '병렬결재',
+ '9': '통보',
+ }
+
+ const groupedBySeq = aplns.reduce<Record<string, SimpleApln[]>>((groups, apln) => {
+ const seq = apln.seq
+ if (!groups[seq]) groups[seq] = []
+ groups[seq].push(apln)
+ return groups
+ }, {})
+
+ const sortedSeqs = Object.keys(groupedBySeq).sort((a, b) => parseInt(a) - parseInt(b))
+
+ return sortedSeqs
+ .map((seq) => {
+ const group = groupedBySeq[seq]
+ const isParallel = group.length > 1 || group.some((apln) => apln.role === '4' || apln.role === '7')
+ if (isParallel) {
+ const parallelMembers = group
+ .map((apln) => {
+ const name = apln.name || apln.emailAddress || '이름없음'
+ const role = roleMap[apln.role] || '알수없음'
+ return `${name}(${role})`
+ })
+ .join(', ')
+ return `[${parallelMembers}]`
+ } else {
+ const apln = group[0]
+ const name = apln.name || apln.emailAddress || '이름없음'
+ const role = roleMap[apln.role] || '알수없음'
+ return `${name}(${role})`
+ }
+ })
+ .join(' → ')
+}
+
+