mod.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. imgMsgData: [
  15. {
  16. total: 4500,
  17. totalName: "累计运输锂辉石",
  18. styles: { left: "0%", top: "19%" },
  19. cumulativeProduction: "",
  20. inventory: 0,
  21. },
  22. {
  23. total: 3233,
  24. totalName: "锂辉石库存量",
  25. styles: { left: "11%", top: "45%" },
  26. cumulativeProduction: "",
  27. inventory: 0,
  28. },
  29. {
  30. total: 3578,
  31. totalName: "锂辉石库存量",
  32. styles: { left: "32%", top: "27%" },
  33. cumulativeProduction: "",
  34. inventory: 0,
  35. },
  36. {
  37. total: 0,
  38. totalName: "",
  39. styles: { left: "10%", top: "88%" },
  40. cumulativeProduction: 1222,
  41. inventory: 1000,
  42. day:222,
  43. mood:333,
  44. year:444,
  45. rawMaterial:[
  46. {
  47. prodCatgory:"原料-鲤辉石",
  48. indexValue:22,
  49. },
  50. {
  51. prodCatgory:"产品-碳酸锂",
  52. indexValue:33,
  53. },
  54. {
  55. prodCatgory:"产品-氯化锂",
  56. indexValue:44,
  57. },
  58. {
  59. prodCatgory:"产品-氢氧化锂",
  60. indexValue:66,
  61. },
  62. {
  63. prodCatgory:"产品-金属锂",
  64. indexValue:88,
  65. },
  66. {
  67. prodCatgory:"产品-98K",
  68. indexValue:1000,
  69. },
  70. ]
  71. },
  72. {
  73. total: 0,
  74. totalName: "",
  75. styles: { left: "27%", top: "73%" },
  76. cumulativeProduction: 1222,
  77. inventory: 1000,
  78. day:222,
  79. mood:333,
  80. year:444,
  81. rawMaterial:[
  82. {
  83. prodCatgory:"原料-鲤辉石",
  84. indexValue:22,
  85. },
  86. {
  87. prodCatgory:"产品-碳酸锂",
  88. indexValue:33,
  89. },
  90. {
  91. prodCatgory:"产品-氯化锂",
  92. indexValue:44,
  93. },
  94. {
  95. prodCatgory:"产品-氢氧化锂",
  96. indexValue:66,
  97. },
  98. {
  99. prodCatgory:"产品-金属锂",
  100. indexValue:88,
  101. },
  102. {
  103. prodCatgory:"产品-98K",
  104. indexValue:1000,
  105. },
  106. ]
  107. },
  108. {
  109. total: 0,
  110. totalName: "",
  111. styles: { left: "49%", top: "56%" },
  112. cumulativeProduction: 1222,
  113. inventory: 1000,
  114. day:222,
  115. mood:333,
  116. year:444,
  117. rawMaterial:[
  118. {
  119. prodCatgory:"原料-鲤辉石",
  120. indexValue:22,
  121. },
  122. {
  123. prodCatgory:"产品-碳酸锂",
  124. indexValue:33,
  125. },
  126. {
  127. prodCatgory:"产品-氯化锂",
  128. indexValue:44,
  129. },
  130. {
  131. prodCatgory:"产品-氢氧化锂",
  132. indexValue:66,
  133. },
  134. {
  135. prodCatgory:"产品-金属锂",
  136. indexValue:88,
  137. },
  138. {
  139. prodCatgory:"产品-98K",
  140. indexValue:1000,
  141. },
  142. ]
  143. },
  144. {
  145. total: 0,
  146. totalName: "",
  147. styles: { left: "66%", top: "42%" },
  148. cumulativeProduction: 1222,
  149. inventory: 1000,
  150. day:222,
  151. mood:333,
  152. year:444,
  153. rawMaterial:[
  154. {
  155. prodCatgory:"原料-鲤辉石",
  156. indexValue:22,
  157. },
  158. {
  159. prodCatgory:"产品-碳酸锂",
  160. indexValue:33,
  161. },
  162. {
  163. prodCatgory:"产品-氯化锂",
  164. indexValue:44,
  165. },
  166. {
  167. prodCatgory:"产品-氢氧化锂",
  168. indexValue:66,
  169. },
  170. {
  171. prodCatgory:"产品-金属锂",
  172. indexValue:88,
  173. },
  174. {
  175. prodCatgory:"产品-98K",
  176. indexValue:1000,
  177. },
  178. ]
  179. },
  180. {
  181. total: 0,
  182. totalName: "",
  183. styles: { left: "83%", top: "28%" },
  184. cumulativeProduction: 1222,
  185. inventory: 1000,
  186. day:222,
  187. mood:333,
  188. year:444,
  189. rawMaterial:[
  190. {
  191. prodCatgory:"原料-鲤辉石",
  192. indexValue:22,
  193. },
  194. {
  195. prodCatgory:"产品-碳酸锂",
  196. indexValue:33,
  197. },
  198. {
  199. prodCatgory:"产品-氯化锂",
  200. indexValue:44,
  201. },
  202. {
  203. prodCatgory:"产品-氢氧化锂",
  204. indexValue:66,
  205. },
  206. {
  207. prodCatgory:"产品-金属锂",
  208. indexValue:88,
  209. },
  210. {
  211. prodCatgory:"产品-98K",
  212. indexValue:1000,
  213. },
  214. ]
  215. },
  216. ],
  217. }
  218. // 严格模式
  219. configure({
  220. enforceActions: 'observed'
  221. });
  222. /**
  223. * mod层 - 业务逻辑,数据逻辑应该存储于此
  224. */
  225. class Mod {
  226. constructor() {
  227. makeObservable(this);
  228. }
  229. // 监视状态
  230. @observable state = cloneDeep(defaultState);
  231. @action saveState = async (payload) => {
  232. runInAction(() => {
  233. this.state = {
  234. ...this.state,
  235. ...payload
  236. };
  237. });
  238. };
  239. // 新增/编辑运营商
  240. // @action customerOperatorsmod = async (par, type) => {
  241. // try {
  242. // const { data, resultCode, resultMsg } = await Serv.customerOperatorsServ(par, type);
  243. // if (resultCode + '' === '0') {
  244. // runInAction(() => {
  245. // message.success('操作成功!')
  246. // this.state.addEditVisiable = false;
  247. // this.state.version = Math.random()
  248. // });
  249. // }
  250. // } catch (e) {
  251. // console.log('e: ', e);
  252. // }
  253. // }
  254. }
  255. // 将组件实例化,这意味着组件将不能从别处实例化
  256. const mod = new Mod();
  257. export default mod;