store.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. scroll:{
  12. x:0,y:0
  13. },
  14. symptom:{ //症状情况
  15. choose:[],
  16. origin:{},
  17. datas:{},
  18. text:[],
  19. },
  20. diagnose:{ //诊疗
  21. origin:[], //模板数据
  22. datas:[],
  23. text:[],
  24. imgFile:[],//上传图片信息file
  25. imgSrc:{},//上传的图片信息src
  26. },
  27. others:{ //其他情况
  28. origin:[], //模板数据
  29. datas:[],
  30. text:[],
  31. imgFile:[],
  32. imgSrc:{},
  33. },
  34. addContent:{
  35. origin:[],
  36. txt:'',
  37. txtDoc:''
  38. },
  39. activeModule:{},//有效显示的模块
  40. loadingShow:false,
  41. detailInfo:{},
  42. detailShow:false,
  43. finish:{ //标识已填
  44. '1':true,
  45. '51':false,
  46. '3':false,
  47. '52':false
  48. },
  49. currentTab:{ //标识当前tab页
  50. '1':true,
  51. '51':false,
  52. '3':false,
  53. '52':false
  54. },
  55. tabType: {
  56. "1": 1,
  57. "51": 0,
  58. "3": 0,
  59. "52": 0,
  60. },
  61. },
  62. mutations:{
  63. setFinish(state,param){
  64. let obj = state.finish
  65. let obj1 = state.currentTab
  66. for(let key in obj){
  67. if(key == param){
  68. obj[key] = true
  69. obj1[key] = true
  70. }else{
  71. obj1[key] = false
  72. }
  73. }
  74. state.finish = obj
  75. },
  76. setActiveModule(state,param){
  77. state.activeModule = param
  78. },
  79. initAllData(state){
  80. state.symptom={ //症状情况
  81. choose:[],
  82. origin:{},
  83. datas:{},
  84. text:[],
  85. }
  86. state.diagnose={ //诊疗
  87. origin:[], //模板数据
  88. datas:[],
  89. text:[],
  90. imgFile:[],
  91. imgSrc:{},
  92. }
  93. state.others={ //其他情况
  94. origin:[], //模板数据
  95. datas:[],
  96. text:[],
  97. imgFile:[],
  98. imgSrc:{},
  99. }
  100. state.addContent={
  101. origin:[],
  102. txt:'',
  103. txtDoc:''
  104. }
  105. },
  106. setDetail(state,param){//明细
  107. const detail = param.detail;
  108. if(JSON.stringify(detail)=='{}'){
  109. state.detailShow = false;
  110. }else{
  111. if(param.sign!=1){
  112. state.detailInfo = Object.assign({},param);
  113. state.detailShow = true;
  114. }else{
  115. if(param.idx == 0&&detail.idx == 1){
  116. state.detailInfo = Object.assign({},param);
  117. state.detailShow = true;
  118. }else{
  119. state.detailShow = false;
  120. }
  121. }
  122. }
  123. },
  124. setSearchShow(state,flg){//搜索显示与否
  125. state.searchShow = flg;
  126. },
  127. setDataAll(state,param){
  128. let res = state.allMoudles
  129. for(let i = 0;i<res.length;i++){
  130. if(res[i].type == moduleCP['suplement']){
  131. res[i].moduleDetailDTOList[param.idx] = param.data
  132. }
  133. }
  134. state.allMoudles = res
  135. },
  136. savePathInfo(state,param){
  137. let obj = param;
  138. obj.sexType = obj.patientSex == '男' ? 1 : (obj.patientSex == '女' ? 2 : 3);
  139. obj.doctorName = '傻子'
  140. obj.recordId = '265254885'
  141. state.pathInfo = obj;
  142. },
  143. saveSysConfig(state,param){
  144. state.sysConfig = param;
  145. let tabType = {
  146. "1": param.length > 0 && param.filter(item => item.code == "symptoms_show")[0].value,
  147. "51": param.length > 0 && param.filter(item => item.code == "diagnosis_show")[0].value,
  148. "3": param.length > 0 && param.filter(item => item.code == "omhistory_show")[0].value,
  149. "52": param.length > 0 && param.filter(item => item.code == "replenish_show")[0].value,
  150. }
  151. state.tabType = tabType
  152. },
  153. saveAll(state,param){
  154. state.allMoudles = param;
  155. for(let k in param){
  156. if(param[k].type == moduleCP['diagT']){
  157. state.diagnose.origin = JSON.parse(JSON.stringify(param[k].moduleDetailDTOList))
  158. state.diagnose.datas = JSON.parse(JSON.stringify(param[k].moduleDetailDTOList))
  159. }else if(param[k].type == moduleCP['other']){
  160. state.others.origin = JSON.parse(JSON.stringify(param[k].moduleDetailDTOList))
  161. state.others.datas = JSON.parse(JSON.stringify(param[k].moduleDetailDTOList))
  162. }
  163. }
  164. },
  165. setOrigin(state,param){//取消选中时用
  166. const type = parseInt(param.type);
  167. const data = param.data;
  168. switch(type){
  169. case moduleCP['symp']: //症状情况
  170. state.symptom.origin = Object.assign({},state.symptom.origin,{[data.id]:data});
  171. break;
  172. case moduleCP['diagT']: //诊疗情况
  173. let diagData = state.diagnose.origin;
  174. for(let i in diagData){
  175. if(diagData[i].id == param.pId){
  176. let questionMapping = diagData[i].questionMapping;
  177. for(let k in questionMapping){
  178. if(questionMapping[k].id == data.id){
  179. questionMapping.splice(k,1,data);
  180. }
  181. }
  182. }
  183. }
  184. break;
  185. case moduleCP['other']:
  186. let otherData = state.others.origin;
  187. for(let i in otherData){
  188. if(otherData[i].id == param.pId){
  189. let questionMapping = otherData[i].questionMapping;
  190. for(let k in questionMapping){
  191. if(questionMapping[k].id == data.id){
  192. questionMapping.splice(k,1,data);
  193. }
  194. }
  195. }
  196. }
  197. break;
  198. case moduleCP['suplement']:
  199. break;
  200. default:
  201. break;
  202. }
  203. },
  204. setDatas(state,param){
  205. // ppId--每一道题的id;pId--每个选项的id
  206. const type = parseInt(param.type);
  207. const data = param.data;
  208. const ppId = param.ppId;
  209. switch(type){
  210. case moduleCP['symp']:
  211. state.symptom.datas = Object.assign({},state.symptom.datas,{[param.pId]:data});
  212. break;
  213. case moduleCP['diagT']: //诊疗情况
  214. let diagData = state.diagnose.datas;
  215. for(let i in diagData){
  216. if(diagData[i].id == ppId){
  217. let questionMapping = diagData[i].questionMapping;
  218. for(let k in questionMapping){
  219. if(questionMapping[k].id == data.id){
  220. // questionMapping[k].questionMapping = data.questionMapping;
  221. questionMapping.splice(k,1,data);
  222. }
  223. }
  224. }
  225. }
  226. break;
  227. case moduleCP['other']:
  228. let otherData = state.others.datas;
  229. for(let i in otherData){
  230. if(otherData[i].id == ppId){
  231. let questionMapping = otherData[i].questionMapping;
  232. for(let k in questionMapping){
  233. if(questionMapping[k].id == data.id){
  234. questionMapping[k].questionMapping = data.questionMapping;
  235. }
  236. }
  237. }
  238. }
  239. break;
  240. case moduleCP['suplement']:
  241. break;
  242. default:
  243. break;
  244. }
  245. },
  246. setText(state,param){
  247. const type = parseInt(param.type);
  248. switch(type){
  249. case moduleCP['symp']:
  250. // 对象易更新但顺序无法控制
  251. // state.symptom.text = Object.assign({},state.symptom.text,{[param.pId]:param.text});
  252. let text = state.symptom.text;
  253. if(text.length > 0){
  254. for(let i in text){
  255. // 点完成时才覆盖,单纯点开再关闭不覆盖flag
  256. if(text[i].pId==param.pId){
  257. if(param.flag){
  258. text.splice(i,1,param);
  259. }
  260. return
  261. }
  262. }
  263. }
  264. text.push(param);
  265. break;
  266. case moduleCP['diagT']: //诊疗情况
  267. let diaText = JSON.parse(JSON.stringify(state.diagnose.text));
  268. // 先判断order,然后判断index
  269. let item = diaText[param.order];
  270. if(item){
  271. // 判断是对象还是数组--数组则区分index
  272. if(Array.isArray(item)){
  273. if(param.flag){//详情完成-覆盖
  274. item[param.index] = param;
  275. }else{ //直接点label--无则覆盖
  276. if(!item[param.index]){
  277. item[param.index] = param;
  278. }
  279. }
  280. }else{
  281. if(param.flag){
  282. diaText[param.order] = param;
  283. }
  284. }
  285. }else{
  286. if(param.arrFlag){
  287. let temp = [];
  288. temp[param.index] = param;
  289. diaText[param.order] = temp;
  290. }else{
  291. diaText[param.order] = param;
  292. }
  293. }
  294. state.diagnose.text = diaText;
  295. break;
  296. case moduleCP['other']: //其他情况
  297. let otherText = JSON.parse(JSON.stringify(state.others.text));
  298. let oitem = otherText[param.order];
  299. if(oitem){
  300. // 判断是对象还是数组--数组则区分index
  301. if(Array.isArray(oitem)){
  302. if(param.flag){//详情完成-覆盖
  303. oitem[param.index] = param;
  304. }else{ //直接点label--无则覆盖
  305. if(!oitem[param.index]){
  306. oitem[param.index] = param;
  307. }
  308. }
  309. }else{
  310. if(param.flag){
  311. otherText[param.order] = param;
  312. }
  313. }
  314. }else{
  315. if(param.arrFlag){
  316. let temp = [];
  317. temp[param.index] = param;
  318. otherText[param.order] = temp;
  319. }else{
  320. otherText[param.order] = param;
  321. }
  322. }
  323. state.others.text = otherText;
  324. break;
  325. case moduleCP['suplement']:
  326. let addText = state.addContent.txt
  327. state.addContent.origin = param.data
  328. state.addContent.txt = getAllStr(param).allStr
  329. state.addContent.txtDoc = getAllStr(param).allStrDoc
  330. break;
  331. default:
  332. break;
  333. }
  334. },
  335. delText(state,param){
  336. const type = parseInt(param.type);
  337. switch(type){
  338. case moduleCP['symp']:
  339. let text = state.symptom.text;
  340. for(let i in text){
  341. if(text[i].pId==param.pId){
  342. text.splice(i,1)
  343. }
  344. }
  345. break;
  346. case moduleCP['diagT']: //诊疗情况
  347. let diaText = JSON.parse(JSON.stringify(state.diagnose.text));
  348. let temp = diaText[param.order];
  349. temp[param.index] = null;
  350. state.diagnose.text = diaText;
  351. break;
  352. case moduleCP['other']:
  353. let otherText = JSON.parse(JSON.stringify(state.others.text));
  354. let otemp = otherText[param.order];
  355. otemp[param.index] = null;
  356. state.others.text = otherText;
  357. break;
  358. case moduleCP['suplement']:
  359. break;
  360. default:
  361. break;
  362. }
  363. },
  364. setChoose(state,param){ //症状情况-已选症状
  365. state.symptom.choose = param.choose;
  366. },
  367. setScroll(state,data){ //症状情况-已选症状
  368. state.scroll = data;
  369. },
  370. delChoose(state,param){ //详情有必填项未填--移除症状
  371. const id = param.id;
  372. let symp = state.symptom.choose;
  373. for(let i=0; i<symp.length; i++){
  374. if(id == (symp[i].id || symp[i].questionId)){
  375. symp.splice(i,1);
  376. }
  377. }
  378. },
  379. setImgFile(state,param){//区别模块
  380. const type = parseInt(param.type);
  381. switch(type){
  382. case moduleCP['symp']:
  383. break;
  384. case moduleCP['diagT']: //诊疗情况
  385. state.diagnose.imgFile.push(param);
  386. break;
  387. case moduleCP['other']:
  388. break;
  389. case moduleCP['suplement']:
  390. break;
  391. default:
  392. break;
  393. }
  394. },
  395. setImgSrc(state,param){
  396. const key = param.key;
  397. const src = param.src;
  398. const type = parseInt(param.type);
  399. switch(type){
  400. case moduleCP['symp']:
  401. break;
  402. case moduleCP['diagT']:
  403. state.diagnose.imgSrc = Object.assign({},state.diagnose.imgSrc,{[key]:src});
  404. break;
  405. case moduleCP['other']:
  406. break;
  407. case moduleCP['suplement']:
  408. break;
  409. default:
  410. break;
  411. }
  412. },
  413. deleImg(state,param){
  414. const key = param.key;
  415. const type = parseInt(param.type);
  416. switch(type){
  417. case moduleCP['symp']:
  418. break;
  419. case moduleCP['diagT']:
  420. let data = state.diagnose.imgFile;
  421. for(let i=0; i<data.length;i++){
  422. if(data[i].key==key){
  423. data.splice(i,1)
  424. }
  425. }
  426. break;
  427. case moduleCP['other']:
  428. break;
  429. case moduleCP['suplement']:
  430. break;
  431. default:
  432. break;
  433. }
  434. },
  435. deleSrc(state,param){
  436. const key = param.key;
  437. const type = parseInt(param.type);
  438. switch(type){
  439. case moduleCP['symp']:
  440. break;
  441. case moduleCP['diagT']:
  442. let data = state.diagnose.imgFile;
  443. let obj = state.diagnose.imgSrc;
  444. delete(obj[key]);
  445. state.diagnose.imgSrc = Object.assign({},obj);
  446. break;
  447. case moduleCP['other']:
  448. break;
  449. case moduleCP['suplement']:
  450. break;
  451. default:
  452. break;
  453. }
  454. },
  455. handleToggleShow(state,flg){
  456. state.loadingShow = flg
  457. }
  458. }
  459. })
  460. export default store;