123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449 |
- 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,Spin,Table,message,DatePicker,Modal,Upload,Checkbox,Row,InputNumber,Radio,Col,Tabs} from 'antd';
- import {areaSelect, getProvince} from '@/NewDicProvinceList';//省市区
- import { getGameState, splitUrl, getprovince, getStatuslist, getLvl,beforeUploadFile} from '@/tools.js';
- //主体
- const MemberPowerList = 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/listLvltype',
- data: {
- pageNo: pageNo || 1,
- pageSize: this.state.pagination.pageSize,
- },
- success: function(data) {
- let theArr = [];
- if (!data.data || !data.data) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- }
- } else {
- for (let i = 0; i < data.data.length; i++) {
- let thisdata = data.data[i];
- theArr.push({
- key: i,
- id: thisdata.id,
- typeName: thisdata.typeName,
- lvlNumber: thisdata.lvlNumber,
- viewCg: thisdata.viewCg,
- viewQy: thisdata.viewQy,
- viewJmc: thisdata.viewJmc,
- viewMjc: thisdata.viewMjc,
- viewCyc: thisdata.viewCyc,
- viewDyc:thisdata.viewDyc,
- viewQyc:thisdata.viewQyc,
- });
- }
- 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,
- totalData:{
- mark: false,
- },
- 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: 'lvlNumber',
- key: 'lvlNumber'
- },
- {
- title: '名称',
- dataIndex: 'typeName',
- key: 'typeName'
- },
- {
- title: '操作',
- dataIndex: 'a',
- key: 'a',
- render:(text,record,index)=>{
- return <Button type="primary" onClick={()=>{
- this.tableRowClick(record)
- }}>修改</Button>
- }
- },
- ],
- dataSource: []
- };
- },
-
- componentWillMount() {
- this.loadData()
- },
- detailes(record) {
- this.setState({
- loading:true
- });
- $.ajax({
- method: 'get',
- dataType: 'json',
- crossDomain: false,
- url: globalConfig.context + '/api/admin/detailsLvltype',
- data: {
- id: record.id,
- },
- success: function(data) {
- let theArr = [];
- let thisdata = data.data;
- if (!data.data || !data.data.list) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- }
- }
- Object.assign(this.state.totalData,{},this.state.RowData)
- console.log(this.state.totalData)
- }.bind(this)
-
- }).always(
- function() {
- this.setState({
- loading: false
- });
- }.bind(this)
- );
- },
-
- stopPropagation(e){
- e.stopPropagation();
- e.nativeEvent.stopImmediatePropagation();
- },
-
- //项目列表整行点击
- tableRowClick(record, index) {
- this.state.RowData = record;
- this.setState({
- editvisible: true,
- });
- this.detailes(record);
- },
- edithandleCancel(e) {
- this.setState({
- editvisible: false
- },()=>{
- this.addReset()
- });
- this.loadData()
- },
-
- search() {
- this.loadData();
- },
-
- add(){
- this.setState({
- editvisible: true,
- flag: false,
- });
- },
- addNew(){
- this.setState({
- loading:true
- });
- $.ajax({
- method: 'post',
- dataType: 'json',
- crossDomain: false,
- url: globalConfig.context + (this.state.flag?'/api/admin/updateLvltype':'/api/admin/addLvltype'),
- data: this.state.totalData,
- }).done(function(data) {
- this.setState({
- loading: false
- });
- if(!data.error.length) {
- message.success('保存成功!');
- this.cancelAdd()
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this));
- },
-
- saveNew(){
- this.addNew()
- },
-
- issueNew(){
- this.addNew()
- },
-
- delete(id){
- this.setState({
- loading:true
- });
- $.ajax({
- method: 'post',
- dataType: 'json',
- crossDomain: false,
- url: "api/admin/deleteLvltype",
- data: {
- id: id,
- },
- }).done(function(data) {
- this.setState({
- loading: false
- });
- if(!data.error.length) {
- message.success('删除成功!');
- this.loadData()
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this));
- },
-
- cancelAdd(){
- this.setState({
- editvisible: false,
- },()=>{
- this.setState({
- flag:true
- })
- this.addReset()
- });
- this.loadData()
- },
-
- //新增框的清零
- addReset(){
- this.setState({
- totalData:{
- mark:false,
- },
- },()=>{
- console.log(this.state.totalData)
- })
- },
- //搜索部分的清零
- reset() {
- this.loadData();
- },
-
- change(key, e, f){
- if(f === undefined ){
- this.state.totalData[key] = e
- this.setState({
- totalData:this.state.totalData
- })
- }else if(typeof(f) === "function"){
- this.state.totalData[key] = e
- this.setState({
- totalData:this.state.totalData
- },f)
- }
- },
-
- 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 (
- <div className="user-content">
- <div className="content-title">
- <span>会员权限列表</span>
- <div className="user-search">
- {/*<Input
- placeholder="企业名称"
- style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
- value={this.state.nameSearch}
- onChange={(e) => {
- this.setState({ nameSearch: e.target.value });
- }}
- />
- <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
- 搜索
- </Button>
- <Button onClick={this.reset} style={{ marginRight: '10px' }}>
- 重置
- </Button>*/}
- <Button type="primary" onClick={this.add}>
- 新增会员权限
- </Button>
- </div>
- <div className="patent-table">
- <Spin spinning={this.state.loading}>
- <Table
- columns={this.state.columns}
- dataSource={this.state.dataSource}
- pagination={this.state.pagination}
- onRowClick={this.tableRowClick}
- />
- </Spin>
- </div>
- </div>
- <div className="patent-desc">
- <Modal
- className="customeDetails"
- title={this.state.flag?'会员权限详情':'新增会员权限'}
- width="1000px"
- visible={this.state.editvisible}
- onOk={this.edithandleCancel}
- onCancel={this.state.flag?this.edithandleCancel:this.cancelAdd}
- footer=""
- >
- <Form layout="horizontal" onSubmit={this.edithandleSubmit} id="demand-form">
- <Spin spinning={this.state.loading}>
- <div className="clearfix">
- <Row style={{marginTop:"20px"}}>
- <Col span={8}>
- <Checkbox checked={data.viewCg} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewCg",1)
- }else{
- this.change("viewCg",0)
- }
- }}>查看采购联系人</Checkbox>
- </Col>
- <Col span={8}>
- <Checkbox checked={data.viewQy} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewQy",1)
- }else{
- this.change("viewQy",0)
- }
- }}>查看军工企业信息</Checkbox>
- </Col>
- <Col span={8}>
- <Checkbox checked={data.viewQyc} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewQyc",1)
- }else{
- this.change("viewQyc",0)
- }
- }}>查看军工企业联系信息</Checkbox>
- </Col>
- </Row>
- <Row style={{marginTop:"20px"}}>
- <Col span={8}>
- <Checkbox checked={data.viewJmc} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewJmc",1)
- }else{
- this.change("viewJmc",0)
- }
- }}>军转民联系信息</Checkbox>
- </Col>
- <Col span={8}>
- <Checkbox checked={data.viewMjc} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewMjc",1)
- }else{
- this.change("viewMjc",0)
- }
- }}>民参军联系信息</Checkbox>
- </Col>
- <Col span={8}>
- <Checkbox checked={data.viewCyc} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewCyc",1)
- }else{
- this.change("viewCyc",0)
- }
- }}>创业军人联系信息</Checkbox>
- </Col>
- </Row>
- <Row style={{marginTop:"20px"}}>
- <Col span={8}>
- <Checkbox checked={data.viewDyc} onChange={(e)=>{
- if (e.target.checked) {
- this.change("viewDyc",1)
- }else{
- this.change("viewDyc",0)
- }
- }}>待就业军人联系信息</Checkbox>
- </Col>
- </Row>
- </div>
- <div className="clearfix" style={{marginTop:'40px'}}>
- <FormItem
- className="half-item"
- labelCol={{ span: 2 }}
- wrapperCol={{ span: 12 }}
- label="名称"
- >
- <Input placeholder="请输入名称" value={data.typeName}
- onChange={(e)=>{
- this.change('typeName',e.target.value)
- }} style={{width:'240px'}} />
- </FormItem>
- <FormItem
- className="half-item"
- labelCol={{ span: 2 }}
- wrapperCol={{ span: 12 }}
- label="序号"
- >
- <Input placeholder="请输入序号" value={data.lvlNumber}
- onChange={(e)=>{
- this.change('lvlNumber',e.target.value)
- }} style={{width:'240px'}} />
- </FormItem>
- </div>
- <div className="clearfix">
- <Button type="primary" size="large" onClick={this.saveNew} style={{float:'right',marginRight:'80px',marginTop:'20px'}}>保存</Button>
- {/*<Button type="primary" size="large" onClick={this.issueNew} style={{float:'right',marginRight:'20px',marginTop:'20px'}}>保存并发布</Button>*/}
- </div>
- </Spin>
- </Form>
- </Modal>
- </div>
- </div>
- );
- }
- })
- );
- export default MemberPowerList;
|