SpreadDrop.js 12 KB

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