fix bug
This commit is contained in:
		| @ -1,8 +1,19 @@ | |||||||
| import { AfterViewInit, ChangeDetectorRef, Component, OnChanges, OnInit, ViewChild } from '@angular/core'; | import { AfterViewInit, ChangeDetectorRef, Component, OnChanges, OnInit, ViewChild } from '@angular/core'; | ||||||
| import { ActivatedRoute } from '@angular/router'; | import { ActivatedRoute } from '@angular/router'; | ||||||
| import { SFAutoCompleteWidgetSchema, SFComponent, SFRadioWidgetSchema, SFSchema, SFSchemaEnumType, SFSelectWidgetSchema, SFTextareaWidgetSchema, SFUISchema } from '@delon/form'; | import { | ||||||
|  |   SFAutoCompleteWidgetSchema, | ||||||
|  |   SFComponent, | ||||||
|  |   SFRadioWidgetSchema, | ||||||
|  |   SFSchema, | ||||||
|  |   SFSchemaEnum, | ||||||
|  |   SFSchemaEnumType, | ||||||
|  |   SFSelectWidgetSchema, | ||||||
|  |   SFTextareaWidgetSchema, | ||||||
|  |   SFUISchema | ||||||
|  | } from '@delon/form'; | ||||||
| import { _HttpClient } from '@delon/theme'; | import { _HttpClient } from '@delon/theme'; | ||||||
| import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; | import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; | ||||||
|  | import { of } from 'rxjs'; | ||||||
| import { map } from 'rxjs/operators'; | import { map } from 'rxjs/operators'; | ||||||
| import { AmapPoiPickerComponent } from 'src/app/shared/components/amap'; | import { AmapPoiPickerComponent } from 'src/app/shared/components/amap'; | ||||||
| import { ChannelSalesService } from '../../services/channel-sales.service'; | import { ChannelSalesService } from '../../services/channel-sales.service'; | ||||||
| @ -18,8 +29,8 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|   i: any; |   i: any; | ||||||
|   sts: any; |   sts: any; | ||||||
|   type: any; |   type: any; | ||||||
|   record:any; |   record: any; | ||||||
|   currentOAItem:any; |   currentOAItem: any; | ||||||
|   constructor( |   constructor( | ||||||
|     public http: _HttpClient, |     public http: _HttpClient, | ||||||
|     private cdr: ChangeDetectorRef, |     private cdr: ChangeDetectorRef, | ||||||
| @ -30,29 +41,39 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|   ) {} |   ) {} | ||||||
|  |  | ||||||
|   ngOnInit(): void { |   ngOnInit(): void { | ||||||
|     if(!this.sts) { |     this.initSF(); | ||||||
|       this.service.request(this.service.$api_getChannelSalesInfo, {id:this.i?.id}).subscribe(res => { |     if (!this.sts) { | ||||||
|         if(res){ |       this.service.request(this.service.$api_getChannelSalesInfo, { id: this.i?.id }).subscribe(res => { | ||||||
|          let value1 =  Object.assign({}, res) |         const List: any = []; | ||||||
|          delete value1.employeeVO; |         if (res) { | ||||||
|          this.record = value1; |           let value1 = Object.assign({}, res); | ||||||
|          console.log(value1); |           delete value1.employeeVO; | ||||||
|          console.log(this.record); |           console.log(value1); | ||||||
|  |           console.log(this.record); | ||||||
|  |  | ||||||
|         let value = res.employeeVO; |           let value = res.employeeVO; | ||||||
|         let yeeVO = {label: value.empName+"/"+value.empNo, value: value.empNo} |           console.log(value); | ||||||
|         console.log(yeeVO); |  | ||||||
|  |  | ||||||
|        setTimeout(()=>{ |           List.push({ label: value.empName + '/' + value.empNo, value: value.empNo }); | ||||||
|         this.sf.getProperty('/employeeVO')!.schema.enum = [yeeVO]; |           console.log(List); | ||||||
|         this.sf.getProperty('/employeeVO')!.widget.reset([yeeVO]); |  | ||||||
|        }) |  | ||||||
|  |  | ||||||
|           this.initSF(); |           setTimeout(() => { | ||||||
|  |             if (this.sf) { | ||||||
|  |               console.log(this.sf.getProperty('/employeeVO')!.schema); | ||||||
|  |  | ||||||
|  |               this.sf.getProperty('/employeeVO')!.schema.enum = List; | ||||||
|  |               this.sf.getProperty('/employeeVO')!.widget.reset(List); | ||||||
|  |             } | ||||||
|  |             if (value.empNo) { | ||||||
|  |               this.sf.setValue('/employeeVO', value.empNo); | ||||||
|  |               this.currentOAItem  = value; | ||||||
|  |               this.sf.setValue('/phoneNumber', res.telephone); | ||||||
|  |             } | ||||||
|  |           }); | ||||||
|  |           this.record = value1; | ||||||
|         } |         } | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|      |  | ||||||
|   } |   } | ||||||
|   initSF() { |   initSF() { | ||||||
|     this.schema = { |     this.schema = { | ||||||
| @ -67,7 +88,7 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|           type: 'string', |           type: 'string', | ||||||
|           maxLength: 12, |           maxLength: 12, | ||||||
|           ui: { |           ui: { | ||||||
|             placeholder:'请输入' |             placeholder: '请输入' | ||||||
|           } |           } | ||||||
|         }, |         }, | ||||||
|         phoneNumber: { |         phoneNumber: { | ||||||
| @ -75,26 +96,59 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|           type: 'string', |           type: 'string', | ||||||
|           maxLength: 11, |           maxLength: 11, | ||||||
|           ui: { |           ui: { | ||||||
|             placeholder:'请输入' |             placeholder: '请输入' | ||||||
|           } |           } | ||||||
|         }, |         }, | ||||||
|  |         // employeeVO: { | ||||||
|  |         //   title: '关联OA员工', | ||||||
|  |         //   type: 'string', | ||||||
|  |         //   ui: { | ||||||
|  |         //     widget: 'select', | ||||||
|  |         //     placeholder:'请选择', | ||||||
|  |         //     asyncData: (input:string) => this.service.request(this.service.$api_fuzzyQuery,{name:input}).pipe( | ||||||
|  |         //       map((res: any) => { | ||||||
|  |         //         return res.map((item:any)=>{ | ||||||
|  |         //           return {label: item.empName+"/"+item.empNo, value: item.empNo, obj: item} | ||||||
|  |         //         }) | ||||||
|  |         //       }) | ||||||
|  |         //     ), | ||||||
|  |         //     change:(item:any, org:any)=>{ | ||||||
|  |         //       this.currentOAItem = org.obj; | ||||||
|  |         //     } | ||||||
|  |         //   } as SFAutoCompleteWidgetSchema, | ||||||
|  |         // }, | ||||||
|         employeeVO: { |         employeeVO: { | ||||||
|           title: '关联OA员工', |           title: '关联OA员工', | ||||||
|           type: 'string', |           type: 'string', | ||||||
|  |           maxLength: 30, | ||||||
|           ui: { |           ui: { | ||||||
|             widget: 'autocomplete', |             widget: 'select', | ||||||
|             placeholder:'请选择', |             // serverSearch: true, | ||||||
|             asyncData: (input:string) => this.service.request(this.service.$api_fuzzyQuery,{name:input}).pipe( |             allowClear: true, | ||||||
|               map((res: any) => { |             searchDebounceTime: 300, | ||||||
|                 return res.map((item:any)=>{ |             searchLoadingText: '搜索中...', | ||||||
|                   return {label: item.empName+"/"+item.empNo, value: item.empNo, obj: item} |             onSearch: (q: any) => { | ||||||
|                 }) |               let str = q?.replace(/^\s+|\s+$/g, ''); | ||||||
|               }) |               if (str) { | ||||||
|             ), |                 return this.service | ||||||
|             change:(item:any, org:any)=>{ |                   .request(this.service.$api_fuzzyQuery, { name: str }) | ||||||
|  |                   .pipe(map(res => (res as any[]).map(i => ({ label: i.empName + '/' + i.empNo, value: i.empNo, obj: i } as SFSchemaEnum)))) | ||||||
|  |                   .toPromise(); | ||||||
|  |               } else { | ||||||
|  |                 return of([]); | ||||||
|  |               } | ||||||
|  |             }, | ||||||
|  |             // asyncData: (input:string) => this.service.request(this.service.$api_fuzzyQuery,{name:input}).pipe( | ||||||
|  |             //   map((res: any) => { | ||||||
|  |             //     return res.map((item:any)=>{ | ||||||
|  |             //       return {label: item.empName+"/"+item.empNo, value: item.empNo, obj: item} | ||||||
|  |             //     }) | ||||||
|  |             //   }) | ||||||
|  |             // ), | ||||||
|  |             change: (item: any, org: any) => { | ||||||
|               this.currentOAItem = org.obj; |               this.currentOAItem = org.obj; | ||||||
|             } |             } | ||||||
|           } as SFAutoCompleteWidgetSchema, |           } as SFSelectWidgetSchema | ||||||
|         }, |         }, | ||||||
|         isAuthorization: { |         isAuthorization: { | ||||||
|           type: 'string', |           type: 'string', | ||||||
| @ -104,9 +158,9 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|             { label: '是', value: '1' } |             { label: '是', value: '1' } | ||||||
|           ], |           ], | ||||||
|           ui: { |           ui: { | ||||||
|             widget: 'radio', |             widget: 'radio' | ||||||
|           } as SFRadioWidgetSchema, |           } as SFRadioWidgetSchema, | ||||||
|           default: '0', |           default: '0' | ||||||
|         }, |         }, | ||||||
|         roleIds: { |         roleIds: { | ||||||
|           title: '', |           title: '', | ||||||
| @ -128,7 +182,7 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|               ); |               ); | ||||||
|             }, |             }, | ||||||
|             visibleIf: { isAuthorization: (value: string) => value === '1' } |             visibleIf: { isAuthorization: (value: string) => value === '1' } | ||||||
|           }, |           } | ||||||
|         }, |         }, | ||||||
|         remark: { |         remark: { | ||||||
|           type: 'string', |           type: 'string', | ||||||
| @ -137,9 +191,9 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|           ui: { |           ui: { | ||||||
|             widget: 'textarea', |             widget: 'textarea', | ||||||
|             autosize: { minRows: 3, maxRows: 6 }, |             autosize: { minRows: 3, maxRows: 6 }, | ||||||
|             placeholder:'请输入50字符' |             placeholder: '请输入50字符' | ||||||
|           } as SFTextareaWidgetSchema, |           } as SFTextareaWidgetSchema | ||||||
|         }, |         } | ||||||
|       }, |       }, | ||||||
|       required: ['name', 'phoneNumber', 'employeeVO', 'roleIds', 'remark'] |       required: ['name', 'phoneNumber', 'employeeVO', 'roleIds', 'remark'] | ||||||
|     }; |     }; | ||||||
| @ -148,10 +202,8 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|         spanLabelFixed: 150, |         spanLabelFixed: 150, | ||||||
|         grid: { span: 24 } |         grid: { span: 24 } | ||||||
|       }, |       }, | ||||||
|       $isAuthorization:{  grid: { span: 12 }}, |       $isAuthorization: { grid: { span: 12 } }, | ||||||
|       $roleIds:{ spanLabelFixed: 10, grid: { span: 12 }}, |       $roleIds: { spanLabelFixed: 10, grid: { span: 12 } } | ||||||
|        |  | ||||||
|  |  | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @ -160,12 +212,15 @@ export class ParterChannelSalesEditComponent implements OnInit { | |||||||
|   } |   } | ||||||
|   save() {  |   save() {  | ||||||
|     this.sf.validator({ emitError: true }); |     this.sf.validator({ emitError: true }); | ||||||
|     if(!this.sf.valid) return; |     if (!this.sf.valid) return; | ||||||
|     this.service.request(this.service.$api_save, { ...this.sf.value, employeeVO: this.currentOAItem}).subscribe(res => { |     let params = { | ||||||
|  |       ...this.sf.value | ||||||
|  |     } | ||||||
|  |     delete params.telephone | ||||||
|  |     this.service.request(this.service.$api_save, { ...params, employeeVO: this.currentOAItem }).subscribe(res => { | ||||||
|       if (res) { |       if (res) { | ||||||
|  |         this.service.msgSrv.success(res.msg); | ||||||
|         this.modalRef.destroy(true); |         this.modalRef.destroy(true); | ||||||
|       } else { |  | ||||||
|         this.service.msgSrv.error(res.msg); |  | ||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -617,15 +617,8 @@ export class AddEtpPartnerComponent { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   private setInfo(info: any) { |   private setInfo(info: any) { | ||||||
|     if (info.name) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/name', info.name); |       this.sf.setValue('/adminUserInfo/name', info.name); | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoFront) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoFront', info.certificatePhotoFront); |       this.sf.setValue('/adminUserInfo/certificatePhotoFront', info.certificatePhotoFront); | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoFrontWatermark) { |  | ||||||
|       console.log(this.sf.getProperty('/adminUserInfo/certificatePhotoFrontWatermark')); |  | ||||||
|  |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoFrontWatermark', [ |       this.sf.setValue('/adminUserInfo/certificatePhotoFrontWatermark', [ | ||||||
|         { |         { | ||||||
|           uid: -1, |           uid: -1, | ||||||
| @ -635,11 +628,7 @@ export class AddEtpPartnerComponent { | |||||||
|           response: info.certificatePhotoFrontWatermark |           response: info.certificatePhotoFrontWatermark | ||||||
|         } |         } | ||||||
|       ]); |       ]); | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoBack) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoBack', info.certificatePhotoBack); |       this.sf.setValue('/adminUserInfo/certificatePhotoBack', info.certificatePhotoBack); | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoBackWatermark) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoBackWatermark', [ |       this.sf.setValue('/adminUserInfo/certificatePhotoBackWatermark', [ | ||||||
|         { |         { | ||||||
|           uid: -1, |           uid: -1, | ||||||
| @ -649,18 +638,9 @@ export class AddEtpPartnerComponent { | |||||||
|           response: info.certificatePhotoBackWatermark |           response: info.certificatePhotoBackWatermark | ||||||
|         } |         } | ||||||
|       ]); |       ]); | ||||||
|     } |  | ||||||
|     if (info.certificateNumber) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificateNumber', info.certificateNumber); |       this.sf.setValue('/adminUserInfo/certificateNumber', info.certificateNumber); | ||||||
|     } |  | ||||||
|     if (info.validStartTime) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/validStartTime', info.validStartTime); |       this.sf.setValue('/adminUserInfo/validStartTime', info.validStartTime); | ||||||
|     } |       this.sf.setValue('/adminUserInfo/validEndTime', info?.validEndTime ? info?.validEndTime: null); | ||||||
|     if (info.validEndTime) { |       this.sf.setValue('/adminUserInfo/_isLoingDate', info?.validEndTime ? false: true); | ||||||
|       this.sf.setValue('/adminUserInfo/validEndTime', info.validEndTime); |  | ||||||
|       this.sf.setValue('/adminUserInfo/_isLoingDate', false); |  | ||||||
|     } else { |  | ||||||
|       this.sf.setValue('/adminUserInfo/_isLoingDate', true); |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -339,50 +339,30 @@ export class AddPersonalPartnerComponent { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   private setInfo(info: any) { |   private setInfo(info: any) { | ||||||
|     if (info.name) { |       this.sf.setValue('/adminUserInfo/name', info?.name); | ||||||
|       this.sf.setValue('/adminUserInfo/name', info.name); |       this.sf.setValue('/adminUserInfo/certificatePhotoFront', info?.certificatePhotoFront); | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoFront) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoFront', info.certificatePhotoFront); |  | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoFrontWatermark) { |  | ||||||
|       console.log(this.sf.getProperty('/adminUserInfo/certificatePhotoFrontWatermark')); |  | ||||||
|  |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoFrontWatermark', [ |       this.sf.setValue('/adminUserInfo/certificatePhotoFrontWatermark', [ | ||||||
|         { |         { | ||||||
|           uid: -1, |           uid: -1, | ||||||
|           name: '文件', |           name: '文件', | ||||||
|           status: 'done', |           status: 'done', | ||||||
|           url: info.certificatePhotoFrontWatermark, |           url: info?.certificatePhotoFrontWatermark, | ||||||
|           response: info.certificatePhotoFrontWatermark |           response: info?.certificatePhotoFrontWatermark | ||||||
|         } |         } | ||||||
|       ]); |       ]); | ||||||
|     } |       this.sf.setValue('/adminUserInfo/certificatePhotoBack', info?.certificatePhotoBack); | ||||||
|     if (info.certificatePhotoBack) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoBack', info.certificatePhotoBack); |  | ||||||
|     } |  | ||||||
|     if (info.certificatePhotoBackWatermark) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/certificatePhotoBackWatermark', [ |       this.sf.setValue('/adminUserInfo/certificatePhotoBackWatermark', [ | ||||||
|         { |         { | ||||||
|           uid: -1, |           uid: -1, | ||||||
|           name: '文件', |           name: '文件', | ||||||
|           status: 'done', |           status: 'done', | ||||||
|           url: info.certificatePhotoBackWatermark, |           url: info?.certificatePhotoBackWatermark, | ||||||
|           response: info.certificatePhotoBackWatermark |           response: info?.certificatePhotoBackWatermark | ||||||
|         } |         } | ||||||
|       ]); |       ]); | ||||||
|     } |       this.sf.setValue('/adminUserInfo/certificateNumber', info?.certificateNumber); | ||||||
|     if (info.certificateNumber) { |       this.sf.setValue('/adminUserInfo/validStartTime', info?.validStartTime); | ||||||
|       this.sf.setValue('/adminUserInfo/certificateNumber', info.certificateNumber); |       this.sf.setValue('/adminUserInfo/validEndTime', info?.validEndTime ? info?.validEndTime: null); | ||||||
|     } |       this.sf.setValue('/adminUserInfo/_isLoingDate', info?.validEndTime ? false: true); | ||||||
|     if (info.validStartTime) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/validStartTime', info.validStartTime); |  | ||||||
|     } |  | ||||||
|     if (info.validEndTime) { |  | ||||||
|       this.sf.setValue('/adminUserInfo/validEndTime', info.validEndTime); |  | ||||||
|       this.sf.setValue('/adminUserInfo/_isLoingDate', false); |  | ||||||
|     } else { |  | ||||||
|       this.sf.setValue('/adminUserInfo/_isLoingDate', true); |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user