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'
    })
  },
  postAttachmentOneByOne(data) { // 上传你文件后的对象再上传取得真的id
    return axios(ip + '/job/attachment/one', {
      method: 'post',
      data: data
    })
  },
  postScore(data) { // 新增考评
    return axios(ip + '/job/sc/save', {
      method: 'post',
      data: data
    })
  },
  putScore(id, data) { // 修改考评
    return axios(ip + '/job/sc/upDate?userId=' + id, {
      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) {
    return axios(ip + '/job/work/select/work/' + id, {
      method: 'get'
    })
  },
  putPassword(data) {
    return axios(ip + '/manage/user/password', {
      method: 'put',
      data: data
    })
  },
  //   postUserLogin(data) { // 用户登录
  //       console.log(data);
  //       return axios('http://192.168.1.7:8082/userLogin', {
  //           method: 'post',
  //           data: data
  //       });
  //   },
  // getLogout() { // 登出
  //     return axios('http://192.168.1.7:8082/userLogout', {
  //         method: 'get'
  //     });
  // },
  // getUser() { // 查询所有用户
  //   return axios(ip + '/pas/user', {
  //     method: 'get'
  //   })
  // },
  postRegisteredUser(data) { // 注册用户
    return axios(ip + '/pas/user', {
      method: 'post',
      data: data
    });
  },
  putUser(data) { // 更新用户
    return axios(ip + '/pas/user', {
      method: 'put',
      data: data
    });
  },
    putUpdateUserInformation(data) { // 更改用户信息
        return axios(ip + '/pas/user', {
            method: 'put',
            data: data
        });
    },
  getDepartment() { // 查询所有部门
    return axios(ip + '/pas/department', {
      method: 'get'
    })
  },
  getJob() { // 查询所有岗位
    return axios(ip + '/pas/job', {
      method: 'get'
    })
  },
  getGroup() { // 查询所有小组
    return axios(ip + '/pas/group', {
      method: 'get'
    })
  },
  // getRole() { // 查询所有角色
  //   return axios(ip + '/pas/role', {
  //     method: 'get'
  //   })
  // },
  deleteUser(data) { // 删除用户
    return axios(ip + '/pas/user/delete/' + data, {
      method: 'delete'
    })
  },
  postSelectCommission(data) { // 获取工作台待审核列表
    return axios(ip + '/read/selectCommission?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    });
  },
  postSelectOther(data) { // 获取工作台其他列表
    return axios(ip + '/read/selectOther?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    });
  },
  postSelectSubmit(data) { // 获取工作台提交列表
    return axios(ip + '/read/selectSubmit?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    });
  },
  postSelectFinished(data) { // 获取工作台提交列表
    return axios(ip + '/read/selectFinished?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    });
  },
  getWork(data) { // 根据id查询工作
    return axios(ip + '/job/work/' + data, {
      method: 'get'
    })
  },
  getUserId(data) { // 根据id查询用户
    return axios(ip + '/pas/user/' + data, {
      method: 'get'
    })
  },
  getHistory(data) { // 根据id查询事件操作历史
    return axios(ip + '/history?id=' + data, {
      method: 'get'
    })
  },
  postTitleSelect(data) { // 获取阅读页面标题查询列表
    return axios(ip + '/read/titleSelect?id=' + data.id + '&page=' + data.page + '&size=' + data.size + '&title=' + data.title, {
      method: 'post'
    });
  },
  //  libaibai
  postAddJob(data) { // 新增工作
    return axios(ip + '/job/work/', {
      method: 'post',
      data: data
    });
  },
  getAllRoles () { // 获取所有角色
    return axios(ip + '/pas/role', {
      method: 'get'
    })
  },
    getJobWorks () { // 查询所有工作
        return axios(ip + '/job/work/', {
            method: 'get'
        })
    },
    getJobs () { // 查询所有岗位
        return axios(ip + '/pas/job', {
            method: 'get'
        })
    },
    getUsers () { // 查询所有工作
        return axios(ip + '/pas/user', {
            method: 'get'
        })
    },
    // getLogout () { // 用户登出
    //     return axios(ip + '/pas/user/logout', {
    //         method: 'get'
    //     })
    // },
    postAddAttachment(data) { // 添加附件
        console.log(data);
        return axios(ip + '/job/attachment/' + data.workId, {
            method: 'post',
            data:data.attachments
        });
    },
  postAddAttachmentAll(data) { // 批量添加附件
    console.log(data);
    return axios(ip + '/job/attachment/mul/' + data.workId, {
      method: 'post',
      data:data.attachments
    });
  },
    getJobWorkDraft(data) { // 根据当前用户Id查询其拥有的草稿
        return axios(ip + '/job/work/draft/' + data, {
            method: 'get',
            data:data
        });
    },
    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'}
        });
    },
    deleteWorkById(data){ // 根据workId 删除工作
      return axios(ip + '/job/work/' + data, {
          method: 'delete',
          data: data
      })
    },

  postJob(data) { // 添加岗位
    return axios(ip + '/pas/job?id=' + null + '&name=' + data.name, {
      method: 'get'
    })
  },
  getAuthority() { // 获得所有权限
    return axios(ip + '/pas/authority', {
      method: 'get'
    })
  },
  postPush(data) { // 登录之后触发数据推送
    return axios(ip + '/read/push?id=' + data, {
      method: 'post'
    });
  },
  getMenu() { // 获得所有菜单权限
    return axios(ip + '/pas/menu', {
      method: 'get'
    })
  },
  postDepartment(data) { // 添加部门
    return axios(ip + '/pas/department', {
      method: 'post',
      data: data
    });
  },
  postGroup(data) { // 添加小组
    return axios(ip + '/pas/group', {
      method: 'post',
      data: data
    });
  },
  postJobs(data) { // 添加岗位
    return axios(ip + '/pas/job', {
      method: 'post',
      data: data
    });
  },
  // postRole(data) { // 添加角色
  //   return axios(ip + '/pas/role', {
  //     method: 'post',
  //     data: data
  //   });
  // },
  postCollection(data) { // 收藏事件
    return axios(ip + '/read/collection/?collection=' + data.collection + '&eventId=' + data.eventId + '&id=' + data.id, {
      method: 'post'
    });
  },
  postReadStatus(data) { // 修改事件状态
    return axios(ip + '/read/readStatus/?eventId=' + data.eventId + '&id=' + data.id + '&readState =' + data.readState , {
      method: 'post'
    });
  },
  putStatus(data) { // 修改工作状态
    return axios(ip + '/job/work/status?status=' + data.status + '&msg=' + data.msg + '&taskId=' + data.taskId + '&userId=' + data.userId, {
      method: 'put'
    })
  },
  postCommentWork(data, workId) {
    return axios(ip + '/job/comment/' + workId, {
      method: 'post',
      data: data
    });
  },
  postSelectCollection(data) { // 获取收藏列表
    return axios(ip + '/read/selectCollection?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    });
  },
  putWork(data) { // 修改工作状态
    return axios(ip + '/job/work/status?msg=' + data.msg + '&status=' + data.status + '&taskId=' + data.taskId + '&userId=' + data.userId, {
      method: 'put'
    });
  },
  postReadsStatus(data) { // 修改事件状态
    return axios(ip + '/read/readsStatus?eventId=' + data.eventId + '&id=' + data.id + '&readState=' + data.readState, {
      method: 'post'
    });
  },
  postUpdateChecker(data) { // 修改审核者
    return axios(ip + '/job/work/updateChecker', {
      method: 'post',
      data: data
    });
  },
  postUpdateFlower(data) { // 修改关注者
    return axios(ip + '/job/work/updateFlower', {
      method: 'post',
      data: data
    });
  },
  postFindOne(data) { // 根据id查询部门
    return axios(ip + '/pas/department/findOne?id=' + data.departId, {
      method: 'post'
    });
  },
  postAttachmentWork(data) { // 新增附件添加工作中
    return axios(ip + '/job/attachment/' + data.workId, {
      method: 'post',
      data: data.attachment
    });
  },
  deleteAttachment (data) { // 根据id删除附件
        return axios(ip + '/job/attachment/' + data, {
            method: 'delete',
            data: data
        })
  },
  putWorkId(data) { // 更新工作
    return axios(ip + '/job/work/', {
      method: 'put',
      data: data
    });
  },
  getSearchName(data) { // 根据姓名查询用户
      return axios(ip + '/pas/user/name/' + data, {
        method: 'get'
      });
  },
  postDownload(data) { // 下载附件
    return axios(ip + '/files/download?fileId=' + data.fileId, {
      method: 'post',
      responseType: 'arraybuffer'
    });
  },
  getAsyncId(data) { // 同步根据id查询用户
    return axios(ip + '/pas/user/' + data, {
      method: 'get',
      async: false
    })
  },
  getAsyncMenu() { // 同步获得所有菜单权限
    return axios(ip + '/pas/menu', {
      method: 'get',
      async: false
    })
  },
  deleteAtta(data) { // 根据id删除附件
    return axios(ip + '/job/attachment/' + data, {
      method: 'delete'
    })
  },
  completeTime (data) { // 修改预计完成时间
    return axios(ip + '/job/work/completeTime', {
      method: 'post',
      data: data
    })
  },
  timeHistory(data) { // 修改预计完成时间
    return axios(ip + '/time/history?id=' + data,{
      method: 'get'
    });
  },
  postSelectOtherNoRead(data) { // 获取工作台其他列表
    return axios(ip + '/read/selectOtherNORead?id=' + data.id + '&page=' + data.page + '&size=' + data.size, {
      method: 'post'
    });
  }
};

export default requests;
