123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import axios from '@utils/ajax'
- import {
- initItems,
- delItems,
- batchDelItems,
- changeTitle,
- keepPushData,
- changeVisible
- } from '@store/actions/tabTemplate';
- import {DIAG_SHOW} from "@store/types/print";
- import Notify from '@commonComp/Notify';
- import store from '@store';
- import {
- getAllDataList,
- getAllDataStringList
- } from '@utils/tools';
- export const initItemList = (type) => { //初始化数据
- let baseList = store.getState();
- let whichSign = baseList.typeConfig.typeConfig;
- let state = baseList.patInfo.message;
- return (dispatch) => {
- axios.json('/templateInfo/getByDoctorIdTemplates', {
- "doctorId": state.doctorId,
- "hospitalDeptId": state.hospitalDeptId,
- "hospitalId": state.hospitalId,
- "type": type || whichSign,
- }).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- dispatch(initItems(data));
- } else {
- Notify.error(data.msg)
- }
- })
- }
- };
- export const saveTemplateDetail = (val,sex) => { //保存为模板
- let baseList = store.getState();
- let jsonData = getAllDataList(baseList);
- let jsonStr = getAllDataStringList(baseList);
- let whichSign = baseList.typeConfig.typeConfig;
- let state = baseList.patInfo.message;
- let preview = {
- "chief": jsonStr.chief,
- "present": jsonStr.present,
- "other": jsonStr.other,
- "vital": jsonStr.vital,
- "lis": jsonStr.lis,
- "pacs": jsonStr.pacs,
- "diag": jsonStr.diag,
- "advice": jsonStr.advice,
- }
- function getdata(idx){
- let tmpObj = {
- "doctorId": state.doctorId,
- "hospitalDeptId": state.hospitalDeptId,
- "hospitalId": state.hospitalId,
- "dataJson": JSON.stringify(jsonData),
- "modeName": val,
- "modeType": whichSign,
- "preview": idx ? JSON.stringify(preview):preview,
- "sex":sex
- }
- return tmpObj;
- }
- return (dispatch) => {
- axios.json('/templateInfo/saveTemplateInfo', getdata()).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- Notify.success('模板保存成功');
- dispatch(initItemList());
- dispatch(keepPushData(getdata(1),'part'));
- dispatch({
- type: DIAG_SHOW,
- data:false
- });
- } else {
- if(data.msg == '该模板名存在'){ //存在不关闭弹窗
- dispatch({
- type: DIAG_SHOW,
- data:true
- });
- }else{
- dispatch({
- type: DIAG_SHOW,
- data:false
- });
- }
- Notify.error(data.msg);
- }
- })
- }
- };
- export const delItem = (id) => { //删除
- return (dispatch) => {
- axios.json('/templateInfo/cancelTemplateInfos', {
- ids: id
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(delItems(id));
- Notify.success('模板删除成功');
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const delBatchItem = (ids) => { //批量删除
- return (dispatch) => {
- axios.json('/templateInfo/cancelTemplateInfos', {
- ids: ids.join(",")
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(batchDelItems(ids));
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const changeTitleAsync = (obj) => { //改标题
- let baseList = store.getState();
- let whichSign = baseList.typeConfig.typeConfig;
- let state = baseList.patInfo.message;
- if (obj.title == '') {
- Notify.success('请输入模板名称');
- return;
- }
- return (dispatch) => {
- axios.json('/templateInfo/updateByIdUsNames', {
- "doctorId": state.doctorId,
- "hospitalDeptId": state.hospitalDeptId,
- "hospitalId": state.hospitalId,
- "id": obj.id,
- "modeName": obj.title,
- "type": whichSign
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(changeTitle(obj));
- Notify.success('标题修改成功');
- store.dispatch(changeVisible(false))
- } else {
- console.log(data)
- Notify.error(data.msg)
- }
- })
- }
- };
|