index.tsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import Header from '@/components/Header'
  2. import React, { useState, useEffect } from 'react'
  3. import styles from './index.module.scss'
  4. import SvgIcon from '@/components/SvgIcon'
  5. import './index.scss'
  6. import { Link } from 'react-router-dom'
  7. import { ZhButton } from '@/components/Button'
  8. import { dayjsFormat } from '@/utils/util'
  9. import { userStore } from '@/store/mobx'
  10. import { Tooltip } from 'antd'
  11. import { observer } from 'mobx-react'
  12. import { apiGetDashboard } from './api'
  13. import consts from '@/utils/consts'
  14. import { DashboardState } from '@/types/dashboard'
  15. const Index = () => {
  16. const messageType = {
  17. 1: {
  18. title: '安全巡检',
  19. class: 'badge-success',
  20. path: '/console/safe/content/detail/info'
  21. },
  22. 2: {
  23. title: '质量巡检',
  24. class: 'badge-info',
  25. path: '/console/quality/content/detail/info'
  26. }
  27. }
  28. useEffect(() => {
  29. initData()
  30. }, [])
  31. useEffect(() => {
  32. if (!userStore.projectInfo.id) {
  33. userStore.getProjectInfo()
  34. }
  35. }, [ userStore.projectInfo.id ])
  36. const [ state, setState ] = useState<DashboardState>({ approverData: [], messageData: [], versionData: { id: '', name: '', createTime: '', content: '' } })
  37. const initData = async () => {
  38. const { code = -1, data } = await apiGetDashboard()
  39. if (code === consts.RET_CODE.SUCCESS) {
  40. setState(data)
  41. }
  42. }
  43. return (
  44. <div className="wrap-contaniner hide-menu dashborad-content">
  45. <Header title="待办事项" />
  46. <div className={styles.content}>
  47. <span>系统消息</span>
  48. <h5 className={styles.title}>{userStore.projectName}</h5>
  49. {/* <div className={styles.downtime}>
  50. <SvgIcon type="xxh-wrench" style={{ fontSize: '1.5rem' }}></SvgIcon>
  51. <p className={styles.downtimeText}>系统将于 2019年3月10日 14:09 开始停机维护,持续30分钟。造成不便敬请谅解。</p>
  52. </div> */}
  53. <div className="pi-justify-between">
  54. <div className={[ styles.card, styles.cardFixedHeight, 'pi-flex-quintuple' ].join(' ')}>
  55. <div className={styles.cardHeader}>
  56. <span>需要你处理</span>
  57. </div>
  58. <div className={styles.cardBody}>
  59. {
  60. state.approverData.length ? (
  61. <ul>
  62. {
  63. state.approverData.map(item => {
  64. return (
  65. <li className="pi-flex-column" key={item.id}>
  66. <div className="pi-justify-between">
  67. <div>
  68. <span className={[ 'pi-pd-lr-15', 'pi-height-18', messageType[item.dataType]?.class ].join(' ')}>{messageType[item.dataType]?.title}</span>
  69. <span className="pi-pd-lr-15">
  70. <span>{item.bidsectionName}</span>
  71. <Link to={{ pathname: messageType[item.dataType]?.path, state: { id: item.dataId, name: item.bidsectionName } }}>{item.inspection}</Link>
  72. </span>
  73. </div>
  74. <ZhButton size="small"><Link to={{ pathname: messageType[item.dataType]?.path, state: { id: item.dataId, name: item.bidsectionName } }}>审批</Link></ZhButton>
  75. </div>
  76. <div className="pi-justify-between mt-1 ">
  77. <span>{item.name}-{item.position}</span>
  78. <span>{dayjsFormat(item.updateTime, 'MM-DD HH:mm')}</span>
  79. </div>
  80. </li>
  81. )
  82. })
  83. }
  84. </ul>
  85. ) : <p className="pi-text-center pi-muted">暂时没有需要你处理的事项</p>
  86. }
  87. </div>
  88. </div>
  89. <div className={[ styles.card, styles.cardFixedHeight, 'pi-flex-quintuple', 'pi-mg-lr-30' ].join(' ')}>
  90. <div className={styles.cardHeader}>
  91. <span>需要你关注</span>
  92. </div>
  93. <div className={styles.cardBody}>
  94. {state.messageData.length ? (
  95. <ul>
  96. {
  97. state.messageData.map(item => (
  98. <li className="pi-flex-column" key={item.id}>
  99. <div className="pi-justify-start">
  100. <span className={[ 'pi-pd-lr-15', 'pi-height-18', messageType[item.dataType]?.class ].join(' ')}>{messageType[item.dataType]?.title}</span>
  101. <span className="pi-pd-lr-15">
  102. <span>{item.bidsectionName}</span>
  103. {
  104. item.content.split('|').map((content, idx) => {
  105. if (idx === 0) {
  106. return <span key={idx}>{content} </span>
  107. } else if (idx === 1) {
  108. return <Link key={idx} to={{ pathname: messageType[item.dataType]?.path, state: { id: item.dataId, name: item.bidsectionName } }} className="pi-mg-lr-5">
  109. {content}
  110. </Link>
  111. } else {
  112. return <span key={idx}>{content}</span>
  113. }
  114. })
  115. }
  116. </span>
  117. </div>
  118. <div className="pi-justify-between mt-1">
  119. <span>{item.title}</span>
  120. <span>{dayjsFormat(item.createTime, 'MM-DD HH:mm')}</span>
  121. </div>
  122. </li>
  123. ))
  124. }
  125. </ul>
  126. ) : <p className="pi-text-center pi-muted">暂时没有需要你处理的事项</p>}
  127. </div>
  128. </div>
  129. <div className="pi-flex-twice pi-flex-column">
  130. <div className={styles.card} style={{ height: 'auto' }}>
  131. <div className={styles.cardBody} >
  132. <div className={styles.cardTitle}>
  133. <h5>纵横技术支持</h5>
  134. <h6 className="pi-muted">{userStore.projectInfo.staffName}</h6>
  135. </div>
  136. </div>
  137. <ul className="list-group">
  138. <Tooltip title="腾讯QQ" placement="left">
  139. <li className="list-group-item">
  140. <SvgIcon type="xxh-qq1" style={{ fontSize: 14 }} />
  141. <span className="pi-mg-left-5">{userStore.projectInfo.staffQq}</span>
  142. </li>
  143. </Tooltip>
  144. <Tooltip title="手机号码" placement="left">
  145. <li className="list-group-item">
  146. <SvgIcon type="xxh-mobile-alt" style={{ fontSize: 14 }} />
  147. <span className="pi-mg-left-5">{userStore.projectInfo.staffPhone}</span>
  148. </li>
  149. </Tooltip>
  150. <Tooltip title="固定电话" placement="left">
  151. <li className="list-group-item">
  152. <SvgIcon type="xxh-phone-volume1" style={{ fontSize: 14 }} />
  153. <span className="pi-mg-left-5">{userStore.projectInfo.staffTelephone}</span>
  154. </li>
  155. </Tooltip>
  156. </ul>
  157. </div>
  158. <div className={[ styles.card, 'mt-2' ].join(' ')}>
  159. <div className={styles.cardBody}>
  160. <span className="pi-link-blue">当前版本: {state.versionData?.name}</span>
  161. </div>
  162. </div>
  163. <div />
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. )
  169. }
  170. export default observer(Index)