From aed1ff699140de60131bf9cc1332c98063c66721 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 03 七月 2020 09:14:51 +0800
Subject: [PATCH] 2020-07-03

---
 src/mob/contupdate/index.jsx |   45 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/mob/contupdate/index.jsx b/src/mob/contupdate/index.jsx
index c633eef..3282b3c 100644
--- a/src/mob/contupdate/index.jsx
+++ b/src/mob/contupdate/index.jsx
@@ -1,11 +1,15 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 // import { is, fromJS } from 'immutable'
-import { Form, Icon, Popover, Input } from 'antd'
+import { Form, Icon, Popover, Input, Modal } from 'antd'
 
 import zhCN from '@/locales/zh-CN/mob.js'
 import enUS from '@/locales/en-US/mob.js'
+import FileUpload from '@/tabviews/zshare/fileupload'
 import './index.scss'
+
+const { TextArea } = Input
+const { confirm } = Modal
 
 class ContentUpdate extends Component {
   static propTpyes = {
@@ -15,6 +19,7 @@
 
   state = {
     dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    images: [],
     visible: false
   }
 
@@ -56,18 +61,52 @@
     }
   }
 
+  deleteElement = () => {
+    const _this = this
+
+    confirm({
+      title: '纭畾鍒犻櫎鍏冪礌鍚楋紵',
+      onOk() {
+        _this.props.updateContent(null)
+      },
+      onCancel() {}
+    })
+  }
+
+  imgChange = (list) => {
+    const { element } = this.props
+
+    this.setState({images: list})
+    if (list && list.length && list[0].response) {
+      this.setState({
+        visible: false,
+        images: []
+      })
+      let val = list[0].response
+      if (val && element.content !== val) {
+        this.props.updateContent({...element, content: val})
+      }
+      this.props.form.setFieldsValue({content: val})
+    }
+  }
+
   render () {
     const { element } = this.props
     const { getFieldDecorator } = this.props.form
-    const { visible } = this.state
+    const { visible, images } = this.state
 
     return (
       <div className="mob-content-update">
+        <Icon type="delete" onClick={this.deleteElement} />
         <Popover content={
           <div>
+            {element.eleType === 'img' ? <FileUpload value={images} maxFile={1} fileType="text" onChange={this.imgChange}/> : null}
             {getFieldDecorator('content', {
               initialValue: element.content
-            })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)}
+            })(element.eleType !== 'textarea' ?
+              <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> :
+              <TextArea autosize={{ minRows: 2, maxRows: 3 }} onPressEnter={this.handleSubmit} />
+            )}
           </div>
         } overlayClassName="mob-content-update-popover" placement="bottomRight" title="" visible={visible} trigger="click" onVisibleChange={this.onVisibleChange}>
           <Icon type="edit" />

--
Gitblit v1.8.0