cehn il y a 6 mois
Parent
commit
fc1ebf44a3

+ 12 - 11
projects/textbook/src/modules/nav-author/components/attachment/attachment.component.ts

@@ -331,21 +331,22 @@ export class AttachmentComponent implements OnInit {
         className: 'Company',
         objectId: this.tbookSer.company,
       });
-      params.selfResults &&
-        this.eduTextbook?.set('selfResults', params.selfResults);
+      // params.selfResults &&
+        this.eduTextbook?.set('selfResults', params.selfResults || null);
       // params.unitMaterial &&
       //   this.eduTextbook?.set('unitMaterial', params.unitMaterial);
-      params.expertOpinion &&
-        this.eduTextbook?.set('expertOpinion', params.expertOpinion);
-      params.evidence && this.eduTextbook?.set('evidence', params.evidence);
-      params.cipProveFile &&
-        this.eduTextbook?.set('cipProveFile', params.cipProveFile);
-      params.moreMaterial &&
-        this.eduTextbook?.set('moreMaterial', params.moreMaterial);
+      // params.expertOpinion &&
+        this.eduTextbook?.set('expertOpinion', params.expertOpinion || null);
+      // params.evidence && 
+      this.eduTextbook?.set('evidence', params.evidence || null);
+      // params.cipProveFile &&
+        this.eduTextbook?.set('cipProveFile', params.cipProveFile || null);
+      // params.moreMaterial &&
+        this.eduTextbook?.set('moreMaterial', params.moreMaterial || null);
       // params.examine &&
       //   this.eduTextbook?.set('examine', params.examine);
-      this.eduTextbook?.set('copyrightImgUrl', params.copyrightImgUrl);
-      this.eduTextbook?.set('CIPImgUrl', params.CIPImgUrl);
+      this.eduTextbook?.set('copyrightImgUrl', params.copyrightImgUrl || null);
+      this.eduTextbook?.set('CIPImgUrl', params.CIPImgUrl || null);
       // this.eduTextbook?.set('authorList', params.authorList);
       await this.eduTextbook?.save();
       this.saveLoading = false;

+ 3 - 1
projects/textbook/src/modules/nav-author/components/create/author-file/author-file.component.ts

@@ -106,11 +106,13 @@ export class AuthorFileComponent implements OnInit {
     console.log(this.otherEditor);
   }
   async submitForm(): Promise<boolean> {
+    console.log(this.otherEditor);
+    
     let coursesVrifly = !this.authorList.some((item:any) =>
       Object.keys(item).some((key) => key != 'otherEditor' && (item[key] == '' || item[key] == undefined))
     );
     this.eduTextbookVolume?.set('authorList', this.authorList);
-    this.otherEditor && this.eduTextbookVolume?.set('otherEditor', this.otherEditor);
+    this.eduTextbookVolume?.set('otherEditor', this.otherEditor||null);
     await this.eduTextbookVolume?.save();
     return coursesVrifly;
   }

+ 171 - 12
projects/textbook/src/services/textbook.ts

@@ -274,18 +274,177 @@ export class textbookServer {
     //     count++
     //   }
     // }
-    // console.log(count);
-    // let query = new Parse.Query('EduProcess');
-    // query.limit(2000)
-    // query.select('deadline')
-    // let eduProcess = await query.find()
-    // for (let index = 0; index < eduProcess.length; index++) {
-    //   const item = eduProcess[index];
-    //   item?.set('deadline', new Date('2024-09-30 16:00'));
-    //   await item?.save()
-    //   count++
-    //   console.log(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'),
+      })
+      // item?.set('deadline', new Date('2024-09-30 16:00'));
+      // await item?.save()
+      // count++
+    }
+    console.log(arr);
+
+  }
+   /* 格式化拓展表字段 */
+   fromatFiled(list: Array<Parse.Object>, filed: string): string {
+    let arr: Array<string | null> = [];
+    let isDate = false;
+    // 监测空值
+    list?.forEach((item: Parse.Object) => {
+      // arr.add(item.get(filed))
+        arr.push(item.get(filed));
+    });
+    let j = Array.from(arr).join(',');
+    if (!isDate) {
+      j = Array.from(new Set(arr)).join(' ');
+    }
+    return j || '-';
+  }
+  //导出表格
+  async exportEduTextbook() {
+    try {
+      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','user.department','department.branch')
+      query.limit(3000)
+      query.containedIn('status',['103','200','201','400'])
+      // query.containedIn('status',['400'])
+      let data = await query.find()
+      let table = `<table border="1px" cellspacing="0" cellpadding="0">
+          <thead>
+            <tr>
+              <th>序号</th>
+              <th>申报教材名称</th>
+              <th>第一主编/作者</th>
+              <th>ISBN</th>
+              <th>出版单位</th>
+              <th>所属院校</th>
+            </tr>
+          </thead>
+          <tbody>
+          `;
+      let _body = '';
+      for (var row = 0; row < data.length; row++) {
+        // console.log(data[row].get('user')?.get('department'));
+        let inviteUnit = data[row]?.get('inviteUnit')
+        if (
+          data[row]?.get('department')?.get('branch') == '省级教育行政部门' ||
+          data[row]?.get('department')?.get('branch') == '有关部门(单位)教育司(局)'
+        ) {
+          let parentMap = await this.formatNode(
+            data[row].get('user')?.get('department')?.id
+          );
+          inviteUnit = parentMap[2]?.title
+        }
+        _body += '<tr>';
+        _body += '<td>';
+        _body += `${row + 1}`;
+        _body += '</td>';
+
+        // _body += '<td>';
+        // _body += `&nbsp;${data[row].get('code') || ''}`;
+        // _body += '</td>';
+
+        _body += '<td>';
+        _body += ` &nbsp;${data[row].get('title') || '-'}`;
+        _body += '</td>';
+
+        // _body += '<td>';
+        // _body += ` &nbsp;${(data[row].get("discipline")?.code || "") + '/' + (data[row]?.get("discipline")?.name || "")}`;
+        // _body += '</td>';
+
+        _body += '<td>';
+        _body += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `&nbsp;${this.fromatFiled(data[row]?.get('childrens'), 'ISBN')}`;
+        _body += '</td>';
+
+        // _body += '<td>';
+        // _body += `${
+        //   data[row]?.get('type') == '单本'
+        //     ? '单本'
+        //     : '全册 - ' + data[row]?.get('typeNumber') || '-'
+        // }`;
+        // _body += '</td>';
+
+        // _body += '<td>';
+        // _body += `${data[row]?.get('approval') || '-'}`;
+        // _body += '</td>';
+
+        _body += '<td>';
+        _body += `${this.fromatFiled(
+          data[row]?.get('childrens'),
+          'editionUnit'
+        )}`;
+        _body += '</td>';
+
+        // _body += '<td>';
+        // _body += `&nbsp;${this.fromatFiled(
+        //   data[row]?.get('childrens'),
+        //   'editionFirst'
+        // )}`;
+        // _body += '</td>';
+
+        _body += '<td>';
+        _body += `${inviteUnit}`;
+        _body += '</td>';
+
+        _body += '</tr>';
+      }
+      table += _body;
+      table += '</tbody>';
+      table += '</table>';
+      let title = '已提交教材';
+      this.excel(table, `${title}.xls`);
+    } catch (err) {
+      console.log(err);
+    }
+  }
+  excel(data: any, filename: string) {
+    let html =
+      "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
+    html +=
+      '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
+    html += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
+    html += '; charset=UTF-8">';
+    html += '<head>';
+    html += '</head>';
+    html += '<body>';
+    html += data;
+    html += '</body>';
+    html += '</html>';
+    let uri =
+      'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(html);
+    let link = document.createElement('a');
+    link.href = uri;
+    link.download = `${filename}`;
+    document.body.appendChild(link);
+    link.click();
+    document.body.removeChild(link);
   }
 
   /* 获取所有未上传签名页附件教材 */