Ver Fonte

优化教材列表筛选

cehn há 7 meses atrás
pai
commit
9f91d5cadd

+ 1 - 1
projects/textbook/src/app/textbook/textbook.component.html

@@ -63,7 +63,7 @@
         <th
           nzEllipsis
           nzWidth="180px"
-          [nzShowFilter]="true"
+          [nzShowFilter]="false"
           [nzFilters]="listOfColumns.majorPoniter.listOfFilter"
           (nzFilterChange)="listOfColumns.majorPoniter.onChange($event)"
         >

+ 58 - 30
projects/textbook/src/app/textbook/textbook.component.ts

@@ -146,12 +146,12 @@ export class TextbookComponent implements OnInit {
   };
   //筛选条件
   filters: filter | any = {
-    lang: { type: 'string', value: [] },
-    majorPoniter: { type: 'string', value: [] },
-    editionUnit: { type: 'string', value: [] },
-    approval: { type: 'string', value: [] },
-    carrierShape: { type: 'string', value: [] },
-    department: { type: 'pointer', value: [] },
+    lang: { type: 'EduTextbookVolume', value: [] },
+    majorPoniter: { type: 'EduTextbookVolume', value: [] },
+    editionUnit: { type: 'EduTextbookVolume', value: [] },
+    approval: { type: 'EduTextbook', value: [] },
+    carrierShape: { type: 'EduTextbookVolume', value: [] },
+    department: { type: 'EduTextbook', value: [] },
   };
   loading: boolean = false;
   checkedAll: boolean = false; //全选
@@ -197,31 +197,63 @@ export class TextbookComponent implements OnInit {
     this.loading = true;
     // let query = new Parse.Query('EduTextbook');
     // if (val) {
-    let query1 = Parse.Query.fromJSON('EduTextbook', {
+    let queryParams:any = {
       where: {
         $or: [
           {
             title: { $regex: `.*${val || ''}.*` },
           },
           {
-            ISBN: { $regex: `.*${val || ''}.*` },
-          },
-          {
-            author: { $regex: `.*${val || ''}.*` },
-          },
+            childrens: {
+              $inQuery: {
+                where: {
+                  "$or": [
+                    {
+                      ISBN: { $regex: `.*${val || ''}.*` },
+                    },
+                    {
+                      author: { $regex: `.*${val || ''}.*` },
+                    },
+                  ]
+                },
+                className: 'EduTextbookVolume',
+              },
+            },
+          }
         ],
       },
-    });
-    // let query2 = Parse.Query.fromJSON('EduTextbook', {
-    //   where: {
-    //     $or: [
-    //       {
-    //         ISBN: { $regex: `.*${val || ''}.*` },
-    //       },
-    //     ],
-    //   },
-    // });
+    }
+    let query1 = Parse.Query.fromJSON('EduTextbook', queryParams);
     let query = Parse.Query.or(query1);
+    let queryParams2:any = {
+      where: {}
+    }
+    for (const key in this.filters) {
+      const element = this.filters[key];
+      if (element.value?.length > 0 && element.type == 'EduTextbookVolume') {
+        if(!queryParams2['where']['childrens']){
+          queryParams2['where']['childrens']= {
+            '$inQuery':{
+              'where': {
+                // '$or':[
+                  [key]: { $in: element.value }
+                // ]
+              },
+              className: 'EduTextbookVolume',
+            }
+          }
+        }else{
+          queryParams2['where']['childrens']['$inQuery']['where'][key] = { $in: element.value }
+        }
+      }else if(element.value?.length > 0 && element.type == 'EduTextbook'){
+          queryParams2['where'][key] = { $in: element.value }
+      }
+      // query.containedIn(key, element.value);
+    }
+    let vrifly = Object.keys(queryParams2['where']).some(item=> Object.values(item).length > 0)
+    if(vrifly){
+      query = Parse.Query.and(Parse.Query.fromJSON('EduTextbook', queryParams2), query);
+    }
     if (this.filterObj.team) {
       let childrens = await this.tbookSer.getChild(
         this.tbookSer.profile.user.department?.objectId
@@ -242,14 +274,10 @@ export class TextbookComponent implements OnInit {
           ],
         },
       });
-      query = Parse.Query.and(query3, Parse.Query.or(query1));
-    }
-    // }
-    // this.uid && query.equalTo('user',this.tbookSer.profile.user?.objectId);
-    for (const key in this.filters) {
-      const element = this.filters[key];
-      if (element.value?.length > 0) {
-        query.containedIn(key, element.value);
+      if(vrifly){
+        query = Parse.Query.and(query3, Parse.Query.fromJSON('EduTextbook', queryParams2), query);
+      }else{
+        query = Parse.Query.and(query3, query);
       }
     }
     this.eduProcess?.id && query.equalTo('eduProcess', this.eduProcess.id);

+ 46 - 19
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.ts

@@ -151,25 +151,52 @@ export class UserEditComponent implements OnInit {
       this.message.warning('同级身份暂无权限操作');
       return;
     }
-    switch (type) {
-      case '已认证':
-        this.user.set('accountState', '已认证');
-        Parse.Cloud.run('aliSmsSend', {
-          mobileList: [this.user?.get('phone')],
-          templateCode: 'SMS_468870790',
-          params: {},
-          signName: '普通高等教育教材网',
-        });
-        break;
-      case '已禁用':
-        this.user.set('accountState', '已禁用');
-        break;
-      case '删除':
-        this.user.set('isDeleted', true);
-        break;
-    }
-    await this.user.save();
-    this.ngOnInit();
+    this.modal.confirm({
+      nzTitle: '操作提示',
+      nzContent: `确定${type}吗?`,
+      nzOkText: '确认',
+      nzOkType: 'primary',
+      nzOkDanger: type == '删除' ? true : false,
+      nzOnOk: async () => {
+        switch (type) {
+          case '已认证':
+            if (!this.user?.get('department')?.id) {
+              this.message.warning('该用户暂未绑定所属单位');
+              return;
+            }
+            if (this.profile?.get('identity') == '工作联系人') {
+              let auth = await this.tbookSer.updateProfileSubmitted(
+                this.profile?.id,
+                'save',
+                this.user.get('department').id,
+                this.message
+              );
+              if (!auth) return;
+            }
+            this.user.set('accountState', '已认证');
+            Parse.Cloud.run('aliSmsSend', {
+              mobileList: [this.user?.get('phone')],
+              templateCode: 'SMS_468870790',
+              params: {},
+              signName: '普通高等教育教材网',
+            });
+            await this.user.save();
+            break;
+          case '已禁用':
+            this.user.set('accountState', '已禁用');
+            await this.user.save();
+            break;
+          case '删除':
+            await this.profile.destroy();
+            await this.user.destroy();
+            this.goUserList()
+            break;
+        }
+        this.ngOnInit();
+      },
+      nzCancelText: '取消',
+      nzOnCancel: () => console.log('Cancel'),
+    });
   }
   async handleOk() {
     if (!this.edit) {