123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591 |
- import Vue from 'vue';
- import Vuex from 'vuex';
- import {deepClone,getAllStr,moduleCP} from '@utils/tools.js'
- Vue.use(Vuex);
- const store = new Vuex.Store({
- state:{
- searchShow:false,
- pathInfo:{}, //患者信息-后续提交要用
- sysConfig:[], //系统配置项
- allMoudles:[], //模板
- extPushSymptom:[], //后台维护的伴随症状
- scroll:{
- x:0,y:0
- },
- symptom:{ //症状情况
- choose:[],
- origin:{},
- datas:{},
- text:[],
- },
- diagnose:{ //诊疗
- origin:[], //模板数据
- datas:[],
- text:[],
- imgFile:[],//上传图片信息file
- imgSrc:{},//上传的图片信息src
- },
- others:{ //其他情况
- origin:[], //模板数据
- datas:[],
- text:[],
- imgFile:[],
- imgSrc:{},
- },
- addContent:{
- origin:[],
- datas:[],
- txt:'',
- txtDoc:''
- },
- activeModule:{},//有效显示的模块
- loadingShow:false,
- detailInfo:{},
- detailShow:false,
- finish:{ //标识已填
- '1':true,
- '51':false,
- '3':false,
- '52':false
- },
- currentTab:{ //标识当前tab页
- '1':true,
- '51':false,
- '3':false,
- '52':false
- },
- tabType: {
- "1": 1,
- "51": 0,
- "3": 0,
- "52": 0,
- },
- addBuriedSomeList:[],//买点数据
- },
- mutations:{
- setShowDoctor(state,flag){
- state.showDoctor=flag;
- },
- clearDeledBuried(state){
- state.addBuriedSomeList=[];
- },
- addBuriedSome(state,item){
- let list = state.addBuriedSomeList,num=0
- for(let i = 0;i < list.length;i++){
- let number = list[i].operationNum
- if(list[i].labelName == item.labelName&&list[i].operationType == item.operationType){//已经存在+1
- list[i].operationNum = ++number
- }else{
- ++num
- }
- }
- if(num == list.length){//没有新增一项
- list.push(item)
- }
- // console.log(list)
- state.addBuriedSomeList=list
- },
- setFinish(state,param){
- let obj = state.finish
- let obj1 = state.currentTab
- for(let key in obj){
- if(key == param){
- obj[key] = true
- obj1[key] = true
- }else{
- obj1[key] = false
- }
- }
- state.finish = obj
- },
- setActiveModule(state,param){
- state.activeModule = param
- },
- initAllData(state){
- state.symptom={ //症状情况
- choose:[],
- origin:{},
- datas:{},
- text:[],
- }
- state.diagnose={ //诊疗
- origin:[], //模板数据
- datas:[],
- text:[],
- imgFile:[],
- imgSrc:{},
- }
- state.others={ //其他情况
- origin:[], //模板数据
- datas:[],
- text:[],
- imgFile:[],
- imgSrc:{},
- }
- state.addContent={
- origin:[],
- datas:[],
- text:[],
- txtDoc:''
- }
- state.addBuriedSomeList=[]//买点数据
- },
- setDetail(state,param){//明细
- const detail = param.detail;
- if(JSON.stringify(detail)=='{}'){
- state.detailShow = false;
- }else{
- if(param.sign!=1){
- state.detailInfo = Object.assign({},param);
- state.detailShow = true;
- }else{
- if(param.idx == 0&&detail.idx == 1){
- state.detailInfo = Object.assign({},param);
- state.detailShow = true;
- }else{
- state.detailShow = false;
- }
- }
- }
- },
- setSearchShow(state,flg){//搜索显示与否
- state.searchShow = flg;
- },
- setSymptomDatas(state,data){
- const temp = formatSymptomData(data);
- state.symptom.origin = temp.newArr;
- state.symptom.datas = JSON.parse(JSON.stringify(temp.newArr));
- state.extPushSymptom = temp.extSymptoms||[];
- },
- setUsualSymptom(state,data){
- const arr = [...data];
- arr.length=arr.length>10?10:arr.length;
- state.usualSymptom = arr;
- },
- /*setExtPushSymptom(state,data){
- state.extPushSymptom=data;
- },*/
- setDataAll(state,param){
- let res = state.allMoudles
- for(let i = 0;i<res.length;i++){
- if(res[i].type == moduleCP['suplement']){
- res[i].moduleDetailDTOList[param.idx] = param.data
- }
- }
- state.allMoudles = res
- },
- savePathInfo(state,param){
- let obj = param;
- obj.sexType = obj.patientSex == '男' ? 1 : (obj.patientSex == '女' ? 2 : 3);
- state.pathInfo = obj;
- },
- saveSysConfig(state,param){
- state.sysConfig = param;
- let tabType = {
- "1": param.length > 0 && param.filter(item => item.code == "symptoms_show")[0].value,
- "51": param.length > 0 && param.filter(item => item.code == "diagnosis_show")[0].value,
- "3": param.length > 0 && param.filter(item => item.code == "omhistory_show")[0].value,
- "52": param.length > 0 && param.filter(item => item.code == "replenish_show")[0].value,
- }
- state.tabType = tabType
- },
- saveAll(state,param){
- state.allMoudles = param;
- for(let k in param){
- if(param[k].type == moduleCP['diagT']){
- const arr = formatDiagUploadData(param[k].moduleDetailDTOList);
- state.diagnose.origin = arr;
- state.diagnose.datas = JSON.parse(JSON.stringify(arr));
- }else if(param[k].type == moduleCP['other']){
- const org = param[k].moduleDetailDTOList;
- state.others.origin = JSON.parse(JSON.stringify(org));
- state.others.datas = JSON.parse(JSON.stringify(org));
- }else if(param[k].type == moduleCP['suplement']){
- const org = param[k].moduleDetailDTOList;
- state.addContent.origin = JSON.parse(JSON.stringify(org));
- state.addContent.datas = JSON.parse(JSON.stringify(org));
- }
- }
- },
- setOrigin(state,param){//取消选中时用
- const type = parseInt(param.type);
- const data = param.data;
- switch(type){
- case moduleCP['symp']: //症状情况
- state.symptom.origin = Object.assign({},state.symptom.origin,{[data.id]:data});
- break;
- case moduleCP['diagT']: //诊疗情况
- let diagData = state.diagnose.origin;
- for(let i in diagData){
- if(diagData[i].id == param.pId){
- let questionMapping = diagData[i].questionMapping;
- for(let k in questionMapping){
- if(questionMapping[k].id == data.id){
- questionMapping.splice(k,1,data);
- }
- }
- }
- }
- break;
- case moduleCP['other']:
- let otherData = state.others.origin;
- for(let i in otherData){
- if(otherData[i].id == param.pId){
- let questionMapping = otherData[i].questionMapping;
- for(let k in questionMapping){
- if(questionMapping[k].id == data.id){
- questionMapping.splice(k,1,data);
- }
- }
- }
- }
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- setModuleDatas(state,param){
- const {data,mName} = param;
- state[mName].datas = JSON.parse(JSON.stringify(data));
- },
- setDatas(state,param){
- // ppId--每一道题的id;pId--每个选项的id
- const type = parseInt(param.type);
- const data = param.data;
- const ppId = param.ppId;
- switch(type){
- case moduleCP['symp']:
- state.symptom.datas = Object.assign({},state.symptom.datas,{[param.pId]:data});
- break;
- case moduleCP['diagT']: //诊疗情况
- let diagData = state.diagnose.datas;
- for(let i in diagData){
- if(diagData[i].id == ppId){
- let questionMapping = diagData[i].questionMapping;
- for(let k in questionMapping){
- if(questionMapping[k].id == data.id){
- // questionMapping[k].questionMapping = data.questionMapping;
- questionMapping.splice(k,1,data);
- }
- }
- }
- }
- break;
- case moduleCP['other']:
- let otherData = state.others.datas;
- for(let i in otherData){
- if(otherData[i].id == ppId){
- let questionMapping = otherData[i].questionMapping;
- for(let k in questionMapping){
- if(questionMapping[k].id == data.id){
- questionMapping[k].questionMapping = data.questionMapping;
- }
- }
- }
- }
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- setText(state,param){
- const type = parseInt(param.type);
- // console.log(param,787)
- switch(type){
- case moduleCP['symp']:
- // 对象易更新但顺序无法控制
- // state.symptom.text = Object.assign({},state.symptom.text,{[param.pId]:param.text});
- let text = state.symptom.text;
- if(param.isEdit){ //修改后提交的答案,先删除原存的答案
- text.pop();
- }
- text.push(param);
- break;
- case moduleCP['diagT']: //诊疗情况
- let dtext = state.diagnose.text;
- if(param.isEdit){
- dtext.pop();
- }
- dtext.push(param);
- break;
- case moduleCP['other']: //其他情况
- let otherText = state.others.text;
- if(param.isEdit){
- otherText.pop();
- }
- otherText.push(param);
- /*let oitem = otherText[param.order];
- if(oitem){
- // 判断是对象还是数组--数组则区分index
- if(Array.isArray(oitem)){
- if(param.flag){//详情完成-覆盖
- oitem[param.index] = param;
- }else{ //直接点label--无则覆盖
- if(!oitem[param.index]){
- oitem[param.index] = param;
- }
- }
- }else{
- if(param.flag){
- otherText[param.order] = param;
- }
- }
- }else{
- if(param.arrFlag){
- let temp = [];
- temp[param.index] = param;
- otherText[param.order] = temp;
- }else{
- otherText[param.order] = param;
- }
- }
- state.others.text = otherText;*/
- break;
- case moduleCP['suplement']:
- let addText = state.addContent.text
- if(param.isEdit){
- addText.pop();
- }
- addText.push(param);
- break;
- default:
- break;
- }
- },
- delText(state,param){
- const type = parseInt(param.type);
- switch(type){
- case moduleCP['symp']:
- let text = state.symptom.text;
- for(let i in text){
- if(text[i].pId==param.pId){
- text.splice(i,1)
- }
- }
- break;
- case moduleCP['diagT']: //诊疗情况
- let diaText = JSON.parse(JSON.stringify(state.diagnose.text));
- let temp = diaText[param.order];
- temp[param.index] = null;
- state.diagnose.text = diaText;
- break;
- case moduleCP['other']:
- let otherText = JSON.parse(JSON.stringify(state.others.text));
- let otemp = otherText[param.order];
- otemp[param.index] = null;
- state.others.text = otherText;
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- setChoose(state,param){ //症状情况-已选症状
- state.symptom.choose = param.choose;
- },
- setScroll(state,data){ //症状情况-已选症状
- state.scroll = data;
- },
- delChoose(state,param){ //详情有必填项未填--移除症状
- const id = param.id;
- let symp = state.symptom.choose;
- for(let i=0; i<symp.length; i++){
- if(id == (symp[i].id || symp[i].questionId)){
- symp.splice(i,1);
- }
- }
- },
- setImgFile(state,param){//区别模块
- const type = parseInt(param.type);
- switch(type){
- case moduleCP['symp']:
- break;
- case moduleCP['diagT']: //诊疗情况
- state.diagnose.imgFile.push(param);
- break;
- case moduleCP['other']:
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- setImgSrc(state,param){
- const key = param.key;
- const src = param.src;
- const type = parseInt(param.type);
- switch(type){
- case moduleCP['symp']:
- break;
- case moduleCP['diagT']:
- state.diagnose.imgSrc = Object.assign({},state.diagnose.imgSrc,{[key]:src});
- break;
- case moduleCP['other']:
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- deleImg(state,param){
- const key = param.key;
- const type = parseInt(param.type);
- switch(type){
- case moduleCP['symp']:
- break;
- case moduleCP['diagT']:
- let data = state.diagnose.imgFile;
- for(let i=0; i<data.length;i++){
- if(data[i].key==key){
- data.splice(i,1)
- }
- }
- break;
- case moduleCP['other']:
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- cancelImgs(state){
- state.diagnose.imgFile=[];
- state.diagnose.imgSrc = {};
- },
- setUploadImgs(state,list){
- state.uploadImgs=list;
- },
- deleSrc(state,param){
- const key = param.key;
- const type = parseInt(param.type);
- switch(type){
- case moduleCP['symp']:
- break;
- case moduleCP['diagT']:
- let data = state.diagnose.imgFile;
- let obj = state.diagnose.imgSrc;
- delete(obj[key]);
- state.diagnose.imgSrc = Object.assign({},obj);
- break;
- case moduleCP['other']:
- break;
- case moduleCP['suplement']:
- break;
- default:
- break;
- }
- },
- handleToggleShow(state,flg){
- state.loadingShow = flg
- }
- }
- });
- function formatDiagUploadData(data){
- //上传图片类型处理,前面添加一个问题
- const inx = data.findIndex((it)=>{
- return it.controlType==4;
- });
- let newArr = JSON.parse(JSON.stringify(data));
- if(inx!==-1){
- newArr.splice(inx,0,{
- id: 999999,
- name: "有可以上传的最近一次诊疗记录吗?",
- tagName: "有可以上传的最近一次诊疗记录吗?",
- type: 51,
- controlType: 1,
- itemType: 0,
- tagType: 1,
- labelPrefix: "",
- labelSuffix: "",
- url: "",
- description: "",
- specFlag: 0,
- required: 0,
- explains: null,
- exclusionType: null,
- questionDetailList:[{id: 111111, name: "没有", description: "", questionId: 999999, orderNo: 2, exclusion: 0, remark: null},{id: 111110, name: "有,可以上传", description: "", questionId: 999999, orderNo: 1, exclusion: 0, remark: null}
- ],
- questionMapping: [],
- flag: "",
- remark: null,
- prefix: "",
- suffix: "",
- moduleId: 2,
- questionId: 1191,
- relationModule: null,
- relationModuleName: null});
- };
- return newArr;
- };
- function formatSymptomData(data){
- //症状详情后添加一个大数据推送其他症状
- let newArr = JSON.parse(JSON.stringify(data));
- newArr.push({
- id: 999998,
- name: "还有其他不舒服吗?(可多选)",
- tagName: "还有其他不舒服吗?",
- type: 1,
- controlType: 99,
- itemType: 0,
- tagType: 1,
- labelPrefix: "",
- labelSuffix: "",
- url: "",
- description: "",
- specFlag: 0,
- required: 0,
- explains: null,
- exclusionType: null,
- questionDetailList:[],
- questionMapping: [],
- flag: "",
- remark: null,
- prefix: "",
- suffix: "",
- moduleId: 2,
- questionId: 999998,
- relationModule: null,
- relationModuleName: null});
- //多选伴随类型不展示问题,选项添加到推送症状前
- let extSymptoms = [];
- const n = data.findIndex((it)=>{
- if(+it.controlType===8){
- extSymptoms = it.questionDetailList;
- }
- return +it.controlType===8;
- });
- if(n!==-1){
- newArr.splice(n,1);
- }
- return {newArr,extSymptoms};
- };
- export default store;
|