index.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. import React from 'react';
  2. import { SearchOption, InspectCommon, Calendar ,Notify,ConfirmModal,Add} from '@commonComp';
  3. import { deepClone } from '@utils/tools';
  4. import styles from './index.less';
  5. import date1 from './img/date1.png';
  6. import date2 from './img/date2.png';
  7. import close from './img/close.png';
  8. import store from '@store';
  9. import $ from 'jquery';
  10. import more from '@common/images/addItem1.png';
  11. class Inspect extends React.Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. show: false,
  16. showFill: false,
  17. date: false,
  18. currentIdx: '',
  19. dateTime:"",
  20. currentData:{},
  21. numPlus:0, //判断是否所有的填写单都是空
  22. num:0, //暂存数据,获取一次,不能每次都是新的数据
  23. toastText:'',
  24. visible:false,
  25. type:null,
  26. id:null
  27. }
  28. this.handleChangeDate = this.handleChangeDate.bind(this)
  29. this.handleShowDate = this.handleShowDate.bind(this)
  30. this.getCurrentDate = this.getCurrentDate.bind(this)
  31. this.getItemList = this.getItemList.bind(this)
  32. this.getSearchList = this.getSearchList.bind(this)
  33. this.changeActivePart = this.changeActivePart.bind(this)
  34. this.normalVal = this.normalVal.bind(this)
  35. this.showDetails = this.showDetails.bind(this)
  36. this.delConfirm = this.delConfirm.bind(this)
  37. this.handleCancel = this.handleCancel.bind(this)
  38. this.handleSearchShow = this.handleSearchShow.bind(this)
  39. }
  40. delConfirm(){//弹窗确定
  41. const{delPartItem,handleCloseExcel} = this.props;
  42. const{type,id} = this.state;
  43. if(type==1){
  44. delPartItem(id)
  45. }else if(type==2){
  46. handleCloseExcel(id)
  47. }
  48. this.setState({
  49. visible:false,
  50. type:null,
  51. id:null,
  52. })
  53. Notify.success("删除成功");
  54. }
  55. handleDelClick(type,idx){
  56. this.setState({
  57. type:type,
  58. id:idx,
  59. visible:true
  60. })
  61. if(type==1){//单项
  62. this.setState({
  63. toastText:'是否删除该化验项?'
  64. })
  65. }else if(type==2){//导入项
  66. this.setState({
  67. toastText:'是否删除导入项?'
  68. })
  69. }
  70. }
  71. handleCancel(){
  72. this.setState({
  73. visible:false,
  74. type:null,
  75. id:null,
  76. })
  77. }
  78. componentDidMount() {
  79. $(document).click((event) => {
  80. let searchWrap = $('#searchWrap')[0]; // 搜索按钮
  81. let searchImg = $('#addImg')[0]; // +号按钮
  82. let searchOption = $('#searchOption')[0]; // 搜索列表
  83. let inspectFill = $('#inspectFill')[0]; // 公共填写单
  84. if(searchOption){
  85. if ( searchOption != event.target && searchWrap != event.target && searchImg != event.target && !$.contains(searchOption, event.target)) { // Mark 1
  86. this.setState({ show: false });
  87. }
  88. }
  89. if(inspectFill){
  90. if ( event.target.getAttribute('data-flg') != 'current' && inspectFill != event.target && !$.contains(inspectFill, event.target)) { // Mark 1
  91. this.setState({ showFill: false });
  92. }
  93. }
  94. });
  95. this.getCurrentDate();
  96. }
  97. componentWillReceiveProps(nextProps){
  98. if(nextProps.fillActive.name != this.props.fillActive.name){
  99. this.setState({num:0})
  100. }
  101. }
  102. handleChangeDate(info) {
  103. let date = info.year+'-'+(info.month<10?'0'+info.month:info.month)+'-'+(info.day<10?'0'+info.day:info.day);
  104. this.setState({dateTime:date,date:false})
  105. }
  106. handleSearchShow(e) {
  107. let tmpShow = this.state.show;
  108. this.setState({ show: !tmpShow })
  109. // e.stopPropagation();
  110. }
  111. handleFillShow(e,idx) {
  112. let tmpShow = this.state.showFill;
  113. let baseList = store.getState().inspect.fillActive;
  114. this.setState({
  115. showFill: !tmpShow,
  116. currentIdx:idx,
  117. currentData:baseList
  118. })
  119. // e.stopPropagation();
  120. }
  121. handleShowDate(){
  122. this.setState({
  123. date:!this.state.date
  124. })
  125. }
  126. getCurrentDate(){
  127. let myDate = new Date();
  128. let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  129. let mon = myDate.getMonth()-0+1; //获取当前月份(0-11,0代表1月)
  130. let day = myDate.getDate(); //获取当前日(1-31)
  131. let date = year+'-'+(mon<10?'0'+mon:mon)+'-'+(day<10?'0'+day:day);
  132. this.setState({dateTime:date})
  133. }
  134. changeActivePart(idx,val){
  135. let nums = this.state.num;
  136. let fillActive;
  137. if(nums == 0){
  138. fillActive = this.props.fillActive;
  139. }else{
  140. fillActive = this.state.currentData;
  141. }
  142. ++nums;
  143. this.setState({num:nums});
  144. let tempArr = deepClone(fillActive);
  145. let tempNumPlus = 0;
  146. for (let i = 0; i < tempArr.details.length; i++) {
  147. if (i == idx) {
  148. tempArr.details[i].value = val
  149. }
  150. if(tempArr.details[i].value != undefined && tempArr.details[i].value != ''){
  151. tempArr.show = true;
  152. }else{
  153. ++tempNumPlus;
  154. if(tempNumPlus == tempArr.details.length){
  155. tempArr.show = false;
  156. }
  157. }
  158. }
  159. tempArr.time = this.state.dateTime;
  160. this.setState({currentData:tempArr})
  161. }
  162. getItemList(){ //填写单展示
  163. let number = this.state.num;
  164. let fillActive;
  165. if(number == 0){
  166. fillActive = this.props.fillActive;
  167. }else{
  168. fillActive = this.state.currentData;
  169. }
  170. return <ul className={styles.searchLis}>
  171. {
  172. fillActive && fillActive.details && fillActive.details.map((item,idx) => {
  173. if(item.controlType == 1){
  174. return (
  175. <li className={`${styles.itemPart} ${fillActive.details.length>1?'':styles.itemPartOne}`}>
  176. <span className={styles.itemPartL}>{item.name}</span>
  177. <select className={styles.itemPartR} onChange={(e)=>{
  178. if(e.target.value == '请选择') {
  179. this.changeActivePart(idx,'')
  180. return;
  181. }
  182. this.changeActivePart(idx,e.target.value);
  183. }}
  184. >
  185. <option value="请选择">请选择</option>
  186. {
  187. (item.questionDetailList).map((val)=>{
  188. return <option value={val.name}
  189. selected={val.name == item.value?true:false}
  190. >{val.name}</option>
  191. })
  192. }
  193. </select>
  194. </li>
  195. )
  196. }else if(item.controlType == 6){
  197. return (
  198. <li className={`${styles.itemPart} ${fillActive.details.length>1?'':styles.itemPartOne}`}>
  199. <span className={styles.itemPartL}>{item.name}</span>
  200. <span className={styles.itemPartT}>
  201. <input type="text"
  202. placeholder="(填写)"
  203. value={item.value}
  204. onKeyUp={(e)=>{this.changeActivePart(idx,e.target.value.trim())}}
  205. />
  206. <p className={styles.unit}>{item.labelSuffix}</p>
  207. </span>
  208. </li>
  209. )
  210. }
  211. })
  212. }
  213. </ul>
  214. }
  215. getSearchList(list){ //搜索列表
  216. const {handleSign} = this.props;
  217. return <ul>
  218. {
  219. list && list.map((item,idx) => {
  220. return <li key={idx}
  221. className={styles.searchLi}
  222. title={item.name}
  223. onClick={() => {
  224. handleSign(item.questionId,idx);
  225. this.setState({ show: false })
  226. }}
  227. >
  228. {item.name}{item.name == item.retrievalName?null:'('+item.retrievalName+')'}
  229. </li>
  230. })
  231. }
  232. </ul>
  233. }
  234. normalVal(min,max){
  235. if((min-0) && (max-0)){
  236. return `正常值: (${min}~${max})`
  237. }else if((min-0) && !(max-0)){
  238. return `正常值: (>=${min})`
  239. }else if(!(min-0) && (max-0)){
  240. if(min == '' || min == null){
  241. return `正常值: (<=${max})`
  242. }else{
  243. return `正常值: (${min}~${max})`
  244. }
  245. }else{
  246. return null;
  247. }
  248. }
  249. showDetails(val){
  250. if(val.questionDetailList.length > 0){
  251. return val.questionDetailList.map((item)=>{
  252. if(val.value == item.name){
  253. return <td className={item.abnormal != '0' ?"red":'' }>{val.value}</td>
  254. }
  255. })
  256. }else{
  257. return <td><span className={val.value > val.maxValue || val.value < val.minValue?"red":''}>{val.value}</span> { val.labelSuffix}</td>
  258. }
  259. }
  260. render() {
  261. const { handleChangeValue, list, labelList,delPartItem, handleLabelSub, handleClear, handleConfirm, fillActive,getExcelDataList,handleCloseExcel } = this.props;
  262. const {toastText,visible} = this.state;
  263. return (
  264. <div className={styles.wrapper}>
  265. <div className={styles.check}>
  266. {
  267. getExcelDataList.length > 0 && getExcelDataList.map((items,idx)=>{
  268. return <div style={{marginTop:'10px'}}>
  269. {
  270. items && items.lisExcelRes.length > 0 ? <ul className={styles.excelDataLists}>
  271. <img className={styles.close} src={close} alt="关闭导入excel数据" onClick={(idx)=>{this.handleDelClick(2,idx)}}/>
  272. {
  273. items.lisExcelRes.map((item,idx)=>{
  274. return <li className={styles.excelDataLis} style={{border:items.lisExcelRes.length-1 == idx? 0:''}}>
  275. <span className={styles.excelDataTitle}>
  276. {item.menus}
  277. </span>
  278. <table>
  279. {
  280. item.lisExcelItem && item.lisExcelItem.map((value)=>{
  281. return <tr>
  282. <td>{value.itemName}</td>
  283. <td><span className={value.type == 1?'red':null}>{value.value}</span> {value.unit}</td>
  284. <td>
  285. {this.normalVal(value.min,value.max)}
  286. </td>
  287. <td>{value.time == ''?('导入时间: '+this.state.dateTime):'化验时间: '+value.time}</td>
  288. </tr>
  289. })
  290. }
  291. </table>
  292. </li>
  293. })
  294. }
  295. </ul>:null
  296. }
  297. </div>
  298. })
  299. }
  300. <ul className={styles.labelWrap} >
  301. {
  302. labelList && labelList.map((item,idx) => {
  303. return <li key={item.questionId}>
  304. {
  305. // 标签,血常规。。
  306. item.show ?
  307. <p className={styles.staticTagActive}>
  308. <span data-flg="current" style={{color:"#333"}} onClick={(e) => { handleLabelSub(e, item.questionId,idx); this.handleFillShow(e,idx) }}>{item.name}</span>
  309. </p>:
  310. <p>
  311. <i data-flg="current" onClick={(e) => { handleLabelSub(e,item.questionId,idx); this.handleFillShow(e,idx) }}>{item.name}</i>
  312. </p>
  313. }
  314. {
  315. item.show ?
  316. <table className={styles.table}>
  317. {
  318. item.details.map((val)=>{
  319. if(val.value && val.value != ''){
  320. return <tr>
  321. <td>{val.name}</td>
  322. {this.showDetails(val)}
  323. <td>
  324. {this.normalVal(val.minValue,val.maxValue)}
  325. </td>
  326. <td>{'化验时间:'+item.time}</td>
  327. </tr>
  328. }
  329. })
  330. }
  331. </table>:null
  332. }
  333. <div className={styles.searchResult}>
  334. {
  335. this.state.showFill && fillActive.id == item.id && idx == this.state.currentIdx ?
  336. <InspectCommon
  337. showFill={this.state.showFill}
  338. handleClear={(e)=>{
  339. handleClear(e,idx)
  340. this.setState({
  341. showFill:false
  342. })
  343. }}
  344. handleConfirm={(e)=>{
  345. // handleConfirm(e,idx,this.state.dateTime,fillActive);
  346. if(JSON.stringify(this.state.currentData) == '{}'){
  347. handleConfirm(e,idx,this.state.dateTime,fillActive);
  348. }else{
  349. handleConfirm(e,idx,this.state.dateTime,this.state.currentData);
  350. }
  351. this.setState({showFill:false})
  352. }}
  353. >
  354. <div className={styles.searchResultT}>
  355. <img style={{"position":"absolute","top":"8px","right":"8px"}} src={date1} alt="" onClick={this.handleShowDate}/>
  356. <p style={{position:"absolute",right:"38px",top:"4px",lineHeight:"28px"}}>
  357. {this.state.dateTime}
  358. </p>
  359. <div style={{display:this.state.date?"block":"none",position:"relative"}}>
  360. {/* 日期组件 */}
  361. <Calendar isShow={true} handleChange={this.handleChangeDate}></Calendar>
  362. </div>
  363. </div>
  364. {/* 填写单内容显示 */}
  365. { this.getItemList(idx) }
  366. </InspectCommon>
  367. : null
  368. }
  369. </div>
  370. <img className={styles.partDel} src={close} alt="删除项" onClick={(idx)=>{this.handleDelClick(1,idx)}}/>
  371. </li>
  372. })
  373. }
  374. </ul>
  375. </div>
  376. <div style={{position:"relative"}}>
  377. <img src={more} id="addImg" style={{verticalAlign:'middle',marginRight:'2px'}} onClick={(e) => this.handleSearchShow(e)}/>
  378. <span id="searchWrap" className={`${styles.staticTag}`} onClick={(e) => this.handleSearchShow(e)}>添加化验项</span>
  379. <SearchOption handleChangeValue={handleChangeValue} visible={this.state.show}>
  380. {this.getSearchList(list)}
  381. </SearchOption>
  382. </div>
  383. <ConfirmModal
  384. visible={visible}
  385. confirm={()=>{this.delConfirm()}}
  386. close={this.handleCancel}
  387. cancel={this.handleCancel}
  388. okText="删除"
  389. cancelText='取消'
  390. okBorderColor={'#3B9ED0'}
  391. okColor={'#fff'}
  392. oKBg={'#3B9ED0'}
  393. >
  394. <p className={styles['center']}>{toastText}</p>
  395. </ConfirmModal>
  396. </div>
  397. )
  398. }
  399. }
  400. export default Inspect;