| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { reactive, toRefs } from 'vue';
- import { LoginaccountModel, MarketrunModal, SelectedAccountModel, UserAccountModel, UserInfoModel } from './initDataModel/account';
- import { NeedClearSourceDataType, NoClearSourceDataType } from './interface';
- /**
- * 需要清空数据中心
- */
- const needClearSourceData: NeedClearSourceDataType = {
- systemDate: '',
- externalexchange: [],
- goodsgroups: [], // 商品组
- loginAccount: new LoginaccountModel(),
- markets: [],
- systemParams: [], // 系统参数
- userAccount: new UserAccountModel(), // 用户账号信息
- userInfo: new UserInfoModel(), // 用户信息
- username: '',
- menus: [],
- tableHead: [],
- areaRoles: [],// 所属角色信息
- Goods: [],
- DeliveryGoodsList: [],
- marketRun: new MarketrunModal(), // 市场运行信息
- // checkTokenTimeDiff: Math.floor(Math.random() * 6 + 5) * 60 * 1000,
- checkTokenTimeDiff: 1 * 60 * 1000,
- accountList: [],
- selectedAccount: new SelectedAccountModel(),
- quoteDayInfo: [],
- RootUser: [],
- };
- /**
- * 不需要清空的数据
- */
- const noClearSourceData: NoClearSourceDataType = {
- touristToken: 'c886a057f3d820d4dbc41473686c7c2d',
- };
- class DataCenter {
- private data = toRefs<NeedClearSourceDataType>(reactive(Object.assign({}, needClearSourceData)));
- private noClearData = toRefs<NoClearSourceDataType>(reactive(Object.assign({}, noClearSourceData)));
- /** 重置所有数据 */
- public reset(): void {
- this.data = toRefs<NeedClearSourceDataType>(reactive(Object.assign({}, needClearSourceData)));
- }
- /** 设置键对应的值 */
- public setOneOf(props: keyof (NeedClearSourceDataType & NoClearSourceDataType), value: any) {
- if (Reflect.has(noClearSourceData, props)) {
- this.noClearData[props as keyof NoClearSourceDataType].value = value;
- } else if (Reflect.has(needClearSourceData, props)) {
- this.data[props as keyof NeedClearSourceDataType].value = value;
- }
- }
- /** 获取其中之一 */
- public getOneOf(props: keyof (NeedClearSourceDataType & NoClearSourceDataType)): any {
- if (Reflect.has(noClearSourceData, props)) {
- return this.noClearData[props as keyof NoClearSourceDataType];
- } else if (Reflect.has(needClearSourceData, props)) {
- return this.data[props as keyof NeedClearSourceDataType];
- }
- }
- /** 获取全部数据 */
- // public getAll() {
- // return this.data;
- // }
- }
- export default DataCenter;
|