import http from '@/request/index.js';
export const state = {
	orderDelData: [] //采购计划详情数据
};
export const mutations = {
	setOrderDelsData(state, data) {
		state.orderDelData = data
	},
}
export const actions = {
	// 药品采购单查询
	getPurDerData({
		commit,
		rootState
	}, data) {
		return new Promise((resolve, reject) => {
			http('puhseOrder.getData', {
				...data.pam,
			}, '加载中').then(res => {
				if (res.success == true) {
					data.that.$refs.paging.complete(res.data.records);
				}
			}).catch(e => {
				reject(e)
			})

		})
	},
	//耗材采购单查询
	getMcsOrdeData({
		commit,
		rootState
	}, data) {
		return new Promise((resolve, reject) => {
			http('mcsQueryOrder.getData', {
				...data.pam,
			}, '加载中').then(res => {
				if (res.success == true) {
					data.that.$refs.paging.complete(res.data);
				}
			}).catch(e => {
				reject(e)
			})

		})
	},
	//耗材详情------待出库和已出库
	getMcsOrderDetail({
		commit,
		rootState
	}, data) {
		return new Promise((resolve, reject) => {
			http('mcsQueryOrder.details', {
				...data,
				current: 1,
				size: 10000
			}, '加载中').then(res => {
				if (res.success == true) {
					commit('setOrderDelsData', res.data);
				}

			}).catch(e => {
				reject(e)
			})
		})
	},
	//耗材详情待验收和已验收
	getMcsBondDetail({
		commit,
		rootState
	}, data) {
		return new Promise((resolve, reject) => {
			http('mcsQueryOrder.tabDetails', {
				...data,
				current: 1,
				size: 10000
			}, '加载中').then(res => {
				if (res.success == true) {
					commit('setOrderDelsData', res.data);
				}

			}).catch(e => {
				reject(e)
			})
		})
	},


	// 药品详情
	getpurOrderDetail({
		commit,
		rootState
	}, data) {
		return new Promise((resolve, reject) => {
			http('puhseOrder.details', {
				...data,
				current: 1,
				size: 10000
			}, '加载中').then(res => {
				if (res.success == true) {
					commit('setOrderDelsData', res.data);
				}

			}).catch(e => {
				reject(e)
			})
		})
	},
	// 药品详情
	getOrderTabDetail({
		commit,
		rootState
	}, data) {
		return new Promise((resolve, reject) => {
			http('puhseOrder.tabDetails', {
				...data,
				current: 1,
				size: 10000
			}, '加载中').then(res => {
				if (res.success == true) {
					commit('setOrderDelsData', res.data.records);
				}

			}).catch(e => {
				reject(e)
			})
		})
	},
}