|
@@ -95,27 +95,13 @@ export const getBigSymptom = (state,action) => {
|
|
|
//点击插入新模板--添加病程变化
|
|
|
export const handleTailClick = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
|
- const sonId = action.id;//子模板id
|
|
|
let num = res.moduleNum.num;
|
|
|
num++;
|
|
|
- // const addSmoduleData = JSON.parse(JSON.stringify(res.addSmoduleData));
|
|
|
- // const addDatas = JSON.parse(JSON.stringify(fullfillText(action.info).newArr));
|
|
|
- let addSmoduleData;
|
|
|
- // const allModules = JSON.parse(localStorage.getItem('modules'));
|
|
|
- let allModules = action.allModules;
|
|
|
- for(let k=0; k<allModules.length; k++){
|
|
|
- if(allModules[k].id==sonId){
|
|
|
- addSmoduleData = JSON.parse(JSON.stringify(allModules[k].moduleDetailDTOList));
|
|
|
- }
|
|
|
- }
|
|
|
+ let addSmoduleData = action.addSmoduleData;
|
|
|
let datas = JSON.parse(JSON.stringify(res.data));
|
|
|
- let leng = datas.length;
|
|
|
|
|
|
for(let i=0; i<addSmoduleData.length; i++){
|
|
|
addSmoduleData[i].pos = num;
|
|
|
- // let pos = leng-1+i;
|
|
|
- /* let pos = leng-2+i;
|
|
|
- datas.splice(pos,0,addDatas[i]);*/
|
|
|
}
|
|
|
let newData = insertPro(datas,addSmoduleData);
|
|
|
res.data = fullfillText(newData).newArr;
|
|
@@ -131,7 +117,8 @@ export const insertMain = (state,action) => {
|
|
|
const res = Object.assign({},state);
|
|
|
const items = action.item.select;
|
|
|
const id = action.item.ids;
|
|
|
- let data = JSON.parse(JSON.stringify(res.moduleData||null))||[];
|
|
|
+ const conceptId = action.item.conceptId;
|
|
|
+ let data = JSON.parse(JSON.stringify(res.moduleData));
|
|
|
if(items.length>1){
|
|
|
for(let i=1; i<items.length; i++){
|
|
|
items[i].name = '、'+items[i].name;
|
|
@@ -140,7 +127,7 @@ export const insertMain = (state,action) => {
|
|
|
}
|
|
|
let obj = [];
|
|
|
for(let i=0; i<items.length; i++){
|
|
|
- obj.push({id:items[i].questionId,name:items[i].name,value:items[i].name,tagType:config.tagType,exist:1});
|
|
|
+ obj.push({id:items[i].questionId,name:items[i].name,value:items[i].name,tagType:config.tagType,exist:1,conceptId:items[i].conceptId});
|
|
|
}
|
|
|
let inserIndx = null;
|
|
|
data.map((it,i)=>{
|
|
@@ -160,17 +147,17 @@ export const insertMain = (state,action) => {
|
|
|
res.saveText = [];//将手动输入的值清掉
|
|
|
// res.saveText[inserIndx] = text.name;
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- // res.mainIds.push(id);
|
|
|
- res.mainIds = res.mainIds.concat(id);
|
|
|
+ res.mainIds = res.mainIds.concat(conceptId);
|
|
|
+ res.mainTailIds = res.mainTailIds.concat(id);
|
|
|
res.editClear = false;//主诉框编辑状态
|
|
|
res.update=Math.random();
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
-function getTextLabel(id,name,flag){
|
|
|
+function getTextLabel(id,name,flag,copid){
|
|
|
// exist 主症状1,伴随2
|
|
|
- return {id:id,name:name,value:name,tagType:config.tagType,exist:flag};
|
|
|
+ return {id:id,name:name,value:name,tagType:config.tagType,exist:flag,conceptId:copid};
|
|
|
}
|
|
|
|
|
|
function addPoint(data,num){//给伴随添加顿号
|
|
@@ -188,12 +175,21 @@ export const confirm = (state,action) =>{
|
|
|
const {exists,withs,ikey,withsName,existsName,ban} = action.data;
|
|
|
let banText = JSON.stringify(ban) == "{}" ? '':{id:ban.id,name:ban.name,value:ban.name,tagType:config.tagType};
|
|
|
let length = exists.length;
|
|
|
+ let existConpId = [];
|
|
|
+ let withConpId = [];
|
|
|
+ exists.map((v,i)=>{
|
|
|
+ existConpId.push(v.conceptId);
|
|
|
+ })
|
|
|
+ withs.map((v,i)=>{
|
|
|
+ withConpId.push(v.conceptId);
|
|
|
+ })
|
|
|
let labelIndx = parseInt(ikey);//当前点击标签的index
|
|
|
// 取第一个添加症状的主症状和伴随
|
|
|
if(!arr[labelIndx].pos){
|
|
|
let existsId = getIds(exists);
|
|
|
let withsId = getIds(withs);
|
|
|
- res.mainIds = res.mainIds?res.mainIds.concat(existsId,withsId):[];
|
|
|
+ res.mainIds = res.mainIds?res.mainIds.concat(existConpId,withConpId):[];
|
|
|
+ res.mainTailIds = res.mainTailIds?res.mainTailIds.concat(existsId,withsId):[];
|
|
|
}
|
|
|
|
|
|
// 第二病程-伴位置处理
|
|
@@ -217,7 +213,7 @@ export const confirm = (state,action) =>{
|
|
|
let withsAddP = addPoint(exists,1);
|
|
|
for(let i=0; i<withsAddP.length; i++){
|
|
|
let pos = labelIndx + i;
|
|
|
- arr.splice(pos,0,getTextLabel(withsAddP[i].id,withsAddP[i].name,1));
|
|
|
+ arr.splice(pos,0,getTextLabel(withsAddP[i].id,withsAddP[i].name,1,withsAddP[i].conceptId));
|
|
|
res.saveText[pos] = withsAddP[i].name;
|
|
|
}
|
|
|
}
|
|
@@ -229,7 +225,7 @@ export const confirm = (state,action) =>{
|
|
|
}
|
|
|
for(let j=0; j<newWiths.length; j++){
|
|
|
let withsPos = labelIndx +length + j;
|
|
|
- arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2));
|
|
|
+ arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2,newWiths[j].conceptId));
|
|
|
res.saveText[withsPos] = newWiths[j].name;
|
|
|
}
|
|
|
}
|
|
@@ -248,7 +244,7 @@ export const confirm = (state,action) =>{
|
|
|
existsAddP = addPoint(exists,startInd);
|
|
|
for(let i=0; i<existsAddP.length; i++){
|
|
|
let pos = forwardId + index + i;
|
|
|
- arr.splice(pos,0,getTextLabel(existsAddP[i].id,existsAddP[i].name,1));
|
|
|
+ arr.splice(pos,0,getTextLabel(existsAddP[i].id,existsAddP[i].name,1,existsAddP[i].conceptId));
|
|
|
res.saveText[pos] = existsAddP[i].name;
|
|
|
}
|
|
|
}
|
|
@@ -257,7 +253,7 @@ export const confirm = (state,action) =>{
|
|
|
let withsAddP = addPoint(withs,0);
|
|
|
for(let j=0; j<withsAddP.length; j++){
|
|
|
let withsPos = labelIndx +length + j;
|
|
|
- arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2));
|
|
|
+ arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2,withsAddP[j].conceptId));
|
|
|
res.saveText[withsPos] = withsAddP[j].name;
|
|
|
}
|
|
|
}
|
|
@@ -269,7 +265,7 @@ export const confirm = (state,action) =>{
|
|
|
if(exists.length > 0){
|
|
|
for(let i=0; i<exists.length; i++){
|
|
|
let pos = labelIndx + i;
|
|
|
- arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1));
|
|
|
+ arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1,exists[i].conceptId));
|
|
|
res.saveText[pos] = exists[i].name;
|
|
|
}
|
|
|
}
|
|
@@ -281,7 +277,7 @@ export const confirm = (state,action) =>{
|
|
|
}
|
|
|
for(let j=0; j<newWiths.length; j++){
|
|
|
let withsPos = labelIndx +length + j;
|
|
|
- arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2));
|
|
|
+ arr.splice(withsPos,0,getTextLabel(newWiths[j].id,newWiths[j].name,2,newWiths[j].conceptId));
|
|
|
res.saveText[withsPos] = newWiths[j].name;
|
|
|
}
|
|
|
}
|
|
@@ -289,7 +285,7 @@ export const confirm = (state,action) =>{
|
|
|
if(exists.length > 0){
|
|
|
for(let i=0; i<exists.length; i++){
|
|
|
let pos = index + i;
|
|
|
- arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1));
|
|
|
+ arr.splice(pos,0,getTextLabel(exists[i].id,'、'+exists[i].name,1,exists[i].conceptId));
|
|
|
res.saveText[pos] = exists[i].name;
|
|
|
}
|
|
|
}
|
|
@@ -298,14 +294,12 @@ export const confirm = (state,action) =>{
|
|
|
let withsAddP = addPoint(withs,0);
|
|
|
for(let j=0; j<withsAddP.length; j++){
|
|
|
let withsPos = labelIndx +length + j;
|
|
|
- arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2));
|
|
|
+ arr.splice(withsPos,0,getTextLabel(withsAddP[j].id,withsAddP[j].name,2,withsAddP[j].conceptId));
|
|
|
res.saveText[withsPos] = withsAddP[j].name;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
res.data = arr;
|
|
|
res.saveText = fullfillText(arr).saveText;
|
|
|
res.update=Math.random();
|
|
@@ -337,6 +331,7 @@ export const setSearch = (state,action)=>{
|
|
|
let searchData = action.data;
|
|
|
res.searchDatas = searchData;
|
|
|
res.searchStr = action.inpStr;
|
|
|
+ res.isEnd = action.isEnd;
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -347,10 +342,11 @@ export const insertSearch = (state,action)=>{
|
|
|
let data = res.data;
|
|
|
let moduleData = JSON.parse(JSON.stringify(res.moduleData));
|
|
|
let searchData = action.info.name;
|
|
|
- const id = action.info.questionId;
|
|
|
+ const id = action.info.questionId;//获取尾巴id
|
|
|
+ const ids = action.info.conceptId;//去重id
|
|
|
let focusIndex = res.focusIndex;
|
|
|
let span = action.span;
|
|
|
- let text = {id:id,name:searchData,value:searchData,tagType:config.tagType};
|
|
|
+ let text = {id:id,name:searchData,value:searchData,tagType:config.tagType,conceptId:ids};
|
|
|
const emptySpan = JSON.parse(config.textLabel);
|
|
|
if(data.length==0){
|
|
|
let inserIndx = null;
|
|
@@ -360,43 +356,21 @@ export const insertSearch = (state,action)=>{
|
|
|
}
|
|
|
})
|
|
|
// flag=1前是文本标签就替换,否则插入
|
|
|
- // const iftext = moduleData[inserIndx-1].tagType;
|
|
|
const iftext = inserIndx&&moduleData[inserIndx-1]&&moduleData[inserIndx-1].tagType;
|
|
|
if(iftext==config.tagType){
|
|
|
- moduleData.splice(inserIndx-1,1,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1});
|
|
|
+ moduleData.splice(inserIndx-1,1,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1,conceptId:ids});
|
|
|
}else{
|
|
|
- moduleData.splice(inserIndx,0,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1});
|
|
|
- }
|
|
|
- // moduleData.splice(inserIndx,0,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1},emptySpan);
|
|
|
+ moduleData.splice(inserIndx,0,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1,conceptId:ids});
|
|
|
+ }
|
|
|
res.saveText = [];//将手动输入的值清掉
|
|
|
res.data = moduleData;
|
|
|
- // res.saveText[inserIndx] = searchData;
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- // res.saveText[inserIndx] = searchData;
|
|
|
- res.mainIds.push(id);
|
|
|
+ res.mainIds.push(ids);
|
|
|
+ if(id){
|
|
|
+ res.mainTailIds.push(id);
|
|
|
+ }
|
|
|
res.editClear = false;//主诉框编辑状态
|
|
|
}else{
|
|
|
- // 替换
|
|
|
- /*span.current.innerText = '';
|
|
|
- res.data.splice(focusIndex,1,text);
|
|
|
- res.saveText[focusIndex] = searchData;
|
|
|
- res.mainIds.push(id);*/
|
|
|
- // 追加--前or后?searchStr
|
|
|
- /*const searchStr = res.searchStr;
|
|
|
- let innerText = span.current.innerText;
|
|
|
- let index = innerText.indexOf(searchStr);
|
|
|
- let value;
|
|
|
- if(index <= 1){//前
|
|
|
- value = innerText.replace(searchStr,searchData);
|
|
|
- }else{
|
|
|
- let temp = innerText.substring(0,innerText.lastIndexOf(searchStr));
|
|
|
- value = temp + searchData;
|
|
|
- }
|
|
|
- // let value = innerText + searchData;
|
|
|
- span.current.innerText = value;
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- res.saveText[focusIndex] = value;*/
|
|
|
-
|
|
|
/*******************第一病程搜索结果也移植到现病史修改(2-18)********************/
|
|
|
// 位置判断-第一病程-主症状还是伴随 前一个标签存在 并且没有pos;
|
|
|
// 判断在伴的前面还是后面:前exist=1(主),后exist=2(伴)
|
|
@@ -417,31 +391,37 @@ export const insertSearch = (state,action)=>{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 从新插入一个span标签
|
|
|
const searchStr = res.searchStr;
|
|
|
+ const isEnd = res.isEnd;
|
|
|
let innerText = span.current.innerText || span.current.innerHTML;
|
|
|
- const value = innerText.replace(searchStr,"");
|
|
|
- let index = innerText.indexOf(searchStr);
|
|
|
- if(index < 1){//前
|
|
|
- if(data[focusIndex].value==searchStr){//为空标签则替换
|
|
|
+ if(!isEnd){//前
|
|
|
+ const reg = new RegExp("^"+searchStr)
|
|
|
+ const value = innerText.replace(reg,"");
|
|
|
+ res.data.splice(focusIndex,0,nText);
|
|
|
+ res.saveText.splice(focusIndex,0,searchData);
|
|
|
+ res.data[focusIndex+1].value = value;
|
|
|
+ res.saveText[focusIndex+1] = value;
|
|
|
+ span.current.innerText?(span.current.innerText = value):(span.current.innerHTML=value);
|
|
|
+ }else{
|
|
|
+ const reg = new RegExp(searchStr+"$")
|
|
|
+ const value = innerText.replace(reg,"");
|
|
|
+ if(data[focusIndex].value.trim()==searchStr){//为空标签则替换-否则会多一个空标签
|
|
|
res.data.splice(focusIndex,1,nText);
|
|
|
res.saveText.splice(focusIndex,1,searchData);
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex,0,nText);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- }
|
|
|
- }else{
|
|
|
- res.data.splice(focusIndex+1,0,nText);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
+ res.data.splice(focusIndex+1,0,nText);
|
|
|
+ res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
+ res.data[focusIndex].value = value;
|
|
|
+ res.saveText[focusIndex] = value;
|
|
|
+ }
|
|
|
+ span.current.innerText?(span.current.innerText = value):(span.current.innerHTML=value);
|
|
|
+ }
|
|
|
+ res.mainIds.push(ids);
|
|
|
+ if(id){
|
|
|
+ res.mainTailIds.push(id);
|
|
|
}
|
|
|
- span.current.innerText?(span.current.innerText = value):(span.current.innerHTML=value);
|
|
|
- res.mainIds.push(id);
|
|
|
}
|
|
|
- // console.log(456,res,action);
|
|
|
res.update=Math.random();
|
|
|
return res;
|
|
|
}
|
|
@@ -454,7 +434,7 @@ export function setNumberValue(state,action){
|
|
|
const param = action.params;
|
|
|
const index = param.ikey;
|
|
|
let labelInx = getLabelIndex(index);
|
|
|
- const subInx = index.substr(index.length-1);
|
|
|
+ const subInx = index.split("-")[2];//index.substr(index.length-1);
|
|
|
let item = res.data[labelInx];
|
|
|
// if(param.text.trim()){
|
|
|
if(+item.tagType===1){
|
|
@@ -486,7 +466,7 @@ export function setRadioValue(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
const {ikey,id,text} = action;
|
|
|
let labelInx = getLabelIndex(ikey);
|
|
|
- const subInx = ikey.substr(ikey.length-1);
|
|
|
+ const subInx = ikey.split("-")[2]//ikey.substr(ikey.length-1);
|
|
|
let item = res.data[labelInx];
|
|
|
if(typeof text != 'string'){ //需要展开项--有无治疗类型
|
|
|
const len = +item.copyType === 0?1:0;
|
|
@@ -534,7 +514,7 @@ export const setRadioInputValue = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
|
const {ikey,values,id} = action.data;
|
|
|
let index = getLabelIndex(ikey);
|
|
|
- let innerInx = ikey.substr(ikey.length-1);
|
|
|
+ let innerInx = ikey.split("-")[2];//ikey.substr(ikey.length-1);
|
|
|
let item = res.data[index];
|
|
|
if(item.tagType!=1){ //在组合项中
|
|
|
item = res.data[index].questionMapping[innerInx];
|
|
@@ -589,7 +569,7 @@ export const setRadioInputValue = (state,action)=>{
|
|
|
});
|
|
|
res.saveText[index] = sub.join('');
|
|
|
}else {
|
|
|
- res.saveText[ikey] = str;
|
|
|
+ res.saveText[index] = str;
|
|
|
}
|
|
|
res.update = Math.random();
|
|
|
return res;
|
|
@@ -673,6 +653,7 @@ export const clearMainSuit = (state,action)=>{//回读和清除
|
|
|
// res.saveText = fullfillText(action.data).saveText;//解决删除data里的值保存,回读后页面上有内容saveText里没有的情况
|
|
|
res.selecteds = action.selecteds?action.selecteds:[];
|
|
|
res.mainIds = action.mainIds;
|
|
|
+ res.mainTailIds = action.mainTailIds || [];
|
|
|
res.chronicDesease = action.chronicDesease;//慢病疾病字段
|
|
|
if(action.editClear){
|
|
|
res.editClear = action.editClear;
|
|
@@ -776,10 +757,17 @@ export function removeId(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
const {index,text} = action;
|
|
|
const data = res.data;
|
|
|
+ // 获取尾巴id-questionId
|
|
|
const id = data[index].id;
|
|
|
+ let tailIds = res.mainTailIds;
|
|
|
+ if(tailIds.includes(id)){
|
|
|
+ tailIds.splice(tailIds.indexOf(id),1);
|
|
|
+ }
|
|
|
+ // 去重id
|
|
|
+ const copid = data[index].conceptId;
|
|
|
let ids = res.mainIds;
|
|
|
- if(ids.includes(id)){
|
|
|
- ids.splice(ids.indexOf(id),1);
|
|
|
+ if(ids.includes(copid)){
|
|
|
+ ids.splice(ids.indexOf(copid),1);
|
|
|
}
|
|
|
if(!data[index].value && data[index-1].tagType==8){
|
|
|
data.splice(index,1);
|
|
@@ -828,7 +816,10 @@ export function getSymptomFeature(state,action){
|
|
|
if(data && data.length>0){
|
|
|
for(let i=0; i<data.length; i++){
|
|
|
data[i].tagType = '8';
|
|
|
- res.mainIds.push(data[i].id);
|
|
|
+ res.mainIds.push(data[i].conceptId);
|
|
|
+ if(data[i].id){//questionId有可能为null
|
|
|
+ res.mainTailIds.push(data[i].id);
|
|
|
+ }
|
|
|
}
|
|
|
res.symptomFeature.featureData = data;
|
|
|
res.symptomFeature.refresh = !res.symptomFeature.refresh;
|