Commit 73441028 by sawit

แก้ไขการจัดการบริษัท

parent 2354e7e1
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
(change)="toggleAll($event)" [checked]="allSelected" aria-label="..."> (change)="toggleAll($event)" [checked]="allSelected" aria-label="...">
</th> </th>
<th scope="col" class="text-start">บริษัท</th> <th scope="col" class="text-start">บริษัท</th>
<th scope="col" class="text-start">ชื่อเจ้าของ</th> <th scope="col" class="text-start">อีเมล</th>
<th scope="col" class="text-start">{{"Status" | translate}}</th> <th scope="col" class="text-start">{{"Status" | translate}}</th>
<!-- <th scope="col" class="text-start">{{"Update Date" | translate}}</th> --> <!-- <th scope="col" class="text-start">{{"Update Date" | translate}}</th> -->
<th scope="col" class="text-start">{{ 'Action' | translate}}</th> <th scope="col" class="text-start">{{ 'Action' | translate}}</th>
...@@ -76,7 +76,8 @@ ...@@ -76,7 +76,8 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
{{item.thFirstnameContact}} {{item.thLastnameContact}} {{item.email}}
<!-- {{item.thFirstnameContact}} {{item.thLastnameContact}} -->
</span> </span>
</div> </div>
</td> </td>
...@@ -193,71 +194,81 @@ ...@@ -193,71 +194,81 @@
</div> </div>
</div> </div>
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="thName" class="form-label">{{'ชื่อบริษัท ไทย' | translate}}</label> <label for="thName" class="form-label">{{'ชื่อบริษัท ไทย' | translate}}</label>
<input type="text" class="form-control" id="thName" placeholder="" [(ngModel)]="selectModel.thName" <input type="text" class="form-control" id="thName" placeholder="" [(ngModel)]="selectModel.thName">
[disabled]="action === 'edit'">
<div class="text-danger" *ngIf="!selectModel.thName"> <div class="text-danger" *ngIf="!selectModel.thName">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div>
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="thName" class="form-label">{{'ชื่อบริษัท อังกฤษ' | translate}}</label> <label for="thName" class="form-label">{{'ชื่อบริษัท อังกฤษ' | translate}}</label>
<input type="text" class="form-control" id="thName" placeholder="" [(ngModel)]="selectModel.engName" <input type="text" class="form-control" id="thName" placeholder="" [(ngModel)]="selectModel.engName">
[disabled]="action === 'edit'"> <div class="text-danger" *ngIf="!selectModel.engName">
<div class="text-danger" *ngIf="!selectModel.thName">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12" *ngIf="action == 'edit'">
<label for="companyId" class="form-label">{{'รหัสบริษัท' | translate}}</label> <label for="companyId" class="form-label">{{'รหัสบริษัท' | translate}}</label>
<input type="text" class="form-control" id="companyId" placeholder="" [(ngModel)]="selectModel.companyId" <input type="text" class="form-control !bg-input-readonly" id="companyId" placeholder="" [(ngModel)]="selectModel.companyId"
[disabled]="action === 'edit'" [readonly]="action === 'edit'" [disabled]="action === 'edit'" >
[ngClass]="{ '!bg-input-readonly': action === 'edit' }"> <!-- <div class="text-danger" *ngIf="!selectModel.companyId && action === 'add'">
<div class="text-danger" *ngIf="!selectModel.companyId && action === 'add'">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div> -->
</div> </div>
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label for="email" class="form-label">{{'Email' | translate}}</label>
<input type="email" class="form-control" id="emailAddress" placeholder="Email Addresss" [(ngModel)]="selectModel.email" (input)="filterEngInput($event)">
<div class="text-danger" *ngIf="!selectModel.email">
{{ 'Please fill in information' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && (!selectModel.email.includes('@'))">
{{ 'Invalid email format @' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')">
{{ 'Invalid email format .' | translate }}
</div>
</div>
<!-- <div class="xl:col-span-12 col-span-12">
<label for="password" class="form-label">{{'Password' | translate}}</label>
<input type="password" class="form-control" id="emailAddress" placeholder="Choose Password" [(ngModel)]="selectModel.password">
</div> -->
<!-- <div class="xl:col-span-12 col-span-12">
<label for="companyDetail" class="form-label">{{'ข้อมูลบริษัท' | translate}}</label> <label for="companyDetail" class="form-label">{{'ข้อมูลบริษัท' | translate}}</label>
<textarea class="form-control" id="companyDetail" placeholder="" [(ngModel)]="selectModel.companyDetail" <textarea class="form-control" id="companyDetail" placeholder="" [(ngModel)]="selectModel.companyDetail">
*ngIf="action === 'add'">
</textarea> </textarea>
<app-rendered-html class="small-html" [htmlContent]="selectModel.companyDetail" *ngIf="action === 'edit'"> <app-rendered-html class="small-html" [htmlContent]="selectModel.companyDetail" *ngIf="action === 'edit'">
</app-rendered-html> </app-rendered-html>
<div class="text-danger" *ngIf="!selectModel.companyDetail"> <div class="text-danger" *ngIf="!selectModel.companyDetail">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div> -->
<!-- <div class="xl:col-span-12 col-span-12">
<div class="xl:col-span-12 col-span-12">
<label for="locationDetail" class="form-label">{{'ที่อยู่' | translate}}</label> <label for="locationDetail" class="form-label">{{'ที่อยู่' | translate}}</label>
<textarea class="form-control" id="locationDetail" placeholder="" [(ngModel)]="selectModel.locationDetail" <textarea class="form-control" id="locationDetail" placeholder="" [(ngModel)]="selectModel.locationDetail">
*ngIf="action === 'add'">
</textarea> </textarea>
<app-rendered-html class="small-html" [htmlContent]="selectModel.locationDetail" *ngIf="action === 'edit'"> <app-rendered-html class="small-html" [htmlContent]="selectModel.locationDetail" *ngIf="action === 'edit'">
</app-rendered-html> </app-rendered-html>
</div> </div> -->
<!-- <div class="xl:col-span-6 col-span-12">
<div class="xl:col-span-6 col-span-12">
<label for="thFirstnameContact" class="form-label">{{'ชื่อเจ้าของ' | translate}}</label> <label for="thFirstnameContact" class="form-label">{{'ชื่อเจ้าของ' | translate}}</label>
<input type="text" class="form-control" id="thFirstnameContact" placeholder="" <input type="text" class="form-control" id="thFirstnameContact" placeholder=""
[disabled]="action === 'edit'" [(ngModel)]="selectModel.thFirstnameContact"> [(ngModel)]="selectModel.thFirstnameContact">
</div> </div> -->
<div class="xl:col-span-6 col-span-12"> <!-- <div class="xl:col-span-6 col-span-12">
<label for="thLastnameContact" class="form-label">{{'นามสกุลเจ้าของ' | translate}}</label> <label for="thLastnameContact" class="form-label">{{'นามสกุลเจ้าของ' | translate}}</label>
<input type="text" class="form-control" id="thLastnameContact" placeholder="" [disabled]="action === 'edit'" <input type="text" class="form-control" id="thLastnameContact" placeholder=""
[(ngModel)]="selectModel.thLastnameContact"> [(ngModel)]="selectModel.thLastnameContact">
</div> </div> -->
<!-- <div class="xl:col-span-12 col-span-12">
<div class="xl:col-span-12 col-span-12">
<label for="phoneContact" class="form-label">{{'เบอร์ติดต่อ' | translate}}</label> <label for="phoneContact" class="form-label">{{'เบอร์ติดต่อ' | translate}}</label>
<input type="text" class="form-control" id="phoneContact" placeholder="" [disabled]="action === 'edit'" <input type="text" class="form-control" id="phoneContact" placeholder=""
[(ngModel)]="selectModel.phoneContact"> [(ngModel)]="selectModel.phoneContact">
</div> </div> -->
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label class="form-label">{{'Status' | translate}}</label> <label class="form-label">{{'Status' | translate}}</label>
...@@ -274,8 +285,10 @@ ...@@ -274,8 +285,10 @@
data-hs-overlay="#modal-detail"> data-hs-overlay="#modal-detail">
{{'Cancel' | translate}} {{'Cancel' | translate}}
</button> </button>
<button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium">{{'Save' | <button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium"
translate}}</button> [class.ti-btn-disabled]="!selectModel.thName||!selectModel.engName"
[disabled]="!selectModel.thName||!selectModel.engName">
{{'Save' | translate}}</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -320,7 +320,9 @@ export class CompanyManageComponent { ...@@ -320,7 +320,9 @@ export class CompanyManageComponent {
if (willAdjust) { if (willAdjust) {
const updatePromises = selectedCompanies.map(company => { const updatePromises = selectedCompanies.map(company => {
company.status = status; company.status = status;
return this.comService.saveOrUpdateCompany(company).toPromise() console.log(company);
const respone = new CompanyModelS(company);
return this.comService.saveOrUpdateCompany(respone).toPromise()
.then(() => true) .then(() => true)
.catch(error => { .catch(error => {
console.error(`Error updating status for company ${company.companyId}:`, error); console.error(`Error updating status for company ${company.companyId}:`, error);
...@@ -349,6 +351,13 @@ export class CompanyManageComponent { ...@@ -349,6 +351,13 @@ export class CompanyManageComponent {
this.profileChangeInputRef.nativeElement.click(); this.profileChangeInputRef.nativeElement.click();
} }
} }
filterEngInput(event: any): void {
const input = event.target.value;
const filtered = input.replace(/[^a-zA-Z0-9 @\/.,!?()\-_:*%&$#"]/g, '');
event.target.value = filtered;
}
} }
// import { Component, ElementRef, ViewChild } from '@angular/core'; // import { Component, ElementRef, ViewChild } from '@angular/core';
// import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; // import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
......
...@@ -11,8 +11,8 @@ import { PageResponseModel } from '../models/base.model'; // ตรวจสอ ...@@ -11,8 +11,8 @@ import { PageResponseModel } from '../models/base.model'; // ตรวจสอ
providedIn: 'root' providedIn: 'root'
}) })
export class CompanyServiceS { export class CompanyServiceS {
api = "/company"; api = "/admin/manage-company";
urlApi = environment.baseUrl + "/company"; urlApi = environment.baseUrl + "/admin/manage-company";
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
...@@ -21,7 +21,7 @@ export class CompanyServiceS { ...@@ -21,7 +21,7 @@ export class CompanyServiceS {
} }
getList(): Observable<CompanyModelS[]> { getList(): Observable<CompanyModelS[]> {
return this.http.get<CompanyModelS[]>(this.urlApi + "/list"); return this.http.get<CompanyModelS[]>(this.urlApi + "/lists");
} }
getListByPageSize(body: { page: number; size: number }): Observable<PageResponseModel<CompanyModelS>> { getListByPageSize(body: { page: number; size: number }): Observable<PageResponseModel<CompanyModelS>> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment