Ver código fonte

优化查看

cehn 1 mês atrás
pai
commit
f1c4d78f98

+ 12 - 0
projects/textbook/src/modules/nav-admin/page-process/process-list/process-list.component.html

@@ -8,6 +8,18 @@
   </nz-page-header-title>
   <nz-page-header-extra>
     <nz-space>
+      @if (dev) {
+        <button
+          style="background: #107c41; border: 1px #107c41"
+          *nzSpaceItem
+          nz-button
+          nzType="primary"
+          (click)="tbookSer.getUnitList()"
+        >
+          出版社Excel
+        </button>
+      }
+
       <button
         style="background: #c6233f; border: 1px #c6233f"
         *nzSpaceItem

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

@@ -69,6 +69,7 @@ interface depart {
 export class ProcessListComponent implements OnInit {
   // @ViewChild(CompTableListComponent) list: CompTableListComponent | undefined;
   timeDefaultValue = setHours(new Date(), 0);
+  dev = localStorage.getItem('localdev')
 
   // _Role = _Role
   Department = Department;

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

@@ -41,7 +41,7 @@ export class PageTextbookComponent implements OnInit {
     showMore: true, //显示更多字段
     isCheck: false,
     status: ['400'],
-    btns: {review:true},
+    btns: {eduReivew:true},
   };
   active: number = 0;
 

+ 82 - 74
projects/textbook/src/services/textbook.ts

@@ -234,80 +234,88 @@ export class textbookServer {
     return false;
   }
 
-  /* 批量预设(临时) */
-  async saveProcess() {
-    let count = 0;
-    /* 批量关联流程管理员 */
-    // let queryEdupro = new Parse.Query('EduProcess')
-    // queryEdupro.select('department','name')
-    // queryEdupro.equalTo('profileSubmitted',null)
-    // queryEdupro.limit(1000)
-    // let res = await queryEdupro.find()
-    // console.log(res);
-    // for (let index = 0; index < res.length; index++) {
-    //   const item = res[index];
-    //   let queryParams: any = {
-    //     where: {
-    //       $or: [
-    //         {
-    //           user: {
-    //             $inQuery: {
-    //               where: {
-    //                "department":item?.get('department')?.id,
-    //                "accountState":'已认证',
-    //               },
-    //               className: '_User',
-    //             },
-    //           },
-    //         },
-    //       ],
-    //     },
-    //   };
-    //   let query = Parse.Query.fromJSON('Profile', queryParams);
-    //   query.equalTo('identity','工作联系人')
-    //   query.select('objectId')
-    //   let p = await query.first()
-    //   if(p?.id){
-    //     item.set('profileSubmitted',p.toPointer())
-    //     await item.save()
-    //     console.log('绑定成功'+p.id+':'+item?.get('name'));
-    //     count++
-    //   }
-    // }
-    // let arr = [];
-    // let query = new Parse.Query('EduTextbook');
-    // query.notEqualTo('isDeleted', true);
-    // query.notEqualTo('discard', true);
-    // query.equalTo('render', true);
-    // query.select(
-    //   'title',
-    //   'childrens.ISBN',
-    //   'childrens.author',
-    //   'childrens.editionUnit',
-    //   'inviteUnit'
-    // );
-    // query.limit(3000);
-    // query.containedIn('status', ['400']);
-    // let eduTextbook = await query.find();
-    // for (let index = 0; index < eduTextbook.length; index++) {
-    //   const item = eduTextbook[index];
-    //   let ISBN = '',
-    //     author = '',
-    //     editionUnit = '';
-    //   item?.get('childrens').forEach((children: any) => {
-    //     ISBN = children?.get('ISBN') + ' ' + ISBN;
-    //     author = children?.get('author') + ' ' + author;
-    //     editionUnit = children?.get('editionUnit') + ' ' + editionUnit;
-    //   });
-    //   arr.push({
-    //     教材名称: item?.get('title'),
-    //     ISBN: ISBN,
-    //     作者: author,
-    //     出版社: editionUnit,
-    //     所属院校: item?.get('inviteUnit'),
-    //   });
-    // }
-    // console.log(arr);
+  /* 获取已有联系人出版单位、未注册联系人出版单位 */
+  async getUnitList() {
+    let unitList = new Set<string>(); //单位出版社
+    let query = new Parse.Query('EduTextbook');
+    query.equalTo('status', '400');
+    query.notEqualTo('isDeleted', true);
+    query.notEqualTo('discard', true);
+    query.include('user.phone', 'childrens.editionUnit');
+    query.select('user.phone', 'childrens.editionUnit')
+    query.limit(1000);
+    let r = await query.find();
+    r.forEach((item) => {
+      item
+        .get('childrens')
+        ?.forEach((child: any) => unitList.add(child?.get('editionUnit')));
+    });
+    let unitArr = Array.from(unitList);
+    console.log('已被选择的申报单位:',unitArr);
+    let queryParams: any = {
+      where: {
+        $or: [
+          {
+            department: {
+              $inQuery: {
+                where: {
+                  name: { $in: unitArr },
+                },
+                className: 'Department',
+              }
+            },
+          },
+        ],
+      },
+    };
+    let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
+    queryEduProcess.include('profileSubmitted.user');
+    queryEduProcess.select('profileSubmitted.user.phone','name')
+    query.limit(1000)
+    let list = await queryEduProcess.find();
+    // console.log(list);
+    let unitPhoneList = new Set<string>(); //出版单位联系人
+    let notUnitPhoneList = new Set<string>(); //出版单位联系人
+    list.map(item=> {
+      if(item?.get('profileSubmitted')?.get('user')?.get('phone')){
+        // unitPhoneList.add(item?.get('profileSubmitted')?.get('user')?.get('phone'))
+        unitPhoneList.add(item?.get('name'))
+      }else{
+        notUnitPhoneList.add(item?.get('name'))
+      }
+    })
+    let a = Array.from(unitPhoneList), b = Array.from(notUnitPhoneList)
+    console.log('已注册联系:', Array.from(unitPhoneList));
+    console.log('未注册联系:',Array.from(notUnitPhoneList));
+    let len = a.length > b.length ? a.length : b.length
+     let table = `<table border="1px" cellspacing="0" cellpadding="0">
+          <thead>
+            <tr>
+              <th>已注册</th>
+              <th>未注册</th>
+            </tr>
+          </thead>
+          <tbody>
+          `;
+
+      let _body = '';
+      for (var row = 0; row < len; row++) {
+        _body += '<tr>';
+        _body += '<td>';
+        _body += `${a[row] || ''}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += ` &nbsp;${b[row] || ''}`;
+        _body += '</td>';
+
+        _body += '</tr>';
+      }
+      table += _body;
+      table += '</tbody>';
+      table += '</table>';
+      let title = '出版社';
+      this.excel(table, `${title}.xls`);
   }
   /* 格式化拓展表字段 */
   fromatFiled(list: Array<Parse.Object>, filed: string): string {