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

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

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