tabTemplate.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import axios from '@utils/ajax'
  2. import {
  3. initItems,
  4. delItems,
  5. batchDelItems,
  6. changeTitle,
  7. keepPushData,
  8. changeVisible
  9. } from '@store/actions/tabTemplate';
  10. import {DIAG_SHOW} from "@store/types/print";
  11. import Notify from '@commonComp/Notify';
  12. import store from '@store';
  13. import {
  14. getAllDataList,
  15. getAllDataStringList,
  16. pushAllDataList
  17. } from '@utils/tools';
  18. export const initItemList = (type,current,flg) => { //初始化数据
  19. let baseList = store.getState();
  20. let whichSign = baseList.typeConfig.typeConfig;
  21. let state = baseList.patInfo.message;
  22. return (dispatch) => {
  23. axios.json('/templateInfo/getTemplatePageAlls', {
  24. "doctorId": state.doctorId,
  25. "hospitalDeptId": state.hospitalDeptId,
  26. "hospitalId": state.hospitalId,
  27. "type": type || whichSign,
  28. "current": current,
  29. "sex":[1,2,3],
  30. "size": 9999
  31. }).then((res) => {
  32. const data = res.data;
  33. if (data.code == 0) {
  34. // data.data.flg = flg||false //获取下一页,暂时不用
  35. dispatch(initItems(data.data));
  36. } else {
  37. Notify.error(data.msg)
  38. }
  39. })
  40. }
  41. };
  42. export const saveTemplateDetail = (val,sex) => { //保存为模板
  43. let baseList = store.getState();
  44. let jsonData = getAllDataList(baseList);
  45. let jsonStr = getAllDataStringList(baseList);
  46. let whichSign = baseList.typeConfig.typeConfig;
  47. let state = baseList.patInfo.message;
  48. let preview = {
  49. "chief": jsonStr.chief,
  50. "present": jsonStr.present,
  51. "other": jsonStr.other,
  52. "vital": jsonStr.vital,
  53. "lis": jsonStr.lis,
  54. "pacs": jsonStr.pacs,
  55. "diag": jsonStr.diag,
  56. "advice": jsonStr.advice,
  57. }
  58. function getdata(idx){
  59. let tmpObj = {
  60. "doctorId": state.doctorId,
  61. "hospitalDeptId": state.hospitalDeptId,
  62. "hospitalId": state.hospitalId,
  63. "dataJson": JSON.stringify(jsonData),
  64. "modeName": val,
  65. "modeType": whichSign,
  66. "preview": idx ? JSON.stringify(preview):preview,
  67. "sex":sex
  68. }
  69. return tmpObj;
  70. }
  71. return (dispatch) => {
  72. axios.json('/templateInfo/saveTemplateInfo', getdata()).then((res) => {
  73. const data = res.data;
  74. if (data.code == 0) {
  75. Notify.success('模板保存成功');
  76. dispatch(initItemList("",1));
  77. dispatch(keepPushData(getdata(1),'part'));
  78. dispatch({
  79. type: DIAG_SHOW,
  80. data:false
  81. });
  82. } else {
  83. if(data.msg == '该模板名存在'){ //存在不关闭弹窗
  84. dispatch({
  85. type: DIAG_SHOW,
  86. data:true
  87. });
  88. }else{
  89. dispatch({
  90. type: DIAG_SHOW,
  91. data:false
  92. });
  93. }
  94. Notify.error(data.msg);
  95. }
  96. })
  97. }
  98. };
  99. export const delItem = (id) => { //删除
  100. return (dispatch) => {
  101. axios.json('/templateInfo/cancelTemplateInfos', {
  102. ids: id
  103. }).then((res) => {
  104. let data = res.data;
  105. if (data.code == 0) {
  106. dispatch(delItems(id));
  107. Notify.success('模板删除成功');
  108. } else {
  109. Notify.error(data.msg);
  110. }
  111. })
  112. }
  113. };
  114. export const delBatchItem = (ids) => { //批量删除
  115. return (dispatch) => {
  116. axios.json('/templateInfo/cancelTemplateInfos', {
  117. ids: ids.join(",")
  118. }).then((res) => {
  119. let data = res.data;
  120. if (data.code == 0) {
  121. dispatch(batchDelItems(ids));
  122. } else {
  123. Notify.error(data.msg);
  124. }
  125. })
  126. }
  127. };
  128. export const changeTitleAsync = (obj) => { //改标题
  129. let baseList = store.getState();
  130. let whichSign = baseList.typeConfig.typeConfig;
  131. let state = baseList.patInfo.message;
  132. if (obj.title == '') {
  133. Notify.success('请输入模板名称');
  134. return;
  135. }
  136. return (dispatch) => {
  137. axios.json('/templateInfo/updateByIdUsNames', {
  138. "doctorId": state.doctorId,
  139. "hospitalDeptId": state.hospitalDeptId,
  140. "hospitalId": state.hospitalId,
  141. "id": obj.id,
  142. "modeName": obj.title,
  143. "type": whichSign
  144. }).then((res) => {
  145. let data = res.data;
  146. if (data.code == 0) {
  147. dispatch(changeTitle(obj));
  148. Notify.success('标题修改成功');
  149. store.dispatch(changeVisible(false))
  150. } else {
  151. // console.log(data)
  152. Notify.error(data.msg)
  153. }
  154. })
  155. }
  156. };
  157. export const setPageView = (id,typeConfig) => { //批量删除
  158. return (dispatch) => {
  159. axios.json('/templateInfo/getTemplateIdAlls', {
  160. id: id
  161. }).then((res) => {
  162. let data = res.data;
  163. if (data.code == 0) {
  164. pushAllDataList(typeConfig, 'push', data.data, 'template')//引用
  165. } else {
  166. Notify.error(data.msg);
  167. }
  168. })
  169. }
  170. };