assistCheck.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. SEARCH_HOSPITAL_PAC,
  10. SEARCH_HOSPITAL_PAC_SON,
  11. SET_ALLCHECKS,
  12. SELECT_ONE_CHECKS,
  13. SHOW_IN_ICSSS
  14. } from '../types/assistCheck';
  15. import store from '@store';
  16. const initSearchList = {
  17. list: [], //点击的结果
  18. assistLabel: [], //搜索的结果
  19. dataString: '', //结果拼接
  20. assistVal: '',
  21. hospitalPac: [], //医院检索到的
  22. hospitalPacObj: {}, //组对应的明细(单选多选全选)
  23. selectGroupList: [], //选的组的明细可能有多个组
  24. allCheck: false, //全选反选
  25. checkedList: [], //选中的小项
  26. msgObj:{
  27. name:'',
  28. patientNum:''
  29. }
  30. }
  31. import { getCurrentDate} from '@utils/tools';
  32. export default (state = initSearchList, action) => {
  33. if (action.type == SHOW_IN_ICSSS) {
  34. const newState = Object.assign({}, state);
  35. let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
  36. let tempArrs = newState.assistLabel,tmpString ='';
  37. for (let i = 0; i < tmpGroup.length; i++) {
  38. for (let k = 0; k < tmpGroup[i].pacsResultDTO.length; k++) {
  39. let tmpObj = {}
  40. tmpObj.time = tmpGroup[i].Rtime
  41. tmpObj.name = tmpGroup[i].pacsResultDTO[k].checkItem
  42. tmpObj.value = tmpGroup[i].pacsResultDTO[k].imagingResults
  43. tmpObj.imagingDiagnose = tmpGroup[i].pacsResultDTO[k].imagingDiagnose
  44. tempArrs.push(tmpObj)
  45. }
  46. }
  47. for (let j = 0; j < tempArrs.length; j++) {
  48. let tmpVal = tempArrs[j].value ? tempArrs[j].value.trim() : tempArrs[j].value;
  49. tmpString += (tempArrs[j].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArrs[j].time ? '报告日期:' + tempArrs[j].time : '') + ';')
  50. }
  51. newState.assistLabel = [...tempArrs]
  52. newState.dataString = tmpString
  53. newState.hospitalPac = [] //医院检索到的
  54. newState.hospitalPacObj = {} //组对应的明细(单选多选全选)
  55. newState.selectGroupList = [] //选的组的明细可能有多个组
  56. newState.allCheck = false //全选反选
  57. newState.checkedList = [] //选中的小项
  58. newState.msgObj={name:'',patientNum:''}
  59. return newState;
  60. }
  61. if (action.type == SELECT_ONE_CHECKS) {
  62. const newState = Object.assign({}, state);
  63. let listWrap = JSON.parse(JSON.stringify(newState.hospitalPacObj))
  64. let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
  65. let tmpLen = listWrap.pacsResultDTO.length;
  66. let tmpCheckedLis = JSON.parse(JSON.stringify(newState.checkedList))
  67. let numS = 0;
  68. if (tmpCheckedLis.indexOf(action.name) == -1) { //添加选中
  69. let tempArr = newState.checkedList;
  70. tempArr.push(action.name);
  71. newState.checkedList = [...tempArr]
  72. for (let m = 0; m < tmpGroup.length; m++) {
  73. if (tmpGroup[m].checkItem == action.checkItem) { //右侧有选中相同组的明细
  74. tmpGroup[m].pacsResultDTO.push(action.item)
  75. } else {
  76. ++numS
  77. }
  78. }
  79. if (numS == tmpGroup.length) { //直接添加到右侧
  80. listWrap.pacsResultDTO = []
  81. listWrap.pacsResultDTO.push(action.item)
  82. tmpGroup.push(listWrap)
  83. }
  84. newState.selectGroupList = [...tmpGroup] //右侧已选中的项目
  85. if (tempArr.length == tmpLen) {
  86. newState.allCheck = true;
  87. } else {
  88. newState.allCheck = false;
  89. }
  90. } else { //去除选中
  91. let tempArr = newState.checkedList;
  92. tempArr.splice(tempArr.findIndex(item => item === action.name), 1)
  93. newState.checkedList = [...tempArr]
  94. for (let i = 0; i < tmpGroup.length; i++) {
  95. if (tmpGroup[i].checkItem == action.checkItem) { //右侧肯定有相同组的
  96. let tmpArr = []
  97. for (let k = 0; k < tmpGroup[i].pacsResultDTO.length; k++) {
  98. if (action.name != tmpGroup[i].pacsResultDTO[k].checkItem) {
  99. tmpArr.push(tmpGroup[i].pacsResultDTO[k])
  100. }
  101. }
  102. if(tmpArr.length == 0){
  103. tmpGroup.splice(i,1)
  104. }else{
  105. tmpGroup[i].pacsResultDTO = [...tmpArr]
  106. }
  107. }
  108. }
  109. newState.selectGroupList = tmpGroup //右侧已选中的项目
  110. if (tempArr.length == listWrap.pacsResultDTO.length) {
  111. newState.allCheck = true;
  112. } else {
  113. newState.allCheck = false;
  114. }
  115. }
  116. return newState;
  117. }
  118. if (action.type == SET_ALLCHECKS) {
  119. const newState = Object.assign({}, state);
  120. let flg = newState.allCheck
  121. let listWrap = newState.hospitalPacObj
  122. let tmpGroup = newState.selectGroupList
  123. let tmpCheckedLis = []
  124. newState.allCheck = !flg
  125. if (!flg) { //全选
  126. let numFst = 0
  127. for (let i = 0; i < tmpGroup.length; i++) {
  128. if (listWrap.checkItem == tmpGroup[i].checkItem) {
  129. ++numFst
  130. tmpGroup[i].pacsResultDTO = listWrap.pacsResultDTO
  131. }
  132. }
  133. for (let m = 0; m < listWrap.pacsResultDTO.length; m++) {
  134. tmpCheckedLis.push(listWrap.pacsResultDTO[m].checkItem)
  135. }
  136. if (numFst == 0) {
  137. tmpGroup.push(listWrap)
  138. }
  139. newState.checkedList = [...tmpCheckedLis]
  140. newState.selectGroupList = [...tmpGroup]
  141. } else { //反选
  142. for (let j = 0; j < tmpGroup.length; j++) {
  143. if (listWrap.checkItem == tmpGroup[j].checkItem) {
  144. tmpGroup.splice(j, 1)
  145. }
  146. }
  147. newState.checkedList = []
  148. newState.selectGroupList = [...tmpGroup]
  149. }
  150. return newState;
  151. }
  152. if (action.type == SEARCH_HOSPITAL_PAC_SON) {
  153. const newState = Object.assign({}, state);
  154. let tmpArr = action.list
  155. let tmpSelect = newState.selectGroupList
  156. let tmpSelectSon = []
  157. for (let i = 0; i < tmpSelect.length; i++) {
  158. if (tmpSelect[i].checkItem == action.name) {
  159. for (let k = 0; k < tmpSelect[i].pacsResultDTO.length; k++) {
  160. tmpSelectSon.push(tmpSelect[i].pacsResultDTO[k].checkItem)
  161. }
  162. }
  163. }
  164. newState.checkedList = [...tmpSelectSon]
  165. if (tmpSelectSon.length == tmpArr.pacsResultDTO.length) {
  166. newState.allCheck = true;
  167. } else {
  168. newState.allCheck = false;
  169. }
  170. newState.hospitalPacObj = tmpArr
  171. return newState;
  172. }
  173. if (action.type == SEARCH_HOSPITAL_PAC) {
  174. const newState = Object.assign({}, state);
  175. newState.hospitalPac = action.list
  176. newState.msgObj = action.msg
  177. newState.allCheck = false
  178. newState.hospitalPacObj = {}
  179. return newState;
  180. }
  181. if (action.type == ADD_ASSIST_LABEL) {
  182. const newState = Object.assign({}, state);
  183. let tempArr = newState.assistLabel,
  184. tmpString = '';
  185. for (let i = 0; i < action.lis.length; i++) {
  186. tempArr.push(action.lis[i]);
  187. }
  188. for (let i = 0; i < tempArr.length; i++) {
  189. if (i == action.idx) {
  190. tempArr[i].time = action.date
  191. newState.assistLabel = [...tempArr]
  192. }
  193. let tmpVal = tempArr[i].value ? tempArr[i].value.trim() : tempArr[i].value;
  194. tmpString += (tempArr[i].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArr[i].time ? '报告日期:' + tempArr[i].time : '') + ';')
  195. }
  196. newState.assistLabel = [...tempArr]
  197. newState.dataString = tmpString
  198. return newState;
  199. }
  200. if (action.type == GET_ASSIST_SEARCH_LIST) { //右侧推送添加到左侧
  201. const newState = Object.assign({}, state);
  202. newState.list = action.list
  203. newState.assistVal = action.val
  204. return newState;
  205. }
  206. if (action.type == GET_ASSIST_LABEL) { //默认
  207. const newState = Object.assign({}, state);
  208. const tempArrs = newState.assistLabel;
  209. let tempArr = [];
  210. let tmpString = '';
  211. let tmpCommonLis = store.getState().homePage.assistList;
  212. if (action.sign == 'common') {
  213. let tmpAssistList = JSON.parse(JSON.stringify(tmpCommonLis))
  214. tempArr = tmpAssistList;
  215. } else {
  216. tempArr = newState.list
  217. }
  218. for (let i = 0; i < tempArr.length; i++) {
  219. if (tempArr[i].questionId == action.id && i == action.idx) {
  220. tempArr[i].time = getCurrentDate(1);
  221. tempArrs.push(tempArr[i]);
  222. newState.assistLabel = [...tempArrs];
  223. }
  224. }
  225. for (let j = 0; j < tempArrs.length; j++) {
  226. let tmpVal = tempArrs[j].value ? tempArrs[j].value.trim() : tempArrs[j].value;
  227. tmpString += (tempArrs[j].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArrs[j].time ? '报告日期:' + tempArrs[j].time : '') + ';')
  228. }
  229. newState.dataString = tmpString
  230. return newState;
  231. }
  232. if (action.type == DEL_ASSIST_LABEL) { //删除
  233. const newState = Object.assign({}, state);
  234. let tempArr = newState.assistLabel,
  235. tempArrs = [];
  236. let tmpString = '';
  237. // tempArr.splice(action.idx, 1)
  238. // let tempArrs = tempArr.slice()
  239. for (let k = 0; k < tempArr.length; k++) {
  240. if (k != action.idx) {
  241. tempArrs.push(tempArr[k])
  242. }
  243. }
  244. if (tempArrs == []) {
  245. tmpString == ''
  246. return
  247. }
  248. for (let i = 0; i < tempArrs.length; i++) {
  249. let tmpVal = tempArrs[i].value ? tempArrs[i].value.trim() : tempArrs[i].value;
  250. tmpString += (tempArrs[i].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArrs[i].time ? '报告日期:' + tempArrs[i].time : '') + ';')
  251. }
  252. newState.assistLabel = [...tempArrs]
  253. newState.dataString = tmpString
  254. return newState;
  255. }
  256. if (action.type == CHANGE_ASSIST_VAL) { //改变输入值
  257. const newState = Object.assign({}, state);
  258. const tempArr = newState.assistLabel;
  259. let tmpString = '';
  260. for (let i = 0; i < tempArr.length; i++) {
  261. if (i == action.idx) {
  262. tempArr[i].value = action.val
  263. newState.assistLabel = [...tempArr]
  264. }
  265. let tmpVal = tempArr[i].value ? tempArr[i].value.trim() : tempArr[i].value;
  266. tmpString += (tempArr[i].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArr[i].time ? '报告日期:' + tempArr[i].time : '') + ';')
  267. }
  268. newState.dataString = tmpString
  269. return newState;
  270. }
  271. if (action.type == CHANGE_DATE) { //新增
  272. const newState = Object.assign({}, state);
  273. const tempArr = newState.assistLabel;
  274. let tmpString = '';
  275. for (let i = 0; i < tempArr.length; i++) {
  276. if (i == action.idx) {
  277. tempArr[i].time = action.date
  278. newState.assistLabel = [...tempArr]
  279. }
  280. let tmpVal = tempArr[i].value ? tempArr[i].value.trim() : tempArr[i].value;
  281. tmpString += (tempArr[i].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArr[i].time ? '报告日期:' + tempArr[i].time : '') + ';')
  282. }
  283. newState.dataString = tmpString
  284. return newState;
  285. }
  286. if (action.type == CLEAR_ASSIST_DATA) {
  287. const newState = Object.assign({}, state);
  288. newState.assistLabel = [...action.data];
  289. newState.dataString = action.saveText;
  290. return newState;
  291. }
  292. return state;
  293. }