import { Module } from 'vuex';
import { Session } from '/@/utils/storage';
// 此处加上 `.ts` 后缀报错，具体原因不详
import { deviceInfosState, RootStateTypes } from '/@/store/interface/index';

const deviceInfosModule: Module<deviceInfosState, RootStateTypes> = {
	namespaced: true,
	state: {
		deviceInfos: {
			"clientCode": "",
			"code": "",	
			"deviceBrand": "",
			"deviceCurrentState": 0,
			"deviceGroupCode": "",
			"deviceInitialRunCount": 0,
			"deviceModel": "",
			"deviceName": "",
			"sortOrder":999,
			"deviceNo": "",
			"devicePurchaseTime": "",//购买日期
			"deviceSn": "",
			"deviceType": 0,
			"id": 0,	
			"remark": "",
			"deviceVsSchemes":[]
		},
	},
	mutations: {
		// 设置用户信息
		getdeviceInfos(state: any, data: object) {
			state.deviceInfos = data;
		},
	},
	actions: {
		// 设置用户信息
		async setdeviceInfos({ commit }, data: object) {
			if (data) {
				commit('getdeviceInfos', data);
			} else {
				if (Session.get('deviceInfo')) commit('getdeviceInfos', Session.get('deviceInfo'));
			}
		},
	},
};

export default deviceInfosModule;
