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

const patientInfosModule: Module<patientInfosState, RootStateTypes> = {
	namespaced: true,
	state: {
		patientInfos: {
            // 患者code
            code:'',
            // 患者id
            id:0,
            // 患者姓名
            patientName:'',
			// 证件号码
			patientIdentityNo:'',
			// 地址
			patientAddress:'',
			//电话
			patientTelNo:'',
			

        },
		recordInfo:{
			preHemoWeight:'',
			preMBpH:'',
			preMBpL:'',
			preMP:'',
			recordCode:''
		},
		afteInfo:{
			afterHemoWeight:'',
			afterMBpH:'',
			afterMBpL:'',
			afterMP:'',
			recordCode:''
		},
		printlist:[],
    patientList: []
	},
	mutations: {
		// 设置用户信息
		getpatientInfos(state: any, data: object) {
			console.log('kankan==-----',data)
			state.patientInfos = data;
		},
		setrecordInfoCommit(state: any, data: object) {
			state.recordInfo = data;
		},
		setafteInfoCommit(state: any, data: object) {
			state.afteInfo = data;
		},
		setprintlistCommit(state: any, data: object){
			state.printlist.push(data)
		}
	},
	actions: {
		// 设置用户信息
		async setpatientInfos({ commit }, data: object) {
			if (data) {
				commit('getpatientInfos', data);
			} else {
				if (Session.get('patientInfo')) commit('getpatientInfos', Session.get('patientInfo'));
			}
		},
		setrecordInfo({ commit }, data: object) {
			if(data){
				commit('setrecordInfoCommit',data)
			}
		},
		setafteInfo({ commit }, data: object) {
			if(data){
				commit('setafteInfoCommit',data)
			}
		},
		setPrintList({commit},data:object){
			if(data){
				console.log(data)
				commit('setprintlistCommit',data)
			}
		}



	},
};

export default patientInfosModule;
