store.js 16 KB

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