SpreadDrop.js 12 KB

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