index.jsx 12 KB

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