From 58ae2ba21efcd85df331cf996a94038a77302b51 Mon Sep 17 00:00:00 2001 From: Mr Ke <kelq@hugeinfo.com.cn> Date: Wed, 27 May 2020 17:07:48 +0800 Subject: [PATCH] 修改报错问题 --- SunshineIns/src/page/ApplyFor.jsx | 137 +++++++++++++++++++++++++++++---------------- 1 files changed, 87 insertions(+), 50 deletions(-) diff --git a/SunshineIns/src/page/ApplyFor.jsx b/SunshineIns/src/page/ApplyFor.jsx index 43d5dc3..cb266ae 100644 --- a/SunshineIns/src/page/ApplyFor.jsx +++ b/SunshineIns/src/page/ApplyFor.jsx @@ -2,10 +2,11 @@ import HeadView from '../view/HeadView'; import TableBtnView from '../view/TableBtnView'; +import CommonSearchForm from '../view/CommonSearchForm'; +import TableView from '../view/TableView'; import { Input, Button, DatePicker, Divider, message, Popconfirm, Select, Badge, Tooltip } from 'antd'; import moment from 'moment'; import Fetch from '../fetch'; -import TableView from '../view/TableView'; const Option = Select.Option; function typeOfName(type) { switch (type) { @@ -17,15 +18,27 @@ return "已反馈"; } } + +const activityStatusIds = { + 1: '待处理', + 2: '已受理', + 3: '已反馈', +} + +const activityStatusList = [ + 1, + 2, + 3, +] export default class ApplyFor extends React.Component { constructor(props) { super(props); this.state = { data: [], - formdata: { + formData: { + __key: Date.now(), page: 1, size: 10, - type:1, }, resetKey: Date.now(), loading: false @@ -38,10 +51,20 @@ this.getData(); } - getData = () => { - const { formdata } = this.state; + setFormData = data => { + console.log('form', data); + this.setState({ + formData: data, + }); + } + + searchonClick = data => { + console.log('form', data); + this.setState({ + formData: data, + }); this.setState({ loading: true }) - Fetch.entryQuery({ ...formdata }) + Fetch.entryQuery({ ...data, type: 1 }) .then(res => { console.log(res) for (var i = 0; i < res.rows.length; i++) { @@ -49,7 +72,22 @@ } this.setState({ data: res.rows, - loading:false + loading: false + }); + }); + } + + getData = () => { + this.setState({ loading: true }) + Fetch.entryQuery({ ...this.state.formData, type: 1 }) + .then(res => { + console.log(res) + for (var i = 0; i < res.rows.length; i++) { + res.rows[i]['index'] = i + 1; + } + this.setState({ + data: res.rows, + loading: false }); }); } @@ -85,10 +123,9 @@ } confirm = (e) => { - console.log(e); this.setState({ loading: true }) - Fetch.socialDelete(e).then(res => { - if (res.code == 0) { + Fetch.entryDelete(e).then(res => { + if (res.statuscode == 1) { console.log(res) this.setState({ loading: false }) message.success('删除成功'); @@ -130,55 +167,55 @@ render: (text, record) => ( <span> <a onClick={() => this.showModal(record.id)}>详情</a> - <Divider type="vertical" /> - <Popconfirm - title="确认删除任务吗?" - id={record.id} - onConfirm={e => this.confirm(record.id)} - okText="确定" - cancelText="取消" - > - <a href="#">删除</a> - </Popconfirm> + { + record.status == 1 ? + <React.Fragment> + <Divider type="vertical" /> + <Popconfirm + title="确认删除申请吗?" + id={record.id} + onConfirm={e => this.confirm(record.id)} + okText="确定" + cancelText="取消" + > + <a href="#">删除</a> + </Popconfirm> + </React.Fragment> : '' + } </span> ), }]; - const { data, loading, resetKey } = this.state; + const { data, loading, resetKey, formData } = this.state; return ( <div className="app-page"> <HeadView history={this.props.history} /> <div style={{ marginLeft: '90%', marginBottom: '20px', marginTop: '20px' }}> <Button type="primary" size='large' onClick={() => this.showModal('new')}>添加申请</Button> </div> - {/* <Breadcrumb style={{ padding: '20px' }}> - <Breadcrumb.Item><a href="">后台中心</a></Breadcrumb.Item> - <Breadcrumb.Item>社会关护</Breadcrumb.Item> - </Breadcrumb> */} - <TableBtnView name={''} key={resetKey}> - <Select - style={{ width: 200 }} - placeholder="根据举报性质查询" - onChange={(value) => this.onInputChange({ target: { name: 'nature', value } })} - > - <Option value="1">涉黑涉恶违法犯罪行为</Option> - <Option value="2">涉黑涉恶违法犯罪保护伞</Option> - <Option value="3">其他</Option> - </Select> - <Input placeholder="根据内容模糊查询" style={{ width: "200px" }} name='content' onChange={this.onInputChange} /> - <Select - style={{ width: 200 }} - placeholder="根据状态查询" - onChange={(value) => this.onInputChange({ target: { name: 'status', value } })} - > - <Option value="2">已回复</Option> - <Option value="1">待回复</Option> - </Select> - - <DatePicker onChange={(_, value) => this.onInputChange({ target: { name: 'createTime', value } })} placeholder="根据创建时间查询" /> - <Button type="primary" onClick={this.Seaech}>查询</Button> - <Button onClick={this.Reset}>重置</Button> - </TableBtnView> - <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} /> + <div style={{ background: '#fff', margin: 20 }}> + <CommonSearchForm + {...this.props} + formData={formData} + setFormData={this.setFormData} + searchonClick={this.searchonClick} + pathName={this.props.location.pathname} + data={[ + { + type: 'select', name: '状态', label: '活动状态', key: 'status', list: activityStatusList.map(key => ({ + id: key, + name: activityStatusIds[key] + })), + }, + { + type: 'rangePicker', + label: '申请时间', + name: JSON.stringify(['开始时间', '结束时间']), + key: JSON.stringify(['startTime', 'endTime']), + keylistName: 'rangeTimelist', + }, + ]} /> + <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} /> + </div> </div> ); } -- Gitblit v1.8.0