|
@@ -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 += ` ${data[row].get('code') || ''}`;
|
|
|
+ // _body += '</td>';
|
|
|
+
|
|
|
+ _body += '<td>';
|
|
|
+ _body += ` ${data[row].get('title') || '-'}`;
|
|
|
+ _body += '</td>';
|
|
|
+
|
|
|
+ // _body += '<td>';
|
|
|
+ // _body += ` ${(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 += ` ${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 += ` ${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);
|
|
|
}
|
|
|
|
|
|
/* 获取所有未上传签名页附件教材 */
|