newAdvice.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. import {
  2. SEARCH_LIST,
  3. SET_LABEL,
  4. FILL_ACTIVE,
  5. GET_EXCEL,
  6. CHECK_VALUE_IS_CHANGE,
  7. CLEAR_LABEL,
  8. RESET_LABEL_NEW,
  9. CLEAR_ALL_LABEL,
  10. DEL_PART_ITEM_NEW,
  11. DEL_EXCEL_LIST,
  12. ADD_LABEL,
  13. SET_CONTEXT,
  14. SET_TIP_ADVICE,
  15. DEL_ONE_PIC_NEW,
  16. SEARCH_TYPE_NEW,
  17. CHECK_OFF_ON_NEW,
  18. RENEWADVICEDATA,
  19. CLEARNEWADVICEDATA,
  20. SELECTJITYPE,
  21. HANDLESELECTSHOW,
  22. HANDLESUI,
  23. } from '../types/newAdvice';
  24. import store from '@store';
  25. import {getStringPlus,getPushLists,getPushList,getCurrentDate} from '@utils/tools.js';
  26. const initSearchList = {
  27. list: [], //搜索的结果
  28. labelList: [], //选中的结果,也是需要保存的数据
  29. labelListActive: [], //缓存值
  30. fillActive: {}, //选中的标签的填写单
  31. getExcelData: {}, //导入的数据
  32. inspectStrPlus:'',
  33. getExcelDataList: [], //导入的数据
  34. pushItem:[], //推送的数据
  35. pushItems:[], //右侧模板预览的数据
  36. inspectVal:'',
  37. context:{},
  38. shType:5,
  39. labelListBig:[],//大项
  40. labelListSmall:[],//小项
  41. labelListBlood:[],//输血
  42. drugOrder:[],//开单项
  43. operationOrder:[],//开单项
  44. transfusionOrder:[],
  45. activeIdx:'',
  46. operationName:{}
  47. }
  48. export default (state = initSearchList, action) => {
  49. if (action.type == HANDLESUI) {
  50. const newState = Object.assign({}, state);
  51. let tempArr = newState.labelListSmall;
  52. let tmpLis = action.item
  53. for(let i = 0;i < tempArr.length;i++){
  54. if(action.idx == i){
  55. tempArr[i].hasTreat = 1
  56. }else{
  57. tempArr[i].hasTreat = 0
  58. }
  59. }
  60. let obj = {
  61. "dateValue": tmpLis.dateValue,
  62. "name": tmpLis.name,
  63. "uniqueName": tmpLis.name
  64. }
  65. newState.labelListSmall = [...tempArr]
  66. newState.operationName = obj
  67. return newState;
  68. }
  69. if (action.type == HANDLESELECTSHOW) {
  70. const newState = Object.assign({}, state);
  71. let tempArr = newState.labelListBig;
  72. for(let i = 0;i < tempArr.length;i++){
  73. if(action.idx == i){
  74. let flg = tempArr[i].selectShow;
  75. tempArr[i].selectShow = action.sign==1?true:action.sign==0?false:!flg
  76. newState.activeIdx = action.idx
  77. }
  78. }
  79. newState.labelListBig = [...tempArr]
  80. return newState;
  81. }
  82. if (action.type == SELECTJITYPE) {
  83. const newState = Object.assign({}, state);
  84. let tempArr = newState.labelListBig;
  85. for(let i = 0;i < tempArr.length;i++){
  86. if(action.idx == i){
  87. tempArr[i].selectShow = false
  88. tempArr[i].form = action.part.name
  89. tempArr[i].selectVal = action.part.val
  90. }
  91. }
  92. newState.labelListBig = [...tempArr]
  93. return newState;
  94. }
  95. if (action.type == CHECK_OFF_ON_NEW) {
  96. const newState = Object.assign({}, state);
  97. let tempArr = newState.labelListBig;
  98. let tempArrs = newState.labelListSmall;
  99. let tmpArr = newState.labelListBlood;
  100. let tmpLis = action.item,tempBigOrder=[],tempSmallOrder=[],tempBloodOrder=[],tempTotalOrder=[];
  101. if(tmpLis&&tmpLis.flg == 5){//药品
  102. for(let i = 0;i < tempArr.length;i++){
  103. if(action.tip == i){
  104. let flg = tempArr[i].check;
  105. tempArr[i].check = !flg
  106. }
  107. }
  108. newState.labelListBig = [...tempArr]
  109. }else if(tmpLis&&tmpLis.flg == 6){//手术、操作
  110. for(let i = 0;i < tempArrs.length;i++){
  111. if(action.tip == i){
  112. let flg = tempArrs[i].check;
  113. tempArrs[i].check = !flg
  114. }
  115. }
  116. newState.labelListSmall = [...tempArrs]
  117. }else if(tmpLis&&tmpLis.flg == 8){//输血
  118. for(let i = 0;i < tmpArr.length;i++){
  119. if(action.tip == i){
  120. let flg = tmpArr[i].check;
  121. tmpArr[i].check = !flg
  122. }
  123. }
  124. newState.labelListBlood = [...tmpArr]
  125. }
  126. tempBigOrder = tempArr.filter((item)=>item.check)
  127. tempSmallOrder = tempArrs.filter((item)=>item.check)
  128. tempBloodOrder = tmpArr.filter((item)=>item.check)
  129. newState.drugOrder=[...tempBigOrder]
  130. newState.operationOrder=[...tempSmallOrder]
  131. newState.transfusionOrder=[...tempBloodOrder]
  132. return newState;
  133. }
  134. if (action.type == DEL_ONE_PIC_NEW) {
  135. const newState = Object.assign({}, state);
  136. let tempArr = newState.labelListBig;
  137. let tempArrs = newState.labelListSmall;
  138. let tmpArr = newState.labelListBlood;
  139. let tmpLis = action.item,tempBigOrder=[],tempSmallOrder=[],tempBloodOrder=[],tempTotalOrder=[],num=0;
  140. if(tmpLis&&tmpLis.flg == 5){
  141. tempArr = tempArr.filter((item,idx)=>{
  142. if(action.tip != idx){
  143. return item
  144. }
  145. })
  146. newState.labelListBig = [...tempArr]
  147. }else if(tmpLis&&tmpLis.flg == 6){
  148. tempArrs = tempArrs.filter((item,idx)=> {
  149. if(item['hasTreat'] = 1){
  150. newState.operationName = {}
  151. }
  152. if(action.tip != idx){
  153. return item
  154. }
  155. })
  156. for(let i = 0;i < tempArrs.length;i++){
  157. if(!tempArrs[i].hasTreat){
  158. ++num
  159. }
  160. }
  161. if(tempArrs.length>0&&num == tempArrs.length){
  162. tempArrs[0]['hasTreat'] = 1
  163. let obj = {
  164. "dateValue": tempArrs[0].dateValue,
  165. "name": tempArrs[0].name,
  166. "uniqueName": tempArrs[0].name
  167. }
  168. newState.operationName = obj
  169. }
  170. newState.labelListSmall = [...tempArrs]
  171. }else if(tmpLis&&tmpLis.flg == 8){
  172. tmpArr = tmpArr.filter((item,idx)=> {
  173. if(action.tip != idx){
  174. return item
  175. }
  176. })
  177. newState.labelListBlood = [...tmpArr]
  178. }
  179. tempBigOrder = tempArr.filter((item)=>item.check)
  180. tempSmallOrder = tempArrs.filter((item)=>item.check)
  181. tempBloodOrder = tmpArr.filter((item)=>item.check)
  182. tempTotalOrder=tempBigOrder.concat(tempSmallOrder)
  183. newState.drugOrder=[...tempBigOrder]
  184. newState.operationOrder=[...tempSmallOrder]
  185. newState.transfusionOrder=[...tempBloodOrder]
  186. return newState;
  187. }
  188. if (action.type == SET_TIP_ADVICE) {
  189. const newState = Object.assign({}, state);
  190. let tempArr = newState.labelListBig;
  191. let tempArrs = newState.labelListSmall;
  192. let tmpArr = newState.labelListBlood;
  193. let tmpLis = action.item
  194. if(tmpLis.flg == 5){//药品
  195. for(let i= 0;i < tempArr.length;i++){
  196. if(action.tip == i){
  197. if(action.sign == 1){//时间
  198. tempArr[i].time = action.value
  199. tempArr[i].dateValue = action.value
  200. }else{
  201. tempArr[i].value = action.value
  202. }
  203. }
  204. }
  205. newState.labelListBig = tempArr
  206. }else if(tmpLis.flg == 6){//手术
  207. for(let i= 0;i < tempArrs.length;i++){
  208. if(action.tip == i){
  209. tempArrs[i].time = action.value
  210. tempArrs[i].dateValue = action.value
  211. if(tmpLis.hasTreat){
  212. let obj = {
  213. "dateValue": action.value,
  214. "name": tmpLis.name,
  215. "uniqueName": tmpLis.name
  216. }
  217. newState.operationName = obj
  218. }
  219. }
  220. }
  221. newState.labelListSmall = tempArrs
  222. }if(tmpLis.flg == 8){//输血
  223. for(let i= 0;i < tmpArr.length;i++){
  224. if(action.tip == i){
  225. if(action.sign == 1){
  226. tmpArr[i].time = action.value
  227. tmpArr[i].dateValue = action.value
  228. }else{
  229. tmpArr[i].value = action.value
  230. }
  231. }
  232. }
  233. newState.labelListBlood = tmpArr
  234. }
  235. return newState;
  236. }
  237. if (action.type == SEARCH_TYPE_NEW) {
  238. const newState = Object.assign({}, state);
  239. newState.shType = action.value
  240. return newState;
  241. }
  242. if (action.type == RESET_LABEL_NEW) { //选中的结果重组
  243. const newState = Object.assign({}, state);
  244. const tempArr = newState.labelListBig;
  245. const tempArrs = newState.labelListSmall;
  246. const tmpArr = newState.labelListBlood;
  247. let tmpLis = action.list,num=0
  248. tmpLis['time'] = getCurrentDate(1)
  249. tmpLis['dateValue'] = getCurrentDate(1)
  250. if(tmpLis.flg == 5){
  251. tempArr.push(tmpLis)
  252. newState.labelListBig = [...tempArr]
  253. }else if(tmpLis.flg == 6){
  254. tempArrs.push(tmpLis)
  255. for(let i = 0;i < tempArrs.length;i++){
  256. if(!tempArrs[i].hasTreat){
  257. ++num
  258. }
  259. }
  260. if(num == tempArrs.length){
  261. tempArrs[0]['hasTreat'] = 1
  262. let obj = {
  263. "dateValue": tmpLis.dateValue,
  264. "name": tempArrs[0].name,
  265. "uniqueName": tempArrs[0].name
  266. }
  267. newState.operationName = obj
  268. }
  269. newState.labelListSmall = [...tempArrs]
  270. }else{
  271. tmpArr.push(tmpLis)
  272. newState.labelListBlood = [...tmpArr]
  273. }
  274. return newState;
  275. }
  276. if (action.type == SEARCH_LIST) {
  277. const newState = Object.assign({}, state);
  278. newState.list = action.list
  279. newState.inspectVal = action.val
  280. return newState;
  281. }
  282. if (action.type == SET_LABEL) { //选中的结果
  283. const newState = Object.assign({}, state);
  284. let tempArr = [];
  285. if(action.sign == 'common'){
  286. let tmpInspectList = store.getState().homePage.inspectList
  287. tempArr = tmpInspectList;
  288. }else{
  289. tempArr = newState.list
  290. }
  291. const tempArrs = newState.labelList;
  292. for (let i = 0; i < tempArr.length; i++) {
  293. if (i == action.idx) {
  294. tempArrs.push(tempArr[i])
  295. newState.labelList = [...tempArrs]
  296. }
  297. }
  298. let tmpArr = newState.getExcelDataList;
  299. let tmpArr2 = newState.labelList;
  300. newState.pushItems = getPushLists(tmpArr,tmpArr2);
  301. newState.inspectStrPlus = getStringPlus(newState.pushItems)
  302. return newState;
  303. }
  304. if (action.type == ADD_LABEL) { //右侧推送的检验检查项,点击开单放到左侧检验检查的位置上
  305. const newState = Object.assign({}, state);
  306. const tempArr = newState.labelList;
  307. for(let i = 0;i <action.lis.length;i++){
  308. tempArr.push(action.lis[i]);
  309. }
  310. newState.labelList = [...tempArr]
  311. let tmpArr = newState.getExcelDataList;
  312. let tmpArr2 = newState.labelList;
  313. newState.pushItems = getPushLists(tmpArr,tmpArr2);
  314. newState.inspectStrPlus = getStringPlus(newState.pushItems);
  315. return newState;
  316. }
  317. if (action.type == FILL_ACTIVE) { //点击标签放到暂存里
  318. const newState = Object.assign({}, state);
  319. const tempArr = newState.labelList;
  320. for (let i = 0; i < tempArr.length; i++) {
  321. if (i == action.idx) {
  322. newState.fillActive = tempArr[i]
  323. }
  324. }
  325. return newState;
  326. }
  327. if (action.type == CLEAR_LABEL) { //清空数据填写
  328. const newState = Object.assign({}, state);
  329. const tempArrs = newState.fillActive;
  330. const tempArr = newState.fillActive.details;
  331. let tmpArr = newState.getExcelDataList;
  332. let tmpArr2 = newState.labelList;
  333. for (let i = 0; i < tempArr.length; i++) {
  334. // tempArr[i].value = ''
  335. }
  336. tempArrs.show = false;
  337. newState.pushItem = getPushList(tmpArr,tmpArr2);
  338. newState.pushItems = getPushLists(tmpArr,tmpArr2);
  339. newState.inspectStrPlus = getStringPlus(newState.pushItems)
  340. return newState;
  341. }
  342. if (action.type == GET_EXCEL) { //导入数据
  343. const newState = Object.assign({}, state);
  344. let tmpArr = newState.getExcelDataList;
  345. let tmpArr2 = newState.labelList;
  346. newState.getExcelData = action.data
  347. tmpArr.push(action.data)
  348. newState.getExcelDataList = [...tmpArr]
  349. newState.pushItem = getPushList(tmpArr,tmpArr2);
  350. newState.pushItems = getPushLists(tmpArr,tmpArr2);
  351. newState.inspectStrPlus = getStringPlus(newState.pushItems)
  352. // getExcelString(action,newState,tmpArr,tmpArr2)
  353. return newState;
  354. }
  355. if(action.type == DEL_EXCEL_LIST){ //删除excel列表的某个数据
  356. const newState = Object.assign({}, state);
  357. const tempArr2 = newState.labelList;
  358. let tmpArr = newState.getExcelDataList;
  359. tmpArr.splice(action.idx,1);
  360. newState.getExcelDataList = [...tmpArr];
  361. let tempArr1 = newState.getExcelDataList;
  362. newState.pushItem = getPushList(tempArr1,tempArr2);
  363. newState.pushItems = getPushLists(tempArr1,tempArr2);
  364. newState.inspectStrPlus = getStringPlus(newState.pushItems)
  365. return newState;
  366. }
  367. if (action.type == CHECK_VALUE_IS_CHANGE) { //数据添加后显示与否
  368. const newState = Object.assign({}, state);
  369. // const tempArrAct = newState.fillActive;
  370. const tempArr = action.arr;
  371. tempArr.time = action.time;
  372. tempArr.dateValue = action.time;
  373. let tmpArr = newState.getExcelDataList;
  374. const tempArrs = newState.labelList;
  375. tempArrs[action.idx] = tempArr;
  376. newState.fillActive = tempArr;
  377. newState.labelList = tempArrs;
  378. // tempArrAct.show = true;
  379. newState.pushItem = getPushList(tmpArr,tempArrs);
  380. newState.pushItems = getPushLists(tmpArr,tempArrs);
  381. newState.inspectStrPlus = getStringPlus(newState.pushItems)
  382. return newState;
  383. }
  384. if (action.type == CLEAR_ALL_LABEL) { //清空所有数据
  385. const newState = Object.assign({}, state);
  386. newState.labelList =action.data;
  387. newState.getExcelDataList = action.dataExcel;
  388. let tmpArr = action.dataExcel;
  389. const tempArrs = action.data;
  390. newState.pushItem = getPushList(tmpArr,tempArrs);
  391. newState.inspectStrPlus = action.saveTextData;
  392. return newState;
  393. }
  394. if (action.type == DEL_PART_ITEM_NEW) { //清空填寫数据
  395. const newState = Object.assign({}, state);
  396. const tempArr = newState.labelList;
  397. tempArr.splice(action.idx,1);
  398. newState.labelList = [...tempArr];
  399. let tmpArr = newState.getExcelDataList;
  400. newState.pushItem = getPushList(tmpArr,tempArr);
  401. newState.pushItems = getPushLists(tmpArr,tempArr);
  402. newState.inspectStrPlus = getStringPlus(newState.pushItems)
  403. return newState;
  404. }
  405. if (action.type == SET_CONTEXT) {
  406. const newState = Object.assign({}, state);
  407. newState.context = action.obj
  408. return newState;
  409. }
  410. if (action.type == RENEWADVICEDATA) {
  411. const newState = Object.assign({}, state);
  412. newState.labelListBig = action.params[11].content.labelListBig;
  413. newState.labelListSmall = action.params[11].content.labelListSmall;
  414. newState.drugOrder = action.params[11].content.labelListBig;
  415. newState.operationOrder = action.params[11].content.labelListSmall;
  416. newState.labelListBlood = action.params[11].content.labelListBlood;
  417. newState.transfusionOrder = action.params[11].content.transfusionOrder;
  418. newState.operationName = action.params[11].content.operationName;
  419. return newState;
  420. }
  421. if (action.type == CLEARNEWADVICEDATA) {
  422. const newState = Object.assign({}, state);
  423. newState.labelListBig = [];
  424. newState.labelListSmall = [];
  425. newState.drugOrder = [];
  426. newState.operationOrder = [];
  427. newState.labelListBlood = [];
  428. newState.transfusionOrder = [];
  429. newState.operationName = {};
  430. return newState;
  431. }
  432. return state;
  433. }