responseDecorator.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { openApiRes } from '@/api/openApi/type'
  2. import { def } from '@vue/shared'
  3. import { Color } from 'XrFrame/xrFrameSystem'
  4. type openApiGanZhiGet8ziByDate = openApiRes.openApiGanZhiGet8ziByDate["data"]
  5. interface ganZhiGet8ziByDate extends openApiGanZhiGet8ziByDate {
  6. ganZhiProRowVoList: openApiGanZhiGet8ziByDate["ganZhiRowVoList"][]
  7. }
  8. const textSwitchColor = (text: string) => {
  9. let color = '#333'
  10. switch (text) {
  11. case '棕':
  12. color = '#9C4B08'
  13. break;
  14. case '红':
  15. color = '#CB2C00'
  16. break;
  17. case '绿':
  18. color = '#53996B'
  19. break;
  20. case '蓝':
  21. color = '#006494'
  22. break;
  23. case '黄':
  24. color = '#D19C03'
  25. break;
  26. default:
  27. color = '#333'
  28. }
  29. return color
  30. }
  31. const get8ziByDateDecorator = function (responseData: openApiRes.openApiGanZhiGet8ziByDate["data"]) {
  32. const respData: ganZhiGet8ziByDate = {
  33. ...responseData,
  34. ganZhiProRowVoList: []
  35. }
  36. for (let index = 0; index < (respData.ganZhiRowVoList.length / 2); index++) {
  37. const element1 = respData.ganZhiRowVoList[index * 2];
  38. const element2 = respData.ganZhiRowVoList[index * 2 + 1];
  39. element1.textColor = textSwitchColor(element1.color)
  40. element2.textColor = textSwitchColor(element2.color)
  41. respData.ganZhiProRowVoList.push([element1, element2])
  42. }
  43. return respData
  44. }
  45. export default {
  46. get8ziByDateDecorator
  47. }