store.js 16 KB

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