assistCheck.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import {
  2. GET_ASSIST_SEARCH_LIST,
  3. GET_ASSIST_LABEL,
  4. DEL_ASSIST_LABEL,
  5. CHANGE_ASSIST_VAL,
  6. CHANGE_DATE,
  7. CLEAR_ASSIST_DATA,
  8. ADD_ASSIST_LABEL
  9. } from '../types/assistCheck';
  10. import store from '@store';
  11. const initSearchList = {
  12. list: [], //点击的结果
  13. assistLabel: [], //搜索的结果
  14. dataString: '', //结果拼接
  15. dataArr: [], //结果拼接
  16. assistVal: '',
  17. hospitalPac: [], //医院检索到的
  18. hospitalPacObj: {}, //组对应的明细(单选多选全选)
  19. selectGroupList: [], //选的组的明细可能有多个组
  20. allCheck: false, //全选反选
  21. checkedList: [], //选中的小项
  22. checkedListImport: [], //辅检导入
  23. allCheckLis:[],//所有导入数据
  24. msgObj:{
  25. name:'',
  26. patientNum:''
  27. }
  28. }
  29. import { getCurrentDate,getAllString} from '@utils/tools';
  30. export default (state = initSearchList, action) => {
  31. if (action.type == ADD_ASSIST_LABEL) {
  32. const newState = Object.assign({}, state);
  33. let tempArr = newState.assistLabel;
  34. for (let i = 0; i < action.lis.length; i++) {
  35. tempArr.push(action.lis[i]);
  36. }
  37. for (let i = 0; i < tempArr.length; i++) {
  38. if (i == action.idx) {
  39. tempArr[i].time = action.date
  40. newState.assistLabel = [...tempArr]
  41. }
  42. }
  43. newState.assistLabel = [...tempArr]
  44. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  45. newState.dataArr = getAllString(newState.checkedListImport,newState.assistLabel,1)
  46. return newState;
  47. }
  48. if (action.type == GET_ASSIST_SEARCH_LIST) { //右侧推送添加到左侧
  49. const newState = Object.assign({}, state);
  50. newState.list = action.list
  51. newState.assistVal = action.val
  52. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  53. newState.dataArr = getAllString(newState.checkedListImport,newState.assistLabel,1)
  54. return newState;
  55. }
  56. if (action.type == GET_ASSIST_LABEL) { //默认
  57. const newState = Object.assign({}, state);
  58. const tempArrs = newState.assistLabel;
  59. let tempArr = [];
  60. let tmpCommonLis = store.getState().homePage.assistList;
  61. if (action.sign == 'common') {
  62. let tmpAssistList = JSON.parse(JSON.stringify(tmpCommonLis))
  63. tempArr = tmpAssistList;
  64. } else {
  65. tempArr = newState.list
  66. }
  67. for (let i = 0; i < tempArr.length; i++) {
  68. if (tempArr[i].conceptId == action.id && i == action.idx) {
  69. tempArr[i].time = getCurrentDate(1);
  70. tempArrs.push(tempArr[i]);
  71. newState.assistLabel = [...tempArrs];
  72. }
  73. }
  74. newState.dataArr = getAllString(newState.checkedListImport,newState.assistLabel,1)
  75. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  76. return newState;
  77. }
  78. if (action.type == DEL_ASSIST_LABEL) { //删除
  79. const newState = Object.assign({}, state);
  80. let tempArr = newState.assistLabel,tempArrs = [];
  81. let tmpImportLis = newState.checkedListImport;
  82. if(action.flg == 0){//删除辅检导入
  83. tmpImportLis.splice(action.idx,1)
  84. }else{
  85. for (let k = 0; k < tempArr.length; k++) {
  86. if (k != action.idx) {
  87. tempArrs.push(tempArr[k])
  88. }
  89. }
  90. newState.assistLabel = [...tempArrs]
  91. }
  92. newState.dataArr = getAllString(newState.checkedListImport,newState.assistLabel,1)
  93. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  94. return newState;
  95. }
  96. if (action.type == CHANGE_ASSIST_VAL) { //改变输入值
  97. const newState = Object.assign({}, state);
  98. const tempArr = newState.assistLabel;
  99. for (let i = 0; i < tempArr.length; i++) {
  100. if (i == action.idx) {
  101. tempArr[i].value = action.val
  102. newState.assistLabel = [...tempArr]
  103. }
  104. }
  105. newState.dataArr = getAllString(newState.checkedListImport,newState.assistLabel,1)
  106. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  107. return newState;
  108. }
  109. if (action.type == CHANGE_DATE) { //新增
  110. const newState = Object.assign({}, state);
  111. const tempArr = newState.assistLabel;
  112. for (let i = 0; i < tempArr.length; i++) {
  113. if (i == action.idx) {
  114. tempArr[i].time = action.date
  115. newState.assistLabel = [...tempArr]
  116. }
  117. }
  118. newState.dataArr = getAllString(newState.checkedListImport,newState.assistLabel,1)
  119. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  120. return newState;
  121. }
  122. if (action.type == CLEAR_ASSIST_DATA) {
  123. const newState = Object.assign({}, state);
  124. newState.assistLabel = [...action.data];
  125. newState.dataString = action.saveText;
  126. newState.checkedListImport = action.checkedListImport;
  127. return newState;
  128. }
  129. return state;
  130. }