index.tsx 10.8 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import {
陈帅's avatar
陈帅 committed
2
  Badge,
陈帅's avatar
陈帅 committed
3
  Button,
陈帅's avatar
陈帅 committed
4 5 6 7
  Card,
  Col,
  Descriptions,
  Divider,
陈帅's avatar
陈帅 committed
8 9
  Dropdown,
  Icon,
陈帅's avatar
陈帅 committed
10 11
  Menu,
  Popover,
陈帅's avatar
陈帅 committed
12 13 14 15 16
  Row,
  Steps,
  Table,
  Tooltip,
} from 'antd';
陈帅's avatar
陈帅 committed
17 18 19 20
import { GridContent, PageHeaderWrapper } from '@ant-design/pro-layout';
import React, { Component, Fragment } from 'react';

import { Dispatch } from 'redux';
陈帅's avatar
陈帅 committed
21
import classNames from 'classnames';
陈帅's avatar
陈帅 committed
22
import { connect } from 'dva';
陈帅's avatar
陈帅 committed
23
import { AdvancedProfileData } from './data';
陈帅's avatar
陈帅 committed
24
import styles from './style.less';
陈帅's avatar
陈帅 committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

const { Step } = Steps;
const ButtonGroup = Button.Group;

const getWindowWidth = () => window.innerWidth || document.documentElement.clientWidth;

const menu = (
  <Menu>
    <Menu.Item key="1">选项一</Menu.Item>
    <Menu.Item key="2">选项二</Menu.Item>
    <Menu.Item key="3">选项三</Menu.Item>
  </Menu>
);

const action = (
  <Fragment>
    <ButtonGroup>
      <Button>操作</Button>
      <Button>操作</Button>
      <Dropdown overlay={menu} placement="bottomRight">
        <Button>
          <Icon type="ellipsis" />
        </Button>
      </Dropdown>
    </ButtonGroup>
    <Button type="primary">主操作</Button>
  </Fragment>
);

const extra = (
  <Row
    style={{
      minWidth: 400,
    }}
  >
    <Col xs={24} sm={12}>
      <div className={styles.textSecondary}>状态</div>
      <div className={styles.heading}>待审批</div>
    </Col>
    <Col xs={24} sm={12}>
      <div className={styles.textSecondary}>订单金额</div>
      <div className={styles.heading}>¥ 568.08</div>
    </Col>
  </Row>
);

const description = (
陈帅's avatar
陈帅 committed
72 73 74 75 76
  <Descriptions className={styles.headerList} size="small" column={2}>
    <Descriptions.Item label="创建人">曲丽丽</Descriptions.Item>
    <Descriptions.Item label="订购产品">XX 服务</Descriptions.Item>
    <Descriptions.Item label="创建时间">2017-07-07</Descriptions.Item>
    <Descriptions.Item label="关联单据">
陈帅's avatar
陈帅 committed
77
      <a href="">12421</a>
陈帅's avatar
陈帅 committed
78 79 80 81
    </Descriptions.Item>
    <Descriptions.Item label="生效日期">2017-07-07 ~ 2017-08-08</Descriptions.Item>
    <Descriptions.Item label="备注">请于两个工作日内确认</Descriptions.Item>
  </Descriptions>
陈帅's avatar
陈帅 committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
);

const desc1 = (
  <div className={classNames(styles.textSecondary, styles.stepDescription)}>
    <Fragment>
      曲丽丽
      <Icon type="dingding-o" style={{ marginLeft: 8 }} />
    </Fragment>
    <div>2016-12-12 12:32</div>
  </div>
);

const desc2 = (
  <div className={styles.stepDescription}>
    <Fragment>
      周毛毛
      <Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} />
    </Fragment>
    <div>
      <a href="">催一下</a>
    </div>
  </div>
);

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

const customDot = (
  dot: React.ReactNode,
  {
    status,
  }: {
    status: string;
陈帅's avatar
陈帅 committed
124
  },
陈帅's avatar
陈帅 committed
125
) =>
陈帅's avatar
陈帅 committed
126
  status === 'process' ? (
陈帅's avatar
陈帅 committed
127 128 129 130 131
    <Popover placement="topLeft" arrowPointAtCenter content={popoverContent}>
      {dot}
    </Popover>
  ) : (
    dot
陈帅's avatar
陈帅 committed
132
  );
陈帅's avatar
陈帅 committed
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

const operationTabList = [
  {
    key: 'tab1',
    tab: '操作日志一',
  },
  {
    key: 'tab2',
    tab: '操作日志二',
  },
  {
    key: 'tab3',
    tab: '操作日志三',
  },
];

const columns = [
  {
    title: '操作类型',
    dataIndex: 'type',
    key: 'type',
  },
  {
    title: '操作人',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '执行结果',
    dataIndex: 'status',
    key: 'status',
    render: (text: string) =>
陈帅's avatar
陈帅 committed
165
      text === 'agree' ? (
陈帅's avatar
陈帅 committed
166 167 168
        <Badge status="success" text="成功" />
      ) : (
        <Badge status="error" text="驳回" />
陈帅's avatar
陈帅 committed
169
      ),
陈帅's avatar
陈帅 committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
  },
  {
    title: '操作时间',
    dataIndex: 'updatedAt',
    key: 'updatedAt',
  },
  {
    title: '备注',
    dataIndex: 'memo',
    key: 'memo',
  },
];

@connect(
  ({
    BLOCK_NAME_CAMEL_CASE,
    loading,
  }: {
陈帅's avatar
陈帅 committed
188
    BLOCK_NAME_CAMEL_CASE: AdvancedProfileData;
陈帅's avatar
陈帅 committed
189 190 191 192 193 194
    loading: {
      effects: { [key: string]: boolean };
    };
  }) => ({
    BLOCK_NAME_CAMEL_CASE,
    loading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchAdvanced'],
陈帅's avatar
陈帅 committed
195
  }),
陈帅's avatar
陈帅 committed
196 197
)
class PAGE_NAME_UPPER_CAMEL_CASE extends Component<
陈帅's avatar
陈帅 committed
198
  { loading: boolean; BLOCK_NAME_CAMEL_CASE: AdvancedProfileData; dispatch: Dispatch<any> },
陈帅's avatar
陈帅 committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212
  {
    operationKey: string;
    stepDirection: 'horizontal' | 'vertical';
  }
> {
  public state: {
    operationKey: string;
    stepDirection: 'horizontal' | 'vertical';
  } = {
    operationKey: 'tab1',
    stepDirection: 'horizontal',
  };

  componentDidMount() {
陈帅's avatar
陈帅 committed
213
    const { dispatch } = this.props;
陈帅's avatar
陈帅 committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
    dispatch({
      type: 'BLOCK_NAME_CAMEL_CASE/fetchAdvanced',
    });

    this.setStepDirection();
    window.addEventListener('resize', this.setStepDirection, { passive: true });
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.setStepDirection);
  }

  onOperationTabChange = (key: string) => {
    this.setState({ operationKey: key });
  };
陈帅's avatar
陈帅 committed
229

陈帅's avatar
陈帅 committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
  setStepDirection = () => {
    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',
      });
    }
  };

  render() {
    const { stepDirection, operationKey } = this.state;
    const { BLOCK_NAME_CAMEL_CASE, loading } = this.props;
    const { advancedOperation1, advancedOperation2, advancedOperation3 } = BLOCK_NAME_CAMEL_CASE;
    const contentList = {
      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}
        />
      ),
    };
    return (
陈帅's avatar
陈帅 committed
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
      <PageHeaderWrapper
        title="单号:234231029431"
        extra={action}
        content={description}
        extraContent={extra}
        tabActiveKey="detail"
        tabList={[
          {
            key: 'detail',
            tab: '详情',
          },
          {
            key: 'rule',
            tab: '规则',
          },
        ]}
      >
        <div
          style={{
            margin: 24,
            marginTop: 48,
          }}
          className={styles.main}
        >
          <GridContent>
            <Card title="流程进度" style={{ marginBottom: 24 }}>
              <Steps direction={stepDirection} progressDot={customDot} current={1}>
                <Step title="创建项目" description={desc1} />
                <Step title="部门初审" description={desc2} />
                <Step title="财务复核" />
                <Step title="完成" />
              </Steps>
            </Card>
            <Card title="用户信息" style={{ marginBottom: 24 }} bordered={false}>
              <Descriptions style={{ marginBottom: 24 }}>
                <Descriptions.Item label="用户姓名">付小小</Descriptions.Item>
                <Descriptions.Item label="会员卡号">32943898021309809423</Descriptions.Item>
                <Descriptions.Item label="身份证">3321944288191034921</Descriptions.Item>
                <Descriptions.Item label="联系方式">18112345678</Descriptions.Item>
                <Descriptions.Item label="联系地址">
                  曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口
                </Descriptions.Item>
              </Descriptions>
              <Descriptions style={{ marginBottom: 24 }} title="信息组">
                <Descriptions.Item label="某某数据">725</Descriptions.Item>
                <Descriptions.Item label="该数据更新时间">2017-08-08</Descriptions.Item>
                <Descriptions.Item
                  label={
                    <span>
                      某某数据
                      <Tooltip title="数据说明">
                        <Icon
                          style={{ color: 'rgba(0, 0, 0, 0.43)', marginLeft: 4 }}
                          type="info-circle-o"
                        />
                      </Tooltip>
                    </span>
                  }
陈帅's avatar
陈帅 committed
333
                >
陈帅's avatar
陈帅 committed
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
                  725
                </Descriptions.Item>
                <Descriptions.Item label="该数据更新时间">2017-08-08</Descriptions.Item>
              </Descriptions>
              <h4 style={{ marginBottom: 16 }}>信息组</h4>
              <Card type="inner" title="多层级信息组">
                <Descriptions style={{ marginBottom: 16 }} title="组名称">
                  <Descriptions.Item label="负责人">林东东</Descriptions.Item>
                  <Descriptions.Item label="角色码">1234567</Descriptions.Item>
                  <Descriptions.Item label="所属部门">XX公司 - YY部</Descriptions.Item>
                  <Descriptions.Item label="过期时间">2017-08-08</Descriptions.Item>
                  <Descriptions.Item label="描述">
                    这段描述很长很长很长很长很长很长很长很长很长很长很长很长很长很长...
                  </Descriptions.Item>
                </Descriptions>
                <Divider style={{ margin: '16px 0' }} />
                <Descriptions style={{ marginBottom: 16 }} title="组名称" column={1}>
                  <Descriptions.Item label="学名">
                    Citrullus lanatus (Thunb.) Matsum. et
                    Nakai一年生蔓生藤本;茎、枝粗壮,具明显的棱。卷须较粗..
                  </Descriptions.Item>
                </Descriptions>
                <Divider style={{ margin: '16px 0' }} />
                <Descriptions title="组名称">
                  <Descriptions.Item label="负责人">付小小</Descriptions.Item>
                  <Descriptions.Item label="角色码">1234568</Descriptions.Item>
                </Descriptions>
              </Card>
            </Card>
            <Card title="用户近半年来电记录" style={{ marginBottom: 24 }} bordered={false}>
              <div className={styles.noData}>
                <Icon type="frown-o" />
                暂无数据
陈帅's avatar
陈帅 committed
367
              </div>
陈帅's avatar
陈帅 committed
368 369 370 371 372 373 374 375 376 377 378 379
            </Card>
            <Card
              className={styles.tabsCard}
              bordered={false}
              tabList={operationTabList}
              onTabChange={this.onOperationTabChange}
            >
              {contentList[operationKey]}
            </Card>
          </GridContent>
        </div>
      </PageHeaderWrapper>
陈帅's avatar
陈帅 committed
380 381 382 383 384
    );
  }
}

export default PAGE_NAME_UPPER_CAMEL_CASE;