From ce70be666bcd78a7e16e739040488cf7e7256cc2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 31 五月 2021 15:49:43 +0800 Subject: [PATCH] 2021-05-31 --- src/menu/picturecontroller/editform/index.jsx | 63 ++++++++++--------------------- 1 files changed, 21 insertions(+), 42 deletions(-) diff --git a/src/menu/picturecontroller/editform/index.jsx b/src/menu/picturecontroller/editform/index.jsx index e12d46d..934ebd7 100644 --- a/src/menu/picturecontroller/editform/index.jsx +++ b/src/menu/picturecontroller/editform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio, notification } from 'antd' +import { Form, Row, Col, Input, Radio } from 'antd' import FileUpload from '@/tabviews/zshare/fileupload' import './index.scss' @@ -14,7 +14,6 @@ } state = { - urls: [], linkurl: '', plusType: 'upload' } @@ -24,29 +23,8 @@ return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - if (values.urls && values.urls[0].status === 'error') { - notification.warning({ - top: 92, - message: '璇烽噸鏂颁笂浼犳枃浠讹紒', - duration: 5 - }) - return - } else if (values.urls && values.urls[0] && values.urls[0].status !== 'done') { - notification.warning({ - top: 92, - message: '鏂囦欢涓婁紶涓紝璇风◢鍚庯紒', - duration: 5 - }) - return - } else if (values.urls && values.urls[0] && values.urls[0].response) { - values.linkurl = values.urls[0].response - } else { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌鏂囦欢璺緞锛�', - duration: 5 - }) - return + if (values.urls) { + values.linkurl = values.urls } resolve(values) } else { @@ -57,28 +35,19 @@ } changeType = (val) => { - const { linkurl, urls } = this.state - let _urls = this.props.form.getFieldValue('urls') || '' - let _url = this.props.form.getFieldValue('linkurl') || '' + let _url = '' if (val === 'input') { - if (_urls && _urls[0] && _urls[0].status === 'done' && (_urls[0].url || _urls[0].response)) { - _url = _urls[0].url || _urls[0].response - } else { - _url = linkurl || '' - } - } else { - _urls = urls.filter(item => item.status === 'done') - _url = linkurl + _url = this.props.form.getFieldValue('urls') || '' } - this.setState({plusType: val, urls: _urls, linkurl: _url}) + this.setState({plusType: val, linkurl: _url}) } render() { const { getFieldDecorator } = this.props.form const { card } = this.props - const { urls, linkurl, plusType } = this.state + const { linkurl, plusType } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -103,7 +72,7 @@ {!card.id && card.typecharone === 'image' && plusType === 'upload' ? <Col span={24}> <Form.Item label="鍥剧墖涓婁紶"> {getFieldDecorator('urls', { - initialValue: urls, + initialValue: '', rules: [ { required: true, @@ -111,14 +80,19 @@ } ] })( - <FileUpload accept=".jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp" maxFile={1} fileType={'picture'} /> + <FileUpload config={{ + initval: '', + suffix: '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp', + maxfile: 1, + fileType: 'picture' + }} /> )} </Form.Item> </Col> : null} {!card.id && card.typecharone === 'video' && plusType === 'upload' ? <Col span={24}> <Form.Item label="瑙嗛涓婁紶"> {getFieldDecorator('urls', { - initialValue: urls, + initialValue: '', rules: [ { required: true, @@ -126,7 +100,12 @@ } ] })( - <FileUpload accept=".mp4,.webm,.ogg" maxFile={1} fileType={'text'} /> + <FileUpload config={{ + initval: '', + suffix: '.mp4,.webm,.ogg', + maxfile: 1, + fileType: 'text' + }}/> )} </Form.Item> </Col> : null} -- Gitblit v1.8.0