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