wrapModalBodyPac.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import {
  2. SEARCH_HOSPITAL_PAC,
  3. SEARCH_HOSPITAL_PAC_SON,
  4. SET_ALLCHECKS,
  5. SELECT_ONE_CHECKS,
  6. SHOW_IN_ICSSS
  7. } from '../types/wrapModalBodyPac';
  8. import {getAllString} from '@utils/tools.js';
  9. import store from '@store';
  10. import { getMRAnalyse } from '@store/async-actions/pushMessage';
  11. const initSearchList = {
  12. list: [], //点击的结果
  13. assistLabel: [], //搜索的结果
  14. dataString: '', //结果拼接
  15. assistVal: '',
  16. checkedListImport: [], //辅检导入
  17. hospitalPac: [], //医院检索到的
  18. hospitalPacObj: {}, //组对应的明细(单选多选全选)
  19. selectGroupList: [], //选的组的明细可能有多个组
  20. allCheck: false, //全选反选
  21. checkedList: [], //选中的小项
  22. allCheckLis:[],//所有导入数据
  23. msgObj:{
  24. name:'',
  25. patientNum:''
  26. }
  27. }
  28. export default (state = initSearchList, action) => {
  29. if (action.type == SHOW_IN_ICSSS) {
  30. let allState = store.getState().assistCheck;
  31. const newState = Object.assign({}, state);
  32. let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
  33. let tmpListImport = JSON.parse(JSON.stringify(allState.checkedListImport))
  34. let tempArrs = JSON.parse(JSON.stringify(allState.assistLabel)),importLis=[];
  35. for (let i = 0; i < tmpGroup.length; i++) {
  36. for (let k = 0; k < tmpGroup[i].pacsResultDTO.length; k++) {
  37. let tmpObj = {}
  38. tmpObj.time = tmpGroup[i].Rtime
  39. tmpObj.disabled = true
  40. tmpObj.name = tmpGroup[i].pacsResultDTO[k].checkItem
  41. tmpObj.value = tmpGroup[i].pacsResultDTO[k].imagingResults
  42. tmpObj.imagingDiagnose = tmpGroup[i].pacsResultDTO[k].imagingDiagnose
  43. importLis.push(tmpObj)
  44. tempArrs.push(tmpObj)
  45. }
  46. }
  47. if(JSON.stringify(importLis) != '[]'){
  48. tmpListImport.push(importLis)
  49. }
  50. allState.checkedListImport = [...tmpListImport]
  51. allState.allCheckLis = [...tempArrs]
  52. allState.dataString = getAllString(tmpListImport,allState.assistLabel)
  53. newState.hospitalPac = [] //医院检索到的
  54. newState.hospitalPacObj = {} //组对应的明细(单选多选全选)
  55. newState.selectGroupList = [] //选的组的明细可能有多个组
  56. newState.allCheck = false //全选反选
  57. newState.checkedList = [] //选中的小项
  58. newState.msgObj={name:'',patientNum:''}
  59. if(importLis.length > 0) {
  60. store.dispatch(getMRAnalyse())
  61. }
  62. return newState;
  63. }
  64. if (action.type == SELECT_ONE_CHECKS) {
  65. const newState = Object.assign({}, state);
  66. let listWrap = JSON.parse(JSON.stringify(newState.hospitalPacObj))
  67. let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
  68. let tmpLen = listWrap.pacsResultDTO.length;
  69. let tmpCheckedLis = JSON.parse(JSON.stringify(newState.checkedList))
  70. let numS = 0;
  71. if (tmpCheckedLis.indexOf(action.name) == -1) { //添加选中
  72. let tempArr = newState.checkedList;
  73. tempArr.push(action.name);
  74. newState.checkedList = [...tempArr]
  75. for (let m = 0; m < tmpGroup.length; m++) {
  76. if (tmpGroup[m].checkItem == action.checkItem) { //右侧有选中相同组的明细
  77. tmpGroup[m].pacsResultDTO.push(action.item)
  78. } else {
  79. ++numS
  80. }
  81. }
  82. if (numS == tmpGroup.length) { //直接添加到右侧
  83. listWrap.pacsResultDTO = []
  84. listWrap.pacsResultDTO.push(action.item)
  85. tmpGroup.push(listWrap)
  86. }
  87. newState.selectGroupList = [...tmpGroup] //右侧已选中的项目
  88. if (tempArr.length == tmpLen) {
  89. newState.allCheck = true;
  90. } else {
  91. newState.allCheck = false;
  92. }
  93. } else { //去除选中
  94. let tempArr = newState.checkedList;
  95. tempArr.splice(tempArr.findIndex(item => item === action.name), 1)
  96. newState.checkedList = [...tempArr]
  97. for (let i = 0; i < tmpGroup.length; i++) {
  98. if (tmpGroup[i].checkItem == action.checkItem) { //右侧肯定有相同组的
  99. let tmpArr = []
  100. for (let k = 0; k < tmpGroup[i].pacsResultDTO.length; k++) {
  101. if (action.name != tmpGroup[i].pacsResultDTO[k].checkItem) {
  102. tmpArr.push(tmpGroup[i].pacsResultDTO[k])
  103. }
  104. }
  105. if(tmpArr.length == 0){
  106. tmpGroup.splice(i,1)
  107. }else{
  108. tmpGroup[i].pacsResultDTO = [...tmpArr]
  109. }
  110. }
  111. }
  112. newState.selectGroupList = tmpGroup //右侧已选中的项目
  113. if (tempArr.length == listWrap.pacsResultDTO.length) {
  114. newState.allCheck = true;
  115. } else {
  116. newState.allCheck = false;
  117. }
  118. }
  119. return newState;
  120. }
  121. if (action.type == SET_ALLCHECKS) {
  122. const newState = Object.assign({}, state);
  123. let flg = newState.allCheck
  124. let listWrap = newState.hospitalPacObj
  125. let tmpGroup = newState.selectGroupList
  126. let tmpCheckedLis = []
  127. newState.allCheck = !flg
  128. if (!flg) { //全选
  129. let numFst = 0
  130. for (let i = 0; i < tmpGroup.length; i++) {
  131. if (listWrap.checkItem == tmpGroup[i].checkItem) {
  132. ++numFst
  133. tmpGroup[i].pacsResultDTO = listWrap.pacsResultDTO
  134. }
  135. }
  136. for (let m = 0; m < listWrap.pacsResultDTO.length; m++) {
  137. tmpCheckedLis.push(listWrap.pacsResultDTO[m].checkItem)
  138. }
  139. if (numFst == 0) {
  140. tmpGroup.push(listWrap)
  141. }
  142. newState.checkedList = [...tmpCheckedLis]
  143. newState.selectGroupList = [...tmpGroup]
  144. } else { //反选
  145. for (let j = 0; j < tmpGroup.length; j++) {
  146. if (listWrap.checkItem == tmpGroup[j].checkItem) {
  147. tmpGroup.splice(j, 1)
  148. }
  149. }
  150. newState.checkedList = []
  151. newState.selectGroupList = [...tmpGroup]
  152. }
  153. return newState;
  154. }
  155. if (action.type == SEARCH_HOSPITAL_PAC_SON) {
  156. const newState = Object.assign({}, state);
  157. let tmpArr = action.list
  158. let tmpSelect = newState.selectGroupList
  159. let tmpSelectSon = []
  160. for (let i = 0; i < tmpSelect.length; i++) {
  161. if (tmpSelect[i].checkItem == action.name) {
  162. for (let k = 0; k < tmpSelect[i].pacsResultDTO.length; k++) {
  163. tmpSelectSon.push(tmpSelect[i].pacsResultDTO[k].checkItem)
  164. }
  165. }
  166. }
  167. newState.checkedList = [...tmpSelectSon]
  168. if (tmpSelectSon.length == tmpArr.pacsResultDTO.length) {
  169. newState.allCheck = true;
  170. } else {
  171. newState.allCheck = false;
  172. }
  173. newState.hospitalPacObj = tmpArr
  174. return newState;
  175. }
  176. if (action.type == SEARCH_HOSPITAL_PAC) {
  177. const newState = Object.assign({}, state);
  178. newState.hospitalPac = action.list
  179. newState.msgObj = action.msg
  180. newState.allCheck = false
  181. newState.hospitalPacObj = {}
  182. return newState;
  183. }
  184. return state;
  185. }