store.js 15 KB

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