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

解决冲突

......@@ -9,10 +9,9 @@ import { message } from 'antd';
import React, { Fragment } from 'react';
import * as service from '../publicApiService';
import * as destructionFunc from '../destruction';
import { Link, hashHistory } from 'dva/router';
import { getDefaultValues } from '../destruction';
import { Link } from 'dva/router';
import { getApplyPage } from '../publicApiService';
import { getHuanGeToken } from '@/utils/authority';
import { getToken } from '@/utils/authority';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import List from './List';
......@@ -20,12 +19,12 @@ import pageSetting from './pageSetting';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '@/baseComponent/Shell';
import config from '@/config/config';
// import test from './2333';
export default class AffairPage extends React.Component {
constructor(props) {
super(props);
// const idObj = service.getId();
let pathname = this.props.location.pathname;
const idObj = service.getId(pathname);
if (!idObj) {
message.error('没有配置数据id,无法使用该功能');
}
......@@ -122,7 +121,7 @@ export default class AffairPage extends React.Component {
};
componentDidMount() {
if (!getHuanGeToken()) {
if (!getToken()) {
message.error('您的数据未同步,请联系管理员!');
return false;
}
......@@ -145,7 +144,7 @@ export default class AffairPage extends React.Component {
this.ListComponent.getPage();
});
}
if(event.data.indexOf('iframeHeight') > -1){
if (event.data.indexOf('iframeHeight') > -1) {
let height = Number(event.data.split('-')[1]);
document.getElementById('applyIframeId').height = height;
}
......@@ -157,8 +156,8 @@ export default class AffairPage extends React.Component {
render() {
const { workId, dataBaseId, addFields, showIframe } = this.state;
const url = config.onestopPC.split('/#/');
let iframeUrl = `${url[0]}/#/IFrameForApply?id=${workId}&token=${getHuanGeToken()}`;
// iframeUrl = `http://localhost:8000/onestop/IFrameForApply?id=${workId}&token=${getHuanGeToken()}`;
let iframeUrl = `${url[0]}/#/IFrameForApply?id=${workId}&token=${getToken()}`;
// iframeUrl = `http://localhost:8000/onestop/IFrameForApply?id=${workId}&token=${getHuanGeToken()}`;
return (
<PageHeaderWrapper title="">
<div style={{
......
......@@ -6,7 +6,7 @@ import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import List from '../ApplyPage/List';
import ListTab from './ListTab';
import { deepCopy } from '@/baseComponent/utils';
import { getApplyPage, getHandledPage, getWaitPage } from '@/pages/App/FormInsertDiy/AffairPage/publicApiService';
import { getApplyPage, getHandledPage, getWaitPage } from '../publicApiService';
export default class AuditPage extends Component {
constructor(props) {
......
......@@ -7,9 +7,9 @@ import * as services from '@/highOrderComponent/Service';
import StandardTable from '@/components/StandardTable';
import PropTypes from 'prop-types';
import { deepCopy } from '@/baseComponent/utils';
import { date, format, text } from '@/pages/App/FormInsertDiy/config';
import { date, format, text } from '../../config';
import moment from 'moment';
import { handleAudit } from '@/pages/App/FormInsertDiy/AffairPage/publicApiService';
import { handleAudit } from '../publicApiService';
import { Tooltip } from 'antd';
export default class List extends Component {
......
......@@ -5,17 +5,18 @@
*
* */
import { Row, Col, message } from 'antd';
import React, { Fragment } from 'react';
import { message } from 'antd';
import React, { } from 'react';
import * as service from '../publicApiService';
import AuditPage from './AuditPage';
import * as destructionFunc from '../destruction';
import { Link ,hashHistory} from 'dva/router';
import { Link } from 'dva/router';
export default class Index extends React.Component {
constructor(props) {
super(props);
// const idObj = service.getId();
let pathname = this.props.location.pathname;
const idObj = service.getId(pathname);
if (!idObj) {
message.error('没有配置数据id,无法使用该功能');
}
......
......@@ -11,11 +11,10 @@ import ButtonDiy from '@/baseComponent/ButtonDiy';
import ModalDiy from '@/baseComponent/ModalDiy';
import React, { Component, Fragment } from 'react';
import { deepCopy, } from '@/baseComponent/utils';
import { mustHaveValue } from '../../config/index';
import { mustHaveValue, transLateTimeTOUnix } from '../../config/index';
import { message } from 'antd';
import PropTypes from 'prop-types';
import { startProcess } from '../publicApiService';
import { transLateTimeTOUnix } from '@/pages/App/FormInsertDiy/config';
import FormArray from '../component/FormArray';
export default class ModalForm extends Component {
......
import ButtonDiy from '@/baseComponent/ButtonDiy';
import React, { Component, Fragment } from 'react';
/*
import ExportInfo from '@/components/App/ExportInfo';
import ImportUtil from '@/components/App/ImportUtil';
import ModalDelete from './ModalDelete';
import ModalConfirm from './ModalConfirm';
*/
import ModalBatch from './ModalBatch';
import ModalForm from './ModalForm';
......@@ -24,31 +18,6 @@ export default class ButtonListDom extends Component {
getPage={getPage}
selectRows={selectRows}
/>;
/* case 'ModalDelete': // 删除按钮
return <ModalDelete {...item}
key={item.type}
getPage={getPage}
selectRows={selectRows}
/>;
case 'ImportUtil': // 导入
return <ImportUtil {...item.props}
key={item.type}
callback={() => getPage()}
/>;
case 'ExportInfo': // 导出
return <ExportInfo {...item.props}
key={item.type}
/>;
case 'ModalConfirm': // 一般按钮 点击后弹出是否确定的 Modal Info
return <ModalConfirm key={item.type}
{...item}
getPage={getPage}
listData={listData}
formValues={formValues}
search={search}
selectRows={selectRows}/>;
*/
case 'ModalBatch': // 一般按钮 点击后弹出 填写一些类似 审核理由 意见之类的信息
return <ModalBatch key={item.type}
{...item}
......
import React, { Fragment, Component } from 'react';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import Shell from '@/baseComponent/Shell';
import BlockTitle from '@/baseComponent/BlockTitle';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import router from 'umi/router';
import FormArray from './component/FormArray';
import { getDetailInfo, handleAudit } from '@/pages/App/FormInsertDiy/AffairPage/publicApiService';
import { isJSON } from '@/baseComponent/utils';
import { Col, Row, Timeline, Icon, Tabs } from 'antd';
import ModalBatch from './ButtonListDom/ModalBatch';
import FlowImg from './component/FlowImg';
import { getHuanGeToken } from '@/utils/authority';
import { getToken } from '@/utils/authority';
import config from '@/config/config';
const { TabPane } = Tabs;
/*
export default class Detail extends Component {
/!**
* workId,dataBaseId,record,addFields
* *!/
constructor(props) {
super(props);
this.state = {
detailInfo: {
content: {},
taskInfo: [],
},
show: false,
};
}
componentDidMount() {
const { state } = this.props.location;
const { record } = state;
getDetailInfo(record.id).then((x) => {
if (x) {
if (isJSON(x.content)) {
x.content = JSON.parse(x.content);
}
if(typeof x.content === 'object' && x.content.defaultValues){
for(let z in x.content.defaultValues){
x.content = {
...x.content,
...x.content.defaultValues[z],
}
} }
this.setState({
detailInfo: x,
show: true,
});
}
});
}
buttonDom = () => {
const { detailInfo } = this.state;
const { btns } = detailInfo;
let res = [];
if(typeof btns !== 'undefined' && Array.isArray(btns)){
for(let z of btns){
res.push(
{
type: z.name,
name: z.name,
component: 'ModalBatch',
className: z.name !== '通过' ? 'defaultRed' : 'defaultBlue',
nameSpan: { big: 4, small: 5 },
fileSpan: { big: 1, small: 1 },
values: {
[z.key]: z.value,
},
fields: [
{
key: 'reason',
name: '审核意见',
type: 'textarea',
},
],
beforeSubmit: (props, formValues) => {
return {
taskForm : {},
examineMap: JSON.stringify(formValues),
};
},
sourceKey: 'taskId',
postKey: 'taskIds',
apiServiceApi: handleAudit,
}
)
}
return res;
}
return [];
};
render() {
const { state } = this.props.location;
const { record, addFields, workId } = state;
const { detailInfo, show } = this.state;
const Btns = this.buttonDom();
const dot1 = <Icon type={'check-circle'}
style={{ fontSize: '16px', color: 'rgb(82, 196, 26)' }}/>;
const dot2 = <Icon type={'clock-circle-o'}
style={{ fontSize: '16px', color: 'red' }}/>;
if(!show){
return null;
}
return (<PageHeaderWrapper title="">
<Shell>
<div style={{ height: '54px', padding: '12px 0 12px 12px' }}>
<ButtonDiy name="返回"
className="defaultBlue"
icon="arrow-left"
handleClick={() => {
router.goBack();
}}
/>
{
Btns.map((item)=>{
return <ModalBatch key={item.type}
{...item}
handleSelectRows={()=>{console.log('清空')}}
getPage={()=>{router.goBack()}}
selectRows={[record]}/>
})
}
</div>
</Shell>
<Shell>
<BlockTitle
isSmall={true}
title={'申请信息'}
/>
<Row>
<Col span={20}>
<FormArray config={addFields}
value={detailInfo.content}
changeValue={() => {
console.log(xxx);
}}
disabled={true}
readOnly={true}
fileSpan={{ big: 2, small: 2 }}
nameSpan={{ big: 6, small: 7 }}
/>
</Col>
</Row>
</Shell>
<Shell>
<Tabs>
<TabPane tab={'审批状态'} key={'1'}>
<Row>
<Col span={16} offset={2} style={{paddingTop: '30px', paddingBottom: '30px'}}>
<Timeline>
{
detailInfo.taskInfo.map((item) => {
let reason = item.respdesc;
if(item.taskVariable && item.taskVariable.reason){
reason = item.taskVariable.reason;
}
return (
<Timeline.Item dot={item.endTime ? dot1 : dot2}
key={item.id}
>
{item.assignee ? <p><b>{item.assignee}</b></p> : <p>&nbsp; </p>}
<p>审批流程: {item.name}</p>
<p>审批状态: {item.status}</p>
<p>审批原因: {reason}</p>
</Timeline.Item>
);
})
}
</Timeline>
</Col>
</Row>
</TabPane>
<TabPane tab={'流程图'} key={'2'}>
<FlowImg id={workId}/>
</TabPane>
</Tabs>
</Shell>
</PageHeaderWrapper>)
;
}
}*/
export default class Detail extends Component{
constructor(props){
......@@ -221,7 +39,7 @@ export default class Detail extends Component{
render(){
const { id, showAll } = this.state;
const url = config.onestopPC.split('/#/');
let iframeUrl = `${url[0]}/#/IframeForDetail?id=${id}&token=${getHuanGeToken()}`;
let iframeUrl = `${url[0]}/#/IframeForDetail?id=${id}&token=${getToken()}`;
// iframeUrl = `http://localhost:8000/onestop/IframeForDetail?id=${id}&token=${getHuanGeToken()}`;
return (
<PageHeaderWrapper title="">
......
......@@ -9,7 +9,7 @@ import { apiRequest } from '../request';
import { getFormArrayConfig } from '../config/index';
import { setHuanGeToken } from '@/utils/authority';
import { isJSON } from '@/baseComponent/utils';
import config from '@/config/config';
const giveValue = (x) => {
if(x && x.rows){
......@@ -42,19 +42,15 @@ const getOtherToken = () => {
}
};
const getId = () => { // 获取流程引擎 事务workId 和表dataBaseId
let path = window.location.href;
path = path.split('/');
// let idObj = config[path.pop()];
let idObj;
const getId = (pathname) => { // 获取流程引擎 事务workId 和表dataBaseId
let idObj = config.twOneStopConfig[pathname]; // 路由 /tw/Pjpy/YXTYSBB/Apply
if (typeof idObj === 'undefined') {
console.error('没有找到对应的流程引擎id');
return false;
} else {
const { dataBaseId, workId } = idObj;
return {
dataBaseId,
workId,
dataBaseId: idObj.id,
workId: idObj.id,
};
}
};
......
......@@ -11,6 +11,10 @@ let ApplyPage = ({ id, form }) => {
function submitCb(res) {
ModalInfo(`提交${res ? '成功' : '失败'}!`, {onOk: () => router.goBack()});
}
function saveDraftCb(res) {
ModalInfo(`提交${res ? '成功' : '失败'}!`, {onOk: () => router.goBack()});
}
return (
<Shell styleShell={{ marginTop: 0 }}>
<Entrance id={id} isCg="false" get="web" form={form} />
......@@ -22,6 +26,7 @@ let ApplyPage = ({ id, form }) => {
openDraftButton
DraftButtonText="暂存"
callback={submitCb}
draftCallback={saveDraftCb}
/>
</div>
</Shell>
......
......@@ -82,7 +82,7 @@ function AuditButton(props) {
}
function showModal(str, key, value) {
setModalContent(`确定审核${str}吗?`);
setModalContent(`确定${str}吗?`);
setAffairParams({ oldKey: key, btnValue: value });
setVisible(true);
}
......
......@@ -5,7 +5,7 @@ import { ModalInfo } from '@/baseComponent/Modal';
import React, { useState, useEffect } from 'react';
import { getHistoryFormDetail } from '../../Services';
import withGoBack from '@/highOrderComponent/withGoBack';
import HistoryForm from '@/webPublic/one_stop_public/Entrance/historyForm';
import HistoryForm from '@/webPublic/FormInsertDiy/HistoryForm';
import AuditButton from '../AuditButton';
import styles from '../RenderForm/index.less';
......
import React, { Fragment } from 'react';
import {
Button,
Card, Col,
Form, message, Row,
} from 'antd';
import { connect } from 'dva';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import moment from 'moment';
import router from 'umi/router';
import { text, number, date, getFormArrayConfig } from '../config/index';
import FormArray from '../AffairPage/component/FormArray';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '../Shell';
@connect(({ formList, loading }) => ({
formList,
}))
@Form.create()
class Edit extends React.Component {
state = {
modalVisible: false,
formData: {},
formItem: [],
isAdd: false,
objId: this.props.id,
recordId: this.props.recordId,
recordKey: this.props.recordKey,
};
columns = [];
//渲染值
componentDidMount() {
const { dispatch } = this.props;
const { objId, recordKey, recordId } = this.state;
dispatch({
type: 'formList/getHead',
payload: { dataObjId: objId },
callback: (dates) => {
if (dates) {
this.setState({
formItem: dates,
});
}
},
});
//渲染表单字段
if (recordId != null) {
dispatch({
type: 'formList/getDetail',
payload: {
dataObjId: objId,
key: recordKey,
value: recordId,
},
callback: (res) => {
if (res) {
this.setState({
formData: res,
});
}
},
});
this.setState({
isAdd: false,
})
}else{
this.setState({
isAdd: true,
})
}
}
onSubmit = () => {
//router.goBack();
const { isAdd, objId, formData } = this.state;
let payload = {
params: {...formData},
objId,
isAdd,
};
this.props.dispatch({
type: 'formList/add',
payload,
callback: () => {
message.success('操作成功');
this.props.returnThis();
},
});
};
goBack = () => {
this.props.returnThis();
};
changeFormData = (value, key) => {
let oldValue = this.state.formData;
oldValue[key] = value;
this.setState({
formData: oldValue,
});
};
render() {
let { formItem, formData } = this.state;
let formConfig = getFormArrayConfig(formItem);
return (
<Shell>
<Row>
<FormArray
config={formConfig}
nameSpan={{ big: 10, small: 12 }}
fileSpan={{ big: 4, small: 3 }}
value={formData}
changeValue={this.changeFormData}
/>
<Col span={24}
style={{ textAlign: 'center', paddingTop: '200px', paddingBottom: '50px' }}>
<ButtonDiy
className={'primaryBlue'}
handleClick={this.onSubmit}
name={'保存'}
/>
<ButtonDiy
className={'defaultRed'}
handleClick={this.goBack}
name={'返回'}
/>
</Col>
</Row>
</Shell>
);
}
}
export default Edit;
// import React, { Fragment } from 'react';
// import {
// Button,
// Card, Col,
// Form, message, Row,
// } from 'antd';
// import { connect } from 'dva';
// import PageHeaderWrapper from '@/components/PageHeaderWrapper';
// import moment from 'moment';
// import router from 'umi/router';
// import { text, number, date, getFormArrayConfig } from '../config/index';
// import FormArray from '../AffairPage/component/FormArray';
// import ButtonDiy from '@/baseComponent/ButtonDiy';
// import Shell from '../Shell';
//
//
// @connect(({ formList, loading }) => ({
// formList,
// }))
// @Form.create()
// class Edit extends React.Component {
//
// state = {
// modalVisible: false,
// formData: {},
// formItem: [],
// isAdd: false,
// objId: this.props.id,
// recordId: this.props.recordId,
// recordKey: this.props.recordKey,
// };
// columns = [];
//
// //渲染值
// componentDidMount() {
// const { dispatch } = this.props;
// const { objId, recordKey, recordId } = this.state;
// dispatch({
// type: 'formList/getHead',
// payload: { dataObjId: objId },
// callback: (dates) => {
// if (dates) {
// this.setState({
// formItem: dates,
// });
// }
// },
// });
// //渲染表单字段
// if (recordId != null) {
// dispatch({
// type: 'formList/getDetail',
// payload: {
// dataObjId: objId,
// key: recordKey,
// value: recordId,
// },
// callback: (res) => {
// if (res) {
// this.setState({
// formData: res,
// });
// }
// },
// });
// this.setState({
// isAdd: false,
// })
// }else{
// this.setState({
// isAdd: true,
// })
// }
// }
//
// onSubmit = () => {
// //router.goBack();
// const { isAdd, objId, formData } = this.state;
// let payload = {
// params: {...formData},
// objId,
// isAdd,
// };
// this.props.dispatch({
// type: 'formList/add',
// payload,
// callback: () => {
// message.success('操作成功');
// this.props.returnThis();
// },
// });
// };
//
// goBack = () => {
// this.props.returnThis();
// };
//
// changeFormData = (value, key) => {
// let oldValue = this.state.formData;
// oldValue[key] = value;
// this.setState({
// formData: oldValue,
// });
// };
//
// render() {
// let { formItem, formData } = this.state;
// let formConfig = getFormArrayConfig(formItem);
// return (
// <Shell>
// <Row>
// <FormArray
// config={formConfig}
// nameSpan={{ big: 10, small: 12 }}
// fileSpan={{ big: 4, small: 3 }}
// value={formData}
// changeValue={this.changeFormData}
// />
// <Col span={24}
// style={{ textAlign: 'center', paddingTop: '200px', paddingBottom: '50px' }}>
//
// <ButtonDiy
// className={'primaryBlue'}
// handleClick={this.onSubmit}
// name={'保存'}
// />
// <ButtonDiy
// className={'defaultRed'}
// handleClick={this.goBack}
// name={'返回'}
// />
// </Col>
// </Row>
// </Shell>
// );
// }
// }
//
// export default Edit;
import fetch from 'dva/fetch';
import React from 'react';
import ReactDOM from 'react-dom';
import { Select, Button, Modal, Input, Transfer, Row, Col, Form, message, notification } from 'antd';
import { connect } from 'dva';
import { getToken } from '@/utils/authority';
import config from '@/config/config';
import QueryItem from './QueryItem';
import OrderItem from './OrderItem';
import FormdataWrapper from '@/utils/object-to-formdata-custom';
const Option = Select.Option;
let keyX = 1;
function swapArray(arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
}
const FormItem = Form.Item;
@connect(({ DataObj, loading }) => ({
DataObj,
loading: loading.models.DataObj,
}))
@Form.create()
export default class Index extends React.Component {
constructor(props) {
super(props);
this.state = {
visiable: false,
queryVisiable: false,
groupVisiable: false,
sortVisiable: false,
currentQueryKey: null,
currentGroupKey: null,
orderVisiable: false,
currentOrderKey: null,
querys: [],
orders: [],
groups: [],
gs: [],
os: [],
qs: [],
mockData: [],
targetKeys: [],
sourceSelectedKeys: [],
targetSelectedKeys: [],
infos: {},
confirmLoading: false,
};
}
onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
this.setState({ sourceSelectedKeys, targetSelectedKeys });
};
deleteQuery = (i) => {
const querys = this.state.querys;
querys.splice(i, 1);
this.setState({ querys });
};
deleteOrder = (i) => {
const orders = this.state.orders;
orders.splice(i, 1);
this.setState({ orders });
};
deleteGroup = (i) => {
const groups = this.state.groups;
groups.splice(i, 1);
this.setState({ groups });
};
open = () => {
const { dispatch } = this.props;
dispatch({
type: 'DataObj/getExportInfo',
payload: {
objId: this.props.objId,
},
callback: (infos) => {
const mockData = [];
const qs = [];
const gs = [];
const os = [];
for (var key in infos) {
const x = infos[key];
mockData.push({
key: x.field,
title: x.name,
chosen: false,
});
if (x.canQuery) {
qs.push(x);
}
if (x.canGroup) {
gs.push(x);
}
if (x.canOrder) {
os.push(x);
}
}
this.setState({
mockData, infos, visiable: true, qs, gs, os,
});
},
});
};
onCancle = () => {
this.setState({ visiable: false });
};
handleChange = (targetKeys, direction, moveKeys) => {
this.setState({ targetKeys });
};
up = () => {
keyX = keyX + 1;
var { targetKeys, targetSelectedKeys } = this.state;
for (var i = 0; i < targetKeys.length; i++) {
if (targetKeys[i] === targetSelectedKeys[0]) {
if (i === 0) return;
targetKeys = swapArray(targetKeys, i, i - 1);
break;
}
}
this.setState({ targetKeys });
};
down = () => {
keyX = keyX + 1;
var { targetKeys, targetSelectedKeys } = this.state;
for (var i = 0; i < targetKeys.length; i++) {
if (targetKeys[i] === targetSelectedKeys[0]) {
if (i === targetKeys.length - 1) return;
targetKeys = swapArray(targetKeys, i, i + 1);
break;
}
}
this.setState({ targetKeys });
};
bottom = () => {
keyX = keyX + 1;
const { targetKeys, targetSelectedKeys } = this.state;
var x = [];
for (var i = 0; i < targetKeys.length; i++) {
if (!targetSelectedKeys.includes(targetKeys[i])) {
x.push(targetKeys[i]);
}
}
x = [...x, ...targetSelectedKeys];
this.setState({ targetKeys: x });
};
top = () => {
keyX = keyX + 1;
const { targetKeys, targetSelectedKeys } = this.state;
const x = [...targetSelectedKeys];
for (var i = 0; i < targetKeys.length; i++) {
if (!targetSelectedKeys.includes(targetKeys[i])) {
x.push(targetKeys[i]);
}
}
this.setState({ targetKeys: x });
};
renderItem = (item) => {
if (this.state.targetKeys.includes(item.key)) {
const customLabel = (
<span className="custom-item" key={item.key}>
{item.title}
</span>
);
return {
label: customLabel, // for displayed item
value: item.title, // for title and filter matching
};
} else {
const customLabel = (
<span className="custom-item" key={item.key}>
{item.title}
</span>
);
return {
label: customLabel, // for displayed item
value: item.title, // for title and filter matching
};
}
};
addOrder = () => {
this.setState({ orderVisiable: true });
};
okOrder = () => {
const orders = this.state.orders;
orders.push(this.state.infos[this.state.currentOrderKey]);
this.setState({ orders, orderVisiable: false, currentOrderKey: null });
};
okGroup = () => {
const groups = this.state.groups;
groups.push(this.state.infos[this.state.currentGroupKey]);
this.setState({ groups, groupVisiable: false, currentGroupKey: null });
};
addGroup = () => {
this.setState({ groupVisiable: true });
};
addQuery = () => {
this.setState({ queryVisiable: true });
};
okQuery = () => {
const querys = this.state.querys;
querys.push(this.state.infos[this.state.currentQueryKey]);
this.setState({ querys, queryVisiable: false, currentQueryKey: null });
};
export = () => {
this.props.form.validateFields((err, fieldsValue) => {
if (err) return;
//form.resetFields();
var qqs;
if (this.props.mustQuerys != null) {
qqs = [...this.props.mustQuerys];
} else {
qqs = [];
}
const oos = [];
const ggs = [];
for (let key in fieldsValue) {
var x = key.indexOf('__');
let kk = key.substr(x + 2);
if (key.indexOf('q__') > -1) {
qqs.push({
notes: this.state.infos[kk].notes,
hql: this.state.infos[kk].hql,
c: this.state.infos[kk].type,
x: fieldsValue[key].stringX,
v: fieldsValue[key].string,
});
} else if (key.indexOf('o__') > -1) {
oos.push({ hql: this.state.infos[kk].hql, x: fieldsValue[key].stringX });
} else if (key.indexOf('g__') > -1) {
ggs.push({ hql: this.state.infos[kk].hql });
}
}
if (this.props.voClass && ggs.length === 0) {
message.error('请至少选择一个聚合条件');
return;
}
if (this.state.targetKeys.length === 0) {
message.error('请至少选择一个导出字段');
return;
}
const names = [];
for (let i = 0; i < this.state.targetKeys.length; i++) {
names.push(this.state.infos[this.state.targetKeys[i]].name);
}
let divElement = document.getElementById('downloadDiv');
console.log(config.sqlFormsServer);
let downloadUrl = config.sqlFormsServer + '/DataObjApi/exportFormData?';
const token = getToken() != null && getToken() != 'null' ? getToken() : '0000';
downloadUrl = `${downloadUrl}token=${token}`;
let param = {
fields: this.state.targetKeys,
names: names,
beanName: this.props.beanName,
querys: JSON.stringify(qqs),
orders: JSON.stringify(oos),
groups: JSON.stringify(ggs),
voClass: this.props.voClass,
objId:this.props.objId,
modelClass: this.props.modelClass,
preHandleClass: this.props.preHandleClass,
hqlHandleClass: this.props.hqlHandleClass,
};
param = {...param, ...this.props.params || {}}
this.downloadFile(downloadUrl, param);
});
};
downloadFile(url, params) {
this.setState({ confirmLoading: true });
fetch(url, {
method: 'POST',
body: FormdataWrapper(params),
}).then(res => {
if (res.status != '200') {
return res.json();
} else {
return res.blob();
}
}).then(data => {
if (data instanceof Blob) {
let a = document.createElement('a');
let url = window.URL.createObjectURL(data);
let filename = (this.props.fileName ? this.props.fileName : '导出文件') + '.xlsx';
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
a = null;
} else {
notification.error({
message: `文件导出错误`,
description: data.errMsg,
});
}
}).catch(err => {
notification.error({
message: `网络请求超时`,
});
}).finally(() => {
this.setState({ confirmLoading: false });
});
}
cancelGroup = () => {
this.setState({ currentGroupKey: null, groupVisiable: false });
};
cancelQuery = () => {
this.setState({ currentQueryKey: null, queryVisiable: false });
};
cancelOrder = () => {
this.setState({ currentOrderKey: null, orderVisiable: false });
};
selectOrder = (e) => {
this.setState({ currentOrderKey: e });
};
selectQuery = (e) => {
this.setState({ currentQueryKey: e });
};
selectGroup = (e) => {
this.setState({ currentGroupKey: e });
};
render() {
const { form } = this.props;
const {
visiable, targetKeys, sourceSelectedKeys, queryVisiable, querys, orders, groups, confirmLoading,
targetSelectedKeys, mockData, qs, os, gs, currentQueryKey, currentOrderKey, orderVisiable, currentGroupKey, groupVisiable,
} = this.state;
return (
<span>
<Button shape='round' onClick={this.open}>自定义导出</Button>
<div id='downloadDiv' style={{ display: 'none' }}></div>
<Modal
width={670}
maskClosable={false}
destroyOnClose
title="自定义查询、排序、导出"
style={{ textAlign: 'center' }}
visible={visiable}
onOk={this.export}
onCancel={this.onCancle}
confirmLoading={confirmLoading}
>
<div style={{ overflowY: 'auto', maxHeight: '500px', height: '500px' }}>
<div style={{ textAlign: 'left' }}>
<Button type="primary">新增查询条件</Button>
<Select style={{ width: 200, paddingRight: '10px' }}
value={currentQueryKey}
onChange={this.selectQuery}>
{qs.map((r) => {
return <Option key={r.field}
value={r.field}>
{r.name}
</Option>;
},
)}
</Select>
{currentQueryKey ?
<span style={{ paddingLeft: '0' }}>
<Button type="primary" onClick={this.okQuery}>确定</Button>
</span>
: ''}
<div style={{ height: '12px' }}>
</div>
{querys.map((r, i) =>
<FormItem key={r.name + i}
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
colon={false}
label={r.name}>
{form.getFieldDecorator(i + 'q__' + r.field, {
initialValue: { stringX: '=' },
rules: [{
validator: (rule, value, callback) => {
var errors = [];
if (value == null) {
errors.push(new Error('请输入查询值!', rule.field));
} else {
if (value.stringX != 'IS NOT NULL' && value.stringX != 'IS NULL' && value.string == null) {
errors.push(new Error('请输入查询值!', rule.field));
}
}
callback(errors);
},
}],
})(
<QueryItem obj={r}
key={r.name + i}
deleteQuery={this.deleteQuery.bind(this, i)}/>)}
</FormItem>)
}
</div>
<div style={{ textAlign: 'left', paddingTop: '15px' }}>
<Button type="primary">新增排序条件</Button>
<Select style={{ width: 200, paddingRight: '10px' }}
value={currentOrderKey}
onChange={this.selectOrder}>
{os.map((r) => {
for (let j = 0; j < orders.length; j++) {
if (orders[j].field === r.field) return;
}
return <Option key={r.field} value={r.field}>{r.name}</Option>;
},
)}
</Select>
{currentOrderKey ?
<span style={{ paddingLeft: '0' }}>
<Button type="primary" onClick={this.okOrder}>确定</Button>
</span>
: ''}
<div style={{ height: '12px' }}>
</div>
{orders.map((r, i) =>
<FormItem key={r.name + i}
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
colon={false}
label={'按' + r.name}>
{form.getFieldDecorator(i + 'o__' + r.field, {
initialValue: { stringX: 'desc' },
})(
<OrderItem deleteOrder={this.deleteOrder.bind(this, i)}/>)}
</FormItem>)}
</div>
{this.props.voClass ?
<div style={{ textAlign: 'left', paddingTop: '15px' }}>
<span style={{ paddingRight: '10px' }}>聚合条件:</span>
{!groupVisiable ?
<Button type="primary" onClick={this.addGroup}>新增</Button>
:
<span>
<Select style={{ width: 100 }}
value={currentGroupKey}
onChange={this.selectGroup}>
{gs.map((r) => {
for (var j = 0; j < groups.length; j++) {
if (groups[j].field == r.field) return;
}
return <Option key={r.field}
value={r.field}>
{r.name}
</Option>;
},
)}
</Select>
{currentGroupKey ?
<Button type="primary" onClick={this.okGroup}>确定</Button>
: ''}
<Button type="primary" onClick={this.cancelGroup}>取消</Button>
</span>}
{groups.map((r, i) =>
<FormItem key={i + r.name}
labelCol={{ span: 5 }}
wrapperCol={{ span: 15 }}
label={'按' + r.name + '聚合'}>
{form.getFieldDecorator(i + 'g__' + r.field)(
<Input style={{ display: 'none' }}
value=""/>)}
<Button type="danger" onClick={this.deleteGroup.bind(this, i)}>删除</Button>
</FormItem>)}
</div> : ''}
<Row>
<Col span={24}
style={{ textAlign: 'left', paddingTop: '15px' }}>
<span style={{ paddingRight: '10px' }}>导出项:</span>
{/*<Select>*/}
{/*{*/}
{/*}*/}
{/*</Select>*/}
</Col>
<Col span={18}>
<Transfer key={keyX}
style={{ textAlign: 'left' }}
dataSource={mockData}
listStyle={{
width: 200,
height: 300,
}}
onSelectChange={this.onSelectChange}
selectedKeys={[...sourceSelectedKeys, ...targetSelectedKeys]}
rowKey={record => record.key}
targetKeys={targetKeys}
onChange={this.handleChange}
render={this.renderItem}
/>
</Col>
<Col span={2}>
<div style={{ marginTop: 100 }}>
<Button size="small"
disabled={targetSelectedKeys.length === 0}
onClick={this.top}>
批量置顶
</Button>
<Button size="small"
style={{ marginTop: 10 }}
disabled={targetSelectedKeys.length !== 1}
onClick={this.up}>
单项上移
</Button>
<Button size="small"
style={{ marginTop: 10 }}
disabled={targetSelectedKeys.length !== 1}
onClick={this.down}>
单项下移
</Button>
<Button size="small"
style={{ marginTop: 10 }}
disabled={targetSelectedKeys.length === 0}
onClick={this.bottom}>
批量置底
</Button>
</div>
</Col>
</Row>
</div>
</Modal>
</span>
);
}
}
// import fetch from 'dva/fetch';
// import React from 'react';
// import ReactDOM from 'react-dom';
// import { Select, Button, Modal, Input, Transfer, Row, Col, Form, message, notification } from 'antd';
// import { connect } from 'dva';
// import { getToken } from '@/utils/authority';
// import config from '@/config/config';
// import QueryItem from './QueryItem';
// import OrderItem from './OrderItem';
//
// import FormdataWrapper from '@/utils/object-to-formdata-custom';
//
// const Option = Select.Option;
// let keyX = 1;
// function swapArray(arr, index1, index2) {
// arr[index1] = arr.splice(index2, 1, arr[index1])[0];
// return arr;
// }
// const FormItem = Form.Item;
//
// @connect(({ DataObj, loading }) => ({
// DataObj,
// loading: loading.models.DataObj,
// }))
// @Form.create()
// export default class Index extends React.Component {
// constructor(props) {
// super(props);
// this.state = {
// visiable: false,
//
// queryVisiable: false,
// groupVisiable: false,
// sortVisiable: false,
// currentQueryKey: null,
// currentGroupKey: null,
// orderVisiable: false,
// currentOrderKey: null,
// querys: [],
// orders: [],
// groups: [],
// gs: [],
// os: [],
// qs: [],
// mockData: [],
// targetKeys: [],
// sourceSelectedKeys: [],
// targetSelectedKeys: [],
// infos: {},
// confirmLoading: false,
// };
// }
//
// onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
// this.setState({ sourceSelectedKeys, targetSelectedKeys });
// };
// deleteQuery = (i) => {
// const querys = this.state.querys;
// querys.splice(i, 1);
// this.setState({ querys });
// };
// deleteOrder = (i) => {
// const orders = this.state.orders;
// orders.splice(i, 1);
// this.setState({ orders });
// };
// deleteGroup = (i) => {
// const groups = this.state.groups;
// groups.splice(i, 1);
// this.setState({ groups });
// };
// open = () => {
// const { dispatch } = this.props;
// dispatch({
// type: 'DataObj/getExportInfo',
// payload: {
// objId: this.props.objId,
// },
// callback: (infos) => {
//
// const mockData = [];
// const qs = [];
// const gs = [];
// const os = [];
// for (var key in infos) {
// const x = infos[key];
// mockData.push({
// key: x.field,
// title: x.name,
// chosen: false,
// });
// if (x.canQuery) {
// qs.push(x);
// }
// if (x.canGroup) {
// gs.push(x);
// }
// if (x.canOrder) {
// os.push(x);
// }
// }
//
// this.setState({
// mockData, infos, visiable: true, qs, gs, os,
// });
//
// },
// });
// };
// onCancle = () => {
// this.setState({ visiable: false });
// };
// handleChange = (targetKeys, direction, moveKeys) => {
//
// this.setState({ targetKeys });
// };
//
// up = () => {
// keyX = keyX + 1;
// var { targetKeys, targetSelectedKeys } = this.state;
// for (var i = 0; i < targetKeys.length; i++) {
// if (targetKeys[i] === targetSelectedKeys[0]) {
// if (i === 0) return;
// targetKeys = swapArray(targetKeys, i, i - 1);
//
// break;
// }
// }
//
// this.setState({ targetKeys });
// };
// down = () => {
// keyX = keyX + 1;
// var { targetKeys, targetSelectedKeys } = this.state;
// for (var i = 0; i < targetKeys.length; i++) {
// if (targetKeys[i] === targetSelectedKeys[0]) {
// if (i === targetKeys.length - 1) return;
// targetKeys = swapArray(targetKeys, i, i + 1);
//
// break;
// }
// }
//
// this.setState({ targetKeys });
// };
// bottom = () => {
// keyX = keyX + 1;
// const { targetKeys, targetSelectedKeys } = this.state;
// var x = [];
// for (var i = 0; i < targetKeys.length; i++) {
// if (!targetSelectedKeys.includes(targetKeys[i])) {
// x.push(targetKeys[i]);
// }
// }
// x = [...x, ...targetSelectedKeys];
// this.setState({ targetKeys: x });
// };
// top = () => {
// keyX = keyX + 1;
// const { targetKeys, targetSelectedKeys } = this.state;
// const x = [...targetSelectedKeys];
// for (var i = 0; i < targetKeys.length; i++) {
// if (!targetSelectedKeys.includes(targetKeys[i])) {
// x.push(targetKeys[i]);
// }
// }
//
//
// this.setState({ targetKeys: x });
// };
// renderItem = (item) => {
// if (this.state.targetKeys.includes(item.key)) {
// const customLabel = (
// <span className="custom-item" key={item.key}>
// {item.title}
//
// </span>
// );
// return {
// label: customLabel, // for displayed item
// value: item.title, // for title and filter matching
// };
//
// } else {
// const customLabel = (
// <span className="custom-item" key={item.key}>
// {item.title}
// </span>
// );
// return {
// label: customLabel, // for displayed item
// value: item.title, // for title and filter matching
// };
// }
// };
// addOrder = () => {
//
// this.setState({ orderVisiable: true });
//
// };
// okOrder = () => {
// const orders = this.state.orders;
// orders.push(this.state.infos[this.state.currentOrderKey]);
// this.setState({ orders, orderVisiable: false, currentOrderKey: null });
//
// };
// okGroup = () => {
// const groups = this.state.groups;
// groups.push(this.state.infos[this.state.currentGroupKey]);
// this.setState({ groups, groupVisiable: false, currentGroupKey: null });
// };
// addGroup = () => {
// this.setState({ groupVisiable: true });
// };
//
// addQuery = () => {
// this.setState({ queryVisiable: true });
// };
// okQuery = () => {
// const querys = this.state.querys;
// querys.push(this.state.infos[this.state.currentQueryKey]);
// this.setState({ querys, queryVisiable: false, currentQueryKey: null });
//
// };
// export = () => {
// this.props.form.validateFields((err, fieldsValue) => {
// if (err) return;
// //form.resetFields();
// var qqs;
// if (this.props.mustQuerys != null) {
// qqs = [...this.props.mustQuerys];
// } else {
// qqs = [];
// }
//
// const oos = [];
// const ggs = [];
// for (let key in fieldsValue) {
// var x = key.indexOf('__');
// let kk = key.substr(x + 2);
// if (key.indexOf('q__') > -1) {
// qqs.push({
// notes: this.state.infos[kk].notes,
// hql: this.state.infos[kk].hql,
// c: this.state.infos[kk].type,
// x: fieldsValue[key].stringX,
// v: fieldsValue[key].string,
// });
//
// } else if (key.indexOf('o__') > -1) {
// oos.push({ hql: this.state.infos[kk].hql, x: fieldsValue[key].stringX });
// } else if (key.indexOf('g__') > -1) {
// ggs.push({ hql: this.state.infos[kk].hql });
// }
// }
//
// if (this.props.voClass && ggs.length === 0) {
// message.error('请至少选择一个聚合条件');
// return;
// }
// if (this.state.targetKeys.length === 0) {
// message.error('请至少选择一个导出字段');
// return;
// }
// const names = [];
// for (let i = 0; i < this.state.targetKeys.length; i++) {
// names.push(this.state.infos[this.state.targetKeys[i]].name);
// }
// let divElement = document.getElementById('downloadDiv');
// console.log(config.sqlFormsServer);
// let downloadUrl = config.sqlFormsServer + '/DataObjApi/exportFormData?';
// const token = getToken() != null && getToken() != 'null' ? getToken() : '0000';
// downloadUrl = `${downloadUrl}token=${token}`;
// let param = {
// fields: this.state.targetKeys,
// names: names,
// beanName: this.props.beanName,
// querys: JSON.stringify(qqs),
// orders: JSON.stringify(oos),
// groups: JSON.stringify(ggs),
// voClass: this.props.voClass,
// objId:this.props.objId,
// modelClass: this.props.modelClass,
// preHandleClass: this.props.preHandleClass,
// hqlHandleClass: this.props.hqlHandleClass,
//
// };
// param = {...param, ...this.props.params || {}}
// this.downloadFile(downloadUrl, param);
// });
//
// };
//
// downloadFile(url, params) {
// this.setState({ confirmLoading: true });
//
// fetch(url, {
// method: 'POST',
// body: FormdataWrapper(params),
// }).then(res => {
// if (res.status != '200') {
// return res.json();
// } else {
// return res.blob();
// }
// }).then(data => {
// if (data instanceof Blob) {
// let a = document.createElement('a');
// let url = window.URL.createObjectURL(data);
// let filename = (this.props.fileName ? this.props.fileName : '导出文件') + '.xlsx';
// a.href = url;
// a.download = filename;
// a.click();
// window.URL.revokeObjectURL(url);
// a = null;
// } else {
// notification.error({
// message: `文件导出错误`,
// description: data.errMsg,
// });
// }
//
// }).catch(err => {
// notification.error({
// message: `网络请求超时`,
// });
// }).finally(() => {
// this.setState({ confirmLoading: false });
// });
// }
//
// cancelGroup = () => {
// this.setState({ currentGroupKey: null, groupVisiable: false });
// };
// cancelQuery = () => {
// this.setState({ currentQueryKey: null, queryVisiable: false });
// };
// cancelOrder = () => {
// this.setState({ currentOrderKey: null, orderVisiable: false });
// };
// selectOrder = (e) => {
//
// this.setState({ currentOrderKey: e });
// };
// selectQuery = (e) => {
//
// this.setState({ currentQueryKey: e });
// };
// selectGroup = (e) => {
//
// this.setState({ currentGroupKey: e });
// };
//
// render() {
// const { form } = this.props;
// const {
// visiable, targetKeys, sourceSelectedKeys, queryVisiable, querys, orders, groups, confirmLoading,
// targetSelectedKeys, mockData, qs, os, gs, currentQueryKey, currentOrderKey, orderVisiable, currentGroupKey, groupVisiable,
// } = this.state;
// return (
// <span>
// <Button shape='round' onClick={this.open}>自定义导出</Button>
// <div id='downloadDiv' style={{ display: 'none' }}></div>
// <Modal
// width={670}
// maskClosable={false}
// destroyOnClose
// title="自定义查询、排序、导出"
// style={{ textAlign: 'center' }}
// visible={visiable}
//
// onOk={this.export}
// onCancel={this.onCancle}
// confirmLoading={confirmLoading}
// >
// <div style={{ overflowY: 'auto', maxHeight: '500px', height: '500px' }}>
// <div style={{ textAlign: 'left' }}>
// <Button type="primary">新增查询条件</Button>
//
//
// <Select style={{ width: 200, paddingRight: '10px' }}
// value={currentQueryKey}
// onChange={this.selectQuery}>
// {qs.map((r) => {
// return <Option key={r.field}
// value={r.field}>
// {r.name}
// </Option>;
// },
// )}
//
// </Select>
// {currentQueryKey ?
// <span style={{ paddingLeft: '0' }}>
// <Button type="primary" onClick={this.okQuery}>确定</Button>
// </span>
// : ''}
// <div style={{ height: '12px' }}>
//
// </div>
// {querys.map((r, i) =>
// <FormItem key={r.name + i}
// labelCol={{ span: 4 }}
// wrapperCol={{ span: 20 }}
// colon={false}
// label={r.name}>
// {form.getFieldDecorator(i + 'q__' + r.field, {
// initialValue: { stringX: '=' },
// rules: [{
// validator: (rule, value, callback) => {
// var errors = [];
// if (value == null) {
// errors.push(new Error('请输入查询值!', rule.field));
//
// } else {
// if (value.stringX != 'IS NOT NULL' && value.stringX != 'IS NULL' && value.string == null) {
// errors.push(new Error('请输入查询值!', rule.field));
// }
// }
// callback(errors);
//
// },
// }],
// })(
// <QueryItem obj={r}
// key={r.name + i}
// deleteQuery={this.deleteQuery.bind(this, i)}/>)}
// </FormItem>)
// }
// </div>
// <div style={{ textAlign: 'left', paddingTop: '15px' }}>
// <Button type="primary">新增排序条件</Button>
// <Select style={{ width: 200, paddingRight: '10px' }}
// value={currentOrderKey}
// onChange={this.selectOrder}>
// {os.map((r) => {
// for (let j = 0; j < orders.length; j++) {
// if (orders[j].field === r.field) return;
//
// }
// return <Option key={r.field} value={r.field}>{r.name}</Option>;
// },
// )}
//
// </Select>
// {currentOrderKey ?
// <span style={{ paddingLeft: '0' }}>
// <Button type="primary" onClick={this.okOrder}>确定</Button>
//
// </span>
// : ''}
// <div style={{ height: '12px' }}>
//
// </div>
// {orders.map((r, i) =>
// <FormItem key={r.name + i}
// labelCol={{ span: 4 }}
// wrapperCol={{ span: 20 }}
// colon={false}
// label={'按' + r.name}>
// {form.getFieldDecorator(i + 'o__' + r.field, {
// initialValue: { stringX: 'desc' },
// })(
// <OrderItem deleteOrder={this.deleteOrder.bind(this, i)}/>)}
// </FormItem>)}
// </div>
// {this.props.voClass ?
// <div style={{ textAlign: 'left', paddingTop: '15px' }}>
// <span style={{ paddingRight: '10px' }}>聚合条件:</span>
// {!groupVisiable ?
// <Button type="primary" onClick={this.addGroup}>新增</Button>
//
// :
// <span>
// <Select style={{ width: 100 }}
// value={currentGroupKey}
// onChange={this.selectGroup}>
// {gs.map((r) => {
// for (var j = 0; j < groups.length; j++) {
// if (groups[j].field == r.field) return;
//
// }
// return <Option key={r.field}
// value={r.field}>
// {r.name}
// </Option>;
// },
// )}
// </Select>
// {currentGroupKey ?
// <Button type="primary" onClick={this.okGroup}>确定</Button>
//
//
// : ''}
// <Button type="primary" onClick={this.cancelGroup}>取消</Button>
//
// </span>}
// {groups.map((r, i) =>
// <FormItem key={i + r.name}
// labelCol={{ span: 5 }}
// wrapperCol={{ span: 15 }}
// label={'按' + r.name + '聚合'}>
// {form.getFieldDecorator(i + 'g__' + r.field)(
// <Input style={{ display: 'none' }}
// value=""/>)}
// <Button type="danger" onClick={this.deleteGroup.bind(this, i)}>删除</Button>
//
//
// </FormItem>)}
// </div> : ''}
// <Row>
// <Col span={24}
// style={{ textAlign: 'left', paddingTop: '15px' }}>
// <span style={{ paddingRight: '10px' }}>导出项:</span>
// {/*<Select>*/}
// {/*{*/}
//
// {/*}*/}
// {/*</Select>*/}
// </Col>
// <Col span={18}>
// <Transfer key={keyX}
// style={{ textAlign: 'left' }}
// dataSource={mockData}
// listStyle={{
// width: 200,
// height: 300,
// }}
// onSelectChange={this.onSelectChange}
// selectedKeys={[...sourceSelectedKeys, ...targetSelectedKeys]}
// rowKey={record => record.key}
// targetKeys={targetKeys}
// onChange={this.handleChange}
// render={this.renderItem}
// />
// </Col>
// <Col span={2}>
// <div style={{ marginTop: 100 }}>
// <Button size="small"
// disabled={targetSelectedKeys.length === 0}
// onClick={this.top}>
// 批量置顶
// </Button>
// <Button size="small"
// style={{ marginTop: 10 }}
// disabled={targetSelectedKeys.length !== 1}
// onClick={this.up}>
// 单项上移
// </Button>
// <Button size="small"
// style={{ marginTop: 10 }}
// disabled={targetSelectedKeys.length !== 1}
// onClick={this.down}>
// 单项下移
// </Button>
// <Button size="small"
// style={{ marginTop: 10 }}
// disabled={targetSelectedKeys.length === 0}
// onClick={this.bottom}>
// 批量置底
// </Button>
// </div>
// </Col>
//
// </Row>
// </div>
// </Modal>
// </span>
// );
// }
// }
/* eslint-disable no-nested-ternary */
/**
* 历史表单+最新表单生成
* data 'affair/getIdFormDetail' 接口返回的详细参数
* form 表单控件
* isNewForm 是否展示最新表单
*/
import React from 'react';
import { Spin, Card } from 'antd';
import { isEmpty } from '@/webPublic/one_stop_public/copy';
import RenderForm from '../RenderForm';
import styles from './index.less';
export default function HistoryForm(props) {
const { data, isNewForm } = props;
return (
<div>
{data.hisTaskForm.formKeys && data.hisTaskForm.formKeys.length > 0
? data.hisTaskForm.formKeys.map((item, index) => {
return (
<Card
key={item.formKey}
title={item.taskName}
bordered={false}
style={{ width: 800, margin: 'auto' }}
>
{!data ? (
<div
style={{
width: '100%',
height: 200,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Spin size="large" />
</div>
) : (
<RenderForm
get="web"
isCg="no"
postData={data}
obj={data.hisTaskForm.formData}
form={props.form}
formKey={item.formKey}
/>
)}
</Card>
);
})
: ''}
{isNewForm ? ( // 展示最新表单
data.isHandle && !!data.taskFormKey ? (
<Card
title="当前流程"
bordered={false}
style={{ width: 800, margin: 'auto' }}
>
{!isEmpty(data) && (
<RenderForm
postData={data}
get="web"
isCg="no"
obj={data.hisTaskForm.formData}
table="new"
form={props.form}
/>
)}
</Card>
) : null
) : null}
</div>
);
}
.title {
font-size: 20px;
font-weight: bolder;
margin: 16px 0 8px 0;
padding-left: calc((100% - 800px) / 2);
}
import React, { Fragment } from 'react';
import {
Button,
Modal,
Steps,
Upload,
Icon,
message,
Tabs,
Table,
} from 'antd';
import styles from './ImportUtil.less';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import { exportExcel } from 'xlsx-oc'
import config from '@/config/config';
import { connect } from 'dva';
const Step = Steps.Step;
const TabPane = Tabs.TabPane;
@connect(({ DataObj, loading }) => ({
DataObj,
loading: loading.models.DataObj,
}))
export default class ImportUtil extends React.PureComponent {
constructor(props) {
super(props);
const exportTemplateUrl= encodeURI(`${config.sqlFormsServer}/DataObjApi/importTemplateDownload?objId=${this.props.objId}&name=${props.fileName}`);
this.state = {
ch:false,
currentKey:"1",
visible: false,
current: 0,
isShow: true,
filekey: '',
sucData: [],
errData: [],
column: [],
exportTemplateUrl,
isNextDisabled:false,
};
}
showModal = () => {
this.setState({
visible: true,
});
};
handleOk = (e) => {
this.setState({
visible: false,
});
};
handleCancel = (e) => {
this.setState({
visible: false,
});
};
next() {
const current = this.state.current + 1;
if (current === 2) {
this.setState({
current: current,
isShow: false,
});
if (this.state.errData.lenth > 0) {
message.error('请检查数据');
return;
} else {
this.import();
}
}
if (current === 3) {
this.setState({
current: current,
isShow: true,
});
if (this.props.callback) {
this.props.callback();
}
}
}
prev() {
const current = this.state.current - 1;
this.setState({ current });
}
import() {
const { dispatch ,importParams } = this.props;
dispatch({
type: 'DataObj/importExecute',
payload: {
...(importParams||{}),
cacheKey:this.state.filekey,
objId: this.props.objId,
},
callback: (res) => {
this.next();
message.success('导入成功');
this.setState({
current: 3,
isShow: true,
visible: false,
});
if(this.props.callback){
this.props.callback();
}
}
})
}
getCachKey = (filePath) => {
const { dispatch ,importParams } = this.props;
dispatch({
type: 'DataObj/importAnalyse',
payload: {
...(importParams||{}),
isLocal:false,
filePath,
objId: this.props.objId,
},
callback: (res) => {
this.setState({
filekey: res.cacheKey,
});
this.queryFile(res.cacheKey);
}
})
};
queryFile = (cacheKey) => {
const { dispatch ,importParams } = this.props;
dispatch({
type: 'DataObj/importDataQuery',
payload: {
...(importParams||{}),
cacheKey,
objId: this.props.objId,
},
callback: (res) => {
this.setState({
current: 1,
isShow: false,
sucData: res.pass,
errData: res.noPass,
column: res.column
});
if(res.noPass&&res.noPass.length==0){
if (res.pass.length==0) {
message.error('当前没有验证成功的数据,无法导入。');
this.setState({
currentKey:"1",
ch:!this.state.ch,
isNextDisabled: true
});
} else {
message.success('所有数据验证通过,请确认后点击下一步。');
this.setState({
currentKey:"2",
ch:!this.state.ch,
isNextDisabled: false
});
}
}else{
message.error('当前存在未验证通过的数据,请按错误提示检测更正导入文件');
this.setState({
currentKey:"1",
ch:!this.state.ch,
isNextDisabled: true
});
}
}
})
};
changePane=(activeKey)=>{
this.setState({currentKey:activeKey})
}
exportError=(column,dataSource)=>{
var _headers = []
for(var i=0;i<column.length;i++){
_headers.push({k:column[i].dataIndex,v:column[i].title})
}
for(var j=0;j<dataSource.length;j++){
dataSource[j].index=j+1
}
exportExcel(_headers, dataSource);
}
render() {
const props = {
name: 'file',
action: config.uploadUrl,
headers: {
authorization: 'authorization-text',
},
accept:'.xlsx',
showUploadList: false,
onChange: (info) => {
if (info.file.status !== 'uploading') {
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 上传成功`);
let x = info.file.response;
this.getCachKey(x);
} else if (info.file.status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
},
};
const steps = [{
title: '上传Excel',
}, {
title: '验证数据',
}, {
title: '数据导入',
},
{
title: '导入完成',
}];
const { current } = this.state;
const {name, loading} = this.props
const column1=this.state.column?[{title:"序号",dataIndex:"index",fixed:"left",width:50, render:(v,r,i)=>i+1},...this.state.column]:[]
var column2=this.state.column?[...this.state.column]:[]
if(column1.length>1) column1[1].render=(val)=><span style={{color:"red"}}>{val}</span>
column2.splice(0,1)
column2=[{title:"序号",fixed:"left",width:50, render:(v,r,i)=>i+1},...column2]
return (
<span>
<ButtonDiy name={name||'批量导入'}
type='default'
className='defaultBlue'
handleClick={this.showModal}/>
<Modal
visible={this.state.visible}
onOk={this.handleOk}
maskClosable={false}
destroyOnClose
onCancel={this.handleCancel}
title={null}
footer={null}
width={"80%"}
>
<div className={styles.nomal}>
<p className={styles.import}>
EXCEL导入向导
</p>
<div style={{ margin: 'auto 23px' }}>
<Steps current={current}>
{steps.map(item =>
<Step key={item.title}
title={item.title}/>)}
</Steps>
<div className="steps-content">
{steps[this.state.current].content}
</div>
<div className={styles.button}>
{
(this.state.current < steps.length - 1 && this.state.current !== 0)
&&
<ButtonDiy name={this.state.current==3?"确认导入":"下一步"} type="primary" disabled={this.state.current!=3 && this.state.isNextDisabled} className='primaryBlue' handleClick={() => this.next()}/>
}
{
this.state.current > 0
&&
<ButtonDiy style={{ marginLeft: 8 }} name="上一步" className='defaultBlue' handleClick={() => this.prev()}/>
}
</div>
</div>
<div className={styles.tip}>
<p className={styles.tipContent}>
<span>欢迎使用EXCEL导入向导,首先请您上传需要导入的EXCEL文件。</span>
<span>点击“选择文件”选择您要导入的EXCEL文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。</span>
</p>
</div>
{
this.state.isShow ?
<div className={styles.buttonDown}>
<Upload {...props}>
<Button>
<Icon type="upload"/>点击上传
</Button>
</Upload>
<Button href={this.state.exportTemplateUrl }
target="_blank"
type="danger">
下载模板
</Button>
</div> :
<Upload {...props}>
<Button>
<Icon type="upload"/>
重新上传
</Button>
</Upload>
}
{
this.state.isShow ? <div className={styles.attentionItem}>
<p>导入事项</p>
<p>1. 导入操作一次只能上传 1 EXCEL文件。</p>
<p>2. 导入文件最大文件大小上传 1 GB</p>
<p>3. 只能上传EXCEL文件(XLS, XLSX) 默认支持EXCEL 2003EXCEL 2007</p>
<p>4. 请将EXCEL文件的所有单元格格式设置为“文本”格式</p>
</div> :
<div className={styles.error} style={{marginTop:20}}>
<Tabs activeKey={this.state.currentKey} key={this.state.ch} onChange={this.changePane} type="card">
{this.state.errData&&this.state.errData.length==0?"":<TabPane tab={<span style={{color:"red"}}>验证错误列表</span>} key="1">
<Button style={{marginTop:5,marginBottom:5}} type="danger" onClick={this.exportError.bind(this,column1,this.state.errData)}>导出错误信息</Button>
<Table columns={column1} size="small"
style={{overflow: 'auto'}}
dataSource={this.state.errData}
bordered={true}/></TabPane>}
<TabPane tab={<span style={{color:"green"}}>验证成功列表</span>} key="2">
<Button style={{marginTop:5,marginBottom:5}} type="primary" onClick={this.exportError.bind(this,column2,this.state.sucData)}>导出正确信息</Button>
<Table columns={column2} size="small"
style={{overflow: 'auto'}}
dataSource={this.state.sucData}
bordered={true}/></TabPane>
</Tabs>
</div>
}
</div>
</Modal>
</span>
);
}
}
// import React, { Fragment } from 'react';
// import {
// Button,
// Modal,
// Steps,
// Upload,
// Icon,
// message,
// Tabs,
// Table,
// } from 'antd';
// import styles from './ImportUtil.less';
// import ButtonDiy from '@/baseComponent/ButtonDiy';
// import { exportExcel } from 'xlsx-oc'
// import config from '@/config/config';
// import { connect } from 'dva';
// const Step = Steps.Step;
//
//
// const TabPane = Tabs.TabPane;
//
//
// @connect(({ DataObj, loading }) => ({
// DataObj,
// loading: loading.models.DataObj,
// }))
// export default class ImportUtil extends React.PureComponent {
// constructor(props) {
// super(props);
//
// const exportTemplateUrl= encodeURI(`${config.sqlFormsServer}/DataObjApi/importTemplateDownload?objId=${this.props.objId}&name=${props.fileName}`);
//
// this.state = {
// ch:false,
// currentKey:"1",
// visible: false,
// current: 0,
// isShow: true,
// filekey: '',
// sucData: [],
// errData: [],
// column: [],
//
// exportTemplateUrl,
//
// isNextDisabled:false,
// };
// }
//
// showModal = () => {
//
// this.setState({
// visible: true,
// });
// };
// handleOk = (e) => {
// this.setState({
// visible: false,
// });
// };
// handleCancel = (e) => {
// this.setState({
// visible: false,
// });
// };
//
// next() {
// const current = this.state.current + 1;
// if (current === 2) {
// this.setState({
// current: current,
// isShow: false,
// });
// if (this.state.errData.lenth > 0) {
// message.error('请检查数据');
// return;
// } else {
// this.import();
// }
// }
// if (current === 3) {
// this.setState({
// current: current,
// isShow: true,
// });
// if (this.props.callback) {
// this.props.callback();
// }
// }
//
// }
//
// prev() {
// const current = this.state.current - 1;
// this.setState({ current });
// }
//
// import() {
// const { dispatch ,importParams } = this.props;
// dispatch({
// type: 'DataObj/importExecute',
// payload: {
// ...(importParams||{}),
// cacheKey:this.state.filekey,
//
// objId: this.props.objId,
// },
// callback: (res) => {
//
// this.next();
// message.success('导入成功');
//
// this.setState({
// current: 3,
// isShow: true,
// visible: false,
//
// });
// if(this.props.callback){
// this.props.callback();
// }
// }
// })
//
//
// }
//
// getCachKey = (filePath) => {
// const { dispatch ,importParams } = this.props;
// dispatch({
// type: 'DataObj/importAnalyse',
// payload: {
// ...(importParams||{}),
// isLocal:false,
// filePath,
// objId: this.props.objId,
// },
// callback: (res) => {
// this.setState({
// filekey: res.cacheKey,
//
// });
// this.queryFile(res.cacheKey);
//
// }
// })
//
//
// };
// queryFile = (cacheKey) => {
// const { dispatch ,importParams } = this.props;
// dispatch({
// type: 'DataObj/importDataQuery',
// payload: {
// ...(importParams||{}),
// cacheKey,
// objId: this.props.objId,
// },
// callback: (res) => {
// this.setState({
// current: 1,
// isShow: false,
//
// sucData: res.pass,
// errData: res.noPass,
// column: res.column
// });
// if(res.noPass&&res.noPass.length==0){
//
//
// if (res.pass.length==0) {
// message.error('当前没有验证成功的数据,无法导入。');
// this.setState({
// currentKey:"1",
// ch:!this.state.ch,
// isNextDisabled: true
// });
// } else {
// message.success('所有数据验证通过,请确认后点击下一步。');
// this.setState({
// currentKey:"2",
// ch:!this.state.ch,
// isNextDisabled: false
// });
// }
// }else{
// message.error('当前存在未验证通过的数据,请按错误提示检测更正导入文件');
// this.setState({
// currentKey:"1",
// ch:!this.state.ch,
// isNextDisabled: true
// });
// }
//
// }
// })
// };
// changePane=(activeKey)=>{
// this.setState({currentKey:activeKey})
// }
// exportError=(column,dataSource)=>{
//
//
// var _headers = []
// for(var i=0;i<column.length;i++){
// _headers.push({k:column[i].dataIndex,v:column[i].title})
// }
// for(var j=0;j<dataSource.length;j++){
// dataSource[j].index=j+1
// }
// exportExcel(_headers, dataSource);
//
//
// }
// render() {
//
// const props = {
// name: 'file',
// action: config.uploadUrl,
//
// headers: {
// authorization: 'authorization-text',
// },
// accept:'.xlsx',
// showUploadList: false,
// onChange: (info) => {
// if (info.file.status !== 'uploading') {
//
// }
// if (info.file.status === 'done') {
// message.success(`${info.file.name} 上传成功`);
// let x = info.file.response;
//
//
//
// this.getCachKey(x);
//
// } else if (info.file.status === 'error') {
// message.error(`${info.file.name} file upload failed.`);
// }
// },
// };
// const steps = [{
// title: '上传Excel',
// }, {
// title: '验证数据',
// }, {
// title: '数据导入',
// },
// {
// title: '导入完成',
// }];
//
// const { current } = this.state;
// const {name, loading} = this.props
// const column1=this.state.column?[{title:"序号",dataIndex:"index",fixed:"left",width:50, render:(v,r,i)=>i+1},...this.state.column]:[]
// var column2=this.state.column?[...this.state.column]:[]
// if(column1.length>1) column1[1].render=(val)=><span style={{color:"red"}}>{val}</span>
//
// column2.splice(0,1)
// column2=[{title:"序号",fixed:"left",width:50, render:(v,r,i)=>i+1},...column2]
//
// return (
// <span>
// <ButtonDiy name={name||'批量导入'}
// type='default'
// className='defaultBlue'
// handleClick={this.showModal}/>
// <Modal
// visible={this.state.visible}
// onOk={this.handleOk}
// maskClosable={false}
// destroyOnClose
// onCancel={this.handleCancel}
// title={null}
// footer={null}
// width={"80%"}
// >
//
// <div className={styles.nomal}>
// <p className={styles.import}>
// EXCEL导入向导
// </p>
// <div style={{ margin: 'auto 23px' }}>
// <Steps current={current}>
// {steps.map(item =>
// <Step key={item.title}
// title={item.title}/>)}
// </Steps>
// <div className="steps-content">
// {steps[this.state.current].content}
// </div>
// <div className={styles.button}>
// {
// (this.state.current < steps.length - 1 && this.state.current !== 0)
// &&
// <ButtonDiy name={this.state.current==3?"确认导入":"下一步"} type="primary" disabled={this.state.current!=3 && this.state.isNextDisabled} className='primaryBlue' handleClick={() => this.next()}/>
//
// }
//
// {
// this.state.current > 0
// &&
// <ButtonDiy style={{ marginLeft: 8 }} name="上一步" className='defaultBlue' handleClick={() => this.prev()}/>
//
// }
// </div>
// </div>
//
// <div className={styles.tip}>
// <p className={styles.tipContent}>
// <span>欢迎使用EXCEL导入向导,首先请您上传需要导入的EXCEL文件。</span>
// <span>点击“选择文件”选择您要导入的EXCEL文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。</span>
// </p>
//
// </div>
// {
// this.state.isShow ?
// <div className={styles.buttonDown}>
// <Upload {...props}>
// <Button>
// <Icon type="upload"/>点击上传
// </Button>
// </Upload>
// <Button href={this.state.exportTemplateUrl }
// target="_blank"
// type="danger">
// 下载模板
// </Button>
// </div> :
// <Upload {...props}>
// <Button>
// <Icon type="upload"/>
// 重新上传
// </Button>
// </Upload>
// }
//
// {
// this.state.isShow ? <div className={styles.attentionItem}>
// <p>导入事项</p>
// <p>1. 导入操作一次只能上传 1 个EXCEL文件。</p>
// <p>2. 导入文件最大文件大小上传 1 GB。</p>
// <p>3. 只能上传EXCEL文件(XLS, XLSX) 默认支持EXCEL 2003和EXCEL 2007。</p>
// <p>4. 请将EXCEL文件的所有单元格格式设置为“文本”格式</p>
// </div> :
// <div className={styles.error} style={{marginTop:20}}>
//
// <Tabs activeKey={this.state.currentKey} key={this.state.ch} onChange={this.changePane} type="card">
// {this.state.errData&&this.state.errData.length==0?"":<TabPane tab={<span style={{color:"red"}}>验证错误列表</span>} key="1">
// <Button style={{marginTop:5,marginBottom:5}} type="danger" onClick={this.exportError.bind(this,column1,this.state.errData)}>导出错误信息</Button>
//
// <Table columns={column1} size="small"
// style={{overflow: 'auto'}}
// dataSource={this.state.errData}
// bordered={true}/></TabPane>}
// <TabPane tab={<span style={{color:"green"}}>验证成功列表</span>} key="2">
//
// <Button style={{marginTop:5,marginBottom:5}} type="primary" onClick={this.exportError.bind(this,column2,this.state.sucData)}>导出正确信息</Button>
//
// <Table columns={column2} size="small"
// style={{overflow: 'auto'}}
// dataSource={this.state.sucData}
// bordered={true}/></TabPane>
//
// </Tabs>
//
//
// </div>
// }
// </div>
//
// </Modal>
// </span>
// );
// }
// }
.nomal{
background: #fff;
padding: 10px;
}
.title{
display: flex;
margin-bottom: 20px;
}
.info{
text-align: center;
font-weight: bold;
font-size: 18px;
}
.detail{
text-align: center;
margin:30px auto;
}
.detail img{
margin: auto 10px;
}
.button{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: center; /*Firefox*/
-webkit-box-pack: center; /*Safari,Opera,Chrome*/
box-pack: center;
-moz-justify-content: center;
-webkit-justify-content: center;
justify-content: center;
}
.operation{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: center; /*Firefox*/
-webkit-box-pack: center; /*Safari,Opera,Chrome*/
box-pack: center;
-moz-justify-content: center;
-webkit-justify-content: center;
justify-content: center;
}
.button Button{
margin: auto 10px;
}
.titleInfo p span{
font-weight: bold;
}
.import{
color: #6ca3c9;
font-size: 16px;
}
.button{
// background: #eff3f8;
text-align: center;
padding:20px;
margin-top: 20px;
}
.tip{
margin:20px auto;
padding:10px;
border-top: 1px solid #ccc;
}
.tip span{
display: block;
margin:10px;
font-size: 16px;
}
.tip::after{
content: '';
position: absolute;
width: 5px;
height: 57px;
background: #e5eaf1;
margin-top: -141px;
margin-left: -13px;
}
.select button{
color: #fff;
padding:10px;
background: #abbac3;
border: none;
margin: 10px;
}
.attentionItem{
background: #f4f5f4;
padding: 10px;
box-shadow: 1px 1px 1px #ccc;
}
.attentionItem p:nth-child(1){
font-size: 16px;
margin-left: 0;
}
.attentionItem p{
font-size: 14px;
margin-left: 45px;
}
.submitButtons{
margin-left: 34px;
}
.contentTable{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: justify; /*Firefox*/
-webkit-box-pack:justify; /*Safari,Opera,Chrome*/
box-pack: justify;
-moz-justify-content: space-between;
-webkit-justify-content: space-between;
justify-content: space-between;
margin-top: 20px;
}
.left{
width: 50%;
}
.right{
width: 50%;
border-left: 1px solid #317ecc;
}
.error p{
color: #fff;
background: #317ecc;
// margin: 10px auto;
text-align: left;
font-size: 18px;
}
.download{
background: #f5f5f5;
padding: 5px;
margin-top: -16px;
}
.download img{
margin-top: -2px;
margin-right: 5px;
}
.download button{
border: none;
background: #f5f5f5
}
.download button:nth-child(1){
border-right: 1px solid #ccc;
}
.download button:nth-child(2){
border-right: 1px solid #ccc;
}
.buttonDown{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: start; /*Firefox*/
-webkit-box-pack: start; /*Safari,Opera,Chrome*/
box-pack: start;
-moz-justify-content: flex-start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
margin-bottom: 20px;
}
.buttonDown>button{
margin-left: 10px;
background: #abbac3;
border: none;
color: #fff;
padding: 5px 12px;
border-radius: 5px;
}
\ No newline at end of file
//.nomal{
// background: #fff;
// padding: 10px;
//}
//.title{
// display: flex;
// margin-bottom: 20px;
//}
//.info{
// text-align: center;
// font-weight: bold;
// font-size: 18px;
//}
//.detail{
// text-align: center;
// margin:30px auto;
//}
//.detail img{
// margin: auto 10px;
//}
//.button{
// display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
// display: -moz-box; /* 老版本语法: Firefox (buggy) */
// display: -ms-flexbox; /* 混合版本语法: IE 10 */
// display: -webkit-flex; /* 新版本语法: Chrome 21+ */
// display: -moz-flex;
// display: flex;
// -moz-box-pack: center; /*Firefox*/
// -webkit-box-pack: center; /*Safari,Opera,Chrome*/
// box-pack: center;
// -moz-justify-content: center;
// -webkit-justify-content: center;
// justify-content: center;
//}
//.operation{
// display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
// display: -moz-box; /* 老版本语法: Firefox (buggy) */
// display: -ms-flexbox; /* 混合版本语法: IE 10 */
// display: -webkit-flex; /* 新版本语法: Chrome 21+ */
// display: -moz-flex;
// display: flex;
// -moz-box-pack: center; /*Firefox*/
// -webkit-box-pack: center; /*Safari,Opera,Chrome*/
// box-pack: center;
// -moz-justify-content: center;
// -webkit-justify-content: center;
// justify-content: center;
//}
//.button Button{
// margin: auto 10px;
//
//}
//.titleInfo p span{
// font-weight: bold;
//}
//.import{
// color: #6ca3c9;
// font-size: 16px;
//}
//.button{
// // background: #eff3f8;
// text-align: center;
// padding:20px;
// margin-top: 20px;
//}
//.tip{
// margin:20px auto;
// padding:10px;
// border-top: 1px solid #ccc;
//}
//.tip span{
// display: block;
// margin:10px;
// font-size: 16px;
//}
//.tip::after{
// content: '';
// position: absolute;
// width: 5px;
// height: 57px;
// background: #e5eaf1;
// margin-top: -141px;
// margin-left: -13px;
//}
//.select button{
// color: #fff;
// padding:10px;
// background: #abbac3;
// border: none;
// margin: 10px;
//}
//.attentionItem{
// background: #f4f5f4;
// padding: 10px;
// box-shadow: 1px 1px 1px #ccc;
//}
//.attentionItem p:nth-child(1){
// font-size: 16px;
// margin-left: 0;
//}
//.attentionItem p{
// font-size: 14px;
// margin-left: 45px;
//}
//.submitButtons{
// margin-left: 34px;
//}
//.contentTable{
// display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
// display: -moz-box; /* 老版本语法: Firefox (buggy) */
// display: -ms-flexbox; /* 混合版本语法: IE 10 */
// display: -webkit-flex; /* 新版本语法: Chrome 21+ */
// display: -moz-flex;
// display: flex;
// -moz-box-pack: justify; /*Firefox*/
// -webkit-box-pack:justify; /*Safari,Opera,Chrome*/
// box-pack: justify;
// -moz-justify-content: space-between;
// -webkit-justify-content: space-between;
// justify-content: space-between;
// margin-top: 20px;
//}
//.left{
// width: 50%;
//}
//.right{
// width: 50%;
// border-left: 1px solid #317ecc;
//}
//.error p{
// color: #fff;
// background: #317ecc;
// // margin: 10px auto;
// text-align: left;
// font-size: 18px;
//}
//.download{
// background: #f5f5f5;
// padding: 5px;
// margin-top: -16px;
//}
//.download img{
// margin-top: -2px;
// margin-right: 5px;
//}
//.download button{
// border: none;
// background: #f5f5f5
//}
//.download button:nth-child(1){
// border-right: 1px solid #ccc;
//}
//.download button:nth-child(2){
// border-right: 1px solid #ccc;
//}
//.buttonDown{
// display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
// display: -moz-box; /* 老版本语法: Firefox (buggy) */
// display: -ms-flexbox; /* 混合版本语法: IE 10 */
// display: -webkit-flex; /* 新版本语法: Chrome 21+ */
// display: -moz-flex;
// display: flex;
// -moz-box-pack: start; /*Firefox*/
// -webkit-box-pack: start; /*Safari,Opera,Chrome*/
// box-pack: start;
// -moz-justify-content: flex-start;
// -webkit-justify-content: flex-start;
// justify-content: flex-start;
// margin-bottom: 20px;
//}
//.buttonDown>button{
// margin-left: 10px;
// background: #abbac3;
// border: none;
// color: #fff;
// padding: 5px 12px;
// border-radius: 5px;
//}
......@@ -2,13 +2,13 @@ import React, { Fragment } from 'react';
import { Divider, message, Modal, Popconfirm } from 'antd';
import moment from 'moment';
import router from 'umi/router';
import ExportInfo from '../Export/index';
// import ExportInfo from '../Export/index';
import { text, number, date, getFormArrayConfig } from '../config/index';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '../Shell';
import FormArray from '../AffairPage/component/FormArray';
import Edit from '../Edit/index';
import ImportUtil from '../ImportUtil/ImportUtil';
// import ImportUtil from '../ImportUtil/ImportUtil';
import SearchDom from '@/highOrderComponent/SearchDom';
import StandardTable from '@/components/StandardTable';
import { getHead, fetchData, deleteItem, add } from './services';
......@@ -344,8 +344,8 @@ class FormList extends React.Component {
<Shell>
<div style={{ paddingLeft: '10px', marginTop: '20px' }}>
<ButtonDiy icon="plus" className="primaryBlue" handleClick={this.add} name="新建" />
{hasImport && <ImportUtil objId={objId} />}
{hasExport && <ExportInfo objId={objId} />}
{/* {hasImport && <ImportUtil objId={objId} />}
{hasExport && <ExportInfo objId={objId} />}*/}
<ButtonDiy handleClick={this.batchDelete} name="批量删除" />
</div>
<StandardTable
......
......@@ -75,11 +75,14 @@ class ListWithAddEditTemplate extends React.Component {
if (!headerList) return;
this.setState({ headerList });
this.columns = headerList.filter(i => !i.isHidden).slice(0, 10).map(item => ({
title: item.title,
dataIndex: item.name,
render: date.includes(item.type) && dateRender,
}));
this.columns = headerList
.filter(i => !i.isHidden)
.slice(0, 10)
.map(item => ({
title: item.title,
dataIndex: item.name,
render: date.includes(item.type) && dateRender,
}));
const operation = {
title: '操作',
render: (_, record) => {
......@@ -161,7 +164,10 @@ class ListWithAddEditTemplate extends React.Component {
getPage = () => {
const { objId, filters = {} } = this.props;
const { formValues, pageData: pagination } = this.state;
const {
formValues,
pageData: { pagination },
} = this.state;
const query = { ...formValues, ...filters };
const pageNo = pagination.current ? pagination.current : 1;
const pageSize = pagination.pageSize ? pagination.pageSize : 10;
......@@ -184,21 +190,12 @@ class ListWithAddEditTemplate extends React.Component {
};
handleStandardTableChange = (pagination, filtersArg, sorter) => {
const filters = Object.keys(filtersArg).reduce((obj, key) => {
const newObj = { ...obj };
newObj[key] = getValue(filtersArg[key]);
return newObj;
}, {});
const params = {
pageNo: pagination.current,
pageSize: pagination.pageSize,
...filters,
};
if (sorter.field) {
params.sorter = `${sorter.field}_${sorter.order}`;
}
this.getPage(params);
this.setState(
({ pageData }) => ({
pageData: { ...pageData, pagination },
}),
this.getPage
);
};
handleAdd = () => {
......
import React, { useState, useEffect } from 'react';
import { Form, Spin } from 'antd';
import Shell from '@/baseComponent/Shell';
import HistoryForm from '@/webPublic/one_stop_public/Entrance/historyForm';
import HistoryForm from '@/webPublic/FormInsertDiy/HistoryForm';
import { getHistoryFormDetail } from '../../Services';
import withGoBack from '@/highOrderComponent/withGoBack';
......
......@@ -3,10 +3,10 @@ import ZdyTable from '@/webPublic/one_stop_public/Table';
import styles from './index.less';
import { fetchTemplateByCode, fetchTableItem } from '@/webPublic/Services';
export default function RenderForm({ get = 'web', isCg = 'yes', form, postData }) {
export default function RenderForm({ get = 'web', isCg = 'yes', ...rest }) {
return (
<div className={styles.zyd_onestop_style_class}>
<ZdyTable get={get} isCg={isCg} postData={postData} form={form} />
<ZdyTable get={get} isCg={isCg} {...rest} />
</div>
);
}
......@@ -73,6 +73,12 @@ export function RenderFormByObjId({
);
return (
<RenderFormByContent get={get} isCg={isCg} content={content} templateCode={templateCode} form={form} />
<RenderFormByContent
get={get}
isCg={isCg}
content={content}
templateCode={templateCode}
form={form}
/>
);
}
.zyd_onestop_style_class{
padding: 20px;
table, td, div{
overflow: unset !important;
}
}
import { apiRequest } from '../request';
const api="/DataObjApi";
export default {
namespace: 'DataObj',
state: {
list: [],
data:{
list: [],
pagination: {},
},
code:{
list: [],
pagination: {},
}
},
effects: {
*getExportInfo({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getExportInfo" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*changeCatalogue({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/changeCatalogue" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*find({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/find" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*add({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/add" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},*fetch({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getPage" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'page',
payload: {...response,isMain:payload.isMain},
});
},*remove({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/remove" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
},*open({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/open" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
},
*createTabel({payload,callback},{call,put}){
const response = yield call(apiRequest,api+"/createTable",payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
}
},
reducers: {
list(state, action) {
return {
...state,
list: action.payload,
};
},
page(state, { payload }) {
if(payload.isMain){
return {
...state,
data:{
list: payload.rows,
pagination: {
current:payload.pageNo,
pageSize:payload.pageSize,
total:payload.total,
},
}
};
}else{
return {
...state,
code:{
list: payload.rows,
pagination: {
current:payload.pageNo,
pageSize:payload.pageSize,
total:payload.total,
},
}
};
}
},
nom(state, action) {
return {...state };
},
},
};
import { uaaRequest } from '../../one_stop_public/utils/request';
const api = '/DataObjApi';
export default {
namespace: 'formList',
state: {
list: [],
data: {
list: [],
pagination: {},
},
},
effects: {
* clear({ payload, callback }, { call, put }) {
yield put({
type: 'clearAll',
payload: {},
});
},
* getHead({ payload, callback }, { call, put }) {
console.log('getHead',);
const response = yield call(uaaRequest, '/DataColumnApi/getHeaderList', payload);
console.log(' header response', response);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
* fetch({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/DataObjApi/getFormDataPage', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
/* yield put({
type: 'page',
payload: {
...response,
},
});*/
if (callback) callback(response);
},
* add({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/addFormData',
{
data: JSON.stringify(payload.params),
isAdd: payload.isAdd,
objId: payload.objId,
});
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
* delete({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/deleteFormData', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
* getDetail({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getFormData', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
},
reducers: {
clearAll(state, action) {
return {
...state,
data: {
list: [],
pagination: {},
},
};
},
list(state, action) {
return {
...state,
list: action.payload,
};
},
page(state, { payload }) {
return {
...state,
data: {
list: payload.rows,
pagination: {
current: payload.pageNo,
pageSize: payload.pageSize,
total: Number(payload.total),
},
},
};
},
nom(state, action) {
return { ...state };
},
},
};
......@@ -5,7 +5,7 @@
import {extend} from 'umi-request';
import {notification} from 'antd';
import FormdataWrapper from "@/utils/object-to-formdata-custom";
import { getHuanGeToken } from '@/utils/authority';
import { getToken } from '@/utils/authority';
import { offline } from './Toast';
import systemConfig from '@/config/config';
......@@ -70,7 +70,7 @@ const umiRequest = extend({
});
export const request = (url, data, options = {}) => {
const pp = {...data,token: getHuanGeToken()}
const pp = {...data,token: getToken()}
const requestParams = FormdataWrapper(pp)
// 由于自动添加前缀 这里暂时修改getUrl(url)
......
......@@ -65,8 +65,6 @@ export default class idnex extends Component {
if(this.props?.callback){
this.props.callback(val)
}
} else {
openToast('error', '保存失败', '请尝试');
}
},
}).then(()=>{
......@@ -140,8 +138,9 @@ export default class idnex extends Component {
openDraftButton?
<Button
style={{
marginRight:20
marginRight:24
}}
shape='round'
isLoading={isLoading}
onClick={this.handleDraft}
>
......@@ -153,6 +152,8 @@ export default class idnex extends Component {
onClick={this.showModal}
isLoading={isLoading}
type='primary'
shape='round'
ghost
>
{
text??'提交'
......
......@@ -662,14 +662,68 @@ export default class tableCom extends Component {
if (json.funcs != null && json.funcs != "") {
let enu;
try {
this.getFunctionValue(json.funcs, { base52: this.props.uuid }, json) ;
} catch (e) {
message.error("公式选项配置存在问题")
}
this.getFunctionValue(json.funcs, { base52: this.props.uuid }, json,()=>{
if (init != null && Object.keys(init).length > 0) {
let base52 = dataColumn.base52
let vlu=this.props.form.getFieldValue(base52)
if(vlu instanceof Array){
for(var i=0;i<this.state.options.length;i++){
if(vlu.includes(this.state.options[i].value)){
labs.push(this.state.options[i].label)
}
}
}else{
for(var i=0;i<this.state.options.length;i++){
if(vlu==this.state.options[i].value){
labs.push(this.state.options[i].label)
break;
}
}
}
this.setState({labels:labs})
}else if (!this.props.isEdit && Object.keys(obj).length > 0) {
let base52 = dataColumn.base52
if (this.props.fatherCode) {
const x = base52.split(".")
base52 = x[x.length - 1]
}
const vlu=obj[base52]
const labs=[]
if(vlu instanceof Array){
for(var i=0;i<this.state.options.length;i++){
if(vlu.includes(this.state.options[i].value)){
labs.push(this.state.options[i].label)
}
}
}else{
for(var i=0;i<this.state.options.length;i++){
if(vlu==this.state.options[i].value){
labs.push(this.state.options[i].label)
break;
}
}
}
this.setState({labels:labs})
}
}) ;
} catch (e) {
message.error("公式选项配置存在问题")
}
}
......@@ -688,7 +742,7 @@ export default class tableCom extends Component {
}
}
reqUtil = (base52, json, url, method, params, callback, options = {}) => {
reqUtil = (base52, json,orgCallback, url, method, params, callback, options = {}) => {
//查缓存
var isChange = false;
if(url.indexOf("http")===-1){
......@@ -731,7 +785,9 @@ export default class tableCom extends Component {
const res=callback(data)
if(res!=null&&!(typeof res === "function")){
this.setState({ options: res , selectDis: false });
this.setState({ options: res , selectDis: false },()=>{
if(orgCallback) orgCallback()
});
}
}else if (json.comName == "Button") {
......@@ -808,7 +864,9 @@ export default class tableCom extends Component {
const res=callback(data)
if(res!=null&&!(typeof res === "function")){
this.setState({ options: res , selectDis: false });
this.setState({ options: res , selectDis: false },()=>{
if(orgCallback) orgCallback()
});
}
}else if (json.comName == "Button") {
......@@ -864,7 +922,7 @@ export default class tableCom extends Component {
}
sqlUtil = (base52, json, sqlKey, params, callback, options = {}) => {
sqlUtil = (base52, json,orgCallback, sqlKey, params, callback, options = {}) => {
//查缓存
var isChange = false;
......@@ -895,7 +953,9 @@ export default class tableCom extends Component {
if(json.optionType&&json.optionType=="func"){
const res=callback(data)
if(res!=null&&!(typeof res === "function")){
this.setState({ options: res , selectDis: false });
this.setState({ options: res , selectDis: false },()=>{
if(orgCallback)orgCallback()
});
}
}else if (json.comName == "Button") {
try {
......@@ -974,7 +1034,9 @@ export default class tableCom extends Component {
const res=callback(data)
if(res!=null&&!(typeof res === "function")){
this.setState({ options: res , selectDis: false });
this.setState({ options: res , selectDis: false },()=>{
if(orgCallback) orgCallback()
});
}
}else if (json.comName == "Button") {
......@@ -1030,7 +1092,7 @@ export default class tableCom extends Component {
return "norefeshxxxxxxxxxxxxxxxxxxxx"
}
getFunctionValue = (fun, column, json) => {
getFunctionValue = (fun, column, json,callback) => {
/* if (!this.props.isEdit) {
return
......@@ -1045,10 +1107,10 @@ export default class tableCom extends Component {
const value = fun1(obj,this.props.init, this.props.defaultValues, { clientType: this.props.get }, this.props.index, this.props.fatherCode,
{
moment: moment,
sql: this.sqlUtil.bind(this, base52, json),
sql: this.sqlUtil.bind(this, base52, json,callback),
message: message,router:router,
setValues: this.setValues.bind(this, base52, json),
req: this.reqUtil.bind(this, base52, json),
req: this.reqUtil.bind(this, base52, json,callback),
md5: md5,
render:this.getRender,base64:getBase64
},
......@@ -1072,7 +1134,9 @@ export default class tableCom extends Component {
if(value!=null&&!(typeof value === "function")){
this.setState({ options: value , selectDis: false });
this.setState({ options: value , selectDis: false },()=>{
if(callback) callback()
});
}
} else if (json.comName == "Echart" || json.comName == "QRCode") {
......@@ -1631,8 +1695,15 @@ export default class tableCom extends Component {
}
}
if (!isEdit) {
if (this.props.fatherCode) {
dataColumn.base52 = this.props.uuid
if(bindObj!=null){
dataColumn.base52 = bindObj.base52
}else{
dataColumn.base52 = this.props.uuid
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论