promotion.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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 deletePromotion(record: any) {
  14. const res = await queenApi.showConfirm({
  15. content: `删除后无法恢复,确定要删除:${record.title}?`,
  16. type: "danger",
  17. });
  18. if (!res) return;
  19. await this.https.deletePromotion(record._id);
  20. // this.controls.promotionListCtrl.fresh();
  21. },
  22. async createPromotion() {
  23. const title = await queenApi.showInput({
  24. title: "请输入标题",
  25. });
  26. if (!title) return;
  27. const res = await this.https.createPromotion({ title });
  28. const url = `${location.origin}/editor.html#/?id=${res.result}`;
  29. location.href = url;
  30. },
  31. });