tabTemplate.js 5.1 KB

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