assistCheck.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. checkedListImport: [], //辅检导入
  27. allCheckLis:[],//所有导入数据
  28. msgObj:{
  29. name:'',
  30. patientNum:''
  31. }
  32. }
  33. import { getCurrentDate} from '@utils/tools';
  34. export default (state = initSearchList, action) => {
  35. if (action.type == SHOW_IN_ICSSS) {
  36. const newState = Object.assign({}, state);
  37. let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
  38. let tmpListImport = JSON.parse(JSON.stringify(newState.checkedListImport))
  39. let tempArrs = JSON.parse(JSON.stringify(newState.assistLabel)),importLis=[];
  40. for (let i = 0; i < tmpGroup.length; i++) {
  41. for (let k = 0; k < tmpGroup[i].pacsResultDTO.length; k++) {
  42. let tmpObj = {}
  43. tmpObj.time = tmpGroup[i].Rtime
  44. tmpObj.disabled = true
  45. tmpObj.name = tmpGroup[i].pacsResultDTO[k].checkItem
  46. tmpObj.value = tmpGroup[i].pacsResultDTO[k].imagingResults
  47. tmpObj.imagingDiagnose = tmpGroup[i].pacsResultDTO[k].imagingDiagnose
  48. importLis.push(tmpObj)
  49. tempArrs.push(tmpObj)
  50. }
  51. }
  52. tmpListImport.push(importLis)
  53. newState.checkedListImport = [...tmpListImport]
  54. newState.allCheckLis = [...tempArrs]
  55. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  56. newState.hospitalPac = [] //医院检索到的
  57. newState.hospitalPacObj = {} //组对应的明细(单选多选全选)
  58. newState.selectGroupList = [] //选的组的明细可能有多个组
  59. newState.allCheck = false //全选反选
  60. newState.checkedList = [] //选中的小项
  61. newState.msgObj={name:'',patientNum:''}
  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. if (action.type == ADD_ASSIST_LABEL) {
  185. const newState = Object.assign({}, state);
  186. let tempArr = newState.assistLabel;
  187. for (let i = 0; i < action.lis.length; i++) {
  188. tempArr.push(action.lis[i]);
  189. }
  190. for (let i = 0; i < tempArr.length; i++) {
  191. if (i == action.idx) {
  192. tempArr[i].time = action.date
  193. newState.assistLabel = [...tempArr]
  194. }
  195. }
  196. newState.assistLabel = [...tempArr]
  197. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  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. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  205. return newState;
  206. }
  207. if (action.type == GET_ASSIST_LABEL) { //默认
  208. const newState = Object.assign({}, state);
  209. const tempArrs = newState.assistLabel;
  210. let tempArr = [];
  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].conceptId == action.id && i == action.idx) {
  220. tempArr[i].time = getCurrentDate(1);
  221. tempArrs.push(tempArr[i]);
  222. newState.assistLabel = [...tempArrs];
  223. }
  224. }
  225. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  226. return newState;
  227. }
  228. if (action.type == DEL_ASSIST_LABEL) { //删除
  229. const newState = Object.assign({}, state);
  230. let tempArr = newState.assistLabel,tempArrs = [];
  231. let tmpImportLis = newState.checkedListImport;
  232. if(action.flg == 0){//删除辅检导入
  233. tmpImportLis.splice(action.idx,1)
  234. }else{
  235. for (let k = 0; k < tempArr.length; k++) {
  236. if (k != action.idx) {
  237. tempArrs.push(tempArr[k])
  238. }
  239. }
  240. newState.assistLabel = [...tempArrs]
  241. }
  242. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  243. return newState;
  244. }
  245. if (action.type == CHANGE_ASSIST_VAL) { //改变输入值
  246. const newState = Object.assign({}, state);
  247. const tempArr = newState.assistLabel;
  248. for (let i = 0; i < tempArr.length; i++) {
  249. if (i == action.idx) {
  250. tempArr[i].value = action.val
  251. newState.assistLabel = [...tempArr]
  252. }
  253. }
  254. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  255. return newState;
  256. }
  257. if (action.type == CHANGE_DATE) { //新增
  258. const newState = Object.assign({}, state);
  259. const tempArr = newState.assistLabel;
  260. for (let i = 0; i < tempArr.length; i++) {
  261. if (i == action.idx) {
  262. tempArr[i].time = action.date
  263. newState.assistLabel = [...tempArr]
  264. }
  265. }
  266. newState.dataString = getAllString(newState.checkedListImport,newState.assistLabel)
  267. return newState;
  268. }
  269. if (action.type == CLEAR_ASSIST_DATA) {
  270. const newState = Object.assign({}, state);
  271. newState.assistLabel = [...action.data];
  272. newState.dataString = action.saveText;
  273. newState.checkedListImport = action.checkedListImport;
  274. return newState;
  275. }
  276. return state;
  277. }
  278. function getAllString(checkedListImport,assistLabel){
  279. let tmpImportLis = [],tmpString='';
  280. for(let i = 0;i < checkedListImport.length;i++){
  281. for(let j = 0;j < checkedListImport[i].length;j++){
  282. tmpImportLis.push(checkedListImport[i][j])
  283. }
  284. }
  285. let tempArr = tmpImportLis.concat(assistLabel)
  286. for (let i = 0; i < tempArr.length; i++) {
  287. let tmpVal = tempArr[i].value ? tempArr[i].value.trim() : tempArr[i].value;
  288. tmpString += (tempArr[i].name + (tmpVal ? (':' + tmpVal) + ', ' : ': ') + (tempArr[i].time ? '报告日期:' + tempArr[i].time : '') + ';')
  289. }
  290. return tmpString;
  291. }