promotion.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { queenApi } from "queenjs";
  2. import { ResourceModule } from "..";
  3. import { PromotionController } from "../controllers/PromotionController";
  4. import { PageListController } from "@queenjs/controllers";
  5. export const promotionAction = ResourceModule.action({
  6. async renamePromotion(record: any) {
  7. const title = await queenApi.showInput({
  8. title: "请输入标题",
  9. defaultValue: record.title,
  10. });
  11. if (!title) return;
  12. await this.https.updatePromotion({ _id: record._id, title });
  13. record.title = title;
  14. },
  15. async deletePromotion(record: any) {
  16. const res = await queenApi.showConfirm({
  17. content: `删除后无法恢复,确定要删除:${record.title}?`,
  18. type: "danger",
  19. });
  20. if (!res) return;
  21. await this.https.deletePromotion(record._id);
  22. this.controls.promotionListCtrl.fresh();
  23. },
  24. async createPromotion() {
  25. const title = await queenApi.showInput({
  26. title: "请输入标题",
  27. });
  28. if (!title) return;
  29. const res = await this.https.createPromotion({ title });
  30. const url = `${location.origin}/editor.html#/?id=${res.result}`;
  31. location.href = url;
  32. }
  33. });