SpreadDrop.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. import React ,{Component} from 'react';
  2. import {connect} from 'react-redux';
  3. import SpreadDrop from '@components/SpreadDrop';
  4. import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SETOTHERCHECKBOX,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  5. import {RESET,SETDROPSHOW,HIDEDROP,CLICKCOUNT,ISREAD} from '@store/types/homePage.js';
  6. import {getModules as fetchModules} from '@store/async-actions/fetchModules.js';
  7. import {getCommSymptomPush} from '@store/async-actions/mainSuit.js'
  8. import {GET_BIGDATAPUSH,MIX_CONFIRM,COMM_CONFIRM,CHANGE_LABELVAL} from '@store/types/mainSuit';
  9. import {SETCHECKBOX,CHANGECHECKTEXTLABEL} from '@types/checkBody';
  10. import {CURRENT_CONFIRM,SETMAINCHECKBOX,CURRENT_TEXT_LABEL,CURRENT_GET_BIGDATAPUSH} from '@types/currentIll';
  11. import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
  12. import {Notify} from '@commonComp';
  13. import {filterArr} from '@utils/tools.js';
  14. import config from '@config/index.js';
  15. function mapStateToProps(state) {
  16. return {
  17. mainSaveText:state.mainSuit.saveText,
  18. }
  19. }
  20. function getNames(data,order){//从exist withs 中获取name字段
  21. let nameData = "";
  22. if(+order===1){ //成文默认按点选顺序排序,指定textGenerate=1按从上到下从左到右排序
  23. data.sort(function(a,b){
  24. return a.listIndex-b.listIndex;
  25. });
  26. }
  27. data&&data.forEach((it,i)=>{
  28. nameData += it.name;
  29. });
  30. return nameData;
  31. }
  32. /***********************标签展开确定事件***************************/
  33. // 主诉--不用展开标签
  34. function mainSuitModule(dispatch,store,params){
  35. const {nones,exists,withs,exclusion,excluName,ban,mainSaveText} = params;
  36. let existsName = getNames(exists);
  37. let withsName = getNames(withs);
  38. let banName = ban.name;
  39. let text = filterArr(mainSaveText);
  40. let names;
  41. if(banName){
  42. names = existsName + banName + withsName;
  43. }else{
  44. names = existsName + withsName;
  45. }
  46. let lengths = text.length + names.length;
  47. if(lengths > config.limited){
  48. Notify.info(config.limitText);
  49. return
  50. }
  51. const index = params.ikey;
  52. let ikey = getLabelIndex(index);
  53. dispatch({
  54. type: MIX_CONFIRM,
  55. data: {exists:exists,withs:withs,withsName:withsName,existsName:existsName,ikey,ban}
  56. });
  57. dispatch({ //自由文本标签数据更新
  58. type:ISREAD
  59. });
  60. dispatch({//隐藏下拉
  61. type:HIDEDROP
  62. })
  63. }
  64. // 现病史
  65. function currentIll(dispatch,store,params){
  66. const {nones,exists,withs,exclusion,excluName,ban,noneIds} = params;
  67. // const ikey = params.ikey.substr(1,1);
  68. const index = params.ikey;
  69. let ikey = getLabelIndex(index);
  70. let existsId = getIds(exists);
  71. let withsId = getIds(withs);
  72. // const ids = existsId.join(",")+withsId.join(",");
  73. const ids = (existsId.concat(withsId)).join(",");
  74. let has = [],wes=[];
  75. //获取选中项目模板
  76. fetchModules(ids).then((res)=>{
  77. if(+res.data.code===0){
  78. const list = res.data.data;
  79. existsId.map((i)=>{
  80. // has.push(...list[i].questionMapping);
  81. has.push(list[i]);
  82. });
  83. withsId.map((i)=>{
  84. // wes.push(...list[i].questionMapping);
  85. wes.push(list[i]);
  86. });
  87. dispatch({
  88. type: CURRENT_CONFIRM,
  89. data: {exists:has,withs:wes,nones:nones,ikey,ban,noneIds}
  90. });
  91. dispatch({ //自由文本标签数据更新
  92. type:ISREAD
  93. });
  94. }else{
  95. console.log(res);
  96. }
  97. });
  98. }
  99. //其他史多选标签确定事件
  100. function otherHisConfirm(dispatch,store,params){
  101. const {nones,exists,withs,exclusion,excluName} = params;
  102. // const ikey = params.ikey.substr(1,1);
  103. const index = params.ikey;
  104. let ikey = getLabelIndex(index);
  105. if(params.exclusion){
  106. dispatch({
  107. type: CONFIRMSELECTED,
  108. data:{exclusion,excluName,ikey}
  109. });
  110. return ;
  111. }
  112. let existsId = getIds(exists);
  113. let withsId = getIds(withs);
  114. const ids = existsId.join(",")+withsId.join(",");
  115. // const ids = exists.join(",")+withs.join(",");
  116. let has = [],wes=[];
  117. //获取选中项目模板
  118. fetchModules(ids).then((res)=>{
  119. if(+res.data.code===0){
  120. const list = res.data.data;
  121. existsId.map((i)=>{
  122. if(+list[i].tagType===4){
  123. has.push(...list[i].questionMapping);
  124. }else{
  125. has.push(list[i]);
  126. }
  127. });
  128. withsId.map((i)=>{
  129. if(+list[i].tagType===4){
  130. wes.push(...list[i].questionMapping);
  131. }else{
  132. wes.push(list[i]);
  133. }
  134. });
  135. dispatch({
  136. type: CONFIRMSELECTED,
  137. data: {exists:fullfillText(has,true,false).newArr,withs:fullfillText(wes,true,false).newArr,nones:nones,ikey}
  138. });
  139. dispatch({
  140. type:ISREAD
  141. });
  142. }
  143. });
  144. }
  145. function checkBodyConfirm(dispatch,store,params){
  146. console.log(params)
  147. }
  148. //在不同模块(主诉、现病史等)下拉选中调用不同事件
  149. function handleModuleDiff(dispatch,store,params){
  150. const {type,mainSaveText} = params;
  151. switch (+type){
  152. case 1:
  153. let text = filterArr(mainSaveText);
  154. if(text.length >= config.limited){
  155. Notify.info(config.limitText);
  156. return
  157. }
  158. mainSuitModule(dispatch,store,params);
  159. break;
  160. case 2:
  161. currentIll(dispatch,store,params);
  162. break;
  163. case 3:
  164. otherHisConfirm(dispatch,store,params);
  165. break;
  166. case 4:
  167. checkBodyConfirm(dispatch,store,params);
  168. break;
  169. default:
  170. }
  171. }
  172. /*****************普通多选框确定事件**************************/
  173. //主诉普通多选确定
  174. function mainSuitCheck(dispatch,store,params){
  175. const {nones,exists,withs,order,mainSaveText} = params;
  176. let existsName = getNames(exists,order);
  177. let text = filterArr(mainSaveText);
  178. let lengths = text.length + existsName.length;
  179. if(lengths > config.limited){
  180. Notify.info(config.limitText);
  181. return
  182. }
  183. const index = params.ikey;
  184. let ikey = getLabelIndex(index);
  185. dispatch({
  186. type: COMM_CONFIRM,
  187. data: {exists:exists,existsName:existsName,ikey}
  188. });
  189. dispatch({//隐藏下拉
  190. type:HIDEDROP
  191. })
  192. }
  193. //现病史普通多选确定
  194. function currentCheck(dispatch,store,params){
  195. const {ikey,exclusion,excluName,nones,exists,noneIds,noneOn,nowOn,withOn,withs,order} = params;
  196. let existsName = getNames(exists,order);
  197. let withsName = getNames(withs);
  198. let labelInx = getLabelIndex(ikey);
  199. dispatch({
  200. type:SETMAINCHECKBOX,
  201. data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}
  202. })
  203. }
  204. //查体普通多选确定
  205. function checkBodyCheck(dispatch,store,params){
  206. const {ikey,exclusion,excluName,nones,exists,noneIds,noneOn,nowOn,withOn,withs,order} = params;
  207. let existsName = getNames(exists,order);
  208. let withsName = getNames(withs);
  209. let labelInx = getLabelIndex(ikey);
  210. dispatch({
  211. type:SETCHECKBOX,
  212. data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}
  213. })
  214. }
  215. //其他史普通多选确定
  216. function otherHisCheck(dispatch,store,params){
  217. const {ikey,exclusion,excluName,nones,exists,noneIds,noneOn,nowOn,withOn,withs,order} = params;
  218. let existsName = getNames(exists,order);
  219. let withsName = getNames(withs);
  220. let labelInx = getLabelIndex(ikey);
  221. dispatch({
  222. type:SETOTHERCHECKBOX,
  223. data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}
  224. })
  225. }
  226. function handleCheckBox(dispatch,store,params){
  227. const {type,mainSaveText} = params;
  228. switch (+type){
  229. case 1:
  230. let text = filterArr(mainSaveText);
  231. if(text.length >= config.limited){
  232. Notify.info(config.limitText);
  233. return
  234. }
  235. mainSuitCheck(dispatch,store,params);
  236. break;
  237. case 2:
  238. currentCheck(dispatch,store,params);
  239. break;
  240. case 3:
  241. otherHisCheck(dispatch,store,params);
  242. break;
  243. case 4:
  244. checkBodyCheck(dispatch,store,params);
  245. break;
  246. default:
  247. }
  248. }
  249. /**************标签双击输入**************/
  250. //主诉
  251. function mainSuitLabelEdit(dispatch,params){
  252. const index = params.ikey;
  253. let ikey = getLabelIndex(index);
  254. dispatch({
  255. type:CHANGE_LABELVAL,
  256. data:{changeVal:params.changeVal,ikey:ikey}
  257. })
  258. }
  259. //现病史
  260. function currentLabelEdit(dispatch,params){
  261. const index = params.ikey;
  262. let ikey = getLabelIndex(index);
  263. dispatch({
  264. type:CURRENT_TEXT_LABEL,
  265. data:{changeVal:params.changeVal,ikey:ikey}
  266. })
  267. }
  268. //其他史
  269. function otherHisLabelEdit(dispatch,params){
  270. const index = params.ikey;
  271. let ikey = getLabelIndex(index);
  272. dispatch({
  273. type:CHANGEOTHERTEXTLABEL,
  274. data:{changeVal:params.changeVal,ikey:ikey}
  275. })
  276. }
  277. //查体
  278. function checkBodyLabelEdit(dispatch,params){
  279. const index = params.ikey;
  280. let ikey = getLabelIndex(index);
  281. const {changeVal} = params;
  282. dispatch({
  283. type:CHANGECHECKTEXTLABEL,
  284. data:{totalVal:changeVal,ikey:ikey,changeVal}
  285. })
  286. }
  287. function handleLabel(dispatch,params){
  288. const {type} = params;
  289. switch (+type){
  290. case 1:
  291. mainSuitLabelEdit(dispatch,params);
  292. break;
  293. case 2:
  294. currentLabelEdit(dispatch,params);
  295. break;
  296. case 3:
  297. otherHisLabelEdit(dispatch,params);
  298. break;
  299. case 4:
  300. checkBodyLabelEdit(dispatch,params);
  301. break;
  302. default:
  303. }
  304. }
  305. function mapDispatchToProps(dispatch,store){
  306. return {
  307. handleConfirm(obj){
  308. if(obj.tagType == 6||obj.tagType == 11){//铺开
  309. handleModuleDiff(dispatch,store,obj);
  310. }else if(obj.tagType == 2){//普通多选
  311. handleCheckBox(dispatch,store,obj);
  312. }
  313. },
  314. handleHide(){
  315. dispatch({
  316. type: HIDEDROP
  317. });
  318. },
  319. async handleShow(obj){
  320. // 埋点dispatch
  321. dispatch({
  322. type:CLICKCOUNT,
  323. data:obj,
  324. clickType:'单击',
  325. num:1
  326. });
  327. // 调大数据接口
  328. if(obj.tagType ==11 ){
  329. const bigData = await getCommSymptomPush();
  330. let result = bigData.data;
  331. if(+result.code == 0){
  332. // let pushDataList = result.data.symptom;
  333. let bigDataList = result.data.symptom;
  334. let pushDataList = [];
  335. if(bigDataList.length>0){//剔除没有id
  336. pushDataList = bigDataList.filter(function(item){
  337. return item.id
  338. });
  339. }else{
  340. pushDataList = bigDataList;
  341. }
  342. /*if(pushDataList.length > 0){
  343. if(obj.type == 1){// 主诉--添加症状
  344. dispatch({
  345. type:GET_BIGDATAPUSH,
  346. data:pushDataList,
  347. info:obj
  348. })
  349. }else if(obj.type == 2){// 现病史--添加其他症状
  350. dispatch({
  351. type:CURRENT_GET_BIGDATAPUSH,
  352. data:pushDataList,
  353. info:obj
  354. })
  355. }
  356. }else{
  357. Notify.info("暂无推送");
  358. // return
  359. }*/
  360. //推送无数据显示空下拉并提示暂无推送--1.9/1.18
  361. if(pushDataList.length == 0){Notify.info("暂无推送");}
  362. if(obj.type == 1){// 主诉--添加症状
  363. dispatch({
  364. type:GET_BIGDATAPUSH,
  365. data:pushDataList,
  366. info:obj
  367. })
  368. }else if(obj.type == 2){// 现病史--添加其他症状
  369. dispatch({
  370. type:CURRENT_GET_BIGDATAPUSH,
  371. data:pushDataList,
  372. info:obj
  373. })
  374. }
  375. }else{
  376. console.log(result.msg);
  377. // 接口请求失败,不往下执行显示下拉
  378. return
  379. }
  380. }
  381. dispatch({
  382. type:SETDROPSHOW,
  383. data:obj
  384. });
  385. dispatch({
  386. type: RESET
  387. });
  388. },
  389. handleDbclick(obj){//双击统计
  390. dispatch({
  391. type:CLICKCOUNT,
  392. data:obj,
  393. clickType:'双击',
  394. num:1
  395. });
  396. },
  397. handleLabelChange(obj){//标签内输入
  398. handleLabel(dispatch,obj);
  399. }
  400. }
  401. }
  402. const SpreadDropCont = connect(
  403. mapStateToProps,
  404. mapDispatchToProps
  405. )(SpreadDrop);
  406. export default SpreadDropCont;