提交 551b5ddf authored 作者: 徐立's avatar 徐立
...@@ -230,6 +230,7 @@ export default class List extends Component { ...@@ -230,6 +230,7 @@ export default class List extends Component {
loading, loading,
noSelectRow: !listConfig.selectRows, noSelectRow: !listConfig.selectRows,
onSelectRow: this.handleSelectRows, onSelectRow: this.handleSelectRows,
scroll: {x: true},
}; };
if (!listConfig.paging) { if (!listConfig.paging) {
tableProps.data = { list: data, pagination: false }; tableProps.data = { list: data, pagination: false };
......
...@@ -282,6 +282,7 @@ export default class List extends Component { ...@@ -282,6 +282,7 @@ export default class List extends Component {
loading, loading,
noSelectRow: !listConfig.selectRows, noSelectRow: !listConfig.selectRows,
onSelectRow: this.handleSelectRows, onSelectRow: this.handleSelectRows,
scroll: {x: true},
}; };
if(!listConfig.paging){ if(!listConfig.paging){
tableProps.data = {list: data, pagination:false}; tableProps.data = {list: data, pagination:false};
......
...@@ -6,7 +6,6 @@ import { Tooltip } from 'antd'; ...@@ -6,7 +6,6 @@ import { Tooltip } from 'antd';
import moment from 'moment'; import moment from 'moment';
import React from 'react'; 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)) {
return []; return [];
...@@ -52,7 +51,6 @@ const handleSqlModels = (sqlModels, defaultValues) => { ...@@ -52,7 +51,6 @@ const handleSqlModels = (sqlModels, defaultValues) => {
} }
}; };
const funcHandleFileds = (source, obj, fieldsColumns) => { const funcHandleFileds = (source, obj, fieldsColumns) => {
let fileds = []; let fileds = [];
for (let item of source) { for (let item of source) {
...@@ -65,14 +63,14 @@ const funcHandleFileds = (source, obj, fieldsColumns) => { ...@@ -65,14 +63,14 @@ const funcHandleFileds = (source, obj, fieldsColumns) => {
comName: content.comName, comName: content.comName,
name: content.label || '', name: content.label || '',
}; };
if(content.comName === 'DatePicker'){ if (content.comName === 'DatePicker') {
if(content.format){ if (content.format) {
oneFiled.format = content.format; oneFiled.format = content.format;
} }
} }
if(content.comName === 'PartForm'){ if (content.comName === 'PartForm') {
const { childFormKey, columnIds, } = content; const { childFormKey, columnIds } = content;
if(childFormKey){ if (childFormKey) {
let thisSource = obj[childFormKey].items; let thisSource = obj[childFormKey].items;
let thisFields = funcHandleFileds(thisSource, obj, fieldsColumns); let thisFields = funcHandleFileds(thisSource, obj, fieldsColumns);
for (let i = 0; i < thisFields.length; i++) { for (let i = 0; i < thisFields.length; i++) {
...@@ -90,22 +88,23 @@ const funcHandleFileds = (source, obj, fieldsColumns) => { ...@@ -90,22 +88,23 @@ const funcHandleFileds = (source, obj, fieldsColumns) => {
}; };
} }
} }
if(content.comName === 'RangePicker'){ if (content.comName === 'RangePicker') {
if(content.format){ if (content.format) {
oneFiled.format = content.format; oneFiled.format = content.format;
} }
} }
if (content.comName === 'Description') { if (content.comName === 'Description') {
oneFiled.key = content.sqls[1]; oneFiled.key = content.sqls[1];
} }
if(['Radio', 'Select', 'Checkbox'].indexOf(content.comName)> -1){ // 枚举值 if (['Radio', 'Select', 'Checkbox'].indexOf(content.comName) > -1) {
if(content.optionType){ // 枚举值
if (content.optionType) {
oneFiled.optionType = content.optionType; oneFiled.optionType = content.optionType;
switch (oneFiled.optionType) { switch (oneFiled.optionType) {
case 'enum': case 'enum':
if(content.enums){ if (content.enums) {
let options = isJSON(content.enums) ? JSON.parse(content.enums) : []; let options = isJSON(content.enums) ? JSON.parse(content.enums) : [];
options = options.map((x)=>{ options = options.map((x) => {
return { key: x.value, name: x.label }; return { key: x.value, name: x.label };
}); });
oneFiled.options = options; oneFiled.options = options;
...@@ -120,17 +119,20 @@ const funcHandleFileds = (source, obj, fieldsColumns) => { ...@@ -120,17 +119,20 @@ const funcHandleFileds = (source, obj, fieldsColumns) => {
oneFiled.valueName = content.valueName; oneFiled.valueName = content.valueName;
break; break;
default: default:
oneFiled.options =[]; oneFiled.options = [];
break; break;
} }
} }
} }
if(content.comName === 'ChildForm'){ if (content.comName === 'ChildForm') {
const { childFormKey, columnIds, } = content; const { childFormKey, columnIds } = content;
let thisSource = obj[childFormKey].items; let thisSource = obj[childFormKey].items;
let thisFields = funcHandleFileds(thisSource, obj, fieldsColumns); let thisFields = funcHandleFileds(thisSource, obj, fieldsColumns);
for (let i = 0; i < thisFields.length; i++) { for (let i = 0; i < thisFields.length; i++) {
if (typeof thisFields[i].c1 !== 'undefined' && typeof fieldsColumns[thisFields[i].c1] !== 'undefined') { if (
typeof thisFields[i].c1 !== 'undefined' &&
typeof fieldsColumns[thisFields[i].c1] !== 'undefined'
) {
thisFields[i] = { thisFields[i] = {
...fieldsColumns[thisFields[i].c1], ...fieldsColumns[thisFields[i].c1],
...thisFields[i], ...thisFields[i],
...@@ -143,7 +145,7 @@ const funcHandleFileds = (source, obj, fieldsColumns) => { ...@@ -143,7 +145,7 @@ const funcHandleFileds = (source, obj, fieldsColumns) => {
thisFields, thisFields,
}; };
} }
if(content.comName === 'TableSelect'){ if (content.comName === 'TableSelect') {
oneFiled.componentProps = { oneFiled.componentProps = {
sqlKey: content.sqlKey, sqlKey: content.sqlKey,
labelName: content.labelName, labelName: content.labelName,
...@@ -151,8 +153,9 @@ const funcHandleFileds = (source, obj, fieldsColumns) => { ...@@ -151,8 +153,9 @@ const funcHandleFileds = (source, obj, fieldsColumns) => {
isMultiple: content.isMultiple, isMultiple: content.isMultiple,
}; };
} }
if(content.comName === 'Label'){ // 提示信息显示 if (content.comName === 'Label') {
if(info.hidden){ // 提示信息显示
if (info.hidden) {
continue; continue;
} }
oneFiled.key = content.initialValue ? content.initialValue.slice(0, 10) : ' '; oneFiled.key = content.initialValue ? content.initialValue.slice(0, 10) : ' ';
...@@ -169,16 +172,15 @@ const funcHandleFileds = (source, obj, fieldsColumns) => { ...@@ -169,16 +172,15 @@ const funcHandleFileds = (source, obj, fieldsColumns) => {
} }
} }
return fileds; return fileds;
}; };
export async function destructionGetDetail(response) { export async function destructionGetDetail(response) {
/** /**
* 如果数据校验不通过直接pass 返回默认值, * 如果数据校验不通过直接pass 返回默认值,
* */ * */
if (typeof response.unifiedServicePatternModel === 'undefined' || if (
typeof response.unifiedServicePatternModel === 'undefined' ||
!isJSON(response.unifiedServicePatternModel.content) || !isJSON(response.unifiedServicePatternModel.content) ||
!Array.isArray(response.unifiedServicePatternModel.dataObjModels) || !Array.isArray(response.unifiedServicePatternModel.dataObjModels) ||
!response.unifiedServicePatternModel.dataObjModels.length || !response.unifiedServicePatternModel.dataObjModels.length ||
...@@ -192,14 +194,11 @@ export async function destructionGetDetail(response) { ...@@ -192,14 +194,11 @@ export async function destructionGetDetail(response) {
} }
const basicPatternModel = response.unifiedServicePatternModel; const basicPatternModel = response.unifiedServicePatternModel;
/** 正式开始 **/ /** 正式开始 **/
/*** 字段name, dataType ***/ /*** 字段name, dataType ***/
let fieldsColumns = {}; let fieldsColumns = {};
for(let dataObjModels of basicPatternModel.dataObjModels){ for (let dataObjModels of basicPatternModel.dataObjModels) {
let columns = dataObjModels.columnModels; let columns = dataObjModels.columnModels;
for (let item of columns) { for (let item of columns) {
fieldsColumns[item.base52] = { fieldsColumns[item.base52] = {
...@@ -224,16 +223,16 @@ export async function destructionGetDetail(response) { ...@@ -224,16 +223,16 @@ export async function destructionGetDetail(response) {
let sqlModeData = handleSqlModels(basicPatternModel.sqlModels, basicPatternModel.defaultValues); //Array let sqlModeData = handleSqlModels(basicPatternModel.sqlModels, basicPatternModel.defaultValues); //Array
let defaultBinds = data.datas[key].defaultBinds; let defaultBinds = data.datas[key].defaultBinds;
let defaultKeys = {}; let defaultKeys = {};
if(defaultBinds){ if (defaultBinds) {
for(let item in defaultBinds){ for (let item in defaultBinds) {
let one = defaultBinds[item]; let one = defaultBinds[item];
if(one && one.columnIds && one.sqls){ if (one && one.columnIds && one.sqls) {
defaultKeys[one.sqls[1]] = one.columnIds[1]; defaultKeys[one.sqls[1]] = one.columnIds[1];
} }
} }
} }
for(let item of sqlModeData){ for (let item of sqlModeData) {
if(defaultKeys[item.key]){ if (defaultKeys[item.key]) {
item.defaultKey = defaultKeys[item.key]; item.defaultKey = defaultKeys[item.key];
} }
} }
...@@ -244,28 +243,36 @@ export async function destructionGetDetail(response) { ...@@ -244,28 +243,36 @@ export async function destructionGetDetail(response) {
name: basicPatternModel.dataObjModels[0].name, name: basicPatternModel.dataObjModels[0].name,
defaultValuesId: key, defaultValuesId: key,
}; };
for(let i = 0; i < fileds.length; i++){ for (let i = 0; i < fileds.length; i++) {
let item = fileds[i]; let item = fileds[i];
if(item.comName === 'Description'){ if (item.comName === 'Description') {
if(item.key && !item.defaultValue && basicPatternModel.defaultValues && basicPatternModel.defaultValues[item.key]){ if (
item.key &&
!item.defaultValue &&
basicPatternModel.defaultValues &&
basicPatternModel.defaultValues[item.key]
) {
item.defaultValue = basicPatternModel.defaultValues[item.key]; item.defaultValue = basicPatternModel.defaultValues[item.key];
} }
for(let x of sqlModeData){ for (let x of sqlModeData) {
if(x.key === item.key){ if (x.key === item.key) {
item.c1 = x.defaultKey; item.c1 = x.defaultKey;
fileds[i] = { fileds[i] = {
...item, ...item,
...x, ...x,
};
} }
} }
} }
}
} }
for (let i = 0; i < fileds.length; i++) { for (let i = 0; i < fileds.length; i++) {
if (typeof fileds[i].c1 !== 'undefined') { if (typeof fileds[i].c1 !== 'undefined') {
if(fileds[i].key && fieldsColumns[fileds[i].c1] && fieldsColumns[fileds[i].c1].key && fileds[i].key !== fieldsColumns[fileds[i].c1].key){ if (
fileds[i].key &&
fieldsColumns[fileds[i].c1] &&
fieldsColumns[fileds[i].c1].key &&
fileds[i].key !== fieldsColumns[fileds[i].c1].key
) {
fileds[i].onestopDefaultKey = fileds[i].key; fileds[i].onestopDefaultKey = fileds[i].key;
} }
fileds[i] = { fileds[i] = {
...@@ -275,30 +282,26 @@ export async function destructionGetDetail(response) { ...@@ -275,30 +282,26 @@ export async function destructionGetDetail(response) {
} }
} }
return { return {
addFields: await translateAddFields(fileds, tableInfo), addFields: await translateAddFields(fileds, tableInfo),
tableInfo, tableInfo,
allConfigSetInfo: response, allConfigSetInfo: response,
}; };
} }
export function getDefaultValues(addFields = [], tableInfo = {}) {
export function getDefaultValues(addFields = [], tableInfo = {}){
const values = { const values = {
defaultValues: { defaultValues: {
[tableInfo.defaultValuesId]: {}, [tableInfo.defaultValuesId]: {},
} },
}; };
const defalutValues = {}; const defalutValues = {};
for(let item of addFields){ for (let item of addFields) {
if(typeof item.defaultValue !== 'undefined'){ if (typeof item.defaultValue !== 'undefined') {
values[item.key] = item.defaultValue; values[item.key] = item.defaultValue;
// values[item.onestopDefaultKey] = item.defaultValue;l;l // values[item.onestopDefaultKey] = item.defaultValue;l;l
} }
if(typeof item.defaultKey !== 'undefined' && item.defaultKey){ if (typeof item.defaultKey !== 'undefined' && item.defaultKey) {
values[item.defaultKey] = item.defaultValue; // 表单渲染需要这个值 values[item.defaultKey] = item.defaultValue; // 表单渲染需要这个值
defalutValues[item.key] = item.defaultValue; defalutValues[item.key] = item.defaultValue;
defalutValues[item.onestopDefaultKey] = item.defaultValue; defalutValues[item.onestopDefaultKey] = item.defaultValue;
...@@ -306,27 +309,29 @@ export function getDefaultValues(addFields = [], tableInfo = {}){ ...@@ -306,27 +309,29 @@ export function getDefaultValues(addFields = [], tableInfo = {}){
} }
values.defaultValues[tableInfo.defaultValuesId] = defalutValues; //传给后台需要这个值 values.defaultValues[tableInfo.defaultValuesId] = defalutValues; //传给后台需要这个值
return values; return values;
} }
export function handleColumns(columns) {
export function handleColumns(columns){
const columnsLength = columns.length; const columnsLength = columns.length;
for (let item of columns) { for (let item of columns) {
if(item.dataIndex.indexOf("process_status")>-1) { if (item.dataIndex.indexOf('process_status') > -1) {
item.render = (val) => val ? (val === "0" ? "审核通过" : "审核未通过") : null; item.render = (val) => (val ? (val === '0' ? '审核通过' : '审核未通过') : null);
} }
if (item.dataType) { if (item.dataType) {
if (text.indexOf(item.dataType) > -1) { // 文本类型字段 if (text.indexOf(item.dataType) > -1) {
// 文本类型字段
item.render = (text) => { item.render = (text) => {
if(isJSON(text)){ if (isJSON(text)) {
text = JSON.parse(text); text = JSON.parse(text);
} }
if(item.extendType === 'file' && typeof text === 'string'){ if (item.extendType === 'file' && typeof text === 'string') {
let url = text.includes('http') ? text : config.sqlFormsServer + text; let url = text.includes('http') ? text : config.sqlFormsServer + text;
return <a href={url} target={'_blank'}>点击查看</a>; return (
} <a href={url} target={'_blank'}>
else if (typeof text === 'string' && text.length > 50) { 点击查看
</a>
);
} else if (typeof text === 'string' && text.length > 50) {
const oldTitle = text; const oldTitle = text;
const newTitle = text.slice(0, 20) + '...'; const newTitle = text.slice(0, 20) + '...';
return ( return (
...@@ -334,35 +339,37 @@ export function handleColumns(columns){ ...@@ -334,35 +339,37 @@ export function handleColumns(columns){
<span key={text}>{newTitle}</span> <span key={text}>{newTitle}</span>
</Tooltip> </Tooltip>
); );
} else if (item.extendType === 'file' && text && } else if (
typeof text === 'object' && Array.isArray(text.files) && text.files.length) { item.extendType === 'file' &&
return text.files.map((file,index)=>{ text &&
let url = file.path.includes('http') ? typeof text === 'object' &&
file.path : Array.isArray(text.files) &&
config.sqlFormsServer + file.path; text.files.length
return <a href={url} ) {
target={'_blank'} return text.files.map((file, index) => {
key={file.name} let url = file.path.includes('http') ? file.path : config.sqlFormsServer + file.path;
style={{marginRight: '10px'}} return (
> <a href={url} target={'_blank'} key={file.name} style={{ marginRight: '10px' }}>
{file.name} {file.name}
</a>; </a>
);
}); });
} else { } else {
return text; return text;
} }
}; };
} else if (date.indexOf(item.dataType) > -1) { // 日期类型字段 } else if (date.indexOf(item.dataType) > -1) {
// 日期类型字段
item.render = (text, record) => { item.render = (text, record) => {
if (!isNaN(Number(text)) && Number(text) > 10000000) { if (!isNaN(Number(text)) && Number(text) > 10000000) {
text = Number(text); text = Number(text);
return moment(text).format(format[item.dataType]); return moment(text).format(format[item.dataType]);
}else{ } else {
return ''; return '';
} }
}; };
} else if (taskNode.indexOf(item.dataType) > -1) { // 流程节点类型 } else if (taskNode.indexOf(item.dataType) > -1) {
// 流程节点类型
item.render = (text, record) => { item.render = (text, record) => {
if (record.isEnd) { if (record.isEnd) {
return '已完成'; return '已完成';
...@@ -382,7 +389,7 @@ export function handleColumns(columns){ ...@@ -382,7 +389,7 @@ export function handleColumns(columns){
} }
}; };
} }
if (columnsLength > 10 && item.title && !item.width) { /*if (columnsLength > 10 && item.title && !item.width) {
item.width = item.title.length * 30; item.width = item.title.length * 30;
if (item.title === '学号') { if (item.title === '学号') {
item.width = 140; item.width = 140;
...@@ -390,7 +397,7 @@ export function handleColumns(columns){ ...@@ -390,7 +397,7 @@ export function handleColumns(columns){
if (item.title.indexOf('时间') > -1) { if (item.title.indexOf('时间') > -1) {
item.width = 150; item.width = 150;
} }
} }*/
} }
return columns; return columns;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论