index.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. import React, { Component } from "react";
  2. import style from "./index.less";
  3. import printImg from '@common/images/icon_print_blue.png';
  4. import preview from '@common/images/preview.png';
  5. import saveHistory from '@common/images/saveHistory.png';
  6. import cancelTag from '@common/images/icon_back.png';
  7. import PrintPreviewContainer from '@containers/PrintPreviewContainer';
  8. import PreviewContainer from '@containers/PreviewContainer';
  9. import { ConfirmModal, Notify } from '@commonComp';
  10. import check_circle from './img/check-circle.png';
  11. import check_right from './img/check-right.png';
  12. import {getAllDataList,getAllDataStringList,isAllPartClear,isAllClear,filterDataArr,readyKeepHistory} from '@utils/tools';
  13. import {dragBox} from '@utils/drag';
  14. import store from '@store';
  15. import $ from 'jquery';
  16. class Operation extends Component {
  17. constructor(props) {
  18. super(props)
  19. this.state = {
  20. title: '',
  21. okText: '',
  22. borderColor: '',
  23. okColor: '',
  24. oKBg: '',
  25. msg: '',
  26. type: '',
  27. zIndex:40,
  28. sex:'3',
  29. le:'',
  30. }
  31. this.showPrint = this.showPrint.bind(this);
  32. this.closePrint = this.closePrint.bind(this);
  33. this.showPreview = this.showPreview.bind(this);
  34. this.closePreview = this.closePreview.bind(this);
  35. this.saveAll = this.saveAll.bind(this);
  36. this.clearAll = this.clearAll.bind(this);
  37. this.saveHis = this.saveHis.bind(this);
  38. this.keypress = this.keypress.bind(this);
  39. }
  40. showPrint() {
  41. this.setState({
  42. zIndex:240
  43. })
  44. this.props.showPrintPreview()
  45. }
  46. closePrint() {
  47. this.setState({
  48. zIndex:40
  49. })
  50. this.props.closePrintPreview()
  51. dragBox('previewPrintWrapper','previewPrintStatic','del')
  52. }
  53. showPreview() {
  54. this.setState({
  55. zIndex:240
  56. })
  57. this.props.showPreview()
  58. }
  59. closePreview() {
  60. this.setState({
  61. zIndex:40
  62. })
  63. this.props.closePreview()
  64. dragBox('previewWrapper','previewStatic','del')
  65. }
  66. saveAll(type) {
  67. let keepState = readyKeepHistory();
  68. if(keepState == 1){
  69. Notify.info('主诉不能为空');
  70. return;
  71. }else if(keepState == 2){
  72. Notify.info('诊断不能为空');
  73. return;
  74. }else{
  75. this.setState({
  76. type: type,
  77. okText: '保存',
  78. borderColor: '#3B9ED0',
  79. okColor: '#fff',
  80. oKBg: '#3B9ED0',
  81. msg: <p className={style['msg']}>是否保存该病历?</p>
  82. })
  83. this.props.diagShowTmp(true)
  84. }
  85. }
  86. clearAll(type) {
  87. let baseList = store.getState();
  88. let jsonData = getAllDataList(baseList);
  89. let jsonStr = getAllDataStringList(baseList);
  90. let flg = isAllPartClear(jsonData,jsonStr,baseList);
  91. if(flg){
  92. this.setState({
  93. type: type,
  94. okText: '清除',
  95. borderColor: 'red',
  96. okColor: 'red',
  97. oKBg: '#fff',
  98. msg: <p className={style['msg']}>是否清空所有内容?</p>
  99. })
  100. this.props.diagShowTmp(true)
  101. }else{
  102. Notify.info('当前页面数据已清空');
  103. }
  104. }
  105. onchange(val) {
  106. this.setState({
  107. title: val
  108. })
  109. }
  110. handleInput(e){
  111. let val = (e.target.value).substring(0,30)
  112. this.onchange(val)
  113. }
  114. keypress(event) {
  115. let e = event?event:window.event;
  116. if (e.keyCode == 13) {
  117. this.makeSure()
  118. }
  119. }
  120. saveHis(type) {
  121. const { diagShowTmp } = this.props;
  122. let flg = this.getAllData();
  123. if(flg){
  124. this.setState({
  125. title: '',
  126. sex:'3',
  127. type: type,
  128. okText: '保存',
  129. borderColor: '#3B9ED0',
  130. okColor: '#fff',
  131. oKBg: '#3B9ED0',
  132. msg: this.changeTitle()
  133. })
  134. diagShowTmp(true)
  135. }
  136. }
  137. getAllData(){
  138. let baseList = store.getState();
  139. let jsonData = getAllDataList(baseList);
  140. let jsonStr = getAllDataStringList(baseList);
  141. let whichSign = baseList.typeConfig.mode;
  142. let tmpLis = baseList.tabTemplate.items;
  143. let flg = isAllClear(jsonStr)
  144. if(!flg){
  145. Notify.info('模板数据不能为空')
  146. return false
  147. }
  148. // console.log(jsonStr.chief,'文本')
  149. // console.log(jsonData,'结构') //测试需要用到,不要删了
  150. // console.log(tmpLis,'接口返回的')
  151. for(let i = 0;i <tmpLis.length;i++){
  152. let dataStr = tmpLis[i].preview;
  153. if(
  154. filterDataArr(JSON.parse(jsonStr.chief)) == filterDataArr(eval('('+JSON.parse(dataStr).chief+')')) &&
  155. filterDataArr(JSON.parse(jsonStr.present)) == filterDataArr(eval('('+JSON.parse(dataStr).present+')')) &&
  156. filterDataArr(JSON.parse(jsonStr.other)) == filterDataArr(eval('('+JSON.parse(dataStr).other+')')) &&
  157. filterDataArr(JSON.parse(jsonStr.vital)) == filterDataArr(eval('('+JSON.parse(dataStr).vital+')')) &&
  158. jsonStr.lis == JSON.parse(dataStr).lis &&
  159. jsonStr.pacs == JSON.parse(dataStr).pacs &&
  160. jsonStr.diag == JSON.parse(dataStr).diag &&
  161. jsonStr.advice == JSON.parse(dataStr).advice
  162. ){
  163. Notify.info('该模板已保存');
  164. return false;
  165. }
  166. }
  167. return true;
  168. }
  169. changeTitle() {
  170. return <div className={style['box']}>
  171. <input className={style['ipt']}
  172. placeholder="请输入模板名称"
  173. type="text"
  174. maxLength='30'
  175. onInput={(e) => {
  176. this.handleInput(e)
  177. }}
  178. onPropertyChange={(e) => { // 兼容ie
  179. this.handleInput(e)
  180. }}
  181. onKeyPress={e => this.keypress(e)}
  182. />
  183. <div className={style['line']}></div>
  184. <div className={style['iptWrap']}>
  185. <p>请选择模板性别归属(错误引用,显示可能有误)</p>
  186. <span className={style['commonSex']} id="commonSex" onClick={this.changeRadio.bind(this,1)}><img src={check_right} alt=""/><i style={{color:'#000'}}>通用</i></span>
  187. <span id="maleSex" onClick={this.changeRadio.bind(this,2)}><img src={check_circle} alt=""/><i>男</i></span>
  188. <span id="femaleSex" onClick={this.changeRadio.bind(this,3)}><img src={check_circle} alt=""/><i>女</i></span>
  189. </div>
  190. </div>
  191. }
  192. changeRadio(sex){
  193. if(sex == 1){
  194. $('#commonSex img').attr('src',check_right)
  195. $('#maleSex img').attr('src',check_circle)
  196. $('#femaleSex img').attr('src',check_circle)
  197. $('#commonSex i').css('color','#000')
  198. $('#maleSex i').css('color','#6b6969')
  199. $('#femaleSex i').css('color','#6b6969')
  200. this.setState({sex:'3'})
  201. }else if(sex == 2){
  202. $('#commonSex img').attr('src',check_circle)
  203. $('#maleSex img').attr('src',check_right)
  204. $('#femaleSex img').attr('src',check_circle)
  205. $('#commonSex i').css('color','#6b6969')
  206. $('#maleSex i').css('color','#000')
  207. $('#femaleSex i').css('color','#6b6969')
  208. this.setState({sex:'1'})
  209. }else if(sex == 3){
  210. $('#commonSex img').attr('src',check_circle)
  211. $('#maleSex img').attr('src',check_circle)
  212. $('#femaleSex img').attr('src',check_right)
  213. $('#commonSex i').css('color','#6b6969')
  214. $('#maleSex i').css('color','#6b6969')
  215. $('#femaleSex i').css('color','#000')
  216. this.setState({sex:'2'})
  217. }
  218. }
  219. makeSure() {
  220. const { save, clear, saveDataAll,diagShowTmp ,chronicMagItem,chronicDesease} = this.props;
  221. const { type } = this.state;
  222. if (type == 1) {
  223. diagShowTmp(false)
  224. this.setState({ title: '' })
  225. save();
  226. } else if (type == 2) {
  227. diagShowTmp(false);
  228. this.setState({ title: '' })
  229. // 慢病标识
  230. const chronicFlag = chronicMagItem || chronicDesease?true:false;
  231. clear(chronicFlag);
  232. //更新滚动条
  233. const that = this;
  234. setTimeout(function(){
  235. that.context.scrollArea&&that.context.scrollArea.refresh();
  236. });
  237. } else if (type == 3) {
  238. if (this.state.title.trim() == '') {
  239. Notify.error('请输入模板名称')
  240. return;
  241. }
  242. saveDataAll(this.state.title,this.state.sex);
  243. }
  244. }
  245. closeDiagBox(){
  246. const { diagShowTmp } = this.props;
  247. const { type } = this.state;
  248. if (type == 3){
  249. diagShowTmp(false)
  250. this.setState({ title: '' })
  251. }else{
  252. diagShowTmp(false)
  253. this.setState({ title: '' })
  254. }
  255. }
  256. componentWillReceiveProps(next){//监听滚动事件
  257. const that = this;
  258. if(next.winWidth <= 1024){
  259. /*$(document).on('scroll',function(){
  260. let left = -($(document).scrollLeft() - 10) + 'px';
  261. that.setState({
  262. le:left
  263. })
  264. })*/
  265. $(window).scroll(function(){
  266. let scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft;
  267. let left = -(scrollLeft - 10) +'px';
  268. that.setState({
  269. le:left
  270. })
  271. })
  272. }
  273. }
  274. render() {
  275. const { showPrint, closePrint, showPreview, closePreview } = this;
  276. const { visible, preVisible,diagShow } = this.props.print;
  277. const {winWidth,cancelDelTag} = this.props;
  278. const {zIndex,type,le} = this.state;
  279. return <div className={style['container']} style={{left:le}}>
  280. <span className={style['button']} onClick={showPrint}><img src={printImg} /> 打印病历</span>
  281. <span className={style['preButton']} onClick={showPreview}><img src={preview} /> 预览</span>
  282. <span className={style['preButton']} onClick={() => { this.saveHis(3) }}><img src={saveHistory} /> 保存病历模板</span>
  283. <span className={style['preButton']} onClick={cancelDelTag}><img src={cancelTag} /> 还原标签</span>
  284. <span className={winWidth<=1082?`${style['saveButton']} ${style['minstyle']}`: style['saveButton']} onClick={() => { this.saveAll(1) }}>保存</span>
  285. <span className={winWidth<=1082?`${style['clearButton']} ${style['saveButton']} ${style['minstyle']}`:`${style['clearButton']} ${style['saveButton']}`} onClick={() => { this.clearAll(2) }}>清除</span>
  286. {visible?<PrintPreviewContainer visible={visible} onClose={closePrint} />:null}
  287. {preVisible?<PreviewContainer visible={preVisible} onClose={closePreview} />:null}
  288. <ConfirmModal
  289. visible={diagShow} //改为全局控制
  290. confirm={() => { this.makeSure() }}
  291. close={() => { this.closeDiagBox()}}
  292. cancel={() => {this.closeDiagBox()}}
  293. okText={this.state.okText}
  294. height={type==3?228:200}
  295. width={type==3?400:300}
  296. okBorderColor={this.state.borderColor}
  297. okColor={this.state.okColor}
  298. oKBg={this.state.oKBg}
  299. >
  300. {this.state.msg}
  301. </ConfirmModal>
  302. </div>;
  303. }
  304. }
  305. Operation.contextTypes = {
  306. scrollArea: React.PropTypes.object
  307. };
  308. export default Operation;