index.jsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import React from 'react';
  2. import { ItemBox,ConfirmModal } 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 } from '@utils/config.js';
  10. import {isIE} from '@utils/tools.js';
  11. (function ($) {
  12. var FileAPI = {
  13. // @default: "./dist/"
  14. staticPath: './dists/',
  15. // @default: FileAPI.staticPath + "FileAPI.flash.swf"
  16. flashUrl: './dists/FileAPI.flash.swf',
  17. // @default: FileAPI.staticPath + "FileAPI.flash.image.swf"
  18. flashImageUrl: './dists/FileAPI.flash.image.swf'
  19. };
  20. return FileAPI
  21. })($)
  22. import "./dists/FileAPI.js";
  23. const api = {
  24. upload: host+'/api/icss/lisExcelRes/lisExcelAnalysis'
  25. };
  26. class Inspect extends React.Component {
  27. constructor(props) {
  28. super(props);
  29. this.state = {
  30. val: '',
  31. visible:false,
  32. dom:[],
  33. isIE:isIE()
  34. }
  35. this.handleImportExcel = this.handleImportExcel.bind(this)
  36. this.cancel = this.cancel.bind(this)
  37. this.getWarings = this.getWarings.bind(this)
  38. }
  39. componentDidMount(){
  40. $('iframe').bind( 'load', function(){} )
  41. // FileAPI.debug = true
  42. $.support.cors = true;
  43. const that = this;
  44. var choose = document.getElementById('choose');
  45. FileAPI.event.on(choose, 'change', function (evt){
  46. var files = FileAPI.getFiles(evt);
  47. var baseData = store.getState().patInfo.message;
  48. FileAPI.filterFiles(files, function (file, info){
  49. let name = file.name;
  50. // if( name.split('.')[1] == 'xlsx' || name.split('.')[1] == 'xls' ){
  51. // Notify.error('请选择正确的excel表格')
  52. // return;
  53. // }else{
  54. // alert(9)
  55. // return true;
  56. // }
  57. return true;
  58. },
  59. function (files, rejected){
  60. if( files.length ){
  61. console.log(files[0])
  62. FileAPI.upload({
  63. // url: '/api/icss/lisExcelRes/lisExcelAnalysis',
  64. url: api.upload,
  65. data:{ hospitalCode:baseData == '{}'? '' : baseData.hospitalCode },
  66. files: { uploadfile: files[0] },
  67. headers:{
  68. // 'Content-Type':'Content-Type: multipart/form-data'
  69. // 'Content-Type':'application/json;charset=UTF-8'
  70. // 'Content-type': "text/plain"
  71. // "Content-Type": 'multipart/form-data',
  72. // 'Accept':'application/json'
  73. },
  74. complete: function (err, xhr){
  75. if( !err ){
  76. let res = JSON.parse(xhr.response);
  77. let message = res.data.messages;
  78. store.dispatch(getExcelList(res.data));
  79. if (message.length != 0) {
  80. that.setState({
  81. visible:true,
  82. dom:message
  83. })
  84. }
  85. $("#choose").val("");
  86. }else{
  87. Notify.error(res.msg)
  88. }
  89. }
  90. });
  91. }
  92. });
  93. });
  94. }
  95. handleImportExcel() {
  96. this.inputRef.click();
  97. }
  98. cancel(){
  99. this.setState({visible:false})
  100. }
  101. getStyle(){
  102. if(this.state.isIE){
  103. return styles.disabledBtn;
  104. }else{
  105. return styles.button;
  106. }
  107. }
  108. getWarings(lis){
  109. <ul>
  110. {
  111. lis.length>0 && lis.map((val)=>{
  112. return <li>
  113. {val}
  114. </li>
  115. })
  116. }
  117. </ul>
  118. }
  119. render() {
  120. const { handleCloseExcel, handleChangeValue, labelListActive, list, handleSign, labelList, handleLabelSub, handleClear, handleConfirm, fillActive, changeActivePart, getExcelDataList,delPartItem } = this.props;
  121. return (
  122. <div className={styles.wrapper} >
  123. {/* 导入功能插件,ie8/9权限问题暂未解决,先隐藏 */}
  124. <div className={styles.top}>
  125. <span>化验结果数据</span>
  126. <div className={this.getStyle()} onClick={this.state.isIE?null:this.handleImportExcel}>
  127. <button disabled={this.state.isIE?true:false}>导入化验结果</button>
  128. <input type="file" name="uploadfile" id="choose" style={{ display: 'none' }} ref={(DOM) => this.inputRef = DOM} />
  129. </div>
  130. </div>
  131. <ItemBox
  132. className={styles.title}
  133. title={'化验'}
  134. editable={false}
  135. border={true}
  136. marginTop={'20px'}
  137. >
  138. <div style={{ padding: '10px', boxSizing: 'border-box' }} >
  139. <AddInspect
  140. handleSign={handleSign}
  141. handleChangeValue={handleChangeValue}
  142. list={list}
  143. labelList={labelList}
  144. handleLabelSub={handleLabelSub}
  145. fillActive={fillActive}
  146. handleClear={handleClear}
  147. handleConfirm={handleConfirm}
  148. changeActivePart={changeActivePart}
  149. getExcelDataList={getExcelDataList}
  150. handleCloseExcel={handleCloseExcel}
  151. labelListActive={labelListActive}
  152. delPartItem={delPartItem}
  153. >
  154. </AddInspect>
  155. </div>
  156. </ItemBox>
  157. <ConfirmModal visible={this.state.visible}
  158. okText='删除'
  159. cancelText='确定'
  160. width="450"
  161. noFooter= {true}
  162. close={this.cancel}>
  163. <ul className={styles.excelList}>
  164. {
  165. this.state.dom.length>0 && this.state.dom.map((val)=>{
  166. return <li className={styles.excelListWaring}>
  167. {val}
  168. </li>
  169. })
  170. }
  171. </ul>
  172. <div onClick={this.cancel} className={styles.confirmBtn}>确定</div>
  173. </ConfirmModal>
  174. </div>
  175. )
  176. }
  177. }
  178. export default Inspect;