store.js 16 KB

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