123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- import axios from '@utils/ajax'
- import {
- initItems,
- delItems,
- batchDelItems,
- changeTitle,
- keepPushData,
- changeVisible,
- getDptLis,
- initAdminItems,
- delItemsAdmin,
- batchDelItemsAdmin,
- changeTitleAdmin,
- floderListAdmin,
- folderModal,
- setSearchTemplateNorms,
- } from '@store/actions/tabTemplate';
- import {DIAG_SHOW} from "@store/types/print";
- import Notify from '@commonComp/Notify';
- import store from '@store';
- import {
- getAllDataList,
- getAllDataStringList,
- pushAllDataList,
- getUrlArgObject,
- didPushParamChange
- } from '@utils/tools';
- import { billing, getMRAnalyse } from '@store/async-actions/pushMessage';
- export const initItemList = (current,name,selectTemp) => {
- let admin = store.getState().homePage.admin;
- if(admin || selectTemp==2){
- return initAdminItemList(current,name,selectTemp)
- }else{
- return initCommonItemList(current,name,selectTemp)
- }
- }
- export const initCommonItemList = (current,name) => { //初始化数据
- let baseList = store.getState();
- let state = baseList.patInfo.message;
- // let searchVal = document.getElementById("searchTmp").value
- return (dispatch) => {
- axios.json('/templateInfo/getTemplateAlls', {
- "doctorId": state.doctorId,
- "hospitalDeptId": (name == '')?state.hospitalDeptId:null,
- "hospitalId": state.hospitalId,
- "hospitalCode": state.hospitalCode,
- "current": current,
- "sex":[1,2,3],
- "size": 9999,
- "name":name||''
- }).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- // data.data.flg = flg||false //获取下一页,暂时不用
- dispatch(initItems(data.data));
- } else {
- Notify.error(data.msg)
- }
- })
- }
- };
- export const initAdminItemList = (current,name,selectTemp) => { //初始化数据
- let baseList = store.getState();
- // let searchVal = document.getElementById("searchTmp").value
- let state = baseList.patInfo.message;
- return (dispatch) => {
- if(selectTemp == 2) {
- dispatch(findTemplateNorms(name))
- }else {
- dispatch(getFloderListAll())
- }
- }
- };
- export const saveTemplateDetail = (val,sex,spell) => { //保存为模板
- let baseList = store.getState();
- let jsonData = getAllDataList(baseList);
- let jsonStr = getAllDataStringList(baseList);
- const dConfig = baseList.typeConfig;
- const readMode = dConfig.readMode; //回读模式
- let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
- const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
- jsonData.docConfigs=docConfigs; //保存当时的设置引用
- 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,
- "spell":spell
- }
- return tmpObj;
- }
- return (dispatch) => {
- axios.json('/templateInfo/saveTemplateInfo', getdata()).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- Notify.success('模板保存成功');
- dispatch(initItemList(1,""));
- 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 saveAdminTemplateDetail = (val,sex,id,fstName,folderId,folderName) => { //保存为模板
- let baseList = store.getState();
- let jsonData = getAllDataList(baseList);
- let jsonStr = getAllDataStringList(baseList);
- const dConfig = baseList.typeConfig;
- const readMode = dConfig.readMode; //回读模式
- let whichSign = readMode===-1||readMode===null?dConfig.mode:readMode;
- const docConfigs = dConfig.readConfig===-1||!dConfig.readConfig?dConfig.typeConfig:dConfig.readConfig;
- jsonData.docConfigs=docConfigs; //保存当时的设置引用
- 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": id,
- "hospitalId": state.hospitalId,
- "dataJson": JSON.stringify(jsonData),
- "modeName": val,
- "modeType": whichSign,
- "preview": idx ? JSON.stringify(preview):preview,
- "sex":sex,
- "modeSpell":fstName,
- "folderId": folderId,
- }
- return tmpObj;
- }
- return (dispatch) => {
- axios.json('/templateAdmin/saveTemplateNorms', getdata()).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- Notify.success('模板保存成功');
- dispatch(initItemList(1,""));
- 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 getFloderList = () => { //管理员文件夹列表获取
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateFolderAdmin/list', {
- "doctorId": baseList.doctorId,
- "hospitalId": baseList.hospitalId,
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(floderListAdmin(data.data))
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- function getFloderLis(dispatch){
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateFolderAdmin/list', {
- "doctorId": baseList.doctorId,
- "hospitalId": baseList.hospitalId,
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(floderListAdmin(data.data))
- } else {
- Notify.error(data.msg);
- }
- })
- }
- }
- export const newFloder = (name,id,type) => { //新建管理员文件夹
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateFolderAdmin/saveOrUpdate', {
- "doctorId": baseList.doctorId,
- "hospitalId": baseList.hospitalId,
- "id": id||'',
- "name": name,
- "templateType": 2 //模板类型(个人1,管理员2)
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- if(type=='modify') {
- Notify.success('修改成功');
- } else {
- Notify.success('新建成功');
- }
- dispatch(folderModal(false))
- dispatch(getFloderList())
- dispatch(getFloderListAll())
- dispatch(changeVisible(false))
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const delFloder = (id) => { //文件夹删除
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateFolderAdmin/delete', {
- "doctorId": baseList.doctorId,
- "hospitalId": baseList.hospitalId,
- "folderId": id,
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- Notify.success('文件夹删除成功');
- dispatch(getFloderListAll())
- // axios.json('/templateAdmin/getTemplateNorms').then((res) => {
- // const data = res.data;
- // if (data.code == 0) {
- // // data.data.flg = flg||false //获取下一页,暂时不用
- // dispatch(initAdminItems(data.data));
- // } else {
- // Notify.error(data.msg)
- // }
- // })
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const orderFloder = (folderList) => { //文件夹排序
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateFolderAdmin/sort', {templateFolderSortVOList:folderList}).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- Notify.success('保存成功');
- dispatch(getFloderListAll())
- } else {
- 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 delItemAdmin = (id,folderId) => { //删除
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateAdmin/cancelTemplateNorms', {
- "ids": id,
- "doctorId": baseList.doctorId,
- "hospitalId": baseList.hospitalId,
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- // dispatch(delItemsAdmin(id,folderId));
- dispatch(initAdminItemList())
- 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 delBatchItemAdmin = (ids) => { //批量删除
- let baseList = store.getState().patInfo.message;
- return (dispatch) => {
- axios.json('/templateAdmin/cancelTemplateNorms', {
- "ids": ids.join(","),
- "doctorId": baseList.doctorId,
- "hospitalId": baseList.hospitalId,
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- // dispatch(batchDelItemsAdmin(ids));
- dispatch(initAdminItemList())
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const changeTitleAsyncAdmin = (obj) => { //改标题
- let baseList = store.getState();
- let whichSign = baseList.typeConfig.mode;
- let state = baseList.patInfo.message;
- return (dispatch) => {
- axios.json('/templateAdmin/updateTemplateNorms', {
- "doctorId": state.doctorId,
- "hospitalDeptId": obj.deptId,
- "hospitalId": state.hospitalId,
- "id": obj.id,
- "sex": obj.sex,
- "modeName": obj.title,
- "type": whichSign,
- "folderId": obj.folderId,
- "spell": obj.spell
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(changeTitleAdmin(obj));
- Notify.success('标题修改成功');
- store.dispatch(changeVisible(false))
- dispatch(getFloderListAll())
- } else {
- // console.log(data)
- Notify.error(data.msg)
- }
- })
- }
- };
- export const changeTitleAsync = (obj) => { //改标题
- let baseList = store.getState();
- let whichSign = baseList.typeConfig.mode;
- let state = baseList.patInfo.message;
- return (dispatch) => {
- axios.json('/templateInfo/updateByIdUsNames', {
- "doctorId": state.doctorId,
- "hospitalDeptId": obj.deptId,
- "hospitalId": state.hospitalId,
- "id": obj.id,
- "modeName": obj.title,
- "type": whichSign,
- "spell": obj.spell
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(changeTitle(obj));
- Notify.success('标题修改成功');
- store.dispatch(changeVisible(false))
- store.dispatch(initCommonItemList(1,""))
- } else {
- // console.log(data)
- Notify.error(data.msg)
- }
- })
- }
- };
- export const setPageView = (id) => { //获取模板结构化数据
- return (dispatch) => {
- axios.json('/templateInfo/getTemplateIdAlls', {
- id: id
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- //模板列表不筛选模式后,单个模式引用时看本身的模式
- pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
- if(didPushParamChange()){ //诊断变化时会调推送,避免重复调
- dispatch(billing())
- }
- dispatch(getMRAnalyse())
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const setPageViewAdmin = (id) => { //获取模板结构化数据
- return (dispatch) => {
- axios.json('/templateAdmin/getTemplateIdAlls', {
- id: id
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- //模板列表不筛选模式后,单个模式引用时看本身的模式
- pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
- if(didPushParamChange()){ //诊断变化时会调推送,避免重复调
- dispatch(billing())
- }
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const getDepartments = (value) => { //获取模板结构化数据
- return (dispatch) => {
- axios.json('/doctorInfo/getHospitalDeptInfoAll', {
- "deptInfoName": value,
- "hospitalCode": getUrlArgObject('hospitalId'),
- "thirdpartyName": ""
- }).then((res) => {
- let data = res.data;
- if (data.code == 0) {
- dispatch(getDptLis(data.data))
- } else {
- Notify.error(data.msg);
- }
- })
- }
- };
- export const findTemplateNorms = (name) => {//标准模板搜索
- return (dispatch) => {
- if(!name) {
- dispatch(setSearchTemplateNorms([]));
- } else {
- axios.json('/templateInfo/findTemplateNorms',{
- name,
- templateType: 2
- }).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- dispatch(setSearchTemplateNorms(data.data));
- } else {
- Notify.error(data.msg)
- }
- })
- }
-
- }
-
- }
- export const getFloderListAll = () => {
- return (dispatch) => {
- axios.json('/templateAdmin/getTemplateNorms').then((res) => {
- const data = res.data;
- if (data.code == 0) {
- // data.data.flg = flg||false //获取下一页,暂时不用
- dispatch(initAdminItems(data.data));
- } else {
- Notify.error(data.msg)
- }
- })
- }
- }
- export const addTemplateQuote = (templateId) => {
- let baseList = store.getState();
- let state = baseList.patInfo.message;
- return (dispatch) => {
- axios.json('/templateQuote/addTemplateQuote',{
- "doctorId": state.doctorId,
- "remark": "",
- "templateId": templateId
- }).then((res) => {
- const data = res.data;
- if (data.code == 0) {
- // data.data.flg = flg||false //获取下一页,暂时不用
- } else {
- // Notify.error(data.msg)
- }
- })
- }
- }
|