From 368f2ef5e659b7cb13c40bca7fc0769a47cca6ec Mon Sep 17 00:00:00 2001 From: x2Skyz Date: Tue, 25 Nov 2025 21:11:57 +0700 Subject: [PATCH] . --- ng-ttc-frontend/src/app/app.module.ts | 4 +- .../budget-aproval/budget-aproval.css | 16 + .../budget-aproval/budget-aproval.html | 614 +++++++++--------- .../budget-aproval/budget-aproval.ts | 327 +++++++--- .../main-landing/main-landing.component.html | 24 +- .../main-manager/main-manager.component.html | 233 ++++--- .../main-manager/main-manager.component.ts | 128 +--- .../budget-aproval-content.css | 0 .../budget-aproval-content.html | 1 + .../budget-aproval-content.ts | 92 +++ .../main-manager-content.component.ts | 171 ++--- .../main-control-routing.module.ts | 16 +- .../main-control/main-control.module.ts | 7 +- .../src/app/interfaces/dashboard.interface.ts | 18 + .../src/app/interfaces/main.interface.ts | 26 + .../services/state/budget-state.service.ts | 52 +- .../services/state/project-state.service.ts | 24 +- .../services/state/report-state.service.ts | 36 +- .../state/transaction-state.service.ts | 36 + 19 files changed, 1014 insertions(+), 811 deletions(-) create mode 100644 ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.css create mode 100644 ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.html create mode 100644 ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.ts create mode 100644 ng-ttc-frontend/src/app/interfaces/main.interface.ts create mode 100644 ng-ttc-frontend/src/app/services/state/transaction-state.service.ts diff --git a/ng-ttc-frontend/src/app/app.module.ts b/ng-ttc-frontend/src/app/app.module.ts index 668afd3..68fa7a5 100644 --- a/ng-ttc-frontend/src/app/app.module.ts +++ b/ng-ttc-frontend/src/app/app.module.ts @@ -28,6 +28,7 @@ import { CachingInterceptor } from './services/caching.interceptor'; import { MainProject } from './component/main-project/main-project'; import { MainProjectContent } from './content/main-project-content/main-project-content'; import { MainProjectAdd } from './component/main-project-add/main-project-add'; +import { BudgetAprovalContent } from './content/budget-aproval-content/budget-aproval-content'; // import { BudgetAproval } from './component/budget-aproval/budget-aproval'; // import { AccDateFormatPipe } from './pipe/dtmtodatetime.pipe'; // import { DtmtodatetimePipe } from './dtmtodatetime.pipe'; @@ -39,7 +40,8 @@ import { MainProjectAdd } from './component/main-project-add/main-project-add'; SidebarContentComponent, SidebarComponent, LicensePrivacyTermsComponent, - TokenTimerComponent + TokenTimerComponent, + // BudgetAprovalContent // MainProjectAdd, // MainProject, // MainProjectContent, diff --git a/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.css b/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.css index e69de29..0cf2623 100644 --- a/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.css +++ b/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.css @@ -0,0 +1,16 @@ + .animate-fade-in-down { animation: fadeInDown 0.3s ease-out; } + .animate-fade-in { animation: fadeIn 0.2s ease-out; } + + @keyframes fadeInDown { + from { opacity: 0; transform: translateY(-10px); } + to { opacity: 1; transform: translateY(0); } + } + @keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } + } + input[type=number]::-webkit-inner-spin-button, + input[type=number]::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; + } diff --git a/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.html b/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.html index 90a8491..dd2e64f 100644 --- a/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.html +++ b/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.html @@ -1,307 +1,339 @@ -
- -
-

- รายการงบประมาณของโครงการ: ระบบจัดการน้ำดื่ม - -

+
-
- แสดงข้อมูล {{ budgetItems.length }} รายการ + +
+
+

+ + จัดสรรงบประมาณ +

+

โครงการ: {{projectTitle}}

+
+
+ รายการทั้งหมด: {{ myTrnMst.length }} รายการ
- - - +
+ +
- ➕ เพิ่มเข้าตาราง - - - --> - -
- -
-

เพิ่มรายการงบประมาณสำหรับโครงการ

- +
+ + {{ isEditMode ? 'แก้ไขรายการ' : 'เพิ่มรายการงบประมาณ' }} +
+
- - @if(!isFormExpanded){ -
-
-
- - + + + @if(isFormExpanded){ +
+
+
+ + +
+ + + + @if (budgetForm.get('bdgcod')?.invalid && budgetForm.get('bdgcod')?.touched) { +
+ + กรุณาเลือกหมวดงบ +
+ } +
+ + +
+ +
+ + THB
+ + @if (budgetForm.get('amount')?.invalid && budgetForm.get('amount')?.touched) { +
+ + ระบุจำนวนเงินที่ถูกต้อง +
+ } +
-
- - -
-
- -
- - - - - - - + + @if(isEditMode) { + + } +
+
} -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
ลำดับชื่องบประมาณจำนวนเงินดำเนินการ
{{ i + 1 }} {{ p.code }} - - - - - - -
- -
- - - -
- ยอดรวมทั้งหมด: - - {{ getTotalAmount() | number:'1.0-2' }} บาท -
+ +
+
+ + + + + + + + + + + @for (idx of myTrnMst; track idx.trnseq; let i = $index) { + + + + + + + + + + } @empty { + + + + } + + + + + + + + + + +
#รายการ / หมวดงบจำนวนเงิน (บาท)จัดการ
{{ i + 1 }} +
{{ idx.trnbdgnam }}
+
{{ idx.trnbdgcod }}
+
+ {{ idx.trnexpbdg | number:'1.2-2' }} + +
+ + +
+
+
📭
+

ยังไม่มีรายการงบประมาณ

+
รวมยอดสุทธิ + {{ getTotalAmount() | number:'1.2-2' }} + THB + +
+ + + + + +
+
+
+
+ + + @if(showConfirmModal) { +
+
+ + +
+

+ {{ myTrnMst.length === 0 ? '⚠️' : '💾' }} + {{ myTrnMst.length === 0 ? 'ยืนยันการยกเลิก' : 'ยืนยันการบันทึก' }} +

+ +
+ +
+ +
+ {{ myTrnMst.length === 0 ? '🗑️' : '📝' }} +
+ + +

+ @if(myTrnMst.length === 0) { + คุณต้องการ ยกเลิกการจัดสรรงบประมาณ
ของโครงการนี้ใช่หรือไม่? + } @else { + คุณต้องการ บันทึกข้อมูลการจัดสรรงบประมาณ
ของโครงการนี้ใช่หรือไม่? + } +

+ + +
+
+ จำนวนรายการ: + {{ myTrnMst.length }} รายการ +
+
+ ยอดรวม: + {{ getTotalAmount() | number:'1.2-2' }} บาท +
+
+ + +
+
รายการ:
+ @if(myTrnMst.length > 0) { +
    + @for(item of myTrnMst; track $index) { +
  • {{ item.trnbdgnam }} ({{ item.trnexpbdg | number }})
  • + } +
+ } @else { +

- ไม่พบรายการคงเหลือ (ลบทั้งหมด) -

+ } +
+
+ + +
+ + + +
+
+
+ } + + + + + + @if(showDeleteModal) { +
+
+ +
+

+ 🗑️ ยืนยันการลบ +

+ +
+ +
+
+ ⚠️ +
+

คุณต้องการลบรายการนี้ใช่หรือไม่?

+

การกระทำนี้ไม่สามารถย้อนกลับได้ (ในหน้าจอนี้)

+
+ +
+ + +
+
+
+ } +
diff --git a/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.ts b/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.ts index de0c142..6d28dce 100644 --- a/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.ts +++ b/ng-ttc-frontend/src/app/component/budget-aproval/budget-aproval.ts @@ -1,10 +1,13 @@ +import { TransactionStateService } from './../../services/state/transaction-state.service'; +import { ITrnmst, IDropBdg } from './../../interfaces/main.interface'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { GeneralService } from '../../services/generalservice'; -import { IDropAct, IStateDrop, IStateResultResponse, IActData, IActSumData } from '../../interfaces/dashboard.interface' import { DashboardStateService } from '../../services/state/dashboard-state.service'; import { Router } from '@angular/router'; import { ActivatedRoute } from '@angular/router'; +import { Location } from '@angular/common'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-budget-aproval', @@ -12,109 +15,239 @@ import { ActivatedRoute } from '@angular/router'; templateUrl: './budget-aproval.html', styleUrl: './budget-aproval.css', }) -export class BudgetAproval { - projectCode: any; - project: any; - addItemForm!: FormGroup; - isFormExpanded: boolean = false; +export class BudgetAproval implements OnInit { + @Output() ExpenseEventSubmit = new EventEmitter(); - budgetItems = [ - { code: 'ITEM001', name: 'เอกซ์เรย์', qty: 1, price: 1000 }, - { code: 'ITEM002', name: 'กรอกคำสั่งซื้อ', qty: 1, price: 1500 }, - { code: 'ITEM003', name: 'ตรวจพื้นฐาน', qty: 1, price: 1000 }, - ]; + budgetForm!: FormGroup; + isFormExpanded = true; + isEditMode = false; + editingIndex: number = -1; + showConfirmModal = false; + myTrnMst: ITrnmst[]=[]; + myDropBdg: IDropBdg[]=[]; + param:string = ''; + // State สำหรับการลบ + showDeleteModal = false; + deleteIndex: number = -1; - projects = [ - { code: 'เงินรายได้', name: 'ระบบจัดการน้ำดื่ม', owner: 'นาย A', budget: 20000, status: 'WAIT', acp: 0, bdgnam: 'ยังไมจัดสรร' }, - { code: 'งบดำเนินงาน', name: 'ปรับปรุงอาคาร B', owner: 'นางสาว B', budget: 45000, status: 'WAIT', acp: 0, bdgnam: 'ยังไมจัดสรร'}, - { code: 'ค่ากิจกรรมพัฒนาคุณภาพผู้เรียน', name: 'ซื้อคอมพิวเตอร์', owner: 'นาย C', budget: 30000, status: 'APPROVED', acp: 20000, bdgnam: 'งบดำเนินงาน' } - ]; + // budgetCategoriesDrop = [ + // { dtlcod: 'EXP01', dtlnam: 'ค่าวัสดุอุปกรณ์ (EXP01)' }, + // { dtlcod: 'EXP02', dtlnam: 'ค่าจ้างเหมาแรงงาน (EXP02)' }, + // { dtlcod: 'EXP03', dtlnam: 'ค่าครุภัณฑ์ (EXP03)' } + // ]; - budgetCategoriesDrop = { - expense: [ - { dtlcod: 'BDG001', dtlnam: 'เงินรายได้' }, - { dtlcod: 'BDG002', dtlnam: 'งบดำเนินงาน ปวส.' }, - { dtlcod: 'BDG003', dtlnam: 'โครงการส่งเสริมพัฒนาทักษะวิชาชีพทักษะพื้นฐาน' }, - { dtlcod: 'BDG004', dtlnam: 'ค่ากิจกรรมพัฒนาคุณภาพผู้เรียน' }, - { dtlcod: 'BDG005', dtlnam: 'อุดหนุนส่งเสริมและพัฒนาผู้เรียนองค์การวิชาชีพแห่งประเทศไทย (อวท.)' }, - { dtlcod: 'BDG006', dtlnam: 'งบดำเนินงาน ระยะสั้น' }, - { dtlcod: 'BDG007', dtlnam: 'โครงการบูรณาการการพัฒนาทักษะทางวิชาชีพกับการเสริมสร้างคุณลักษณะอันพึงประสงค์ (FIX IT)' }, - { dtlcod: 'BDG008', dtlnam: 'โครงการพัฒนาทักษะและสมรรถนะวิชาชีพกำลังคน (Up-skill, Re-skill)' }, - { dtlcod: 'BDG009', dtlnam: 'งบดำเนินงาน ปวช.' }, - { dtlcod: 'BDG010', dtlnam: 'โครงการขยายและยกระดับการจัดอาชีวศึกษาระบบทวิภาคีคุณภาพสูง' }, - { dtlcod: 'BDG011', dtlnam: 'ปวช.(สอจ)' }, - { dtlcod: 'BDG012', dtlnam: 'ค่าจัดการเรียนการสอน' }, - { dtlcod: 'BDG013', dtlnam: 'งบดำเนินงาน 170000' }, - { dtlcod: 'BDG014', dtlnam: 'โครงการพัฒนาทักษะและศักยภาพภาพการจัดการเรียนการสอนอาชีวศึกษา' }, - { dtlcod: 'BDG015', dtlnam: 'ศึกษาธิการ' }, - { dtlcod: 'BDG016', dtlnam: 'Up-skill' }, - { dtlcod: 'BDG017', dtlnam: 'ติดตามผู้สำเร็จ' }, - { dtlcod: 'BDG018', dtlnam: 'ทวิภาคี' }, - { dtlcod: 'BDG019', dtlnam: 'พันธุกรรม' }, - { dtlcod: 'BDG020', dtlnam: 'ปวส(สาธารณูประโภค)' }, - { dtlcod: 'BDG021', dtlnam: 'ปวส(ค่าสาธารณูปโภค)' }, - { dtlcod: 'BDG022', dtlnam: 'งบดำเนินงาน (ค่าสาธารณูปโภค)' }, - { dtlcod: 'BDG023', dtlnam: 'ค่าหนังสือเรียน' }, - { dtlcod: 'BDG024', dtlnam: 'โครงการอาชีวะต้านยาเสพติด' }, - { dtlcod: 'BDG025', dtlnam: 'ค่าตอบแทนพนักงานราชการ' }, - { dtlcod: 'BDG026', dtlnam: 'ค่าอุปกรณ์การเรียน' }, - { dtlcod: 'BDG027', dtlnam: 'โครงการยกระดับและพัฒนาขีดความสามารถด้านภาษาและทักษะดิจิทัลเพื่อพัฒนากำลังคนให้มีสมรรถนะสูง' }, - { dtlcod: 'BDG028', dtlnam: 'โครงการอนุรักษ์พันธุกรรมพืชอันเนื่องมาจากพระราชดำริ' }, - { dtlcod: 'BDG029', dtlnam: 'ปวช.(สอจ.)' }, - { dtlcod: 'BDG030', dtlnam: 'โครงการพัฒนาศักยภาพผู้เรียนอาชีวศึกษาในการเป็นผู้ประกอบการ (บ่มเพาะ)' }, - { dtlcod: 'BDG031', dtlnam: 'โครงการพัฒนาและยกระดับการติดตามผู้สำเร็จการศึกษาอาชีวศึกษา' }, - { dtlcod: 'BDG032', dtlnam: 'โครงการเสริมสร้างคุณธรรม จริยธรรมและธรรมาภิบาลในสถานศึกษา' }, - { dtlcod: 'BDG033', dtlnam: 'โครงการจัดการอาชีวศึกษาเพื่อสนองพระราชดำริ' }, - { dtlcod: 'BDG034', dtlnam: 'เงินรายได้ ป.ตรี' }, - { dtlcod: 'BDG035', dtlnam: 'งบดำเนินงาน 235200' } - ] -}; + // budgetItems: IBudgetItem[] = []; + constructor( + private location: Location, + private toastr: ToastrService, + private route: ActivatedRoute, + private transactionStateService: TransactionStateService + ) {} -ngOnInit(): void { - this.setupForm(); -} - -setupForm() { - this.addItemForm = new FormGroup({ - category: new FormControl('', [Validators.required]), - name: new FormControl('', [Validators.required]), - qty: new FormControl(1, [Validators.required, Validators.min(1)]), - price: new FormControl(0, [Validators.required, Validators.min(1)]) - }); -} - -toggleFormCollapse(): void { - this.isFormExpanded = !this.isFormExpanded; -} - -addBudgetItem() { - if (this.addItemForm.invalid) { - this.addItemForm.markAllAsTouched(); - return; + ngOnInit(): void { + this.param = this.route.snapshot.paramMap.get('seq') ?? ''; + this.setupFormControl(); + this.transactionStateService.getTransactionState().subscribe(data => { + this.myTrnMst = data || [] + }); + this.transactionStateService.getBudgetDrop().subscribe(data => { + this.myDropBdg = data ?? [] + }); } - const formValue = this.addItemForm.value; + setupFormControl() { + this.budgetForm = new FormGroup({ + bdgcod: new FormControl('', [Validators.required]), + amount: new FormControl('', [Validators.required, Validators.min(1)]) + }); + } - this.budgetItems.push({ - code: 'NEW' + (this.budgetItems.length + 1).toString().padStart(3, '0'), - name: formValue.name, - qty: formValue.qty, - price: formValue.price, - // category: formValue.category - }); - - // reset form - this.addItemForm.reset({ - category: '', - name: '', - qty: 1, - price: 0 - }); -} - -getTotalAmount() { - return this.budgetItems.reduce((sum, item) => sum + item.qty * item.price, 0); -} + toggleFormCollapse() { + this.isFormExpanded = !this.isFormExpanded; + } + // onSaveSubmit() { + // if (this.budgetForm.invalid) { + // this.budgetForm.markAllAsTouched(); + // return; + // } + + // const formValue = this.budgetForm.value; + // const selectedCode = formValue.bdgcod; + + // // Validation: เช็คว่าหมวดงบซ้ำหรือไม่ + // const duplicateIndex = this.myTrnMst.findIndex(idx => idx.trnbdgcod === selectedCode); + + // if (duplicateIndex !== -1) { + // // กรณีเพิ่มใหม่ (เจอซ้ำ = ห้าม) หรือ กรณีแก้ไข (เจอซ้ำกับแถวอื่นที่ไม่ใช่ตัวเอง = ห้าม) + // if (!this.isEditMode || (this.isEditMode && duplicateIndex !== this.editingIndex)) { + // this.toastr.error(`หมวดงบประมาณนี้ มีอยู่ในตารางแล้ว`, 'ไม่สามารถเพิ่มซ้ำได้', { + // positionClass: 'toast-top-right', + // timeOut: 3500, + // progressBar: true, + // progressAnimation: 'decreasing', + // toastClass: + // 'ngx-toastr error-toast bg-white bg-opacity-90 text-red-700 shadow-lg' + // }) + // return; + // } + // } + + // const category = this.myDropBdg.find(c => c.bdgcod === selectedCode); + + // const newItem: ITrnmst = { + // trnbdgcod: formValue.bdgcod, + // trnbdgnam: category ? category.bdgcod : formValue.bdgcod, + // trnexpbdg: Number(formValue.amount) + // }; + + // if (this.isEditMode && this.editingIndex > -1) { + // this.myTrnMst[this.editingIndex] = newItem; + // this.cancelEdit(); + // } else { + // this.myTrnMst.push(newItem); + // this.budgetForm.reset(); + // this.budgetForm.get('bdgcod')?.setValue(''); + // } + // } + + onSaveSubmit() { + if (this.budgetForm.invalid) { + this.budgetForm.markAllAsTouched(); + return; + } + + const formValue = this.budgetForm.value; + const selectedCode = formValue.bdgcod; + + // 1. Validation: เช็คว่าหมวดงบซ้ำหรือไม่ + const duplicateIndex = this.myTrnMst.findIndex(idx => idx.trnbdgcod === selectedCode); + + if (duplicateIndex !== -1) { + // ถ้าไม่ใช่โหมดแก้ไข หรือ แก้ไขแต่ไปซ้ำกับคนอื่น + if (!this.isEditMode || (this.isEditMode && duplicateIndex !== this.editingIndex)) { + this.toastr.error(`หมวดงบประมาณนี้ (${selectedCode}) มีอยู่ในตารางแล้ว`, 'ไม่สามารถเพิ่มซ้ำได้', { + timeOut: 3500, + progressBar: true + }); + return; + } + } + + // ✅ 2. ค้นหาชื่อหมวดงบ (Name) จาก Dropdown โดยใช้ Code ที่เลือก + const category = this.myDropBdg.find(c => c.bdgcod === selectedCode); + + // ✅ 3. สร้าง Object ใหม่ โดยใส่ชื่อ (trnbdgnam) ที่ค้นหาได้ลงไป + const newItem: ITrnmst = { + trnbdgcod: selectedCode, + // ถ้าเจอชื่อให้ใส่ชื่อ ถ้าไม่เจอให้ใส่รหัสแทน (กันเหนียว) + trnbdgnam: category ? category.bdgnam : selectedCode, + trnexpbdg: Number(formValue.amount), + trnprjnam: this.projectTitle // คงชื่อโครงการเดิมไว้ + }; + + if (this.isEditMode && this.editingIndex > -1) { + // กรณีแก้ไข: Merge ข้อมูลใหม่ทับของเดิม (เพื่อรักษา field อื่นๆ เช่น trnseq ไว้ถ้ามี) + this.myTrnMst[this.editingIndex] = { + ...this.myTrnMst[this.editingIndex], + ...newItem + }; + this.cancelEdit(); + } else { + // กรณีเพิ่มใหม่ + this.myTrnMst.push(newItem); + this.budgetForm.reset(); + this.budgetForm.get('bdgcod')?.setValue(''); + } + } + + editItem(index: number) { + const item = this.myTrnMst[index]; + this.isEditMode = true; + this.editingIndex = index; + this.isFormExpanded = true; + this.budgetForm.patchValue({ + bdgcod: item.trnbdgcod, + amount: item.trnexpbdg + }); + } + + cancelEdit() { + this.isEditMode = false; + this.editingIndex = -1; + this.budgetForm.reset(); + this.budgetForm.get('bdgcod')?.setValue(''); + } + + removeItem(index: number) { + // // if(confirm('ต้องการลบรายการนี้หรือไม่?')) { + // this.myTrnMst.splice(index, 1); + // if (this.isEditMode && this.editingIndex === index) { + // this.cancelEdit(); + // } + // // } + + this.deleteIndex = index; + this.showDeleteModal = true; + } + + confirmDelete() { + if (this.deleteIndex > -1) { + this.myTrnMst.splice(this.deleteIndex, 1); + + // ถ้าลบตัวที่กำลังแก้อยู่ ให้เคลียร์ฟอร์ม + if (this.isEditMode && this.editingIndex === this.deleteIndex) { + this.cancelEdit(); + } + + this.toastr.success('ลบรายการเรียบร้อย', 'สำเร็จ'); + } + this.closeDeleteModal(); + } + + closeDeleteModal() { + this.showDeleteModal = false; + this.deleteIndex = -1; + } + + getTotalAmount() { + return this.myTrnMst.reduce((sum, item) => sum + Number(item.trnexpbdg || 0), 0); + } + + + openConfirmModal() { + this.showConfirmModal = true; + } + + closeConfirmModal() { + this.showConfirmModal = false; + } + + confirmSave() { + const expenseList = this.myTrnMst.map(item => ({ + bdgcod: item.trnbdgcod, + amount: Number(item.trnexpbdg) + })); + + + const body = { + prjseq: this.param, + expenseList: expenseList + }; + + this.expenseEventSubmit(body); + } + + expenseEventSubmit(event: any){ + this.ExpenseEventSubmit.emit(event); + } + + goBack() { + this.location.back(); + } + + get projectTitle(): string { + return this.myTrnMst?.[0]?.trnprjnam ?? ''; + } } diff --git a/ng-ttc-frontend/src/app/component/main-landing/main-landing.component.html b/ng-ttc-frontend/src/app/component/main-landing/main-landing.component.html index 074f4e1..c1d6be5 100644 --- a/ng-ttc-frontend/src/app/component/main-landing/main-landing.component.html +++ b/ng-ttc-frontend/src/app/component/main-landing/main-landing.component.html @@ -22,39 +22,39 @@
-
+

เมนู

- + --> - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - + {{ remainingBudget | number:'1.0-2' }} บาท + + --> - - - -
ลำดับรหัสโครงการชื่อโครงการผู้รับผิดชอบงบที่ขออนุมัติหมวดงบจำนวนที่อนุมัติสถานะดำเนินการ
{{ i + 1 }} {{ p.code }}{{ p.name }}{{ p.owner }} {{ p.budget | number:'1.0-0' }} บาท - - {{ p.bdgnam }} - - - {{ p.acp }} บาท - - +
งบคงเหลือ
+
- อนุมัติแล้ว - รออนุมัติ - ไม่อนุมัติ - -
+ - + + -
- -
+ +
+ + + + + + + + + + + + + + + + + @for(idx of myPrjMst; track idx.prjseq; let i = $index){ + + + + + + + + @if(idx.prjbdgnam){ + + }@else { + + } + + + + + + + + } + +
ลำดับรหัสโครงการชื่อโครงการผู้รับผิดชอบงบที่ขออนุมัติหมวดงบจำนวนที่อนุมัติสถานะดำเนินการ
{{ i + 1 }} {{ idx.prjseq }}{{ idx.prjnam }}{{ idx.prjusrnam }} {{ idx.prjwntbdg | number:'1.0-0' }} บาท{{ idx.prjbdgnam }}ไม่จัดสรร + + {{ idx.prjacpbdg }} บาท + + + อนุมัติแล้ว + รออนุมัติ + ไม่อนุมัติ + + + + - +
+ +
-
+ + + +
diff --git a/ng-ttc-frontend/src/app/component/main-manager/main-manager.component.ts b/ng-ttc-frontend/src/app/component/main-manager/main-manager.component.ts index 737ce38..65609a4 100644 --- a/ng-ttc-frontend/src/app/component/main-manager/main-manager.component.ts +++ b/ng-ttc-frontend/src/app/component/main-manager/main-manager.component.ts @@ -1,8 +1,8 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { GeneralService } from '../../services/generalservice'; -import { IDropAct, IStateDrop, IStateResultResponse, IActData, IActSumData } from '../../interfaces/dashboard.interface' -import { DashboardStateService } from '../../services/state/dashboard-state.service'; +import { IPrjMst } from '../../interfaces/main.interface' +import { ProjectStateService } from '../../services/state/project-state.service'; import { Router } from '@angular/router'; @Component({ @@ -15,6 +15,8 @@ export class MainManagerComponent implements OnInit { mode: string = 'i'; + myPrjMst:IPrjMst[] = []; + totalBudget = 200000; // งบทั้งหมด approvedBudget = 65000; // งบที่อนุมัติแล้ว @@ -24,98 +26,22 @@ export class MainManagerComponent implements OnInit { return this.totalBudget - this.approvedBudget; } - - - projects = [ - { code: 'PRJ001', name: 'ระบบจัดการน้ำดื่ม', owner: 'นาย A', budget: 20000, status: 'WAIT', acp: 0, bdgnam: 'ยังไมจัดสรร' }, - { code: 'PRJ002', name: 'ปรับปรุงอาคาร B', owner: 'นางสาว B', budget: 45000, status: 'WAIT', acp: 0, bdgnam: 'ยังไมจัดสรร'}, - { code: 'PRJ003', name: 'ซื้อคอมพิวเตอร์', owner: 'นาย C', budget: 30000, status: 'APPROVED', acp: 20000, bdgnam: 'งบดำเนินงาน' } - ]; - approveProject(p: any) { - p.status = 'APPROVED'; + p.status = 'BAP'; this.approvedBudget += p.budget; } rejectProject(p: any) { - p.status = 'REJECTED'; + p.status = 'CN'; } - openBudgetDetail(project: any) { - this.router.navigate(['/main/manager/budget', project.code]); + openBudgetDetail(idx: IPrjMst) { + this.router.navigate(['/main/budget/approve', idx.prjseq]); } - - - budgetCategoriesDrop = { - expense: [ - { dtlcod: 'BDG001', dtlnam: 'เงินรายได้' }, - { dtlcod: 'BDG002', dtlnam: 'งบดำเนินงาน ปวส.' }, - { dtlcod: 'BDG003', dtlnam: 'โครงการส่งเสริมพัฒนาทักษะวิชาชีพทักษะพื้นฐาน' }, - { dtlcod: 'BDG004', dtlnam: 'ค่ากิจกรรมพัฒนาคุณภาพผู้เรียน' }, - { dtlcod: 'BDG005', dtlnam: 'อุดหนุนส่งเสริมและพัฒนาผู้เรียนองค์การวิชาชีพแห่งประเทศไทย (อวท.)' }, - { dtlcod: 'BDG006', dtlnam: 'งบดำเนินงาน ระยะสั้น' }, - { dtlcod: 'BDG007', dtlnam: 'โครงการบูรณาการการพัฒนาทักษะทางวิชาชีพกับการเสริมสร้างคุณลักษณะอันพึงประสงค์ (FIX IT)' }, - { dtlcod: 'BDG008', dtlnam: 'โครงการพัฒนาทักษะและสมรรถนะวิชาชีพกำลังคน (Up-skill, Re-skill)' }, - { dtlcod: 'BDG009', dtlnam: 'งบดำเนินงาน ปวช.' }, - { dtlcod: 'BDG010', dtlnam: 'โครงการขยายและยกระดับการจัดอาชีวศึกษาระบบทวิภาคีคุณภาพสูง' }, - { dtlcod: 'BDG011', dtlnam: 'ปวช.(สอจ)' }, - { dtlcod: 'BDG012', dtlnam: 'ค่าจัดการเรียนการสอน' }, - { dtlcod: 'BDG013', dtlnam: 'งบดำเนินงาน 170000' }, - { dtlcod: 'BDG014', dtlnam: 'โครงการพัฒนาทักษะและศักยภาพภาพการจัดการเรียนการสอนอาชีวศึกษา' }, - { dtlcod: 'BDG015', dtlnam: 'ศึกษาธิการ' }, - { dtlcod: 'BDG016', dtlnam: 'Up-skill' }, - { dtlcod: 'BDG017', dtlnam: 'ติดตามผู้สำเร็จ' }, - { dtlcod: 'BDG018', dtlnam: 'ทวิภาคี' }, - { dtlcod: 'BDG019', dtlnam: 'พันธุกรรม' }, - { dtlcod: 'BDG020', dtlnam: 'ปวส(สาธารณูประโภค)' }, - { dtlcod: 'BDG021', dtlnam: 'ปวส(ค่าสาธารณูปโภค)' }, - { dtlcod: 'BDG022', dtlnam: 'งบดำเนินงาน (ค่าสาธารณูปโภค)' }, - { dtlcod: 'BDG023', dtlnam: 'ค่าหนังสือเรียน' }, - { dtlcod: 'BDG024', dtlnam: 'โครงการอาชีวะต้านยาเสพติด' }, - { dtlcod: 'BDG025', dtlnam: 'ค่าตอบแทนพนักงานราชการ' }, - { dtlcod: 'BDG026', dtlnam: 'ค่าอุปกรณ์การเรียน' }, - { dtlcod: 'BDG027', dtlnam: 'โครงการยกระดับและพัฒนาขีดความสามารถด้านภาษาและทักษะดิจิทัลเพื่อพัฒนากำลังคนให้มีสมรรถนะสูง' }, - { dtlcod: 'BDG028', dtlnam: 'โครงการอนุรักษ์พันธุกรรมพืชอันเนื่องมาจากพระราชดำริ' }, - { dtlcod: 'BDG029', dtlnam: 'ปวช.(สอจ.)' }, - { dtlcod: 'BDG030', dtlnam: 'โครงการพัฒนาศักยภาพผู้เรียนอาชีวศึกษาในการเป็นผู้ประกอบการ (บ่มเพาะ)' }, - { dtlcod: 'BDG031', dtlnam: 'โครงการพัฒนาและยกระดับการติดตามผู้สำเร็จการศึกษาอาชีวศึกษา' }, - { dtlcod: 'BDG032', dtlnam: 'โครงการเสริมสร้างคุณธรรม จริยธรรมและธรรมาภิบาลในสถานศึกษา' }, - { dtlcod: 'BDG033', dtlnam: 'โครงการจัดการอาชีวศึกษาเพื่อสนองพระราชดำริ' }, - { dtlcod: 'BDG034', dtlnam: 'เงินรายได้ ป.ตรี' }, - { dtlcod: 'BDG035', dtlnam: 'งบดำเนินงาน 235200' } - ] -}; - - // isModalOpen: boolean = false; - // isSubmitting: boolean = false; - // arrearsForm!: FormGroup; - // saveFrm!: FormGroup; - // myActData: IActData[] = []; - // // myDropAct: IStateDrop[] = []; - // myDropAct: IStateDrop = { income: [], expense: [] }; - // myActSumData: IActSumData = { - // summary: { - // totalIncome: '', - // totalExpense: '', - // netProfit: '', - // profitRate: '', - // adjustedProfitRate: '', - // period: '' - // }, - // pie: { - // income: [], - // expense: [] - // } - // }; - // ActSumDataGradient: any - - - // readonly ownerName = 'Nuttakit'; - constructor( private router: Router, - private dashboardStateService: DashboardStateService + private projectStateService: ProjectStateService ) {} @@ -123,40 +49,14 @@ export class MainManagerComponent implements OnInit { ngOnInit(): void { this.setupFormControl(); - // this.dashboardStateService.getStateResult().subscribe(data => { - // if (data) { - // this.myDropAct = data; - // } - // }); - // // ผลลับท์ ของ รายการ - // this.dashboardStateService.getStateAccountResult().subscribe(data => { - // if (data) { - // this.myActData = data; - // } - // }); - // // ผลลัพการ คำนวณ ของ ปัญชี ต่างๆ - // this.dashboardStateService.getStateSumResult().subscribe(data => { - // if (data) { - // this.myActSumData = data; - // this.ActSumDataGradient = this.buildExpenseGradient() - // } - // }); + this.projectStateService.getStateResult().subscribe(data => { + if(data){ + this.myPrjMst = data + } + }); } setupFormControl(){ - // this.arrearsForm = new FormGroup({ - // // email: new FormControl('',[Validators.required, Validators.email, Validators.maxLength(100)]), - // amount: new FormControl('',[Validators.required, Validators.maxLength(20)]), - // expdtm: new FormControl('',[Validators.required, Validators.maxLength(12)]), - // note: new FormControl('',[Validators.maxLength(200)]), - // reason: new FormControl('',[Validators.required, Validators.maxLength(200)]) - // }); - // this.saveFrm = new FormGroup({ - // actacpdtm: new FormControl('',[Validators.required, Validators.maxLength(12)]), - // actqty: new FormControl('',[Validators.required]), - // actcat: new FormControl('',[Validators.required, Validators.maxLength(1)]), - // actcmt: new FormControl('',[Validators.maxLength(200)]) - // }); } onSaveSubmit(){ diff --git a/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.css b/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.css new file mode 100644 index 0000000..e69de29 diff --git a/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.html b/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.html new file mode 100644 index 0000000..f856aac --- /dev/null +++ b/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.html @@ -0,0 +1 @@ + diff --git a/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.ts b/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.ts new file mode 100644 index 0000000..d8696f7 --- /dev/null +++ b/ng-ttc-frontend/src/app/content/budget-aproval-content/budget-aproval-content.ts @@ -0,0 +1,92 @@ +import { IDropBdg, ITrnmst } from './../../interfaces/main.interface'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { GeneralService } from '../../services/generalservice'; +import { TransactionStateService } from '../../services/state/transaction-state.service'; + +@Component({ + selector: 'app-budget-aproval-content', + standalone: false, + templateUrl: './budget-aproval-content.html', + styleUrl: './budget-aproval-content.css', +}) +export class BudgetAprovalContent implements OnInit { + + myTrnmst: ITrnmst[]=[]; + myDropBdg: IDropBdg[]=[]; + constructor( + private router: Router, + private route: ActivatedRoute, + private generalService: GeneralService, + private transactionStateService: TransactionStateService + ){} + + ngOnInit(): void { + let param = this.route.snapshot.paramMap.get('seq'); + this.OnSearchTrn(param); + this.OnBudgetSearch(); + } + + OnSearchTrn(value: any): void { + const uri = '/api/ttc/transactionsearch'; + let request = { + trnprjseq: value + } + this.generalService.postRequest(uri, request).subscribe({ + next: (result: any) => { + if (result.code === '200') { + this.generalService.trowApi(result); + this.myTrnmst = result.data; + this.transactionStateService.setTransactionState(this.myTrnmst); + }else{ + this.generalService.trowApi(result); + } + }, + error: (error: any) => { + this.generalService.trowApi(error); + }, + complete: () => {} + }); + } + + OnBudgetExp(value: any): void { + const uri = '/api/ttc/budgetexpense'; + let request = value; + this.generalService.postRequest(uri, request).subscribe({ + next: (result: any) => { + if (result.code === '200') { + this.generalService.trowApi(result); + }else{ + this.generalService.trowApi(result); + } + }, + error: (error: any) => { + this.generalService.trowApi(error); + }, + complete: () => { + this.router.navigate(['/main/manager']) + } + }); + } + + + OnBudgetSearch(): void { + const uri = '/api/ttc/budgetsearch'; + let request = {} + this.generalService.postRequest(uri, request).subscribe({ + next: (result: any) => { + if (result.code === '200') { + // this.generalService.trowApi(result); + this.myDropBdg = result.data; + this.transactionStateService.setBudgetDrop(this.myDropBdg); + }else{ + // this.generalService.trowApi(result); + } + }, + error: (error: any) => { + // this.generalService.trowApi(error); + }, + complete: () => {} + }); + } +} diff --git a/ng-ttc-frontend/src/app/content/main-manager-content/main-manager-content.component.ts b/ng-ttc-frontend/src/app/content/main-manager-content/main-manager-content.component.ts index c9599a8..ed699e8 100644 --- a/ng-ttc-frontend/src/app/content/main-manager-content/main-manager-content.component.ts +++ b/ng-ttc-frontend/src/app/content/main-manager-content/main-manager-content.component.ts @@ -3,7 +3,8 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { ChartConfiguration, ChartOptions } from 'chart.js'; import { BaseChartDirective } from 'ng2-charts'; import { GeneralService } from '../../services/generalservice'; -import { IDropAct, IStateDrop, IActData, IActSumData } from '../../interfaces/dashboard.interface'; +import { IPrjMst } from '../../interfaces/main.interface'; +import { ProjectStateService } from '../../services/state/project-state.service'; @Component({ @@ -14,46 +15,41 @@ import { IDropAct, IStateDrop, IActData, IActSumData } from '../../interfaces/da }) export class MainManagerContentComponent implements OnInit { // @ViewChild(BaseChartDirective) chart?: BaseChartDirective; - myDropAct!: IStateDrop; - myActData: IActData[] = []; - myActSumData: IActSumData = { - summary: { - totalIncome: '', - totalExpense: '', - netProfit: '', - profitRate: '', - adjustedProfitRate: '', - period: '' - }, - pie: { - income: [], - expense: [] - } - }; + myPrjMst: IPrjMst[]=[]; + // myActData: IActData[] = []; + // myActSumData: IActSumData = { + // summary: { + // totalIncome: '', + // totalExpense: '', + // netProfit: '', + // profitRate: '', + // adjustedProfitRate: '', + // period: '' + // }, + // pie: { + // income: [], + // expense: [] + // } + // }; constructor( private generalService: GeneralService, - private dashboardStateService: DashboardStateService + private projectStateService: ProjectStateService ) {} ngOnInit(): void { - let token = localStorage.getItem('access_token') - // this.OnSearchAct(token, true); - // this.OnSetupDashboard(token, true); - // this.OnSearchSum(token, true); + this.OnSearchPrj({}, true); } - OnSearchAct(value: any, setupFirst: boolean): void { - const uri = '/api/web/accountingSearch'; - let request = { - token: value - } + OnSearchPrj(value: any, setupFirst: boolean): void { + const uri = '/api/ttc/projectsearch'; + let request = {} this.generalService.postRequest(uri, request).subscribe({ next: (result: any) => { if (result.code === '200') { this.generalService.trowApi(result); - this.myActData = result.data; - this.dashboardStateService.setStateAccountResult(this.myActData); + this.myPrjMst = result.data; + this.projectStateService.setProjectState(this.myPrjMst); }else{ this.generalService.trowApi(result); } @@ -69,94 +65,51 @@ export class MainManagerContentComponent implements OnInit { - OnSetupDashboard(value: any, setupFirst: boolean): void { - const uri = '/api/web/accountingSetup'; - let request = { - token: value - } - this.generalService.postRequest(uri, request).subscribe({ - next: (result: any) => { - if (result.code === '200') { - this.generalService.trowApi(result); - this.myDropAct = result.data - this.dashboardStateService.setStateResult(this.myDropAct) - }else{ - this.generalService.trowApi(result); - } - }, - error: (error: any) => { - this.generalService.trowApi(error); - }, - complete: () => { - - } - }); - } - - OnSearchSum(value: any, setupFirst: boolean): void { - const uri = '/api/web/accountingSum'; - let request = { - token: value - } - this.generalService.postRequest(uri, request).subscribe({ - next: (result: any) => { - if (result.code === '200') { - this.generalService.trowApi(result); - this.myActSumData = result.data - this.dashboardStateService.setStateSumResult(this.myActSumData); - }else{ - this.generalService.trowApi(result); - } - }, - error: (error: any) => { - this.generalService.trowApi(error); - }, - complete: () => { - - } - }); - } - - // fetchChartData(): void { - // // NOTE: Using a placeholder endpoint as the actual one was not provided. - // const uri = '/api/dashboard/summary-last-6-months'; - - // this.generalService.getRequest(uri).subscribe({ + // OnSetupDashboard(value: any, setupFirst: boolean): void { + // const uri = '/api/web/accountingSetup'; + // let request = { + // token: value + // } + // this.generalService.postRequest(uri, request).subscribe({ // next: (result: any) => { - // if (result.code === '200' && result.data) { - // this.processChartData(result.data); - // } else { - // console.warn('Could not fetch chart data:', result.message_th); - // // Optionally, display placeholder data or an error message - // this.setupPlaceholderData(); + // if (result.code === '200') { + // this.generalService.trowApi(result); + // this.myDropAct = result.data + // this.dashboardStateService.setStateResult(this.myDropAct) + // }else{ + // this.generalService.trowApi(result); // } // }, // error: (error: any) => { - // console.error('Error fetching chart data:', error); - // // Display placeholder data on error to show the graph structure - // this.setupPlaceholderData(); + // this.generalService.trowApi(error); + // }, + // complete: () => { + // } // }); // } - // processChartData(data: any[]): void { - // const labels = data.map(item => item.month); - // const revenues = data.map(item => item.revenue); + // OnSearchSum(value: any, setupFirst: boolean): void { + // const uri = '/api/web/accountingSum'; + // let request = { + // token: value + // } + // this.generalService.postRequest(uri, request).subscribe({ + // next: (result: any) => { + // if (result.code === '200') { + // this.generalService.trowApi(result); + // this.myActSumData = result.data + // this.dashboardStateService.setStateSumResult(this.myActSumData); + // }else{ + // this.generalService.trowApi(result); + // } + // }, + // error: (error: any) => { + // this.generalService.trowApi(error); + // }, + // complete: () => { - // this.lineChartData.labels = labels; - // this.lineChartData.datasets[0].data = revenues; - - // this.chart?.update(); - // } - - // setupPlaceholderData(): void { - // // This function is called if the API fails, to show a sample graph. - // const labels = ['January', 'February', 'March', 'April', 'May', 'June']; - // const revenues = [1200, 1900, 3000, 5000, 2300, 3200]; // Sample data - - // this.lineChartData.labels = labels; - // this.lineChartData.datasets[0].data = revenues; - - // this.chart?.update(); + // } + // }); // } } diff --git a/ng-ttc-frontend/src/app/controls/main-control/main-control-routing.module.ts b/ng-ttc-frontend/src/app/controls/main-control/main-control-routing.module.ts index ca4c8b0..b34e427 100644 --- a/ng-ttc-frontend/src/app/controls/main-control/main-control-routing.module.ts +++ b/ng-ttc-frontend/src/app/controls/main-control/main-control-routing.module.ts @@ -6,6 +6,7 @@ import { MainReportComponent } from '../../component/main-report/main-report.com import { BudgetAproval } from '../../component/budget-aproval/budget-aproval'; import { MainLandingComponent } from '../../component/main-landing/main-landing.component'; import { MainProjectContent } from '../../content/main-project-content/main-project-content'; +import { BudgetAprovalContent } from '../../content/budget-aproval-content/budget-aproval-content'; // import { MainReportComponent } from '../../component/main-report/main-report.component'; @@ -17,13 +18,14 @@ const routes: Routes = [ { path: 'manager', component: MainManagerContentComponent }, { path: 'project', component: MainProjectContent }, { path: 'project/:mode', component: MainProjectContent }, - { - path: 'manager', - children: [ - { path: '', component: MainManagerContentComponent }, // รายการโครงการ - { path: 'budget/:code', component: BudgetAproval }, // จัดการงบประมาณ - ] - }, + { path: 'budget/approve/:seq', component: BudgetAprovalContent}, + // { + // path: 'manager', + // children: [ + // { path: '', component: MainManagerContentComponent }, // รายการโครงการ + // { path: 'budget/:code', component: BudgetAproval }, // จัดการงบประมาณ + // ] + // }, // children: [ // { // path: 'dashboard', diff --git a/ng-ttc-frontend/src/app/controls/main-control/main-control.module.ts b/ng-ttc-frontend/src/app/controls/main-control/main-control.module.ts index 4f2a891..9782db9 100644 --- a/ng-ttc-frontend/src/app/controls/main-control/main-control.module.ts +++ b/ng-ttc-frontend/src/app/controls/main-control/main-control.module.ts @@ -5,7 +5,7 @@ import { CommonModule } from '@angular/common'; import { MainControlRoutingModule } from './main-control-routing.module'; -import { ReactiveFormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MainDashboardComponent } from '../../component/main-dashboard/main-dashboard.component'; import { MainDashboardContentComponent } from '../../content/main-dashboard-content/main-dashboard-content.component'; @@ -17,6 +17,7 @@ import { MainLandingComponent } from '../../component/main-landing/main-landing. import { MainProjectContent } from '../../content/main-project-content/main-project-content'; import { MainProject } from '../../component/main-project/main-project'; import { MainProjectAdd } from '../../component/main-project-add/main-project-add'; +import { BudgetAprovalContent } from '../../content/budget-aproval-content/budget-aproval-content'; // import { MainReportComponent } from '../../component/main-report/main-report.component'; @@ -34,13 +35,15 @@ import { MainProjectAdd } from '../../component/main-project-add/main-project-ad MainProjectContent, MainProject, MainProjectAdd, + BudgetAprovalContent, AccDateFormatPipe // MainReportComponent ], imports: [ CommonModule, MainControlRoutingModule, - ReactiveFormsModule + ReactiveFormsModule, + FormsModule // BrowserAnimationsModule ], exports: [ diff --git a/ng-ttc-frontend/src/app/interfaces/dashboard.interface.ts b/ng-ttc-frontend/src/app/interfaces/dashboard.interface.ts index 3d44aca..aeb1b57 100644 --- a/ng-ttc-frontend/src/app/interfaces/dashboard.interface.ts +++ b/ng-ttc-frontend/src/app/interfaces/dashboard.interface.ts @@ -2,6 +2,12 @@ export interface IStateDrop { income: IDropAct[]; expense: IDropAct[]; } +export interface IBudgetItem { + id?: number; // เอาไว้เช็คตอน Edit + code: string; + name: string; + amount: number; +} export interface IDropAct { dtlnam?: string, @@ -22,6 +28,18 @@ export interface IStateResultResponse { data: IStateDrop; } +export interface IPrjData { + prjseq?: number; + prjnam?: string; + prjusrnam?: string; + prjwntbdg?: string; + prjbdgnam?: string; + prjbdgcod?: string; + prjacpbdg?: string; + prjcomstt?: string; + prjacpdtm?: string; +} + export interface IStateResultResponse { data: IStateDrop; } diff --git a/ng-ttc-frontend/src/app/interfaces/main.interface.ts b/ng-ttc-frontend/src/app/interfaces/main.interface.ts new file mode 100644 index 0000000..6988c1b --- /dev/null +++ b/ng-ttc-frontend/src/app/interfaces/main.interface.ts @@ -0,0 +1,26 @@ +export interface IPrjMst { + prjseq?: number; + prjnam?: string; + prjusrnam?: string; + prjwntbdg?: string; + prjbdgnam?: string; + prjbdgcod?: string; + prjacpbdg?: string; + prjcomstt?: string; + prjacpdtm?: string; +} + +export interface ITrnmst { + trnseq?: number; + trnprjnam?: string; + trnbdgnam?: string; + trnbdgcod?: string; + trncomstt?: string; + trnexpbdg: number; + trnacpdtm?: number; +} + +export interface IDropBdg { + bdgnam?: string; + bdgcod?: number; +} diff --git a/ng-ttc-frontend/src/app/services/state/budget-state.service.ts b/ng-ttc-frontend/src/app/services/state/budget-state.service.ts index 855412a..424a97e 100644 --- a/ng-ttc-frontend/src/app/services/state/budget-state.service.ts +++ b/ng-ttc-frontend/src/app/services/state/budget-state.service.ts @@ -1,32 +1,32 @@ -import { Injectable } from '@angular/core'; -import { BehaviorSubject, Observable } from 'rxjs'; -import { IBudgetExpenseResponse, IBudgetAddResponse } from '../../interfaces/dashboard.interface'; +// import { Injectable } from '@angular/core'; +// import { BehaviorSubject, Observable } from 'rxjs'; +// import { IBudgetExpenseResponse, IBudgetAddResponse } from '../../interfaces/dashboard.interface'; -@Injectable({ - providedIn: 'root' -}) -export class BudgetStateService { - private budgetExpenseState = new BehaviorSubject(null); - private budgetAddState = new BehaviorSubject(null); +// @Injectable({ +// providedIn: 'root' +// }) +// export class BudgetStateService { +// private budgetExpenseState = new BehaviorSubject(null); +// private budgetAddState = new BehaviorSubject(null); - getBudgetExpenseState(): Observable { - return this.budgetExpenseState.asObservable(); - } +// getBudgetExpenseState(): Observable { +// return this.budgetExpenseState.asObservable(); +// } - setBudgetExpenseState(budgetExpense: IBudgetExpenseResponse): void { - this.budgetExpenseState.next(budgetExpense); - } +// setBudgetExpenseState(budgetExpense: IBudgetExpenseResponse): void { +// this.budgetExpenseState.next(budgetExpense); +// } - getBudgetAddState(): Observable { - return this.budgetAddState.asObservable(); - } +// getBudgetAddState(): Observable { +// return this.budgetAddState.asObservable(); +// } - setBudgetAddState(budgetAdd: IBudgetAddResponse): void { - this.budgetAddState.next(budgetAdd); - } +// setBudgetAddState(budgetAdd: IBudgetAddResponse): void { +// this.budgetAddState.next(budgetAdd); +// } - clearState(): void { - this.budgetExpenseState.next(null); - this.budgetAddState.next(null); - } -} +// clearState(): void { +// this.budgetExpenseState.next(null); +// this.budgetAddState.next(null); +// } +// } diff --git a/ng-ttc-frontend/src/app/services/state/project-state.service.ts b/ng-ttc-frontend/src/app/services/state/project-state.service.ts index 205f10d..96deec3 100644 --- a/ng-ttc-frontend/src/app/services/state/project-state.service.ts +++ b/ng-ttc-frontend/src/app/services/state/project-state.service.ts @@ -1,32 +1,26 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; -import { IProjectSearchResponse, ITransactionSearchResponse } from '../../interfaces/dashboard.interface'; +import { IPrjMst } from '../../interfaces/main.interface'; @Injectable({ providedIn: 'root' }) export class ProjectStateService { - private projectState = new BehaviorSubject(null); - private transactionState = new BehaviorSubject(null); + // ประกาศ BehaviorSubject ด้วย Interface + private projectState = new BehaviorSubject(null); - getProjectState(): Observable { + // ส่ง Observable ไปให้ components subscribe + getStateResult(): Observable { return this.projectState.asObservable(); } - setProjectState(project: IProjectSearchResponse): void { - this.projectState.next(project); - } - - getTransactionState(): Observable { - return this.transactionState.asObservable(); - } - - setTransactionState(transaction: ITransactionSearchResponse): void { - this.transactionState.next(transaction); + // เซ็ท state + setProjectState(projects: IPrjMst[]): void { + this.projectState.next(projects); } + // เคลียร์ state clearState(): void { this.projectState.next(null); - this.transactionState.next(null); } } diff --git a/ng-ttc-frontend/src/app/services/state/report-state.service.ts b/ng-ttc-frontend/src/app/services/state/report-state.service.ts index 007d33f..6e2546e 100644 --- a/ng-ttc-frontend/src/app/services/state/report-state.service.ts +++ b/ng-ttc-frontend/src/app/services/state/report-state.service.ts @@ -1,22 +1,22 @@ -import { Injectable } from '@angular/core'; -import { BehaviorSubject, Observable } from 'rxjs'; -import { IReportResponse } from '../../interfaces/dashboard.interface'; +// import { Injectable } from '@angular/core'; +// import { BehaviorSubject, Observable } from 'rxjs'; +// import { IReportResponse } from '../../interfaces/dashboard.interface'; -@Injectable({ - providedIn: 'root' -}) -export class ReportStateService { - private reportState = new BehaviorSubject(null); +// @Injectable({ +// providedIn: 'root' +// }) +// export class ReportStateService { +// private reportState = new BehaviorSubject(null); - getReportState(): Observable { - return this.reportState.asObservable(); - } +// getReportState(): Observable { +// return this.reportState.asObservable(); +// } - setReportState(report: IReportResponse): void { - this.reportState.next(report); - } +// setReportState(report: IReportResponse): void { +// this.reportState.next(report); +// } - clearState(): void { - this.reportState.next(null); - } -} +// clearState(): void { +// this.reportState.next(null); +// } +// } diff --git a/ng-ttc-frontend/src/app/services/state/transaction-state.service.ts b/ng-ttc-frontend/src/app/services/state/transaction-state.service.ts new file mode 100644 index 0000000..f8f673a --- /dev/null +++ b/ng-ttc-frontend/src/app/services/state/transaction-state.service.ts @@ -0,0 +1,36 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { ITrnmst, IDropBdg } from '../../interfaces/main.interface'; + +@Injectable({ + providedIn: 'root' +}) +export class TransactionStateService { + // ประกาศ BehaviorSubject ด้วย Interface + private transactionState = new BehaviorSubject(null); + private budgetState = new BehaviorSubject(null); + + // ส่ง Observable ไปให้ components subscribe + getTransactionState(): Observable { + return this.transactionState.asObservable(); + } + + // เซ็ท state + setTransactionState(transactions: ITrnmst[]): void { + this.transactionState.next(transactions); + } + + // เคลียร์ state + clearState(): void { + this.transactionState.next(null); + } + + + setBudgetDrop(budget: IDropBdg[]): void { + this.budgetState.next(budget); + } + + getBudgetDrop(): Observable { + return this.budgetState.asObservable(); + } +}