created.service.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Injectable } from '@angular/core';
  2. import Parse from 'parse';
  3. @Injectable({
  4. providedIn: 'root'
  5. })
  6. export class CreatedService {
  7. constructor() { }
  8. /** 册数*/
  9. typeNumber:any
  10. /** 申报类型*/
  11. type:any
  12. /**扩展表记录 */
  13. eduTextbookVolumeList: Array<any> = []
  14. /**获取扩展表记录 */
  15. async getEduTextbookVolumeList(eduTextbook:any) {
  16. console.log('服务获取扩展记录表')
  17. if (this.typeNumber && this.typeNumber > 12) {
  18. this.typeNumber = 12
  19. }
  20. console.log(this.type, this.typeNumber)
  21. let query = new Parse.Query('EduTextbookVolume')
  22. query.equalTo('eduTextbook', eduTextbook)
  23. query.select('objectId')
  24. query.ascending('createdAt')//小到大
  25. query.notEqualTo('isDeleted', true)
  26. if (this.type == '全册') {
  27. query.limit(this.typeNumber)
  28. } else {
  29. query.limit(1)
  30. }
  31. let list = await query.find()
  32. console.log(list)
  33. if (this.type == '全册') {
  34. this.eduTextbookVolumeList = new Array(this.typeNumber).fill({ objectId: '' })
  35. for (let i in list) {
  36. this.eduTextbookVolumeList[i] = list[i]
  37. }
  38. } else {
  39. this.eduTextbookVolumeList[0] = list[0]
  40. console.log(this.eduTextbookVolumeList)
  41. }
  42. }
  43. }