Pārlūkot izejas kodu

新增需求:用户更改部门

cehn 8 mēneši atpakaļ
vecāks
revīzija
10db82fc5f

+ 172 - 22
projects/textbook/src/modules/nav-admin/page-role/page-role.component.html

@@ -42,7 +42,7 @@
           nz-dropdown
           [nzDropdownMenu]="menutep"
           [nzPlacement]="'bottomLeft'"
-          style="margin-left: 0px; width: 280px;"
+          style="margin-left: 0px; width: 280px"
         >
           <span nz-icon nzType="plus" nzTheme="outline"></span>新建
         </button>
@@ -77,8 +77,10 @@
         <span nz-icon nzType="team" nzTheme="outline"></span>
         {{ profiles.length }}人
       </div>
-      <label nz-checkbox [(ngModel)]="checkedShowFilter"
-      (ngModelChange)="onChecked()"
+      <label
+        nz-checkbox
+        [(ngModel)]="checkedShowFilter"
+        (ngModelChange)="onChecked()"
         >仅显示部门直属成员</label
       >
     </div>
@@ -102,10 +104,10 @@
         [nzExpandedKeys]="nzExpandedKeys"
       ></nz-tree>
       }@else {
-        <div class="loading">
-          <nz-spin nzSimple></nz-spin>
-          <div class="tips">节点加载中</div>
-        </div>
+      <div class="loading">
+        <nz-spin nzSimple></nz-spin>
+        <div class="tips">节点加载中</div>
+      </div>
       }
       <ng-template #nzTreeTemplate let-node let-origin="origin">
         <span
@@ -120,8 +122,8 @@
         <ul nz-menu>
           <li nz-menu-item (click)="showModalDepart('add')">添加下级部门</li>
           @if (activatedNode?.origin?.branch) {
-            <li nz-menu-item (click)="showModalDepart('edit')">编辑部门</li>
-            <li nz-menu-item (click)="onDelDepart()">删除部门</li>
+          <li nz-menu-item (click)="showModalDepart('edit')">编辑部门</li>
+          <li nz-menu-item (click)="onDelDepart()">删除部门</li>
           }
         </ul>
       </nz-dropdown-menu>
@@ -181,19 +183,19 @@
               class="activeTd"
             >
               <nz-avatar nzIcon="user"></nz-avatar>
-              {{ data?.get("user")?.get("name") || '-'}}
+              {{ data?.get("user")?.get("name") || "-" }}
             </td>
             <td nzEllipsis>
-              {{ data?.get("user")?.get("phone") || '-' }}
+              {{ data?.get("user")?.get("phone") || "-" }}
             </td>
             <td nzEllipsis>
-              {{ data?.get("user")?.get("email") || data?.get("email") || '-'}}
+              {{ data?.get("user")?.get("email") || data?.get("email") || "-" }}
             </td>
             <td nzEllipsis>
               {{ data?.get("identity") }}
             </td>
             <td nzEllipsis>
-              {{ data?.get("user").get("departmentName") || '-' }}
+              {{ data?.get("user").get("departmentName") || "-" }}
             </td>
             <td nzEllipsis nzRight>
               <button
@@ -208,13 +210,24 @@
                 <ul nz-menu>
                   <li nz-menu-item>
                     <button
-                      (click)="removeBranch(data)"
                       nz-button
                       style="color: #231c1f"
+                      (click)="showProfile(data)"
+                      nzType="link"
+                    >
+                      <span nz-icon nzType="retweet" nzTheme="outline"></span
+                      >更换部门
+                    </button>
+                  </li>
+                  <li nz-menu-item>
+                    <button
+                      nz-button
+                      (click)="deleteSelected(data)"
+                      style="color: #231c1f"
                       nzType="link"
                     >
-                      <span nz-icon nzType="stop" nzTheme="outline"></span
-                      >移除部门
+                      <span nz-icon nzType="delete" nzTheme="outline"></span
+                      >删除用户
                     </button>
                   </li>
                 </ul>
@@ -293,7 +306,14 @@
               />
             </nz-input-group>
             <ng-template #suffixIconclear>
-              <button nz-button nzType="primary" nzSearch (click)="reset('editObject')">清空</button>
+              <button
+                nz-button
+                nzType="primary"
+                nzSearch
+                (click)="reset('editObject')"
+              >
+                清空
+              </button>
             </ng-template>
           </div>
         </div>
@@ -351,7 +371,7 @@
   <ng-container *nzModalContent>
     <div nz-row class="depart-modal">
       <div nz-col nzSpan="12">
-        <div class="row" style="margin-bottom: 6px;">
+        <div class="row" style="margin-bottom: 6px">
           <div class="label">
             选择所属部门 <span style="color: #e8353e">*</span>
           </div>
@@ -367,7 +387,14 @@
               />
             </nz-input-group>
             <ng-template #suffixIconclear>
-              <button nz-button nzType="primary" nzSearch (click)="reset('account')">清空</button>
+              <button
+                nz-button
+                nzType="primary"
+                nzSearch
+                (click)="reset('account')"
+              >
+                清空
+              </button>
             </ng-template>
           </div>
         </div>
@@ -477,7 +504,6 @@
             </ng-template> -->
           </div>
         </div>
-     
       </div>
     </div>
   </ng-container>
@@ -495,6 +521,130 @@
   </div>
 </nz-modal>
 
+<nz-modal
+  [(nzVisible)]="profileVisible"
+  nzTitle="变更部门"
+  (nzOnCancel)="handleCancel()"
+  nzWidth="400px"
+  nzCentered
+>
+  <ng-container *nzModalContent>
+    <div nz-row class="depart-modal">
+      <div nz-col nzSpan="24">
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div style="color: rgb(0 0 0 / 36%)">
+            把{{
+              profileAccount?.get("user")?.get("name") ||
+                profileAccount?.get("user")?.get("phone") ||
+                profileAccount?.get("email") ||
+                profileAccount?.get("user")?.get("username")
+            }}的所属部门变更为
+          </div>
+        </div>
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div class="label">
+            选择更换的所属部门 <span style="color: #e8353e">*</span>
+          </div>
+          <div class="value">
+            <nz-input-group nzSearch [nzAddOnAfter]="suffixIconclear">
+              <input
+                nz-input
+                placeholder="请选择所属部门"
+                [(ngModel)]="modalValue"
+                (ngModelChange)="onSearchNodes($event, true)"
+                type="text"
+                (blur)="onblur('profileEdit')"
+              />
+            </nz-input-group>
+            <ng-template #suffixIconclear>
+              <button
+                nz-button
+                nzType="primary"
+                nzSearch
+                (click)="reset('profileEdit')"
+              >
+                清空
+              </button>
+            </ng-template>
+          </div>
+        </div>
+        <div class="select" style="width: 100%">
+          <div class="bar">
+            <a style="color: #86909c" (click)="onPre()">所有部门</a>
+            @for (data of parentMap; track data.title) {
+            <span style="margin: 0 10px">/</span>
+            <a (click)="onPre(data, $index)">{{ data.title }}</a>
+            }
+          </div>
+          <div class="tree">
+            @if(parentList.length > 0){ @for (data of parentList; track $index)
+            {
+            <div class="li" (click)="onCheckedDepart('profileEdit', data)">
+              <label
+                nz-radio
+                [ngModel]="data.key == radio"
+                [nzValue]="data.key"
+                (click)="onCheckedDepart('profileEdit', data, data?.branch)"
+                >{{ data.title }}</label
+              >
+              @if (!data.isLeaf) {
+              <span nz-icon nzType="right" nzTheme="outline"></span>
+              }
+            </div>
+            }}@else {
+            <nz-empty nzNotFoundContent="暂无下级部门"></nz-empty>
+            }
+          </div>
+        </div>
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div class="label">人员类型</div>
+          <div class="value">
+            <nz-select
+              style="width: 100%"
+              [disabled]="!this.profileEdit.department?.id"
+              nzShowSearch
+              nzAllowClear
+              [(ngModel)]="profileEdit.identity"
+              nzPlaceHolder="请选择所属的身份类型"
+            >
+              @for(item of userType; track item;let index = $index){
+              <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
+                item
+              }}</nz-option>
+              }
+            </nz-select>
+          </div>
+        </div>
+        @if (profileAccount?.get('identity') == '工作联系人') {
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div class="warning">
+            <span
+              nz-icon
+              color="#3e49b3"
+              nzType="info-circle"
+              nzTheme="outline"
+            ></span
+            >该用户已被设置工作联系人,变更部门后,你需要重新设置该部门的工作联系人
+          </div>
+        </div>
+        }
+      </div>
+    </div>
+  </ng-container>
+  <div *nzModalFooter>
+    <button nz-button nzType="default" (click)="handleCancel()">取消</button>
+    <button
+      nz-button
+      nzType="primary"
+      style="background: #3e49b3; border: 1px #3e49b3"
+      [nzLoading]="isLoadingOne"
+      (click)="updateProfile()"
+    >
+      确定
+    </button>
+  </div>
+</nz-modal>
+
 <!-- 全选操作:批量操作 -->
 <div class="batch-toolbar-modal" *ngIf="setOfCheckedId.size">
   <div class="batch-toolbar">
@@ -505,9 +655,9 @@
     <div class="batch-toolbar-actions">
       <div class="ant-space ant-space-horizontal ant-space-align-center">
         <div class="ant-space-item" style="margin-right: 16px">
-          <button nz-button nzType="text" (click)="removeBranchAll()">
+          <button nz-button nzType="text" (click)="deleteSelected()">
             <span nz-icon nzType="delete"></span>
-            移除部门
+            批量删除
           </button>
         </div>
       </div>

+ 5 - 0
projects/textbook/src/modules/nav-admin/page-role/page-role.component.scss

@@ -87,6 +87,11 @@
   .row{
     width: 90%;
     margin-bottom: 26px;
+    .warning{
+      padding: 10px;
+      background: #eceef7;
+      border-radius: 4px;
+    }
   }
   .select{
     width: 90%;

+ 314 - 126
projects/textbook/src/modules/nav-admin/page-role/page-role.component.ts

@@ -60,7 +60,7 @@ interface depart {
     NzModalModule,
     NzRadioModule,
     NzSelectModule,
-    NzSpinModule
+    NzSpinModule,
   ],
   standalone: true,
 })
@@ -86,7 +86,7 @@ export class PageRoleComponent implements OnInit {
   loading = false;
   pageSize: number = 10;
   pageIndex: number = 1;
-  profileLength:number = 0
+  profileLength: number = 0;
 
   isVisible: boolean = false;
   activatedNode: NzTreeNode | any; //当前选择节点
@@ -116,8 +116,18 @@ export class PageRoleComponent implements OnInit {
   };
   userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '教师'];
   parents: Array<any> = []; //所有一级列表
-  nzExpandedKeys:any = [] //默认展开节点数
-  modalValue:string = ''
+  nzExpandedKeys: any = []; //默认展开节点数
+  modalValue: string = '';
+  childrenList: Array<string> = [];
+
+  profileVisible: boolean = false; //用户部门变更
+  profileAccount: Parse.Object | undefined; //变更部门用户
+  profileEdit: any = {
+    //变更部门用户json
+    department: {},
+    companyType: '',
+    identity: '',
+  };
   constructor(
     private route: Router,
     private activeRoute: ActivatedRoute,
@@ -138,15 +148,17 @@ export class PageRoleComponent implements OnInit {
   }
   ngOnInit(): void {
     this.activeRoute.paramMap.subscribe(async (params) => {
-      let nodes:Array<any> = await this.getDepart();
-      this.parents = [...nodes]
-      Promise.all(nodes.map(async (item,index)=>{
-        nodes[index].children = await this.getDepart(item.key);
-        // nodes[index]['isExpanded'] = true
-        this.nzExpandedKeys.push(nodes[index]?.key)
-      })).then(()=>{
-        this.nodes = nodes
-      })
+      let nodes: Array<any> = await this.getDepart();
+      this.parents = [...nodes];
+      Promise.all(
+        nodes.map(async (item, index) => {
+          nodes[index].children = await this.getDepart(item.key);
+          // nodes[index]['isExpanded'] = true
+          this.nzExpandedKeys.push(nodes[index]?.key);
+        })
+      ).then(() => {
+        this.nodes = nodes;
+      });
     });
   }
   async getDepart(
@@ -161,7 +173,7 @@ export class PageRoleComponent implements OnInit {
     }
     searchValue && query.contains('name', searchValue);
     query.notEqualTo('isDeleted', true);
-    query.select('code', 'name', 'branch', 'parent', 'type','hasChildren');
+    query.select('code', 'name', 'branch', 'parent', 'type', 'hasChildren');
     query.descending('createdAt');
     query.limit(2000);
     if (this.activeDepart) query.notEqualTo('objectId', this.activeDepart?.id);
@@ -174,7 +186,7 @@ export class PageRoleComponent implements OnInit {
         branch: item.get('branch'),
         parent: item.get('parent')?.id, //上级
         isLeaf: !item.get('hasChildren'), //是否是最下级
-        type: item.get('type')
+        type: item.get('type'),
       });
     });
     return nodes;
@@ -188,23 +200,27 @@ export class PageRoleComponent implements OnInit {
     this.nodes = await this.getDepart('', e, e ? true : false);
   }
   //搜索失去焦点
-  onblur(type:string){
+  onblur(type: string) {
     console.log(type);
-    if(type == 'account'){
-      this.modalValue = this.account.department?.title
-    }else if(type == 'editObject'){
-      this.modalValue = this.editObject.parent?.title
+    if (type == 'account' || type == 'profileEdit') {
+      this.modalValue = this.account.department?.title;
+      this.modalValue = this.account.profileEdit?.title;
+    } else if (type == 'editObject') {
+      this.modalValue = this.editObject.parent?.title;
     }
   }
-  reset(type:string){
-    this.modalValue = ''
+  reset(type: string) {
+    this.modalValue = '';
     this.parentList = this.nodes;
-    this.parentMap = []
-    if(type == 'account'){
-      this.account.department = {}
-      this.account.identity = ''
-    }else if(type == 'editObject'){
-      this.editObject.parent = {}
+    this.parentMap = [];
+    if (type == 'account' || type == 'profileEdit') {
+      this.account.department = {};
+      this.account.identity = '';
+
+      this.account.profileEdit = {};
+      this.account.profileEdit = '';
+    } else if (type == 'editObject') {
+      this.editObject.parent = {};
     }
   }
   //展开/合并
@@ -223,7 +239,10 @@ export class PageRoleComponent implements OnInit {
       console.log(this.nodes);
     } else {
       // if (node.origin.isParent) {
+      this.loading = true;
+      this.pageIndex = 1;
       this.currentDepart = node.origin;
+      this.childrenList = await this.tbookSer.getChild(this.currentDepart.key);
       this.getProfile();
       // }
     }
@@ -231,9 +250,9 @@ export class PageRoleComponent implements OnInit {
   async getProfile() {
     this.profiles = [];
     this.loading = true;
-    let childrens = [this.currentDepart.key]
-    if(!this.checkedShowFilter){
-      childrens = await this.tbookSer.getChild(this.currentDepart.key)
+    let childrens = [this.currentDepart.key];
+    if (!this.checkedShowFilter) {
+      childrens = this.childrenList;
     }
     let queryParams = {
       where: {
@@ -259,13 +278,13 @@ export class PageRoleComponent implements OnInit {
     query.include('user');
     query.notEqualTo('identity', '国家级管理员');
     query.notEqualTo('isDeleted', true);
-    this.profileLength = await query.count()
-    query.limit(this.pageSize)
-    query.skip((this.pageIndex - 1) * this.pageSize)
+    this.profileLength = await query.count();
+    query.limit(this.pageSize);
+    query.skip((this.pageIndex - 1) * this.pageSize);
     let r = await query.find();
     this.profiles = r;
     this.loading = false;
-    this.resetChange()
+    this.resetChange();
   }
   //分页切换
   pageIndexChange(e: any) {
@@ -273,9 +292,9 @@ export class PageRoleComponent implements OnInit {
     this.pageIndex = e;
     this.getProfile();
   }
-  onChecked(){
+  onChecked() {
     this.pageIndex = 1;
-    this.getProfile()
+    this.getProfile();
   }
   //搜索触发
   onSearch(event: NzFormatEmitEvent) {
@@ -342,7 +361,7 @@ export class PageRoleComponent implements OnInit {
   //添加成员
   addMember() {
     this.radio = '';
-    this.modalValue = ''
+    this.modalValue = '';
     this.parentList = this.nodes;
     this.account = {
       name: '',
@@ -366,10 +385,10 @@ export class PageRoleComponent implements OnInit {
       branch: '',
     };
     this.radio = '';
-    this.modalValue = ''
+    this.modalValue = '';
     if (type == 'edit') {
       let query = new Parse.Query('Department');
-      query.include('parent','parent.parent')
+      query.include('parent', 'parent.parent');
       let r = await query.get(this.activatedNode?.key);
       this.activeDepart = r;
       this.editObject = {
@@ -382,24 +401,32 @@ export class PageRoleComponent implements OnInit {
         },
         branch: this.activeDepart.get('branch'),
       };
+      this.modalValue = this.activeDepart.get('parent')?.get('name');
+
       this.parentMap = await this.tbookSer.formatNode(
         this.activeDepart.get('parent')?.id
       );
       if (r?.get('parent')?.get('parent')?.id) {
-        this.parentList = await this.getDepart(r.get('parent')?.get('parent').id);
-      }else{
-        this.parentList = this.parents
+        this.parentList = await this.getDepart(
+          r.get('parent')?.get('parent').id
+        );
+      } else {
+        this.parentList = this.parents;
       }
-      this.radio = this.activeDepart.get('parent')?.id
+      this.radio = this.activeDepart.get('parent')?.id;
     } else if (type == 'add' && this.activatedNode) {
       this.editObject.parent = {
         title: this.activatedNode.origin.title,
         id: this.activatedNode.origin.key,
       };
-      this.radio = this.activatedNode.origin.key
+      this.radio = this.activatedNode.origin.key;
+      this.modalValue = this.activatedNode.origin.title;
+
       this.editObject.branch =
         this.activatedNode.origin.branch || this.activatedNode.origin.title;
-      this.parentMap = await this.tbookSer.formatNode(this.activatedNode.origin.key);
+      this.parentMap = await this.tbookSer.formatNode(
+        this.activatedNode.origin.key
+      );
       if (this.activatedNode?.origin.branch) {
         this.parentList = await this.getDepart(
           this.activatedNode?.origin.branch
@@ -425,10 +452,13 @@ export class PageRoleComponent implements OnInit {
   async onCheckedDepart(type: string, e: any, checked?: boolean) {
     console.log(e);
     this.radio = e.key;
-    if (type == 'account') this.account.identity = '';
+    if (type == 'account' || type == 'profileEdit') {
+      this.account.identity = '';
+      this.profileEdit.identity = '';
+    }
     this.parentMap = await this.tbookSer.formatNode(e.key);
     if (checked || e.isLeaf) {
-      this.pushValue(type,e)
+      this.pushValue(type, e);
       return;
     }
     if (e.isLeaf) {
@@ -437,16 +467,29 @@ export class PageRoleComponent implements OnInit {
     this.parentList = await this.getDepart(e?.key);
   }
   //赋值
-  pushValue(type:string, e: any){
-    this.modalValue = e.title
+  pushValue(type: string, e: any) {
+    this.modalValue = e.title;
+    this.radio = e.key;
     if (type == 'account' && e.parent) {
       this.account.department = { title: e.title, id: e.key };
       this.account.companyType = e.branch || e.title;
       this.userType = this.parents.some((item) => e.parent == item.key)
-      ? !e.type ? ['工作联系人'] : ['评审专家', '工作联系人', '教师']
-      : e.type == '单位'
-      ? ['评审专家', '高校联系人', '教师']
-      : ['评审专家', '教师'];
+        ? !e.type
+          ? ['工作联系人']
+          : ['评审专家', '工作联系人', '教师']
+        : e.type == '单位'
+        ? ['评审专家', '高校联系人', '教师']
+        : ['评审专家', '教师'];
+    } else if (type == 'profileEdit' && e.parent) {
+      this.profileEdit.department = { title: e.title, id: e.key };
+      this.profileEdit.companyType = e.branch || e.title;
+      this.userType = this.parents.some((item) => e.parent == item.key)
+        ? !e.type
+          ? ['工作联系人']
+          : ['评审专家', '工作联系人', '教师']
+        : e.type == '单位'
+        ? ['评审专家', '高校联系人', '教师']
+        : ['评审专家', '教师'];
     } else {
       this.editObject.parent = {
         title: e.title,
@@ -455,6 +498,7 @@ export class PageRoleComponent implements OnInit {
       this.editObject.branch = e.branch || e.title;
     }
   }
+  //保存编辑&新增部门
   async handleOk(): Promise<void> {
     if (!this.editObject?.name || !this.editObject.parent?.id) {
       this.message.error('请填写完整信息');
@@ -483,24 +527,24 @@ export class PageRoleComponent implements OnInit {
       });
       this.activeDepart?.set('branch', this.editObject.branch);
     }
-    let type
-    let filters = ['出版单位','教育部直属高校']
-    if(filters.includes(this.editObject.parent?.title)){
-      type = '单位'
+    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){
+    if (!type && this.activeDepart?.id) {
       //判断添加的是部门还是单位
-      let leng = await this.tbookSer.formatNode(this.activeDepart.id)
-      if(leng.length > 2){
+      let leng = await this.tbookSer.formatNode(this.activeDepart.id);
+      if (leng.length > 2) {
         console.log(leng.length);
-        if(filters.includes(leng[0].title)){
+        if (filters.includes(leng[0].title)) {
           this.activeDepart?.set('type', '部门');
-        }else{
-          this.activeDepart?.set('type',leng.length > 3 ? '部门' : '单位');
+        } else {
+          this.activeDepart?.set('type', leng.length > 3 ? '部门' : '单位');
         }
-        leng.slice()
+        leng.slice();
         await this.activeDepart?.save();
       }
     }
@@ -514,7 +558,7 @@ export class PageRoleComponent implements OnInit {
   async updateChildren() {
     let query = new Parse.Query('Department');
     query.equalTo('objectId', this.editObject.parent?.id);
-    query.select('hasChildren')
+    query.select('hasChildren');
     let r = await query.first();
     if (r?.id && !r.get('hasChildren')) {
       r?.set('hasChildren', true);
@@ -522,6 +566,44 @@ export class PageRoleComponent implements OnInit {
     }
     return;
   }
+  //变更用户部门
+  async showProfile(data: Parse.Object) {
+    let query = new Parse.Query('Department');
+    query.include('parent', 'parent.parent');
+    let r = await query.get(data?.get('user')?.get('department')?.id);
+    this.parentMap = await this.tbookSer.formatNode(
+      data?.get('user')?.get('department')?.id
+    );
+    if (r?.get('parent')?.id) {
+      this.parentList = await this.getDepart(r.get('parent').id);
+    } else {
+      this.parentList = this.parents;
+    }
+    this.radio = data?.get('user')?.get('department')?.id;
+    this.profileAccount = data;
+    this.profileEdit = {
+      //变更部门用户json
+      department: {
+        key: r?.id,
+        title: r?.get('title'),
+      },
+      companyType: data?.get('companyType'),
+      identity: data?.get('identity'),
+    };
+    let parms = {
+      title: r?.get('name'),
+      key: r?.id,
+      type: r?.get('type'),
+      parent: r?.get('parent')?.id,
+      branch: r?.get('branch'),
+    };
+    console.log(parms);
+
+    this.pushValue('profileEdit', parms);
+
+    this.modalValue = r?.get('name');
+    this.profileVisible = true;
+  }
   handleCancel(): void {
     console.log('Button cancel clicked!');
     this.isVisible = false;
@@ -529,7 +611,23 @@ export class PageRoleComponent implements OnInit {
     this.parentMap = [];
 
     this.accountIsVisible = false;
-    this.account = null;
+    this.account = {
+      name: '',
+      phone: '',
+      email: '',
+      password: '',
+      identity: '',
+      department: {},
+      companyType: '',
+    };
+    this.profileVisible = false;
+    this.profileAccount = undefined;
+    this.profileEdit = {
+      //变更部门用户json
+      department: {},
+      companyType: '',
+      identity: '',
+    };
   }
 
   /* 组织 */
@@ -541,25 +639,25 @@ export class PageRoleComponent implements OnInit {
   }
 
   randomPassword() {
-    this.account.password = this.tbookSer.randomPassword()
+    this.account.password = this.tbookSer.randomPassword();
     console.log(this.account.password);
   }
   /* 添加账号 */
-  isLoadingOne:boolean = false
-  async accountComplete(){
-    if(this.isLoadingOne) return
-    this.isLoadingOne = true
+  isLoadingOne: boolean = false;
+  async accountComplete() {
+    if (this.isLoadingOne) return;
+    this.isLoadingOne = true;
     this.account.email = this.account?.email.trim();
     this.account.phone = this.account?.phone.trim();
     this.account.name = this.account?.name.trim();
     this.account.password = this.account?.password.trim();
-    if(!await this.authVrifly()){
-      this.isLoadingOne = false
-      return
+    if (!(await this.authVrifly())) {
+      this.isLoadingOne = false;
+      return;
     }
-    try{
+    try {
       let obj = Parse.Object.extend('_User');
-      let user = new obj()
+      let user = new obj();
       user?.set('username', this.account?.email || this.account?.phone);
       user?.set('name', this.account?.name);
       user?.set('phone', this.account?.phone);
@@ -571,57 +669,103 @@ export class PageRoleComponent implements OnInit {
         className: 'Department',
         objectId: this.account.department?.id,
       });
-      let u = await user.save()
+      let u = await user.save();
       let p = Parse.Object.extend('Profile');
-      let profile = new p()
+      let profile = new p();
       profile?.set('user', u?.toPointer());
       profile?.set('companyType', this.account.companyType);
       profile?.set('email', this.account.email);
       profile?.set('identity', this.account.identity);
       let res = await profile?.save();
-      this.isLoadingOne = false
+      this.isLoadingOne = false;
       this.accountIsVisible = false;
       this.account = null;
-      Parse.Cloud.run('aliSmsSend',{
-        "mobileList": [this.account?.phone],"templateCode":"SMS_469060724","params":{},"signName":"普通高等教育教材网"
-      })
+      Parse.Cloud.run('aliSmsSend', {
+        mobileList: [this.account?.phone],
+        templateCode: 'SMS_469060724',
+        params: {},
+        signName: '普通高等教育教材网',
+      });
       this.modal.success({
         nzTitle: '添加成功',
         nzContent: '',
-        nzOnOk: () =>{
-          this.currentDepart && this.getProfile()
+        nzOnOk: () => {
+          this.currentDepart && this.getProfile();
         },
       });
+    } catch (err: any) {
+      console.warn('添加用户错误', err);
+      this.isLoadingOne = false;
+      this.message.error(
+        err?.Error || '错误:请检查用户邮箱或手机号是否已存在'
+      );
+      return;
     }
-    catch(err:any){
-      console.warn('添加用户错误',err);
-      this.isLoadingOne = false
-      this.message.error(err?.Error || '错误:请检查用户邮箱或手机号是否已存在');
+  }
+
+  //保存更新部门
+  async updateProfile() {
+    if (this.isLoadingOne) return;
+    this.isLoadingOne = true;
+    if (
+      !this.profileEdit?.department.id ||
+      !this.profileEdit?.department?.title ||
+      !this.profileEdit?.identity ||
+      !this.profileEdit.companyType
+    ) {
+      this.message.warning('填写信息不完整');
+      this.isLoadingOne = false;
       return;
     }
+    try {
+      this.profileAccount?.set('identity', this.profileEdit?.identity);
+      this.profileAccount?.set('companyType', this.profileEdit?.companyType);
+      await this.profileAccount?.save();
+      this.profileAccount?.get('user')?.set('department', {
+        __type: 'Pointer',
+        className: 'Department',
+        objectId: this.profileEdit?.department.id,
+      });
+      await this.profileAccount?.get('user')?.save();
+      this.pageIndex = 1;
+      this.getProfile();
+      this.isLoadingOne = false;
+      this.handleCancel()
+    } catch (err) {
+      console.log(err);
+      this.message.error('修改出错,请稍后重试');
+      this.isLoadingOne = false;
+    }
   }
-  async authVrifly():Promise< boolean | undefined>{
+
+  async authVrifly(): Promise<boolean | undefined> {
     this.account.email = this.account?.email.trim();
     this.account.phone = this.account?.phone.trim();
     this.account.name = this.account?.name.trim();
     this.account.password = this.account?.password.trim();
-    if(!this.account?.name|| !this.account.department?.id || !this.account.password
-      || !this.account.phone || !this.account?.email){
+    if (
+      !this.account?.name ||
+      !this.account.department?.id ||
+      !this.account.password ||
+      !this.account.phone ||
+      !this.account?.email
+    ) {
       this.message.warning('请填写必填项');
-      return
+      return;
     }
-    if(!this.account.identity){
-      this.message.error("请选择人员类型");
+    if (!this.account.identity) {
+      this.message.error('请选择人员类型');
       return;
     }
-    let a = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
-    if(this.account.phone && !String(this.account.phone).match(a)){
-      this.message.error("请填写正确手机号");
+    let a = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
+    if (this.account.phone && !String(this.account.phone).match(a)) {
+      this.message.error('请填写正确手机号');
       return;
     }
-    let m = /^(([^<>()[\]\\.,;:\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.account.email).match(m)){
-      this.message.error("邮箱格式有误");
+    let m =
+      /^(([^<>()[\]\\.,;:\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.account.email).match(m)) {
+      this.message.error('邮箱格式有误');
       return;
     }
     // if(!this.account?.email && !this.account?.phone){
@@ -629,32 +773,78 @@ export class PageRoleComponent implements OnInit {
     //   return;
     // }
     console.log(this.account.password);
-    if(!(this.account.password.length >= 6 && this.account.password.length <= 18)){
-      this.message.error('密码格式错误,请填写6-18位非空字符串(数字、大小写字母或英文符号)');
+    if (
+      !(this.account.password.length >= 6 && this.account.password.length <= 18)
+    ) {
+      this.message.error(
+        '密码格式错误,请填写6-18位非空字符串(数字、大小写字母或英文符号)'
+      );
       return;
     }
-    if(!await this.tbookSer.userFind(this.account.phone)){
+    if (!(await this.tbookSer.userFind(this.account.phone))) {
       this.message.error('手机号已存在');
-      return
+      return;
     }
-    return true
+    return true;
   }
 
-
   setOfCheckedId = new Set<string>();
   //移除部门
-  async removeBranch(data:Parse.Object){
-    if(data?.get('user')?.id){
-      data?.get('user')?.set('department',null)
-      await data?.get('user')?.save()
-      this.message.success("移除成功");
-      this.getProfile();
+  // async removeBranch(data: Parse.Object) {
+  //   if (data?.get('user')?.id) {
+  //     data?.get('user')?.set('department', null);
+  //     await data?.get('user')?.save();
+  //     this.message.success('移除成功');
+  //     this.getProfile();
+  //   }
+  // }
+  // removeBranchAll() {
+  //   this.modal.confirm({
+  //     nzTitle: '批量移除',
+  //     nzContent: `请谨慎操作`,
+  //     nzOkText: '确认',
+  //     nzOkType: 'primary',
+  //     nzOkDanger: true,
+  //     nzOnOk: async () => {
+  //       let selectedList = this.profiles.filter((item: any) =>
+  //         this.setOfCheckedId.has(item?.id)
+  //       );
+  //       let romovePromiseList = selectedList.map((item: any) => {
+  //         return new Promise(async (resolve) => {
+  //           item?.get('user')?.set('department', null);
+  //           await item?.get('user')?.save();
+  //           resolve(true);
+  //         });
+  //       });
+  //       try {
+  //         await Promise.all(romovePromiseList);
+  //         this.message.error('移除成功');
+  //         this.getProfile();
+  //         this.resetChange();
+  //       } catch (err) {}
+  //     },
+  //     nzCancelText: '取消',
+  //     nzOnCancel: () => console.log('Cancel'),
+  //   });
+  // }
+  //删除用户
+  async deleteSelected(data?: Parse.Object) {
+    let filters = [];
+    if (data?.id) {
+      filters = [data?.id];
+    } else {
+      filters = Array.from(this.setOfCheckedId);
     }
-  }
-  removeBranchAll(){
+    console.log(filters);
+
+    let v = await this.tbookSer.getEduProcessProf(filters);
     this.modal.confirm({
-      nzTitle: '批量移除',
-      nzContent: `请谨慎操作`,
+      nzTitle: `确认${data?.id ? '批量删除' : '删除该用户'}吗?`,
+      nzContent: `${
+        v
+          ? '该用户已经被设置为【流程名称】的工作联系人,删除后,你需要重新设置该流程的工作联系人'
+          : '该用户已经提交至申报流程中的教材不会被删除'
+      }`,
       nzOkText: '确认',
       nzOkType: 'primary',
       nzOkDanger: true,
@@ -662,27 +852,25 @@ export class PageRoleComponent implements OnInit {
         let selectedList = this.profiles.filter((item: any) =>
           this.setOfCheckedId.has(item?.id)
         );
-        let romovePromiseList = selectedList.map((item: any) => {
+        let deletePromiseList = selectedList.map((item: any) => {
           return new Promise(async (resolve) => {
-            item?.get('user')?.set('department',null)
-            await item?.get('user')?.save()
-            resolve(true)
+            await item.get('user')?.destroy();
+            await item.destroy();
+            resolve(true);
           });
         });
         try {
-          await Promise.all(romovePromiseList);
-          this.message.error("移除成功");
+          await Promise.all(deletePromiseList);
           this.getProfile();
-          this.resetChange()
+          this.resetChange();
         } catch (err) {}
       },
       nzCancelText: '取消',
       nzOnCancel: () => console.log('Cancel'),
     });
   }
-  resetChange(){
+  resetChange() {
     this.setOfCheckedId = new Set<string>();
     this.checkedAll = false;
   }
-
 }

+ 140 - 4
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.html

@@ -166,7 +166,7 @@
             <td
               nzLeft
               [nzChecked]="setOfCheckedId.has(data.id)"
-              (nzCheckedChange)="onItemChecked(data.objectId, $event)"
+              (nzCheckedChange)="onItemChecked(data.id, $event)"
             ></td>
             <td
               nzEllipsis
@@ -202,8 +202,13 @@
               <nz-dropdown-menu #menu="nzDropdownMenu">
                 <ul nz-menu>
                   <li nz-menu-item>
-                    <button nz-button style="color: #231c1f" nzType="link">
-                      <span nz-icon nzType="stop" nzTheme="outline"></span
+                    <button
+                      (click)="showProfile(data)"
+                      nz-button
+                      style="color: #231c1f"
+                      nzType="link"
+                    >
+                      <span nz-icon nzType="retweet" nzTheme="outline"></span
                       >更换部门
                     </button>
                   </li>
@@ -530,6 +535,137 @@
   </div>
 </nz-modal>
 
+<nz-modal
+  [(nzVisible)]="profileVisible"
+  nzTitle="变更部门"
+  (nzOnCancel)="handleCancel()"
+  nzWidth="400px"
+  nzCentered
+>
+  <ng-container *nzModalContent>
+    <div nz-row class="depart-modal">
+      <div nz-col nzSpan="24">
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div style="color: rgb(0 0 0 / 36%)">
+            把{{
+              profileAccount?.get("user")?.get("name") ||
+                profileAccount?.get("user")?.get("phone") ||
+                profileAccount?.get("email") ||
+                profileAccount?.get("user")?.get("username")
+            }}的所属部门变更为
+          </div>
+        </div>
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div class="label">
+            选择更换的所属部门 <span style="color: #e8353e">*</span>
+          </div>
+          <div class="value">
+            <nz-input-group nzSearch [nzAddOnAfter]="suffixIconclear">
+              <input
+                nz-input
+                placeholder="可输入搜索{{
+                  profileEdit.department?.title || nodes[0]?.title
+                }}下级所属部门"
+                [(ngModel)]="modalValue"
+                (ngModelChange)="
+                  onSearchNodes($event, true, profileEdit.department?.id)
+                "
+                type="text"
+                (blur)="onblur('profileEdit')"
+              />
+            </nz-input-group>
+            <ng-template #suffixIconclear>
+              <button
+                nz-button
+                nzType="primary"
+                nzSearch
+                (click)="reset('profileEdit')"
+              >
+                清空
+              </button>
+            </ng-template>
+          </div>
+        </div>
+        <div class="select" style="width: 100%">
+          <div class="bar">
+            <a style="color: #86909c">所有部门</a>
+            @for (data of parentMap; track data.title) {
+            <span style="margin: 0 10px">/</span>
+            @if ($index !=0 && data?.verify) {
+            <a (click)="onPre('profileEdit', data, $index)">{{ data.title }}</a>
+            }@else {
+            <a style="color: #86909c">{{ data.title }}</a>
+            } }
+          </div>
+          <div class="tree">
+            @if(parentList.length > 0){ @for (data of parentList; track $index)
+            {
+            <div class="li" (click)="onCheckedDepart('profileEdit', data)">
+              <label
+                nz-radio
+                [ngModel]="data.key == radio"
+                [nzValue]="data.key"
+                (click)="onCheckedDepart('profileEdit', data, true)"
+                >{{ data.title }}</label
+              >
+              @if (!data.isLeaf) {
+              <span nz-icon nzType="right" nzTheme="outline"></span>
+              }
+            </div>
+            }}@else {
+            <nz-empty nzNotFoundContent="暂无下级部门"></nz-empty>
+            }
+          </div>
+        </div>
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div class="label">人员类型</div>
+          <div class="value">
+            <nz-select
+              style="width: 100%"
+              [disabled]="!this.profileEdit.department?.id"
+              nzShowSearch
+              nzAllowClear
+              [(ngModel)]="profileEdit.identity"
+              nzPlaceHolder="请选择所属的身份类型"
+            >
+              @for(item of userType; track item;let index = $index){
+              <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
+                item
+              }}</nz-option>
+              }
+            </nz-select>
+          </div>
+        </div>
+        @if (profileAccount?.get('identity') == '工作联系人') {
+        <div class="row" style="margin-bottom: 6px; width: 100%">
+          <div class="warning">
+            <span
+              nz-icon
+              color="#3e49b3"
+              nzType="info-circle"
+              nzTheme="outline"
+            ></span
+            >该用户已被设置工作联系人,变更部门后,你需要重新设置该部门的工作联系人
+          </div>
+        </div>
+        }
+      </div>
+    </div>
+  </ng-container>
+  <div *nzModalFooter>
+    <button nz-button nzType="default" (click)="handleCancel()">取消</button>
+    <button
+      nz-button
+      nzType="primary"
+      style="background: #3e49b3; border: 1px #3e49b3"
+      [nzLoading]="isLoadingOne"
+      (click)="updateProfile()"
+    >
+      确定
+    </button>
+  </div>
+</nz-modal>
+
 <!-- 全选操作:批量操作 -->
 <div class="batch-toolbar-modal" *ngIf="setOfCheckedId?.size">
   <div class="batch-toolbar">
@@ -542,7 +678,7 @@
         <div class="ant-space-item" style="margin-right: 16px">
           <button nz-button nzType="text" (click)="deleteSelected()">
             <span nz-icon nzType="delete"></span>
-            删除
+            批量删除
           </button>
         </div>
       </div>

+ 187 - 49
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.ts

@@ -117,6 +117,14 @@ export class PageRoleComponent implements OnInit {
   parents: Array<any> = []; //所有一级列表
   setOfCheckedId = new Set<string>();
 
+  profileVisible: boolean = false; //用户部门变更
+  profileAccount: Parse.Object | undefined; //变更部门用户
+  profileEdit: any = {
+    //变更部门用户json
+    department: {},
+    companyType: '',
+    identity: '',
+  };
   constructor(
     public tbookSer: textbookServer,
     private route: Router,
@@ -214,9 +222,10 @@ export class PageRoleComponent implements OnInit {
   //搜索失去焦点
   onblur(type:string){
     console.log(type);
-    if(type == 'account'){
-      this.modalValue = this.account.department?.title
-    }else if(type == 'editObject'){
+    if (type == 'account' || type == 'profileEdit') {
+      this.modalValue = this.account.department?.title;
+      this.modalValue = this.account.profileEdit?.title;
+    } else if (type == 'editObject') {
       this.modalValue = this.editObject.parent?.title
     }
   }
@@ -224,15 +233,19 @@ export class PageRoleComponent implements OnInit {
     this.modalValue = ''
     this.parentList = this.nodes;
     this.parentMap = []
-    if(type == 'account'){
-      this.account.department = {}
-      this.account.identity = ''
+    if (type == 'account' || type == 'profileEdit') {
+      this.account.department = {};
+      this.account.identity = '';
+
+      this.account.profileEdit = {};
+      this.account.profileEdit = '';
     }else if(type == 'editObject'){
       this.editObject.parent = {}
     }
   }
   //添加成员
   addMember() {
+    this.modalValue = '';
     this.radio = ''
     this.parentList = this.nodes;
     this.account = {
@@ -261,6 +274,7 @@ export class PageRoleComponent implements OnInit {
       }
     } else {
       // if (node.origin.isParent) {
+      this.pageIndex = 1
       this.currentDepart = node.origin;
       this.getProfile();
       // }
@@ -412,6 +426,8 @@ export class PageRoleComponent implements OnInit {
         },
         branch: this.activeDepart.get('branch'),
       };
+      this.modalValue = this.activeDepart.get('parent')?.get('name');
+
       this.parentMap = await this.tbookSer.formatNode(
         this.activeDepart.get('parent')?.id
       );
@@ -420,12 +436,15 @@ export class PageRoleComponent implements OnInit {
           this.activatedNode?.parentNode?.origin?.parentNode?.origin.key
         );
       }
+      this.radio = this.activeDepart.get('parent')?.id;
     } else if (type == 'add' && this.activatedNode) {
       console.log(this.activatedNode);
       this.editObject.parent = {
         title: this.activatedNode.origin.title,
         id: this.activatedNode.origin.key,
       };
+      this.radio = this.activatedNode.origin.key;
+      this.modalValue = this.activatedNode.origin.title;
       this.editObject.branch =
         this.activatedNode.origin.branch || this.activatedNode.origin.title;
       this.parentMap = await this.tbookSer.formatNode(this.activatedNode.origin.key);
@@ -450,6 +469,9 @@ export class PageRoleComponent implements OnInit {
     // if(index == this.parentMap.length-1) return
     this.parentMap.splice((index || 0) + 1);
     this.radio = '';
+    if(type == 'profileEdit'){
+      this.profileEdit.identity = ''
+    }
     this.pushValue(type,this.parentMap[this.parentMap.length - 1])
     this.parentList = this.parentMap[this.parentMap.length - 1].key == this.tbookSer.profile.user.department?.objectId ? this.nodes : await this.getDepart(data?.parent);
   }
@@ -457,7 +479,10 @@ export class PageRoleComponent implements OnInit {
   async onCheckedDepart(type: string, e: any, checked?: boolean) {
     this.radio = '';
     console.log(e);
-    if (type == 'account') this.account.identity = '';
+    if (type == 'account' || type == 'profileEdit') {
+      this.account.identity = '';
+      this.profileEdit.identity = '';
+    }
     this.parentMap = await this.tbookSer.formatNode(e.key);
     let index = this.parentMap.findIndex(
       (item) => this.tbookSer.profile.user.department?.objectId == item.key
@@ -494,6 +519,16 @@ export class PageRoleComponent implements OnInit {
         ? ['评审专家', '高校联系人', '教师']
         : ['评审专家', '教师'];
       }
+    }else if (type == 'profileEdit' && e.parent) {
+      this.profileEdit.department = { title: e.title, id: e.key };
+      this.profileEdit.companyType = e.branch || e.title;
+      if(this.tbookSer.profile.identity == '工作联系人'){
+        this.userType = this.parents.some((item) => e.parent == item.id)
+        ? ['评审专家', '教师','高校联系人']
+        : e.type == '单位'
+        ? ['评审专家', '高校联系人', '教师']
+        : ['评审专家', '教师'];
+      }
     } else {
       this.editObject.parent = {
         title: e.title,
@@ -564,15 +599,81 @@ export class PageRoleComponent implements OnInit {
     }
     return;
   }
+
+  //变更用户部门
+  async showProfile(data: Parse.Object) {
+    let query = new Parse.Query('Department');
+    query.include('parent', 'parent.parent');
+    let r = await query.get(data?.get('user')?.get('department')?.id);
+    if(data?.get('user')?.get('department')?.id == this.tbookSer.profile.user.department?.objectId){
+      this.parentList = this.nodes;
+    }else{
+      this.parentList = await this.getDepart(r.get('parent').id);
+    }
+    this.parentMap = await this.tbookSer.formatNode(
+      data?.get('user')?.get('department')?.id
+    );
+    let index = this.parentMap.findIndex(
+      (item) => this.tbookSer.profile.user.department?.objectId == item.key
+    );
+    if (index != -1) {
+      this.parentMap.forEach((item, i) => {
+        if (i >= index) {
+          this.parentMap[i].verify = true;
+        }
+      });
+    }
+
+    this.radio = data?.get('user')?.get('department')?.id;
+    this.profileAccount = data;
+    this.profileEdit = {
+      //变更部门用户json
+      department: {
+        key: r?.id,
+        title: r?.get('title'),
+      },
+      companyType: data?.get('companyType'),
+      identity: data?.get('identity'),
+    };
+    let parms = {
+      title: r?.get('name'),
+      key: r?.id,
+      type: r?.get('type'),
+      parent: r?.get('parent')?.id,
+      branch: r?.get('branch'),
+    };
+    console.log(parms);
+    this.pushValue('profileEdit', parms);
+    this.modalValue = r?.get('name');
+    this.profileVisible = true;
+  }
+
   handleCancel(): void {
-    console.log('Button cancel clicked!');
+    console.log('关闭弹窗');
+    this.activeDepart = undefined;
     this.modalValue = ''
     this.isVisible = false;
     this.activatedNode = undefined;
     this.parentMap = [];
 
     this.accountIsVisible = false;
-    this.account = null;
+    this.account = {
+      name: '',
+      phone: '',
+      email: '',
+      password: '',
+      identity: '',
+      department: {},
+      companyType: '',
+    };
+    this.profileVisible = false;
+    this.profileAccount = undefined;
+    this.profileEdit = {
+      //变更部门用户json
+      department: {},
+      companyType: '',
+      identity: '',
+    };
   }
 
   /* 组织 */
@@ -681,54 +782,57 @@ export class PageRoleComponent implements OnInit {
   }
 
   //移除部门
-  async removeBranch(data: Parse.Object) {
-    if (data?.get('user')?.id) {
-      data?.get('user')?.set('department', null);
-      await data?.get('user')?.save();
-      this.message.error('移除成功');
-      this.getProfile();
-    }
-  }
-  removeBranchAll() {
-    this.modal.confirm({
-      nzTitle: '批量移除',
-      nzContent: `请谨慎操作`,
-      nzOkText: '确认',
-      nzOkType: 'primary',
-      nzOkDanger: true,
-      nzOnOk: async () => {
-        let selectedList = this.profiles.filter((item: any) =>
-          this.setOfCheckedId.has(item?.id)
-        );
-        let romovePromiseList = selectedList.map((item: any) => {
-          return new Promise(async (resolve) => {
-            item?.get('user')?.set('department', null);
-            await item?.get('user')?.save();
-            resolve(true);
-          });
-        });
-        try {
-          await Promise.all(romovePromiseList);
-          this.message.error('移除成功');
-          this.getProfile();
-          this.resetChange();
-        } catch (err) {}
-      },
-      nzCancelText: '取消',
-      nzOnCancel: () => console.log('Cancel'),
-    });
-  }
+  // async removeBranch(data: Parse.Object) {
+  //   if (data?.get('user')?.id) {
+  //     data?.get('user')?.set('department', null);
+  //     await data?.get('user')?.save();
+  //     this.message.error('移除成功');
+  //     this.getProfile();
+  //   }
+  // }
+  // removeBranchAll() {
+  //   this.modal.confirm({
+  //     nzTitle: '批量移除',
+  //     nzContent: `请谨慎操作`,
+  //     nzOkText: '确认',
+  //     nzOkType: 'primary',
+  //     nzOkDanger: true,
+  //     nzOnOk: async () => {
+  //       let selectedList = this.profiles.filter((item: any) =>
+  //         this.setOfCheckedId.has(item?.id)
+  //       );
+  //       let romovePromiseList = selectedList.map((item: any) => {
+  //         return new Promise(async (resolve) => {
+  //           item?.get('user')?.set('department', null);
+  //           await item?.get('user')?.save();
+  //           resolve(true);
+  //         });
+  //       });
+  //       try {
+  //         await Promise.all(romovePromiseList);
+  //         this.message.error('移除成功');
+  //         this.getProfile();
+  //         this.resetChange();
+  //       } catch (err) {}
+  //     },
+  //     nzCancelText: '取消',
+  //     nzOnCancel: () => console.log('Cancel'),
+  //   });
+  // }
   //删除用户
-  deleteSelected(data?:Parse.Object) {
+  async deleteSelected(data?:Parse.Object) {
     let filters = []
     if(data?.id){
       filters = [data?.id]
     }else{
       filters = Array.from(this.setOfCheckedId)
     }
+    console.log(filters);
+
+    let v = await this.tbookSer.getEduProcessProf(filters)
     this.modal.confirm({
-      nzTitle: '批量删除',
-      nzContent: `删除后数据不可恢复,请谨慎操作`,
+      nzTitle: `确认${data?.id ? '批量删除' : '删除该用户'}吗?`,
+      nzContent: `${v ? '该用户已经被设置为【流程名称】的工作联系人,删除后,你需要重新设置该流程的工作联系人' : '该用户已经提交至申报流程中的教材不会被删除'}`,
       nzOkText: '确认',
       nzOkType: 'primary',
       nzOkDanger: true,
@@ -754,6 +858,40 @@ export class PageRoleComponent implements OnInit {
       nzOnCancel: () => console.log('Cancel'),
     });
   }
+    //保存更新部门
+    async updateProfile() {
+      if (this.isLoadingOne) return;
+      this.isLoadingOne = true;
+      if (
+        !this.profileEdit?.department.id ||
+        !this.profileEdit?.department?.title ||
+        !this.profileEdit?.identity ||
+        !this.profileEdit.companyType
+      ) {
+        this.message.warning('填写信息不完整');
+        this.isLoadingOne = false;
+        return;
+      }
+      try {
+        this.profileAccount?.set('identity', this.profileEdit?.identity);
+        this.profileAccount?.set('companyType', this.profileEdit?.companyType);
+        await this.profileAccount?.save();
+        this.profileAccount?.get('user')?.set('department', {
+          __type: 'Pointer',
+          className: 'Department',
+          objectId: this.profileEdit?.department.id,
+        });
+        await this.profileAccount?.get('user')?.save();
+        this.pageIndex = 1;
+        this.getProfile();
+        this.isLoadingOne = false;
+        this.handleCancel()
+      } catch (err) {
+        console.log(err);
+        this.message.error('修改出错,请稍后重试');
+        this.isLoadingOne = false;
+      }
+    }
   resetChange() {
     this.setOfCheckedId = new Set<string>();
     this.checkedAll = false;

+ 13 - 0
projects/textbook/src/services/textbook.ts

@@ -215,4 +215,17 @@ export class textbookServer {
     let res = await query.first();
     return res?.id;
   }
+
+  //需要删除是否存在为联系人情况
+  async getEduProcessProf(filter:Array<string>):Promise<boolean>{
+    let query = new Parse.Query('EduProcess')
+    query.notEqualTo('isDeleted', true);
+    query.containedIn('profileSubmitted',filter)
+    query.select('objectId')
+    let res = await query.first();
+    if(res?.id){
+      return true
+    }
+    return false
+  }
 }