import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
const store = new Vuex.Store({
	state: {
		// oper_record: [], // 保存操作记录数据--日志数据  --弃用
		all_data: [], // 保存页面数据 -- 所有的巡检数据,list列表
		deviceData: [], //设备上架
		all_user_data: [], //所有用户信息 -- list列表,

		log_list: [], // 保存操作记录数据--日志数据

		now_user: {}, //保存当前登录用户
		darf_data: {}, // 保存草稿内容

		temp_data: {}, // 当前编辑或者查看的数据,

		oper_type: "", // 当前操作类型
		// last_time: '', //上次上报时间,
		user_data: {}, //所有用户信息
		scroll_top: 510, //
		flgObj: false,
		roomNum: null,
		startTime: "",
	},
	mutations: {
		SET_STARTTIME(state, payload) {
			state.startTime = payload;
		},
		SET_TOP(state, payload) {
			state.scroll_top = payload;
		},
		SET_ROOM(state, payload) {
			state.roomNum = payload;
		},
		set_FLAG(state, payload) {
			state.flgObj = payload;
		},
		SET_TYPE(state, payload) {
			//设置操作类型
			state.oper_type = payload;
		},
		SET_USER(state, payload) {
			//保存当前登录用户
			state.now_user = payload;
		},
		SET_TIME(state, payload) { //保存上次上报时间
			state.last_time = payload
		},
		DEL_DATA(state, index) {
			//删除数据
			state.all_data.splice(index, 1);
		},
		SET_TEMP_DATA(state, payload) {
			//设置当前编辑或查看的数据
			state.temp_data = payload;
		},
		SET_USER_DATA(state, payload) {
			//设置当前编辑或查看的数据
			state.user_data = payload;
		},

		SET_DARF_DATA(state, payload) {
			// 保存巡检内容的草稿状态
			state.darf_data = payload;
		},
		SET_ALL_DATA(state, payload) {
			// 保存 巡检数据
			state.all_data = payload;
		},
		SET_LOG_LIST(state, payload) {
			// 保存 日志文件
			state.log_list = payload;
		},
		SET_DEVICEDATA(state, payload) { 
			//保存设备上架数据
			state.deviceData = payload
		},
		DEL_DEVICEDATA(state, index) {
			//删除数据
			state.deviceData.splice(index, 1);
		},
	},
});

export default store;