import React from "react"; import $ from "jquery/src/ajax"; import "react-quill/dist/quill.bubble.css"; import moment from "moment"; import { Form, Icon, Button, Input, Select, Table, message, DatePicker, Modal, Upload, Popconfirm, Cascader, InputNumber, Radio, TimePicker, Tabs, Tag, Tooltip, Checkbox } from "antd"; import { areaSelect, getProvince } from "@/NewDicProvinceList"; //省市区 import { getGameState, splitUrl, getprovince, getStatuslist, getLvl, beforeUploadFile, getSecretType, getBuyAuditType, getPicPath } from "@/tools.js"; import Img01 from "./image/cgg.jpg"; import Img02 from "./image/ttt.jpg"; import Img03 from "./image/xxxd.jpg"; import Img04 from "./image/bbb.jpg"; import SpinContainer from "../../SpinContainer"; import {companyList, getCompanyName, getCompanyValueArray} from "../../common/configure"; //上传图片组件 const PicturesWall = React.createClass({ getInitialState() { return { previewVisible: false, previewImage: "", fileList: this.props.pictureUrl, imgflag: this.props.flagimg }; }, getDefaultProps() { return { changeClick: this.modifyChange }; }, 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, flagimg } = this.state; const uploadButton = (
点击上传
); return (
{fileList && fileList.length >= 1 ? null : uploadButton}
); } }); //主体 const Proservlist = 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 + "/api/admin/organization/listOrganization", data: { pageNo: pageNo || this.state.pagination.current || 1, pageSize: this.state.pagination.pageSize, name: this.state.nameSearch, location: this.state.locationSearch, }, 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]; thisdata.key = i + 1; theArr.push(thisdata); } 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 { loading: false, flag: true, timesArr: [], totalData: { mark: false }, purchaseImg: [], 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 + "条数据"; } }, //数据类型 columns: [ { title: "序号", dataIndex: "key", key: "key" }, { title: "是否发布", dataIndex: "releaseStatus", key: "releaseStatus", render: s => { return s ? ( 已发布 ) : ( 未发布 ); } }, { title: "是否首页", dataIndex: "status", key: "status", render: s => { return s ? ( ) : ( ); } }, { title: "战略合作机构", dataIndex: "name", key: "name" }, { title: "LOGO缩率图", dataIndex: "pictureUrl", key: "pictureUrl", render: url => { let path = getPicPath(globalConfig.avatarUploadHost, url); return (
); } }, { title: "公司", dataIndex: "locations", key: "locations", width:150, render: r => { let text = ''; r && r.map((v,i)=>( text += (i === 0 ? '':',')+getCompanyName(v) )) return( { r && r.map((v,i)=>( i <= 2 ? (i === 0 ? '':',')+getCompanyName(v) : null )) } { r.length > 3 ? '.....' : null } ) } }, { title: "排序", dataIndex: "sort", key: "sort" }, { title: "操作", dataIndex: "ads", key: "ads", render: (text, record, index) => { return (
{ } { { this.delete(record.id); }} > } { }
); } } ], //数据列表 dataSource: [] }; }, componentWillMount() { this.loadData(); }, stopPropagation(e) { e.stopPropagation(); e.nativeEvent.stopImmediatePropagation(); }, //点击大图 maximg(url) { this.setState({ imgeditvisible: true, maximg: url }); }, imghandleCancel() { this.setState({ imgeditvisible: false }); }, //删除按钮 delete(id) { $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/deleteOrganization", data: { id }, success: function(data) { let theArr = []; if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.warning('删除成功') this.loadData(); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, //项目列表整行点击 tableRowClick(record, index) { this.state.RowData = record; this.setState({ editvisible: true }); this.edit(record); }, edithandleCancel(e) { this.setState( { editvisible: false, indeterminate: false, checked:false, }, () => { this.addReset(); } ); this.loadData(); }, search() { this.loadData(); }, add() { this.setState({ editvisible: true, flag: false }); }, //撤下 remove(record, flag) { $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/updateOrganization", data: { id: record.id, releaseStatus: flag }, success: function(data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { this.loadData(); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, addNew(flag) { if(!this.state.name){ message.warning('请填写名称') return ; } if(this.state.locations.length === 0){ message.warning('请选择公司') return ; } if (this.state.flag) { $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/updateOrganization", data: { id: this.state.id, name: this.state.name, releaseStatus: flag, sort: this.state.sort, locations: this.state.locations.join(','), pictureUrl: this.state.pictureUrl ? this.state.pictureUrl[0].response.data : undefined }, success: function(data) { if (data.error.length || data.data.list == "") { if (data.error && data.error.length) { message.warning(data.error[0].message); } } else { message.success('操作成功') this.edithandleCancel(); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); } else { $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/addOrganization", data: { name: this.state.name, releaseStatus: flag, sort: this.state.sort, locations: this.state.locations.join(','), pictureUrl: this.state.pictureUrl ? this.state.pictureUrl[0].response.data : undefined }, success: function(data) { if (data.error.length || data.data.list == "") { if (data.error && data.error.length) { message.warning(data.error[0].message); } } else { message.success('添加成功') this.cancelAdd(); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); } }, saveNew() { this.change("releaseStatus", 0, () => { this.addNew(); }); }, issueNew() { this.change("releaseStatus", 1, () => { this.addNew(); }); }, //编辑按钮操作 edit(record, index) { this.setState({ editvisible: true, loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectOrganization", data: { id: record.id }, success: function(data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { const thisdata = data.data; this.setState({ id: thisdata.id, name: thisdata.name, pictureUrl: thisdata.pictureUrl ? splitUrl( thisdata.pictureUrl, ",", globalConfig.avatarUploadHost ) : [], releaseStatus: thisdata.releaseStatus, sort: thisdata.sort, locations: thisdata.locations, checked:thisdata.locations.length === companyList.length, indeterminate: thisdata.locations.length < companyList.length, releaseTimeConvert: thisdata.releaseTimeConvert, createTimeConvert: thisdata.createTimeConvert }); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, cancelAdd() { this.setState( { editvisible: false, indeterminate: false, checked:false, }, () => { this.setState({ flag: true }); this.addReset(); } ); this.loadData(); }, //新增框的清零 addReset() { this.setState({ totalData: {}, purchaseImg: [] }); }, //搜索部分的清零 reset() { this.setState({ locationSearch:undefined, nameSearch : undefined, },()=>{ this.loadData(); }) }, getOrgCodeUrl(e) { this.setState({ pictureUrl: e }); }, toTop(record, num) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/updateOrganization", data: { id: record.id, status: num }, success: function(data) { let theArr = []; if (data.error && data.error.length) { message.warning(data.error[0].message); } else { this.loadData(); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, render() { const FormItem = Form.Item; const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows.slice(-1), selectedRowKeys: selectedRowKeys.slice(-1) }); } }; let data = this.state.totalData; const { TextArea } = Input; //文本域 const { TabPane } = Tabs; //标签页 const { MonthPicker, RangePicker, WeekPicker } = DatePicker; //日期输入框 return (
战略合作列表
{ this.setState({ nameSearch: e.target.value }); }} />
{ this.setState({ editvisible: false, name:'', pictureUrl:[], sort:'', locations:[], indeterminate: false, checked:false, }) } } footer="" >
{ this.setState({ name: e.target.value }); }} style={{ width: "240px" }} />

建议尺寸:250X86

{ this.setState({ sort: e.target.value }); }} style={{ width: "240px" }} />
{ this.setState({ locations: e.target.checked ? getCompanyValueArray():[], indeterminate: false, checked:e.target.checked }) }}>全选 { this.setState({ locations: e, indeterminate: companyList.length > e.length, checked: companyList.length === e.length }); }} />
); } }) ); export default Form.create()(Proservlist);