store.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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. // console.log(param,787)
  298. switch(type){
  299. case moduleCP['symp']:
  300. // 对象易更新但顺序无法控制
  301. // state.symptom.text = Object.assign({},state.symptom.text,{[param.pId]:param.text});
  302. let text = state.symptom.text;
  303. if(param.isEdit){ //修改后提交的答案,先删除原存的答案
  304. text.pop();
  305. }
  306. text.push(param);
  307. break;
  308. case moduleCP['diagT']: //诊疗情况
  309. let dtext = state.diagnose.text;
  310. if(param.isEdit){
  311. dtext.pop();
  312. }
  313. dtext.push(param);
  314. break;
  315. case moduleCP['other']: //其他情况
  316. let otherText = state.others.text;
  317. if(param.isEdit){
  318. otherText.pop();
  319. }
  320. otherText.push(param);
  321. /*let oitem = otherText[param.order];
  322. if(oitem){
  323. // 判断是对象还是数组--数组则区分index
  324. if(Array.isArray(oitem)){
  325. if(param.flag){//详情完成-覆盖
  326. oitem[param.index] = param;
  327. }else{ //直接点label--无则覆盖
  328. if(!oitem[param.index]){
  329. oitem[param.index] = param;
  330. }
  331. }
  332. }else{
  333. if(param.flag){
  334. otherText[param.order] = param;
  335. }
  336. }
  337. }else{
  338. if(param.arrFlag){
  339. let temp = [];
  340. temp[param.index] = param;
  341. otherText[param.order] = temp;
  342. }else{
  343. otherText[param.order] = param;
  344. }
  345. }
  346. state.others.text = otherText;*/
  347. break;
  348. case moduleCP['suplement']:
  349. let addText = state.addContent.text
  350. if(param.isEdit){
  351. addText.pop();
  352. }
  353. addText.push(param);
  354. break;
  355. default:
  356. break;
  357. }
  358. },
  359. delText(state,param){
  360. const type = parseInt(param.type);
  361. switch(type){
  362. case moduleCP['symp']:
  363. let text = state.symptom.text;
  364. for(let i in text){
  365. if(text[i].pId==param.pId){
  366. text.splice(i,1)
  367. }
  368. }
  369. break;
  370. case moduleCP['diagT']: //诊疗情况
  371. let diaText = JSON.parse(JSON.stringify(state.diagnose.text));
  372. let temp = diaText[param.order];
  373. temp[param.index] = null;
  374. state.diagnose.text = diaText;
  375. break;
  376. case moduleCP['other']:
  377. let otherText = JSON.parse(JSON.stringify(state.others.text));
  378. let otemp = otherText[param.order];
  379. otemp[param.index] = null;
  380. state.others.text = otherText;
  381. break;
  382. case moduleCP['suplement']:
  383. break;
  384. default:
  385. break;
  386. }
  387. },
  388. setChoose(state,param){ //症状情况-已选症状
  389. state.symptom.choose = param.choose;
  390. },
  391. setScroll(state,data){ //症状情况-已选症状
  392. state.scroll = data;
  393. },
  394. delChoose(state,param){ //详情有必填项未填--移除症状
  395. const id = param.id;
  396. let symp = state.symptom.choose;
  397. for(let i=0; i<symp.length; i++){
  398. if(id == (symp[i].id || symp[i].questionId)){
  399. symp.splice(i,1);
  400. }
  401. }
  402. },
  403. setImgFile(state,param){//区别模块
  404. const type = parseInt(param.type);
  405. switch(type){
  406. case moduleCP['symp']:
  407. break;
  408. case moduleCP['diagT']: //诊疗情况
  409. state.diagnose.imgFile.push(param);
  410. break;
  411. case moduleCP['other']:
  412. break;
  413. case moduleCP['suplement']:
  414. break;
  415. default:
  416. break;
  417. }
  418. },
  419. setImgSrc(state,param){
  420. const key = param.key;
  421. const src = param.src;
  422. const type = parseInt(param.type);
  423. switch(type){
  424. case moduleCP['symp']:
  425. break;
  426. case moduleCP['diagT']:
  427. state.diagnose.imgSrc = Object.assign({},state.diagnose.imgSrc,{[key]:src});
  428. break;
  429. case moduleCP['other']:
  430. break;
  431. case moduleCP['suplement']:
  432. break;
  433. default:
  434. break;
  435. }
  436. },
  437. deleImg(state,param){
  438. const key = param.key;
  439. const type = parseInt(param.type);
  440. switch(type){
  441. case moduleCP['symp']:
  442. break;
  443. case moduleCP['diagT']:
  444. let data = state.diagnose.imgFile;
  445. for(let i=0; i<data.length;i++){
  446. if(data[i].key==key){
  447. data.splice(i,1)
  448. }
  449. }
  450. break;
  451. case moduleCP['other']:
  452. break;
  453. case moduleCP['suplement']:
  454. break;
  455. default:
  456. break;
  457. }
  458. },
  459. cancelImgs(state){
  460. state.diagnose.imgFile=[];
  461. state.diagnose.imgSrc = {};
  462. },
  463. setUploadImgs(state,list){
  464. state.uploadImgs=list;
  465. },
  466. deleSrc(state,param){
  467. const key = param.key;
  468. const type = parseInt(param.type);
  469. switch(type){
  470. case moduleCP['symp']:
  471. break;
  472. case moduleCP['diagT']:
  473. let data = state.diagnose.imgFile;
  474. let obj = state.diagnose.imgSrc;
  475. delete(obj[key]);
  476. state.diagnose.imgSrc = Object.assign({},obj);
  477. break;
  478. case moduleCP['other']:
  479. break;
  480. case moduleCP['suplement']:
  481. break;
  482. default:
  483. break;
  484. }
  485. },
  486. handleToggleShow(state,flg){
  487. state.loadingShow = flg
  488. }
  489. }
  490. });
  491. function formatDiagUploadData(data){
  492. //上传图片类型处理,前面添加一个问题
  493. const inx = data.findIndex((it)=>{
  494. return it.controlType==4;
  495. });
  496. let newArr = JSON.parse(JSON.stringify(data));
  497. if(inx!==-1){
  498. newArr.splice(inx,0,{
  499. id: 999999,
  500. name: "有可以上传的最近一次诊疗记录吗?",
  501. tagName: "有可以上传的最近一次诊疗记录吗?",
  502. type: 51,
  503. controlType: 1,
  504. itemType: 0,
  505. tagType: 1,
  506. labelPrefix: "",
  507. labelSuffix: "",
  508. url: "",
  509. description: "",
  510. specFlag: 0,
  511. required: 0,
  512. explains: null,
  513. exclusionType: null,
  514. 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}
  515. ],
  516. questionMapping: [],
  517. flag: "",
  518. remark: null,
  519. prefix: "",
  520. suffix: "",
  521. moduleId: 2,
  522. questionId: 1191,
  523. relationModule: null,
  524. relationModuleName: null});
  525. };
  526. return newArr;
  527. };
  528. function formatSymptomData(data){
  529. //症状详情后添加一个大数据推送其他症状
  530. let newArr = JSON.parse(JSON.stringify(data));
  531. newArr.push({
  532. id: 999998,
  533. name: "还有其他不舒服吗?(可多选)",
  534. tagName: "还有其他不舒服吗?",
  535. type: 1,
  536. controlType: 99,
  537. itemType: 0,
  538. tagType: 1,
  539. labelPrefix: "",
  540. labelSuffix: "",
  541. url: "",
  542. description: "",
  543. specFlag: 0,
  544. required: 0,
  545. explains: null,
  546. exclusionType: null,
  547. questionDetailList:[],
  548. questionMapping: [],
  549. flag: "",
  550. remark: null,
  551. prefix: "",
  552. suffix: "",
  553. moduleId: 2,
  554. questionId: 999998,
  555. relationModule: null,
  556. relationModuleName: null});
  557. //多选伴随类型不展示问题,选项添加到推送症状前
  558. let extSymptoms = [];
  559. const n = data.findIndex((it)=>{
  560. if(+it.controlType===8){
  561. extSymptoms = it.questionDetailList;
  562. }
  563. return +it.controlType===8;
  564. });
  565. if(n!==-1){
  566. newArr.splice(n,1);
  567. }
  568. return {newArr,extSymptoms};
  569. };
  570. export default store;