AdvancedProfile.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. import React, { Component } from 'react';
  2. import addEventListener from 'rc-util/lib/Dom/addEventListener';
  3. import debounce from 'lodash.debounce';
  4. import { connect } from 'dva';
  5. import { Button, Menu, Dropdown, Icon, Row, Col, Steps, Card, Popover, Badge, Table, Tooltip, Divider } from 'antd';
  6. import classNames from 'classnames';
  7. import PageHeaderLayout from '../../layouts/PageHeaderLayout';
  8. import DescriptionList from '../../components/DescriptionList';
  9. import styles from './AdvancedProfile.less';
  10. const { Step } = Steps;
  11. const { Description } = DescriptionList;
  12. const ButtonGroup = Button.Group;
  13. const getWindowWidth = () => (window.innerWidth || document.documentElement.clientWidth);
  14. const menu = (
  15. <Menu>
  16. <Menu.Item key="1">选项一</Menu.Item>
  17. <Menu.Item key="2">选项二</Menu.Item>
  18. <Menu.Item key="3">选项三</Menu.Item>
  19. </Menu>
  20. );
  21. const action = (
  22. <div>
  23. <ButtonGroup>
  24. <Button>操作</Button>
  25. <Button>操作</Button>
  26. <Dropdown overlay={menu} placement="bottomRight">
  27. <Button><Icon type="ellipsis" /></Button>
  28. </Dropdown>
  29. </ButtonGroup>
  30. <Button type="primary">主操作</Button>
  31. </div>
  32. );
  33. const extra = (
  34. <Row>
  35. <Col xs={24} sm={12}>
  36. <div className={styles.textSecondary}>状态</div>
  37. <div className={styles.heading}>待审批</div>
  38. </Col>
  39. <Col xs={24} sm={12}>
  40. <div className={styles.textSecondary}>订单金额</div>
  41. <div className={styles.heading}>¥ 568.08</div>
  42. </Col>
  43. </Row>
  44. );
  45. const description = (
  46. <DescriptionList className={styles.headerList} size="small" col="2">
  47. <Description term="创建人">曲丽丽</Description>
  48. <Description term="订购产品">XX 服务</Description>
  49. <Description term="创建时间">2017-07-07</Description>
  50. <Description term="关联单据"><a href="">12421</a></Description>
  51. <Description term="生效日期">2017-07-07 ~ 2017-08-08</Description>
  52. <Description term="备注">请于两个工作日内确认</Description>
  53. </DescriptionList>
  54. );
  55. const tabList = [{
  56. key: 'detail',
  57. tab: '详情',
  58. }, {
  59. key: 'rule',
  60. tab: '规则',
  61. }];
  62. const desc1 = (
  63. <div className={classNames(styles.textSecondary, styles.stepDescription)}>
  64. <div>
  65. 曲丽丽
  66. <Icon type="dingding-o" style={{ marginLeft: 8 }} />
  67. </div>
  68. <div>2016-12-12 12:32</div>
  69. </div>
  70. );
  71. const desc2 = (
  72. <div className={styles.stepDescription}>
  73. <div>
  74. 周毛毛
  75. <Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} />
  76. </div>
  77. <div><a href="">催一下</a></div>
  78. </div>
  79. );
  80. const popoverContent = (
  81. <div style={{ width: 160 }}>
  82. 吴加号
  83. <span className={styles.textSecondary} style={{ float: 'right' }}>
  84. <Badge status="default" text={<span style={{ color: 'rgba(0, 0, 0, 0.45)' }}>未响应</span>} />
  85. </span>
  86. <p className={styles.textSecondary} style={{ marginTop: 4 }} >耗时:2小时25分钟</p>
  87. </div>
  88. );
  89. const customDot = (dot, { status }) => (status === 'process' ?
  90. <Popover placement="topLeft" arrowPointAtCenter content={popoverContent}>
  91. {dot}
  92. </Popover>
  93. : dot
  94. );
  95. const operationTabList = [{
  96. key: 'tab1',
  97. tab: '操作日志一',
  98. }, {
  99. key: 'tab2',
  100. tab: '操作日志二',
  101. }, {
  102. key: 'tab3',
  103. tab: '操作日志三',
  104. }];
  105. const columns = [{
  106. title: '操作类型',
  107. dataIndex: 'type',
  108. key: 'type',
  109. }, {
  110. title: '操作人',
  111. dataIndex: 'name',
  112. key: 'name',
  113. }, {
  114. title: '执行结果',
  115. dataIndex: 'status',
  116. key: 'status',
  117. render: text => (
  118. text === 'agree' ? <Badge status="success" text="成功" /> : <Badge status="error" text="驳回" />
  119. ),
  120. }, {
  121. title: '操作时间',
  122. dataIndex: 'updatedAt',
  123. key: 'updatedAt',
  124. }, {
  125. title: '备注',
  126. dataIndex: 'memo',
  127. key: 'memo',
  128. }];
  129. @connect(state => ({
  130. profile: state.profile,
  131. }))
  132. export default class AdvancedProfile extends Component {
  133. state = {
  134. operationkey: 'tab1',
  135. stepDirection: 'horizontal',
  136. }
  137. componentDidMount() {
  138. const { dispatch } = this.props;
  139. dispatch({
  140. type: 'profile/fetchAdvanced',
  141. });
  142. this.setStepDirection();
  143. this.resizeEvent = addEventListener(window, 'resize', debounce(this.setStepDirection, 100, {
  144. leading: false,
  145. }));
  146. }
  147. componentWillUnmount() {
  148. if (this.resizeEvent) {
  149. this.resizeEvent.remove();
  150. }
  151. }
  152. onOperationTabChange = (key) => {
  153. this.setState({ operationkey: key });
  154. }
  155. setStepDirection = () => {
  156. const { stepDirection } = this.state;
  157. const w = getWindowWidth();
  158. if (stepDirection !== 'vertical' && w <= 576) {
  159. this.setState({
  160. stepDirection: 'vertical',
  161. });
  162. } else if (stepDirection !== 'horizontal' && w > 576) {
  163. this.setState({
  164. stepDirection: 'horizontal',
  165. });
  166. }
  167. }
  168. render() {
  169. const { stepDirection } = this.state;
  170. const { profile } = this.props;
  171. const { advancedLoading, advancedOperation1, advancedOperation2, advancedOperation3 } = profile;
  172. const contentList = {
  173. tab1: <Table
  174. pagination={false}
  175. loading={advancedLoading}
  176. dataSource={advancedOperation1}
  177. columns={columns}
  178. />,
  179. tab2: <Table
  180. pagination={false}
  181. loading={advancedLoading}
  182. dataSource={advancedOperation2}
  183. columns={columns}
  184. />,
  185. tab3: <Table
  186. pagination={false}
  187. loading={advancedLoading}
  188. dataSource={advancedOperation3}
  189. columns={columns}
  190. />,
  191. };
  192. return (
  193. <PageHeaderLayout
  194. title="单号:234231029431"
  195. logo={<img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/JcBAEvlHGhVvBekIJCWT.svg" />}
  196. action={action}
  197. content={description}
  198. extraContent={extra}
  199. tabList={tabList}
  200. >
  201. <Card title="流程进度" style={{ marginBottom: 24 }} bordered={false}>
  202. <Steps direction={stepDirection} progressDot={customDot} current={1}>
  203. <Step title="创建项目" description={desc1} />
  204. <Step title="部门初审" description={desc2} />
  205. <Step title="财务复核" />
  206. <Step title="完成" />
  207. </Steps>
  208. </Card>
  209. <Card title="用户信息" style={{ marginBottom: 24 }} bordered={false}>
  210. <DescriptionList style={{ marginBottom: 24 }}>
  211. <Description term="用户姓名">付小小</Description>
  212. <Description term="会员卡号">32943898021309809423</Description>
  213. <Description term="身份证">3321944288191034921</Description>
  214. <Description term="联系方式">18112345678</Description>
  215. <Description term="联系地址">曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口</Description>
  216. </DescriptionList>
  217. <DescriptionList style={{ marginBottom: 24 }} title="信息组">
  218. <Description term="某某数据">725</Description>
  219. <Description term="该数据更新时间">2017-08-08</Description>
  220. <Description>&nbsp;</Description>
  221. <Description term={
  222. <span>
  223. 某某数据
  224. <Tooltip title="数据说明">
  225. <Icon style={{ color: 'rgba(0, 0, 0, 0.43)', marginLeft: 4 }} type="info-circle-o" />
  226. </Tooltip>
  227. </span>
  228. }
  229. >
  230. 725
  231. </Description>
  232. <Description term="该数据更新时间">2017-08-08</Description>
  233. </DescriptionList>
  234. <h4 style={{ marginBottom: 16 }}>信息组</h4>
  235. <Card type="inner" title="多层级信息组">
  236. <DescriptionList size="small" style={{ marginBottom: 16 }} title="组名称">
  237. <Description term="负责人">林东东</Description>
  238. <Description term="角色码">1234567</Description>
  239. <Description term="所属部门">XX公司 - YY部</Description>
  240. <Description term="过期时间">2017-08-08</Description>
  241. <Description term="描述">这段描述很长很长很长很长很长很长很长很长很长很长很长很长很长很长...</Description>
  242. </DescriptionList>
  243. <Divider style={{ margin: '16px 0' }} />
  244. <DescriptionList size="small" style={{ marginBottom: 16 }} title="组名称" col="1">
  245. <Description term="学名">
  246. Citrullus lanatus (Thunb.) Matsum. et Nakai一年生蔓生藤本;茎、枝粗壮,具明显的棱。卷须较粗..
  247. </Description>
  248. </DescriptionList>
  249. <Divider style={{ margin: '16px 0' }} />
  250. <DescriptionList size="small" title="组名称">
  251. <Description term="负责人">付小小</Description>
  252. <Description term="角色码">1234568</Description>
  253. </DescriptionList>
  254. </Card>
  255. </Card>
  256. <Card title="用户近半年来电记录" style={{ marginBottom: 24 }} bordered={false}>
  257. <div className={styles.noData}>
  258. <Icon type="frown-o" />暂无数据
  259. </div>
  260. </Card>
  261. <Card
  262. className={styles.tabsCard}
  263. bordered={false}
  264. tabList={operationTabList}
  265. onTabChange={this.onOperationTabChange}
  266. >
  267. {contentList[this.state.operationkey]}
  268. </Card>
  269. </PageHeaderLayout>
  270. );
  271. }
  272. }