Parcourir la source

add EditableItem
adjust AdvancedProfile page

ddcat1115 il y a 8 ans
Parent
commit
a924c48448

+ 1 - 0
src/components/DescriptionList/index.less

@@ -31,6 +31,7 @@
   }
 
   .detail {
+    width: 100%;
     padding-bottom: 16px;
     color: @text-color;
     display: table-cell;

+ 54 - 0
src/components/EditableItem/index.js

@@ -0,0 +1,54 @@
+import React, { PureComponent } from 'react';
+import { Input, Icon } from 'antd';
+import styles from './index.less';
+
+export default class EditableItem extends PureComponent {
+  state = {
+    value: this.props.value,
+    editable: false,
+  };
+  handleChange = (e) => {
+    const value = e.target.value;
+    this.setState({ value });
+  }
+  check = () => {
+    this.setState({ editable: false });
+    if (this.props.onChange) {
+      this.props.onChange(this.state.value);
+    }
+  }
+  edit = () => {
+    this.setState({ editable: true });
+  }
+  render() {
+    const { value, editable } = this.state;
+    return (
+      <div className={styles.editableItem}>
+        {
+          editable ?
+            <div className={styles.wrapper}>
+              <Input
+                value={value}
+                onChange={this.handleChange}
+                onPressEnter={this.check}
+              />
+              <Icon
+                type="check"
+                className={styles.icon}
+                onClick={this.check}
+              />
+            </div>
+            :
+            <div className={styles.wrapper}>
+              <span>{value || ' '}</span>
+              <Icon
+                type="edit"
+                className={styles.icon}
+                onClick={this.edit}
+              />
+            </div>
+        }
+      </div>
+    );
+  }
+}

+ 25 - 0
src/components/EditableItem/index.less

@@ -0,0 +1,25 @@
+@import "~antd/lib/style/themes/default.less";
+
+.editableItem {
+  line-height: @input-height-base;
+  display: table;
+  width: 100%;
+  margin-top: (@font-size-base * @line-height-base - @input-height-base) / 2;
+
+  .wrapper {
+    display: table-row;
+
+    & > * {
+      display: table-cell;
+    }
+
+    & > *:first-child {
+      width: 85%;
+    }
+
+    .icon {
+      cursor: pointer;
+      text-align: right;
+    }
+  }
+}

+ 0 - 4
src/components/PageHeader/index.less

@@ -42,10 +42,6 @@
   .action {
     margin-left: 56px;
     min-width: 266px;
-
-    button:not(:last-child) {
-      margin-right: 8px;
-    }
   }
 
   .title, .action, .content, .extraContent, .main {

+ 17 - 9
src/routes/Profile/AdvancedProfile.js

@@ -3,9 +3,11 @@ import { connect } from 'dva';
 import { Button, Menu, Dropdown, Icon, Row, Col, Steps, Card, Popover, Badge, Table, Tooltip } from 'antd';
 import PageHeaderLayout from '../../layouts/PageHeaderLayout';
 import DescriptionList from '../../components/DescriptionList';
+import EditableItem from '../../components/EditableItem';
 import styles from './AdvancedProfile.less';
 
 const { Step } = Steps;
+const ButtonGroup = Button.Group;
 const { Description } = DescriptionList;
 
 const menu = (
@@ -18,13 +20,16 @@ const menu = (
 
 const action = (
   <div>
+    <ButtonGroup style={{ marginRight: 8 }}>
+      <Button size="large">操作</Button>
+      <Button size="large">操作</Button>
+      <Dropdown overlay={menu}>
+        <Button size="large">
+          更多操作 <Icon type="down" />
+        </Button>
+      </Dropdown>
+    </ButtonGroup>
     <Button size="large" type="primary">主操作</Button>
-    <Button size="large">次操作</Button>
-    <Dropdown overlay={menu}>
-      <Button size="large">
-        更多 <Icon type="down" />
-      </Button>
-    </Dropdown>
   </div>
 );
 
@@ -44,10 +49,11 @@ const extra = (
 const description = (
   <DescriptionList col="2">
     <Description term="创建人">曲丽丽</Description>
-    <Description term="关联单据"><a href="">12421</a></Description>
+    <Description term="订购产品">XX 服务</Description>
     <Description term="创建时间">2017-07-07</Description>
+    <Description term="关联单据"><a href="">12421</a></Description>
     <Description term="生效日期">2017-07-07 ~ 2017-08-08</Description>
-    <Description term="单据备注">修改公司地址:浙江省杭州市西湖区工专路</Description>
+    <Description term="备注">请于两个工作日内确认</Description>
   </DescriptionList>
 );
 
@@ -195,7 +201,9 @@ export default class AdvancedProfile extends Component {
             <Description term="用户姓名">付小小</Description>
             <Description term="会员卡号">32943898021309809423</Description>
             <Description term="身份证">3321944288191034921</Description>
-            <Description term="联系方式">18322193472</Description>
+            <Description term="联系方式">
+              <EditableItem value="18112345678" />
+            </Description>
             <Description term="联系地址">曲丽丽  18100000000  浙江省杭州市西湖区黄姑山路工专路交叉路口</Description>
           </DescriptionList>
           <DescriptionList style={{ marginBottom: 24 }} title="信息组" col="2">