index.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. const tpVal = $("#clearTemplateSearch").prev().val(); //模板是否有搜索条件未清空
  92. const mdVal = $("#clearMedicalInfoSearch").prev().val(); //知识是否有搜索条件未清空
  93. if(flg||tpVal||mdVal){
  94. this.setState({
  95. type: type,
  96. okText: '清除',
  97. borderColor: 'red',
  98. okColor: 'red',
  99. oKBg: '#fff',
  100. msg: <p className={style['msg']}>是否清空所有内容?</p>
  101. })
  102. this.props.diagShowTmp(true)
  103. }else{
  104. Notify.info('当前页面数据已清空');
  105. }
  106. }
  107. onchange(val) {
  108. this.setState({
  109. title: val
  110. })
  111. }
  112. handleInput(e){
  113. let val = (e.target.value).substring(0,30)
  114. this.onchange(val)
  115. }
  116. keypress(event) {
  117. let e = event?event:window.event;
  118. if (e.keyCode == 13) {
  119. this.makeSure()
  120. }
  121. }
  122. saveHis(type) {
  123. const { diagShowTmp } = this.props;
  124. let flg = this.getAllData();
  125. if(flg){
  126. this.setState({
  127. title: '',
  128. sex:'3',
  129. type: type,
  130. okText: '保存',
  131. borderColor: '#3B9ED0',
  132. okColor: '#fff',
  133. oKBg: '#3B9ED0',
  134. msg: this.changeTitle()
  135. })
  136. diagShowTmp(true)
  137. }
  138. }
  139. getAllData(){
  140. let baseList = store.getState();
  141. let jsonData = getAllDataList(baseList);
  142. let jsonStr = getAllDataStringList(baseList);
  143. let whichSign = baseList.typeConfig.mode;
  144. let tmpLis = baseList.tabTemplate.items;
  145. let flg = isAllClear(jsonStr)
  146. if(!flg){
  147. Notify.info('模板数据不能为空')
  148. return false
  149. }
  150. // console.log(jsonStr.chief,'文本')
  151. // console.log(jsonData,'结构') //测试需要用到,不要删了
  152. // console.log(tmpLis,'接口返回的')
  153. for(let i = 0;i <tmpLis.length;i++){
  154. let dataStr = tmpLis[i].preview;
  155. if(
  156. filterDataArr(JSON.parse(jsonStr.chief)) == filterDataArr(eval('('+JSON.parse(dataStr).chief+')')) &&
  157. filterDataArr(JSON.parse(jsonStr.present)) == filterDataArr(eval('('+JSON.parse(dataStr).present+')')) &&
  158. filterDataArr(JSON.parse(jsonStr.other)) == filterDataArr(eval('('+JSON.parse(dataStr).other+')')) &&
  159. filterDataArr(JSON.parse(jsonStr.vital)) == filterDataArr(eval('('+JSON.parse(dataStr).vital+')')) &&
  160. jsonStr.lis == JSON.parse(dataStr).lis &&
  161. jsonStr.pacs == JSON.parse(dataStr).pacs &&
  162. jsonStr.diag == JSON.parse(dataStr).diag &&
  163. jsonStr.advice == JSON.parse(dataStr).advice
  164. ){
  165. Notify.info('该模板已保存');
  166. return false;
  167. }
  168. }
  169. return true;
  170. }
  171. changeTitle() {
  172. return <div className={style['box']}>
  173. <input className={style['ipt']}
  174. placeholder="请输入模板名称"
  175. type="text"
  176. maxLength='30'
  177. onInput={(e) => {
  178. this.handleInput(e)
  179. }}
  180. onPropertyChange={(e) => { // 兼容ie
  181. this.handleInput(e)
  182. }}
  183. onKeyPress={e => this.keypress(e)}
  184. />
  185. <div className={style['line']}></div>
  186. <div className={style['iptWrap']}>
  187. <p>请选择模板性别归属(错误引用,显示可能有误)</p>
  188. <span className={style['commonSex']} id="commonSex" onClick={this.changeRadio.bind(this,1)}><img src={check_right} alt=""/><i style={{color:'#000'}}>通用</i></span>
  189. <span id="maleSex" onClick={this.changeRadio.bind(this,2)}><img src={check_circle} alt=""/><i>男</i></span>
  190. <span id="femaleSex" onClick={this.changeRadio.bind(this,3)}><img src={check_circle} alt=""/><i>女</i></span>
  191. </div>
  192. </div>
  193. }
  194. changeRadio(sex){
  195. if(sex == 1){
  196. $('#commonSex img').attr('src',check_right)
  197. $('#maleSex img').attr('src',check_circle)
  198. $('#femaleSex img').attr('src',check_circle)
  199. $('#commonSex i').css('color','#000')
  200. $('#maleSex i').css('color','#6b6969')
  201. $('#femaleSex i').css('color','#6b6969')
  202. this.setState({sex:'3'})
  203. }else if(sex == 2){
  204. $('#commonSex img').attr('src',check_circle)
  205. $('#maleSex img').attr('src',check_right)
  206. $('#femaleSex img').attr('src',check_circle)
  207. $('#commonSex i').css('color','#6b6969')
  208. $('#maleSex i').css('color','#000')
  209. $('#femaleSex i').css('color','#6b6969')
  210. this.setState({sex:'1'})
  211. }else if(sex == 3){
  212. $('#commonSex img').attr('src',check_circle)
  213. $('#maleSex img').attr('src',check_circle)
  214. $('#femaleSex img').attr('src',check_right)
  215. $('#commonSex i').css('color','#6b6969')
  216. $('#maleSex i').css('color','#6b6969')
  217. $('#femaleSex i').css('color','#000')
  218. this.setState({sex:'2'})
  219. }
  220. }
  221. makeSure() {
  222. const { save, clear, saveDataAll,diagShowTmp ,chronicMagItem,chronicDesease} = this.props;
  223. const { type } = this.state;
  224. if (type == 1) {
  225. diagShowTmp(false)
  226. this.setState({ title: '' })
  227. save();
  228. } else if (type == 2) {
  229. diagShowTmp(false);
  230. this.setState({ title: '' })
  231. // 慢病标识
  232. const chronicFlag = chronicMagItem || chronicDesease?true:false;
  233. clear(chronicFlag);
  234. //更新滚动条
  235. const that = this;
  236. setTimeout(function(){
  237. that.context.scrollArea&&that.context.scrollArea.refresh();
  238. });
  239. } else if (type == 3) {
  240. if (this.state.title.trim() == '') {
  241. Notify.error('请输入模板名称')
  242. return;
  243. }
  244. saveDataAll(this.state.title,this.state.sex);
  245. }
  246. }
  247. closeDiagBox(){
  248. const { diagShowTmp } = this.props;
  249. const { type } = this.state;
  250. if (type == 3){
  251. diagShowTmp(false)
  252. this.setState({ title: '' })
  253. }else{
  254. diagShowTmp(false)
  255. this.setState({ title: '' })
  256. }
  257. }
  258. componentWillReceiveProps(next){//监听滚动事件
  259. const that = this;
  260. if(next.winWidth <= 1024){
  261. /*$(document).on('scroll',function(){
  262. let left = -($(document).scrollLeft() - 10) + 'px';
  263. that.setState({
  264. le:left
  265. })
  266. })*/
  267. $(window).scroll(function(){
  268. let scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft;
  269. let left = -(scrollLeft - 10) +'px';
  270. that.setState({
  271. le:left
  272. })
  273. })
  274. }
  275. }
  276. render() {
  277. const { showPrint, closePrint, showPreview, closePreview } = this;
  278. const { visible, preVisible,diagShow } = this.props.print;
  279. const {winWidth,cancelDelTag} = this.props;
  280. const {zIndex,type,le} = this.state;
  281. return <div className={style['container']} style={{left:le}}>
  282. <span className={style['button']} onClick={showPrint}><img src={printImg} /> 打印病历</span>
  283. <span className={style['preButton']} onClick={showPreview}><img src={preview} /> 预览</span>
  284. <span className={style['preButton']} onClick={() => { this.saveHis(3) }}><img src={saveHistory} /> 保存病历模板</span>
  285. <span className={style['preButton']} onClick={cancelDelTag}><img src={cancelTag} /> 还原标签</span>
  286. <span className={winWidth<=1082?`${style['saveButton']} ${style['minstyle']}`: style['saveButton']} onClick={() => { this.saveAll(1) }}>保存</span>
  287. <span className={winWidth<=1082?`${style['clearButton']} ${style['saveButton']} ${style['minstyle']}`:`${style['clearButton']} ${style['saveButton']}`} onClick={() => { this.clearAll(2) }}>清除</span>
  288. {visible?<PrintPreviewContainer visible={visible} onClose={closePrint} />:null}
  289. {preVisible?<PreviewContainer visible={preVisible} onClose={closePreview} />:null}
  290. <ConfirmModal
  291. visible={diagShow} //改为全局控制
  292. confirm={() => { this.makeSure() }}
  293. close={() => { this.closeDiagBox()}}
  294. cancel={() => {this.closeDiagBox()}}
  295. okText={this.state.okText}
  296. height={type==3?228:200}
  297. width={type==3?400:300}
  298. okBorderColor={this.state.borderColor}
  299. okColor={this.state.okColor}
  300. oKBg={this.state.oKBg}
  301. >
  302. {this.state.msg}
  303. </ConfirmModal>
  304. </div>;
  305. }
  306. }
  307. Operation.contextTypes = {
  308. scrollArea: React.PropTypes.object
  309. };
  310. export default Operation;