Jelajahi Sumber

附件预览

warrior 3 bulan lalu
induk
melakukan
a0d26d5b02

+ 46 - 9
projects/textbook/src/modules/nav-province-contact/components/upload-collect/upload-collect.component.ts

@@ -111,21 +111,58 @@ export class UploadCollectComponent implements OnInit {
     return true;
   }
 
-  async openUrl(url: string, isFile?:boolean) {
-    let path = window.location
+  async openUrl(url: string, isFile?: boolean) {
+    let path = window.location;
     if (
-      isFile && ((this.eduTextbookVolume?.get('editionUnit') ===
-      this.tbookSer.profile?.user?.department?.name)
-      ||
-      (path.pathname.indexOf(`/external/review/detail/${this.eduTextbookVolume?.get('eduTextbook')?.id}`) != -1
-      && Parse.User.current()?.get('username') === '145review'))
+      isFile &&
+      (this.eduTextbookVolume?.get('editionUnit') ===
+        this.tbookSer.profile?.user?.department?.name ||
+        (path.pathname.indexOf(
+          `/external/review/detail/${
+            this.eduTextbookVolume?.get('eduTextbook')?.id
+          }`
+        ) != -1 &&
+          Parse.User.current()?.get('username') === '145review' &&
+          (await this.authVerifly())))
     ) {
-      url = await this.ossProvider?.signatureUrl(url,{expires:180});
+      url = await this.ossProvider?.signatureUrl(url, { expires: 180 });
       this.modal.warning({
         nzTitle: '提示',
-        nzContent: '教材文件临时链接已打开,请勿外泄。'
+        nzContent: '教材文件临时链接已打开,请勿外泄。',
       });
     }
     window.open(url);
   }
+  authVerifly(): Promise<boolean> {
+    const currentUrl = window.location.href;
+    return new Promise((resolve) => {
+      fetch(
+        'https://audit.hep.com.cn/common-shenhe-api/api/public/index/search/bookPath_cache_check',
+        {
+          method: 'POST',
+          headers: {
+            'Content-Type': 'application/json',
+          },
+          body: JSON.stringify({ path: currentUrl }),
+        }
+      )
+        .then((response) => response.json())
+        .then((data) => {
+          console.log(data.data);
+          if (data.data.rs == 0) {
+            resolve(false);
+            window.location.href =
+              'https://audit.hep.com.cn/admin/401?noGoBack=0';
+          } else {
+            resolve(true);
+          }
+        })
+        .catch((error) => {
+          resolve(false);
+          console.error('Error:', error);
+          window.location.href =
+            'https://audit.hep.com.cn/admin/401?noGoBack=0';
+        });
+    });
+  }
 }

+ 86 - 11
projects/textbook/src/services/shell.ts

@@ -143,7 +143,7 @@ export class shellServer {
       `;
 
     let _body = '';
-    for (var row = 0; row < r.length; row++) {
+    for (let row = 0; row < r.length; row++) {
       _body += '<tr>';
       _body += '<td>';
       _body += `&nbsp;${r[row]?.get('user')?.get('phone') || ''}`;
@@ -233,7 +233,7 @@ export class shellServer {
     //       `;
 
     //   let _body = '';
-    //   for (var row = 0; row < len; row++) {
+    //   for (let row = 0; row < len; row++) {
     //     _body += '<tr>';
     //     _body += '<td>';
     //     _body += `${a[row] || ''}`;
@@ -299,7 +299,7 @@ export class shellServer {
         `;
 
     let _body = '';
-    for (var row = 0; row < data.length; row++) {
+    for (let row = 0; row < data.length; row++) {
       _body += '<tr>';
       _body += '<td>';
       _body += `${data[row]?.get('title') || ''}`;
@@ -384,8 +384,8 @@ export class shellServer {
                 $inQuery: {
                   where: {
                     // editionUnit: unitName,
-                    collectStatus: { $ne: '200' },
-                    // collectStatus: '200',
+                    // collectStatus: { $ne: '200' },
+                    collectStatus: '200',
                   },
                   className: 'EduTextbookVolume',
                 },
@@ -414,6 +414,12 @@ export class shellServer {
         'childrens.editionNumber',
         'childrens.printSum',
         'childrens.importantProject',
+
+        'childrens.collectFiles',
+        'childrens.collectLink',
+        'childrens.collectDigitFiles',
+        'childrens.collectCheck',
+
         'user.department',
         'department.branch',
         'code',
@@ -434,7 +440,7 @@ export class shellServer {
       query.ascending('createdAt');
       let count = await query.count();
       console.log(count);
-      query.limit(100);
+      query.limit(10000);
       query.skip(0);
       let data = await query.find();
       let table = `<table border="1px" cellspacing="0" cellpadding="0">
@@ -464,6 +470,12 @@ export class shellServer {
             <th>适用专业代码(六位)及名称</th>
             <th>申报状态</th>
             <th>源文件状态</th>
+
+            <th>纸质教材PDF名称</th>
+            <th>数字教材链接</th>
+            <th>链接和账号密码</th>
+            <th>数字教材文件名称</th>
+
           </tr>
         </thead>
         <tbody>
@@ -482,7 +494,7 @@ export class shellServer {
       // <tbody>
       // `;
       let _body = '';
-      for (var row = 0; row < data.length; row++) {
+      for (let row = 0; row < data.length; row++) {
         // console.log(data[row]?.get('user')?.get('department'));
         let inviteUnit = data[row]?.get('inviteUnit');
         if (
@@ -525,8 +537,8 @@ export class shellServer {
         _body += '</td>';
 
         _body += '<td>';
-        // _body += `&nbsp;${data[row]?.get('inviteUnit') || ''}`;
-        _body += `&nbsp;${inviteUnit || ''}`;
+        _body += `&nbsp;${data[row]?.get('inviteUnit') || ''}`;
+        // _body += `&nbsp;${inviteUnit || ''}`;
         _body += '</td>';
 
         _body += '<td>';
@@ -641,7 +653,35 @@ export class shellServer {
         _body += `已报送`;
         _body += '</td>';
         _body += '<td>';
-        _body += `待上传`;
+        _body += `已上传`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${this.fromatFiledCollect(
+          data[row]?.get('childrens')
+        )}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${this.fromatFiledCollect(
+          data[row]?.get('childrens'),
+          '链接'
+        )}`;
+        _body += '</td>';
+
+
+        _body += '<td>';
+        _body += `${this.fromatFiledCollect(
+          data[row]?.get('childrens'),
+          '链接和账号密码'
+        )}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${this.fromatFiledCollect(
+          data[row]?.get('childrens'),
+          '上传文件'
+        )}`;
         _body += '</td>';
 
         _body += '</tr>';
@@ -655,6 +695,41 @@ export class shellServer {
       console.log(err);
     }
   }
+
+  /* 格式化拓展表字段教材文件 */
+  fromatFiledCollect(list: Array<Parse.Object>, radioValue?: string): string {
+    let arr: Array<string | null> = [];
+    // 监测空值
+    list?.forEach((item: Parse.Object) => {
+      if(radioValue){
+        switch (radioValue) {
+          case '链接':
+            item.get('collectCheck') == '链接' && arr.push('链接:' + item.get('collectLink').url);
+            break;
+          case '链接和账号密码':
+            item.get('collectCheck') == '链接和账号密码' && arr.push(`链接:lian${item.get('collectLink').url}
+            账号:lian${item.get('collectLink').username}
+            密码:lian${item.get('collectLink').password}
+            `);
+            break;
+          default:
+            if(item.get('collectCheck') == '上传文件'){
+              let list:Array<string> = []
+              item.get('collectDigitFiles')?.forEach((i:any)=>list.push(i.name))
+              arr.push(...list);
+            }
+            break;
+        }
+      }else{
+        let list:Array<string> = []
+        item.get('collectFiles')?.forEach((i:any)=>list.push(i.name))
+        arr.push(...list);
+      }
+    });
+    let j = Array.from(arr).join(',');
+    return j || '-';
+  }
+
   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'>";
@@ -858,7 +933,7 @@ export class shellServer {
         <tbody>
         `;
     let _body = '';
-    for (var row = 0; row < data.length; row++) {
+    for (let row = 0; row < data.length; row++) {
       _body += '<tr>';
 
       _body += '<td>';