Commit ca6384bb by Nattana Chaiyamat

ตั้งค่าผู้ใช้งาน

parent 84c08d57
...@@ -174,13 +174,25 @@ ...@@ -174,13 +174,25 @@
<div class="ti-modal-body padding-16px pt-0 overflow-y-0"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label class="ti-form-label mt-2rem">ชื่อล็อคอิน</label> <label class="ti-form-label mt-2rem">ชื่อล็อคอิน</label>
<input type="text" class="ti-form-input" [ngClass]="{'bg-input-readonly':currentModal=='edit'}" <input type="text" class="ti-form-input" [ngClass]="{'bg-input-readonly':currentModal=='edit'}"
[readonly]="currentModal=='edit'" [(ngModel)]="data.select.usernameId" [maxLength]="20"> [readonly]="currentModal=='edit'" [(ngModel)]="user.select.usernameId" [maxLength]="20">
<label class="ti-form-label mt-2rem">รหัสพนักงาน</label> <label class="ti-form-label mt-2rem">รหัสพนักงาน</label>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="relative flex rounded-md">
<input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="user.select.empId">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#department-list-bu1-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<input type="text" class="ti-form-input bg-input-readonly" readonly <input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="data.select.empId"> [(ngModel)]="user.select.employee.thFullName">
<input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="data.select.employee.thFullName">
</div> </div>
<!-- <label class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label> <!-- <label class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" class="ti-form-input h-16" [(ngModel)]="data.select.edesc"> <input type="text" class="ti-form-input h-16" [(ngModel)]="data.select.edesc">
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model';
import { MyUserModel, UserModel } from 'src/app/shared/model/user.model'; import { MyUserModel, UserModel } from 'src/app/shared/model/user.model';
import { EmployeeService } from 'src/app/shared/services/employee.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import { UserService } from 'src/app/shared/services/user.service'; import { UserService } from 'src/app/shared/services/user.service';
...@@ -14,28 +16,43 @@ export class UserSettingsComponent { ...@@ -14,28 +16,43 @@ export class UserSettingsComponent {
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
currentModal: 'add' | 'edit' = "add" currentModal: 'add' | 'edit' = "add"
data: { loading: boolean, select: UserModel, dataList: { check: boolean, data: UserModel }[] } = { loading: false, select: new MyUserModel(), dataList: [] } user: { loading: boolean, select: UserModel, dataList: { check: boolean, data: UserModel }[] } = { loading: false, select: new MyUserModel(), dataList: [] }
employee: { loading: boolean, select: EmployeeModel, dataList: { check: boolean, data: EmployeeModel }[] } = { loading: false, select: new MyEmployeeModel(), dataList: [] }
constructor(private toastr: ToastrService, constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private userService: UserService, private userService: UserService,
private employeeService: EmployeeService,
private fileService: FileService) { } private fileService: FileService) { }
ngOnInit(): void { ngOnInit(): void {
this.getUserList() this.getUserList()
this.getEmployeeList()
}
getEmployeeList() {
this.employee.loading = true
this.employeeService.getList().subscribe(response => {
this.employee.dataList = response.map(x => ({ check: false, data: new MyEmployeeModel(x) }))
this.employee.loading = false
this.cdr.detectChanges()
}, error => {
this.employee.loading = false
this.cdr.detectChanges()
})
} }
getUserList() { getUserList() {
this.data.loading = true this.user.loading = true
this.userService.getList().subscribe(response => { this.userService.getList().subscribe(response => {
this.data.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) })) this.user.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) }))
this.data.loading = false this.user.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
}, error => { }, error => {
this.data.loading = false this.user.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
}) })
} }
selectUser(data?: UserModel) { selectData(filed: string, data: any) {
this.data.select = new MyUserModel(data) (this as any)[filed] = data
} }
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
...@@ -48,21 +65,24 @@ export class UserSettingsComponent { ...@@ -48,21 +65,24 @@ export class UserSettingsComponent {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.data.loading = true this.user.loading = true
this.fileService.upload(formData, 'mbu1').subscribe({ this.fileService.upload(formData, 'mbu1').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.data.loading = false this.user.loading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.data.loading = false this.user.loading = false
} }
}) })
} }
selectUser() {
}
downloadFile() { downloadFile() {
const fileName = 'IMPORT_USER.xlsx' const fileName = 'IMPORT_USER.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.download(fileName).subscribe({
......
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id" style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id"
(ngModelChange)="bu1idChange()"> (ngModelChange)="bu1idChange()">
<div <div
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
......
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" readonly class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
readonly style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id" readonly style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id"
(ngModelChange)="bu4idChange()"> (ngModelChange)="bu4idChange()">
<div <div
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10 bg-input-readonly" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
readonly style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id" readonly style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id"
(ngModelChange)="bu4idChange()"> (ngModelChange)="bu4idChange()">
<div <div
......
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