提交 4160092a authored 作者: 钟是志's avatar 钟是志

Merge remote-tracking branch 'origin/master'

......@@ -166,9 +166,12 @@ export default class AffairPage extends React.Component {
if (event.data === 'returnList') {
this.returnList(true);
}
if (event.data.indexOf('iframeHeight') > -1) {
if (event && event.data && event.data.indexOf && event.data.indexOf('iframeHeight') > -1) {
let height = Number(event.data.split('-')[1]);
document.getElementById('applyIframeId').height = height;
const iframe = document.getElementById('applyIframeId');
if (iframe) {
iframe.height = height;
}
}
}, false);
......
......@@ -18,10 +18,10 @@ export default class AuditPage extends Component {
componentDidMount() {}
handleButtonSet = () => {
const { addFields, workId } = this.props;
const { addFields, workId, hasBatchAudit } = this.props;
return {
tab1: [
{
hasBatchAudit ? {
type: 'audit',
component: 'RenderComponent',
render: ({ selectRows, getPage }) => {
......@@ -52,8 +52,8 @@ export default class AuditPage extends Component {
</AuditModal>
);
},
},
],
}: false,
].filter(i => i),
tab2: [],
};
};
......
/***
* 批量审核
* 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}
/>
)
}
}
......@@ -12,6 +12,11 @@ import * as destructionFunc from '../destruction';
import { Link } from 'dva/router';
export default class Index extends React.Component {
static defaultProps = {
hasBatchAudit: false, // 是否有批量审核按钮 默认关掉 如果有需要再在外面包一层 2020年5月6日 18:44:11 钟是志
};
constructor(props) {
super(props);
......@@ -112,11 +117,13 @@ export default class Index extends React.Component {
render() {
const { workId, dataBaseId, columns, searchCondition, addFields, allConfigSetInfo, tableInfo } = this.state;
const { hasBatchAudit } = this.props;
if(!workId){
return null;
}
return (
<AuditPage
hasBatchAudit={hasBatchAudit}
workId={workId}
dataBaseId={dataBaseId}
columns={columns}
......
......@@ -3,7 +3,9 @@ import { uaaRequest } from '@/webPublic/one_stop_public/utils/request';
export const getHead = (payload, callback) => {
uaaRequest('/DataColumnApi/getHeaderList', payload).then(res => {
if (!res) return;
if (callback) callback(res);
if (callback) {
callback(res);
}
});
};
......
......@@ -20,11 +20,11 @@ import {
} from '@/webPublic/Services';
import { ModalConfirm } from '@/baseComponent/Modal';
const dateRender = val => val && moment(val).format('YYYY-MM-DD HH:mm:ss');
const dateRender = (val) => val && moment(val).format('YYYY-MM-DD HH:mm:ss');
const getValue = obj =>
const getValue = (obj) =>
Object.keys(obj)
.map(key => obj[key])
.map((key) => obj[key])
.join(',');
/**
......@@ -58,7 +58,7 @@ class ListWithAddEditTemplate extends React.Component {
isAdd: false, // 是新增还是编辑
selectedRows: [],
primaryKey: null,
showEdit: false, // 是否显示编辑区域
// showEdit: false, // 是否显示编辑区域
pageData: {
list: [],
pagination: {},
......@@ -71,20 +71,22 @@ class ListWithAddEditTemplate extends React.Component {
// 渲染值
componentDidMount() {
const { objId } = this.props;
fetchTableHeader(objId).then(headerList => {
fetchTableHeader(objId).then((headerList) => {
if (!headerList) return;
this.setState({ headerList });
this.columns = headerList
.filter(i => !i.isHidden)
.filter((i) => !i.isHidden)
.slice(0, 10)
.map(item => ({
.map((item) => ({
title: item.title,
dataIndex: item.name,
render: date.includes(item.type) && dateRender,
}));
const operation = {
title: '操作',
fixed: 'right',
width: 120,
render: (_, record) => {
return (
<Fragment>
......@@ -97,11 +99,11 @@ class ListWithAddEditTemplate extends React.Component {
};
this.columns.push(operation);
const primaryKey = (headerList.find(i => i.isPrimaryKey) || {}).name;
const primaryKey = (headerList.find((i) => i.isPrimaryKey) || {}).name;
this.setState({ primaryKey });
const searchConfig = headerList.filter(i => i.isShowQuery).map(item => {
const searchConfig = headerList.filter((i) => i.isShowQuery).map((item) => {
const sear = getFormArrayConfig([item]);
const { required, placeHolder, ...config } = sear[0];
return config;
......@@ -114,35 +116,35 @@ class ListWithAddEditTemplate extends React.Component {
// 新增按钮事件
add = () => {
const { headerList } = this.state;
const showEdit = headerList.length >= 10;
// const showEdit = headerList.length >= 10;
this.setState({
modalVisible: !showEdit,
modalVisible: true,
formData: {},
isAdd: true,
showEdit,
// showEdit,
});
};
// 修改按钮事件
modify = record => {
modify = (record) => {
const recordTemp = { ...record, update_time: Date.now() };
const { headerList } = this.state;
const showEdit = headerList.length >= 10;
// const showEdit = headerList.length >= 10;
// 把record里明文key改成转换后的key,用于在模板表单中回显
const headerMap = headerList.reduce((acc, header) => ({ ...acc, [header.name]: header }), {});
const formData = Object.keys(recordTemp).reduce(
(acc, key) => ({ ...acc, [headerMap[key].base52]: recordTemp[key] }),
{}
);
const formData = Object.keys(recordTemp).reduce((acc, key) => {
if (!headerMap[key]) return acc;
return { ...acc, [headerMap[key].base52]: recordTemp[key] };
}, {});
this.setState({
formData,
modalVisible: !showEdit,
modalVisible: true,
isAdd: false,
showEdit,
// showEdit,
});
};
delete = record => {
delete = (record) => {
ModalConfirm('确定删除?', {
onOk: () => {
const { objId } = this.props;
......@@ -151,7 +153,7 @@ class ListWithAddEditTemplate extends React.Component {
const Keys = {};
Keys[primaryKey] = record[primaryKey];
deleteTableItem(objId, primaryKey, record[primaryKey]).then(res => {
deleteTableItem(objId, primaryKey, record[primaryKey]).then((res) => {
this.getPage();
});
},
......@@ -172,7 +174,7 @@ class ListWithAddEditTemplate extends React.Component {
const pageNo = pagination.current ? pagination.current : 1;
const pageSize = pagination.pageSize ? pagination.pageSize : 10;
fetchTableData({ dataObjId: objId, query, pageSize, pageNo }).then(res => {
fetchTableData({ dataObjId: objId, query, pageSize, pageNo }).then((res) => {
if (!res.rows) {
console.log('分页接口rows返回null报错');
}
......@@ -194,7 +196,7 @@ class ListWithAddEditTemplate extends React.Component {
({ pageData }) => ({
pageData: { ...pageData, pagination },
}),
this.getPage
this.getPage,
);
};
......@@ -207,7 +209,7 @@ class ListWithAddEditTemplate extends React.Component {
validateFields((err, values) => {
if (err) return;
this.setState({ confirmLoading: true });
addOrEditTableItem({ objId, data: values, isAdd }).then(res => {
addOrEditTableItem({ objId, data: values, isAdd }).then((res) => {
this.setState({ confirmLoading: false });
if (res === true) {
message.success('操作成功');
......@@ -229,13 +231,13 @@ class ListWithAddEditTemplate extends React.Component {
});
};
handleSelectRows = rows => {
handleSelectRows = (rows) => {
this.setState({
selectedRows: rows,
});
};
batchDelete = e => {
batchDelete = (e) => {
const { selectedRows, primaryKey } = this.state;
const { objId } = this.props;
......@@ -243,12 +245,14 @@ class ListWithAddEditTemplate extends React.Component {
ModalConfirm('确定删除?', {
onOk: () => {
deleteTableItem(objId, primaryKey, selectedRows.map(row => row[primaryKey])).then(res => {
deleteTableItem(objId, primaryKey, selectedRows.map((row) => row[primaryKey])).then(
(res) => {
this.setState({
selectedRows: [],
});
this.getPage();
});
},
);
},
});
};
......@@ -295,20 +299,6 @@ class ListWithAddEditTemplate extends React.Component {
};
return (
<>
{showEdit ? (
<Edit
id={objId}
recordId={formData[primaryKey]}
recordKey={primaryKey}
returnThis={() => {
this.setState({
showEdit: false,
});
this.getPage();
}}
/>
) : (
<Fragment>
{searchConfig.length > 0 ? (
<SearchDom
formStateChange={this.formStateChange}
......@@ -332,11 +322,10 @@ class ListWithAddEditTemplate extends React.Component {
selectedRows={selectedRows}
onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange}
scroll={{ x: 1200 }}
scroll={{ x: true }}
/>
</Shell>
</Fragment>
)}
<AddOrEditModal {...addOrEditModalProps} />
</>
);
......
import React, { useState, useEffect } from 'react';
import { Form, Button } from 'antd';
import Shell from '@/baseComponent/Shell';
import { ModalInfo } from '@/baseComponent/Modal';
import { addOrEditTableItem, fetchTableData, fetchTableHeader, } from '@/webPublic/Services';
import { preHandle } from '@/webPublic/one_stop_public/utils/myutils';
import { getOneStopConfig } from '@/baseComponent/utils';
import { RenderFormByContent } from '../RenderForm';
// 直接获取的表格数据的字段是明文,找换成base转换后的字段
function getBaseEncodedData(rowData, tableHeader) {
// {name: base52}
const nameBaseMap = tableHeader.reduce((acc, header) => {
return {...acc, [header.name] : header.base52};
}, {});
// 明文字段转换成base后的字段, eg. {process_status: 1} => {JbZWZHoGRsA: 1}
return Object.keys(rowData).reduce((acc, name) => {
const base52 = nameBaseMap[name];
if(!base52) return acc;
return {...acc, [base52]: rowData[name] };
}, {});
}
// 配置页面,配置数据在元数据表格的第一行
// 1. 页面显示通过模板id渲染。
// 2. 页面数据通过元数据表id, 查询和修改。
// templateCode, 页面模板id
// tableId, 元数据列表id
// children, 可以传children,但children不能是数组(不能传属性),children里可以自定义其他组件。
function SingleDataPageInFirstRow(props) {
const { children, form, templateCode: templateCodeFromProps, dataObjId: dataObjIdFromProps, location: {pathname} } = props;
// templateCode 和 dataObjId 可以通过组件属性或者根据路径配置获取
const templateCodeFromPathname = getOneStopConfig(`${pathname}-templateCode`);
const dataObjIdFromPathname = getOneStopConfig(`${pathname}-dataObjId`);
const templateCode = templateCodeFromPathname || templateCodeFromProps;
const dataObjId = dataObjIdFromPathname || dataObjIdFromProps;
if (!templateCode || !dataObjId) {
console.warn("模板code或者元数据表格id为空,templateCode: " + templateCode + ", dataObjId: " + dataObjId);
return null;
}
const [isAdd, setIsAdd] = useState(false);
const [content, setContent] = useState({});
useEffect(
() => {
fetchTableHeader(dataObjId).then(tableHeader => {
if (!tableHeader) return;
fetchTableData({ pageNo: 1, pageSize: 10, isBase: true, dataObjId, query: {} }).then(res => {
const firstRowData = (res && res.rows && res.rows[0]) || {};
setContent(getBaseEncodedData(firstRowData, tableHeader));
setIsAdd(!!(!res || res.errMsg))
});
});
},
[dataObjId]
);
function handleSave() {
const { validateFields } = form;
validateFields((err, values) => {
if (err) return;
// console.log(JSON.stringify(values.JjvkRobXWTE), JSON.stringify(values.JjvkwLqcsyY));
preHandle(values);
// console.log(JSON.stringify(values.JjvkRobXWTE));
addOrEditTableItem({ objId: dataObjId, isAdd, data: values }).then(res => {
if (res) {
ModalInfo('保存成功!');
}
});
});
}
let ClonedChildren;
if (children) {
ClonedChildren = React.cloneElement(React.Children.only(children), {
form,
isAdd,
url: '/DataObjApi/addFormData',
});
}
return (
<Shell styleShell={{ marginTop: 0 }}>
<RenderFormByContent
content={content}
templateCode={templateCode}
form={form}
/>
{ClonedChildren || (
<div style={{ textAlign: 'center', padding: 16 }}>
<Button type="primary" shape="round" ghost onClick={handleSave}>
保存
</Button>
</div>
)}
</Shell>
);
}
export default Form.create()(SingleDataPageInFirstRow);
......@@ -24,7 +24,9 @@ function SingleDataPageTemplate(props) {
validateFields((err, values) => {
if (err) return;
// console.log(JSON.stringify(values.JjvkRobXWTE), JSON.stringify(values.JjvkwLqcsyY));
preHandle(values);
// console.log(JSON.stringify(values.JjvkRobXWTE));
addOrEditTableItem({ objId: tableId, isAdd, data: values }).then(res => {
if (res) {
ModalInfo('保存成功!');
......
......@@ -571,6 +571,7 @@ export default class ZdyTable extends Component {
<TableCom
formCode={formCode} // 当前表单code
modalInit={modalInit}
formId={formId} // 当前表单Id
i={i} // 当前组件下标
j={j} // 当前行数下班
......@@ -657,6 +658,7 @@ export default class ZdyTable extends Component {
}) : ""}
<IsNewTable
modalInit={modalInit}
items={items}
checkAllHidden={this.checkAllHidden}
isBorder={isBorder}
......
......@@ -8,6 +8,7 @@ import { Row, Col } from 'antd';
export default class isNewTable extends Component {
render() {
const {
items,
checkAllHidden,
isBorder,
......@@ -30,7 +31,8 @@ export default class isNewTable extends Component {
formCode,
formId,
fatherObj,
style
style,
modalInit
} = this.props
if(!isEdit ){ // 展示栏 暂不做处理
return <>
......@@ -51,6 +53,7 @@ export default class isNewTable extends Component {
item.map((ary, j) => {
return !allhidden && ary.hidden ? ""
: <><TableCom
modalInit={modalInit}
formCode={formCode}
formId={formId}
i={i}
......@@ -176,6 +179,7 @@ export default class isNewTable extends Component {
title={
!allhidden && ary.hidden ? ""
:<><TableCom
modalInit={modalInit}
formCode={formCode}
formId={formId}
i={i}
......@@ -208,6 +212,7 @@ export default class isNewTable extends Component {
// textAlign:ary.content&&ary.content.comName === 'Table'?"left":'right'
}}
> <><TableCom
modalInit={modalInit}
formCode={formCode}
formId={formId}
i={i}
......
......@@ -33,6 +33,7 @@ export default class isNewWebTable extends Component {
fatherObj,
style,
max,
modalInit
} = this.props
return (
<div
......@@ -89,6 +90,7 @@ export default class isNewWebTable extends Component {
isEdit={isEdit}
formKey={currentFormKey}
init={init}
modalInit={modalInit}
get={get} // 区分移动端或wen端
json={cell.content}
obj={obj || {}} // 是否存在默认值
......
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 {
}
render() {
let {dates} = this.state
const {format}=this.props
const startTime=dates.length>0?dates[0].valueOf():null
const endTime=dates.length>1?dates[1].valueOf():null
......@@ -72,18 +72,20 @@ export default class MobileDate extends Component {
<div>
<DatePicker
// 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:'取消'}}
value={ !!startTime?new Date(startTime):null}
format={format?format:'YYYY-MM-DD HH:mm:ss'}
onChange={date => this.handelStartChange(date)}
>
<List.Item arrow="horizontal">开始时间</List.Item>
</DatePicker>
<DatePicker
// 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}
locale={{okText:"确定",dismissText:'取消'}}
format={format?format:'YYYY-MM-DD HH:mm:ss'}
onChange={date => this.handelEndChange(date)}
>
<List.Item arrow="horizontal">结束时间</List.Item>
......
......@@ -9,6 +9,7 @@
import React from 'react';
import { Tree, Table, Spin } from 'antd';
import FormList from './formList';
import TreeList from './formList/TreeList'
import { connect } from 'dva';
export default class TableList extends React.Component {
......@@ -40,7 +41,30 @@ export default class TableList extends React.Component {
}
render() {
return <FormList
const {isTree} = this.props
return isTree?
<TreeList
onSelectRow={this.props.value.onSelectRow}
istableCom={true}
showHeader={this.props.showHeader}
get={this.props.get}
isHiddenPage={
this.props.isHiddenPage!=null?
this.props.isHiddenPage
:false}
loading={this.props.loading}
pageSize={this.props.pageSize||10}
value={this.state}
notShowBack={true}
rights={this.props.rights || []}
objCode={this.props.objCode}
isFormCom={true}
sql={this.props.sql}/>:
<FormList
onSelectRow={this.props.value.onSelectRow}
istableCom={true}
showHeader={this.props.showHeader}
......
import React, { Fragment } from 'react';
import {
Button,
Card,
DatePicker,
Divider,
Table,
Form,
Row,
Col,
Input,
InputNumber,
message,
Modal,
Select,
Popconfirm,
Tooltip,
Spin
} from 'antd';
import { connect } from 'dva';
import PageHeaderWrapper from './PageHeaderWrapper';
import styles from './TableList.less';
import StandardTable from './StandardTable';
import moment from 'moment';
import router from 'umi/router';
import ExportInfo from '../../App/ExportInfo';
import ExportCurrentInfo from '../../App/ExportCurrentInfo';
import StatisticsInfo from '../../App/StatisticsInfo';
import ImportUtil from '../../App/ImportUtil';
import SearchInfo from '../../App/SearchInfo';
import {Base16Encode} from "../../Base16/index";
import baseX from 'base-x'
import {isEmpty} from 'lodash'
const BASE16 = '0123456789abcdef'
const bs16 = baseX(BASE16)
const FormItem = Form.Item;
let AllWidth = 0; // 表格总长度
const { RangePicker } = DatePicker;
const text = [
'BINARY',
'BIT',
'BLOB',
'CHAR',
'GEOMETRY',
'GEOMETRYCOLLECTION',
'JSON',
'LINESTRING',
'LONGBLOB',
'LONGTEXT',
'MEDIUMBLOB',
'MEDIUMINT',
'MEDIUMTEXT',
'MULTILINESTRING',
'MULTIPOINT',
'MULTIPOLYGON',
'POINT',
'POLYGON',
'REAL',
'DECIMAL',
'ENUM',
'SET',
'TEXT',
'TINYBLOB',
'TIBYTEXT',
'VARBINARY',
'VARCHAR',
];
const number = ['BIGINT', 'DOUBLE', 'FLOAT', 'INT', 'INTEGER', 'NUMERIC', 'SMALLINT', 'TINYINT'];
const data = ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'];
const CreateForm = Form.create()(props => {
const {
modalVisible,
form,
handleAdd,
formLoading,
formData,
isAdd,
handleModalVisible,
formItem,
getItem,
isView
} = props;
//通过回调
const okHandle = () => {
form.validateFields((err, fieldsValue) => {
if (err) return;
if(isView){
handleModalVisible();
return;
}
formItem.map((item, index) => {
if (item.type.indexOf('DATE') > -1) {
for (let d in fieldsValue) {
if (item.name === d&&fieldsValue[d]) {
fieldsValue[d] = fieldsValue[d].format('YYYY-MM-DD HH:mm:ss');
}
}
}
});
let params = { ...fieldsValue };
handleAdd(params, isAdd);
});
};
console.log("isView",isView)
//需要获取动态表单
return (
<Modal
width="700px"
maskClosable={false}
destroyOnClose
title={isView?"查看详情":(isAdd ? '新增' : '编辑')}
visible={modalVisible}
footer={isView?null:[
<Button key="back" onClick={() => handleModalVisible()}>
取消
</Button>,
<Button key="submit" type="primary" onClick={okHandle}>
确定
</Button>
]}
onOk={okHandle}
onCancel={() => handleModalVisible()}
>
{formItem.map((item, index) => getItem(false,form, item, isAdd, formData, { span: 5 }, { span: 15 }))}
</Modal>
);
});
@connect(({ formList, loading }) => ({
formList, loading: loading.models.formList,
}))
@Form.create()
class TreeList extends React.Component {
state = {
data: {
list: [],
pagination: {},
},
selects:[],
modalVisible: false,
formData: null,
formValues: {},
formItem: [],
objId: this.props.objId || (this.props.location?this.props.location.state.id:null),
isAdd: false,
querys: [],
selectedRows: [],
primaryKey: null,
options: {},
isTable: true,
tableWidth:500,
rights:this.props.rights||[],
columnRights:[],
isReady:false,
groups:{},
showDiv:'',
showMobileDiv:'',
isView:false
};
columns = [];
getOptions = () => {
const refIds = []
for (var i = 0; i < this.state.formItem.length; i++) {
if (this.state.formItem[i].referenceObjId != null && this.state.options[this.state.formItem[i].id + ''] == null) {
refIds.push(datas[t].id)
}
}
if (refIds.length > 0) {
dispatch({
type: 'formList/getBatchOptions',
payload: { ids: refIds },
callback: (options) => {
this.setState({ options: { ...this.state.options, ...options } })
}
});
}
}
modify = record => {
// if (this.state.formItem.length < 10) {
this.getOptions()
this.setState({
formData: record,
modalVisible: true,
isAdd: false,
isView:false
});
// } else {
// router.push({
// pathname: '/admin/ddl/dataObj/formEdit',
// state: {
// id: this.state.objId,
// recordId: record[this.state.primaryKey],
// recordKey: this.state.primaryKey,
// isAdd: false,
// isView:false
// },
// });
// }
};
view = record => {
// if (this.state.formItem.length < 10) {
this.getOptions()
this.setState({
formData: record,
modalVisible: true,
isAdd: false,
isView:true
});
// } else {
// router.push({
// pathname: '/admin/ddl/dataObj/formEdit',
// state: {
// id: this.state.objId,
// recordId: record[this.state.primaryKey],
// recordKey: this.state.primaryKey,
// isAdd: false,
// isView:true
// },
// });
// }
};
delete = record => {
//找出主键
let Keys = {};
Keys[this.state.primaryKey] = record[this.state.primaryKey];
this.props.dispatch({
type: 'formList/delete',
payload: {
keys: JSON.stringify(Keys),
objId: this.state.objId
},
callback: () => {
this.getPage();
},
});
};
viewProcess = record => {
const {dispatch}= this.props;
dispatch({
type: 'formList/getAppId',
payload: {
code: record.process_biz_key,
},
callback: (data) => {
router.push({pathname: '/portal/serviceCentre/getdetail',state: {id:data.id}})
},
});
};
/**
* 宽度自适应函数
*/
resize = (e) => {
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
let showMobileDiv = scrollWidth-77
if(document.querySelector('#previewDiv')){ // 预览模式
this.setState({
showMobileDiv:document.querySelector('#previewDiv').clientWidth-77
})
} else {
this.setState({
showMobileDiv,
})
}
console.log(showMobileDiv)
}
//渲染值
componentDidMount() {
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
window.addEventListener('resize', this.resize);
if(this.props.objCode){
const { dispatch, objCode,sql} = this.props;
if(objCode==1||objCode=="1"){
this.initColumn();
}else{
dispatch({
type: 'DataObj/findByCode',
payload: { objCode:this.props.objCode },
callback: dataObj => {
this.setState({ objId: dataObj.id ,isTable: data.isTable},()=>{
dispatch({
type: 'DataRight/getUserRight',
payload: { objId: this.state.objId },
callback: data => {
if(!this.props.rights){
this.setState({ rights: data });
}
dispatch({
type: 'DataRight/getUserColumnRight',
payload: { objId: this.state.objId },
callback: data => {
this.setState({ columnRights: data });
this.initColumn();
}
});
}
});
});
},
});
}
}else{
dispatch({
type: 'formList/getObjDetail',
payload: { id: this.state.objId },
callback: data => {
this.setState({ isTable: data.isTable });
}
});
dispatch({
type: 'DataRight/getUserRight',
payload: { objId: this.state.objId },
callback: data => {
if(!this.props.rights){
this.setState({ rights: data });
}
dispatch({
type: 'DataRight/getUserColumnRight',
payload: { objId: this.state.objId },
callback: data => {
this.setState({ columnRights: data });
this.initColumn();
}
});
}
});
}
}
/**
* 移除监听器
*/
componentWillUnmount(){
window.removeEventListener('resize',this.resize);
}
custom=this.props.value?Base16Encode(JSON.stringify(this.props.value)):null
componentWillReceiveProps(nextProps){
const b = nextProps.value||{}
const a = this.props.value||{}
if(JSON.stringify(a)!=JSON.stringify(b)){
const params = {
pageNo: 1,
pageSize: this.props.pageSize||10,
query: JSON.stringify(this.state.formValues),
};
this.columns=nextProps.value.columns
this.custom=Base16Encode(JSON.stringify(b))
if( nextProps.value.getPage){
this.getPage(params,null,nextProps.value.getPage);
}else{
if(this.state.objId)this.getPage(params)
}
}
const x=nextProps.selects
const y = this.props.selects
if(JSON.stringify(x)!=JSON.stringify(y)){
this.setState({selects:x})
}
}
initColumn = () =>{
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
const {rights,columnRights} = this.state;
if(this.props.value&&this.props.value.columns){
this.columns=this.props.value.columns
this.getPage();
return
}
if(this.props.objCode==1||this.props.objCode=="1"){
}else{
dispatch({
type: 'formList/getHead',
payload: { dataObjId: this.state.objId },
callback: datas => {
const querys = []
const refIds = []
const groups ={};
if (datas) {
this.state.formItem = datas;
let i = 0;
for (let t in datas) {
if (datas[t].isPrimaryKey) this.state.primaryKey = datas[t].name;
if(datas[t].isHidden){
continue
}
let column = {};
column.title = datas[t].title;
column.dataIndex = datas[t].name;
column.width = datas[t].width;
if(i==0) column.fixed='left';
if(columnRights.length>0&&!columnRights.includes(datas[t].id)){
continue;
}
if (data.includes(datas[t].type)) {
column.render =( val) =>{
if(val == null){
return val;
}
if(datas[t].dataFormatStrWeb!=null){
return moment(val).format(datas[t].dataFormatStrWeb);
}else {
return moment(val).format('YYYY-MM-DD HH:mm:ss');
}
}
}else if(datas[t].name.indexOf("process_status")>-1){
column.render=(val)=>val?(val==="0"?"审核通过":"审核未通过"):null
}else {
column.render=(val)=>val&&val.length>100? <Tooltip title={val} overlayStyle={{width:1000}}>
<span style={{width:column.width||200,display:"block", wordBreak:"keep-all",whiteSpace:"nowrap", overflow:"hidden", textOverflow:"ellipsis"}}>{val}</span>
</Tooltip>:val
}
this.setState({tableWidth:((datas.length-1)*200)})
this.columns.push(column);
if (datas[t].isShowQuery) {
querys.push(datas[t])
if (datas[t].referenceObjId != null) {
refIds.push(datas[t].id)
}
if(datas[t].isGroupQuery!=null){
dispatch({
type: 'formList/getGroupList',
payload: { columnId: datas[t].id },
callback: (gourp) => {
groups[datas[t].id] = gourp;
this.setState({ groups })
}
});
}
}
i++;
}
if (querys.length > 0) {
this.setState({ querys })
if (refIds.length > 0) {
dispatch({
type: 'formList/getBatchOptions',
payload: { ids: refIds },
callback: (options) => {
this.setState({ options })
}
});
}
}
this.getPage();
}
},
});
}
}
sqlBs16=Base16Encode(this.props.sql)
getPage = (params, values,callPage) => {
if(this.columns==null||this.columns.length==0){
return;
}
const { dispatch } = this.props;
const pagination = this.state.data.pagination;
if (params == null) {
params = {
pageNo: pagination.current ? pagination.current : 1,
pageSize: pagination.pageSize ? pagination.pageSize : (this.props.pageSize||10),
query: JSON.stringify(values!=null?values:this.state.formValues),
};
}
if(this.props.objCode&&(this.props.objCode=="1"||this.props.objCode==1)){
if(callPage){
callPage(params,(data)=>{
if(!this.state.isReady){
this.setState({data,isReady:true})
}else{
this.setState({data})
}
})
}else if(this.props.value&&this.props.value.getPage){
this.props.value.getPage(params,(data)=>{
if(!this.state.isReady){
this.setState({data,isReady:true})
}else{
this.setState({data})
}
})
}
}else{
dispatch({
type: 'formList/fetch',
payload: {
custom:this.custom,
...params,
sql:this.sqlBs16,
dataObjId: this.state.objId,
},
callback:(data)=>{
if(!this.state.isReady){
this.setState({data,isReady:true})
}else{
this.setState({data})
}
}
});
}
};
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,
query: JSON.stringify(this.state.formValues),
};
if (sorter.field) {
params.sorter = `${sorter.field}_${sorter.order}`;
}
this.getPage(params);
};
handleAdd = (fields, isAdd) => {
let params = {
...fields,
};
this.props.dispatch({
type: 'formList/add',
payload: {
params: params,
objId: this.state.objId,
isAdd: isAdd,
isSelf: true,
isView:false
},
callback: () => {
message.success('操作成功');
this.setState({
modalVisible: false,
});
this.getPage();
},
});
};
handleModalVisible = () => {
this.setState({
modalVisible: this.state.modalVisible ? false : true,
formData: {},
});
};
add = () => {
// if (this.state.formItem.length < 10) {
this.getOptions()
this.setState({
modalVisible: true,
formData: {},
isAdd: true,
isView:false
});
// } else {
// router.push({
// pathname: '/admin/ddl/dataObj/formEdit',
// state: { id: this.state.objId,isAdd: true,isView:false }
// });
// }
};
handleSelectRows = rows => {
if(this.props.onSelectRow){
this.props.onSelectRow(rows)
}
this.setState({
selectedRows: rows,
});
};
batchDelete = e => {
const { dispatch } = this.props;
const { selectedRows } = this.state;
if (!selectedRows) return;
let columns = this.state.formItem;
let Keys = {};
for (let i in columns) {
if (columns[i].isPrimaryKey) {
//key
Keys[columns[i].name] = selectedRows.map(row => row[columns[i].name])
.join(',');
}
}
this.props.dispatch({
type: 'formList/delete',
payload: {
keys: JSON.stringify(Keys),
objId: this.state.objId,
isSelf: true
},
callback: () => {
this.setState({
selectedRows: [],
});
this.getPage();
},
});
};
goBack = () => {
router.goBack();
};
handleSearch = (e) => {
e.preventDefault();
const { dispatch, form } = this.props;
const {formValues} = this.state;
form.validateFields((err, fieldsValue) => {
if (err) return;
const formItem = this.state.formItem
formItem.map((item, index) => {
if (item.type.indexOf('DATE') > -1) {
for (let d in fieldsValue) {
if (item.name === d && fieldsValue[d]) {
if(fieldsValue[d]!=null&&fieldsValue[d].length>0){
fieldsValue[d]=[fieldsValue[d][0].format('YYYY-MM-DD HH:mm:ss'),fieldsValue[d][1].format('YYYY-MM-DD HH:mm:ss')];
}else {
fieldsValue[d]="";
}
}
}
}
});
const values = {
...this.state.formValues,
...fieldsValue
};
this.setState({
formValues: fieldsValue,
});
this.getPage(null, values)
});
}
hanldeHighSearch=(e)=>{
const pagination = this.props.formList.data.pagination;
let params = {
pageNo: pagination.current ? pagination.current : 1,
pageSize: pagination.pageSize ? pagination.pageSize : (this.props.pageSize||10),
...e
}
this.setState({formValues:{...e,...this.state.formValues}})
this.getPage(params)
}
handleFormReset = () => {
const { form, dispatch } = this.props;
form.resetFields();
this.setState({
formValues: {},
}, () => {
this.getPage()
});
}
getItem = (isQuery,form, item, isAdd, formData, labelCol, wrapperCol) => {
const {groups} =this.state;
if (item.isPrimaryKey) {
if (isAdd) {
return (<></>);
} else {
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<Input style={{ width: '70%' }} readOnly={!isAdd} placeholder="请输入"/>)}
</FormItem>
);
}
} else if (item.referenceObjId != null) {
const { options } = this.state
const ops = options[item.id + ''] || []
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<Select style={{ width: '70%' }} placeholder="请选择" allowClear>
{ops.map((r) => <Option value={r[item.referenceCodeName]}
key={r[item.referenceCodeName]}>{r[item.referenceNameName]}</Option>)}
</Select>)}
</FormItem>
);
}else if(item.name.indexOf("process_status")>-1){
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<Select style={{ width: '70%' }} placeholder="请选择" allowClear>
<Option value={'0'} key={'0'}>审核通过</Option>
<Option value={'2'} key={'2'}>审核未通过</Option>
</Select>)}
</FormItem>
);
} else if(isQuery&&item.isGroupQuery!=null&&item.isGroupQuery){ //如果是查询 并且是组合查询
const ops = groups[item.id + ''] || []
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<Select style={{ width: '70%' }} placeholder="请选择" allowClear>
{ops.map((r) => <Option value={r.value}
key={r.value}>{r.value}</Option>)}
</Select>)}
</FormItem>
);
} else if (text.indexOf(item.type) > -1) {
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<Input style={{ width: '70%' }} placeholder="请输入"/>)}
</FormItem>
);
} else if (number.indexOf(item.type) > -1) {
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<InputNumber placeholder="请输入" min={0}/>)}
</FormItem>
);
} else if (isQuery&&data.indexOf(item.type) > -1) {
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? null : moment(formData[item.name]),
rules: [{ required: !item.isNull }],
})(
<RangePicker format={item.dataFormatStrWeb==null?"YYYY-MM-DD HH:mm:ss":item.dataFormatStrWeb}
style={{ width: '95%' }} />)}
</FormItem>
);
}else if (data.indexOf(item.type) > -1) {
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? moment() :(formData[item.name]?moment(formData[item.name]):null),
rules: [{ required: !item.isNull }],
})(
<DatePicker
format={item.dataFormatStrWeb==null?"YYYY-MM-DD HH:mm:ss":item.dataFormatStrWeb}
style={{ width: '100%' }}
placeholder="请输入"
/>,
)}
</FormItem>
);
} else {
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : formData[item.name],
rules: [{ required: !item.isNull }],
})(<Input style={{ width: '70%' }} placeholder="请输入"/>)}
</FormItem>
);
}
}
renderForm() {
const {
form,
get,
} = this.props;
console.log(get)
const { querys } = this.state
if (querys.length == 0) {
return '';
}
return (
<Form layout="inline">
<Row style={{padding:"15px"}}>
{querys.map((item) =>
<Col style={{height:58}} span={get==='mobile'?24:8} key={item.id}>
{this.getItem(true,form, {
...item,
isNull: true
}, true)}
</Col>
)}
<Col span={get==='mobile'?24:8}
style={{
textAlign:get==='mobile'?'right':'',
paddingRight: get==='mobile'?12:''
}}
>
<span className={styles.submitButtons}>
<Button type="primary" loading={this.props.loading} onClick={this.handleSearch}>
查询
</Button>
<Button style={{ marginLeft: 8 }} onClick={this.handleFormReset}>
重置
</Button>
{/* <a style={{ marginLeft: 8 }} onClick={this.toggleForm}>
展开 <Icon type="down" />
</a> */}
</span>
</Col>
</Row>
</Form>
);
}
render() {
const {
modalVisible,
selectedRows,
querys,
tableWidth,
rights ,
data,
isReady,
} = this.state;
if(!isReady){
return <div style={{width:20,margin:"auto"}}><Spin/></div>
}
const {
isFormCom,
isSelect,
get,
callback,
valueName,
notShowBack,
istableCom, // 是否有模板设计器调用
} = this.props;
const {
showMobileDiv,
isView
} = this.state
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
let isMobile = scrollWidth < 1200
if(document.querySelector('#previewDiv')){
isMobile = true
}
let showDiv = document.querySelector('#mobelDiv')&&document.querySelector('#mobelDiv')?.parentNode.clientWidth
const parentMethods = {
handleAdd: this.handleAdd,
handleModalVisible: this.handleModalVisible,
formData: this.state.formData,
formItem: this.state.formItem,
isAdd: this.state.isAdd,
getItem: this.getItem,
isView:isView,
};
if(!isSelect&&!rights.includes('edit')&&!rights.includes('delete')&&!rights.includes("view")&&!rights.includes("viewProcess")){
}else{
let width=0;
if(rights && rights.includes('viewProcess')){
width=width+75;
}
if(rights && rights.includes('view')){
width=width+75;
}
if(rights && rights.includes('edit')){
width=width+40;
}
if(rights && rights.includes('delete')){
width=width+40;
}
const column = {
title: '操作',
fixed: 'right',
width: width,
render: (text, record) => {
return <Fragment>
<div style={{textAlign:'center'}}>
{isSelect ? this.state.selects.includes(record[valueName]) ? <><span>已选择</span><Divider
type="vertical"/></> : <><a
onClick={callback.bind(this, record, this.columns)}>选择</a><Divider
type="vertical"/></> : ''}
{rights && !rights.includes('view') ? '' : <><a
onClick={this.view.bind(this, record)}>查看详情</a><Divider type="vertical"/></>}
{rights && !rights.includes('edit') ? '' : <><a
onClick={this.modify.bind(this, record)}>编辑</a><Divider type="vertical"/></>}
{rights &&rights.includes("viewProcess")&&record.process_biz_key?<><a onClick={this.viewProcess.bind(this, record)}>查看流程详情</a><Divider type="vertical"/></>:''}
{rights && !rights.includes('delete') ? '' : <> <Popconfirm
title="确定删除该数据?"
onConfirm={this.delete.bind(this, record)}
okText="确定"
cancelText="取消"
>
<a>删除</a>
</Popconfirm></>}
</div>
</Fragment>
}
}
if(this.columns.length>0&&this.columns[this.columns.length-1].title=="操作"){
this.columns[this.columns.length-1]=column;
}else{
this.columns.push(column);
}
}
if(this.columns){
/**
* 计算总长度
*/
AllWidth = 0
this.columns = this.columns.map((item,index) => {
if(isEmpty(item)){
return item
}
if(index === this.columns.length-1&&this.columns[this.columns.length-1].title !== '操作'){
AllWidth+=150
item.width = ''
return item
}
let width = item.width?item.width:150
if(!item.width){
item.width = 150
}
AllWidth += width
return item
})
if(!isEmpty(this.columns[this.columns.length-1])
&&this.columns[this.columns.length-1].title === '操作'
){
this.columns[this.columns.length-2].width = ''
AllWidth+=100
}
}
const xxxx = <><Card bordered={false} bodyStyle={{padding:0}}>
<div className={styles.tableList}>
<div className={styles.tableListForm}>{this.renderForm()}</div>
<div className={styles.tableListOperator}>
{notShowBack ? notShowBack : <Button icon="rollback" type="primary" onClick={this.goBack}>
返回
</Button>}
{rights && !rights.includes('add') ? '' :
<Button icon="plus" type="primary" onClick={this.add}>
新建
</Button>}
{rights && !rights.includes('searchData') ? '' :<SearchInfo hanldeHighSearch={this.hanldeHighSearch} objId = {this.state.objId}/>}
{rights && !rights.includes('importData') ? '' : <ImportUtil objId={this.state.objId}/>}
{rights && !rights.includes('exportCurrent') ? '' : <ExportCurrentInfo objId={this.state.objId}
query={JSON.stringify(this.state.formValues)}
custom={this.props.value?Base16Encode(JSON.stringify(this.props.value)):null}
sql={Base16Encode(this.props.sql)}
/>}
{rights && !rights.includes('exportData') ? '' : <ExportInfo objId={this.state.objId}/>}
{rights && !rights.includes('statistics') ? '' :
<StatisticsInfo objId={this.state.objId}/>}
{rights && !rights.includes('delete') ? '' : selectedRows.length > 0 && (
<span>
<Popconfirm
title="确定删除该数据?"
onConfirm={this.batchDelete}
okText="确定"
cancelText="取消"
>
<Button>批量删除</Button></Popconfirm>
</span>
)}
</div>
{
(!istableCom)||(this.props.value&&this.props.value.columns)?
<StandardTable
showHeader={this.props.showHeader!=null?this.props.showHeader:true}
noSelectRow={this.props.onSelectRow==null&&( rights==null|| !rights.includes('delete')) }
rowKey="id"
data={data}
isHiddenPage={this.props.isHiddenPage!=null?this.props.isHiddenPage:false}
columns={this.columns}
scroll={this.props.value&&this.props.value.columns?{}:{ x: AllWidth }}
selectedRows={selectedRows}
onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange}
loading={this.props.loading}
/>
:
<div
id='mobelDiv'
style={{
overflow:'hidden',
width: isMobile?showMobileDiv:showDiv,
height: '100%'
}}
>
<div
>
{
get==='mobile'?
<div>手机端,请将手机横屏查看</div>
:null
}
{
showDiv&&<StandardTable
showHeader={this.props.showHeader!=null?this.props.showHeader:true}
noSelectRow={this.props.onSelectRow==null&&( rights==null|| !rights.includes('delete')) }
rowKey="id"
data={data}
columns={this.columns}
scroll={this.props.value&&this.props.value.columns?{}:{ x: AllWidth }}
selectedRows={selectedRows}
isHiddenPage={this.props.isHiddenPage!=null?this.props.isHiddenPage:false}
onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange}
loading={this.props.loading}
/>
}
</div>
</div>
}
</div>
</Card>
<CreateForm {...parentMethods} modalVisible={modalVisible}/></>
if (isFormCom) {
return xxxx
}
return (
<PageHeaderWrapper title="">
{xxxx}
</PageHeaderWrapper>
);
}
}
export default TreeList;
......@@ -32,6 +32,9 @@ import SearchInfo from '../../App/SearchInfo';
import {Base16Encode} from "../../Base16/index";
import baseX from 'base-x'
import {isEmpty} from 'lodash'
import FilePreview from "@/webPublic/one_stop_public/filePreview";
import {queryApiActionPath} from "@/webPublic/one_stop_public/utils/queryConfig";
import UploadCom from "@/components/libs/UploadCom";
const BASE16 = '0123456789abcdef'
const bs16 = baseX(BASE16)
const FormItem = Form.Item;
......@@ -232,6 +235,24 @@ class FormList extends React.Component {
// }
};
isJSON = (str) => {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
console.log('error:' + str + '!!!' + e);
return false;
}
}
console.log('这不是个字符串')
}
delete = record => {
//找出主键
let Keys = {};
......@@ -361,27 +382,23 @@ class FormList extends React.Component {
const b = nextProps.value||{}
const a = this.props.value||{}
if(JSON.stringify(a)!=JSON.stringify(b)){
const params = {
pageNo: 1,
pageSize: this.props.pageSize||10,
query: JSON.stringify(this.state.formValues),
};
this.custom=Base16Encode(JSON.stringify(b))
if(this.state.objId)this.getPage(params)
}
if(this.props.objCode=="1"||this.props.objCode==1){
if(JSON.stringify(a)!=JSON.stringify(b)){
const params = {
pageNo: 1,
pageSize: this.props.pageSize||10,
query: JSON.stringify(this.state.formValues),
};
if(nextProps.value.columns!=null&&nextProps.value.columns.length>0){
this.columns=nextProps.value.columns
}
this.custom=Base16Encode(JSON.stringify(b))
if( nextProps.value.getPage){
this.getPage(params,null,nextProps.value.getPage);
}else{
if(this.state.objId)this.getPage(params)
}
}
const x=nextProps.selects
......@@ -444,7 +461,27 @@ class FormList extends React.Component {
}
}else if(datas[t].name.indexOf("process_status")>-1){
column.render=(val)=>val?(val==="0"?"审核通过":"审核未通过"):null
}else if(datas[t].extendTypeId&&datas[t].extendTypeId.indexOf("file")>-1){ //特殊处理附件
column.render =( val) =>{
if(this.isJSON(val)){
val = JSON.parse(val);
let files = val.files;
let xx =( <ul>
{files.map((f, index2) => {
return <li key={index2}><FilePreview
path={queryApiActionPath() + f.path}
pathName={f.name}
/></li>
}
)}
</ul>
)
return xx;
}else {
return val;
}
}
}else{
column.render=(val)=>val&&val.length>100? <Tooltip title={val} overlayStyle={{width:1000}}>
<span style={{width:column.width||200,display:"block", wordBreak:"keep-all",whiteSpace:"nowrap", overflow:"hidden", textOverflow:"ellipsis"}}>{val}</span>
</Tooltip>:val
......@@ -770,6 +807,17 @@ class FormList extends React.Component {
</FormItem>
);
} else if(item.extendTypeId&&item.extendTypeId.indexOf("file")>-1){
//特殊处理附件 如果是查询就 跳过
if(isQuery) return ;
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : (formData[item.name]&&this.isJSON(formData[item.name])?JSON.parse(formData[item.name]):null),
rules: [{ required: !item.isNull }],
})(<UploadCom />)}
</FormItem>
);
} else if(isQuery&&item.isGroupQuery!=null&&item.isGroupQuery){ //如果是查询 并且是组合查询
const ops = groups[item.id + ''] || []
......@@ -965,7 +1013,7 @@ class FormList extends React.Component {
onClick={this.view.bind(this, record)}>查看详情</a><Divider type="vertical"/></>}
{rights && !rights.includes('edit') ? '' : <><a
onClick={this.modify.bind(this, record)}>编辑</a><Divider type="vertical"/></>}
{rignt&&rights.includes("viewProcess")&&record.process_biz_key?<><a onClick={this.viewProcess.bind(this, record)}>查看流程详情</a><Divider type="vertical"/></>:''}
{rights&&rights.includes("viewProcess")&&record.process_biz_key?<><a onClick={this.viewProcess.bind(this, record)}>查看流程详情</a><Divider type="vertical"/></>:''}
{rights && !rights.includes('delete') ? '' : <> <Popconfirm
title="确定删除该数据?"
onConfirm={this.delete.bind(this, record)}
......
......@@ -49,6 +49,7 @@ import TableSelect from '../libs/TableSelect';
import LocationCom from '../libs/LocationCom'
import MobileDate from '../libs/MobileDate';
import ChildForm from '../libs/ChildForm';
import ImgUploadCom from '../libs/ImgUploadCom';
import moment from 'moment';
import router from 'umi/router';
import TableList from '../libs/TableList';
......@@ -115,13 +116,6 @@ const errorHandler = error => {
}
};
let oldProps = {}
const normFile = (e) => {
if (Array.isArray(e)) {
return e;
}
return e && e.fileList[0];
}
@connect(({ DataColumn, SqlManageEntity, formList, loading }) => ({
DataColumn, SqlManageEntity, formList,
loading: loading.models.DataColumn || loading.models.SqlManageEntity || loading.models.formList
......@@ -430,7 +424,7 @@ export default class tableCom extends Component {
componentWillReceiveProps(props) {
const { json, mapData, obj } = props;
if (json == null) {
if (json == null||this.props.safe) {
return;
}
if (!(this.dataFilter.includes(json.comName) || json.comName == "TableSelect") && json.isFormulaOnce) {
......@@ -772,7 +766,7 @@ export default class tableCom extends Component {
}
reqUtil = (base52, json, orgCallback, url, method, params, callback, options = {}) => {
//查缓存
var isChange = false;
var isChange = true;
if (url.indexOf("http") === -1) {
url = config.httpServer + url
}
......@@ -858,7 +852,7 @@ export default class tableCom extends Component {
}
return "norefeshxxxxxxxxxxxxxxxxxxxx"
}
this.setState({ reqUrls }, () => {
this.setState({ }, () => {
for (let i in params) {
if (params[i] == null) {
delete params[i]
......@@ -882,10 +876,10 @@ export default class tableCom extends Component {
method: method,
requestType: "form"
}).then(data => {
this.setState({ res: data }, () => {
const { reqUrls } = this.state
reqUrls[url].data = data
this.setState({ reqUrls })
this.setState({ res: data,reqUrls }, () => {
if (callback) {
if (json.optionType && json.optionType == "func") {
......@@ -1289,7 +1283,7 @@ export default class tableCom extends Component {
}
this.getData(json, dataColumn, obj)
if (json.formula != null && json.formula != "") {
if (json.formula != null && json.formula != ""&&!this.props.safe) {
this.getFunctionValue(json.formula, dataColumn, json)
}
......@@ -1469,16 +1463,7 @@ export default class tableCom extends Component {
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() {
/**
* json为申请表单
......@@ -1931,19 +1916,14 @@ export default class tableCom extends Component {
if (end != null) ivs.push(moment(parseInt(init[end.base52])));
}
if (begin != null && end != null) {
if (!isEdit) {
r:
cm = <span>
{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')}
</span>
} else {
cm = getFieldDecorator(begin.base52 + '_' + end.base52, {
initialValue: ivs,
rules: [{ required: required, message: '请选择起止时间' }],
})(<RangePicker showTime />);
}
} else {
cm = ""
}
......@@ -2106,6 +2086,8 @@ export default class tableCom extends Component {
}
cm = <TableList
get={get}
isTree = {json.isTree}
json={json}
loading={this.props.loading}
showHeader={json.showHeader}
isHiddenPage={json.isHiddenPage}
......@@ -2543,7 +2525,7 @@ export default class tableCom extends Component {
cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
initialValue: ivs,
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) {
cm = <Form.Item
labelCol={{ span: json.labelSpan }}
......@@ -2558,7 +2540,7 @@ export default class tableCom extends Component {
cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
initialValue: ivs,
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 = '起止时间';
break;
......@@ -2610,7 +2592,7 @@ export default class tableCom extends Component {
rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
})(<DatePicker
disabled={disabled}
showTime
showTime={json.showTime!=null?json.showTime:true}
onOpenChange={get === 'mobile' ? () => { // 取消唤起移动端小键盘
setTimeout(() => {
if (document.querySelector('.ant-calendar-input ')) {
......@@ -2711,15 +2693,9 @@ export default class tableCom extends Component {
break;
case 'ImgUploadCom':
cm = getFieldDecorator("img$" + dataColumn.base52, {
valuePropName: 'fileList[0]',
getValueFromEvent: normFile,
})(<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>);
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
})(<ImgUploadCom json={json} disabled={disabled}/>);
if (get === 'mobile' && json.isLabel && title) {
cm = <Form.Item
labelCol={{ span: json.labelSpan }}
......@@ -2755,6 +2731,8 @@ export default class tableCom extends Component {
initialValue: initValue || {}
})(<TableList
json={json}
isTree = {json.isTree}
isHiddenPage={json.isHiddenPage}
showHeader={json.showHeader}
loading={this.props.loading}
......
import React, { Fragment, Component } from 'react';
import styles from './index.less';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '@/baseComponent/Shell';
import { ModalConfirm } from '@/baseComponent/Modal';
export default class FormatSetting extends Component {
dragEventList = () => {
const { formatSettingObject, updateFormatSettingObject } = this.props;
let draggedRef = null;
document.addEventListener('dragstart', function(event) {
// 保存拖动元素的引用(ref.)
draggedRef = event.target;
// 使其半透明
event.target.style.opacity = 0.5;
}, false);
document.addEventListener('dragend', function(event) {
// 重置透明度
event.target.style.opacity = '';
}, false);
/* 放下目标节点时触发事件 */
document.addEventListener('dragover', function(event) {
// 阻止默认动作
event.preventDefault();
}, false);
document.addEventListener('drop', function(event) {
// 阻止默认动作(如打开一些元素的链接)
event.preventDefault();
// 将拖动的元素到所选择的放置目标节点中
if (event.target.id === 'dropZone') {
const left = event.offsetX;
if (left > (event.target.width - draggedRef.offsetWidth - 10)) {
console.log('拖拽到了图片区域外部,不能进行拖拽');
return false;
}
const top = event.offsetY;
updateFormatSettingObject(draggedRef.id, left, top);
draggedRef.style.left = left; // `${left}px`;
draggedRef.style.top = top; // `${top}px`;
}
}, false);
};
componentDidMount() {
this.dragEventList();
}
initConfig = () => {
ModalConfirm('您确定初始化打印录取通知书格式吗?',{
onOk: ()=>{
this.props.initConfig();
},
});
};
render() {
const { bgImage, formatSettingObject, saveConfig } = this.props;
const configInfo = Object.keys(formatSettingObject);
return <Fragment>
<Shell styleShell={{marginTop: '0',marginBottom: '20px'}}>
<div style={{ height: '54px', padding: '12px 0 12px 12px' }}>
<ButtonDiy name="保存"
className="primary"
handleClick={saveConfig}
/>
<ButtonDiy name={'初始化格式'}
handleClick={this.initConfig}
/>
</div>
</Shell>
<div className={styles.outSideDiv}>
<div>
<img src={bgImage}
id={'dropZone'}
draggable={false}
className={styles.bgimage}
alt={'背景图'}
/>
{configInfo.map((x) => {
return (
<div draggable={true}
className={styles.inSideItem}
key={x}
id={x}
style={formatSettingObject[x].style}
>
{formatSettingObject[x].title}
</div>
);
})}
</div>
</div>
</Fragment>
;
}
}
/***
* formatSettingObject: {
* content_set: {
* font: "宋体"
isNeedConfig: true
key: "JjqCiRYamxs"
name: "content_set"
size: "12"
style: {top: 300, left: 50}
title: "--详细内容--"
* }
* }
*
* */
.outSideDiv{
position: relative;
text-align: left;
width: 100%;
.bgimage{
height: auto;
overflow: auto;
z-index: 1;
}
.inSideItem{
position: absolute;
cursor: move;
z-index: 10;
color: #000;
padding-left: 10px;
padding-right: 10px;
font-size: 14px;
line-height: 28px;
border: 1px solid gray;
background-color: #CCC;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论