index.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import { Tab, ConfirmModal, Notify } from '@commonComp';
  4. import { tabChange, allChecked, changeVisible, keepPushData, allCheckedShow,allCheckedAdmin,allCheckedShowAdmin } from '@store/actions/tabTemplate';
  5. import { initItemList, delItem,delItemAdmin, delBatchItem, delBatchItemAdmin,changeTitleAsync, setPageView,changeTitleAsyncAdmin,setPageViewAdmin } from '@store/async-actions/tabTemplate';
  6. import { connect } from "react-redux";
  7. import store from '@store';
  8. import { billing } from '@store/async-actions/pushMessage';
  9. import TemplateContainer from '@components/TemplateContainer';
  10. import TemplateItems from '@components/TemplateItems';
  11. import PushItemsContainer from '@containers/PushItemsContainer';
  12. import { pushAllDataList, getWindowInnerHeight, didPushParamChange } from '@utils/tools';
  13. import CopyRightContainer from "@containers/CopyRightContainer";
  14. import MedicalInfoContainer from '@containers/MedicalInfoContainer';
  15. import CaseQuailty from "../CaseQuailty";
  16. class PushContainer extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.state = {
  20. data: null,
  21. tabs: [{
  22. title: '辅助信息',
  23. disabled: true
  24. },
  25. {
  26. title: '病历质控',
  27. }, {
  28. title: '模板',
  29. },
  30. {
  31. title: '医学知识',
  32. }
  33. ],
  34. visible: false,
  35. message: '', //提示的内容
  36. type: '', //1:删除模板 2:批量删除 3.修改标题 4.引用
  37. id: '', //单个删除
  38. obj: {}, //修改模板标题
  39. title: '', //修改后的标题
  40. okText: '确定', //确认按钮
  41. okBorderColor: 'red',
  42. oKBg: '',
  43. okColor: 'red',
  44. num: 0, //计数
  45. deptId:'', //科室id
  46. }
  47. this.$cont = React.createRef();
  48. this.itemList = null;
  49. this.handleActiveClick = this.handleActiveClick.bind(this)
  50. this.handleContentClick = this.handleContentClick.bind(this)
  51. this.handleTemplateDel = this.handleTemplateDel.bind(this)
  52. this.handleTitleChange = this.handleTitleChange.bind(this)
  53. this.handleAllCheckbox = this.handleAllCheckbox.bind(this)
  54. this.handleAllCheckboxAdmin = this.handleAllCheckboxAdmin.bind(this)
  55. this.handleMangerTemplate = this.handleMangerTemplate.bind(this)
  56. this.handleMangerTemplateAdmin = this.handleMangerTemplateAdmin.bind(this)
  57. this.handleDelList = this.handleDelList.bind(this)
  58. this.makeSure = this.makeSure.bind(this)
  59. this.handleClose = this.handleClose.bind(this);
  60. this.templateSearch = this.templateSearch.bind(this);
  61. }
  62. componentDidMount() {
  63. // const height = getWindowInnerHeight()-160;
  64. // this.$cont.current.style.height = height+"px";
  65. }
  66. templateSearch(name){
  67. store.dispatch(initItemList(1,name));
  68. }
  69. /**
  70. *
  71. * @param {tab组件切换id} id
  72. */
  73. handleActiveClick(id) {
  74. if (id == '2') {
  75. store.dispatch(initItemList(1,0));
  76. }
  77. store.dispatch(tabChange(id))
  78. }
  79. /**
  80. * 引用模板id
  81. * @param {模板id} id
  82. */
  83. handleContentClick(id, sex) {
  84. let baseSex = store.getState().patInfo.message.sex
  85. this.setState({
  86. message: this.content(sex, baseSex),
  87. type: 4,
  88. id: id,
  89. okText: '引用',
  90. okBorderColor: '#3B9ED0',
  91. okColor: '#fff',
  92. oKBg: '#3B9ED0'
  93. }, () => {
  94. store.dispatch(changeVisible(true))
  95. })
  96. }
  97. content(sex, baseSex) {
  98. if (sex != 3 && sex != baseSex) {
  99. return <p className={style['center']}>确认引用该模板?<p style={{ fontSize: '12px', color: '#6b6969', marginTop: '10px' }}>引用该模版可能显示有误</p></p>
  100. } else {
  101. return <p className={style['center']}>确认引用该模板?</p>
  102. }
  103. }
  104. /**
  105. * 删除模板
  106. * @param {模板id} id
  107. */
  108. handleTemplateDel(id) {
  109. this.setState({
  110. message: this.delDiv(),
  111. type: 1,
  112. id: id,
  113. okText: '删除',
  114. okBorderColor: 'red',
  115. okColor: 'red',
  116. oKBg: '#fff'
  117. }, () => {
  118. store.dispatch(changeVisible(true))
  119. })
  120. }
  121. delDiv() {
  122. return <p className={style['center']}>确认删除模板?</p>
  123. }
  124. onchange(value,deptId) {
  125. this.setState({
  126. title: value
  127. }, () => {
  128. this.setState({
  129. message: this.changeTitle(),
  130. })
  131. })
  132. }
  133. keypress(event) {
  134. let e = event ? event : window.event;
  135. if (e.keyCode == 13) {
  136. this.makeSure()
  137. }
  138. }
  139. handleInput(e) {
  140. let val = (e.target.value).substring(0, 30)
  141. this.onchange(val)
  142. }
  143. changeTitle() {
  144. return <div className={style['box']}>
  145. <input className={style['ipt']}
  146. placeholder="请输入模板名称"
  147. type="text"
  148. value={this.state.title}
  149. maxLength='30'
  150. onInput={(e) => {
  151. this.handleInput(e)
  152. }}
  153. onPropertyChange={(e) => { // 兼容ie
  154. this.handleInput(e)
  155. }}
  156. onKeyPress={e => this.keypress(e)}
  157. />
  158. <div className={style['line']}></div>
  159. </div>
  160. }
  161. /**
  162. * 改变模板标题
  163. * @param {模板id和模板title} obj
  164. */
  165. handleTitleChange(id, text,deptId) {
  166. store.dispatch(changeVisible(true))
  167. this.setState({
  168. type: 3,
  169. currId: id,
  170. title: text,
  171. text: text,
  172. deptId: deptId,
  173. okText: '保存',
  174. okBorderColor: '#3B9ED0',
  175. okColor: '#fff',
  176. oKBg: '#3B9ED0'
  177. }, () => {
  178. this.setState({
  179. message: this.changeTitle(),
  180. })
  181. })
  182. }
  183. handleAllCheckboxAdmin() { //全.反选
  184. let tmpFlg = this.props.allCheckedAdmin;
  185. if (this.props.checkItemsAdmin.length < this.props.adminItems.length && this.props.allCheckedAdmin) {
  186. tmpFlg = false;
  187. } else if (this.props.checkItemsAdmin.length == this.props.adminItems.length && !this.props.allCheckedAdmin) {
  188. tmpFlg = true;
  189. } //两种特殊情况处理
  190. store.dispatch(allCheckedAdmin(!tmpFlg))
  191. }
  192. handleMangerTemplateAdmin() { //管理
  193. let tmpFlg = this.props.allCheckShowAdmin;
  194. store.dispatch(allCheckedAdmin(false))
  195. store.dispatch(allCheckedShowAdmin(!tmpFlg))
  196. }
  197. handleAllCheckbox() { //全.反选
  198. let tmpFlg = this.props.allChecked;
  199. if (this.props.checkItems.length < this.props.items.length && this.props.allChecked) {
  200. tmpFlg = false;
  201. } else if (this.props.checkItems.length == this.props.items.length && !this.props.allChecked) {
  202. tmpFlg = true;
  203. } //两种特殊情况处理
  204. store.dispatch(allChecked(!tmpFlg))
  205. }
  206. handleMangerTemplate() { //管理
  207. let tmpFlg = this.props.allCheckShow;
  208. store.dispatch(allChecked(false))
  209. store.dispatch(allCheckedShow(!tmpFlg))
  210. }
  211. handleDelList() { //批量删除
  212. this.setState({
  213. type: 2,
  214. message: this.delDiv(),
  215. okText: '删除',
  216. okBorderColor: 'red',
  217. okColor: 'red',
  218. oKBg: '#fff'
  219. })
  220. store.dispatch(changeVisible(true))
  221. }
  222. handleClickGetMore(page){
  223. let tmpPage = ++page
  224. store.dispatch(initItemList(tmpPage,true))
  225. }
  226. makeSure() {
  227. if (this.state.type == 1) {
  228. if(this.props.admin){
  229. store.dispatch(delItemAdmin(this.state.id))
  230. }else{
  231. store.dispatch(delItem(this.state.id))
  232. }
  233. store.dispatch(changeVisible(false))
  234. } else if (this.state.type == 2) {
  235. if(this.props.admin){
  236. store.dispatch(delBatchItemAdmin(this.props.checkItemsAdmin))
  237. }else{
  238. store.dispatch(delBatchItem(this.props.checkItems))
  239. }
  240. store.dispatch(changeVisible(false))
  241. } else if (this.state.type == 3) {
  242. if (this.state.title == this.state.text) {
  243. store.dispatch(changeVisible(false))
  244. Notify.success('标题修改成功');
  245. return;
  246. }
  247. if ((this.state.title).trim() == '') {
  248. Notify.info('请输入模板名称');
  249. return;
  250. }
  251. let tempObj = {
  252. id: this.state.currId,
  253. title: this.state.title,
  254. deptId:this.state.deptId
  255. }
  256. if(this.props.admin){
  257. store.dispatch(changeTitleAsyncAdmin(tempObj))
  258. }else{
  259. store.dispatch(changeTitleAsync(tempObj))
  260. }
  261. } else if (this.state.type == 4) { //模板引入
  262. if(this.props.admin){
  263. store.dispatch(setPageViewAdmin(this.state.id))
  264. }else{
  265. store.dispatch(setPageView(this.state.id))
  266. }
  267. store.dispatch(changeVisible(false))
  268. }
  269. }
  270. handleClose() {
  271. store.dispatch(changeVisible(false));
  272. }
  273. render() {
  274. const { activeId, checkItems, visible, showMsg,hasMore,current, items, allCheckShow,allCheckShowAdmin,adminItems,admin,checkItemsAdmin,clearSearch } = this.props;
  275. return <div className={style["container"]} ref={this.$cont} >
  276. <Tab tabs={this.state.tabs}
  277. activeId={activeId}
  278. handleActiveClick={this.handleActiveClick}
  279. >
  280. <TemplateContainer activeId={activeId}>
  281. <PushItemsContainer></PushItemsContainer>
  282. <CaseQuailty></CaseQuailty>
  283. <TemplateItems
  284. items={items}
  285. clearSearch={clearSearch}
  286. adminItems={adminItems}
  287. admin={admin}
  288. handleAllCheckboxAdmin={this.handleAllCheckboxAdmin}
  289. handleMangerTemplateAdmin={this.handleMangerTemplateAdmin}
  290. current={current}
  291. hasMore={hasMore}
  292. checkItems={checkItems}
  293. checkItemsAdmin={checkItemsAdmin}
  294. allCheckShow={allCheckShow}
  295. allCheckShowAdmin={allCheckShowAdmin}
  296. handleContentClick={this.handleContentClick}
  297. handleTemplateDel={this.handleTemplateDel}
  298. handleTitleChange={this.handleTitleChange}
  299. handleDelList={this.handleDelList}
  300. handleMangerTemplate={this.handleMangerTemplate}
  301. handleAllCheckbox={this.handleAllCheckbox}
  302. handleClickGetMore={this.handleClickGetMore}
  303. templateSearch={this.templateSearch}
  304. ></TemplateItems>
  305. <MedicalInfoContainer></MedicalInfoContainer>
  306. </TemplateContainer>
  307. </Tab>
  308. <ConfirmModal
  309. visible={visible}
  310. confirm={this.makeSure}
  311. close={this.handleClose}
  312. cancel={this.handleClose}
  313. okText={this.state.okText}
  314. okBorderColor={this.state.okBorderColor}
  315. okColor={this.state.okColor}
  316. oKBg={this.state.oKBg}
  317. >
  318. {this.state.message}
  319. </ConfirmModal>
  320. <CopyRightContainer />
  321. </div>
  322. }
  323. }
  324. const mapStateToProps = (state) => {//console.log(state)
  325. return {
  326. items: state.tabTemplate.items,
  327. adminItems: state.tabTemplate.adminItems,
  328. admin: state.homePage.admin,
  329. current: state.tabTemplate.current,
  330. hasMore: state.tabTemplate.hasMore,
  331. activeId: state.tabTemplate.activeId,
  332. checkItems: state.tabTemplate.checkItems,
  333. allChecked: state.tabTemplate.allChecked,
  334. visible: state.tabTemplate.visible,
  335. showMsg: state.tabTemplate.showMsg,
  336. allCheckShow: state.tabTemplate.allCheckShow,
  337. allCheckedAdmin: state.tabTemplate.allCheckedAdmin,
  338. allCheckShowAdmin: state.tabTemplate.allCheckShowAdmin,
  339. checkItemsAdmin: state.tabTemplate.checkItemsAdmin,
  340. clearSearch:state.print.clearSearch,
  341. }
  342. }
  343. export default connect(mapStateToProps, null)(PushContainer);