|
@@ -6,7 +6,59 @@ import moment from 'moment';
|
|
|
import '../content.less';
|
|
|
import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload,Popconfirm,TimePicker } from 'antd';
|
|
|
import {categoryState} from '../../../dataDic.js';
|
|
|
-import {getCategoryState} from '../../../tools.js';
|
|
|
+import {getCategoryState,splitUrl} from '../../../tools.js';
|
|
|
+//图片组件
|
|
|
+const PicturesWall = React.createClass({
|
|
|
+ getInitialState() {
|
|
|
+ return {
|
|
|
+ previewVisible: false,
|
|
|
+ previewImage: '',
|
|
|
+ fileList: [],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCancel() {
|
|
|
+ this.setState({ previewVisible: false })
|
|
|
+ },
|
|
|
+ handlePreview(file) {
|
|
|
+ this.setState({
|
|
|
+ previewImage: file.url || file.thumbUrl,
|
|
|
+ previewVisible: true,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleChange(info) {
|
|
|
+ let fileList = info.fileList;
|
|
|
+ this.setState({ fileList });
|
|
|
+ this.props.fileList(fileList);
|
|
|
+ },
|
|
|
+ componentWillReceiveProps(nextProps) {
|
|
|
+ this.state.fileList = nextProps.pictureUrl;
|
|
|
+ },
|
|
|
+ render() {
|
|
|
+ const { previewVisible, previewImage, fileList } = this.state;
|
|
|
+ const uploadButton = (
|
|
|
+ <div>
|
|
|
+ <Icon type="plus" />
|
|
|
+ <div className="ant-upload-text">点击上传</div>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ return (
|
|
|
+ <div style={{display:"inline-block"}}>
|
|
|
+ <Upload
|
|
|
+ action={globalConfig.context + "/api/admin/Varieties/uploadPicture"}
|
|
|
+ data={{ 'sign': this.props.pictureSign }}
|
|
|
+ listType="picture-card"
|
|
|
+ fileList={fileList}
|
|
|
+ onPreview={this.handlePreview}
|
|
|
+ onChange={this.handleChange} >
|
|
|
+ {fileList.length >= 1 ? null : uploadButton}
|
|
|
+ </Upload>
|
|
|
+ <Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel}>
|
|
|
+ <img alt="example" style={{ width: '100%' }} src={previewImage} />
|
|
|
+ </Modal>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+});
|
|
|
const BusinessCategory=Form.create()(React.createClass({
|
|
|
//搜索功能和初始列表加载
|
|
|
loadData(pageNo, apiUrl) {
|
|
@@ -69,6 +121,8 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
selectedRowKeys: [],
|
|
|
selectedRows: [],
|
|
|
loading: false,
|
|
|
+ orgCodeUrl: [],
|
|
|
+ companyLogoUrl: [],
|
|
|
pagination: {
|
|
|
defaultCurrent: 1,
|
|
|
defaultPageSize: 10,
|
|
@@ -163,6 +217,22 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
let superIdText=this.state.editSuperId;
|
|
|
let superOne=this.state.editDataSource[0].editSuperName;
|
|
|
let isStatus=this.state.editStatus;
|
|
|
+ let theorgCodeUrl = [];
|
|
|
+ if(this.state.orgCodeUrl.length) {
|
|
|
+ let picArr = [];
|
|
|
+ this.state.orgCodeUrl.map(function(item) {
|
|
|
+ picArr.push(item.response.data);
|
|
|
+ });
|
|
|
+ theorgCodeUrl = picArr.join(",");
|
|
|
+ };
|
|
|
+ let thecompanyLogoUrl = [];
|
|
|
+ if(this.state.companyLogoUrl.length) {
|
|
|
+ let picArr = [];
|
|
|
+ this.state.companyLogoUrl.map(function(item) {
|
|
|
+ picArr.push(item.response.data);
|
|
|
+ });
|
|
|
+ thecompanyLogoUrl = picArr.join(",");
|
|
|
+ };
|
|
|
if(isStatus==1){
|
|
|
if(confirm('是否要停用该品类?')){
|
|
|
if(!(superOne==superText)){
|
|
@@ -178,6 +248,7 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
cname:this.state.editName,//品类名称
|
|
|
superId:changeSuper,//上级品类
|
|
|
status:this.state.editStatus,//品类状态
|
|
|
+ varietiesLogo:theorgCodeUrl,
|
|
|
}
|
|
|
}).done(function (data) {
|
|
|
this.setState({
|
|
@@ -204,6 +275,7 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
cname:this.state.editName,//品类名称
|
|
|
superId:superIdText,//上级品类
|
|
|
status:this.state.editStatus,//品类状态
|
|
|
+ varietiesLogo:theorgCodeUrl,
|
|
|
}
|
|
|
}).done(function (data) {
|
|
|
this.setState({
|
|
@@ -233,6 +305,7 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
cname:this.state.editName,//品类名称
|
|
|
superId:changeSuper,//上级品类
|
|
|
status:this.state.editStatus,//品类状态
|
|
|
+ varietiesLogo:theorgCodeUrl,
|
|
|
}
|
|
|
}).done(function (data) {
|
|
|
this.setState({
|
|
@@ -259,6 +332,7 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
cname:this.state.editName,//品类名称
|
|
|
superId:superIdText,//上级品类
|
|
|
status:this.state.editStatus,//品类状态
|
|
|
+ varietiesLogo:theorgCodeUrl,
|
|
|
}
|
|
|
}).done(function (data) {
|
|
|
this.setState({
|
|
@@ -309,6 +383,7 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
editCid: thisdata.cid,//品类编号
|
|
|
editCreateName:thisdata.createName,//创建人
|
|
|
editTime:thisdata.createTimeFormattedDate,//创建时间
|
|
|
+ orgCodeUrl: thisdata.varietiesLogo ? splitUrl(thisdata.varietiesLogo, ',', globalConfig.avatarHost + '/upload') : [],
|
|
|
});
|
|
|
};
|
|
|
this.setState({
|
|
@@ -321,6 +396,7 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
editCid: thisdata.cid,//品类编号
|
|
|
editCreateName:thisdata.createName,//创建人
|
|
|
editTime:thisdata.createTimeFormattedDate,//创建时间
|
|
|
+ orgCodeUrl: thisdata.varietiesLogo ? splitUrl(thisdata.varietiesLogo, ',', globalConfig.avatarHost + '/upload') : [],
|
|
|
editDataSource: theArr,
|
|
|
});
|
|
|
}.bind(this),
|
|
@@ -330,6 +406,10 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
});
|
|
|
}.bind(this));
|
|
|
},
|
|
|
+ //左侧图片地址
|
|
|
+ getOrgCodeUrl(e) {
|
|
|
+ this.setState({ orgCodeUrl: e });
|
|
|
+ },
|
|
|
//新增一个品类,保存
|
|
|
addhandleSubmit(e){
|
|
|
e.preventDefault();
|
|
@@ -642,6 +722,17 @@ const BusinessCategory=Form.create()(React.createClass({
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
|
+ <FormItem
|
|
|
+ labelCol={{ span: 7 }}
|
|
|
+ wrapperCol={{ span: 12 }}
|
|
|
+ label="业务品类图标" >
|
|
|
+ <PicturesWall
|
|
|
+ pictureSign="varieties_picture"
|
|
|
+ fileList={this.getOrgCodeUrl}
|
|
|
+ pictureUrl={this.state.orgCodeUrl} />
|
|
|
+ </FormItem>
|
|
|
+ </div>
|
|
|
+ <div className="clearfix">
|
|
|
<FormItem
|
|
|
labelCol={{ span: 7 }}
|
|
|
wrapperCol={{ span: 12 }}
|