import axios from './axios';
import url from './index'

var ip = url;
// console.log(ip);
// var mcjUrl = 'http://192.168.1.7:8082'
// let baiIp = 'http://192.168.1.244:8082';
const requests = {
  postUserLogin(data) { // 用户登录
      return axios(ip + '/userLogin', {
      method: 'post',
      data: data
    });
  },
  getLogout() { // 登出
      return axios(ip + '/userLogout', {
          method: 'get'
      });
  },
  postAddAuthority(data) { // 新增权限
    return axios(ip + '/pas/authority/addAuthority', {
      method: 'post',
      data: data
    })
  },
	deleteAuthority(id) { // 删除权限
		return axios(ip + '/pas/authority/deleteAuthority/' + id, {
			method: 'delete',
		})
	},
  putAuthority() { // 查询权限
    return axios(ip + '/pas/authority/findAuthority', {
      method: 'get'
    })
  },
	putChangeAuthority(data) { // 修改权限
		return axios(ip + '/pas/authority/updateAuthority', {
			method: 'put',
      data: data
		})
	},
  postAddConfig(data) { // 保存权限
    return axios(ip + '/pas/config/addConfig', {
      method: 'post',
      data: data
    })
  },
	getAddConfig() { // 保存权限
		return axios(ip + '/pas/config/findConfig', {
			method: 'get'
		})
	},
	postUser(data) { // 添加用户
		return axios(ip + '/pas/user', {
			method: 'post',
			data: data
		});
	},
	getUser() { // 查询所有用户
		return axios(ip + '/pas/user', {
			method: 'get'
		})
	},
  putUsers(data) { // 更新用户信息
    return axios(ip + '/pas/user', {
      method: 'put',
      data: data
    })
  },
  deleteUsers(id) {
    return axios(ip + '/pas/user/delete/' + id, {
      method: 'delete'
    })
  },
	postRole(data) { // 添加角色
		return axios(ip + '/pas/role', {
			method: 'post',
			data: data
		});
	},
  putRoles(data) {
    return axios(ip + '/pas/role/updateRole', {
      method: 'put',
      data: data
    })
  },
	getRole() { // 查询所有角色
		return axios(ip + '/pas/role', {
			method: 'get'
		})
	},
  deleteRole(id) { // 删除角色
    return axios(ip + '/pas/role/deleteRole/' + id, {
      method: 'delete'
    })
  },
  getRoleFindDepartment(id) { // 根据部门id查询角色
    return axios(ip + '/pas/role/findRoleByDepartId/' + id, {
      method: 'get'
    })
  },
  postDepartmentList() { // 查询部门列表
    return axios(ip + '/pas/department/findList', {
      method: 'get'
    })
  },
  getAllDepartment() { // 所有部门，不是树形
    return axios(ip + '/pas/department', {
      method: 'get'
    })
  },
  postAddDepartment(data) { // 新增部门
    return axios(ip + '/pas/department', {
      method: 'post',
      data: data
    })
  },
  deleteDepartmentList(id) {
    return axios(ip + '/pas/department/deleteDepartment/' + id, {
      method: 'delete'
    })
  },
	putDepartmentList(data) {
		return axios(ip + '/pas/department/', {
			method: 'put',
      data: data
		})
	},
  getHoliday(id) { // 获取节假日
    return axios(ip + '/pas/config/getHolidayByMonth?date=' + id, {
      method: 'get'
    })
  },
  putHoliday(data) { // 设置节假日
    return axios(ip + '/pas/config/setHolidays', {
      method: 'put',
      data: data
    })
  },
  putOrdinaryUser(data) { // 保存普通用户自己信息的修改
    return axios(ip + '/manage/user/updateSelf', {
      method: 'put',
      data: data
    })
  },
  getDepartmentFind(id) { // 人员管理列表下拉框数据
    return axios(ip + '/manage/user/findDepartmentList/' + id, {
      method: 'get'
    })
  },
	getManageUserList(data) { // 人员管理列表
		return axios(ip + '/manage/user/findUserList/', {
			method: 'post',
      data: data
		})
	},
  postUpcoming(data) { // 我的待办任务
    return axios(ip + '/read/selectCommission?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post',
      data: data
    })
  },
  postRelease(data) { // 我的发布任务
    return axios(ip + '/read/selectMeRelease?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    })
  },
	postBreakDown(data) { // 我的分解任务
		return axios(ip + '/read/selectMeResolve?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
			method: 'post',
			data: data
		})
	},
	postRelated(data) { // 我的相关任务
		return axios(ip + '/read/selectRelated?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
			method: 'post',
			data: data
		})
	},
  postAddTask(data) { // 新增任务
    return axios(ip + '/job/work/save', {
      method: 'post',
      data:data
    })
  },
  getUserById(id) { // 根据id获取该id下人员
    return axios(ip + '/pas/user/findUserList/' + id, {
      method: 'get'
    })
  },
  getWorkDetails(id) { // 很久id获取任务的详情
    return axios(ip + '/job/work/' + id, {
      method: 'get'
    })
  },
  getTaskHistory(id) {
    return axios(ip + '/history?id=' + id, {
      method: 'get'
    })
  },
  putTaskGroup(data) { // 修改组员
    return axios(ip + '/job/work/', {
      method: 'put',
      data: data
    })
  },
  putTaskWorkload(data) { // 修改工作量和系数
    // ?msg=' + data.msg + '&userId=' + data.userId + '&workCoefficient=' + data.workCoefficient + '&workId=' + data.workId + '&workload=' + data.workload
    return axios(ip + '/job/work/upDate/Workload', {
      method: 'put',
      data: data
    })
  },
  putTaskUnpushToGoing(data) { // 未发布改为发布
    return axios(ip + '/job/work/upDateSave', {
      method: 'put',
      data: data
    })
  },
  putTaskStatus(data) { // 修改任务状态
    return axios(ip + '/job/work/status?msg=' + data.msg + '&userId=' + data.userId + '&workId=' + data.workId + '&status=' + data.status + '&re=' + data.re, {
      method: 'put',
    })
  },
  deleteTaskByParams(data) {
    return axios(ip + '/job/work/delete?msg=' + data.msg + '&personalWorkload=' + data.personalWorkload + '&userId=' + data.userId + '&workId=' + data.workId + '&workloadCount=' + data.workloadCount, {
      method: 'put'
    })
  },
	postUpload(data) { // 上传文件
		return axios(ip + '/files/upload', {
			method: 'post',
			data: data,
			send: 'formData',
			headers: {'Content-Type': 'application/json;charset=UTF-8;multipart/form-data'}
			// ,
			// headers: {'Content-Type': 'multipart/form-data;charset=UTF-8'}
		});
	},
  postAttachmentOneByOne(data) { // 上传你文件后的对象再上传取得真的id
    return axios(ip + '/job/attachment/one', {
      method: 'post',
      data: data
    })
  },
	postAttachmentWorkId(id, data) { // 上传你文件后的对象再上传取得真的id,完成任务提交文件
		return axios(ip + '/job/attachment/' + id, {
			method: 'post',
			data: data
		})
	},
  postScore(data) { // 新增考评
    return axios(ip + '/job/sc/save', {
      method: 'post',
      data: data
    })
  },
  putScore(id, msg, data) { // 修改考评
    return axios(ip + '/job/sc/upDate?userId=' + id + '&msg=' + msg, {
      method: 'put',
      data: data
    })
  },
  getScore(id) { // 获取考评数据
    return axios(ip + '/job/sc/select?workId=' + id, {
      method: 'post'
    })
  },
  postChangeReadStatus(data) { // 未读改已读
    return axios(ip + '/read/readsStatus?eventId=' + data.eventId + '&id=' + data.id + '&readState=' + data.readState, {
      method: 'post'
    })
  },
  postFirstWebSocket(id) { // 告诉该推消息了
    return axios(ip + '/read/push?id=' + id, {
      method: 'post'
    })
  },
  putCanSubmitTask(id) { // 是否可以提交任务
    return axios(ip + '/job/work/select/subtasks/' + id, {
      method: 'put'
    })
  },
  putFindWorkload(id) { // 任务id查找剩余工作量
    return axios(ip + '/job/work/select/workload/' + id, {
      method: 'put'
    })
  },
  getTaskFindById(id) { //根据用户id查看其部门所有的任务
    return axios(ip + '/job/work/select/work/' + id, {
      method: 'get'
    })
  },
  putPassword(data) { // 修改密码
    return axios(ip + '/manage/user/password', {
      method: 'put',
      data: data
    })
  },
	postDownload(id) { // 下载附件
		return axios(ip + '/files/download?fileId=' + id, {
			method: 'post',
			responseType: 'arraybuffer'
		});
	},
	getFeedback() { // 获取反馈
		return axios(ip + '/manage/user', {
			method:'get'
		})
	},
	postFeedback(data) { // 添加反馈
		return axios(ip + '/manage/user', {
			method:'post',
			data: data
		})
	},
	getJudgeParent(id, uid) { // 是否是某用户上级并且拥有修改任务权限
		return axios(ip + '/pas/user/judgeParent/' + id + '/' + uid, {
			method: 'get'
		})
	},
	getRelatedWorkId(id) { // 任务详情获取相关任务数据
		return axios(ip + '/job/work/select/work/workId/' + id, {
			method: 'get'
		})
	},
	getPublisherUser() { // 查询审核人
		return axios(ip + '/pas/user/findPublishUsers', {
			method: 'get'
		})
	},
	getTaskBack(id) { // 任务是否审核未通过
		return axios(ip + '/job/work/select/back/' + id, {
			method: 'get'
		})
	},
	getPersonAttendance(data) { // 查看个人统计
		return axios(ip + '/attendance/info/personnel', {
			method: 'post',
			data: data
		})
	},
	getDepartmentAttendance(data) { // 查看部门统计
		return axios(ip + '/attendance/info/department', {
			method: 'post',
			data: data
		})
	},
	postApprovalSubmit(data) {	// 查看我的提交申请
		return axios(ip + '/attendance/approval/findAllSubmitApproval', {
			method: 'post',
			data: data
		}) // /attendance/approval/findAllSubmitWorkOverApproval
	},
	postApprovalOvertimeSubmit(data) {	// 查看我的提交加班申请
		return axios(ip + '/attendance/approval/findAllSubmitWorkOverApproval', {
			method: 'post',
			data: data
		})
	},
	getApprovalAudit(data) {	// 查看我的审批审批
		return axios(ip + '/attendance/approval/findAllAuditApproval', {
			method: 'post',
			data: data
		})
	},
	postApprovalOvertimeAudit(data) {	// 查看我的审批加班审批
		return axios(ip + '/attendance/approval/findAllAuditWorkOverApproval', {
			method: 'post',
			data: data
		})
	},
	postAuditApproval(id, status, data) { // 审批申请
		return axios(ip + '/attendance/approval/audit/' + id + '/' + status, {
			method: 'post',
			data: data
		})
	},
	postAuditOvertimeApproval(id, status, data) { // 审批加班申请
		return axios(ip + '/attendance/approval/approWorkover/' + id + '/' + status, {
			method: 'post',
			data: data
		})
	},
	postSubmitApproval(data) { // 提交新的申请
		return axios(ip + '/attendance/approval/submit', {
			method: 'post',
			data: data
		})
	},
	postSubmitOvertimeApproval(data) { // 提交新的加班申请
		return axios(ip + '/attendance/approval/submitWorkover', {
			method: 'post',
			data: data
		})
	},
	postExportExcel(data) { // 导出部门统计excel
		return axios(ip + '/attendance/excel', {
			method: 'post',
			data: data,
			responseType: 'arraybuffer'
		})
	},
	getApprovalDepartment() { // 申请单的部门
		return axios(ip + '/attendance/approval/departSelect', {
			method: 'get'
		})
	},
	getTaskOvertime(id) { // 加班任务选择
		return axios(ip + '/job/work/select/WorkOverTime/' + id, {
			method: 'get'
		})
	},
	deleteApproval(id) { // 删除审批
		return axios(ip + '/attendance/approval/delete/' + id, {
			method: 'delete'
		})
	},
	deleteOvertime(id) { // 删除加班审批
		return axios(ip + '/attendance/approval/deleteWorkover/' + id, {
			method: 'delete'
		})
	}
};

export default requests;
