promotion.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 createPromotion() {
  36. const title = await queenApi.showInput({
  37. title: "请输入标题",
  38. });
  39. if (!title) return;
  40. const res = await this.https.createPromotion({ title });
  41. //console.log(location.host, location.host == "www.infish.cn");
  42. // if (location.host == "www.infish.cn") {
  43. // const url = `${location.origin}/projects/queenshowv1/editor.html#/?id=${res.result}`;
  44. // location.href = url;
  45. // return;
  46. // }
  47. const url = `${location.origin}/editor.html#/?id=${res.result}`;
  48. location.href = url;
  49. },
  50. async createComp() {
  51. const title = await queenApi.showInput({
  52. title: "请输入标题",
  53. });
  54. if (!title) return;
  55. const res = await this.https.createComp({ title });
  56. // console.log(location.host, location.host == "www.infish.cn");
  57. // if (location.host == "www.infish.cn") {
  58. // const url = `${location.origin}/projects/queenshowv1/editor.html#/?id=${res.result}&mode=editComp`;
  59. // location.href = url;
  60. // return;
  61. // }
  62. const url = `${location.origin}/editor.html#/?id=${res.result}&mode=editComp`;
  63. location.href = url;
  64. },
  65. async deleteComp(record: any) {
  66. const res = await queenApi.showConfirm({
  67. content: `删除后无法恢复,确定要删除:${record.title}?`,
  68. type: "danger",
  69. });
  70. if (!res) return;
  71. await this.https.deleteComp(record._id);
  72. // this.controls.promotionListCtrl.fresh();
  73. },
  74. async renameComp(record: any) {
  75. const title = await queenApi.showInput({
  76. title: "请输入标题",
  77. defaultValue: record.title,
  78. });
  79. if (!title) return;
  80. await this.https.updateComp({ _id: record._id, title });
  81. record.title = title;
  82. },
  83. });