123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- import React ,{Component} from 'react';
- import {connect} from 'react-redux';
- import SpreadDrop from '@components/SpreadDrop';
- import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SETOTHERCHECKBOX,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
- import {RESET,SETDROPSHOW,HIDEDROP,CLICKCOUNT,ISREAD} from '@store/types/homePage.js';
- import {getModules as fetchModules} from '@store/async-actions/fetchModules.js';
- import {getCommSymptomPush} from '@store/async-actions/mainSuit.js'
- import {GET_BIGDATAPUSH,MIX_CONFIRM,COMM_CONFIRM,CHANGE_LABELVAL} from '@store/types/mainSuit';
- import {SETCHECKBOX,CHANGECHECKTEXTLABEL} from '@types/checkBody';
- import {CURRENT_CONFIRM,SETMAINCHECKBOX,CURRENT_TEXT_LABEL,CURRENT_GET_BIGDATAPUSH} from '@types/currentIll';
- import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
- import {billing} from '@store/async-actions/pushMessage';
- import {Notify} from '@commonComp';
- import {filterArr,didPushParamChange} from '@utils/tools.js';
- import config from '@config/index.js';
- function mapStateToProps(state) {
- return {
- mainSaveText:state.mainSuit.saveText,
- }
- }
- function getNames(data,order){//从exist withs 中获取name字段
- let nameData = "";
- if(+order===1){ //成文默认按点选顺序排序,指定textGenerate=1按从上到下从左到右排序
- data.sort(function(a,b){
- return a.listIndex-b.listIndex;
- });
- }
- data&&data.forEach((it,i)=>{
- nameData += it.name;
- });
- return nameData;
- }
- /***********************标签展开确定事件***************************/
- // 主诉--不用展开标签
- function mainSuitModule(dispatch,store,params){
- const {nones,exists,withs,exclusion,excluName,ban,mainSaveText} = params;
- let existsName = getNames(exists);
- let withsName = getNames(withs);
- let banName = ban.name;
- let text = filterArr(mainSaveText);
- let names;
- if(banName){
- names = existsName + banName + withsName;
- }else{
- names = existsName + withsName;
- }
- let lengths = text.length + names.length;
- if(lengths > config.limited){
- Notify.info(config.limitText);
- return
- }
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- dispatch({
- type: MIX_CONFIRM,
- data: {exists:exists,withs:withs,withsName:withsName,existsName:existsName,ikey,ban}
- });
- dispatch({ //自由文本标签数据更新
- type:ISREAD
- });
- dispatch({//隐藏下拉
- type:HIDEDROP
- })
- }
- // 现病史
- function currentIll(dispatch,store,params){
- const {nones,exists,withs,exclusion,excluName,ban,noneIds} = params;
- // const ikey = params.ikey.substr(1,1);
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- // let existsId = getIds(exists);
- // let withsId = getIds(withs);
- let existsId = exists && exists.length>0?getIds(exists):[];
- let withsId = withs && withs.length>0?getIds(withs):[];
- // const ids = existsId.join(",")+withsId.join(",");
- const ids = (existsId.concat(withsId)).join(",");console.log("点击的下标是:",index,"选中的id是:",ids)
- let has = [],wes=[];
- //获取选中项目模板
- fetchModules(ids).then((res)=>{
- if(+res.data.code===0){
- const list = res.data.data;
- existsId.map((i)=>{
- // has.push(...list[i].questionMapping);
- has.push(list[i]);
- });
- withsId.map((i)=>{
- // wes.push(...list[i].questionMapping);
- wes.push(list[i]);
- });
- dispatch({
- type: CURRENT_CONFIRM,
- data: {exists:has,withs:wes,nones:nones,ikey,ban,noneIds}
- });
- dispatch({ //自由文本标签数据更新
- type:ISREAD
- });
- }else{
- console.log(res);
- }
- });
- }
- //其他史多选标签确定事件
- function otherHisConfirm(dispatch,store,params){
- const {nones,exists,withs,exclusion,excluName,copyType} = params;
- // const ikey = params.ikey.substr(1,1);
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- if(params.exclusion){
- dispatch({
- type: CONFIRMSELECTED,
- data:{exclusion,excluName,ikey,copyType}
- });
- return ;
- }
- let existsId = getIds(exists);
- let withsId = getIds(withs);
- const ids = existsId.join(",")+withsId.join(",");
- if(!ids&&nones){ //只有无的项目
- dispatch({
- type: CONFIRMSELECTED,
- data: {exists:[],withs:[],nones:nones,ikey,copyType}
- });
- dispatch({
- type:ISREAD
- });
- return;
- }
- // const ids = exists.join(",")+withs.join(",");
- let has = [],wes=[];
- //获取选中项目模板
- fetchModules(ids).then((res)=>{
- if(+res.data.code===0){
- const list = res.data.data;
- existsId.map((i)=>{
- has.push(...list[i].questionMapping);
- });
- withsId.map((i)=>{
- wes.push(...list[i].questionMapping);
- });
- dispatch({
- type: CONFIRMSELECTED,
- data: {exists:fullfillText(has,false,false).newArr,withs:fullfillText(wes,false,false).newArr,nones:nones,ikey,copyType}
- });
- dispatch({
- type:ISREAD
- });
- }
- });
- }
- function checkBodyConfirm(dispatch,store,params){
- console.log(params)
- }
- //在不同模块(主诉、现病史等)下拉选中调用不同事件
- function handleModuleDiff(dispatch,store,params){
- const {type,mainSaveText} = params;
- switch (+type){
- case 1:
- let text = filterArr(mainSaveText);
- if(text.length >= config.limited){
- Notify.info(config.limitText);
- return
- }
- mainSuitModule(dispatch,store,params);
- break;
- case 2:
- currentIll(dispatch,store,params);
- break;
- case 3:
- otherHisConfirm(dispatch,store,params);
- break;
- case 4:
- checkBodyConfirm(dispatch,store,params);
- break;
- default:
- }
- }
- /*****************普通多选框确定事件**************************/
- //主诉普通多选确定
- function mainSuitCheck(dispatch,store,params){
- const {nones,exists,withs,order,mainSaveText} = params;
- let existsName = getNames(exists,order);
- let text = filterArr(mainSaveText);
- let lengths = text.length + existsName.length;
- if(lengths > config.limited){
- Notify.info(config.limitText);
- return
- }
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- dispatch({
- type: COMM_CONFIRM,
- data: {exists:exists,existsName:existsName,ikey}
- });
- dispatch({//隐藏下拉
- type:HIDEDROP
- })
- }
- //现病史普通多选确定
- function currentCheck(dispatch,store,params){
- const {ikey,exclusion,excluName,nones,exists,noneIds,noneOn,nowOn,withOn,withs,order} = params;
- let existsName = getNames(exists,order);
- let withsName = getNames(withs);
- let labelInx = getLabelIndex(ikey);
- dispatch({
- type:SETMAINCHECKBOX,
- data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}
- })
- }
- //查体普通多选确定
- function checkBodyCheck(dispatch,store,params){
- const {ikey,exclusion,excluName,nones,exists,noneIds,noneOn,nowOn,withOn,withs,order} = params;
- let existsName = getNames(exists,order);
- let withsName = getNames(withs);
- let labelInx = getLabelIndex(ikey);
- dispatch({
- type:SETCHECKBOX,
- data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}
- })
- }
- //其他史普通多选确定
- function otherHisCheck(dispatch,store,params){
- const {ikey,exclusion,excluName,nones,exists,noneIds,noneOn,nowOn,withOn,withs,order} = params;
- let existsName = getNames(exists,order);
- let withsName = getNames(withs);
- let labelInx = getLabelIndex(ikey);
- dispatch({
- type:SETOTHERCHECKBOX,
- data:{labelInx,ikey,exclusion,excluName,nones,exists,existsName,noneIds,noneOn,nowOn,withOn,withs,withsName}
- })
- }
- function handleCheckBox(dispatch,store,params){
- const {type,mainSaveText} = params;
- switch (+type){
- case 1:
- let text = filterArr(mainSaveText);
- if(text.length >= config.limited){
- Notify.info(config.limitText);
- return
- }
- mainSuitCheck(dispatch,store,params);
- break;
- case 2:
- currentCheck(dispatch,store,params);
- break;
- case 3:
- otherHisCheck(dispatch,store,params);
- break;
- case 4:
- checkBodyCheck(dispatch,store,params);
- break;
- default:
- }
- }
- /**************标签双击输入**************/
- //主诉
- function mainSuitLabelEdit(dispatch,params){
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- dispatch({
- type:CHANGE_LABELVAL,
- data:{changeVal:params.changeVal,ikey:ikey}
- })
- }
- //现病史
- function currentLabelEdit(dispatch,params){
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- dispatch({
- type:CURRENT_TEXT_LABEL,
- data:{changeVal:params.changeVal,ikey:ikey}
- })
- }
- //其他史
- function otherHisLabelEdit(dispatch,params){
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- dispatch({
- type:CHANGEOTHERTEXTLABEL,
- data:{changeVal:params.changeVal,ikey:ikey}
- })
- }
- //查体
- function checkBodyLabelEdit(dispatch,params){
- const index = params.ikey;
- let ikey = getLabelIndex(index);
- const {changeVal} = params;
- dispatch({
- type:CHANGECHECKTEXTLABEL,
- data:{totalVal:changeVal,ikey:ikey,changeVal}
- })
- }
- function handleLabel(dispatch,params){
- const {type} = params;
- switch (+type){
- case 1:
- mainSuitLabelEdit(dispatch,params);
- break;
- case 2:
- currentLabelEdit(dispatch,params);
- break;
- case 3:
- otherHisLabelEdit(dispatch,params);
- break;
- case 4:
- checkBodyLabelEdit(dispatch,params);
- break;
- default:
- }
- dispatch(billing);
- dispatch({
- type:ISREAD
- })
- }
- function mapDispatchToProps(dispatch,store){
- return {
- handleConfirm(obj){
- if(obj.tagType == 6||obj.tagType == 11){//铺开
- handleModuleDiff(dispatch,store,obj);
- }else if(obj.tagType == 2){//普通多选
- handleCheckBox(dispatch,store,obj);
- }
- //右侧推送
- setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
- if(didPushParamChange()){ //操作后内容有变化才推送
- dispatch(billing);
- }
- },500);
- },
- handleHide(){
- dispatch({
- type: HIDEDROP
- });
- },
- async handleShow(obj){
- // 埋点dispatch
- dispatch({
- type:CLICKCOUNT,
- data:obj,
- clickType:'单击',
- num:1
- });
- // 调大数据接口
- if(obj.tagType ==11 ){
- const bigData = await getCommSymptomPush();
- let result = bigData.data;
- if(+result.code == 0){
- // let pushDataList = result.data.symptom;
- let bigDataList = result.data.symptom;
- let pushDataList = [];
- if(bigDataList.length>0){//剔除没有id
- pushDataList = bigDataList.filter(function(item){
- return item.id
- });
- }else{
- pushDataList = bigDataList;
- }
- /*if(pushDataList.length > 0){
- if(obj.type == 1){// 主诉--添加症状
- dispatch({
- type:GET_BIGDATAPUSH,
- data:pushDataList,
- info:obj
- })
- }else if(obj.type == 2){// 现病史--添加其他症状
- dispatch({
- type:CURRENT_GET_BIGDATAPUSH,
- data:pushDataList,
- info:obj
- })
- }
- }else{
- Notify.info("暂无推送");
- // return
- }*/
- //推送无数据显示空下拉并提示暂无推送--1.9/1.18
- if(pushDataList.length == 0){Notify.info("暂无推送");}
- if(obj.type == 1){// 主诉--添加症状
- dispatch({
- type:GET_BIGDATAPUSH,
- data:pushDataList,
- info:obj
- })
- }else if(obj.type == 2){// 现病史--添加其他症状
- dispatch({
- type:CURRENT_GET_BIGDATAPUSH,
- data:pushDataList,
- info:obj
- })
- }
- }else{
- console.log(result.msg);
- // 接口请求失败,不往下执行显示下拉
- return
- }
- }
- dispatch({
- type:SETDROPSHOW,
- data:obj
- });
- dispatch({
- type: RESET
- });
- },
- handleDbclick(obj){//双击统计
- dispatch({
- type:CLICKCOUNT,
- data:obj,
- clickType:'双击',
- num:1
- });
- },
- handleLabelChange(obj){//标签内输入
- handleLabel(dispatch,obj);
- }
- }
- }
- const SpreadDropCont = connect(
- mapStateToProps,
- mapDispatchToProps
- )(SpreadDrop);
- export default SpreadDropCont;
|