store.js 16 KB

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