store.js 16 KB

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