promotion.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { queenApi } from "queenjs";
  2. import { ResourceModule } from "..";
  3. export const promotionAction = ResourceModule.action({
  4. async renamePromotion(record: any) {
  5. const title = await queenApi.showInput({
  6. title: "请输入标题",
  7. defaultValue: record.title,
  8. });
  9. if (!title) return;
  10. await this.https.updatePromotion({ _id: record._id, title });
  11. record.title = title;
  12. },
  13. async publishPromotion(record: any, publish: boolean) {
  14. await this.https.publishPromotion(record._id, publish);
  15. record.published = publish;
  16. queenApi.messageSuccess("操作成功!");
  17. },
  18. async deletePromotion(record: any) {
  19. const res = await queenApi.showConfirm({
  20. content: `删除后无法恢复,确定要删除:${record.title}?`,
  21. type: "danger",
  22. });
  23. if (!res) return;
  24. await this.https.deletePromotion(record._id);
  25. // this.controls.promotionListCtrl.fresh();
  26. },
  27. async deleteCustomComp(record: any) {
  28. const res = await queenApi.showConfirm({
  29. content: `删除后无法恢复,确定要删除当前组合?`,
  30. type: "danger",
  31. });
  32. if (!res) return;
  33. await this.https.deleteComp(record._id);
  34. },
  35. async deleteUserComp(record: any, title: string) {
  36. const res = await queenApi.showConfirm({
  37. content: `删除后无法恢复,确定要删除当前${title}:${record.title}?`,
  38. type: "danger",
  39. });
  40. if (!res) return;
  41. await this.https.deleteComp(record._id);
  42. },
  43. async createPromotion() {
  44. const title = await queenApi.showInput({
  45. title: "请输入标题",
  46. });
  47. if (!title) return;
  48. const res = await this.https.createPromotion({ title });
  49. //console.log(location.host, location.host == "www.infish.cn");
  50. // if (location.host == "www.infish.cn") {
  51. // const url = `${location.origin}/projects/queenshowv1/editor.html#/?id=${res.result}`;
  52. // location.href = url;
  53. // return;
  54. // }
  55. const url = `${location.origin}/editor.html#/?id=${res.result}`;
  56. location.href = url;
  57. },
  58. async createComp() {
  59. const title = await queenApi.showInput({
  60. title: "请输入标题",
  61. });
  62. if (!title) return;
  63. const res = await this.https.createComp({ title });
  64. // console.log(location.host, location.host == "www.infish.cn");
  65. // if (location.host == "www.infish.cn") {
  66. // const url = `${location.origin}/projects/queenshowv1/editor.html#/?id=${res.result}&mode=editComp`;
  67. // location.href = url;
  68. // return;
  69. // }
  70. const url = `${location.origin}/editor.html#/?id=${res.result}&mode=editComp`;
  71. location.href = url;
  72. },
  73. async deleteComp(record: any) {
  74. const res = await queenApi.showConfirm({
  75. content: `删除后无法恢复,确定要删除:${record.title}?`,
  76. type: "danger",
  77. });
  78. if (!res) return;
  79. await this.https.deleteComp(record._id);
  80. // this.controls.promotionListCtrl.fresh();
  81. },
  82. async renameComp(record: any) {
  83. const title = await queenApi.showInput({
  84. title: "请输入标题",
  85. defaultValue: record.title,
  86. });
  87. if (!title) return;
  88. await this.https.updateComp({ _id: record._id, title });
  89. record.title = title;
  90. },
  91. });