store.js 16 KB

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