/* * @Author: dayan_hjm * @Date: 2022-10-27 11:11:30 * @Last modified by: dayan_hjm * @Last modified time: 2022-10-27 11:11:30 */ // 状态管理方法 import { observable, action, configure, makeObservable, runInAction } from 'mobx'; // 工具方法 import { cloneDeep, get, groupBy, isEmpty, orderBy, pick, values } from "lodash"; import { message } from 'antd'; // 默认状态 const defaultState = { imgMsgData: [ { total: 4500, totalName: "累计运输锂辉石", styles: { left: "0%", top: "19%" }, cumulativeProduction: "", inventory: 0, }, { total: 3233, totalName: "锂辉石库存量", styles: { left: "11%", top: "45%" }, cumulativeProduction: "", inventory: 0, }, { total: 3578, totalName: "锂辉石库存量", styles: { left: "32%", top: "27%" }, cumulativeProduction: "", inventory: 0, }, { total: 0, totalName: "", styles: { left: "10%", top: "88%" }, cumulativeProduction: 1222, inventory: 1000, day:222, mood:333, year:444, rawMaterial:[ { prodCatgory:"原料-鲤辉石", indexValue:22, }, { prodCatgory:"产品-碳酸锂", indexValue:33, }, { prodCatgory:"产品-氯化锂", indexValue:44, }, { prodCatgory:"产品-氢氧化锂", indexValue:66, }, { prodCatgory:"产品-金属锂", indexValue:88, }, { prodCatgory:"产品-98K", indexValue:1000, }, ] }, { total: 0, totalName: "", styles: { left: "27%", top: "73%" }, cumulativeProduction: 1222, inventory: 1000, day:222, mood:333, year:444, rawMaterial:[ { prodCatgory:"原料-鲤辉石", indexValue:22, }, { prodCatgory:"产品-碳酸锂", indexValue:33, }, { prodCatgory:"产品-氯化锂", indexValue:44, }, { prodCatgory:"产品-氢氧化锂", indexValue:66, }, { prodCatgory:"产品-金属锂", indexValue:88, }, { prodCatgory:"产品-98K", indexValue:1000, }, ] }, { total: 0, totalName: "", styles: { left: "49%", top: "56%" }, cumulativeProduction: 1222, inventory: 1000, day:222, mood:333, year:444, rawMaterial:[ { prodCatgory:"原料-鲤辉石", indexValue:22, }, { prodCatgory:"产品-碳酸锂", indexValue:33, }, { prodCatgory:"产品-氯化锂", indexValue:44, }, { prodCatgory:"产品-氢氧化锂", indexValue:66, }, { prodCatgory:"产品-金属锂", indexValue:88, }, { prodCatgory:"产品-98K", indexValue:1000, }, ] }, { total: 0, totalName: "", styles: { left: "66%", top: "42%" }, cumulativeProduction: 1222, inventory: 1000, day:222, mood:333, year:444, rawMaterial:[ { prodCatgory:"原料-鲤辉石", indexValue:22, }, { prodCatgory:"产品-碳酸锂", indexValue:33, }, { prodCatgory:"产品-氯化锂", indexValue:44, }, { prodCatgory:"产品-氢氧化锂", indexValue:66, }, { prodCatgory:"产品-金属锂", indexValue:88, }, { prodCatgory:"产品-98K", indexValue:1000, }, ] }, { total: 0, totalName: "", styles: { left: "83%", top: "28%" }, cumulativeProduction: 1222, inventory: 1000, day:222, mood:333, year:444, rawMaterial:[ { prodCatgory:"原料-鲤辉石", indexValue:22, }, { prodCatgory:"产品-碳酸锂", indexValue:33, }, { prodCatgory:"产品-氯化锂", indexValue:44, }, { prodCatgory:"产品-氢氧化锂", indexValue:66, }, { prodCatgory:"产品-金属锂", indexValue:88, }, { prodCatgory:"产品-98K", indexValue:1000, }, ] }, ], } // 严格模式 configure({ enforceActions: 'observed' }); /** * mod层 - 业务逻辑,数据逻辑应该存储于此 */ class Mod { constructor() { makeObservable(this); } // 监视状态 @observable state = cloneDeep(defaultState); @action saveState = async (payload) => { runInAction(() => { this.state = { ...this.state, ...payload }; }); }; // 新增/编辑运营商 // @action customerOperatorsmod = async (par, type) => { // try { // const { data, resultCode, resultMsg } = await Serv.customerOperatorsServ(par, type); // if (resultCode + '' === '0') { // runInAction(() => { // message.success('操作成功!') // this.state.addEditVisiable = false; // this.state.version = Math.random() // }); // } // } catch (e) { // console.log('e: ', e); // } // } } // 将组件实例化,这意味着组件将不能从别处实例化 const mod = new Mod(); export default mod;