AdvancedProfile.js 9.71 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import React, { Component, Fragment } from 'react';
2
import Debounce from 'lodash-decorators/debounce';
afc163's avatar
afc163 committed
3
import Bind from 'lodash-decorators/bind';
4
import { connect } from 'dva';
jim's avatar
jim committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import {
  Button,
  Menu,
  Dropdown,
  Icon,
  Row,
  Col,
  Steps,
  Card,
  Popover,
  Badge,
  Table,
  Tooltip,
  Divider,
} from 'antd';
20
import classNames from 'classnames';
niko's avatar
niko committed
21
import DescriptionList from 'components/DescriptionList';
ddcat1115's avatar
ddcat1115 committed
22 23
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import styles from './AdvancedProfile.less';
24 25 26

const { Step } = Steps;
const { Description } = DescriptionList;
ddcat1115's avatar
ddcat1115 committed
27
const ButtonGroup = Button.Group;
28

jim's avatar
jim committed
29
const getWindowWidth = () => window.innerWidth || document.documentElement.clientWidth;
30

31 32 33 34 35 36 37 38 39
const menu = (
  <Menu>
    <Menu.Item key="1">选项一</Menu.Item>
    <Menu.Item key="2">选项二</Menu.Item>
    <Menu.Item key="3">选项三</Menu.Item>
  </Menu>
);

const action = (
陈帅's avatar
陈帅 committed
40
  <Fragment>
ddcat1115's avatar
ddcat1115 committed
41 42 43 44
    <ButtonGroup>
      <Button>操作</Button>
      <Button>操作</Button>
      <Dropdown overlay={menu} placement="bottomRight">
jim's avatar
jim committed
45 46 47
        <Button>
          <Icon type="ellipsis" />
        </Button>
ddcat1115's avatar
ddcat1115 committed
48 49
      </Dropdown>
    </ButtonGroup>
afc163's avatar
afc163 committed
50
    <Button type="primary">主操作</Button>
陈帅's avatar
陈帅 committed
51
  </Fragment>
52 53 54 55
);

const extra = (
  <Row>
ddcat1115's avatar
ddcat1115 committed
56
    <Col xs={24} sm={12}>
57 58 59
      <div className={styles.textSecondary}>状态</div>
      <div className={styles.heading}>待审批</div>
    </Col>
ddcat1115's avatar
ddcat1115 committed
60
    <Col xs={24} sm={12}>
61 62 63 64 65 66 67
      <div className={styles.textSecondary}>订单金额</div>
      <div className={styles.heading}>¥ 568.08</div>
    </Col>
  </Row>
);

const description = (
68
  <DescriptionList className={styles.headerList} size="small" col="2">
69
    <Description term="创建人">曲丽丽</Description>
ddcat1115's avatar
ddcat1115 committed
70
    <Description term="订购产品">XX 服务</Description>
71
    <Description term="创建时间">2017-07-07</Description>
jim's avatar
jim committed
72 73 74
    <Description term="关联单据">
      <a href="">12421</a>
    </Description>
75
    <Description term="生效日期">2017-07-07 ~ 2017-08-08</Description>
ddcat1115's avatar
ddcat1115 committed
76
    <Description term="备注">请于两个工作日内确认</Description>
77 78 79
  </DescriptionList>
);

jim's avatar
jim committed
80 81 82 83 84 85 86 87 88 89
const tabList = [
  {
    key: 'detail',
    tab: '详情',
  },
  {
    key: 'rule',
    tab: '规则',
  },
];
90 91

const desc1 = (
92
  <div className={classNames(styles.textSecondary, styles.stepDescription)}>
陈帅's avatar
陈帅 committed
93
    <Fragment>
ddcat1115's avatar
ddcat1115 committed
94 95
      曲丽丽
      <Icon type="dingding-o" style={{ marginLeft: 8 }} />
陈帅's avatar
陈帅 committed
96
    </Fragment>
97 98 99 100 101
    <div>2016-12-12 12:32</div>
  </div>
);

const desc2 = (
102
  <div className={styles.stepDescription}>
陈帅's avatar
陈帅 committed
103
    <Fragment>
ddcat1115's avatar
ddcat1115 committed
104 105
      周毛毛
      <Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} />
陈帅's avatar
陈帅 committed
106
    </Fragment>
jim's avatar
jim committed
107 108 109
    <div>
      <a href="">催一下</a>
    </div>
110 111 112 113 114 115 116
  </div>
);

const popoverContent = (
  <div style={{ width: 160 }}>
    吴加号
    <span className={styles.textSecondary} style={{ float: 'right' }}>
117
      <Badge status="default" text={<span style={{ color: 'rgba(0, 0, 0, 0.45)' }}>未响应</span>} />
118
    </span>
jim's avatar
jim committed
119 120 121
    <div className={styles.textSecondary} style={{ marginTop: 4 }}>
      耗时2小时25分钟
    </div>
122 123 124
  </div>
);

jim's avatar
jim committed
125 126 127 128 129 130 131 132
const customDot = (dot, { status }) =>
  status === 'process' ? (
    <Popover placement="topLeft" arrowPointAtCenter content={popoverContent}>
      {dot}
    </Popover>
  ) : (
    dot
  );
133

jim's avatar
jim committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147
const operationTabList = [
  {
    key: 'tab1',
    tab: '操作日志一',
  },
  {
    key: 'tab2',
    tab: '操作日志二',
  },
  {
    key: 'tab3',
    tab: '操作日志三',
  },
];
148

jim's avatar
jim committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
const columns = [
  {
    title: '操作类型',
    dataIndex: 'type',
    key: 'type',
  },
  {
    title: '操作人',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '执行结果',
    dataIndex: 'status',
    key: 'status',
    render: text =>
      text === 'agree' ? (
        <Badge status="success" text="成功" />
      ) : (
        <Badge status="error" text="驳回" />
      ),
  },
  {
    title: '操作时间',
    dataIndex: 'updatedAt',
    key: 'updatedAt',
  },
  {
    title: '备注',
    dataIndex: 'memo',
    key: 'memo',
  },
];
182

Andreas Cederström's avatar
Andreas Cederström committed
183 184 185
@connect(({ profile, loading }) => ({
  profile,
  loading: loading.effects['profile/fetchAdvanced'],
186
}))
ddcat1115's avatar
ddcat1115 committed
187
export default class AdvancedProfile extends Component {
188 189
  state = {
    operationkey: 'tab1',
190
    stepDirection: 'horizontal',
jim's avatar
jim committed
191
  };
192 193 194 195

  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
ddcat1115's avatar
ddcat1115 committed
196
      type: 'profile/fetchAdvanced',
197
    });
198 199

    this.setStepDirection();
200
    window.addEventListener('resize', this.setStepDirection);
201 202 203
  }

  componentWillUnmount() {
204
    window.removeEventListener('resize', this.setStepDirection);
afc163's avatar
afc163 committed
205
    this.setStepDirection.cancel();
206 207
  }

jim's avatar
jim committed
208
  onOperationTabChange = key => {
209
    this.setState({ operationkey: key });
jim's avatar
jim committed
210
  };
211

afc163's avatar
afc163 committed
212
  @Bind()
213
  @Debounce(200)
afc163's avatar
afc163 committed
214
  setStepDirection() {
215 216 217 218 219 220 221 222 223 224 225 226 227
    const { stepDirection } = this.state;
    const w = getWindowWidth();
    if (stepDirection !== 'vertical' && w <= 576) {
      this.setState({
        stepDirection: 'vertical',
      });
    } else if (stepDirection !== 'horizontal' && w > 576) {
      this.setState({
        stepDirection: 'horizontal',
      });
    }
  }

228
  render() {
229
    const { stepDirection, operationkey } = this.state;
Andreas Cederström's avatar
Andreas Cederström committed
230 231
    const { profile, loading } = this.props;
    const { advancedOperation1, advancedOperation2, advancedOperation3 } = profile;
232
    const contentList = {
jim's avatar
jim committed
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
      tab1: (
        <Table
          pagination={false}
          loading={loading}
          dataSource={advancedOperation1}
          columns={columns}
        />
      ),
      tab2: (
        <Table
          pagination={false}
          loading={loading}
          dataSource={advancedOperation2}
          columns={columns}
        />
      ),
      tab3: (
        <Table
          pagination={false}
          loading={loading}
          dataSource={advancedOperation3}
          columns={columns}
        />
      ),
257 258 259 260 261
    };

    return (
      <PageHeaderLayout
        title="单号:234231029431"
jim's avatar
jim committed
262 263 264
        logo={
          <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png" />
        }
265 266 267 268 269
        action={action}
        content={description}
        extraContent={extra}
        tabList={tabList}
      >
270
        <Card title="流程进度" style={{ marginBottom: 24 }} bordered={false}>
271
          <Steps direction={stepDirection} progressDot={customDot} current={1}>
272 273 274 275 276 277
            <Step title="创建项目" description={desc1} />
            <Step title="部门初审" description={desc2} />
            <Step title="财务复核" />
            <Step title="完成" />
          </Steps>
        </Card>
278
        <Card title="用户信息" style={{ marginBottom: 24 }} bordered={false}>
279 280 281 282
          <DescriptionList style={{ marginBottom: 24 }}>
            <Description term="用户姓名">付小小</Description>
            <Description term="会员卡号">32943898021309809423</Description>
            <Description term="身份证">3321944288191034921</Description>
283
            <Description term="联系方式">18112345678</Description>
jim's avatar
jim committed
284 285 286
            <Description term="联系地址">
              曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口
            </Description>
287
          </DescriptionList>
288
          <DescriptionList style={{ marginBottom: 24 }} title="信息组">
289 290
            <Description term="某某数据">725</Description>
            <Description term="该数据更新时间">2017-08-08</Description>
291
            <Description>&nbsp;</Description>
jim's avatar
jim committed
292 293 294 295 296 297 298 299 300 301 302
            <Description
              term={
                <span>
                  某某数据
                  <Tooltip title="数据说明">
                    <Icon
                      style={{ color: 'rgba(0, 0, 0, 0.43)', marginLeft: 4 }}
                      type="info-circle-o"
                    />
                  </Tooltip>
                </span>
303 304 305 306 307 308
              }
            >
              725
            </Description>
            <Description term="该数据更新时间">2017-08-08</Description>
          </DescriptionList>
309
          <h4 style={{ marginBottom: 16 }}>信息组</h4>
310
          <Card type="inner" title="多层级信息组">
311
            <DescriptionList size="small" style={{ marginBottom: 16 }} title="组名称">
312 313 314 315
              <Description term="负责人">林东东</Description>
              <Description term="角色码">1234567</Description>
              <Description term="所属部门">XX公司 - YY部</Description>
              <Description term="过期时间">2017-08-08</Description>
jim's avatar
jim committed
316 317 318
              <Description term="描述">
                这段描述很长很长很长很长很长很长很长很长很长很长很长很长很长很长...
              </Description>
319
            </DescriptionList>
320 321
            <Divider style={{ margin: '16px 0' }} />
            <DescriptionList size="small" style={{ marginBottom: 16 }} title="组名称" col="1">
322
              <Description term="学名">
jim's avatar
jim committed
323 324
                Citrullus lanatus (Thunb.) Matsum. et
                Nakai一年生蔓生藤本枝粗壮具明显的棱卷须较粗..
325 326
              </Description>
            </DescriptionList>
327 328
            <Divider style={{ margin: '16px 0' }} />
            <DescriptionList size="small" title="组名称">
329 330 331 332 333
              <Description term="负责人">付小小</Description>
              <Description term="角色码">1234568</Description>
            </DescriptionList>
          </Card>
        </Card>
334
        <Card title="用户近半年来电记录" style={{ marginBottom: 24 }} bordered={false}>
335
          <div className={styles.noData}>
陈帅's avatar
陈帅 committed
336 337
            <Icon type="frown-o" />
            暂无数据
338 339 340 341 342 343 344 345
          </div>
        </Card>
        <Card
          className={styles.tabsCard}
          bordered={false}
          tabList={operationTabList}
          onTabChange={this.onOperationTabChange}
        >
346
          {contentList[operationkey]}
347 348 349 350 351
        </Card>
      </PageHeaderLayout>
    );
  }
}