EduTextbook.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { MatDialog } from "@angular/material/dialog";
  2. import { Router } from "@angular/router";
  3. import Parse from "parse";
  4. import { ParseSchema } from "./func-parse";
  5. export const EduTextbook:ParseSchema = {
  6. title:"教材",
  7. className:"EduTextbook",
  8. emptyImg:"/img/webhook-empty.png",
  9. include:["user"],
  10. buttons:[
  11. // 仅在 /nav-author/manage/space 显示的编辑
  12. {
  13. name:"编辑",
  14. place:"item",
  15. show:(options:{object:Parse.Object})=>{
  16. if(location?.pathname=='/nav-author/manage/space' && !options.object.get('render')){
  17. return true
  18. }
  19. return false
  20. },
  21. handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
  22. options.router?.navigate(['/nav-author/manage/apply',{id:options.object.id}])
  23. }
  24. },
  25. {
  26. name:"提交材料",
  27. place:"item",
  28. show:(options:{object:Parse.Object})=>{
  29. if(location?.pathname=='/nav-author/manage/space' && !options.object.get('render')){
  30. return true
  31. }
  32. return false
  33. },
  34. handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router,modal:any})=>{
  35. options.modal?.confirm({
  36. nzTitle: '你确定提交吗?',
  37. nzContent: '<p>提交后不可撤回,你可以在已提交评审教材中查看</p>',
  38. nzOkText: '确认',
  39. nzOkType: 'primary',
  40. nzOkDanger: true,
  41. nzOnOk:async () => {
  42. options.object.set('render',true)
  43. await options.object.save()
  44. history.go(0)
  45. },
  46. nzCancelText: '取消',
  47. nzOnCancel: () => console.log('Cancel')
  48. });
  49. }
  50. },
  51. {
  52. name:"删除",
  53. place:"item",
  54. show:(options:{object:Parse.Object})=>{
  55. if(location?.pathname=='/nav-author/manage/space' && !options.object.get('render')){
  56. return true
  57. }
  58. return false
  59. },
  60. handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router,modal?:any})=>{
  61. options.modal?.confirm({
  62. nzTitle: '你确定删除吗?',
  63. nzContent: '<p>删除后你可以在回收站恢复</p>',
  64. nzOkText: '确认',
  65. nzOkType: 'primary',
  66. nzOkDanger: true,
  67. nzOnOk:async () => {
  68. options.object.set('discard',true)
  69. await options.object.save()
  70. history.go(0)
  71. },
  72. nzCancelText: '取消',
  73. nzOnCancel: () => console.log('Cancel')
  74. });
  75. }
  76. },
  77. {
  78. name:"恢复",
  79. place:"item",
  80. show:(options:{object:Parse.Object})=>{
  81. if(location?.pathname=='/nav-author/manage/recycle' && options.object.get('discard')){
  82. return true
  83. }
  84. return false
  85. },
  86. handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router,modal?:any})=>{
  87. options.modal?.confirm({
  88. nzTitle: '你确定恢复吗?',
  89. nzContent: '<p>恢复后你可以在个人空间中查看</p>',
  90. nzOkText: '确认',
  91. nzOkType: 'primary',
  92. nzOkDanger: true,
  93. nzOnOk:async () => {
  94. options.object.set('discard',false)
  95. await options.object.save()
  96. history.go(0)
  97. },
  98. nzCancelText: '取消',
  99. nzOnCancel: () => console.log('Cancel')
  100. });
  101. }
  102. },
  103. {
  104. name:"预览材料",
  105. place:"item",
  106. show:(options:{object:Parse.Object})=>{
  107. if((location?.pathname=='/nav-author/manage/space' && options.object.get('render')) || location?.pathname=='/nav-author/manage/recycle'){
  108. return true
  109. }
  110. return false
  111. },
  112. handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
  113. options.router?.navigate(['/nav-author/manage/dateils',{id:options.object.id}])
  114. }
  115. },
  116. ],
  117. fieldsArray:[
  118. {key:"title",name:"教材名称",type:"String",isHeader:true},
  119. {key:"typeNumber",name:"册数",type:"Number",isHeader:true},
  120. {key:"author",name:"第一主编 / 作者",type:"String",isHeader:true},
  121. {key:"major",name:"所属本科专业",type:"Object",isHeader:true,showName:"${name}"},
  122. {key:"lang",name:"主要语种类型",type:"String",isHeader:true},
  123. {key:"ISBN",name:"ISBN",type:"String",isHeader:true},
  124. {key:"user",name:"创建人",type:"Pointer",targetClass:"_User",isHeader:true,showName:"${mobile}"},
  125. ]
  126. }