index.jsx 11 KB

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