Commit ca6384bb by Nattana Chaiyamat

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

parent 84c08d57
......@@ -174,13 +174,25 @@
<div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label class="ti-form-label mt-2rem">ชื่อล็อคอิน</label>
<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>
<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
[(ngModel)]="data.select.empId">
<input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="data.select.employee.thFullName">
[(ngModel)]="user.select.employee.thFullName">
</div>
<!-- <label class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" class="ti-form-input h-16" [(ngModel)]="data.select.edesc">
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
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 { EmployeeService } from 'src/app/shared/services/employee.service';
import { FileService } from 'src/app/shared/services/file.service';
import { UserService } from 'src/app/shared/services/user.service';
......@@ -14,28 +16,43 @@ export class UserSettingsComponent {
selectedFileName: string = 'กรุณาเลือกไฟล์';
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,
private cdr: ChangeDetectorRef,
private userService: UserService,
private employeeService: EmployeeService,
private fileService: FileService) { }
ngOnInit(): void {
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() {
this.data.loading = true
this.user.loading = true
this.userService.getList().subscribe(response => {
this.data.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) }))
this.data.loading = false
this.user.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) }))
this.user.loading = false
this.cdr.detectChanges()
}, error => {
this.data.loading = false
this.user.loading = false
this.cdr.detectChanges()
})
}
selectUser(data?: UserModel) {
this.data.select = new MyUserModel(data)
selectData(filed: string, data: any) {
(this as any)[filed] = data
}
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
......@@ -48,21 +65,24 @@ export class UserSettingsComponent {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.data.loading = true
this.user.loading = true
this.fileService.upload(formData, 'mbu1').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
} else {
this.showAlert(response.message, 'error')
this.data.loading = false
this.user.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.data.loading = false
this.user.loading = false
}
})
}
selectUser() {
}
downloadFile() {
const fileName = 'IMPORT_USER.xlsx'
this.fileService.download(fileName).subscribe({
......
......@@ -191,7 +191,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<div
......@@ -294,7 +294,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......
......@@ -190,7 +190,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......@@ -297,7 +297,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......
......@@ -190,7 +190,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......@@ -297,7 +297,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......
......@@ -192,7 +192,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......@@ -299,7 +299,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......
......@@ -190,7 +190,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......@@ -297,7 +297,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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()">
<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">
......
......@@ -190,7 +190,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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"
(ngModelChange)="bu4idChange()">
<div
......@@ -298,7 +298,7 @@
<div class="relative flex rounded-md">
<input type="text" id="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"
(ngModelChange)="bu4idChange()">
<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