mod.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * @Author: dayan_hjm
  3. * @Date: 2022-10-27 11:11:30
  4. * @Last modified by: dayan_hjm
  5. * @Last modified time: 2022-10-27 11:11:30
  6. */
  7. // 状态管理方法
  8. import { observable, action, configure, makeObservable, runInAction } from 'mobx';
  9. // 工具方法
  10. import { cloneDeep, get, groupBy, isEmpty, orderBy, pick, values } from "lodash";
  11. import { message } from 'antd';
  12. // 默认状态
  13. const defaultState = {
  14. list:[{name:'营运数据大屏'},{name:'经营大盘'},{name:'到家专题'},{name:'门店大盘'},{name:'自助跑数SQL平台'},{name:'月度包材预警跑数模板'}],
  15. rightlist:[],
  16. bumen:'数字化中心/数据工程部',
  17. gw:'数据产品经理',
  18. }
  19. // 严格模式
  20. configure({
  21. enforceActions: 'observed'
  22. });
  23. /**
  24. * mod层 - 业务逻辑,数据逻辑应该存储于此
  25. */
  26. class Mod {
  27. constructor() {
  28. makeObservable(this);
  29. }
  30. // 监视状态
  31. @observable state = cloneDeep(defaultState);
  32. @action saveState = async (payload) => {
  33. runInAction(() => {
  34. this.state = {
  35. ...this.state,
  36. ...payload
  37. };
  38. });
  39. };
  40. // 新增/编辑运营商
  41. // @action customerOperatorsmod = async (par, type) => {
  42. // try {
  43. // const { data, resultCode, resultMsg } = await Serv.customerOperatorsServ(par, type);
  44. // if (resultCode + '' === '0') {
  45. // runInAction(() => {
  46. // message.success('操作成功!')
  47. // this.state.addEditVisiable = false;
  48. // this.state.version = Math.random()
  49. // });
  50. // }
  51. // } catch (e) {
  52. // console.log('e: ', e);
  53. // }
  54. // }
  55. }
  56. // 将组件实例化,这意味着组件将不能从别处实例化
  57. const mod = new Mod();
  58. export default mod;