Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
5,939
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   componentDidMount() {
  2.         if (this.props.elaborationModel) {
  3.             this.frecuency = this.props.elaborationModel.promotion.frecuencia;
  4.             this.fechaDesde = this.props.elaborationModel.promotion.fechaDesde;
  5.         }
  6.  
  7.         this.loadData(this.frecuency, false, this.fechaDesde, null);
  8.  
  9.         this.props.setBusy(true);
  10.         /*this.commercialStructureService.loadSearch(this.frecuency, false, this.fechaDesde, null).then(response => {
  11.             if (!response.length && response.length !== 0) {
  12.                 var arr = new Array();
  13.                 arr.push(response);
  14.                 if (arr[0].message !== "") {
  15.                     this.dialogService.show("Mantenimiento EstructuraComercial", arr[0].message);
  16.                 }
  17.             } else if (response.length === 0) {
  18.                 this.dialogService.show("Mantenimiento EstructuraComercial", "No se ha producido ninguna coincidencia con los criterios de busqueda.");
  19.             }
  20.             this.setState({
  21.                 items: response
  22.             });
  23.             this.props.setBusy(false);
  24.         }).catch(error => {
  25.             if (error.message !== "" && error.message.indexOf("timeout") !== -1) {
  26.                 this.dialogService.show("Mantenimiento Soportes", "La base de datos ha tardado mucho en responder.");
  27.             } else if (error.message && error.message !== "" && error.message.indexOf("code 500") !== -1) {
  28.                 this.dialogService.show("Mantenimiento Soportes", "Ha habido un problema al intentar conctarse con el servidor. Intente cotactar con su administrador.");
  29.             }
  30.             this.props.setBusy(false);
  31.         });*/
  32.     }
  33.  
  34.     @autobind
  35.     private loadData(frequency, sinPlan, fechaDesde, idEstanco) {
  36.         this.props.setBusy(true);
  37.         this.commercialStructureService.loadSearch(frequency, sinPlan, fechaDesde, idEstanco).then(response => {
  38.             if (!response.length && response.length !== 0) {
  39.                 var arr = new Array();
  40.                 arr.push(response);
  41.                 if (arr[0].message !== "") {
  42.                     this.dialogService.show("Mantenimiento EstructuraComercial", arr[0].message);
  43.                 }
  44.             } else if (response.length === 0) {
  45.                 this.dialogService.show("Mantenimiento EstructuraComercial", "No se ha producido ninguna coincidencia con los criterios de busqueda.");
  46.             }
  47.             this.setState({
  48.                 items: response
  49.             });
  50.             this.props.setBusy(false);
  51.         }).catch(error => {
  52.             if (error.message !== "" && error.message.indexOf("timeout") !== -1) {
  53.                 this.dialogService.show("Mantenimiento Soportes", "La base de datos ha tardado mucho en responder.");
  54.             } else if (error.message && error.message !== "" && error.message.indexOf("code 500") !== -1) {
  55.                 this.dialogService.show("Mantenimiento Soportes", "Ha habido un problema al intentar conctarse con el servidor. Intente cotactar con su administrador.");
  56.             }
  57.             this.props.setBusy(false);
  58.         });
  59.     }
  60.  
  61.     @autobind
  62.     private reload(sinPlan: boolean) {
  63.         this.loadData(this.frecuency, sinPlan, this.fechaDesde, null);
  64.         /*this.props.setBusy(true);
  65.         this.commercialStructureService.loadSearch(this.frecuency, sinPlan, this.fechaDesde, null).then(response => {
  66.             if (!response.length && response.length !== 0) {
  67.                 var arr = new Array();
  68.                 arr.push(response);
  69.                 if (arr[0].message !== "") {
  70.                     this.dialogService.show("Mantenimiento EstructuraComercial", arr[0].message);
  71.                 }
  72.             } else if (response.length === 0) {
  73.                 this.dialogService.show("Mantenimiento EstructuraComercial", "No se ha producido ninguna coincidencia con los criterios de busqueda.");
  74.             }
  75.             this.setState({
  76.                 items: response
  77.             });
  78.             this.props.setBusy(false);
  79.         }).catch(error => {
  80.             if (error.message !== "" && error.message.indexOf("timeout") !== -1) {
  81.                 this.dialogService.show("Mantenimiento Soportes", "La base de datos ha tardado mucho en responder.");
  82.             } else if (error.message && error.message !== "" && error.message.indexOf("code 500") !== -1) {
  83.                 this.dialogService.show("Mantenimiento Soportes", "Ha habido un problema al intentar conctarse con el servidor. Intente cotactar con su administrador.");
  84.             }
  85.             this.props.setBusy(false);
  86.         });*/
  87.     }
  88.  
  89.     @autobind
  90.     private reloadEstanco(idEstanco) {
  91.  
  92.         return new Promise((resolve, reject) => { this.loadData(this.frecuency, false, this.fechaDesde, idEstanco); resolve() });
  93.         /*this.commercialStructureService.loadSearch(this.frecuency, false, this.fechaDesde, idEstanco).then(response => {
  94.             if (!response.length && response.length !== 0) {
  95.                 var arr = new Array();
  96.                 arr.push(response);
  97.                 if (arr[0].message !== "") {
  98.                     this.dialogService.show("Mantenimiento EstructuraComercial", arr[0].message);
  99.                 }
  100.             } else if (response.length === 0) {
  101.                 this.dialogService.show("Mantenimiento EstructuraComercial", "No se ha producido ninguna coincidencia con los criterios de busqueda.");
  102.             }
  103.             this.setState({
  104.                 items: response
  105.             });
  106.             this.props.setBusy(false);
  107.         }).catch(error => {
  108.             if (error.message !== "" && error.message.indexOf("timeout") !== -1) {
  109.                 this.dialogService.show("Mantenimiento Soportes", "La base de datos ha tardado mucho en responder.");
  110.             } else if (error.message && error.message !== "" && error.message.indexOf("code 500") !== -1) {
  111.                 this.dialogService.show("Mantenimiento Soportes", "Ha habido un problema al intentar conctarse con el servidor. Intente cotactar con su administrador.");
  112.             }
  113.             this.props.setBusy(false);
  114.         });*/
  115.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement