model.ts 860 B

123456789101112131415161718192021222324252627282930
  1. import type { Option } from '@/components/BaseCrud/index';
  2. import { Store } from 'jetlinks-store';
  3. import SystemConst from '@/utils/const';
  4. import { model } from '@formily/reactive';
  5. export const CurdModel = model<Option>({
  6. model: 'add',
  7. current: undefined,
  8. visible: false,
  9. add() {
  10. Store.set(SystemConst.BASE_CURD_MODAL_VISIBLE, true);
  11. Store.set(SystemConst.BASE_CURD_CURRENT, {});
  12. Store.set(SystemConst.BASE_CURD_MODEL, 'add');
  13. this.model = 'add';
  14. },
  15. update(current: any) {
  16. Store.set(SystemConst.BASE_CURD_MODEL, 'edit');
  17. Store.set(SystemConst.BASE_CURD_MODAL_VISIBLE, true);
  18. Store.set(SystemConst.BASE_CURD_CURRENT, current);
  19. this.model = 'edit';
  20. this.current = current;
  21. },
  22. close() {
  23. Store.set(SystemConst.BASE_CURD_MODAL_VISIBLE, false);
  24. Store.set(SystemConst.BASE_CURD_CURRENT, {});
  25. },
  26. });