tabTemplate.js 4.5 KB

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