Browse Source

处理自动跳到富文本

魏熙美 5 years ago
parent
commit
f27d9cfc23

+ 12
- 0
src/components/Wangedit/Wangedit.jsx View File

@@ -55,6 +55,18 @@ class Wangedit extends React.Component {
55 55
       }
56 56
     }
57 57
   }
58
+
59
+  /**
60
+   *增加这个 shouldComponentUpdate 生命函数
61
+    处理自动聚焦到富文本上
62
+   *
63
+   * @param {*} nextProps
64
+   * @returns
65
+   * @memberof Wangedit
66
+   */
67
+  shouldComponentUpdate(nextProps) {
68
+    return nextProps.value !== this.editor.txt.html()
69
+  }
58 70
 }
59 71
 
60 72
 export default Wangedit

+ 3
- 2
src/pages/building/list/add/components/buildingProjectType.jsx View File

@@ -61,7 +61,7 @@ class TypeForm extends React.Component {
61 61
           position: 'relative',
62 62
           border: '1px solid #eee',
63 63
           borderRadius: '4px',
64
-          marginTop:'16px'
64
+          marginTop: '16px',
65 65
         }}>
66 66
 
67 67
           <p style={{ padding: '20px', borderBottom: '1px solid #eee' }}>{this.props.type.buildingTypeName || ''}  <Button type="link" style={{ position: 'absolute', right: '16px' }} icon="close" onClick={() => this.close()} /></p>
@@ -140,6 +140,7 @@ class ProjectTypeBody extends React.Component {
140 140
     const updateProjectDate = this.updateProjectType(tempDate)
141 141
     console.log('updateProjectDate: ', updateProjectDate)
142 142
     this.setState({ data: updateProjectDate })
143
+    this.setState({ defaultCheckboxValue: updateProjectDate.map(item => item.buildingTypeId) })
143 144
   }
144 145
 
145 146
   onClose = e => {
@@ -239,7 +240,7 @@ class ProjectTypeBody extends React.Component {
239 240
           onOk={this.handleOk}
240 241
           onCancel={this.handleCancel}
241 242
         >
242
-          <Checkbox.Group options={this.state.projectType.map(item => ({ label: item.buildingTypeName, value: item.buildingTypeId }))} defaultValue={this.state.defaultCheckboxValue} onChange={e => this.onCheckboxChange(e)} />
243
+          <Checkbox.Group options={this.state.projectType.map(item => ({ label: item.buildingTypeName, value: item.buildingTypeId }))} onChange={e => this.onCheckboxChange(e)} value={this.state.defaultCheckboxValue}/>
243 244
         </Modal>
244 245
         <Row type="flex" justify="space-between">
245 246
           {