import request from '@/utils/request';

// 获取账号列表数据
export function getTableData(forData) {
	let data = new FormData();
	data.append('page', forData.page);
	data.append('rows', forData.rows);
  
	return request({
		url: '/adminlist.action',
		method: 'post',
		data
	});
};

// 新增管理员
export function addAccount(param) {
	let data = {
		admin_name: param.username,
		phone: param.phone,
		password: param.password,
		level: param.checkedRole[0] == '超级管理员' ? 2 : 1,
		user_name: param.fullname,
		remark: param.comment,
    admin_power: '1,2,3,4,5,6',
		// card_number: param.cardNumber
	};
  
	return request({
		url: '/admininsert.action',
		method: 'post',
		data
	});
};

// 修改管理员
export function modifyAccount(param) {
	let data = {
		id: param.id,
		admin_name: param.username,
		phone: param.phone,
		password: param.password,
		user_name: param.fullname,
		level: param.checkedRole[0] == '超级管理员' ? 2 : 1,
		remark: param.comment,
    admin_power: '1,2,3,4,5,6',
		// card_number: param.cardNumber
	};
	return request({
		url: '/adminupdate.action',
		method: 'post',
		data
	});
};

// 删除管理员
export function deleteAccount(param) {
	let data = new FormData();
	data.append('id', param);
	return request({
		url: '/admindel.action',
		method: 'post',
		data
	});
};
