index.jsx 14 KB

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