|
|
@@ -125,10 +125,7 @@ export class SubcontratistComponent implements OnInit, AfterViewInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public async openDialog(typeForm: string, element?: any) {
|
|
|
- console.log(typeForm);
|
|
|
- console.log(element);
|
|
|
-
|
|
|
+ public async openDialog(typeForm: string, element?: any) {
|
|
|
if (typeForm === 'REG') {
|
|
|
|
|
|
const typeFormSubcontract: TypeFormSubcontract = {
|
|
|
@@ -252,51 +249,40 @@ export class SubcontratistComponent implements OnInit, AfterViewInit {
|
|
|
}
|
|
|
|
|
|
public async getSubcontratists() {
|
|
|
- try{
|
|
|
- this.isLoading = true;
|
|
|
- this.hasError = false;
|
|
|
- this.errorStr = '';
|
|
|
-
|
|
|
- let idUser = localStorage.getItem('idusuario')!;
|
|
|
- let subcontratists: SubcontratistsResponse = await lastValueFrom(this._subcontratistService.getConsultOfSubcontratists(idUser, 1));
|
|
|
-
|
|
|
- this.hasError = subcontratists.error;
|
|
|
- this.errorStr = subcontratists.msg;
|
|
|
-
|
|
|
- if(!this.hasError){
|
|
|
- let subcontratistsArr: SubcontratistItem[] = [];
|
|
|
- subcontratists.response.forEach(item => {
|
|
|
- let regFormatted = this._functionsService.orderDate(item.REGISTER_DATE);
|
|
|
- let modFormatted = null;
|
|
|
-
|
|
|
- if(item.UPDATE_DATE != null){
|
|
|
- modFormatted = this._functionsService.orderDate(item.UPDATE_DATE);
|
|
|
- }
|
|
|
-
|
|
|
- item.REGISTER_DATE = regFormatted!;
|
|
|
- item.UPDATE_DATE = modFormatted!;
|
|
|
-
|
|
|
- subcontratistsArr.push(item);
|
|
|
- }),
|
|
|
-
|
|
|
- this.dataSourceSubcontratists.data = subcontratistsArr;
|
|
|
- // this.dataSourceSubcontratists.sort = this.sort2;
|
|
|
- // this.dataSourceSubcontratists.paginator = this.paginator2;
|
|
|
- }
|
|
|
-
|
|
|
- this.isLoading = false;
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else{
|
|
|
- this.errorStr = error.error.msg;
|
|
|
- }
|
|
|
+ this.isLoading = true;
|
|
|
+
|
|
|
+ const USER: string = this.resourcesService.getUser();
|
|
|
+ const LINE: number = this.resourcesService.getLineNumber();
|
|
|
+ await lastValueFrom(this._subcontratistService.getConsultOfSubcontratists(USER, LINE)).then(
|
|
|
+ (responseData: SubcontratistsResponse) => {
|
|
|
+ this.hasError = responseData.error;
|
|
|
+ if (!responseData.error) {
|
|
|
|
|
|
- this.hasError = true;
|
|
|
- this.isLoading = false;
|
|
|
- }
|
|
|
+ let subcontratistsArr: SubcontratistItem[] = [];
|
|
|
+ responseData.response.forEach(item => {
|
|
|
+ let regFormatted = this._functionsService.orderDate(item.REGISTER_DATE);
|
|
|
+ let modFormatted = null;
|
|
|
+
|
|
|
+ if(item.UPDATE_DATE != null){
|
|
|
+ modFormatted = this._functionsService.orderDate(item.UPDATE_DATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ item.REGISTER_DATE = regFormatted!;
|
|
|
+ item.UPDATE_DATE = modFormatted!;
|
|
|
+
|
|
|
+ subcontratistsArr.push(item);
|
|
|
+ }),
|
|
|
+
|
|
|
+ this.dataSourceSubcontratists.data = subcontratistsArr;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.errorStr = responseData.msg;
|
|
|
+ this.resourcesService.openSnackBar(`${ responseData.msg }`);
|
|
|
+ }
|
|
|
+ }, (httpErrorResponse: HttpErrorResponse) => this.resourcesService.checkErrors(httpErrorResponse)
|
|
|
+ );
|
|
|
+
|
|
|
+ this.isLoading = false;
|
|
|
}
|
|
|
|
|
|
private async deleteSubcontratist(subcontratistId: string) {
|
|
|
@@ -337,35 +323,24 @@ export class SubcontratistComponent implements OnInit, AfterViewInit {
|
|
|
}
|
|
|
|
|
|
public async getContractsBySubcontratists() {
|
|
|
- try{
|
|
|
- let idUser = localStorage.getItem('idusuario')!;
|
|
|
-
|
|
|
- const USER: string = this.resourcesService.getUser();
|
|
|
- const LINE: number = this.resourcesService.getLineNumber();
|
|
|
- let contracts: ContractsBySubcontratistsResponse = await lastValueFrom(this._subcontratistService.getContractsOfEverySubcontratist(USER, LINE));
|
|
|
-
|
|
|
- this.hasError = contracts.error;
|
|
|
- this.errorStr = contracts.msg;
|
|
|
-
|
|
|
- if(!this.hasError){
|
|
|
- this.dataSourceContracts = new MatTableDataSource(contracts.response);
|
|
|
- this.dataSourceContracts.paginator = this.paginator;
|
|
|
- this.dataSourceContracts.sort = this.sort;
|
|
|
- }
|
|
|
-
|
|
|
- this.isLoading = false;
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else{
|
|
|
- this.errorStr = error.error.msg;
|
|
|
- }
|
|
|
+ this.isLoading = true;
|
|
|
+
|
|
|
+ const USER: string = this.resourcesService.getUser();
|
|
|
+ const LINE: number = this.resourcesService.getLineNumber();
|
|
|
+ await lastValueFrom(this._subcontratistService.getContractsOfEverySubcontratist(USER, LINE)).then(
|
|
|
+ (responseData: ContractsBySubcontratistsResponse) => {
|
|
|
+
|
|
|
+ this.hasError = responseData.error;
|
|
|
+ if (!responseData.error) {
|
|
|
+ this.dataSourceContracts.data = responseData.response;
|
|
|
+ } else {
|
|
|
+ this.errorStr = responseData.msg;
|
|
|
+ this.resourcesService.openSnackBar(responseData.msg);
|
|
|
+ }
|
|
|
+ }, (httpErrorResponse: HttpErrorResponse) => this.resourcesService.checkErrors(httpErrorResponse)
|
|
|
+ );
|
|
|
|
|
|
- this.hasError = true;
|
|
|
- this.isLoading = false;
|
|
|
- }
|
|
|
+ this.isLoading = false;
|
|
|
}
|
|
|
|
|
|
// Método de filtrado de datos
|