dropdown
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
|
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
|||||||
@@ -627,3 +627,14 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quick-log__form select {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
|
||||||
|
background-position: right 0.5rem center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 1.5em 1.5em;
|
||||||
|
padding-right: 2.5rem;
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,13 +77,25 @@
|
|||||||
<div class="quick-log__grid">
|
<div class="quick-log__grid">
|
||||||
<label>
|
<label>
|
||||||
<span>หมวดหมู่</span>
|
<span>หมวดหมู่</span>
|
||||||
<select>
|
@if(mode == 'i'){
|
||||||
<!-- @for(){
|
<select class="w-full h-full px-4 py-2 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-100 focus:border-blue-50 transition-all bg-white">
|
||||||
<option>
|
<option value="">ไม่เลือก</option>
|
||||||
{{ country.name }}
|
@for (item of myDropAct.income; track item.dtlcod) {
|
||||||
</option>
|
<option [value]="item.dtlcod">
|
||||||
} -->
|
{{ item.dtlnam }}
|
||||||
</select>
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}@else if(mode == 'e'){
|
||||||
|
<select class="w-full h-full px-4 py-2 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-100 focus:border-blue-50 transition-all bg-white">
|
||||||
|
<option value="">ไม่เลือก</option>
|
||||||
|
@for (item of myDropAct.expense; track item.dtlcod) {
|
||||||
|
<option [value]="item.dtlcod">
|
||||||
|
{{ item.dtlnam }}
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>ยอดเงิน (฿)</span>
|
<span>ยอดเงิน (฿)</span>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||||
import { GeneralService } from '../../services/generalservice';
|
import { GeneralService } from '../../services/generalservice';
|
||||||
import { IDropAct } from '../../interfaces/dashboard.interface'
|
import { IDropAct, IStateDrop, IStateResultResponse } from '../../interfaces/dashboard.interface'
|
||||||
import { DashboardStateService } from '../../services/state/dashboard-state.service';
|
import { DashboardStateService } from '../../services/state/dashboard-state.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -17,7 +17,9 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
isSubmitting: boolean = false;
|
isSubmitting: boolean = false;
|
||||||
arrearsForm!: FormGroup;
|
arrearsForm!: FormGroup;
|
||||||
saveFrm!: FormGroup;
|
saveFrm!: FormGroup;
|
||||||
myDropAct!: IDropAct;
|
// myDropAct: IStateDrop[] = [];
|
||||||
|
myDropAct: IStateDrop = { income: [], expense: [] };
|
||||||
|
|
||||||
|
|
||||||
readonly ownerName = 'Nuttakit';
|
readonly ownerName = 'Nuttakit';
|
||||||
|
|
||||||
@@ -185,11 +187,10 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.setupFormControl();
|
this.setupFormControl();
|
||||||
this.dashboardStateService.getStateResult().subscribe(data => {
|
this.dashboardStateService.getStateResult().subscribe(data => {
|
||||||
if(data) {
|
if (data) {
|
||||||
this.myDropAct = data;
|
this.myDropAct = data;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFormControl(){
|
setupFormControl(){
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
|
|||||||
import { ChartConfiguration, ChartOptions } from 'chart.js';
|
import { ChartConfiguration, ChartOptions } from 'chart.js';
|
||||||
import { BaseChartDirective } from 'ng2-charts';
|
import { BaseChartDirective } from 'ng2-charts';
|
||||||
import { GeneralService } from '../../services/generalservice';
|
import { GeneralService } from '../../services/generalservice';
|
||||||
import { IDropAct } from '../../interfaces/dashboard.interface';
|
import { IDropAct, IStateDrop } from '../../interfaces/dashboard.interface';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -14,7 +14,7 @@ import { IDropAct } from '../../interfaces/dashboard.interface';
|
|||||||
})
|
})
|
||||||
export class MainDashboardContentComponent implements OnInit {
|
export class MainDashboardContentComponent implements OnInit {
|
||||||
@ViewChild(BaseChartDirective) chart?: BaseChartDirective;
|
@ViewChild(BaseChartDirective) chart?: BaseChartDirective;
|
||||||
myDropAct!: IDropAct;
|
myDropAct!: IStateDrop;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private generalService: GeneralService,
|
private generalService: GeneralService,
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
|
export interface IStateDrop {
|
||||||
|
income: IDropAct[];
|
||||||
|
expense: IDropAct[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface IDropAct {
|
export interface IDropAct {
|
||||||
dtlnam?: string,
|
dtlnam?: string,
|
||||||
dtlcod?: string
|
dtlcod?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IStateResultResponse {
|
||||||
|
data: IStateDrop;
|
||||||
|
}
|
||||||
|
|
||||||
// ข้อมูลสินค้าหลัก
|
// ข้อมูลสินค้าหลัก
|
||||||
// export interface IProduct {
|
// export interface IProduct {
|
||||||
// id: string;
|
// id: string;
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { IDropAct } from '../../interfaces/dashboard.interface';
|
import { IDropAct, IStateDrop } from '../../interfaces/dashboard.interface';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class DashboardStateService {
|
export class DashboardStateService {
|
||||||
// ประกาศ BehaviorSubject ด้วย Interface
|
// ประกาศ BehaviorSubject ด้วย Interface
|
||||||
private productState = new BehaviorSubject<IDropAct | null>(null);
|
private dashboardState = new BehaviorSubject<IStateDrop | null>(null);
|
||||||
|
|
||||||
// ส่ง Observable ไปให้ components subscribe
|
// ส่ง Observable ไปให้ components subscribe
|
||||||
getStateResult(): Observable<IDropAct | null> {
|
getStateResult(): Observable<IStateDrop | null> {
|
||||||
return this.productState.asObservable();
|
return this.dashboardState.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// เซ็ท state
|
// เซ็ท state
|
||||||
setStateResult(product: IDropAct): void {
|
setStateResult(product: IStateDrop): void {
|
||||||
this.productState.next(product);
|
this.dashboardState.next(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
// เคลียร์ state
|
// เคลียร์ state
|
||||||
clearState(): void {
|
clearState(): void {
|
||||||
this.productState.next(null);
|
this.dashboardState.next(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ดึงค่า current state (ไม่ใช่ observable)
|
// ดึงค่า current state (ไม่ใช่ observable)
|
||||||
|
|||||||
Reference in New Issue
Block a user