index.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. import React from 'react';
  2. import { SearchOption, InspectCommon, Calendar, Notify, ConfirmModal, Add, DelToast } from '@commonComp';
  3. import SlideExcel from './SlideExcel';
  4. import SlidePic from './SlidePic';
  5. import { deepClone, getPageCoordinate, getStatusImg,getDomUpDown ,getCurrentDate,setPosition,getCalendarDate} from '@utils/tools';
  6. import styles from './index.less';
  7. import ScrollArea from 'react-scrollbar';
  8. import store from '@store';
  9. import $ from 'jquery';
  10. class Inspect extends React.Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. show: false,
  15. showFill: false,
  16. date: false,
  17. currentIdx: '',
  18. dateTime: "",
  19. currentData: {},
  20. numPlus: 0, //判断是否所有的填写单都是空
  21. num: 0, //暂存数据,获取一次,不能每次都是新的数据
  22. type: null,
  23. id: null,
  24. pageTop: '',
  25. // tmpIds: [], //内层外层
  26. impId: null
  27. }
  28. this.$ul = React.createRef();
  29. this.handleChangeDate = this.handleChangeDate.bind(this)
  30. this.handleShowDate = this.handleShowDate.bind(this)
  31. this.getItemList = this.getItemList.bind(this)
  32. this.getSearchList = this.getSearchList.bind(this)
  33. this.getCommonList = this.getCommonList.bind(this)
  34. this.changeActivePart = this.changeActivePart.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. this.changeShowFill = this.changeShowFill.bind(this)
  40. this.handleFillShow = this.handleFillShow.bind(this)
  41. this.handleDelClick = this.handleDelClick.bind(this)
  42. }
  43. delConfirm() {//弹窗确定
  44. const { delPartItem, handleCloseExcel, handlePush } = this.props;
  45. const { type, id, impId } = this.state;
  46. if (type == 1) {
  47. delPartItem(id)
  48. } else if (type == 2) {
  49. handleCloseExcel(impId)
  50. }
  51. this.setState({
  52. type: null,
  53. id: null,
  54. impId: null
  55. })
  56. Notify.success("删除成功");
  57. handlePush && handlePush({mode:8}); //右侧推送
  58. }
  59. handleDelClick(type, idx) {
  60. if (type == 2) {
  61. this.setState({
  62. impId: idx,
  63. type: type,
  64. id: null
  65. })
  66. } else {
  67. this.setState({
  68. type: type,
  69. id: idx,
  70. impId: null
  71. })
  72. }
  73. }
  74. handleCancel() {
  75. this.setState({
  76. type: null,
  77. id: null,
  78. impId: null
  79. })
  80. }
  81. componentDidMount() {
  82. $(document).click((event) => {
  83. let searchWrap = document.getElementById("searchWrap"); // 搜索按钮
  84. let searchOption = document.getElementById("searchOption"); // 搜索列表
  85. let inspectFill = document.getElementById("inspectFill"); // 公共填写单
  86. let _del = $('#delBox')[0]; // 删除弹窗
  87. let _impClose = $('#impClose')[0]; // 导入删除按钮
  88. let _addClose = $('#addClose')[0]; // 添加删除按钮
  89. let _closeTil = $('#delTit')[0]; // 弹窗标题
  90. if (searchOption&&!this.isBar) {//onMousedown的目标为滚动条时,添加弹窗不关闭
  91. if (searchOption != event.target && searchWrap != event.target && searchWrap != event.target.parentNode && !$.contains(searchOption, event.target)) { // Mark 1
  92. if(this.state.show){
  93. this.props.setHighter(48)
  94. }
  95. this.setState({ show: false });
  96. }
  97. }
  98. if (inspectFill&&!this.isBar) {//onMousedown的目标为滚动条时,子项弹窗不关闭
  99. if ($(event.target).attr('id') != "getSureTime"&&event.target.getAttribute('data-flg') != 'current' && inspectFill != event.target && !$.contains(inspectFill, event.target)) { // Mark 1
  100. if(this.state.showFill){
  101. this.props.setHighter(48)
  102. }
  103. this.setState({ showFill: false, date: false });
  104. }
  105. }
  106. if (_del&&!this.isBar) {//onMousedown的目标为滚动条时,删除弹窗不关闭
  107. if (!event.target.isEqualNode(_impClose) && !event.target.isEqualNode(_addClose) && !event.target.isEqualNode(_del) && event.target.parentNode != _del && !event.target.isEqualNode(_closeTil)) {
  108. this.setState({
  109. id: null,
  110. impId: null
  111. })
  112. }
  113. }
  114. });
  115. const that = this;
  116. document.addEventListener('mousedown',function(e){
  117. //onMousedown的目标为滚动条时,标签填写单不关闭
  118. if(e.target.className=='scrollbar'){
  119. that.isBar = true;
  120. }else{
  121. that.isBar = false;
  122. }
  123. });
  124. // this.setState({ dateTime: getCurrentDate(1) })
  125. }
  126. componentWillReceiveProps(nextProps) {
  127. if (nextProps.fillActive.name != this.props.fillActive.name) {
  128. this.setState({ num: 0 })
  129. }
  130. }
  131. changeShowFill() {
  132. this.setState({ showFill: false })
  133. this.props.setHighter(48)
  134. }
  135. handleChangeDate(info) {
  136. let date = getCalendarDate(info);
  137. this.setState({ dateTime: date, date: false })
  138. }
  139. handleSearchShow(e) {
  140. let tmpShow = this.state.show;
  141. this.setState({ show: !tmpShow, pageTop: getPageCoordinate(e).boxTop })
  142. // e.stopPropagation();
  143. if(tmpShow){
  144. this.props.setHighter(48)
  145. }else{
  146. setPosition(e,"#searchOption",this.props.setHighter)
  147. }
  148. }
  149. handleFillShow(e, idx) {
  150. let tmpShow = this.state.showFill;
  151. let baseList = store.getState().inspect.fillActive;
  152. this.setState({
  153. showFill: !tmpShow,
  154. currentIdx: idx,
  155. currentData: baseList,
  156. dateTime: baseList.time ? baseList.time : getCurrentDate(1)
  157. })
  158. // e.stopPropagation();
  159. }
  160. handleShowDate() {
  161. this.setState({
  162. date: !this.state.date
  163. })
  164. }
  165. changeActivePart(idx, val, clear) {
  166. let nums = this.state.num;
  167. let fillActive;
  168. if (nums == 0) {
  169. fillActive = this.props.fillActive;
  170. } else {
  171. fillActive = this.state.currentData;
  172. }
  173. ++nums;
  174. this.setState({ num: nums });
  175. let tempArr = deepClone(fillActive);
  176. if (clear) { //点击清空按钮,至清初输入的数字
  177. for (let i = 0; i < tempArr.details.length; i++) {
  178. tempArr.details[i].value = ''
  179. tempArr.show = false;
  180. }
  181. tempArr.time = getCurrentDate(1);
  182. this.setState({ currentData: tempArr })
  183. return;
  184. } else {
  185. let tempNumPlus = 0;
  186. for (let i = 0; i < tempArr.details.length; i++) {
  187. if (i == idx) {
  188. tempArr.details[i].value = val
  189. }
  190. if (tempArr.details[i].value != undefined && tempArr.details[i].value != '') {
  191. tempArr.show = true;
  192. } else {
  193. ++tempNumPlus;
  194. if (tempNumPlus == tempArr.details.length) {
  195. tempArr.show = false;
  196. }
  197. }
  198. }
  199. tempArr.time = this.state.dateTime;
  200. this.setState({ currentData: tempArr })
  201. }
  202. }
  203. getItemList() { //填写单展示
  204. let number = this.state.num;
  205. let fillActive;
  206. if (number == 0) {
  207. fillActive = this.props.fillActive;
  208. } else {
  209. fillActive = this.state.currentData;
  210. }
  211. return <ul className={styles.searchLis} ref={this.$ul}>
  212. {
  213. fillActive && fillActive.details && fillActive.details.map((item, idx) => {
  214. if (item.controlType == 1) {
  215. return (
  216. <li className={`${styles.itemPart} ${fillActive.details.length > 1 ? '' : styles.itemPartOne}`}>
  217. <span className={styles.itemPartL}>{item.name}</span>
  218. <span className={styles.itemPartT}>
  219. <select className={styles.itemPartR} onChange={(e) => {
  220. if (e.target.value == '请选择') {
  221. this.changeActivePart(idx, '')
  222. return;
  223. }
  224. this.changeActivePart(idx, e.target.value);
  225. }}
  226. >
  227. <option value="请选择">请选择</option>
  228. {
  229. (item.questionDetailList).map((val) => {
  230. return <option value={val.name}
  231. selected={val.name == item.value ? true : false}
  232. >{val.name}</option>
  233. })
  234. }
  235. </select>
  236. </span>
  237. </li>
  238. )
  239. } else if (item.controlType == 6) {
  240. return (
  241. <li className={`${styles.itemPart} ${fillActive.details.length > 1 ? '' : styles.itemPartOne}`}>
  242. <span className={styles.itemPartL} title={item.name}>{item.name}</span>
  243. <span className={styles.itemPartT}>
  244. <input type="text"
  245. placeholder="(填写)"
  246. value={item.value}
  247. onKeyUp={(e) => { this.changeActivePart(idx, e.target.value.trim()) }}
  248. />
  249. <p className={styles.unit} title={item.labelSuffix}>{item.labelSuffix}</p>
  250. </span>
  251. </li>
  252. )
  253. }
  254. })
  255. }
  256. </ul>
  257. }
  258. getSearchList(list) {//搜索列表
  259. const { handleSign } = this.props;
  260. const contStyle={
  261. opacity:'0.4',
  262. right:'0',
  263. top:'1px',
  264. zIndex:'15',
  265. width:'14px',
  266. background:'#f1f1f1'};
  267. const barStyle={background:'#777',width:'100%'};
  268. return <ScrollArea speed={0.8}
  269. horizontal={false}
  270. stopScrollPropagation={list.length>6?true:false}
  271. style={{'max-height':'225px'}}
  272. className={styles["area"]}
  273. verticalContainerStyle={contStyle}
  274. verticalScrollbarStyle={barStyle}
  275. contentClassName="content">
  276. <ul className={`${styles.searchLiUl} ${styles.searchIsp}`}>
  277. {
  278. list && list.map((item, idx) => {
  279. return <li key={idx}
  280. className={styles.searchLi}
  281. title={item.uniqueName}
  282. onClick={() => {
  283. this.props.setHighter(48)
  284. handleSign(item, idx, 'search');
  285. this.setState({ show: false })
  286. }}
  287. >
  288. {item.uniqueName}
  289. </li>
  290. })
  291. }
  292. </ul></ScrollArea>;
  293. }
  294. getCommonList() {//常用列表
  295. const { handleSign, inspectList } = this.props;
  296. return <ul className={styles.searchLiUl}>
  297. {
  298. inspectList && inspectList.map((item, idx) => {
  299. return <li key={idx}
  300. className={styles.searchLi}
  301. title={item.name}
  302. onClick={() => {
  303. this.props.setHighter(48)
  304. handleSign(item.questionId, idx, 'common');
  305. this.setState({ show: false })
  306. }}
  307. >
  308. {item.name}
  309. </li>
  310. })
  311. }
  312. </ul>
  313. }
  314. showDetails(val) {
  315. let min = val.minValue, max = val.maxValue, value = val.value, dom = '';
  316. dom = getDomUpDown(min,max,value)
  317. if (val.questionDetailList.length > 0) {
  318. return val.questionDetailList.map((item) => {
  319. if (val.value == item.name) {
  320. return <td style={{ width: '20%' }} className={item.abnormal != '0' ? "red" : ''}>{val.value}</td>
  321. }
  322. })
  323. } else {
  324. // return <td style={{ width: '20%' }}><span className={(val.value - 0).toString() == 'NaN' ? "red" : (val.maxValue || val.minValue) ? (val.value > val.maxValue || val.value < val.minValue ? "red" : '') : ''}>{val.value}</span> {val.labelSuffix}</td>
  325. return <td style={{ width: '20%' }}>{dom} {val.labelSuffix}</td>
  326. }
  327. }
  328. render() {
  329. const {setHighter,refreshScroller, getInfomation,setTipValue, handleChangeValue,inspectList, inspectVal, list, labelListBig, windowHeight, windowWidth,detailClick, handleLabelSub, handleClear, handleConfirm, fillActive, getExcelDataList, handleCloseExcel, handlePush } = this.props;
  330. const { tmpId, tmpIdx, id, pageTop, impId } = this.state;
  331. const contStyle={
  332. opacity:'0.4',
  333. right:'0',
  334. top:'1px',
  335. zIndex:'15',
  336. width:'14px',
  337. background:'#f1f1f1'};
  338. const barStyle={background:'#777',width:'100%'};
  339. return (
  340. <div className={styles.wrapper}>
  341. <div className={styles.check}>
  342. {
  343. getExcelDataList.length > 0 && getExcelDataList.map((items, ind) => {
  344. return <div style={{ marginTop: '10px' }}>
  345. {
  346. items && items.lisExcelRes.length > 0 ? <ul className={styles.excelDataLists}>
  347. {/*<img className={styles.close} src={close} alt="关闭导入excel数据" onClick={() => { this.handleDelClick(2, id) }} />*/}
  348. <span className={styles.close} id="impClose" onClick={() => { this.handleDelClick(2, ind) }}></span>
  349. <DelToast show={impId == ind ? true : false}
  350. top={'22px'}
  351. right={'-34px'}
  352. name="该导入项"
  353. cancel={this.handleCancel}
  354. confirm={this.delConfirm} />
  355. {
  356. items.lisExcelRes.map((item, idx) => {
  357. return <SlideExcel
  358. items={items}
  359. item={item}
  360. idx={idx}
  361. dateTime={this.state.dateTime}
  362. getInfomation={getInfomation}
  363. ></SlideExcel>
  364. })
  365. }
  366. </ul> : null
  367. }
  368. </div>
  369. })
  370. }
  371. <ul className={styles.labelWrap} >
  372. {console.log(labelListBig)}
  373. {
  374. labelListBig && labelListBig.map((item, idx) => {
  375. return <SlidePic
  376. item={item}
  377. idx={idx}
  378. ></SlidePic>
  379. })
  380. }
  381. </ul>
  382. </div>
  383. <div style={{ position: "relative", clear: "both", top: "5px" }}>
  384. <Add showText="添加化验项" handleClick={(e) => this.handleSearchShow(e)} id="searchWrap" />
  385. {this.state.show ? <SearchOption searchType="1" detailClick={detailClick} windowHeight={windowHeight} height={280} refreshScroller={refreshScroller} pageTop={pageTop} handleChangeValue={handleChangeValue} visible={true}>
  386. {list && list.length > 0 ? this.getSearchList(list) : (inspectVal == '' ? '' : <p style={{ padding: '5px 30px', color: '#bfbfbf' }}>暂无筛选项</p>)}
  387. {/* {
  388. (list && list.length > 0) || (inspectVal != '') || (inspectList&&inspectList.length==0) ? '' : <div>
  389. <p style={{ padding: '5px 30px', color: '#bfbfbf' }}>常用化验项</p>
  390. <ScrollArea speed={0.8}
  391. horizontal={false}
  392. stopScrollPropagation={true}
  393. style={{height:'225px'}}
  394. className={styles["area"]}
  395. verticalContainerStyle={contStyle}
  396. verticalScrollbarStyle={barStyle}
  397. contentClassName="content">
  398. {
  399. this.getCommonList()
  400. }
  401. </ScrollArea>
  402. </div>
  403. } */}
  404. </SearchOption> : ''}
  405. </div>
  406. </div>
  407. )
  408. }
  409. }
  410. export default Inspect;