store.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import {deepClone,getAllStr,moduleCP} from '@utils/tools.js'
  4. Vue.use(Vuex);
  5. const store = new Vuex.Store({
  6. state:{
  7. searchShow:false,
  8. pathInfo:{}, //患者信息-后续提交要用
  9. scaleInfo:null,//量表信息
  10. sysConfig:[], //系统配置项
  11. allMoudles:[], //模板
  12. istrue:false,//是否填写预问诊
  13. extPushSymptom:[], //后台维护的伴随症状
  14. scroll:{
  15. x:0,y:0
  16. },
  17. symptom:{ //症状情况
  18. choose:[],
  19. origin:{},
  20. datas:{},
  21. text:[],
  22. },
  23. diagnose:{ //诊疗
  24. origin:[], //模板数据
  25. datas:[],
  26. text:[],
  27. imgFile:[],//上传图片信息file
  28. imgSrc:{},//上传的图片信息src
  29. },
  30. others:{ //其他情况
  31. origin:[], //模板数据
  32. datas:[],
  33. text:[],
  34. imgFile:[],
  35. imgSrc:{},
  36. },
  37. addContent:{
  38. origin:[],
  39. datas:[],
  40. txt:'',
  41. txtDoc:''
  42. },
  43. activeModule:{},//有效显示的模块
  44. loadingShow:false,
  45. detailInfo:{},
  46. detailShow:false,
  47. finish:{ //标识已填
  48. '1':true,
  49. '51':false,
  50. '3':false,
  51. '52':false
  52. },
  53. currentTab:{ //标识当前tab页
  54. '1':true,
  55. '51':false,
  56. '3':false,
  57. '52':false
  58. },
  59. tabType: {
  60. "1": 1,
  61. "51": 0,
  62. "3": 0,
  63. "52": 0,
  64. },
  65. addBuriedSomeList:[],//买点数据
  66. deptName:'',//科室名字
  67. },
  68. mutations:{
  69. setShowDoctor(state,flag){
  70. state.showDoctor=flag;
  71. },
  72. clearDeledBuried(state){
  73. state.addBuriedSomeList=[];
  74. },
  75. addBuriedSome(state,item){
  76. let list = state.addBuriedSomeList,num=0
  77. for(let i = 0;i < list.length;i++){
  78. let number = list[i].operationNum
  79. if(list[i].labelName == item.labelName&&list[i].operationType == item.operationType){//已经存在+1
  80. list[i].operationNum = ++number
  81. }else{
  82. ++num
  83. }
  84. }
  85. if(num == list.length){//没有新增一项
  86. list.push(item)
  87. }
  88. // console.log(list)
  89. state.addBuriedSomeList=list
  90. },
  91. setFinish(state,param){
  92. let obj = state.finish
  93. let obj1 = state.currentTab
  94. for(let key in obj){
  95. if(key == param){
  96. obj[key] = true
  97. obj1[key] = true
  98. }else{
  99. obj1[key] = false
  100. }
  101. }
  102. state.finish = obj
  103. },
  104. setActiveModule(state,param){
  105. state.activeModule = param
  106. },
  107. initAllData(state){
  108. state.symptom={ //症状情况
  109. choose:[],
  110. origin:{},
  111. datas:{},
  112. text:[],
  113. }
  114. state.diagnose={ //诊疗
  115. origin:[], //模板数据
  116. datas:[],
  117. text:[],
  118. imgFile:[],
  119. imgSrc:{},
  120. }
  121. state.others={ //其他情况
  122. origin:[], //模板数据
  123. datas:[],
  124. text:[],
  125. imgFile:[],
  126. imgSrc:{},
  127. }
  128. state.addContent={
  129. origin:[],
  130. datas:[],
  131. text:[],
  132. txtDoc:''
  133. }
  134. state.addBuriedSomeList=[]//买点数据
  135. state.scaleInfo =null//量表信息
  136. },
  137. setDetail(state,param){//明细
  138. const detail = param.detail;
  139. if(JSON.stringify(detail)=='{}'){
  140. state.detailShow = false;
  141. }else{
  142. if(param.sign!=1){
  143. state.detailInfo = Object.assign({},param);
  144. state.detailShow = true;
  145. }else{
  146. if(param.idx == 0&&detail.idx == 1){
  147. state.detailInfo = Object.assign({},param);
  148. state.detailShow = true;
  149. }else{
  150. state.detailShow = false;
  151. }
  152. }
  153. }
  154. },
  155. setSearchShow(state,flg){//搜索显示与否
  156. state.searchShow = flg;
  157. },
  158. setistrue(state,flg){
  159. state.istrue = flg
  160. },
  161. setSymptomDatas(state,data){
  162. const temp = formatSymptomData(data);
  163. state.symptom.origin = temp.newArr;
  164. state.symptom.datas = JSON.parse(JSON.stringify(temp.newArr));
  165. state.extPushSymptom = temp.extSymptoms||[];
  166. },
  167. setUsualSymptom(state,data){
  168. const arr = [...data];
  169. arr.length=arr.length>10?10:arr.length;
  170. state.usualSymptom = arr;
  171. },
  172. /*setExtPushSymptom(state,data){
  173. state.extPushSymptom=data;
  174. },*/
  175. setDataAll(state,param){
  176. let res = state.allMoudles
  177. for(let i = 0;i<res.length;i++){
  178. if(res[i].type == moduleCP['suplement']){
  179. res[i].moduleDetailDTOList[param.idx] = param.data
  180. }
  181. }
  182. state.allMoudles = res
  183. },
  184. savePathInfo(state,param){
  185. let obj = param;
  186. obj.sexType = obj.patientSex == '男' ? 1 : (obj.patientSex == '女' ? 2 : 3);
  187. state.pathInfo = obj;
  188. },
  189. saveScaleInfo(state,param){
  190. let obj = param;
  191. state.scaleInfo = obj;
  192. },
  193. saveSysConfig(state,param){
  194. state.sysConfig = param;
  195. let tabType = {
  196. "1": param.length > 0 && param.filter(item => item.code == "symptoms_show")[0].value,
  197. "51": param.length > 0 && param.filter(item => item.code == "diagnosis_show")[0].value,
  198. "3": param.length > 0 && param.filter(item => item.code == "omhistory_show")[0].value,
  199. "52": param.length > 0 && param.filter(item => item.code == "replenish_show")[0].value,
  200. }
  201. state.tabType = tabType
  202. },
  203. saveAll(state,param){
  204. state.allMoudles = param;
  205. for(let k in param){
  206. if(param[k].type == moduleCP['diagT']){
  207. const arr = formatDiagUploadData(param[k].moduleDetailDTOList);
  208. state.diagnose.origin = arr;
  209. state.diagnose.datas = JSON.parse(JSON.stringify(arr));
  210. }else if(param[k].type == moduleCP['other']){
  211. const org = param[k].moduleDetailDTOList;
  212. state.others.origin = JSON.parse(JSON.stringify(org));
  213. state.others.datas = JSON.parse(JSON.stringify(org));
  214. }else if(param[k].type == moduleCP['suplement']){
  215. const org = param[k].moduleDetailDTOList;
  216. state.addContent.origin = JSON.parse(JSON.stringify(org));
  217. state.addContent.datas = JSON.parse(JSON.stringify(org));
  218. }
  219. }
  220. },
  221. setOrigin(state,param){//取消选中时用
  222. const type = parseInt(param.type);
  223. const data = param.data;
  224. switch(type){
  225. case moduleCP['symp']: //症状情况
  226. state.symptom.origin = Object.assign({},state.symptom.origin,{[data.id]:data});
  227. break;
  228. case moduleCP['diagT']: //诊疗情况
  229. let diagData = state.diagnose.origin;
  230. for(let i in diagData){
  231. if(diagData[i].id == param.pId){
  232. let questionMapping = diagData[i].questionMapping;
  233. for(let k in questionMapping){
  234. if(questionMapping[k].id == data.id){
  235. questionMapping.splice(k,1,data);
  236. }
  237. }
  238. }
  239. }
  240. break;
  241. case moduleCP['other']:
  242. let otherData = state.others.origin;
  243. for(let i in otherData){
  244. if(otherData[i].id == param.pId){
  245. let questionMapping = otherData[i].questionMapping;
  246. for(let k in questionMapping){
  247. if(questionMapping[k].id == data.id){
  248. questionMapping.splice(k,1,data);
  249. }
  250. }
  251. }
  252. }
  253. break;
  254. case moduleCP['suplement']:
  255. break;
  256. default:
  257. break;
  258. }
  259. },
  260. setModuleDatas(state,param){
  261. const {data,mName} = param;
  262. state[mName].datas = JSON.parse(JSON.stringify(data));
  263. },
  264. setDatas(state,param){
  265. // ppId--每一道题的id;pId--每个选项的id
  266. const type = parseInt(param.type);
  267. const data = param.data;
  268. const ppId = param.ppId;
  269. switch(type){
  270. case moduleCP['symp']:
  271. state.symptom.datas = Object.assign({},state.symptom.datas,{[param.pId]:data});
  272. break;
  273. case moduleCP['diagT']: //诊疗情况
  274. let diagData = state.diagnose.datas;
  275. for(let i in diagData){
  276. if(diagData[i].id == ppId){
  277. let questionMapping = diagData[i].questionMapping;
  278. for(let k in questionMapping){
  279. if(questionMapping[k].id == data.id){
  280. // questionMapping[k].questionMapping = data.questionMapping;
  281. questionMapping.splice(k,1,data);
  282. }
  283. }
  284. }
  285. }
  286. break;
  287. case moduleCP['other']:
  288. let otherData = state.others.datas;
  289. for(let i in otherData){
  290. if(otherData[i].id == ppId){
  291. let questionMapping = otherData[i].questionMapping;
  292. for(let k in questionMapping){
  293. if(questionMapping[k].id == data.id){
  294. questionMapping[k].questionMapping = data.questionMapping;
  295. }
  296. }
  297. }
  298. }
  299. break;
  300. case moduleCP['suplement']:
  301. break;
  302. default:
  303. break;
  304. }
  305. },
  306. setText(state,param){
  307. const type = parseInt(param.type);
  308. // console.log(param,787)
  309. switch(type){
  310. case moduleCP['symp']:
  311. // 对象易更新但顺序无法控制
  312. // state.symptom.text = Object.assign({},state.symptom.text,{[param.pId]:param.text});
  313. let text = state.symptom.text;
  314. if(param.isEdit){ //修改后提交的答案,先删除原存的答案
  315. text.pop();
  316. }
  317. text.push(param);
  318. break;
  319. case moduleCP['diagT']: //诊疗情况
  320. let dtext = state.diagnose.text;
  321. if(param.isEdit){
  322. dtext.pop();
  323. }
  324. dtext.push(param);
  325. break;
  326. case moduleCP['other']: //其他情况
  327. let otherText = state.others.text;
  328. if(param.isEdit){
  329. otherText.pop();
  330. }
  331. otherText.push(param);
  332. /*let oitem = otherText[param.order];
  333. if(oitem){
  334. // 判断是对象还是数组--数组则区分index
  335. if(Array.isArray(oitem)){
  336. if(param.flag){//详情完成-覆盖
  337. oitem[param.index] = param;
  338. }else{ //直接点label--无则覆盖
  339. if(!oitem[param.index]){
  340. oitem[param.index] = param;
  341. }
  342. }
  343. }else{
  344. if(param.flag){
  345. otherText[param.order] = param;
  346. }
  347. }
  348. }else{
  349. if(param.arrFlag){
  350. let temp = [];
  351. temp[param.index] = param;
  352. otherText[param.order] = temp;
  353. }else{
  354. otherText[param.order] = param;
  355. }
  356. }
  357. state.others.text = otherText;*/
  358. break;
  359. case moduleCP['suplement']:
  360. let addText = state.addContent.text
  361. if(param.isEdit){
  362. addText.pop();
  363. }
  364. addText.push(param);
  365. break;
  366. default:
  367. break;
  368. }
  369. },
  370. delText(state,param){
  371. const type = parseInt(param.type);
  372. switch(type){
  373. case moduleCP['symp']:
  374. let text = state.symptom.text;
  375. for(let i in text){
  376. if(text[i].pId==param.pId){
  377. text.splice(i,1)
  378. }
  379. }
  380. break;
  381. case moduleCP['diagT']: //诊疗情况
  382. let diaText = JSON.parse(JSON.stringify(state.diagnose.text));
  383. let temp = diaText[param.order];
  384. temp[param.index] = null;
  385. state.diagnose.text = diaText;
  386. break;
  387. case moduleCP['other']:
  388. let otherText = JSON.parse(JSON.stringify(state.others.text));
  389. let otemp = otherText[param.order];
  390. otemp[param.index] = null;
  391. state.others.text = otherText;
  392. break;
  393. case moduleCP['suplement']:
  394. break;
  395. default:
  396. break;
  397. }
  398. },
  399. setChoose(state,param){ //症状情况-已选症状
  400. state.symptom.choose = param.choose;
  401. },
  402. setScroll(state,data){ //症状情况-已选症状
  403. state.scroll = data;
  404. },
  405. delChoose(state,param){ //详情有必填项未填--移除症状
  406. const id = param.id;
  407. let symp = state.symptom.choose;
  408. for(let i=0; i<symp.length; i++){
  409. if(id == (symp[i].id || symp[i].questionId)){
  410. symp.splice(i,1);
  411. }
  412. }
  413. },
  414. setImgFile(state,param){//区别模块
  415. const type = parseInt(param.type);
  416. switch(type){
  417. case moduleCP['symp']:
  418. break;
  419. case moduleCP['diagT']: //诊疗情况
  420. state.diagnose.imgFile.push(param);
  421. break;
  422. case moduleCP['other']:
  423. break;
  424. case moduleCP['suplement']:
  425. break;
  426. default:
  427. break;
  428. }
  429. },
  430. setImgSrc(state,param){
  431. const key = param.key;
  432. const src = param.src;
  433. const type = parseInt(param.type);
  434. switch(type){
  435. case moduleCP['symp']:
  436. break;
  437. case moduleCP['diagT']:
  438. state.diagnose.imgSrc = Object.assign({},state.diagnose.imgSrc,{[key]:src});
  439. break;
  440. case moduleCP['other']:
  441. break;
  442. case moduleCP['suplement']:
  443. break;
  444. default:
  445. break;
  446. }
  447. },
  448. deleImg(state,param){
  449. const key = param.key;
  450. const type = parseInt(param.type);
  451. switch(type){
  452. case moduleCP['symp']:
  453. break;
  454. case moduleCP['diagT']:
  455. let data = state.diagnose.imgFile;
  456. for(let i=0; i<data.length;i++){
  457. if(data[i].key==key){
  458. data.splice(i,1)
  459. }
  460. }
  461. break;
  462. case moduleCP['other']:
  463. break;
  464. case moduleCP['suplement']:
  465. break;
  466. default:
  467. break;
  468. }
  469. },
  470. cancelImgs(state){
  471. state.diagnose.imgFile=[];
  472. state.diagnose.imgSrc = {};
  473. },
  474. setUploadImgs(state,list){
  475. state.uploadImgs=list;
  476. },
  477. deleSrc(state,param){
  478. const key = param.key;
  479. const type = parseInt(param.type);
  480. switch(type){
  481. case moduleCP['symp']:
  482. break;
  483. case moduleCP['diagT']:
  484. let data = state.diagnose.imgFile;
  485. let obj = state.diagnose.imgSrc;
  486. delete(obj[key]);
  487. state.diagnose.imgSrc = Object.assign({},obj);
  488. break;
  489. case moduleCP['other']:
  490. break;
  491. case moduleCP['suplement']:
  492. break;
  493. default:
  494. break;
  495. }
  496. },
  497. handleToggleShow(state,flg){
  498. state.loadingShow = flg
  499. }
  500. }
  501. });
  502. function formatDiagUploadData(data){
  503. //上传图片类型处理,前面添加一个问题
  504. const inx = data.findIndex((it)=>{
  505. return it.controlType==4;
  506. });
  507. let newArr = JSON.parse(JSON.stringify(data));
  508. if(inx!==-1){
  509. newArr.splice(inx,0,{
  510. id: 999999,
  511. name: "有可以上传的最近一次诊疗记录吗?",
  512. tagName: "有可以上传的最近一次诊疗记录吗?",
  513. type: 51,
  514. controlType: 1,
  515. itemType: 0,
  516. tagType: 1,
  517. labelPrefix: "",
  518. labelSuffix: "",
  519. url: "",
  520. description: "",
  521. specFlag: 0,
  522. required: 0,
  523. explains: null,
  524. exclusionType: null,
  525. 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}
  526. ],
  527. questionMapping: [],
  528. flag: "",
  529. remark: null,
  530. prefix: "",
  531. suffix: "",
  532. moduleId: 2,
  533. questionId: 1191,
  534. relationModule: null,
  535. relationModuleName: null});
  536. };
  537. return newArr;
  538. };
  539. function formatSymptomData(data){
  540. //症状详情后添加一个大数据推送其他症状
  541. let newArr = JSON.parse(JSON.stringify(data));
  542. newArr.push({
  543. id: 999998,
  544. name: "还有其他不舒服吗?(可多选)",
  545. tagName: "还有其他不舒服吗?",
  546. type: 1,
  547. controlType: 99,
  548. itemType: 0,
  549. tagType: 1,
  550. labelPrefix: "",
  551. labelSuffix: "",
  552. url: "",
  553. description: "",
  554. specFlag: 0,
  555. required: 0,
  556. explains: null,
  557. exclusionType: null,
  558. questionDetailList:[],
  559. questionMapping: [],
  560. flag: "",
  561. remark: null,
  562. prefix: "",
  563. suffix: "",
  564. moduleId: 2,
  565. questionId: 999998,
  566. relationModule: null,
  567. relationModuleName: null});
  568. //多选伴随类型不展示问题,选项添加到推送症状前
  569. let extSymptoms = [];
  570. const n = data.findIndex((it)=>{
  571. if(+it.controlType===8){
  572. extSymptoms = it.questionDetailList;
  573. }
  574. return +it.controlType===8;
  575. });
  576. if(n!==-1){
  577. newArr.splice(n,1);
  578. }
  579. return {newArr,extSymptoms};
  580. };
  581. export default store;