import React from 'react'; import $ from 'jquery/src/ajax'; import { citySelect} from '@/NewDicProvinceListAll'; import { Form, Icon, Button, Input, Select, Spin, Table, message, DatePicker, Modal, Upload,Popconfirm,Cascader, InputNumber } from 'antd'; import {getGameState,splitUrl,getprovince} 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 = (
点击上传
); return (
{fileList.length >= 1 ? null : uploadButton} example
); } }); //主体 const BusinessProject=Form.create()(React.createClass({ loadData(pageNo) { this.state.data = []; this.setState({ loading: true, page:pageNo, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/portal/service/jtProject/list', data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, secondId:this.state.cid, name:this.state.nameSearch, }, success: function (data) { let theArr = []; if (!data.data || !data.data.list) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i], ProvinceCityArr = [], cname='',superName='', ProvinceS = thisdata.province, //getprovince citys = thisdata.city, Areas = thisdata.area; ProvinceCityArr.push(ProvinceS, citys, Areas); this.state.categoryList.map(item=>{ if(thisdata.categoryId==item.id){ cname=item.name; superName=item.superName } }) theArr.push({ key: i, id:thisdata.id,//业务名称 name: thisdata.name,//业务名称 categoryId: thisdata.categoryId,//业务品类 number:thisdata.number, price: thisdata.price,//市场价 superName:superName, cname:cname, city:thisdata.city, activityPrice:thisdata.activityPrice?thisdata.activityPrice:'',//最低折扣 memberPrice:thisdata.memberPrice?thisdata.memberPrice:'',//会员价 offset:thisdata.offset?thisdata.offset:'', activityPrice:thisdata.activityPrice?thisdata.activityPrice:'',//活动价 activityFlag:thisdata.activityFlag,//活动生效标识 status: thisdata.status,//项目状态 province:thisdata.province, introduce:thisdata.introduce, createTime:thisdata.createTime?(new Date(thisdata.createTime)).toLocaleString():'', value:thisdata.value, applyConditions:thisdata.applyConditions }); }; this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; }; this.setState({ dataSource: theArr, pagination: this.state.pagination }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getInitialState() { return { searchMore: true, selectedRowKeys: [], selectedRows: [], loading: false, orgCodeUrl: [], companyLogoUrl: [], pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); this.setState({ selectedRowKeys: [], }) }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, formatPagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, formatDataSource: [], columns: [ { title: '项目名称', dataIndex: 'name', key: 'bname', }, { title: '品类名称', dataIndex: 'cname', key: 'cname' }, { title: '上级品类', dataIndex: 'superName', key: 'superName' }, { title: '业务地区', dataIndex: 'area', key: 'area', render: (text,rocard) => { return
{rocard.province!=0?{getprovince(rocard.province)+'-'+getprovince(rocard.city)}:'全国'}
} }, { title: '市场价', dataIndex: 'price', key: 'price', }, { title: '最低折扣', dataIndex: 'offset', key: 'offset', }, { title: '会员价', dataIndex: 'memberPrice', key: 'memberPrice', }, { title: '活动价', dataIndex: 'activityPrice', key: 'activityPrice', }, { title: '活动生效标识', dataIndex: 'activityFlag', key: 'activityFlag', render: text => { return getGameState(text) } } ], dataSource: [], }; }, //业务品类列表获取 topLevel(){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/user/jtBusiness/category/list', data: { pageNo: 1, pageSize: 999, }, success: function (data) { let theArr = [],firstData=[]; if (!data.data || !data.data.list) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i]; theArr.push({ key: i, id:thisdata.id, name: thisdata.name, superName:thisdata.superName//上级品类 }); if(thisdata.layer=='2'){ firstData.push({ key: i, id:thisdata.id, name: thisdata.name, superName:thisdata.superName//上级品类 }) } }; }; this.setState({ categoryList: theArr, firstData:firstData }); this.loadData(); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, componentWillMount() { this.topLevel() }, //编辑部门,保存 edithandleSubmit(e){ e.preventDefault(); if(!this.state.name){ message.warning('请输入项目名称'); return ; } if(!this.state.categoryId){ message.warning('请选择项目业务品类'); return ; } if(!(this.state.ProvinceCity.length)){ message.warning('请选择省份'); return ; } if(!(this.state.price)){ message.warning('请输入正确的市场价'); return ; } this.setState({ loading:true }) let minPictureUrl = []; if (this.state.orgCodeUrl.length) { let picArr = []; this.state.orgCodeUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ picArr.push(item.response.data); } }); minPictureUrl = picArr.join(","); }; let maxPictureUrl = []; if (this.state.companyLogoUrl.length) { let picArr = []; this.state.companyLogoUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ picArr.push(item.response.data); } }); maxPictureUrl = picArr.join(","); }; $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/jtBusiness/project/update", data: { id:this.state.id,//业务名称 name: this.state.name,//业务名称 categoryId: this.state.categoryId,//业务品类 price: this.state.price,//市场价 activityPrice:this.state.activityPrice?this.state.activityPrice:'0',//最低折扣 memberPrice:this.state.memberPrice?this.state.memberPrice:'0',//会员价 offset:this.state.offset?this.state.offset:'0', activityFlag:this.state.activityFlag,//活动生效标识 province:this.state.ProvinceCity?this.state.ProvinceCity[0]:'',//是否全国 city:this.state.ProvinceCity?this.state.ProvinceCity[1]:'', introduce:this.state.introduce, value:this.state.value, minImgUrl:minPictureUrl.length?minPictureUrl:'', maxImgUrl:maxPictureUrl.length?maxPictureUrl:'', applyConditions:this.state.applyConditions, } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); this.setState({ loading: false, editvisible:false }); } else { message.warning(data.error[0].message); }; this.loadData(this.state.page) }.bind(this)); }, detailes(recard){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/user/jtBusiness/project/detail', data: { id:recard.id }, success: function (data) { if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { let thisdata=data.data; let ProvinceCityArr=[]; ProvinceCityArr.push(thisdata.province,thisdata.city) this.setState({ id:thisdata.id,//业务名称 name: thisdata.name,//业务名称 categoryId: thisdata.categoryId,//业务品类 number:thisdata.number, price: thisdata.price,//市场价 activityPrice:thisdata.activityPrice?thisdata.activityPrice:'',//最低折扣 memberPrice:thisdata.memberPrice?thisdata.memberPrice:'',//会员价 offset:thisdata.offset?thisdata.offset:'', activityFlag:thisdata.activityFlag?thisdata.activityFlag.toString():'',//活动生效标识 ProvinceCity:ProvinceCityArr, introduce:thisdata.introduce, createTime:thisdata.createTime?(new Date(thisdata.createTime)).toLocaleString():'', value:thisdata.value, applyConditions:thisdata.applyConditions, orgCodeUrl: thisdata.minImgUrl ? splitUrl(thisdata.minImgUrl, ',', globalConfig.avatarHost + '/upload') : [], companyLogoUrl:thisdata.maxImgUrl ? splitUrl(thisdata.maxImgUrl, ',', globalConfig.avatarHost + '/upload') : [], }) }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //项目列表整行点击 tableRowClick(record, index) { this.state.RowData = record; this.setState({ editvisible:true }) this.detailes(record) }, //左侧图片地址 getOrgCodeUrl(e) { this.setState({ orgCodeUrl: e }); }, //右侧图片地址 getCompanyLogoUrl(e) { this.setState({ companyLogoUrl: e }); }, //新增一个项目,保存 addhandleSubmit(e){ e.preventDefault(); if(!this.state.categoryName){ message.warning('请输入项目名称'); return false; } if(!this.state.addCid){ message.warning('请选择项目品类'); return false; } this.setState({ loading: true }); //上级组织字典 $.ajax({ method: "post", dataType: "json", crossDomain: false, url:globalConfig.context + '/api/user/jtBusiness/project/apply', data:{ name:this.state.categoryName,//项目名称 categoryId:this.state.addCid, province:this.state.ProvinceCity?this.state.ProvinceCity[0]:'',//是否全国 city:this.state.ProvinceCity?this.state.ProvinceCity[1]:'' } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('新增项目成功!'); this.handleCancel(); this.loadData(this.state.page); } else { message.warning(data.error[0].message); } }.bind(this)); }, //项目整行删除 delectRow() { let deletedIds = ''; for (let idx = 0; idx < this.state.selectedRows.length; idx++) { let rowItem = this.state.selectedRows[idx]; if (rowItem.id) { deletedIds=rowItem.id; }; }; this.setState({ selectedRowKeys: [], loading: deletedIds.length > 0 }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/jtBusiness/project/delete", data: { id:deletedIds } }).done(function (data) { if (!data.error.length) { message.success('删除成功!'); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; this.loadData(this.state.page); }.bind(this)); }, addClick() { this.state.RowData = {}; this.setState({ visible: true }); this.addReset(); }, editClick(e) { this.state.RowData = {}; this.setState({ editvisible: true }); }, handleCancel() { this.setState({ visible: false }) }, edithandleCancel(e) { this.setState({ editvisible: false }); }, search() { this.loadData(); }, //搜索部分的清零 reset() { this.state.nameSearch = '';//项目名称清零 this.state.cid = undefined;//品类名称清零 this.state.ressSearch= undefined;//省市区清零 this.state.activityFlag = undefined;//活动生效清零 this.state.status = undefined;//项目状态清零 this.loadData(); }, //新增部分的清零 addReset(){ this.state.categoryName='';//项目名称清零 this.state.ProvinceCity=undefined; this.state.addCid=undefined; this.state.boutique=''; }, //更多搜索的显示与否 searchSwitch() { this.setState({ searchMore: !this.state.searchMore }); }, render() { const FormItem = Form.Item const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows.slice(-1), selectedRowKeys: selectedRowKeys.slice(-1) }); } }; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; const hasSelected = this.state.selectedRowKeys.length > 0; const { RangePicker } = DatePicker; const categoryList = this.state.categoryList ||[]; const firstData = this.state.firstData || []; return (
{ this.setState({ nameSearch: e.target.value }); }} />
{this.setState({categoryName:e.target.value})}} required="required"/> *
*
{ this.setState({ ProvinceCity: e }) }} /> *
*项目名称} > {this.setState({name:e.target.value})}}/> *业务品类} >
*省-市} > { this.setState({ ProvinceCity: e }) }} />
*市场价} > {this.setState({price:e})}} required="required"/> 万元 {this.setState({activityPrice:e})}} min={0} max={999999} step={0.01}/> 万元 {this.setState({offset:e})}} min={0} max={1} step={0.01}/> {this.setState({memberPrice:e})}} min={0} max={999999} step={0.01}/> 万元 {this.state.createTime}
{ this.setState({ introduce: e.target.value }) }}/>
{ this.setState({ value: e.target.value }) }}/>
{ this.setState({ applyConditions: e.target.value }) }}/>

图片建议:图片要清晰。(35*35)

图片建议:图片要清晰。(200*200)

); } })); export default BusinessProject;