123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- import React, { Component } from "react";
- import style from "./index.less";
- import printImg from '@common/images/icon_print_blue.png';
- import preview from '@common/images/preview.png';
- import saveHistory from '@common/images/saveHistory.png';
- import PrintPreviewContainer from '@containers/PrintPreviewContainer';
- import PreviewContainer from '@containers/PreviewContainer';
- import { ConfirmModal, Notify } from '@commonComp';
- import {getAllDataList,getAllDataStringList} from '@utils/tools';
- import store from '@store';
- class Operation extends Component {
- constructor(props) {
- super(props)
- this.state = {
- title: '',
- okText: '',
- borderColor: '',
- okColor: '',
- oKBg: '',
- msg: '',
- type: '',
- zIndex:40
- }
- this.showPrint = this.showPrint.bind(this);
- this.closePrint = this.closePrint.bind(this);
- this.showPreview = this.showPreview.bind(this);
- this.closePreview = this.closePreview.bind(this);
- this.saveAll = this.saveAll.bind(this);
- this.clearAll = this.clearAll.bind(this);
- this.saveHis = this.saveHis.bind(this);
- this.keypress = this.keypress.bind(this);
- }
- showPrint() {
- this.setState({
- zIndex:240
- })
- this.props.showPrintPreview()
- }
- closePrint() {
- this.setState({
- zIndex:40
- })
- this.props.closePrintPreview()
- }
- showPreview() {
- this.setState({
- zIndex:240
- })
- this.props.showPreview()
- }
- closePreview() {
- this.setState({
- zIndex:40
- })
- this.props.closePreview()
- }
- saveAll(type) {
- let flg = this.keepHistory();
- if(flg){
- this.setState({
- type: type,
- okText: '保存',
- borderColor: '#3B9ED0',
- okColor: '#fff',
- oKBg: '#3B9ED0',
- msg: <p className={style['msg']}>是否保存该病历?</p>
- })
-
- this.props.diagShowTmp(true)
- }
- }
- keepHistory(){
- let baseList = store.getState();
- let jsonStr = getAllDataStringList(baseList);
- if(JSON.parse(jsonStr.chief).length == 1 && JSON.parse(jsonStr.chief)[0].trim() ==''){
- Notify.info('主诉不能为空');
- return false;
- }else if(jsonStr.chief && JSON.parse(jsonStr.chief).length < 1){
- Notify.info('主诉不能为空');
- return false;
- }else if(!jsonStr.diag || jsonStr.diag.trim().length < 1){
- Notify.info('诊断不能为空');
- return false;
- }else{
- return true;
- }
- }
- clearAll(type) {
- let flg = this.isClear();
- if(flg){
- this.setState({
- type: type,
- okText: '清除',
- borderColor: 'red',
- okColor: 'red',
- oKBg: '#fff',
- msg: <p className={style['msg']}>是否清空所有内容?</p>
- })
-
- this.props.diagShowTmp(true)
- }
- }
- isClear(){
- let baseList = store.getState();
- let jsonData = getAllDataList(baseList);
- let jsonStr = getAllDataStringList(baseList);
- if ( //结构化和文本数据都为空
- JSON.stringify(jsonData.advice) == '{}' &&
- jsonData.chief.length < 1 &&
- jsonData.diag.length < 1 &&
- jsonData.vital.length < 1 &&
- jsonData.other.length < 1 &&
- jsonData.pacs.length < 1 &&
- jsonData.present.length < 1 &&
- jsonData.lis.labelList.length < 1 &&
- jsonData.lis.getExcelDataList.length < 1 &&
- JSON.stringify(jsonData.advice) == '{}' &&
- jsonStr.chief == '[]' &&
- jsonStr.present == '[]' &&
- jsonStr.other == '[]' &&
- jsonData.vital.length < 1 &&
- jsonData.diag.length < 1 &&
- jsonData.pacs.length < 1 &&
- jsonData.lis.labelList.length < 1 &&
- jsonData.lis.getExcelDataList.length < 1
- ) {
- Notify.info('当前页面数据已清空');
- return false;
- }else{
- return true;
- }
- }
- onchange(val) {
- this.setState({
- title: val
- })
- }
- handleInput(e){
- let val = e.target.value
- if(e.target.value.length > 30){
- e.target.value = val.substring(0,30)
- this.onchange(val.substring(0,30))
- }else{
- this.onchange(e.target.value)
- }
- }
- keypress(event) {
- let e = event?event:window.event;
- if (e.keyCode == 13) {
- this.makeSure()
- }
- }
- saveHis(type) {
- const { diagShowTmp } = this.props;
- let flg = this.getAllData();
- if(flg){
- this.setState({
- title: '',
- type: type,
- okText: '保存',
- borderColor: '#3B9ED0',
- okColor: '#fff',
- oKBg: '#3B9ED0',
- msg: this.changeTitle()
- })
- diagShowTmp(true)
- }
- }
- getAllData(){
- let baseList = store.getState();
- let jsonData = getAllDataList(baseList);
- let jsonStr = getAllDataStringList(baseList);
- let whichSign = baseList.typeConfig.typeConfig;
- let tmpLis = baseList.tabTemplate.items;
- for(let i = 0;i <tmpLis.length;i++){
- let dataStr = tmpLis[i].preview;
- let jsStr = tmpLis[i].dataJson;
- // console.log(JSON.stringify(JSON.parse(dataStr)))
- // console.log(JSON.stringify(jsonStr))
- if(JSON.stringify(JSON.parse(dataStr)) == JSON.stringify(jsonStr) && jsStr == JSON.stringify(jsonData)){
- Notify.info('该模板已保存');
- return false;
- }
- }
- if (whichSign == 0) {
- if (
- JSON.stringify(jsonData.advice) == '{}' &&
- (jsonData.chief.length < 1 && jsonStr.chief == '[]') &&
- jsonData.diag.length < 1 &&
- jsonData.vital.length < 1 &&
- jsonData.other.length < 1 &&
- jsonData.pacs.length < 1 &&
- jsonData.present.length < 1 &&
- jsonData.lis.labelList.length < 1 &&
- jsonData.lis.getExcelDataList.length < 1
- ) {
- Notify.info('模板数据不能为空');
- return false;
- }else{
- return true;
- }
- } else if(whichSign == 1) {
- if (JSON.stringify(jsonData.advice) == '{}' &&
- jsonStr.chief == '[]' &&
- jsonStr.present == '[]' &&
- jsonStr.other == '[]' &&
- jsonData.vital.length < 1 &&
- jsonData.diag.length < 1 &&
- jsonData.pacs.length < 1 &&
- jsonData.lis.labelList.length < 1 &&
- jsonData.lis.getExcelDataList.length < 1
- ) {
- Notify.info('模板数据不能为空');
- return false;
- }else{
- return true;
- }
- }else{
- return true;
- }
- }
- changeTitle() {
- return <div className={style['box']}>
- <input className={style['ipt']}
- placeholder="请输入模板名称"
- type="text"
- maxLength='30'
- onInput={(e) => {
- this.handleInput(e)
- }}
- onPropertyChange={(e) => { // 兼容ie
- this.handleInput(e)
- }}
- onKeyPress={e => this.keypress(e)}
- />
- <div className={style['line']}></div>
- </div>
- }
- makeSure() {
- const { save, clear, saveDataAll,diagShowTmp } = this.props;
- const { type } = this.state;
- if (type == 1) {
- diagShowTmp(false)
- this.setState({ title: '' })
- save();
- } else if (type == 2) {
- diagShowTmp(false)
- this.setState({ title: '' })
- clear();
- } else if (type == 3) {
- if (this.state.title.trim() == '') {
- Notify.error('请输入模板名称')
- return;
- }
- // diagShowTmp(false)
- saveDataAll(this.state.title);
- }
- }
- closeDiagBox(){
- const { diagShowTmp } = this.props;
- const { type } = this.state;
- if (type == 3){
- diagShowTmp(false)
- this.setState({ title: '' })
- }else{
- diagShowTmp(false)
- this.setState({ title: '' })
- }
- }
- render() {
- const { showPrint, closePrint, showPreview, closePreview } = this;
- const { visible, preVisible,diagShow } = this.props.print;
- const {zIndex} = this.state;
- return <div className={style['container']} style={{zIndex:zIndex}}>
- <span className={style['button']} onClick={showPrint}><img src={printImg} /> 打印病历</span>
- <span className={style['preButton']} onClick={showPreview}><img src={preview} /> 预览</span>
- <span className={style['preButton']} onClick={() => { this.saveHis(3) }}><img src={saveHistory} /> 保存病历模板</span>
- <span className={style['saveButton']} onClick={() => { this.saveAll(1) }}>保存</span>
- <span className={`${style['clearButton']} ${style['saveButton']}`} onClick={() => { this.clearAll(2) }}>清除</span>
- <PrintPreviewContainer visible={visible} onClose={closePrint} />
- <PreviewContainer visible={preVisible} onClose={closePreview} />
- <ConfirmModal
- visible={diagShow} //改为全局控制
- confirm={() => { this.makeSure() }}
- close={() => { this.closeDiagBox()}}
- cancel={() => {this.closeDiagBox()}}
- okText={this.state.okText}
- okBorderColor={this.state.borderColor}
- okColor={this.state.okColor}
- oKBg={this.state.oKBg}
- >
- {this.state.msg}
- </ConfirmModal>
- </div>;
- }
- }
- export default Operation;
|