提交 cc838bc6 authored 作者: 徐立's avatar 徐立

合并

/***
* 批量审核
* 2020年5月7日 09:53:12
* 钟是志
*
* */
import React, {Component} from 'react';
import AuditPage from './index';
export default class BatchAudit extends Component{
constructor(props) {
super(props);
}
render() {
return(
<AuditPage {...this.props}
hasBatchAudit={true}
/>
)
}
}
...@@ -58,7 +58,7 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -58,7 +58,7 @@ class ListWithAddEditTemplate extends React.Component {
isAdd: false, // 是新增还是编辑 isAdd: false, // 是新增还是编辑
selectedRows: [], selectedRows: [],
primaryKey: null, primaryKey: null,
showEdit: false, // 是否显示编辑区域 // showEdit: false, // 是否显示编辑区域
pageData: { pageData: {
list: [], list: [],
pagination: {}, pagination: {},
...@@ -114,12 +114,12 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -114,12 +114,12 @@ class ListWithAddEditTemplate extends React.Component {
// 新增按钮事件 // 新增按钮事件
add = () => { add = () => {
const { headerList } = this.state; const { headerList } = this.state;
const showEdit = headerList.length >= 10; // const showEdit = headerList.length >= 10;
this.setState({ this.setState({
modalVisible: !showEdit, modalVisible: true,
formData: {}, formData: {},
isAdd: true, isAdd: true,
showEdit, // showEdit,
}); });
}; };
...@@ -127,18 +127,21 @@ class ListWithAddEditTemplate extends React.Component { ...@@ -127,18 +127,21 @@ class ListWithAddEditTemplate extends React.Component {
modify = record => { modify = record => {
const recordTemp = { ...record, update_time: Date.now() }; const recordTemp = { ...record, update_time: Date.now() };
const { headerList } = this.state; const { headerList } = this.state;
const showEdit = headerList.length >= 10; // const showEdit = headerList.length >= 10;
// 把record里明文key改成转换后的key,用于在模板表单中回显 // 把record里明文key改成转换后的key,用于在模板表单中回显
const headerMap = headerList.reduce((acc, header) => ({ ...acc, [header.name]: header }), {}); const headerMap = headerList.reduce((acc, header) => ({ ...acc, [header.name]: header }), {});
const formData = Object.keys(recordTemp).reduce( const formData = Object.keys(recordTemp).reduce(
(acc, key) => ({ ...acc, [headerMap[key].base52]: recordTemp[key] }), (acc, key) => {
if (!headerMap[key]) return acc;
return { ...acc, [headerMap[key].base52]: recordTemp[key] };
},
{} {}
); );
this.setState({ this.setState({
formData, formData,
modalVisible: !showEdit, modalVisible: true,
isAdd: false, isAdd: false,
showEdit, // showEdit,
}); });
}; };
......
import React from 'react'
import { Upload,message } from 'antd';
import config from '@/config/config'
export default class ImgUploadCom extends React.Component {
constructor(props){
super(props)
const value = props.value
this.state = {
url:value
}
}
triggerChange = (changedValue) => {
// Should provide an event to pass value to Form.
const onChange = this.props.onChange;
if (onChange) {
onChange( changedValue);
}
}
componentWillReceiveProps(nextProps) {
// Should be a controlled component.
if ('value' in nextProps) {
const value = nextProps.value;
this.setState({url:value});
}
}
changeUrl = (info, key) => {
if (info.file.status === 'done') {
message.success(`图片上传成功`);
if (!('value' in this.props)) {
this.setState({url: info.file.response });
}
this.triggerChange(info.file.response);
} else if (info.file.status === 'error') {
message.error(`图片上传失败`);
}
}
changePos=(obj)=>{
if (!('value' in this.props)) {
this.setState({...obj});
}
this.triggerChange({...obj});
}
render() {
const{json,disabled}=this.props
const {url}=this.state
return (
<Upload.Dragger disabled={disabled} accept={"image/*"} url={url} showUploadList={false} name="file" action={config.uploadUrl} onChange={this.changeUrl} multiple={false} style={{ padding: 0 }}>
{url ? <img src={config.httpServer + (url )} style={{ height: json.height, width: json.width }} /> : <div style={{ height: json.height, width: json.width }}>
</div>}
</Upload.Dragger>
);
}
}
\ No newline at end of file
...@@ -64,7 +64,7 @@ export default class MobileDate extends Component { ...@@ -64,7 +64,7 @@ export default class MobileDate extends Component {
} }
render() { render() {
let {dates} = this.state let {dates} = this.state
const {format}=this.props
const startTime=dates.length>0?dates[0].valueOf():null const startTime=dates.length>0?dates[0].valueOf():null
const endTime=dates.length>1?dates[1].valueOf():null const endTime=dates.length>1?dates[1].valueOf():null
...@@ -72,18 +72,20 @@ export default class MobileDate extends Component { ...@@ -72,18 +72,20 @@ export default class MobileDate extends Component {
<div> <div>
<DatePicker <DatePicker
// value={this.state.date} // value={this.state.date}
extra={<span style={{fontSize:14}}>{!!startTime?moment(startTime).format('YYYY-MM-DD HH:mm:ss'):'请选择时间'}</span>} extra={<span style={{fontSize:14}}>{!!startTime?moment(startTime).format(format?format:'YYYY-MM-DD HH:mm:ss'):'请选择时间'}</span>}
locale={{okText:"确定",dismissText:'取消'}} locale={{okText:"确定",dismissText:'取消'}}
value={ !!startTime?new Date(startTime):null} value={ !!startTime?new Date(startTime):null}
format={format?format:'YYYY-MM-DD HH:mm:ss'}
onChange={date => this.handelStartChange(date)} onChange={date => this.handelStartChange(date)}
> >
<List.Item arrow="horizontal">开始时间</List.Item> <List.Item arrow="horizontal">开始时间</List.Item>
</DatePicker> </DatePicker>
<DatePicker <DatePicker
// value={this.state.date} // value={this.state.date}
extra={<span style={{fontSize:14}}>{!!endTime?moment(endTime).format('YYYY-MM-DD HH:mm:ss'):'请选择时间'}</span>} extra={<span style={{fontSize:14}}>{!!endTime?moment(endTime).format(format?format:'YYYY-MM-DD HH:mm:ss'):'请选择时间'}</span>}
value={!!endTime?new Date(endTime):null} value={!!endTime?new Date(endTime):null}
locale={{okText:"确定",dismissText:'取消'}} locale={{okText:"确定",dismissText:'取消'}}
format={format?format:'YYYY-MM-DD HH:mm:ss'}
onChange={date => this.handelEndChange(date)} onChange={date => this.handelEndChange(date)}
> >
<List.Item arrow="horizontal">结束时间</List.Item> <List.Item arrow="horizontal">结束时间</List.Item>
......
...@@ -49,6 +49,7 @@ import TableSelect from '../libs/TableSelect'; ...@@ -49,6 +49,7 @@ import TableSelect from '../libs/TableSelect';
import LocationCom from '../libs/LocationCom' import LocationCom from '../libs/LocationCom'
import MobileDate from '../libs/MobileDate'; import MobileDate from '../libs/MobileDate';
import ChildForm from '../libs/ChildForm'; import ChildForm from '../libs/ChildForm';
import ImgUploadCom from '../libs/ImgUploadCom';
import moment from 'moment'; import moment from 'moment';
import router from 'umi/router'; import router from 'umi/router';
import TableList from '../libs/TableList'; import TableList from '../libs/TableList';
...@@ -116,14 +117,6 @@ const errorHandler = error => { ...@@ -116,14 +117,6 @@ const errorHandler = error => {
} }
}; };
let oldProps = {}
const normFile = (e) => {
console.log(e)
if (Array.isArray(e)) {
return e;
}
return e && e.fileList[0];
}
@connect(({ DataColumn, SqlManageEntity, formList, loading }) => ({ @connect(({ DataColumn, SqlManageEntity, formList, loading }) => ({
DataColumn, SqlManageEntity, formList, DataColumn, SqlManageEntity, formList,
loading: loading.models.DataColumn || loading.models.SqlManageEntity || loading.models.formList loading: loading.models.DataColumn || loading.models.SqlManageEntity || loading.models.formList
...@@ -774,11 +767,11 @@ export default class tableCom extends Component { ...@@ -774,11 +767,11 @@ export default class tableCom extends Component {
} }
reqUtil = (base52, json, orgCallback, url, method, params, callback, options = {}) => { reqUtil = (base52, json, orgCallback, url, method, params, callback, options = {}) => {
//查缓存 //查缓存
var isChange = false; var isChange = true;
if (url.indexOf("http") === -1) { if (url.indexOf("http") === -1) {
url = config.httpServer + url url = config.httpServer + url
} }
const { reqUrls } = this.state const { reqUrls } = this.state
if (reqUrls[url] != null) { if (reqUrls[url] != null) {
const ps = reqUrls[url].params const ps = reqUrls[url].params
...@@ -860,7 +853,7 @@ export default class tableCom extends Component { ...@@ -860,7 +853,7 @@ export default class tableCom extends Component {
} }
return "norefeshxxxxxxxxxxxxxxxxxxxx" return "norefeshxxxxxxxxxxxxxxxxxxxx"
} }
this.setState({ reqUrls }, () => { this.setState({ }, () => {
for (let i in params) { for (let i in params) {
if (params[i] == null) { if (params[i] == null) {
delete params[i] delete params[i]
...@@ -884,10 +877,10 @@ export default class tableCom extends Component { ...@@ -884,10 +877,10 @@ export default class tableCom extends Component {
method: method, method: method,
requestType: "form" requestType: "form"
}).then(data => { }).then(data => {
this.setState({ res: data }, () => { const { reqUrls } = this.state
const { reqUrls } = this.state reqUrls[url].data = data
reqUrls[url].data = data this.setState({ res: data,reqUrls }, () => {
this.setState({ reqUrls })
if (callback) { if (callback) {
if (json.optionType && json.optionType == "func") { if (json.optionType && json.optionType == "func") {
...@@ -1471,16 +1464,7 @@ export default class tableCom extends Component { ...@@ -1471,16 +1464,7 @@ export default class tableCom extends Component {
return dataColumn; return dataColumn;
}; };
changeUrl = (info, key) => {
if (info.file.status === 'done') {
message.success(`图片上传成功`);
this.setState({ url: info.file.response })
} else if (info.file.status === 'error') {
message.error(`图片上传失败`);
}
}
render() { render() {
/** /**
* json为申请表单 * json为申请表单
...@@ -1933,19 +1917,14 @@ export default class tableCom extends Component { ...@@ -1933,19 +1917,14 @@ export default class tableCom extends Component {
if (end != null) ivs.push(moment(parseInt(init[end.base52]))); if (end != null) ivs.push(moment(parseInt(init[end.base52])));
} }
if (begin != null && end != null) { if (begin != null && end != null) {
if (!isEdit) {
r:
cm = <span> cm = <span>
{moment(parseInt(obj[begin.base52])).format(json.format ? json.format : 'YYYY-MM-DD HH:mm:ss')}{' '} {moment(parseInt(obj[begin.base52])).format(json.format ? json.format : 'YYYY-MM-DD HH:mm:ss')}{' '}
{moment(parseInt(obj[end.base52])).format(json.format ? json.format : 'YYYY-MM-DD HH:mm:ss')} {moment(parseInt(obj[end.base52])).format(json.format ? json.format : 'YYYY-MM-DD HH:mm:ss')}
</span> </span>
} else {
cm = getFieldDecorator(begin.base52 + '_' + end.base52, {
initialValue: ivs,
rules: [{ required: required, message: '请选择起止时间' }],
})(<RangePicker showTime />);
}
} else { } else {
cm = "" cm = ""
} }
...@@ -2545,7 +2524,7 @@ export default class tableCom extends Component { ...@@ -2545,7 +2524,7 @@ export default class tableCom extends Component {
cm = getFieldDecorator(begin.base52 + '$' + end.base52, { cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
initialValue: ivs, initialValue: ivs,
rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }], rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
})(<MobileDate disabled={disabled} />); })(<MobileDate disabled={disabled} formate={json.format}/>);
if (json.isLabel && title) { if (json.isLabel && title) {
cm = <Form.Item cm = <Form.Item
labelCol={{ span: json.labelSpan }} labelCol={{ span: json.labelSpan }}
...@@ -2560,7 +2539,7 @@ export default class tableCom extends Component { ...@@ -2560,7 +2539,7 @@ export default class tableCom extends Component {
cm = getFieldDecorator(begin.base52 + '$' + end.base52, { cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
initialValue: ivs, initialValue: ivs,
rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }], rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
})(<RangePicker showTime disabled={disabled} />); })(<RangePicker showTime={json.showTime!=null?json.showTime:true} format={json.format?json.format:"YYYY-MM-DD HH:mm:ss"} disabled={disabled} />);
} }
if (json.label == null) title = '起止时间'; if (json.label == null) title = '起止时间';
break; break;
...@@ -2612,7 +2591,7 @@ export default class tableCom extends Component { ...@@ -2612,7 +2591,7 @@ export default class tableCom extends Component {
rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }], rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
})(<DatePicker })(<DatePicker
disabled={disabled} disabled={disabled}
showTime showTime={json.showTime!=null?json.showTime:true}
onOpenChange={get === 'mobile' ? () => { // 取消唤起移动端小键盘 onOpenChange={get === 'mobile' ? () => { // 取消唤起移动端小键盘
setTimeout(() => { setTimeout(() => {
if (document.querySelector('.ant-calendar-input ')) { if (document.querySelector('.ant-calendar-input ')) {
...@@ -2712,33 +2691,10 @@ export default class tableCom extends Component { ...@@ -2712,33 +2691,10 @@ export default class tableCom extends Component {
} }
break; break;
case 'ImgUploadCom': case 'ImgUploadCom':
cm = getFieldDecorator("img$" + dataColumn.base52, {
valuePropName: 'fileList[0]', cm = getFieldDecorator(dataColumn.base52, {
getValueFromEvent: normFile, initialValue: initValue,
})( })(<ImgUploadCom json={json} disabled={disabled}/>);
<Upload.Dragger
disabled={disabled}
accept={"image/*"}
url={this.state.url || initValue}
showUploadList={false}
name="file"
action={config.uploadUrl}
onChange={info => this.changeUrl(info, dataColumn.base52)}
multiple={false}
style={{ padding: 0 }}>
{this.state.url || initValue ?
<img
src={config.httpServer + (this.state.url || initValue)}
style={{ height: json.height, width: json.width }} />
: <div
style={{
height: json.height,
width: json.width }}>
</div>}
</Upload.Dragger>
);
if (get === 'mobile' && json.isLabel && title) { if (get === 'mobile' && json.isLabel && title) {
cm = <Form.Item cm = <Form.Item
labelCol={{ span: json.labelSpan }} labelCol={{ span: json.labelSpan }}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论