index.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. import React from 'react';
  2. import { ItemBox, ConfirmModal, WrapModalContainer } from '@commonComp';
  3. import AddNewInspect from '../AddNewInspect';
  4. import styles from './index.less';
  5. import { getExcelList } from '@store/actions/inspect';
  6. import Notify from '@commonComp/Notify';
  7. import store from '@store';
  8. import $ from 'jquery';
  9. import { host, prefix } from '@utils/config.js';
  10. import { isIE, getUrlArgObject,getCurrentDate,setFontColorSize } from '@utils/tools.js';
  11. import { dragBox } from '@utils/drag';
  12. import WrapModalBody from '@containers/WrapModalBody';
  13. import {getMRAnalyse} from '@store/async-actions/pushMessage';
  14. import {SET_CURRENT_MODULE} from '@types/homePage';
  15. (function ($) {
  16. var FileAPI = {
  17. // @default: "./dist/"
  18. staticPath: './dists/',
  19. // @default: FileAPI.staticPath + "FileAPI.flash.swf"
  20. flashUrl: './dists/FileAPI.flash.swf',
  21. // @default: FileAPI.staticPath + "FileAPI.flash.image.swf"
  22. flashImageUrl: './dists/FileAPI.flash.image.swf'
  23. };
  24. return FileAPI
  25. })($)
  26. import "./dists/FileAPI.js";
  27. const isLocal = window.location.hostname.indexOf('localhost') != -1;
  28. const qhost = isLocal ? host + prefix : prefix;
  29. const api = {
  30. upload: qhost + '/lisExcelRes/lisExcelAnalysis'
  31. };
  32. let numFlg = 0;
  33. class NewAdvice extends React.Component {
  34. constructor(props) {
  35. super(props);
  36. this.state = {
  37. val: '',
  38. visible: false,
  39. dom: [],
  40. isIE: isIE(),
  41. ieVersion: null,
  42. height: '-1',
  43. hide: false,
  44. importLis:false
  45. }
  46. this.handleImportExcel = this.handleImportExcel.bind(this);
  47. this.cancel = this.cancel.bind(this);
  48. this.getWarings = this.getWarings.bind(this);
  49. this.checkSystemIpt = this.checkSystemIpt.bind(this);
  50. this.onClose = this.onClose.bind(this);
  51. this.handleBindFileApi = this.handleBindFileApi.bind(this);
  52. this.closeInIcss = this.closeInIcss.bind(this);
  53. this.showSlideImport = this.showSlideImport.bind(this);
  54. this.refreshScroller = this.refreshScroller.bind(this);
  55. }
  56. componentDidMount() {
  57. $(document).click((event) => {
  58. let searchWrap = $('#importInspectBtn')[0]; // 导入按钮按钮
  59. let searchOption = $('#importList')[0]; // 下拉列表
  60. if (searchOption&&$('#importList').css("display")=="block") {
  61. if(searchWrap != event.target){
  62. this.setState({ importLis: false });
  63. }
  64. }
  65. });
  66. this.props.setContext(this.context)
  67. }
  68. handleBindFileApi(){
  69. const {message} = this.props;
  70. var ua = navigator.userAgent;
  71. var _isIE = ua.indexOf("MSIE") > -1;
  72. if (_isIE) {
  73. let version = ua.match(/MSIE ([\d.]+)/)[1];
  74. this.setState({
  75. ieVersion: version
  76. })
  77. }
  78. $('iframe').bind('load', function () { })
  79. const { fetchPushInfos } = this.props;
  80. // FileAPI.debug = true
  81. $.support.cors = true;
  82. const that = this;
  83. var choose = document.getElementById('choose');
  84. FileAPI.event.on(choose, 'change', function (evt) {
  85. var files = FileAPI.getFiles(evt);
  86. FileAPI.filterFiles(files, function (file, info) {
  87. let name = file.name;
  88. // if( name.split('.')[1] == 'xlsx' || name.split('.')[1] == 'xls' ){
  89. // Notify.error('请选择正确的excel表格')
  90. // return false;
  91. // }else{
  92. // return true;
  93. // }
  94. return true;
  95. },
  96. function (files, rejected) {
  97. if (files.length) {
  98. //console.log(files[0])
  99. const securityCode = getUrlArgObject("code");
  100. const appKeyId = getUrlArgObject("appI");
  101. const appKeySecret = getUrlArgObject("appS");
  102. const productId = getUrlArgObject("productId");
  103. FileAPI.upload({
  104. // url: '/api/icss/lisExcelRes/lisExcelAnalysis',
  105. url: api.upload,
  106. data: { hospitalCode: message == '{}' ? '' : message.hospitalCode },
  107. files: { uploadfile: files[0] },
  108. headers: {
  109. appKeyId: appKeyId,
  110. appKeySecret: appKeySecret,
  111. securityCode: securityCode,
  112. productId: productId
  113. },
  114. complete: function (err, xhr) {
  115. if (!err) {
  116. let res = JSON.parse(xhr.response);
  117. if(res.code == 0){
  118. let message = res.data.messages;
  119. if(res.data.lisExcelRes){
  120. for(let i = 0;i < res.data.lisExcelRes.length;i++){
  121. let tmpLisExcelItem = res.data.lisExcelRes[i]
  122. if(tmpLisExcelItem.lisExcelItem){
  123. for(let j = 0;j < tmpLisExcelItem.lisExcelItem.length;j++){
  124. tmpLisExcelItem.lisExcelItem[j].time = tmpLisExcelItem.lisExcelItem[j].time||getCurrentDate(1)
  125. }
  126. }
  127. }
  128. }
  129. store.dispatch(getExcelList(res.data));
  130. store.dispatch(getMRAnalyse());
  131. fetchPushInfos && fetchPushInfos({mode:8});
  132. if (message && message.length != 0) {
  133. that.setState({
  134. visible: true,
  135. dom: message,
  136. height: message.length
  137. })
  138. }
  139. }else{
  140. Notify.error(res.msg)
  141. }
  142. $("#choose").val("");
  143. } else {
  144. let res = JSON.parse(xhr.response);
  145. Notify.error(res.msg)
  146. $("#choose").val("");
  147. }
  148. }
  149. });
  150. }
  151. });
  152. });
  153. }
  154. handleImportExcel() {
  155. this.inputRef.click();
  156. const storeState = store.getState()
  157. const {moduleName} = storeState.homePage
  158. if(moduleName != '检验') {
  159. store.dispatch({
  160. type: SET_CURRENT_MODULE,
  161. moduleName:'检验'
  162. });
  163. store.dispatch(getMRAnalyse());
  164. }
  165. }
  166. cancel() {
  167. this.setState({ visible: false })
  168. }
  169. getStyle() {
  170. const { ieVersion } = this.state;
  171. if (ieVersion && ieVersion <= 9) {
  172. return styles.disabledBtn;
  173. } else {
  174. return styles.button;
  175. }
  176. }
  177. getWarings(lis) {
  178. <ul>
  179. {
  180. lis.length > 0 && lis.map((val) => {
  181. return <li>
  182. {val}
  183. </li>
  184. })
  185. }
  186. </ul>
  187. }
  188. checkSystemIpt() {
  189. this.setState({
  190. hide: true
  191. })
  192. const storeState = store.getState()
  193. const {moduleName} = storeState.homePage
  194. if(moduleName != '检验') {
  195. store.dispatch({
  196. type: SET_CURRENT_MODULE,
  197. moduleName:'检验'
  198. });
  199. store.dispatch(getMRAnalyse());
  200. }
  201. }
  202. onClose() {
  203. this.setState({
  204. hide: false
  205. })
  206. dragBox('previewWrapper', 'previewStatic', 'del')
  207. }
  208. closeInIcss(){
  209. this.setState({
  210. hide: false
  211. })
  212. }
  213. showSlideImport(){
  214. let flg = this.state.importLis
  215. this.setState({
  216. importLis:!flg
  217. })
  218. const storeState = store.getState()
  219. const {moduleName} = storeState.homePage
  220. if(moduleName != '检验') {
  221. store.dispatch({
  222. type: SET_CURRENT_MODULE,
  223. moduleName:'检验'
  224. });
  225. store.dispatch(getMRAnalyse());
  226. }
  227. }
  228. refreshScroller(){
  229. //滚动条对象
  230. return this.context.scrollArea;
  231. /*this.context.scrollArea.refresh();
  232. this.context.scrollArea.scrollBottom();*/
  233. }
  234. render() {
  235. const {hideAllDrop,setHighter,labelListBig, fetchPushInfos,getInfomation,labelListSmall, hospitalMsg, inspectVal, windowHeight, windowWidth,setTipValue, handleCloseExcel, handleChangeValue, labelListActive, list, handleSign, labelList, handleLabelSub, handleClear, handleConfirm, fillActive, changeActivePart, getExcelDataList, delPartItem, inspectList,detailClick,handleDelConfirm,checkOnOff } = this.props;
  236. const { ieVersion, isIE, hide,importLis } = this.state;
  237. const { checkSystemIpt, onClose,handleBindFileApi,closeInIcss,showSlideImport } = this;
  238. if(JSON.stringify(hospitalMsg) != {} && document.getElementById("choose")){//动态绑定只绑定一次
  239. ++numFlg
  240. numFlg == 1?handleBindFileApi():null
  241. }
  242. return (
  243. <div className={styles.wrapper}>
  244. {/* 导入功能插件,ie8/9权限问题暂未解决,先隐藏 */}
  245. <div className={styles.top}>
  246. <span id="inspectResultData" className={styles.newAdviceTitle}> </span>
  247. {/* <div className={this.getStyle()} onClick={ieVersion&&ieVersion<=9?null:this.handleImportExcel}> */}
  248. {/* <div className={this.getStyle()} style={{ display: hospitalMsg.import_way_lis == 0||hospitalMsg.import_way_lis ==undefined ? 'none' : 'block' }}> */}
  249. {/* <button disabled={ieVersion&&ieVersion>9?true:false}onClick={ieVersion && ieVersion <= 9 ? null : this.handleImportExcel}>导入检验结果</button>
  250. <input accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" type="file" name="uploadfile" id="choose" style={{ display: 'none' }} ref={(DOM) => this.inputRef = DOM} /> */}
  251. {/* {0没有,1本地,2医院,3本地和医院} */}
  252. {/* {
  253. hospitalMsg.import_way_lis == 1 ? <div className={styles.pushButton} disabled={ieVersion && ieVersion > 9 ? true : false} onClick={ieVersion && ieVersion <= 9 ? null : this.handleImportExcel}>
  254. <p className={styles.importInspectBtn}>导入检验结果</p>
  255. <input accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" type="file" name="uploadfile" id="choose" style={{ display: 'none' }} ref={(DOM) => this.inputRef = DOM} />
  256. </div> : hospitalMsg.import_way_lis == 2 ? <div className={styles.pushButton} disabled={ieVersion && ieVersion > 9 ? true : false} onClick={checkSystemIpt}>
  257. <p className={styles.importInspectBtn}>导入检验结果</p>
  258. </div> : hospitalMsg.import_way_lis == 3 ? <div className={`${styles.pushButton} ${styles.importInspect}`} onClick={showSlideImport}>
  259. <p id="importInspectBtn" className={styles.importInspectBtn}>导入检验结果</p>
  260. {
  261. <ul className={styles.importSelect} style={{display:importLis?'block':'none'}} id="importList">
  262. <li className={styles.excelIpt}>
  263. <div onClick={ieVersion && ieVersion <= 9 ? null : this.handleImportExcel}>本地导入</div>
  264. <input accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" type="file" name="uploadfile" id="choose" style={{ display: 'none' }} ref={(DOM) => this.inputRef = DOM} />
  265. </li>
  266. <li className={`${styles.excelIpt} ${styles.systemIpt}`} onClick={checkSystemIpt}>从设备导入</li>
  267. </ul>
  268. }
  269. </div> : null
  270. } */}
  271. {/* {
  272. hide ? <WrapModalContainer title={'导入检验数据'} width={1000} height={570} onClose={onClose}>
  273. <WrapModalBody
  274. height={570}
  275. closeInIcss={closeInIcss}
  276. ></WrapModalBody>
  277. </WrapModalContainer> : null
  278. } */}
  279. {/* </div> */}
  280. </div>
  281. <ItemBox
  282. hideAllDrop={hideAllDrop}
  283. className={styles.title}
  284. title={'医嘱'}
  285. editable={false}
  286. border={true}
  287. // style={{marginRight:'0'}}
  288. marginTop={'0px'}
  289. >
  290. <div style={{ padding: '0 10px 10px 10px', boxSizing: 'border-box',color:'#000' }} >
  291. <AddNewInspect
  292. checkOnOff={checkOnOff}
  293. handleDelConfirm={handleDelConfirm}
  294. labelListBig={labelListBig}
  295. labelListSmall={labelListSmall}
  296. handleSign={handleSign}
  297. setHighter={setHighter}
  298. refreshScroller={this.refreshScroller}
  299. handleChangeValue={handleChangeValue}
  300. list={list}
  301. handlePush={fetchPushInfos}
  302. detailClick={detailClick}
  303. labelList={labelList}
  304. handleLabelSub={handleLabelSub}
  305. fillActive={fillActive}
  306. handleClear={handleClear}
  307. handleConfirm={handleConfirm}
  308. changeActivePart={changeActivePart}
  309. getExcelDataList={getExcelDataList}
  310. handleCloseExcel={handleCloseExcel}
  311. labelListActive={labelListActive}
  312. delPartItem={delPartItem}
  313. inspectList={inspectList}
  314. getInfomation={getInfomation}
  315. inspectVal={inspectVal}
  316. windowHeight={windowHeight}
  317. windowWidth={windowWidth}
  318. setTipValue={setTipValue}
  319. >
  320. </AddNewInspect>
  321. </div>
  322. </ItemBox>
  323. <ConfirmModal visible={this.state.visible}
  324. okText='删除'
  325. cancelText='确定'
  326. width="450"
  327. height={(this.state.height > 2 && this.state.height < 8) ? ((this.state.height * 30 + 120) + 'px') : this.state.height > 8 ? '350px' : '200px'}
  328. noFooter={true}
  329. close={this.cancel}>
  330. <ul className={styles.excelList}>
  331. {
  332. this.state.dom.length > 0 && this.state.dom.map((val) => {
  333. return <li className={styles.excelListWaring}>
  334. {val}
  335. </li>
  336. })
  337. }
  338. </ul>
  339. <div onClick={this.cancel} className={styles.confirmBtn}>确定</div>
  340. </ConfirmModal>
  341. </div>
  342. )
  343. }
  344. }
  345. NewAdvice.contextTypes = {
  346. scrollArea: React.PropTypes.object
  347. };
  348. export default NewAdvice;