提交 7049d1d3 authored 作者: 钟是志's avatar 钟是志

流程引擎 申请 审核页面表头字段回显bug

8614 评奖评优,流程审核结束后当前节点为空
上级 9027c58d
...@@ -6,9 +6,10 @@ import ColumnsRender from '@/highOrderComponent/ColumnsRender'; ...@@ -6,9 +6,10 @@ import ColumnsRender from '@/highOrderComponent/ColumnsRender';
import StandardTable from '@/components/StandardTable'; import StandardTable from '@/components/StandardTable';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { deepCopy } from '@/baseComponent/utils'; import { deepCopy } from '@/baseComponent/utils';
import { date, format, text } from '../../config'; import { date, format, text, taskNode } from '../../config';
import moment from 'moment'; import moment from 'moment';
import { Tooltip } from 'antd'; import { Tooltip } from 'antd';
import { handleColumns } from '@/webPublic/FormInsertDiy/AffairPage/destruction';
export default class List extends Component { export default class List extends Component {
constructor(props) { constructor(props) {
...@@ -38,9 +39,9 @@ export default class List extends Component { ...@@ -38,9 +39,9 @@ export default class List extends Component {
giveDefaultValue = (props) => { giveDefaultValue = (props) => {
// 如果设置了 giveFieldsToFormValues 则将默认值赋值给formValues // 如果设置了 giveFieldsToFormValues 则将默认值赋值给formValues
let formValues = {}; let formValues = {};
if(props.pageSearch && props.pageSearch.search && props.pageSearch.search.giveFieldsToFormValues){ if (props.pageSearch && props.pageSearch.search && props.pageSearch.search.giveFieldsToFormValues) {
for(let x in props.pageSearch.search.field){ for (let x in props.pageSearch.search.field) {
if(props.pageSearch.search.field[x].required === true){ if (props.pageSearch.search.field[x].required === true) {
formValues[x] = props.pageSearch.search.field[x].defaultValue; formValues[x] = props.pageSearch.search.field[x].defaultValue;
} }
} }
...@@ -67,7 +68,7 @@ export default class List extends Component { ...@@ -67,7 +68,7 @@ export default class List extends Component {
data.pageSize = pagination.pageSize; data.pageSize = pagination.pageSize;
data.pageNo = pagination.current; data.pageNo = pagination.current;
} }
if(search.beforeGetPage){ if (search.beforeGetPage) {
data = search.beforeGetPage(data); data = search.beforeGetPage(data);
} }
return data; return data;
...@@ -78,14 +79,14 @@ export default class List extends Component { ...@@ -78,14 +79,14 @@ export default class List extends Component {
const { pagination, sortGetPageFields } = this.state; const { pagination, sortGetPageFields } = this.state;
const { search } = pageSearch; const { search } = pageSearch;
let data = this.giveGetPageFields(); let data = this.giveGetPageFields();
if(!data){ if (!data) {
return false; return false;
} }
if(search.handleSort){ if (search.handleSort) {
data = { data = {
...data, ...data,
...sortGetPageFields, // 增加排序的搜索条件 ...sortGetPageFields, // 增加排序的搜索条件
} };
} }
this.setState({ this.setState({
list: [], list: [],
...@@ -139,19 +140,19 @@ export default class List extends Component { ...@@ -139,19 +140,19 @@ export default class List extends Component {
/** /**
* 如果设置了beforeChange回调函数 则调用此回调函数改变另外的字段的值 * 如果设置了beforeChange回调函数 则调用此回调函数改变另外的字段的值
* */ * */
const index = condition.findIndex((item)=>{ const index = condition.findIndex((item) => {
return item.key === key; return item.key === key;
}); });
if(index !== -1){ if (index !== -1) {
const thisConfig = condition[index]; const thisConfig = condition[index];
if(thisConfig.beforeChange){ if (thisConfig.beforeChange) {
oldValue = thisConfig.beforeChange(oldValue,thisConfig); oldValue = thisConfig.beforeChange(oldValue, thisConfig);
} }
} }
this.setState({ this.setState({
formValues: oldValue, formValues: oldValue,
},()=>{ }, () => {
if(search.afterFormValuesChange){ if (search.afterFormValuesChange) {
search.afterFormValuesChange(key, oldValue, this.getPage); search.afterFormValuesChange(key, oldValue, this.getPage);
} }
}); });
...@@ -165,7 +166,7 @@ export default class List extends Component { ...@@ -165,7 +166,7 @@ export default class List extends Component {
componentDidMount() { componentDidMount() {
const { search } = this.props.pageSearch; const { search } = this.props.pageSearch;
if(!search.noNeedInitData){ if (!search.noNeedInitData) {
this.getPage(); this.getPage();
} }
} }
...@@ -173,20 +174,20 @@ export default class List extends Component { ...@@ -173,20 +174,20 @@ export default class List extends Component {
componentWillMount() { componentWillMount() {
} }
componentWillUnmount(){ componentWillUnmount() {
} }
resetFormValues = () => { resetFormValues = () => {
const { beforeResetFormValues } = this.props.pageSearch.search; const { beforeResetFormValues } = this.props.pageSearch.search;
let { formValues } = this.state; let { formValues } = this.state;
if(beforeResetFormValues){ if (beforeResetFormValues) {
formValues = beforeResetFormValues(formValues); formValues = beforeResetFormValues(formValues);
}else{ } else {
formValues = {} ; formValues = {};
} }
this.setState({ this.setState({
formValues, formValues,
}) });
}; };
/** /**
...@@ -194,86 +195,30 @@ export default class List extends Component { ...@@ -194,86 +195,30 @@ export default class List extends Component {
* */ * */
handleOnChange = (pagination, filters, sorter) => { handleOnChange = (pagination, filters, sorter) => {
const { pageSearch } = this.props; const { pageSearch } = this.props;
if(sorter){ if (sorter) {
const sortGetPageFields = pageSearch.search.handleSort(sorter); const sortGetPageFields = pageSearch.search.handleSort(sorter);
this.setState({ this.setState({
sortGetPageFields, sortGetPageFields,
},()=>{ }, () => {
this.getPage(); this.getPage();
}) });
} }
}; };
render() { render() {
const { formValues, selectRows, list, pagination, loading } = this.state; const { formValues, selectRows, list, pagination, loading } = this.state;
const { listConfig, pageSearch, pageButton ,children, addFields} = this.props; const { listConfig, pageSearch, pageButton, children, addFields } = this.props;
const { columns, search } = pageSearch; let { columns, search } = pageSearch;
const columnsLength = columns.length; columns = handleColumns(columns);
for(let item of columns){
if(typeof item.renderConfig !== 'undefined' && !item.render){
item.render = (text,record)=>{
return <ColumnsRender text={text}
getPage={this.getPage}
config={item.renderConfig}
record={record} />
}
}
if (item.dataType && text.indexOf(item.dataType)> -1){
item.render = (text) => {
if (typeof text === 'string' && text.length > 20) {
const oldTitle = text;
const newTitle = text.slice(0, 7) + '...';
return (
<Tooltip title={oldTitle} key={oldTitle} style={{ width: 260 }}>
<span key={text}>{newTitle}</span>
</Tooltip>
);
} else if (typeof text === 'object' && Array.isArray(text.files) && text.files.length){
return <a href={text.files[0].path} target={'_blank'}>点击查看</a>;
}else{
return text;
}
}
}
if(item.dataType && date.indexOf(item.dataType) > -1){
item.render = (text, record) => {
if(!text){
return '';
}
if(!isNaN(parseInt(text)) && parseInt(text) > 10000000 ){
text = parseInt(text);
}
return moment(text).format(format[item.dataType]);
};
}
if(item.dataIndex === 'rate'){
item.render = (text, record) => {
if(text || text == 0){
return Number(text) + '%';
}else{
return '';
}
}
}
if(columnsLength > 10 && item.title && !item.width){
item.width = item.title.length * 30;
if(item.title === '学号'){
item.width = 140;
}
if(item.title.indexOf('时间') > -1){
item.width = 150;
}
}
}
let data = list; let data = list;
for(let item of addFields){ for (let item of addFields) {
if(item.type === 'tableSelect' && item.c1){ if (item.type === 'tableSelect' && item.c1) {
for(let i = 0; i < data.length; i++ ){ for (let i = 0; i < data.length; i++) {
let nameKey = item.componentProps.labelName; let nameKey = item.componentProps.labelName;
if(data[i][item.c1] && data[i][item.c1].selects){ if (data[i][item.c1] && data[i][item.c1].selects) {
let res = []; let res = [];
for(let x in data[i][item.c1].selects){ for (let x in data[i][item.c1].selects) {
res.push(data[i][item.c1].selects[x][nameKey]); res.push(data[i][item.c1].selects[x][nameKey]);
} }
data[i][item.c1] = res.join(','); data[i][item.c1] = res.join(',');
...@@ -284,17 +229,17 @@ export default class List extends Component { ...@@ -284,17 +229,17 @@ export default class List extends Component {
const tableProps = { const tableProps = {
rowKey: pageSearch.tableRowKey || 'id', rowKey: pageSearch.tableRowKey || 'id',
selectedRows: selectRows, selectedRows: selectRows,
data: {list: data, pagination}, data: { list: data, pagination },
columns, columns,
bordered: pageSearch.bordered || false, bordered: pageSearch.bordered || false,
loading, loading,
noSelectRow: !listConfig.selectRows, noSelectRow: !listConfig.selectRows,
onSelectRow: this.handleSelectRows, onSelectRow: this.handleSelectRows,
}; };
if(!listConfig.paging){ if (!listConfig.paging) {
tableProps.data = {list: data, pagination:false}; tableProps.data = { list: data, pagination: false };
} }
if(search && search.handleSort){ if (search && search.handleSort) {
tableProps.onChange = this.handleOnChange; tableProps.onChange = this.handleOnChange;
} }
return ( return (
...@@ -343,9 +288,7 @@ List.defaultProps = { ...@@ -343,9 +288,7 @@ List.defaultProps = {
pageSearch: { pageSearch: {
search: { search: {
url: '', url: '',
field: { field: {},
},
responseCallBack: (response) => { responseCallBack: (response) => {
return response; return response;
}, },
......
...@@ -11,6 +11,7 @@ import { date, format, text } from '../../config'; ...@@ -11,6 +11,7 @@ import { date, format, text } from '../../config';
import moment from 'moment'; import moment from 'moment';
import { handleAudit } from '../publicApiService'; import { handleAudit } from '../publicApiService';
import { Tooltip } from 'antd'; import { Tooltip } from 'antd';
import { handleColumns } from '@/webPublic/FormInsertDiy/AffairPage/destruction';
export default class List extends Component { export default class List extends Component {
constructor(props) { constructor(props) {
...@@ -258,67 +259,8 @@ export default class List extends Component { ...@@ -258,67 +259,8 @@ export default class List extends Component {
render() { render() {
const { formValues, selectRows, list, pagination, loading } = this.state; const { formValues, selectRows, list, pagination, loading } = this.state;
const { listConfig, pageSearch, pageButton ,children, addFields} = this.props; const { listConfig, pageSearch, pageButton ,children, addFields} = this.props;
const { columns, search } = pageSearch; let { columns, search } = pageSearch;
const columnsLength = columns.length; columns = handleColumns(columns);
for(let item of columns){
if(typeof item.renderConfig !== 'undefined' && !item.render){
item.render = (text,record)=>{
return <ColumnsRender text={text}
getPage={this.getPage}
config={item.renderConfig}
record={record} />
}
}
if(item.dataType && date.indexOf(item.dataType) > -1){
item.render = (text, record) => {
if(!text){
return '';
}
if(!isNaN(parseInt(text)) && parseInt(text) > 10000000 ){
text = parseInt(text);
}
return moment(text).format(format[item.dataType]);
};
}
if (item.dataType && text.indexOf(item.dataType)> -1){
item.render = (text) => {
if (typeof text === 'string' && text.length > 20) {
const oldTitle = text;
const newTitle = text.slice(0, 7) + '...';
return (
<Tooltip title={oldTitle} key={oldTitle} style={{ width: 260 }}>
<span key={text}>{newTitle}</span>
</Tooltip>
);
} else if (typeof text === 'object' && Array.isArray(text.files) && text.files.length){
return <a href={text.files[0].path} target={'_blank'}>点击查看</a>;
}else{
return text;
}
}
}
if(item.dataIndex === 'rate'){
item.render = (text, record) => {
if(text || text == 0){
return Number(text) + '%';
}else{
return '';
}
}
}
if(columnsLength > 10 && item.title && !item.width){
item.width = item.title.length * 30;
if(item.title === '学号'){
item.width = 140;
}
if(item.title.indexOf('时间') > -1){
item.width = 150;
}
}
}
let data = list; let data = list;
for(let item of addFields){ for(let item of addFields){
...@@ -398,13 +340,7 @@ List.defaultProps = { ...@@ -398,13 +340,7 @@ List.defaultProps = {
pageSearch: { pageSearch: {
search: { search: {
url: '', url: '',
field: { field: {},
// status:{
// required: true,
// defaultValue: undefined,
// 如果有查询的字段必填且defaultValue=undefined 应该在页面的constructor方法中 通过各种方法把默认值传进去.
// }
},
responseCallBack: (response) => { responseCallBack: (response) => {
return response; return response;
}, },
......
import { text, number, date } from '../config/index'; import { text, number, date, format, taskNode } from '../config/index';
import { isJSON } from '@/baseComponent/utils'; import { isJSON } from '@/baseComponent/utils';
import { translateAddFields } from '../config/index'; import { translateAddFields } from '../config/index';
import ColumnsRender from '@/highOrderComponent/ColumnsRender';
import { Tooltip } from 'antd';
import moment from 'moment';
import React from 'react';
const handleSqlModels = (sqlModels, defaultValues) => { const handleSqlModels = (sqlModels, defaultValues) => {
if (typeof sqlModels === 'undefined' || !Array.isArray(sqlModels)) { if (typeof sqlModels === 'undefined' || !Array.isArray(sqlModels)) {
...@@ -301,3 +306,65 @@ export function getDefaultValues(addFields = [], tableInfo = {}){ ...@@ -301,3 +306,65 @@ export function getDefaultValues(addFields = [], tableInfo = {}){
return values; return values;
} }
export function handleColumns(columns){
const columnsLength = columns.length;
for (let item of columns) {
if (item.dataType) {
if (text.indexOf(item.dataType) > -1) { // 文本类型字段
item.render = (text) => {
if (typeof text === 'string' && text.length > 20) {
const oldTitle = text;
const newTitle = text.slice(0, 7) + '...';
return (
<Tooltip title={oldTitle} key={oldTitle} style={{ width: 260 }}>
<span key={text}>{newTitle}</span>
</Tooltip>
);
} else if (typeof text === 'object' && Array.isArray(text.files) && text.files.length) {
return <a href={text.files[0].path} target={'_blank'}>点击查看</a>;
} else {
return text;
}
};
} else if (date.indexOf(item.dataType) > -1) { // 日期类型字段
item.render = (text, record) => {
if (!isNaN(parseInt(text)) && parseInt(text) > 10000000) {
text = parseInt(text);
}
return moment(text).format(format[item.dataType]);
};
} else if (taskNode.indexOf(item.dataType) > -1) { // 流程节点类型
item.render = (text, record) => {
if (record.isEnd) {
return '已完成';
} else {
return text || record.taskName;
}
};
}
}
if (item.dataIndex === 'rate') {
item.render = (text, record) => {
if (text || text == 0) {
return Number(text) + '%';
} else {
return '';
}
};
}
if (columnsLength > 10 && item.title && !item.width) {
item.width = item.title.length * 30;
if (item.title === '学号') {
item.width = 140;
}
if (item.title.indexOf('时间') > -1) {
item.width = 150;
}
}
}
return columns;
}
...@@ -37,7 +37,7 @@ const text = [ ...@@ -37,7 +37,7 @@ const text = [
const number = ['BIGINT', 'DOUBLE', 'FLOAT', 'INT', 'INTEGER', 'NUMERIC', 'SMALLINT', 'TINYINT']; const number = ['BIGINT', 'DOUBLE', 'FLOAT', 'INT', 'INTEGER', 'NUMERIC', 'SMALLINT', 'TINYINT'];
const date = ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR']; const date = ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'];
const taskNode = ['TASKNODE'];
const format = { const format = {
//欢哥那边定义好的 时间格式类型 //欢哥那边定义好的 时间格式类型
DATE: 'YYYY-MM-DD HH:mm', DATE: 'YYYY-MM-DD HH:mm',
...@@ -245,4 +245,5 @@ export { ...@@ -245,4 +245,5 @@ export {
transLateTimeTOUnix, transLateTimeTOUnix,
format, format,
mustHaveValue, mustHaveValue,
taskNode,
}; };
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论