mod.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. totalValue:0,
  15. yearDecline:0,
  16. yearSend:0,
  17. productInventory:0,
  18. list:[{name:'营运数据大屏'},{name:'经营大盘'},{name:'到家专题'},{name:'门店大盘'},{name:'自助跑数SQL平台'},{name:'月度包材预警跑数模板'}],
  19. rightlist:[],
  20. bumen:'数字化中心/数据工程部',
  21. gw:'数据产品经理',
  22. }
  23. // 严格模式
  24. configure({
  25. enforceActions: 'observed'
  26. });
  27. /**
  28. * mod层 - 业务逻辑,数据逻辑应该存储于此
  29. */
  30. class Mod {
  31. constructor() {
  32. makeObservable(this);
  33. }
  34. // 监视状态
  35. @observable state = cloneDeep(defaultState);
  36. @action saveState = async (payload) => {
  37. runInAction(() => {
  38. this.state = {
  39. ...this.state,
  40. ...payload
  41. };
  42. });
  43. };
  44. // 新增/编辑运营商
  45. // @action customerOperatorsmod = async (par, type) => {
  46. // try {
  47. // const { data, resultCode, resultMsg } = await Serv.customerOperatorsServ(par, type);
  48. // if (resultCode + '' === '0') {
  49. // runInAction(() => {
  50. // message.success('操作成功!')
  51. // this.state.addEditVisiable = false;
  52. // this.state.version = Math.random()
  53. // });
  54. // }
  55. // } catch (e) {
  56. // console.log('e: ', e);
  57. // }
  58. // }
  59. }
  60. // 将组件实例化,这意味着组件将不能从别处实例化
  61. const mod = new Mod();
  62. export default mod;