diagnosticList.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. export const addDiagnostic = (state, action) => {
  2. const res = JSON.parse(JSON.stringify(state));
  3. res.diagnosticList.push(action.item)
  4. return res;
  5. }
  6. export const delDiagnostic = (state, action) => {
  7. const res = JSON.parse(JSON.stringify(state));
  8. res.diagnosticList = res.diagnosticList.filter(item => (item.id !== action.item.id && item.name !== action.item.name));
  9. return res;
  10. }
  11. export const upDiagnostic = (state, action) => {
  12. const res = JSON.parse(JSON.stringify(state));
  13. const index = action.index;
  14. if ( index === 0) {
  15. return res
  16. }
  17. const temp = res.diagnosticList[index-1];
  18. res.diagnosticList[index-1] =res.diagnosticList[index];
  19. res.diagnosticList[index] = temp;
  20. return res;
  21. }
  22. export const downDiagnostic = (state, action) => {
  23. const res = JSON.parse(JSON.stringify(state));
  24. const index = action.index;
  25. if ( index === state.length-1) {
  26. return res
  27. }
  28. const temp = res.diagnosticList[index+1];
  29. res.diagnosticList[index+1] = res.diagnosticList[index];
  30. res.diagnosticList[index] = temp;
  31. return res;
  32. }
  33. export const setTreat = (state, action) => {
  34. const res = JSON.parse(JSON.stringify(state));
  35. const resLength = res.diagnosticList.length;
  36. res.diagnosticList[resLength-1].treat = action.treat;
  37. return res;
  38. }
  39. function getDiagType(type) {
  40. if (type === 1) {
  41. return '初诊'
  42. } else {
  43. return '复诊'
  44. }
  45. }
  46. export const getDiagnosticStr = (state, action) => {
  47. const res = Object.assign({}, state)
  48. const diagnosticList = res.diagnosticList
  49. let diagnosticStr= '';
  50. let diagnosticStrNoType = ''
  51. for (let i = 0; i < diagnosticList.length; i++) {
  52. diagnosticStr = diagnosticStr + diagnosticList[i].name + '(' + getDiagType(diagnosticList[i].type) + '); '
  53. diagnosticStrNoType = diagnosticStrNoType + diagnosticList[i].name + ','
  54. }
  55. res.diagnosticStrNoType = diagnosticStrNoType
  56. res.diagnosticStr = diagnosticStr
  57. return res;
  58. }
  59. export const setDiagToMainSuit = (state, action) => {
  60. const res = Object.assign({}, state);
  61. res.mainSuitStr = action.data;
  62. return res;
  63. }
  64. export const clearAllDiag = (state, action) => {
  65. const res = Object.assign({}, state);
  66. res.diagnosticList = action.data
  67. res.diagnosticStr = action.saveText
  68. res.mainSuitStr = action.mainSuitStr
  69. res.diagnosticStrNoType = action.saveText
  70. res.chronicMagItem = action.chronicMagItem
  71. return res;
  72. }
  73. export const setClickDiag = (state, action) => {
  74. const res = Object.assign({}, state);
  75. res.clickDiag = action.clickDiag
  76. return res;
  77. }
  78. export const setChronicMagItem = (state, action) => {
  79. const res = Object.assign({}, state);
  80. res.chronicMagItem = action.chronicMagItem
  81. return res;
  82. }
  83. export const showReferRecord = (state, action) => {
  84. const res = Object.assign({}, state);
  85. res.showReferRecord = true
  86. return res;
  87. }
  88. export const hideReferRecord = (state, action) => {
  89. const res = Object.assign({}, state);
  90. res.showReferRecord = false
  91. return res;
  92. }
  93. export const showHistoryCase = (state, action) => {
  94. const res = Object.assign({}, state);
  95. res.showHistoryCase = true
  96. return res;
  97. }
  98. export const hideHistoryCase = (state, action) => {
  99. const res = Object.assign({}, state);
  100. res.showHistoryCase = false
  101. return res;
  102. }