tabTemplate.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. import axios from '@utils/ajax'
  2. import {
  3. initItems,
  4. delItems,
  5. batchDelItems,
  6. changeTitle,
  7. keepPushData,
  8. changeVisible,
  9. getDptLis,
  10. initAdminItems,
  11. delItemsAdmin,
  12. batchDelItemsAdmin,
  13. changeTitleAdmin,
  14. } from '@store/actions/tabTemplate';
  15. import {DIAG_SHOW} from "@store/types/print";
  16. import Notify from '@commonComp/Notify';
  17. import store from '@store';
  18. import {
  19. getAllDataList,
  20. getAllDataStringList,
  21. pushAllDataList,
  22. getUrlArgObject,
  23. didPushParamChange
  24. } from '@utils/tools';
  25. import { billing, getMRAnalyse } from '@store/async-actions/pushMessage';
  26. export const initItemList = (current,name) => {
  27. let admin = store.getState().homePage.admin;
  28. if(admin){
  29. return initAdminItemList(current,name)
  30. }else{
  31. return initCommonItemList(current,name)
  32. }
  33. }
  34. export const initCommonItemList = (current,name) => { //初始化数据
  35. let baseList = store.getState();
  36. let state = baseList.patInfo.message;
  37. // let searchVal = document.getElementById("searchTmp").value
  38. return (dispatch) => {
  39. axios.json('/templateInfo/getTemplatePageAlls', {
  40. "doctorId": state.doctorId,
  41. "hospitalDeptId": (name == '')?state.hospitalDeptId:null,
  42. "hospitalId": state.hospitalId,
  43. "hospitalCode": state.hospitalCode,
  44. "current": current,
  45. "sex":[1,2,3],
  46. "size": 9999,
  47. "name":name||''
  48. }).then((res) => {
  49. const data = res.data;
  50. if (data.code == 0) {
  51. // data.data.flg = flg||false //获取下一页,暂时不用
  52. dispatch(initItems(data.data));
  53. } else {
  54. Notify.error(data.msg)
  55. }
  56. })
  57. }
  58. };
  59. export const initAdminItemList = (current,name) => { //初始化数据
  60. let baseList = store.getState();
  61. // let searchVal = document.getElementById("searchTmp").value
  62. let state = baseList.patInfo.message;
  63. return (dispatch) => {
  64. axios.json('/templateAdmin/getTemplatePageAlls', {
  65. "doctorId": state.doctorId,
  66. "hospitalDeptId": '',
  67. "hospitalId": state.hospitalId,
  68. "hospitalCode": state.hospitalCode,
  69. "current": current,
  70. "sex":[1,2,3],
  71. "size": 9999,
  72. "name":name||''
  73. }).then((res) => {
  74. const data = res.data;
  75. if (data.code == 0) {
  76. // data.data.flg = flg||false //获取下一页,暂时不用
  77. dispatch(initAdminItems(data.data));
  78. } else {
  79. Notify.error(data.msg)
  80. }
  81. })
  82. }
  83. };
  84. export const saveTemplateDetail = (val,sex) => { //保存为模板
  85. let baseList = store.getState();
  86. let jsonData = getAllDataList(baseList);
  87. let jsonStr = getAllDataStringList(baseList);
  88. const dConfig = baseList.typeConfig;
  89. const readMode = dConfig.readMode; //回读模式
  90. let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
  91. const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
  92. jsonData.docConfigs=docConfigs; //保存当时的设置引用
  93. let state = baseList.patInfo.message;
  94. let preview = {
  95. "chief": jsonStr.chief,
  96. "present": jsonStr.present,
  97. "other": jsonStr.other,
  98. "vital": jsonStr.vital,
  99. "lis": jsonStr.lis,
  100. "pacs": jsonStr.pacs,
  101. "diag": jsonStr.diag,
  102. "advice": jsonStr.advice,
  103. }
  104. function getdata(idx){
  105. let tmpObj = {
  106. "doctorId": state.doctorId,
  107. "hospitalDeptId": state.hospitalDeptId,
  108. "hospitalId": state.hospitalId,
  109. "dataJson": JSON.stringify(jsonData),
  110. "modeName": val,
  111. "modeType": whichSign,
  112. "preview": idx ? JSON.stringify(preview):preview,
  113. "sex":sex
  114. }
  115. return tmpObj;
  116. }
  117. return (dispatch) => {
  118. axios.json('/templateInfo/saveTemplateInfo', getdata()).then((res) => {
  119. const data = res.data;
  120. if (data.code == 0) {
  121. Notify.success('模板保存成功');
  122. dispatch(initItemList(1,""));
  123. dispatch(keepPushData(getdata(1),'part'));
  124. dispatch({
  125. type: DIAG_SHOW,
  126. data:false
  127. });
  128. } else {
  129. if(data.msg == '该模板名存在'){ //存在不关闭弹窗
  130. dispatch({
  131. type: DIAG_SHOW,
  132. data:true
  133. });
  134. }else{
  135. dispatch({
  136. type: DIAG_SHOW,
  137. data:false
  138. });
  139. }
  140. Notify.error(data.msg);
  141. }
  142. })
  143. }
  144. };
  145. export const saveAdminTemplateDetail = (val,sex,id) => { //保存为模板
  146. let baseList = store.getState();
  147. let jsonData = getAllDataList(baseList);
  148. let jsonStr = getAllDataStringList(baseList);
  149. const dConfig = baseList.typeConfig;
  150. const readMode = dConfig.readMode; //回读模式
  151. let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
  152. const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
  153. jsonData.docConfigs=docConfigs; //保存当时的设置引用
  154. let state = baseList.patInfo.message;
  155. let preview = {
  156. "chief": jsonStr.chief,
  157. "present": jsonStr.present,
  158. "other": jsonStr.other,
  159. "vital": jsonStr.vital,
  160. "lis": jsonStr.lis,
  161. "pacs": jsonStr.pacs,
  162. "diag": jsonStr.diag,
  163. "advice": jsonStr.advice,
  164. }
  165. function getdata(idx){
  166. let tmpObj = {
  167. "doctorId": state.doctorId,
  168. "hospitalDeptId": id,
  169. "hospitalId": state.hospitalId,
  170. "dataJson": JSON.stringify(jsonData),
  171. "modeName": val,
  172. "modeType": whichSign,
  173. "preview": idx ? JSON.stringify(preview):preview,
  174. "sex":sex
  175. }
  176. return tmpObj;
  177. }
  178. return (dispatch) => {
  179. axios.json('/templateAdmin/saveTemplateAdmin', getdata()).then((res) => {
  180. const data = res.data;
  181. if (data.code == 0) {
  182. Notify.success('模板保存成功');
  183. dispatch(initItemList(1,""));
  184. dispatch(keepPushData(getdata(1),'part'));
  185. dispatch({
  186. type: DIAG_SHOW,
  187. data:false
  188. });
  189. } else {
  190. if(data.msg == '该模板名存在'){ //存在不关闭弹窗
  191. dispatch({
  192. type: DIAG_SHOW,
  193. data:true
  194. });
  195. }else{
  196. dispatch({
  197. type: DIAG_SHOW,
  198. data:false
  199. });
  200. }
  201. Notify.error(data.msg);
  202. }
  203. })
  204. }
  205. };
  206. export const delItem = (id) => { //删除
  207. return (dispatch) => {
  208. axios.json('/templateInfo/cancelTemplateInfos', {
  209. ids: id
  210. }).then((res) => {
  211. let data = res.data;
  212. if (data.code == 0) {
  213. dispatch(delItems(id));
  214. Notify.success('模板删除成功');
  215. } else {
  216. Notify.error(data.msg);
  217. }
  218. })
  219. }
  220. };
  221. export const delItemAdmin = (id) => { //删除
  222. let baseList = store.getState().patInfo.message;
  223. return (dispatch) => {
  224. axios.json('/templateAdmin/cancelTemplateAdminb', {
  225. "ids": id,
  226. "doctorId": baseList.doctorId,
  227. "hospitalId": baseList.hospitalId,
  228. }).then((res) => {
  229. let data = res.data;
  230. if (data.code == 0) {
  231. dispatch(delItemsAdmin(id));
  232. Notify.success('模板删除成功');
  233. } else {
  234. Notify.error(data.msg);
  235. }
  236. })
  237. }
  238. };
  239. export const delBatchItem = (ids) => { //批量删除
  240. return (dispatch) => {
  241. axios.json('/templateInfo/cancelTemplateInfos', {
  242. ids: ids.join(",")
  243. }).then((res) => {
  244. let data = res.data;
  245. if (data.code == 0) {
  246. dispatch(batchDelItems(ids));
  247. } else {
  248. Notify.error(data.msg);
  249. }
  250. })
  251. }
  252. };
  253. export const delBatchItemAdmin = (ids) => { //批量删除
  254. let baseList = store.getState().patInfo.message;
  255. return (dispatch) => {
  256. axios.json('/templateAdmin/cancelTemplateAdminb', {
  257. "ids": ids.join(","),
  258. "doctorId": baseList.doctorId,
  259. "hospitalId": baseList.hospitalId,
  260. }).then((res) => {
  261. let data = res.data;
  262. if (data.code == 0) {
  263. dispatch(batchDelItemsAdmin(ids));
  264. } else {
  265. Notify.error(data.msg);
  266. }
  267. })
  268. }
  269. };
  270. export const changeTitleAsyncAdmin = (obj) => { //改标题
  271. let baseList = store.getState();
  272. let whichSign = baseList.typeConfig.mode;
  273. let state = baseList.patInfo.message;
  274. return (dispatch) => {
  275. axios.json('/templateAdmin/updateByAdminNames', {
  276. "doctorId": state.doctorId,
  277. "hospitalDeptId": obj.deptId,
  278. "hospitalId": state.hospitalId,
  279. "id": obj.id,
  280. "modeName": obj.title,
  281. "type": whichSign
  282. }).then((res) => {
  283. let data = res.data;
  284. if (data.code == 0) {
  285. dispatch(changeTitleAdmin(obj));
  286. Notify.success('标题修改成功');
  287. store.dispatch(changeVisible(false))
  288. } else {
  289. // console.log(data)
  290. Notify.error(data.msg)
  291. }
  292. })
  293. }
  294. };
  295. export const changeTitleAsync = (obj) => { //改标题
  296. let baseList = store.getState();
  297. let whichSign = baseList.typeConfig.mode;
  298. let state = baseList.patInfo.message;
  299. return (dispatch) => {
  300. axios.json('/templateInfo/updateByIdUsNames', {
  301. "doctorId": state.doctorId,
  302. "hospitalDeptId": obj.deptId,
  303. "hospitalId": state.hospitalId,
  304. "id": obj.id,
  305. "modeName": obj.title,
  306. "type": whichSign
  307. }).then((res) => {
  308. let data = res.data;
  309. if (data.code == 0) {
  310. dispatch(changeTitle(obj));
  311. Notify.success('标题修改成功');
  312. store.dispatch(changeVisible(false))
  313. } else {
  314. // console.log(data)
  315. Notify.error(data.msg)
  316. }
  317. })
  318. }
  319. };
  320. export const setPageView = (id) => { //获取模板结构化数据
  321. return (dispatch) => {
  322. axios.json('/templateInfo/getTemplateIdAlls', {
  323. id: id
  324. }).then((res) => {
  325. let data = res.data;
  326. if (data.code == 0) {
  327. //模板列表不筛选模式后,单个模式引用时看本身的模式
  328. pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
  329. if(didPushParamChange()){ //诊断变化时会调推送,避免重复调
  330. dispatch(billing())
  331. }
  332. dispatch(getMRAnalyse())
  333. } else {
  334. Notify.error(data.msg);
  335. }
  336. })
  337. }
  338. };
  339. export const setPageViewAdmin = (id) => { //获取模板结构化数据
  340. return (dispatch) => {
  341. axios.json('/templateAdmin/getTemplateIdAlls', {
  342. id: id
  343. }).then((res) => {
  344. let data = res.data;
  345. if (data.code == 0) {
  346. //模板列表不筛选模式后,单个模式引用时看本身的模式
  347. pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
  348. if(didPushParamChange()){ //诊断变化时会调推送,避免重复调
  349. dispatch(billing())
  350. }
  351. } else {
  352. Notify.error(data.msg);
  353. }
  354. })
  355. }
  356. };
  357. export const getDepartments = (value) => { //获取模板结构化数据
  358. return (dispatch) => {
  359. axios.json('/doctorInfo/getHospitalDeptInfoAll', {
  360. "deptInfoName": value,
  361. "hospitalCode": getUrlArgObject('hospitalId'),
  362. "thirdpartyName": ""
  363. }).then((res) => {
  364. let data = res.data;
  365. if (data.code == 0) {
  366. dispatch(getDptLis(data.data))
  367. } else {
  368. Notify.error(data.msg);
  369. }
  370. })
  371. }
  372. };