Browse Source

Merge branch 'master' of http://192.168.20.122:3000/root/MemberCenter

tanyang 5 years ago
parent
commit
e8f985d115

+ 22 - 2
Member/MemberUI/src/components/Form/AutoField.js

@@ -28,6 +28,12 @@ class AutoField extends React.Component {
     let dataKey = fieldOption.key;
     this.props.onChange && this.props.onChange(dataKey, value);    
   }
+  
+  onClick(value) {
+    let fieldOption = this.props.fieldOption;
+    let dataKey = fieldOption.key;
+    this.props.onClick && this.props.onClick(dataKey, value);    
+  }
 
   getValueTag(field,fieldData) {    
     let self = this;
@@ -43,6 +49,7 @@ class AutoField extends React.Component {
         return <Input {...{
           value: field.value,
           onChange: e => self.onChange(e.target.value),
+          onClick: e => self.onClick(e.target.value),
           disabled: field.disabled,
           placeholder: field.placeholder,
           ...innerProps
@@ -51,6 +58,7 @@ class AutoField extends React.Component {
         return <TextArea {...{
           value: field.value,
           onChange: e => self.onChange(e.target.value),
+          onClick: e => self.onClick(e.target.value),
           disabled: field.disabled,
           placeholder: field.placeholder,
           autosize: { minRows: 4, maxRows: 8 },
@@ -60,6 +68,7 @@ class AutoField extends React.Component {
         return <InputNumber {...{
           value: field.value || 0,
           onChange: value => self.onChange(util.string.isEmpty(value) ? 0 : value),
+          onClick: value => self.onClick(util.string.isEmpty(value) ? 0 : value),
           disabled: field.disabled,
           placeholder: field.placeholder,
           min: 0,
@@ -72,6 +81,7 @@ class AutoField extends React.Component {
         return <InputNumber {...{
           value: field.value || 0,
           onChange: value => self.onChange(util.string.isEmpty(value) ? 0 : value),
+          onClick: value => self.onClick(util.string.isEmpty(value) ? 0 : value),
           disabled: field.disabled,
           placeholder: field.placeholder,
           min: 0,
@@ -86,6 +96,7 @@ class AutoField extends React.Component {
         return <Switch {...{
           checked: field.value + '' === "1" || field.value + '' === 'true',
           onChange: value => self.onChange(value ? "1" : "0"),
+          onClick: value => self.onClick(value ? "1" : "0"),
           disabled: field.disabled,
           checkedChildren: <Icon type="check" />,
           unCheckedChildren: <Icon type="cross" />,
@@ -127,6 +138,7 @@ class AutoField extends React.Component {
         return <BirdSelector {...{
           selectedValue: field.value,
           onChange: value => self.onChange(value),
+          onClick: value => self.onClick(value ? "1" : "0"),
           disabled: field.disabled,
           data: sourcedata || [],
           url: field.source.url,
@@ -142,6 +154,7 @@ class AutoField extends React.Component {
         return <BirdMulti {...{
           selectedValue: field.value,
           onChange: value => self.onChange(value),
+          onClick: value => self.onClick(value),
           disabled: field.disabled,
           options: field.source.data || [],
           url: field.source.url,
@@ -156,6 +169,7 @@ class AutoField extends React.Component {
         return <BirdCascader {...{
           value: field.value,
           onChange: value => self.onChange(value),
+          onClick: value => self.onClick(value),
           disabled: field.disabled,
           data: field.source.data || [],
           url: field.source.url,
@@ -174,7 +188,8 @@ class AutoField extends React.Component {
           disabled: field.disabled,
           listType: field.fieldType === 'img' || field.fieldType === 'imgs' ? 'picture' : 'text',
           value: field.value,
-          onChange: value => self.onChange(value)
+          onChange: value => self.onChange(value),
+          onClick: value => self.onClick(value),
         };       
         if (field.fieldType === 'img' || field.fieldType === 'imgs') {
           fileProps.accept = "image/png,image/jpeg,image/jpg,image/gif,image/bmp";
@@ -185,6 +200,7 @@ class AutoField extends React.Component {
         return <DatePicker {...{
           value: field.value ? moment(field.value) : null,
           onChange: (date, dateString) => self.onChange(dateString),
+          onClick: (date, dateString) => self.onClick(dateString),
           disabled: field.disabled,
           format: "YYYY-MM-DD",
           style: { width: '100%' },
@@ -194,6 +210,7 @@ class AutoField extends React.Component {
         return <DatePicker {...{
           value: field.value ? moment(field.value) : null,
           onChange: (date, dateString) => self.onChange(dateString),
+          onClick: (date, dateString) => self.onClick(dateString),
           disabled: field.disabled,
           showTime: true,
           format: "YYYY-MM-DD HH:mm:ss",
@@ -205,13 +222,15 @@ class AutoField extends React.Component {
           initValue: field.value,
           contentId: field.key,
           onChange: value => self.onChange(value),
+          onClick: value => self.onClick(value),
           innerProps: innerProps
         }} />;
         case "input":
         return <InputNumber {...{
           defaultValue:field.value,
           contentId: field.key,
-          onChange: value=>self.onChange(value)
+          onChange: value=>self.onChange(value),
+          onClick: value=>self.onClick(value)
         }} />
       default:
         return <span />;
@@ -249,6 +268,7 @@ AutoField.propTypes = {
   fieldData: PropTypes.array,
   labelColSpan: PropTypes.number,
   onChange: PropTypes.func,
+  onClick: PropTypes.func,
   initOption:PropTypes.func,
   inline:PropTypes.bool,
 }

+ 31 - 5
Member/MemberUI/src/components/Grid/BirdGrid.js

@@ -8,6 +8,7 @@ import BirdButton from '../Form/BirdButton';
 import { DropdownRender, SwitchRender, DateTimeRender, MultiRender, ImageRender, FileRender, MoneyRender, InputRender,Link } from './render';
 import { Pagination, Modal, Card, Popconfirm, message, Row, Col, Checkbox, Button, Divider, Spin, Popover } from 'antd';
 import AutoField from '../Form/AutoField';
+import { cpus } from 'os';
 
 const sourceTypes = ['dropdown', 'multi', 'cascader'];
 
@@ -316,6 +317,8 @@ class BirdGrid extends React.Component {
       let checkValues = this.state.gridDatas.items.map(p => p[this.state.primaryKey]);
       this.setState({ checkedValues: checkValues })
     }
+    this.props.gridOption.afterCheck && this.props.gridOption.afterCheck(this.state.gridDatas,
+      checkValues)
   }
 
   
@@ -788,9 +791,20 @@ class BirdGrid extends React.Component {
                     }}/>
                   </td>
                 }else{
-                  return  <td style={{ textAlign: align, ...widthStyle,...customStyle }} title={formatValue} key={colKey}>
-                  {tgvalue}
+                  if(col.onclick){
+                    return  <td style={{ textAlign: align, ...widthStyle,...customStyle }} title={formatValue} key={colKey}
+                    >
+                      <Popconfirm style={self.state.hidePop?"display:'none'":""} okText={'确定'} cancelText={'取消'} 
+                      title={'您确认要摘取这个值吗?'} 
+                      onConfirm={() => col.onclick(data[col.data])}>
+                    <Button icon='sync' ghost /></Popconfirm>
+                    {tgvalue}
+                    </td>
+                  }else{
+                    return <td style={{ textAlign: align, ...widthStyle,...customStyle }} title={formatValue} key={colKey}
+                    >{tgvalue}
                   </td>
+                  }
                 }
               } else {
                 if (field.editor&&col.editor.inline
@@ -831,9 +845,21 @@ class BirdGrid extends React.Component {
                     fieldData = {sourceData}/>
                   </td>
                 }else{
-                  return <td style={{ textAlign: align, ...widthStyle,...customStyle }} key={colKey}>
-                  {formatValue}
-                </td>
+                  if(col.onclick){
+                    return <td style={{ textAlign: align, ...widthStyle,...customStyle }} key={colKey}
+                    >
+                    <Popconfirm style={self.state.hidePop?"display:'none'":""} okText={'确定'} cancelText={'取消'} 
+                      title={'您确认要摘取这个值吗?'} 
+                      onConfirm={() => col.onclick(data[col.data])}>
+                    <Button icon='sync' ghost /></Popconfirm>
+                    {formatValue}
+                    </td>
+                  }else{
+                    return <td style={{ textAlign: align, ...widthStyle,...customStyle }} key={colKey}
+                  >{formatValue}
+                  </td>
+                  }
+                  
                 }
               }
             }

+ 16 - 2
Member/MemberUI/src/pages/demo/bird-grid.js

@@ -1,14 +1,21 @@
 import React from 'react';
 import { BirdGrid } from 'components/Grid';
+import { Popconfirm } from 'antd';
 
 class BirdGridDemoPage extends React.Component {
   constructor(props) {
     super(props)
     this.state = {
+      hidePop:true
     }
   }
 
+  onClose(){
+
+  }
+
   render() {
+    self = this;
     let database = [
       {
         "label": "选项1",
@@ -44,7 +51,12 @@ class BirdGridDemoPage extends React.Component {
       //actions: [{ name: '外部按钮', color: 'error', onClick: function () { } }],
       columns: [
         { title: "编号", data: "id", type: "number" },
-        { title: "文本", data: "field-text", type: "text", editor: {}, query: true },
+        { title: "文本", data: "field-text", type: "text", 
+          editor: {}, query: true,
+          onclick:function(value){
+            alert("click value---!"+value);
+          } 
+        },
         { title: "数字", data: "field-number", type: "number", editor: {}, colSpan: 2,sum:true, query: true },
         { title: "小数", data: "field-float", type: "number", editor: { innerProps: { step: 0.1, precision: 2 } }, colSpan: 0,sum:true, query: true },
         { title: "布尔值", data: "field-switch", type: "switch", editor: {}, query: true },
@@ -68,7 +80,9 @@ class BirdGridDemoPage extends React.Component {
         }
       ]
     };
-    return <BirdGrid gridOption={gridOption} />
+    return <div>
+                <BirdGrid gridOption={gridOption} />
+           </div>
   }
 }
 

+ 97 - 0
Member/MemberUI/src/pages/demo/tabs.js

@@ -0,0 +1,97 @@
+import { Tabs } from 'antd';
+import PropTypes from 'prop-types';
+
+const { TabPane } = Tabs;
+
+class TopTabs1 extends React.Component {
+  constructor(props) {
+    super(props);
+    this.newTabIndex = 0;
+    // const panes = [
+    //   { title: 'Tab 1', content: <div>eweweff<span>22</span></div>, key: '1' },
+    //   { title: 'Tab 2', content: 'Content of Tab 2', key: '2' },
+    //   {
+    //     title: 'Tab 3',
+    //     content: 'Content of Tab 3',
+    //     key: '3',
+    //     closable: false,
+    //   },
+    // ];
+    
+    let panes = this.props.panes;
+    this.state = {
+      activeKey: panes[0].key,
+      panes,
+    };
+  }
+
+  onChange = activeKey => {
+    this.setState({ activeKey });
+  };
+
+  onEdit = (targetKey, action) => {
+    this[action](targetKey);
+  };
+
+  add = () => {
+    const panes = this.state.panes;
+    const activeKey = `newTab${this.newTabIndex++}`;
+    panes.push({ title: 'New Tab', content: 'Content of new Tab', key: activeKey });
+    this.setState({ panes, activeKey });
+  };
+
+  remove = targetKey => {
+    let activeKey = this.state.activeKey;
+    let lastIndex;
+    this.state.panes.forEach((pane, i) => {
+      if (pane.key === targetKey) {
+        lastIndex = i - 1;
+      }
+    });
+    const panes = this.state.panes.filter(pane => pane.key !== targetKey);
+    if (panes.length && activeKey === targetKey) {
+      if (lastIndex >= 0) {
+        activeKey = panes[lastIndex].key;
+      } else {
+        activeKey = panes[0].key;
+      }
+    }
+    this.setState({ panes, activeKey });
+  };
+
+  render() {
+    return (
+      <Tabs
+        onChange={this.onChange}
+        activeKey={this.state.activeKey}
+        type="editable-card"
+        onEdit={this.onEdit}
+      >
+        {this.state.panes.map(pane => (
+          <TabPane tab={pane.title} key={pane.key} closable={pane.closable}>
+            {pane.content}
+          </TabPane>
+        ))}
+      </Tabs>
+    );
+  }
+}
+
+TopTabs1.propTypes = {
+  panes: PropTypes.array.isRequired
+}
+
+TopTabs1.defaultProps = {
+  panes: [
+      { title: 'Tab 1', content: <div>eweweff<span>22</span></div>, key: '1' },
+      { title: 'Tab 2', content: 'Content of Tab 2', key: '2' },
+      {
+        title: 'Tab 3',
+        content: 'Content of Tab 3',
+        key: '3',
+        closable: false,
+      },
+    ]
+}
+
+export default TopTabs1; 

+ 1 - 1
Member/MemberUI/src/pages/login/index.js

@@ -27,7 +27,7 @@ const Login = ({
       }
 
       
-    function selectElement() {  
+function selectElement() {  
   console.log('Username',$('.text'));
   //console.log('Username',$('.text')[0].textContent);
 }