Browse Source

更新27号测试问题

warrior 1 month ago
parent
commit
7c165289a7

+ 1 - 0
projects/textbook/src/modules/nav-admin/page-process/process-create/process-create.component.ts

@@ -143,6 +143,7 @@ export class ProcessCreateComponent implements OnInit {
   //根据所选单位类型获取对应单位
   async provinceChange(id?: string, val?: string) {
     let query = new Parse.Query('Department');
+    query.notEqualTo('isDeleted', true);
     id && query.equalTo('parent', id);
     query.select('name', 'branch');
     query.limit(100);

+ 2 - 1
projects/textbook/src/modules/nav-admin/page-role/page-role.component.html

@@ -195,7 +195,7 @@
               {{ data?.get("identity") }}
             </td>
             <td nzEllipsis>
-              {{ data?.get("user").get("departmentName") || "-" }}
+              {{ data?.get("user").get("department")?.get('name') || "-" }}
             </td>
             <td nzEllipsis nzRight>
               <button
@@ -354,6 +354,7 @@
       nz-button
       nzType="primary"
       style="background: #3e49b3; border: 1px #3e49b3"
+      [disabled]="isDisabled"
       (click)="handleOk()"
     >
       确定

+ 118 - 66
projects/textbook/src/modules/nav-admin/page-role/page-role.component.ts

@@ -189,7 +189,10 @@ export class PageRoleComponent implements OnInit {
         type: item.get('type'),
       });
     });
-    parent && nodes.sort((a:any,b:any)=> a.title.localeCompare(b.title, 'zh-Hans-CN'))
+    parent &&
+      nodes.sort((a: any, b: any) =>
+        a.title.localeCompare(b.title, 'zh-Hans-CN')
+      );
     return nodes;
   }
   //搜索
@@ -276,7 +279,7 @@ export class PageRoleComponent implements OnInit {
       },
     };
     let query = Parse.Query.fromJSON('Profile', queryParams);
-    query.include('user');
+    query.include('user', 'user.department');
     query.notEqualTo('identity', '国家级管理员');
     query.notEqualTo('isDeleted', true);
     this.profileLength = await query.count();
@@ -313,6 +316,7 @@ export class PageRoleComponent implements OnInit {
   }
   //删除部门
   async onDelDepart() {
+    console.log(this.activatedNode);
     this.modal.confirm({
       nzTitle: '删除',
       nzContent: '删除后数据不可恢复,请谨慎操作',
@@ -327,6 +331,23 @@ export class PageRoleComponent implements OnInit {
             if (r?.id) {
               r.set('isDeleted', true);
               await r.save();
+              if (r?.get('parent')) {
+                let queryDat = new Parse.Query('Department');
+                queryDat.equalTo('parent', r?.get('parent'));
+                queryDat.notEqualTo('isDeleted', true);
+                let res = await queryDat.count();
+                if (res == 0) {
+                  let queryDatPat = new Parse.Query('Department');
+                  // queryDatPat.equalTo('id',r?.get('parent'));
+                  queryDatPat.select('hasChildren');
+                  let resParent = await queryDatPat.get(r?.get('parent'));
+                  console.log(resParent);
+                  if (resParent) {
+                    resParent.set('hasChildren', false);
+                    await resParent.save();
+                  }
+                }
+              }
             }
             this.message.success('删除成功');
             this.nodes = await this.getDepart();
@@ -499,61 +520,69 @@ export class PageRoleComponent implements OnInit {
       this.editObject.branch = e.branch || e.title;
     }
   }
+  isDisabled: boolean = false; //禁用
+  timer: any;
   //保存编辑&新增部门
-  async handleOk(): Promise<void> {
-    if (!this.editObject?.name || !this.editObject.parent?.id) {
-      this.message.error('请填写完整信息');
-      return;
-    }
-    if (this.activeDepart?.id && this.editType == 'edit') {
-      this.activeDepart.set('name', this.editObject?.name);
-      this.activeDepart.set('code', this.editObject?.code);
-      this.activeDepart.set('desc', this.editObject.desc);
-      this.activeDepart.set('parent', {
-        __type: 'Pointer',
-        className: 'Department',
-        objectId: this.editObject.parent?.id,
-      });
-      this.activeDepart.set('branch', this.editObject.branch);
-    } else {
-      let obj = Parse.Object.extend('Department');
-      this.activeDepart = new obj();
-      this.activeDepart?.set('name', this.editObject?.name);
-      this.activeDepart?.set('code', this.editObject?.code);
-      this.activeDepart?.set('desc', this.editObject.desc);
-      this.activeDepart?.set('parent', {
-        __type: 'Pointer',
-        className: 'Department',
-        objectId: this.editObject.parent?.id,
-      });
-      this.activeDepart?.set('branch', this.editObject.branch);
-    }
-    let type;
-    let filters = ['出版单位', '教育部直属高校'];
-    if (filters.includes(this.editObject.parent?.title)) {
-      type = '单位';
-    }
-    this.activeDepart?.set('type', type);
-    await this.activeDepart?.save();
-    if (!type && this.activeDepart?.id) {
-      //判断添加的是部门还是单位
-      let leng = await this.tbookSer.formatNode(this.activeDepart.id);
-      if (leng.length > 2) {
-        console.log(leng.length);
-        if (filters.includes(leng[0].title)) {
-          this.activeDepart?.set('type', '部门');
-        } else {
-          this.activeDepart?.set('type', leng.length > 3 ? '部门' : '单位');
+  handleOk() {
+    if (this.isDisabled) return;
+    if (this.timer) clearTimeout(this.timer);
+    this.timer = setTimeout(async () => {
+      if (!this.editObject?.name || !this.editObject.parent?.id) {
+        this.message.error('请填写完整信息');
+        this.isDisabled = false;
+        return;
+      }
+      if (this.activeDepart?.id && this.editType == 'edit') {
+        this.activeDepart.set('name', this.editObject?.name);
+        this.activeDepart.set('code', this.editObject?.code);
+        this.activeDepart.set('desc', this.editObject.desc);
+        this.activeDepart.set('parent', {
+          __type: 'Pointer',
+          className: 'Department',
+          objectId: this.editObject.parent?.id,
+        });
+        this.activeDepart.set('branch', this.editObject.branch);
+      } else {
+        let obj = Parse.Object.extend('Department');
+        this.activeDepart = new obj();
+        this.activeDepart?.set('name', this.editObject?.name);
+        this.activeDepart?.set('code', this.editObject?.code);
+        this.activeDepart?.set('desc', this.editObject.desc);
+        this.activeDepart?.set('parent', {
+          __type: 'Pointer',
+          className: 'Department',
+          objectId: this.editObject.parent?.id,
+        });
+        this.activeDepart?.set('branch', this.editObject.branch);
+      }
+      let type;
+      let filters = ['出版单位', '教育部直属高校'];
+      if (filters.includes(this.editObject.parent?.title)) {
+        type = '单位';
+      }
+      this.activeDepart?.set('type', type);
+      await this.activeDepart?.save();
+      if (!type && this.activeDepart?.id) {
+        //判断添加的是部门还是单位
+        let leng = await this.tbookSer.formatNode(this.activeDepart.id);
+        if (leng.length > 2) {
+          console.log(leng.length);
+          if (filters.includes(leng[0].title)) {
+            this.activeDepart?.set('type', '部门');
+          } else {
+            this.activeDepart?.set('type', leng.length > 3 ? '部门' : '单位');
+          }
+          leng.slice();
+          await this.activeDepart?.save();
         }
-        leng.slice();
-        await this.activeDepart?.save();
       }
-    }
-    await this.updateChildren();
-    this.isVisible = false;
-    this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功');
-    this.activeDepart = undefined;
-    this.nodes = await this.getDepart();
+      await this.updateChildren();
+      this.isVisible = false;
+      this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功');
+      this.activeDepart = undefined;
+      this.nodes = await this.getDepart();
+      this.isDisabled = false;
+    }, 500);
   }
   //更新上级children字段
   async updateChildren() {
@@ -569,7 +598,9 @@ export class PageRoleComponent implements OnInit {
   }
   //变更用户部门
   async showProfile(data: Parse.Object) {
-    let id = data?.get('user')?.get('department')?.id || data?.get('user')?.get('department')?.objectId
+    let id =
+      data?.get('user')?.get('department')?.id ||
+      data?.get('user')?.get('department')?.objectId;
     let query = new Parse.Query('Department');
     query.include('parent', 'parent.parent');
     let r = await query.get(id);
@@ -719,8 +750,14 @@ export class PageRoleComponent implements OnInit {
     }
     try {
       //如果更换用户之前是工作联系人,卸载对应流程工作联系人
-      if(this.profileAccount?.id && this.profileAccount?.get('identity') == '工作联系人'){
-        await this.tbookSer.updateProfileSubmitted(this.profileAccount?.id,'del')
+      if (
+        this.profileAccount?.id &&
+        this.profileAccount?.get('identity') == '工作联系人'
+      ) {
+        await this.tbookSer.updateProfileSubmitted(
+          this.profileAccount?.id,
+          'del'
+        );
       }
       this.profileAccount?.set('identity', this.profileEdit?.identity);
       this.profileAccount?.set('companyType', this.profileEdit?.companyType);
@@ -731,17 +768,25 @@ export class PageRoleComponent implements OnInit {
         objectId: this.profileEdit?.department.id,
       });
       await this.profileAccount?.get('user')?.save();
-      if(this.profileEdit?.identity == '工作联系人' && this.profileAccount?.id){
-        let auth = await this.tbookSer.updateProfileSubmitted(this.profileAccount?.id,'save',this.profileEdit?.department.id,this.message)
-        if(!auth){
+      if (
+        this.profileEdit?.identity == '工作联系人' &&
+        this.profileAccount?.id
+      ) {
+        let auth = await this.tbookSer.updateProfileSubmitted(
+          this.profileAccount?.id,
+          'save',
+          this.profileEdit?.department.id,
+          this.message
+        );
+        if (!auth) {
           this.isLoadingOne = false;
-          return
+          return;
         }
       }
       this.pageIndex = 1;
       this.getProfile();
       this.isLoadingOne = false;
-      this.handleCancel()
+      this.handleCancel();
     } catch (err) {
       console.log(err);
       this.message.error('修改出错,请稍后重试');
@@ -853,16 +898,23 @@ export class PageRoleComponent implements OnInit {
       nzTitle: `确认${data?.id ? '删除该用户' : '批量删除'}吗?`,
       nzContent: `${
         v
-          ? '该用户已经被设置为【'+ v + '】的工作联系人,删除后,你需要重新设置该流程的工作联系人'
+          ? '该用户已经被设置为【' +
+            v +
+            '】的工作联系人,删除后,你需要重新设置该流程的工作联系人'
           : '该用户已经提交至申报流程中的教材不会被删除'
       }`,
       nzOkText: '确认',
       nzOkType: 'primary',
       nzOkDanger: true,
       nzOnOk: async () => {
-        let selectedList = this.profiles.filter((item: any) =>
-          this.setOfCheckedId.has(item?.id)
-        );
+        let selectedList: Array<any> = [];
+        if (!data?.id) {
+          selectedList = this.profiles.filter((item: any) =>
+            this.setOfCheckedId.has(item?.id)
+          );
+        } else {
+          selectedList = [data];
+        }
         let deletePromiseList = selectedList.map((item: any) => {
           return new Promise(async (resolve) => {
             await item.get('user')?.destroy();

+ 6 - 1
projects/textbook/src/modules/nav-admin/page-user/page-user.component.html

@@ -128,7 +128,7 @@
         <td>
           {{ data?.get("user")?.get("phone") || "-" }}
         </td>
-        <td nzEllipsis>
+        <td nzEllipsis nz-popover [nzPopoverContent]="contentTemplate">
           <div class="email">
             <span
               class="state"
@@ -142,6 +142,11 @@
               {{ data?.get("user")?.get("email") || data?.get("email") }}
             </div>
           </div>
+          <ng-template #contentTemplate>
+            <div style="max-width: 400px">
+              {{ data?.get("user")?.get("email") || data?.get("email") }}
+            </div>
+          </ng-template>
         </td>
         <td>
           {{ data?.get("identity") }}

+ 2 - 0
projects/textbook/src/modules/nav-admin/page-user/page-user.component.ts

@@ -15,6 +15,7 @@ import { textbookServer } from '../../../services/textbook';
 import { NzMessageService } from 'ng-zorro-antd/message';
 import { NzSelectModule } from 'ng-zorro-antd/select';
 import { NzRadioModule } from 'ng-zorro-antd/radio';
+import { NzPopoverModule } from 'ng-zorro-antd/popover';
 
 @Component({
   selector: 'app-page-user',
@@ -31,6 +32,7 @@ import { NzRadioModule } from 'ng-zorro-antd/radio';
     NzRadioModule,
     NzEmptyModule,
     NzSelectModule,
+    NzPopoverModule,
   ],
   standalone: true,
 })

+ 2 - 2
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.html

@@ -114,7 +114,7 @@
           <div nz-col nzSpan="8">
             <div class="lable">创建时间</div>
             <div class="value pd4-8">
-              {{ user?.createdAt | date : "yyyy-MM-dd HH:MM:ss" || "-" }}
+              {{ (user?.createdAt | date : "yyyy-MM-dd HH:MM:ss") || "-" }}
             </div>
           </div>
           <div nz-col nzSpan="8">
@@ -294,7 +294,7 @@
                 nzAllowClear
                 [disabled]="this.tbookSer.profile.identity != '国家级管理员'"
                 nzPlaceHolder="请选择所在单位类型"
-                (ngModelChange)="onChangeType()"
+                (ngModelChange)="onChangeType($event)"
                 [(ngModel)]="userDataJson.companyType"
                 [ngModelOptions]="{ standalone: true }"
               >

+ 6 - 4
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.ts

@@ -247,7 +247,8 @@ export class UserEditComponent implements OnInit {
     this.isVisible = false;
   }
   //切换单位类型
-  onChangeType() {
+  onChangeType(e:string) {
+    // console.log(e);
     this.userDataJson.department = null;
     this.depTitle = '';
     this.radio = '';
@@ -258,8 +259,8 @@ export class UserEditComponent implements OnInit {
       this.message.warning('同级身份暂无权限操作');
       return;
     }
-    this.depTitle = this.userDataJson.department.name;
-    this.radio = this.userDataJson.department.id;
+    this.depTitle = this.userDataJson.department?.name;
+    this.radio = this.userDataJson.department?.id;
     if (this.unitTypes.length == 0) {
       await this.getUnitTypes();
     }
@@ -455,6 +456,7 @@ export class UserEditComponent implements OnInit {
     } else {
       this.userJson = this.user.toJSON();
       this.profileJson = this.profile.toJSON();
+      this.userJson.email = this.profileJson.email;
       this.userDataJson = {
         companyType: this.profile?.get('companyType'),
         department: {
@@ -475,7 +477,7 @@ export class UserEditComponent implements OnInit {
     console.log(this.profileJson);
     this.userJson.username = this.userJson?.username?.trim();
     this.userJson.email = this.userJson?.email?.trim();
-    this.userJson.phone = this.userJson?.phone?.trim();
+    this.userJson.phone = String(this.userJson?.phone)?.trim();
     this.userJson.name = this.userJson?.name?.trim();
     if (!(await this.authVrifly())) {
       this.loading = false;

+ 1 - 1
projects/textbook/src/services/textbook.ts

@@ -210,7 +210,7 @@ export class textbookServer {
     query.notEqualTo('isDeleted', true);
     let res = await query.first();
     if (!res?.id) {
-      msg?.warning('所属单位不存在');
+      msg?.warning('用户绑定的单位流程不存在');
       return false;
     }
     if (type == 'del') {