Browse Source

申报单位管理

warrior 8 months ago
parent
commit
b53b342a78

+ 5 - 5
projects/textbook/src/app/comp-manage/comp-manage.component.ts

@@ -50,11 +50,11 @@ export class CompManageComponent implements OnInit {
             path:"/nav-admin/manage/user",
             id:'2-1',
           },
-          {
-            name:'组织管理',
-            path:"/nav-admin/manage/role",
-            id:'2-3',
-          },
+          // {
+          //   name:'组织管理',
+          //   path:"/nav-admin/manage/role",
+          //   id:'2-3',
+          // },
         ]
       },
       // {

+ 4 - 1
projects/textbook/src/app/comp-upload/comp-upload.component.html

@@ -1,4 +1,5 @@
-<nz-upload
+<div [style.width]="width ? width + 'px' : '100%'">
+  <nz-upload
   nzAction="https://www.mocky.io/v2/5cc8019d300000980a055e76"
   [nzHeaders]="{ authorization: 'authorization-text' }"
   (nzChange)="handleChange($event)"
@@ -11,3 +12,5 @@
   </div>
 
 </nz-upload>
+
+</div>

+ 2 - 1
projects/textbook/src/app/comp-upload/comp-upload.component.ts

@@ -19,7 +19,8 @@ export class CompUploadComponent implements OnInit {
   @Input('title') title:string = '上传文件'
   @Input('files') files:Array<any> = []
   @Output() change: EventEmitter<any> = new EventEmitter<any>();
-
+  @Input('width') width:number = 0
+  
   fileList:any = [
     // {
     //   uid: '1',

+ 25 - 4
projects/textbook/src/modules/login/account-info/account-info.component.html

@@ -83,8 +83,7 @@
           <input
             nz-input
             type="text"
-            [(ngModel)]="nonRequired.telephone"
-            [ngModelOptions]="{ standalone: true }"
+            formControlName="telephone"
             placeholder="请填写办公电话"
           />
         </nz-input-group>
@@ -107,6 +106,26 @@
           </nz-select>
         </nz-input-group>
       </nz-form-item>
+      <nz-form-item>
+        <nz-form-label class="label" [nzNoColon]="true" nzRequired
+          >人员类型</nz-form-label
+        >
+        <nz-input-group>
+          <nz-select
+            style="width: 100%"
+            nzShowSearch
+            nzAllowClear
+            nzPlaceHolder="请选择人员类型"
+            formControlName="identity"
+          >
+            @for(item of userType; track item;let index = $index){
+            <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
+              item
+            }}</nz-option>
+            }
+          </nz-select>
+        </nz-input-group>
+      </nz-form-item>
       <nz-form-item>
         <nz-form-label class="label" [nzNoColon]="true" nzRequired
           >单位类型</nz-form-label
@@ -118,6 +137,7 @@
             nzAllowClear
             nzPlaceHolder="请选择单位类型"
             formControlName="companyType"
+            (ngModelChange)="provinceChange('', true)"
           >
             @for(item of unitTypes; track item;let index = $index){
             <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
@@ -137,8 +157,9 @@
             nzShowSearch
             nzAllowClear
             nzPlaceHolder="请选择单位名称"
-            formControlName="companyName"
+            [(ngModel)]="companyName"
             (nzOnSearch)="provinceChange($event)"
+            [ngModelOptions]="{ standalone: true }"
           >
             @for(item of companys; track item;let index = $index){
             <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
@@ -188,7 +209,7 @@
           >单位联系人认证文件</nz-form-label
         >
         <nz-input-group>
-          <app-comp-upload (change)="upload($event)" title="上传认证文件"></app-comp-upload>
+          <app-comp-upload [width]="320" (change)="upload($event)" title="上传认证文件"></app-comp-upload>
           <div class="text" style="margin: 10px 0; color: #231c1f99">
             请下载单位联系人认证<a href="">文件模板</a
             >,填写盖章后上传。支持上传 PDF、JPG、JPEG、PNG

+ 38 - 24
projects/textbook/src/modules/login/account-info/account-info.component.ts

@@ -42,38 +42,33 @@ export class AccountInfoComponent implements OnInit {
     email: FormControl<string>; //电子邮箱
     telephone: FormControl<string>; //办公电话
     province: FormControl<string>; //省份
+    identity:FormControl<string>; //人员类型
     companyType: FormControl<string>; //单位类型
-    companyName: FormControl<string>; //单位名称
     // idcard: FormControl<string>; //身份证号
     departmentName: FormControl<string>; //所在部门
     postName: FormControl<string>; //职务
-    identityFile: FormControl<string>; //单位联系人认证文件
   }> = this.fb.group({
     name: ['', [Validators.required]],
     phone: [''],
     email: ['', [Validators.required]],
     telephone: [''],
     province: [''],
+    identity: ['', [Validators.required]],
     companyType: ['', [Validators.required]],
-    companyName: ['', [Validators.required]],
     // idcard: ['', [Validators.required]],
     departmentName: [''],
     postName: [''],
-    identityFile: [''],
   });
-  nonRequired: any = {
-    job: '',
-  };
+  identityFile: string = '' //单位联系人认证文件
+  companyName: string = '' //单位名称
 
-  //省份
-  provinces: Array<string> = provinces.options;
-  unitTypes: Array<string> = [
-    '全国出版单位',
-    '教育部直属高校',
-    '中央有关部门教育司',
-    '省级教育行政部门',
-  ];
+  provinces: Array<string> = provinces.options;  //省份
+  unitTypes: Array<string> = [];
   companys: Array<string> = [];
+  userType: Array<string> = [
+    '报送联系人','评审专家','高校联系人','个人'
+  ];
+
   constructor(
     public tbookSer: textbookServer,
     private fb: NonNullableFormBuilder,
@@ -88,6 +83,7 @@ export class AccountInfoComponent implements OnInit {
     let user = Parse.User.current();
     if(!user?.id) history.back()
     this.user = user;
+    await this.getUnitTypes()
     if (user?.get('accountState') == '已认证') {
       this.message.success('账号已认证,无需重复认证');
       this.authServr.profileVerify(this.modal);
@@ -106,17 +102,32 @@ export class AccountInfoComponent implements OnInit {
       email: [user?.get('email') || '', [Validators.required]],
       telephone: [profile?.get('telephone') || ''],
       province: [user?.get('province') || ''],
+      identity: [profile?.get('identity') || '', [Validators.required]],
       companyType: [profile?.get('companyType') || '', [Validators.required]],
-      companyName: [user?.get('companyName') || '', [Validators.required]],
       departmentName: [user?.get('departmentName') || ''],
       postName: [profile?.get('postName') || ''],
-      identityFile: [profile?.get('identityFile') || ''],
     });
+    this.identityFile = profile?.get('identityFile') || ''
+    this.companyName = user?.get('companyName') || ''
+    this.provinceChange()
+    console.log(this.companyName, this.identityFile);
+    console.log(this.validateForm.value);
+  }
+  async getUnitTypes(){
+    let query = new Parse.Query('Department');
+    query.equalTo('branch', undefined);
+    query.equalTo('parent', undefined);
+    query.notEqualTo('isDeleted',true);
+    query.select('name');
+    let r = await query.find()
+    r.forEach(item=>{
+      this.unitTypes.push(item.get('name'))
+    })
   }
   //根据所选单位类型获取对应单位
-  async provinceChange(val?: string) {
-    console.log(this.validateForm.value.companyType);
+  async provinceChange(val?: string, isChange?:boolean) {
     console.log(val);
+    if(isChange) this.companyName = ''
     this.companys = [];
     let query = new Parse.Query('Department');
     query.equalTo('branch', this.validateForm.value.companyType);
@@ -131,6 +142,10 @@ export class AccountInfoComponent implements OnInit {
   submitForm(): void {
     console.log(this.validateForm.value);
     if (this.validateForm.valid) {
+      if(!this.companyName){
+        this.message.error('单位名称未选择或与单位类型不匹配,请重新选择');
+        return
+      }
       let a =
         /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
       if (!String(this.validateForm.value.email).match(a)) {
@@ -155,12 +170,11 @@ export class AccountInfoComponent implements OnInit {
     this.user?.set('email', params.email);
     this.user?.set('phone', params.phone);
     this.user?.set('province', params.province);
-    this.user?.set('companyName', params.companyName);
+    this.user?.set('companyName', this.companyName);
     !this.user?.get('accountState') && this.user?.set('accountState', '待认证');
     this.user?.set('departmentName', params.departmentName);
     await this.user?.save();
 
-    console.log(params);
     let query = new Parse.Query('Profile');
     query.equalTo('user', Parse.User.current()?.id);
     query.notEqualTo('isDeleted', true);
@@ -179,8 +193,8 @@ export class AccountInfoComponent implements OnInit {
     profile?.set('companyType', params.companyType);
     profile?.set('email', params.email);
     // profile?.set('idcard', params.idcard);
-    profile?.set('identity', '报送联系人');
-    profile?.set('identityFile', params.identityFile);
+    profile?.set('identity', params.identity);
+    profile?.set('identityFile', this.identityFile);
     profile?.set('postName', params.postName);
     let res = await profile?.save();
     this.modal.success({
@@ -193,7 +207,7 @@ export class AccountInfoComponent implements OnInit {
   upload(e:any){
     console.log(e);
     let file = e[0]
-    this.validateForm.value.identityFile = file
+    this.identityFile = file
   }
   //验证手机号或邮箱是否注册
   async authUser(): Promise<boolean> {