common.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import {
  2. postJ,
  3. post,
  4. get
  5. } from '@/utils/request'
  6. import Vue from 'vue'
  7. /**
  8. * 登录
  9. */
  10. export async function login(data) {
  11. const res = await postJ(Vue.prototype.apiUrl + '/main/user/login', data)
  12. if (res.code == 0) {
  13. return res
  14. }
  15. return Promise.reject(res.message)
  16. }
  17. /**
  18. * 获取用户信息
  19. */
  20. export async function getLoginUser(data) {
  21. const res = await get(Vue.prototype.apiUrl + '/system/account/getLoginUser', data)
  22. if (res.code == 0) {
  23. return res.data
  24. }
  25. return Promise.reject(res.message)
  26. }
  27. // 公司名称
  28. export async function usName() {
  29. const data = await get(Vue.prototype.apiUrl + `/pda/mes/us/indexName`)
  30. if (data.code == 0) {
  31. return data.data
  32. }
  33. return Promise.reject(data.message)
  34. }
  35. // 工序列表
  36. export async function producetaskList() {
  37. const data = await get(Vue.prototype.apiUrl + `/main/producetask/list`)
  38. if (data.code == 0) {
  39. return data.data
  40. }
  41. return Promise.reject(data.message)
  42. }
  43. /**
  44. * 查询机构列表
  45. * @param params 查询条件
  46. */
  47. export async function listOrganizations(params) {
  48. const res = await get(Vue.prototype.apiUrl + `/main/group/getGroupList`, params)
  49. console.log(res.code, '=====')
  50. if (res.code == 0) {
  51. return res.data
  52. }
  53. return Promise.reject(new Error(res.message))
  54. }
  55. /**
  56. * 查询人员列表
  57. * @param params 查询条件
  58. */
  59. export async function getUserPage(params) {
  60. // let par = new URLSearchParams(params);
  61. const res = await get(Vue.prototype.apiUrl + `/main/user/getUserPage`, params)
  62. if (res.code == 0) {
  63. return res.data
  64. }
  65. return Promise.reject(new Error(res.message))
  66. }
  67. /**
  68. * 获取所有用户
  69. *
  70. */
  71. export async function listAllUserBind() {
  72. const res = await get(Vue.prototype.apiUrl + `/main/user/listAllUserBind`)
  73. if (res.code == 0) {
  74. return res.data
  75. }
  76. return Promise.reject(new Error(res.message))
  77. }
  78. /**
  79. * 获取部门所有父级
  80. *
  81. */
  82. export async function getParentIdListByDeptId(id) {
  83. const res = await get(Vue.prototype.apiUrl + `/main/group/getParentIdListById/${id}`)
  84. if (res.code == 0) {
  85. return res.data
  86. }
  87. return Promise.reject(new Error(res.message))
  88. }
  89. // 获取字典
  90. export async function getDictByCode(code) {
  91. const data = await get(
  92. Vue.prototype.apiUrl + `/system/dict/getByCode/${code}`,
  93. );
  94. if (data.code == 0) {
  95. return data.data;
  96. }
  97. return Promise.reject(data.message);
  98. }