tabTemplate.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. floderListAdmin,
  15. folderModal,
  16. setSearchTemplateNorms,
  17. } from '@store/actions/tabTemplate';
  18. import {DIAG_SHOW} from "@store/types/print";
  19. import Notify from '@commonComp/Notify';
  20. import store from '@store';
  21. import {
  22. getAllDataList,
  23. getAllDataStringList,
  24. pushAllDataList,
  25. getUrlArgObject,
  26. didPushParamChange
  27. } from '@utils/tools';
  28. import { billing, getMRAnalyse } from '@store/async-actions/pushMessage';
  29. export const initItemList = (current,name,selectTemp) => {
  30. let admin = store.getState().homePage.admin;
  31. if(admin || selectTemp==2){
  32. return initAdminItemList(current,name,selectTemp)
  33. }else{
  34. return initCommonItemList(current,name,selectTemp)
  35. }
  36. }
  37. export const initCommonItemList = (current,name) => { //初始化数据
  38. let baseList = store.getState();
  39. let state = baseList.patInfo.message;
  40. // let searchVal = document.getElementById("searchTmp").value
  41. return (dispatch) => {
  42. axios.json('/templateInfo/getTemplateAlls', {
  43. "doctorId": state.doctorId,
  44. "hospitalDeptId": (name == '')?state.hospitalDeptId:null,
  45. "hospitalId": state.hospitalId,
  46. "hospitalCode": state.hospitalCode,
  47. "current": current,
  48. "sex":[1,2,3],
  49. "size": 9999,
  50. "name":name||''
  51. }).then((res) => {
  52. const data = res.data;
  53. if (data.code == 0) {
  54. // data.data.flg = flg||false //获取下一页,暂时不用
  55. dispatch(initItems(data.data));
  56. } else {
  57. Notify.error(data.msg)
  58. }
  59. })
  60. }
  61. };
  62. export const initAdminItemList = (current,name,selectTemp) => { //初始化数据
  63. let baseList = store.getState();
  64. // let searchVal = document.getElementById("searchTmp").value
  65. let state = baseList.patInfo.message;
  66. return (dispatch) => {
  67. if(selectTemp == 2) {
  68. dispatch(findTemplateNorms(name))
  69. }else {
  70. dispatch(getFloderListAll())
  71. }
  72. }
  73. };
  74. export const saveTemplateDetail = (val,sex,spell) => { //保存为模板
  75. let baseList = store.getState();
  76. let jsonData = getAllDataList(baseList);
  77. let jsonStr = getAllDataStringList(baseList);
  78. const dConfig = baseList.typeConfig;
  79. const readMode = dConfig.readMode; //回读模式
  80. let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
  81. const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
  82. jsonData.docConfigs=docConfigs; //保存当时的设置引用
  83. let state = baseList.patInfo.message;
  84. let preview = {
  85. "chief": jsonStr.chief,
  86. "present": jsonStr.present,
  87. "other": jsonStr.other,
  88. "vital": jsonStr.vital,
  89. "lis": jsonStr.lis,
  90. "pacs": jsonStr.pacs,
  91. "diag": jsonStr.diag,
  92. "advice": jsonStr.advice
  93. }
  94. function getdata(idx){
  95. let tmpObj = {
  96. "doctorId": state.doctorId,
  97. "hospitalDeptId": state.hospitalDeptId,
  98. "hospitalId": state.hospitalId,
  99. "dataJson": JSON.stringify(jsonData),
  100. "modeName": val,
  101. "modeType": whichSign,
  102. "preview": idx ? JSON.stringify(preview):preview,
  103. "sex":sex,
  104. "spell":spell
  105. }
  106. return tmpObj;
  107. }
  108. return (dispatch) => {
  109. axios.json('/templateInfo/saveTemplateInfo', getdata()).then((res) => {
  110. const data = res.data;
  111. if (data.code == 0) {
  112. Notify.success('模板保存成功');
  113. dispatch(initItemList(1,""));
  114. dispatch(keepPushData(getdata(1),'part'));
  115. dispatch({
  116. type: DIAG_SHOW,
  117. data:false
  118. });
  119. } else {
  120. if(data.msg == '该模板名存在'){ //存在不关闭弹窗
  121. dispatch({
  122. type: DIAG_SHOW,
  123. data:true
  124. });
  125. }else{
  126. dispatch({
  127. type: DIAG_SHOW,
  128. data:false
  129. });
  130. }
  131. Notify.error(data.msg);
  132. }
  133. })
  134. }
  135. };
  136. export const saveAdminTemplateDetail = (val,sex,id,fstName,folderId,folderName) => { //保存为模板
  137. let baseList = store.getState();
  138. let jsonData = getAllDataList(baseList);
  139. let jsonStr = getAllDataStringList(baseList);
  140. const dConfig = baseList.typeConfig;
  141. const readMode = dConfig.readMode; //回读模式
  142. let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
  143. const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
  144. jsonData.docConfigs=docConfigs; //保存当时的设置引用
  145. let state = baseList.patInfo.message;
  146. let preview = {
  147. "chief": jsonStr.chief,
  148. "present": jsonStr.present,
  149. "other": jsonStr.other,
  150. "vital": jsonStr.vital,
  151. "lis": jsonStr.lis,
  152. "pacs": jsonStr.pacs,
  153. "diag": jsonStr.diag,
  154. "advice": jsonStr.advice,
  155. }
  156. function getdata(idx){
  157. let tmpObj = {
  158. "doctorId": state.doctorId,
  159. "hospitalDeptId": id,
  160. "hospitalId": state.hospitalId,
  161. "dataJson": JSON.stringify(jsonData),
  162. "modeName": val,
  163. "modeType": whichSign,
  164. "preview": idx ? JSON.stringify(preview):preview,
  165. "sex":sex,
  166. "modeSpell":fstName,
  167. "folderId": folderId,
  168. }
  169. return tmpObj;
  170. }
  171. return (dispatch) => {
  172. axios.json('/templateAdmin/saveTemplateNorms', getdata()).then((res) => {
  173. const data = res.data;
  174. if (data.code == 0) {
  175. Notify.success('模板保存成功');
  176. dispatch(initItemList(1,""));
  177. dispatch(keepPushData(getdata(1),'part'));
  178. dispatch({
  179. type: DIAG_SHOW,
  180. data:false
  181. });
  182. } else {
  183. if(data.msg == '该模板名存在'){ //存在不关闭弹窗
  184. dispatch({
  185. type: DIAG_SHOW,
  186. data:true
  187. });
  188. }else{
  189. dispatch({
  190. type: DIAG_SHOW,
  191. data:false
  192. });
  193. }
  194. Notify.error(data.msg);
  195. }
  196. })
  197. }
  198. };
  199. export const getFloderList = () => { //管理员文件夹列表获取
  200. let baseList = store.getState().patInfo.message;
  201. return (dispatch) => {
  202. axios.json('/templateFolderAdmin/list', {
  203. "doctorId": baseList.doctorId,
  204. "hospitalId": baseList.hospitalId,
  205. }).then((res) => {
  206. let data = res.data;
  207. if (data.code == 0) {
  208. dispatch(floderListAdmin(data.data))
  209. } else {
  210. Notify.error(data.msg);
  211. }
  212. })
  213. }
  214. };
  215. function getFloderLis(dispatch){
  216. let baseList = store.getState().patInfo.message;
  217. return (dispatch) => {
  218. axios.json('/templateFolderAdmin/list', {
  219. "doctorId": baseList.doctorId,
  220. "hospitalId": baseList.hospitalId,
  221. }).then((res) => {
  222. let data = res.data;
  223. if (data.code == 0) {
  224. dispatch(floderListAdmin(data.data))
  225. } else {
  226. Notify.error(data.msg);
  227. }
  228. })
  229. }
  230. }
  231. export const newFloder = (name,id,type) => { //新建管理员文件夹
  232. let baseList = store.getState().patInfo.message;
  233. return (dispatch) => {
  234. axios.json('/templateFolderAdmin/saveOrUpdate', {
  235. "doctorId": baseList.doctorId,
  236. "hospitalId": baseList.hospitalId,
  237. "id": id||'',
  238. "name": name,
  239. "templateType": 2 //模板类型(个人1,管理员2)
  240. }).then((res) => {
  241. let data = res.data;
  242. if (data.code == 0) {
  243. if(type=='modify') {
  244. Notify.success('修改成功');
  245. } else {
  246. Notify.success('新建成功');
  247. }
  248. dispatch(folderModal(false))
  249. dispatch(getFloderList())
  250. dispatch(getFloderListAll())
  251. dispatch(changeVisible(false))
  252. } else {
  253. Notify.error(data.msg);
  254. }
  255. })
  256. }
  257. };
  258. export const delFloder = (id) => { //文件夹删除
  259. let baseList = store.getState().patInfo.message;
  260. return (dispatch) => {
  261. axios.json('/templateFolderAdmin/delete', {
  262. "doctorId": baseList.doctorId,
  263. "hospitalId": baseList.hospitalId,
  264. "folderId": id,
  265. }).then((res) => {
  266. let data = res.data;
  267. if (data.code == 0) {
  268. Notify.success('文件夹删除成功');
  269. dispatch(getFloderListAll())
  270. // axios.json('/templateAdmin/getTemplateNorms').then((res) => {
  271. // const data = res.data;
  272. // if (data.code == 0) {
  273. // // data.data.flg = flg||false //获取下一页,暂时不用
  274. // dispatch(initAdminItems(data.data));
  275. // } else {
  276. // Notify.error(data.msg)
  277. // }
  278. // })
  279. } else {
  280. Notify.error(data.msg);
  281. }
  282. })
  283. }
  284. };
  285. export const orderFloder = (folderList) => { //文件夹排序
  286. let baseList = store.getState().patInfo.message;
  287. return (dispatch) => {
  288. axios.json('/templateFolderAdmin/sort', {templateFolderSortVOList:folderList}).then((res) => {
  289. let data = res.data;
  290. if (data.code == 0) {
  291. Notify.success('保存成功');
  292. dispatch(getFloderListAll())
  293. } else {
  294. Notify.error(data.msg);
  295. }
  296. })
  297. }
  298. };
  299. export const delItem = (id) => { //删除
  300. return (dispatch) => {
  301. axios.json('/templateInfo/cancelTemplateInfos', {
  302. ids: id
  303. }).then((res) => {
  304. let data = res.data;
  305. if (data.code == 0) {
  306. dispatch(delItems(id));
  307. Notify.success('模板删除成功');
  308. } else {
  309. Notify.error(data.msg);
  310. }
  311. })
  312. }
  313. };
  314. export const delItemAdmin = (id,folderId) => { //删除
  315. let baseList = store.getState().patInfo.message;
  316. return (dispatch) => {
  317. axios.json('/templateAdmin/cancelTemplateNorms', {
  318. "ids": id,
  319. "doctorId": baseList.doctorId,
  320. "hospitalId": baseList.hospitalId,
  321. }).then((res) => {
  322. let data = res.data;
  323. if (data.code == 0) {
  324. // dispatch(delItemsAdmin(id,folderId));
  325. dispatch(initAdminItemList())
  326. Notify.success('模板删除成功');
  327. } else {
  328. Notify.error(data.msg);
  329. }
  330. })
  331. }
  332. };
  333. export const delBatchItem = (ids) => { //批量删除
  334. return (dispatch) => {
  335. axios.json('/templateInfo/cancelTemplateInfos', {
  336. ids: ids.join(",")
  337. }).then((res) => {
  338. let data = res.data;
  339. if (data.code == 0) {
  340. dispatch(batchDelItems(ids));
  341. } else {
  342. Notify.error(data.msg);
  343. }
  344. })
  345. }
  346. };
  347. export const delBatchItemAdmin = (ids) => { //批量删除
  348. let baseList = store.getState().patInfo.message;
  349. return (dispatch) => {
  350. axios.json('/templateAdmin/cancelTemplateNorms', {
  351. "ids": ids.join(","),
  352. "doctorId": baseList.doctorId,
  353. "hospitalId": baseList.hospitalId,
  354. }).then((res) => {
  355. let data = res.data;
  356. if (data.code == 0) {
  357. // dispatch(batchDelItemsAdmin(ids));
  358. dispatch(initAdminItemList())
  359. } else {
  360. Notify.error(data.msg);
  361. }
  362. })
  363. }
  364. };
  365. export const changeTitleAsyncAdmin = (obj) => { //改标题
  366. let baseList = store.getState();
  367. let whichSign = baseList.typeConfig.mode;
  368. let state = baseList.patInfo.message;
  369. return (dispatch) => {
  370. axios.json('/templateAdmin/updateTemplateNorms', {
  371. "doctorId": state.doctorId,
  372. "hospitalDeptId": obj.deptId,
  373. "hospitalId": state.hospitalId,
  374. "id": obj.id,
  375. "sex": obj.sex,
  376. "modeName": obj.title,
  377. "type": whichSign,
  378. "folderId": obj.folderId,
  379. "spell": obj.spell
  380. }).then((res) => {
  381. let data = res.data;
  382. if (data.code == 0) {
  383. dispatch(changeTitleAdmin(obj));
  384. Notify.success('标题修改成功');
  385. store.dispatch(changeVisible(false))
  386. dispatch(getFloderListAll())
  387. } else {
  388. // console.log(data)
  389. Notify.error(data.msg)
  390. }
  391. })
  392. }
  393. };
  394. export const changeTitleAsync = (obj) => { //改标题
  395. let baseList = store.getState();
  396. let whichSign = baseList.typeConfig.mode;
  397. let state = baseList.patInfo.message;
  398. return (dispatch) => {
  399. axios.json('/templateInfo/updateByIdUsNames', {
  400. "doctorId": state.doctorId,
  401. "hospitalDeptId": obj.deptId,
  402. "hospitalId": state.hospitalId,
  403. "id": obj.id,
  404. "modeName": obj.title,
  405. "type": whichSign,
  406. "spell": obj.spell
  407. }).then((res) => {
  408. let data = res.data;
  409. if (data.code == 0) {
  410. dispatch(changeTitle(obj));
  411. Notify.success('标题修改成功');
  412. store.dispatch(changeVisible(false))
  413. store.dispatch(initCommonItemList(1,""))
  414. } else {
  415. // console.log(data)
  416. Notify.error(data.msg)
  417. }
  418. })
  419. }
  420. };
  421. export const setPageView = (id) => { //获取模板结构化数据
  422. return (dispatch) => {
  423. axios.json('/templateInfo/getTemplateIdAlls', {
  424. id: id
  425. }).then((res) => {
  426. let data = res.data;
  427. if (data.code == 0) {
  428. //模板列表不筛选模式后,单个模式引用时看本身的模式
  429. pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
  430. if(didPushParamChange()){ //诊断变化时会调推送,避免重复调
  431. dispatch(billing())
  432. }
  433. dispatch(getMRAnalyse())
  434. } else {
  435. Notify.error(data.msg);
  436. }
  437. })
  438. }
  439. };
  440. export const setPageViewAdmin = (id) => { //获取模板结构化数据
  441. return (dispatch) => {
  442. axios.json('/templateAdmin/getTemplateIdAlls', {
  443. id: id
  444. }).then((res) => {
  445. let data = res.data;
  446. if (data.code == 0) {
  447. //模板列表不筛选模式后,单个模式引用时看本身的模式
  448. pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
  449. if(didPushParamChange()){ //诊断变化时会调推送,避免重复调
  450. dispatch(billing())
  451. }
  452. } else {
  453. Notify.error(data.msg);
  454. }
  455. })
  456. }
  457. };
  458. export const getDepartments = (value) => { //获取模板结构化数据
  459. return (dispatch) => {
  460. axios.json('/doctorInfo/getHospitalDeptInfoAll', {
  461. "deptInfoName": value,
  462. "hospitalCode": getUrlArgObject('hospitalId'),
  463. "thirdpartyName": ""
  464. }).then((res) => {
  465. let data = res.data;
  466. if (data.code == 0) {
  467. dispatch(getDptLis(data.data))
  468. } else {
  469. Notify.error(data.msg);
  470. }
  471. })
  472. }
  473. };
  474. export const findTemplateNorms = (name) => {//标准模板搜索
  475. return (dispatch) => {
  476. if(!name) {
  477. dispatch(setSearchTemplateNorms([]));
  478. } else {
  479. axios.json('/templateInfo/findTemplateNorms',{
  480. name,
  481. templateType: 2
  482. }).then((res) => {
  483. const data = res.data;
  484. if (data.code == 0) {
  485. dispatch(setSearchTemplateNorms(data.data));
  486. } else {
  487. Notify.error(data.msg)
  488. }
  489. })
  490. }
  491. }
  492. }
  493. export const getFloderListAll = () => {
  494. return (dispatch) => {
  495. axios.json('/templateAdmin/getTemplateNorms').then((res) => {
  496. const data = res.data;
  497. if (data.code == 0) {
  498. // data.data.flg = flg||false //获取下一页,暂时不用
  499. dispatch(initAdminItems(data.data));
  500. } else {
  501. Notify.error(data.msg)
  502. }
  503. })
  504. }
  505. }
  506. export const addTemplateQuote = (templateId) => {
  507. let baseList = store.getState();
  508. let state = baseList.patInfo.message;
  509. return (dispatch) => {
  510. axios.json('/templateQuote/addTemplateQuote',{
  511. "doctorId": state.doctorId,
  512. "remark": "",
  513. "templateId": templateId
  514. }).then((res) => {
  515. const data = res.data;
  516. if (data.code == 0) {
  517. // data.data.flg = flg||false //获取下一页,暂时不用
  518. } else {
  519. // Notify.error(data.msg)
  520. }
  521. })
  522. }
  523. }