commonMeth.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { getCommon, getByDictType } from '../api/main';
  2. import { IOptions } from '../types/global';
  3. export function outTypeList(type: string) {
  4. const typeList: Array<IOptions> = [];
  5. getCommon(type).then(res => {
  6. res.data.forEach((item: any) => {
  7. typeList.push({
  8. label: item.dictLabel,
  9. value: item.dictValue,
  10. });
  11. });
  12. });
  13. return typeList;
  14. }
  15. export function outDictTypeList(type: string) {
  16. const typeList: Array<IOptions> = [];
  17. getByDictType(type).then(res => {
  18. res.data.forEach((item: any) => {
  19. typeList.push({
  20. label: item.dictLabel,
  21. value: item.dictValue,
  22. });
  23. });
  24. });
  25. return typeList;
  26. }
  27. export function computedTypeList(type: string) {
  28. const dictList: Array<IOptions> = [];
  29. const globalList: Array<IOptions> = [];
  30. getByDictType(type).then(res => {
  31. res.data.dictList.forEach((item: any) => {
  32. dictList.push({
  33. label: item.dictLabel,
  34. value: item.dictValue,
  35. });
  36. });
  37. res.data.globalList.forEach((item: any) => {
  38. globalList.push({
  39. label: item.name,
  40. value: item.key,
  41. });
  42. });
  43. });
  44. return {
  45. dictList,
  46. globalList,
  47. };
  48. }