提交 6e999a0c authored 作者: 钟是志's avatar 钟是志

Merge remote-tracking branch 'origin/master'

...@@ -9,6 +9,8 @@ import { ...@@ -9,6 +9,8 @@ import {
getColumnsDataRealize, getColumnsDataRealize,
getColumnsSqlKeyRealize, getColumnsSqlKeyRealize,
getWord, getWord,
renderContentAll,
renderContentRow,
} from './globalFunction'; } from './globalFunction';
export function giveSmartFormGlobalProps({ export function giveSmartFormGlobalProps({
...@@ -37,14 +39,18 @@ export function giveSmartFormGlobalProps({ ...@@ -37,14 +39,18 @@ export function giveSmartFormGlobalProps({
getColumnsDataRealize, getColumnsDataRealize,
getColumnsSqlKeyRealize, getColumnsSqlKeyRealize,
getWord, getWord,
remark: ` renderContentAll,
giveFilePostDataInfoForTrue(params, url); //将接口参数 二进制文件化 并返回新的接口地址与参数'; renderContentRow,
getSpanJson(mergeKey, data, eliminateStr); //列表获取纵向合并数据 mergeKey : 需要合并的表头key data : 列表数据 eliminateStr : 需要忽略合并的数据 remark: {
getColumns(columns); //获取ant表头的属性 columns : ant的表头 "giveFilePostDataInfoForTrue(params, url) ":`将接口参数 二进制文件化 并返回新的接口地址与参数';`,
getColumnsDataRealize({data, mergeKey, columns, styles, defect, fileName, ext , eliminateStr}); // 下载列表合并的数据,前三个必填data, mergeKey, columns "getSpanJson(mergeKey, data, eliminateStr)":`列表获取纵向合并数据 ;参数-> mergeKey : 需要合并的表头key data : 列表数据 eliminateStr : 需要忽略合并的数据`,
getColumnsSqlKeyRealize({sqlKey, columns, styles, fileName, ext}); // 下载列表表头合并的数据,前两个个必填sqlKey, columns "getColumns(columns)":`获取ant表头的属性 ;参数->columns : ant的表头`,
getWord({templatePath,params, title, allValues, listConfig, ext});// 下载文档地址 ,前五个必填 templatePath,params, title, allValues, listConfig "getColumnsDataRealize({data, mergeKey, columns, styles, defect, fileName, ext , eliminateStr})":`下载列表合并的数据;参数-> 前三个必填data, mergeKey, columns`,
`, "getColumnsSqlKeyRealize({sqlKey, columns, styles, fileName, ext})":`下载列表表头合并的数据;参数->前两个个必填sqlKey, columns`,
"getWord({templatePath,params, title, allValues, listConfig, ext})":`下载文档地址 ;参数->前五个必填 templatePath,params, title, allValues, listConfig`,
"renderContentAll(value, row, index, key, spanData, cloumnNames) ":`ant表头横向、纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContentAll(value, row, index,"inst_name",spanData,cloumnNames)}`,
"renderContentRow(value, row, index, key, spanData, cloumnNames) ":`ant表头纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContentRow(value, row, index,"inst_name",spanData,cloumnNames)}`,
}
}, },
publicComponent: { publicComponent: {
React, React,
......
import { giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16'; import { giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16';
import { queryOauthActionPath } from '@/webPublic/one_stop_public/utils/queryConfig'; import { queryOauthActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
import { getToken } from '@/webPublic/one_stop_public/utils/token'; import { getToken } from '@/webPublic/one_stop_public/utils/token';
export { deepCopy} from '@/webPublic/zyd_public/utils/utils';
const apiUrl = queryOauthActionPath();
/** /**
* 公共函数代码 * 公共函数代码
...@@ -11,19 +14,29 @@ import { getToken } from '@/webPublic/one_stop_public/utils/token'; ...@@ -11,19 +14,29 @@ import { getToken } from '@/webPublic/one_stop_public/utils/token';
* 列表获取纵向合并数据 * 列表获取纵向合并数据
* mergeKey : 需要合并的表头key * mergeKey : 需要合并的表头key
* data : 列表数据 * data : 列表数据
* eliminateStr : 需要忽略合并的数据 * eliminateRow : 列需要忽略合并的数据
* eliminateCol : 行需要忽略合并的数据
* *
* 返回值 * 返回值
* rowSpanData 列合并数据,colSpanData行合并数据 * rowSpanData 列合并数据,colSpanData行合并数据
* */ * */
export function getSpanJson(mergeKey, data, eliminateStr = []) { export function getSpanJson({
mergeKey, data, eliminateRow = [], eliminateCol = []
}) {
try {
let dataList = deepCopy(data);
return { return {
rowSpanData: getRowSpanJson(mergeKey, data, eliminateStr), rowSpanData: getRowSpanJson(mergeKey,dataList, eliminateRow),
colSpanData: getColSpanJson(mergeKey, data, eliminateStr), colSpanData: getColSpanJson(mergeKey, dataList, eliminateCol),
}; };
} catch (err) {
console.table(err);
}
} }
function getRowSpanJson(cloumnNames, data, eliminateStr = []) { function getRowSpanJson(cloumnNames, data, eliminateStr = []) {
data = deepCopy(data);
//纵向合并 //纵向合并
// 获取列的 dataIndex 集合 // 获取列的 dataIndex 集合
var rowSpanJson = {}; var rowSpanJson = {};
...@@ -63,6 +76,7 @@ function getRowSpanJson(cloumnNames, data, eliminateStr = []) { ...@@ -63,6 +76,7 @@ function getRowSpanJson(cloumnNames, data, eliminateStr = []) {
} }
function getColSpanJson(cloumnNames, data, eliminateStr = []) { function getColSpanJson(cloumnNames, data, eliminateStr = []) {
data = deepCopy(data);
//横向合并 //横向合并
var colSpanJson = {}; var colSpanJson = {};
for (let idx = 0; idx < data.length; idx++) { for (let idx = 0; idx < data.length; idx++) {
...@@ -100,6 +114,8 @@ function getColSpanJson(cloumnNames, data, eliminateStr = []) { ...@@ -100,6 +114,8 @@ function getColSpanJson(cloumnNames, data, eliminateStr = []) {
colSpanJson[triggerColIndex][idx] = triggerColSum; colSpanJson[triggerColIndex][idx] = triggerColSum;
colSpanJson[keyItem][idx] = 0; colSpanJson[keyItem][idx] = 0;
triggerColIndex = null; triggerColIndex = null;
} else if(isCol && triggerColIndex !== null ) {
colSpanJson[keyItem][idx] = 0;
} else { } else {
colSpanJson[keyItem][idx] = colSum; colSpanJson[keyItem][idx] = colSum;
} }
...@@ -120,6 +136,8 @@ function getColSpanJson(cloumnNames, data, eliminateStr = []) { ...@@ -120,6 +136,8 @@ function getColSpanJson(cloumnNames, data, eliminateStr = []) {
* columnsHeight 行数 * columnsHeight 行数
* */ * */
export function getColumns(columns) { export function getColumns(columns) {
columns = deepCopy(columns);
const uj = { const uj = {
t: 1, t: 1,
v: '序号', v: '序号',
...@@ -229,7 +247,10 @@ export function getColumnsSqlKeyRealize({ ...@@ -229,7 +247,10 @@ export function getColumnsSqlKeyRealize({
fileName = '导出文件', fileName = '导出文件',
ext = 'xlsx', ext = 'xlsx',
}) { }) {
columns = deepCopy(columns);
let { columnsList, columnsMerges, columnsKey } = getColumns(columns); let { columnsList, columnsMerges, columnsKey } = getColumns(columns);
let content = { let content = {
sheets: [ sheets: [
{ {
...@@ -254,7 +275,7 @@ export function getColumnsSqlKeyRealize({ ...@@ -254,7 +275,7 @@ export function getColumnsSqlKeyRealize({
verticalAlignment: 'CENTER', //TOP、CENTER、BOTTOM、JUSTIFY、DISTRIBUTED verticalAlignment: 'CENTER', //TOP、CENTER、BOTTOM、JUSTIFY、DISTRIBUTED
wrapText: true, wrapText: true,
rowHeights: 20, rowHeights: 20,
colWidths: 200, colWidths: 250,
}, },
head: { head: {
font: { font: {
...@@ -267,12 +288,13 @@ export function getColumnsSqlKeyRealize({ ...@@ -267,12 +288,13 @@ export function getColumnsSqlKeyRealize({
if (styles) { if (styles) {
content.styles = styles; content.styles = styles;
} }
try {
let getFileData = giveFilePostDataInfoForTrue( let getFileData = giveFilePostDataInfoForTrue(
{ {
content: JSON.stringify(content), content: JSON.stringify(content),
title: fileName, title: fileName,
}, },
`${queryOauthActionPath() + '/DataObjApi/exportCustom'}`, `${apiUrl + '/DataObjApi/exportCustom'}`,
); );
let token = getToken(); let token = getToken();
downloadFile( downloadFile(
...@@ -284,6 +306,9 @@ export function getColumnsSqlKeyRealize({ ...@@ -284,6 +306,9 @@ export function getColumnsSqlKeyRealize({
fileName, fileName,
ext, ext,
); );
} catch (err) {
console.table(err);
}
} }
/** /**
...@@ -295,7 +320,8 @@ export function getColumnsSqlKeyRealize({ ...@@ -295,7 +320,8 @@ export function getColumnsSqlKeyRealize({
* fileName : 导出文件名 * fileName : 导出文件名
* ext : 导出后缀 目前xecl、dbf * ext : 导出后缀 目前xecl、dbf
* url : 接口地址 * url : 接口地址
* eliminateStr : 忽略合并的值 * eliminateRow : 列需要忽略合并的数据
* eliminateCol : 行需要忽略合并的数据
* 返回值 * 返回值
* */ * */
export function getColumnsDataRealize({ export function getColumnsDataRealize({
...@@ -306,29 +332,33 @@ export function getColumnsDataRealize({ ...@@ -306,29 +332,33 @@ export function getColumnsDataRealize({
defect = null, defect = null,
fileName = '导出文件', fileName = '导出文件',
ext = 'xlsx', ext = 'xlsx',
eliminateStr = [], eliminateRow = [],
eliminateCol = [],
}) { }) {
columns = deepCopy(columns);
data = deepCopy(data);
let { columnsList, columnsMerges, columnsKey, columnsHeight } = getColumns(columns); let { columnsList, columnsMerges, columnsKey, columnsHeight } = getColumns(columns);
let { colSpanData, rowSpanData } = getSpanJson(mergeKey, data, eliminateStr); let { colSpanData, rowSpanData } = getSpanJson({ mergeKey, data, eliminateRow, eliminateCol });
// 处理数据 // 处理数据
let bodyData = []; let bodyData = [];
let dataMerges = [];
const uj = { const uj = {
t: 1, t: 1,
v: '序号', v: '序号',
s: 'header', s: 'header',
}; };
try {
data.forEach((dv, di) => { data.forEach((dv, di) => {
let nowArroy = new Array(columnsKey.length).fill({}); let nowArroy = new Array(columnsKey.length).fill({});
columnsKey.forEach((av, ai) => { columnsKey.forEach((av, ai) => {
nowArroy[ai] = { nowArroy[ai] = {
...uj, ...uj,
v: av in dv ? dv[av].toString() : defect || '', v: av in dv && dv[av] != null ? dv[av].toString() : defect || '',
}; };
}); });
bodyData.push(nowArroy); bodyData.push(nowArroy);
}); });
// 处理合并数据 // 处理合并数据
let dataMerges = [];
mergeKey.forEach((mv, mi) => { mergeKey.forEach((mv, mi) => {
rowSpanData[mv].forEach((cv, ci) => { rowSpanData[mv].forEach((cv, ci) => {
if (cv > 1) { if (cv > 1) {
...@@ -345,6 +375,10 @@ export function getColumnsDataRealize({ ...@@ -345,6 +375,10 @@ export function getColumnsDataRealize({
} }
}); });
}); });
} catch (err) {
console.table(err);
}
let content = { let content = {
sheets: [ sheets: [
...@@ -368,7 +402,7 @@ export function getColumnsDataRealize({ ...@@ -368,7 +402,7 @@ export function getColumnsDataRealize({
verticalAlignment: 'CENTER', //TOP、CENTER、BOTTOM、JUSTIFY、DISTRIBUTED verticalAlignment: 'CENTER', //TOP、CENTER、BOTTOM、JUSTIFY、DISTRIBUTED
wrapText: true, wrapText: true,
rowHeights: 20, rowHeights: 20,
colWidths: 200, colWidths: 250,
}, },
head: { head: {
font: { font: {
...@@ -381,14 +415,15 @@ export function getColumnsDataRealize({ ...@@ -381,14 +415,15 @@ export function getColumnsDataRealize({
if (styles) { if (styles) {
content.styles = styles; content.styles = styles;
} }
try {
let getFileData = giveFilePostDataInfoForTrue( let getFileData = giveFilePostDataInfoForTrue(
{ {
content: JSON.stringify(content), content: JSON.stringify(content),
title: fileName, title: fileName,
}, },
`${queryOauthActionPath() + '/DataObjApi/exportCustom'}`, `${apiUrl + '/DataObjApi/exportCustom'}`,
); );
let token = localStorage.getItem('antd-pro-token-onestop'); let token = getToken();
downloadFile( downloadFile(
getFileData.url, getFileData.url,
{ {
...@@ -398,8 +433,60 @@ export function getColumnsDataRealize({ ...@@ -398,8 +433,60 @@ export function getColumnsDataRealize({
fileName, fileName,
ext, ext,
); );
} catch (err) {
console.table(err);
}
} }
// ant列表组件合并表格 render属性,合并纵向、横向。
export function renderContentAll(value, row, index, key, spanData, cloumnNames = []) {
let colSpan, rowSpan = null;
try {
colSpan = spanData.colSpanData[key][index];// 横向合并
rowSpan = spanData.rowSpanData[key][index];// 纵向合并
} catch (err) {
console.table(err);
}
const obj = {
children: value,
props: {
rowSpan: rowSpan,
colSpan: colSpan
}
};
return obj;
}
// ant列表组件合并表格 render属性,合并纵向。 meanwhileKey :key 是本身字段key,value 是同步的字段key
export function renderContentRow(value, row, index, key, spanData, cloumnNames = [], meanwhileKey = {}) {
let colSpan, rowSpan = null;
try {
if (cloumnNames.indexOf(key) !== -1) {
rowSpan = spanData.rowSpanData[key][index];// 纵向合并
} else {
if (key in meanwhileKey && meanwhileKey[key]) {
let meanwhileKeyValue = meanwhileKey[key];
rowSpan = spanData.rowSpanData[meanwhileKeyValue][index];// 同步字段 的纵向合并
} else {
rowSpan = 1;
}
}
} catch (err) {
console.table(err);
}
const obj = {
children: value,
props: {
rowSpan: rowSpan,
colSpan: 1
}
};
return obj;
}
/** /**
* 表头和数据导出(合并表格) * 表头和数据导出(合并表格)
* templatePath : word文档模板地址 * templatePath : word文档模板地址
...@@ -407,7 +494,7 @@ export function getColumnsDataRealize({ ...@@ -407,7 +494,7 @@ export function getColumnsDataRealize({
* title : 导出文件名 * title : 导出文件名
* allValues : sql参数 * allValues : sql参数
* listConfig : 导出列表配置 * listConfig : 导出列表配置
* ext : 导出后缀 目前xecl、dbf * ext : 导出后缀 目前xecl、dbf,docx,pdf
* 返回值 * 返回值
* */ * */
export function getWord({ export function getWord({
...@@ -418,7 +505,7 @@ export function getWord({ ...@@ -418,7 +505,7 @@ export function getWord({
listConfig = {}, listConfig = {},
ext = 'docx', ext = 'docx',
}) { }) {
//可更新的 try {
let getFileData = giveFilePostDataInfoForTrue( let getFileData = giveFilePostDataInfoForTrue(
{ {
templatePath: templatePath, templatePath: templatePath,
...@@ -429,7 +516,7 @@ export function getWord({ ...@@ -429,7 +516,7 @@ export function getWord({
title: `${title}.${ext}`, title: `${title}.${ext}`,
allValues: JSON.stringify({ ...allValues }), allValues: JSON.stringify({ ...allValues }),
}, },
`${queryOauthActionPath()}` + `/DataColumnApi/exportWord`, apiUrl + `/DataColumnApi/exportWord`,
); );
let token = getToken(); let token = getToken();
downloadFile( downloadFile(
...@@ -441,6 +528,10 @@ export function getWord({ ...@@ -441,6 +528,10 @@ export function getWord({
title, title,
ext, ext,
); );
} catch (err) {
console.table(err);
}
//可更新的
function setObjectKey(data) { function setObjectKey(data) {
return ( return (
...@@ -476,12 +567,12 @@ function makeArrayKey(key) { ...@@ -476,12 +567,12 @@ function makeArrayKey(key) {
function FormdataWrapper(obj, fd, pre) { function FormdataWrapper(obj, fd, pre) {
fd = fd || new FormData(); fd = fd || new FormData();
Object.keys(obj).forEach(function(prop) { Object.keys(obj).forEach(function (prop) {
var key = pre ? pre + '[' + prop + ']' : prop; var key = pre ? pre + '[' + prop + ']' : prop;
if (isObject(obj[prop]) && !isArray(obj[prop]) && !isFile(obj[prop])) { if (isObject(obj[prop]) && !isArray(obj[prop]) && !isFile(obj[prop])) {
FormdataWrapper(obj[prop], fd, key); FormdataWrapper(obj[prop], fd, key);
} else if (isArray(obj[prop])) { } else if (isArray(obj[prop])) {
obj[prop].forEach(function(value) { obj[prop].forEach(function (value) {
var arrayKey = makeArrayKey(key); var arrayKey = makeArrayKey(key);
if (isObject(value) && !isFile(value)) { if (isObject(value) && !isFile(value)) {
FormdataWrapper(value, fd, arrayKey); FormdataWrapper(value, fd, arrayKey);
......
...@@ -47,6 +47,7 @@ export default function RangePickerDiy(props){ ...@@ -47,6 +47,7 @@ export default function RangePickerDiy(props){
const [bindValue, setBindValue] = useState([undefined, undefined]); const [bindValue, setBindValue] = useState([undefined, undefined]);
useEffect(() => { useEffect(() => {
// console.log('RangePickerDiy组件Value', value);
if(!value || !Array.isArray(value) || value.length !==2){ if(!value || !Array.isArray(value) || value.length !==2){
setBindValue([undefined, undefined]); setBindValue([undefined, undefined]);
...@@ -56,7 +57,7 @@ export default function RangePickerDiy(props){ ...@@ -56,7 +57,7 @@ export default function RangePickerDiy(props){
bindValue[i] = moment(value[i]); bindValue[i] = moment(value[i]);
}else if(!moment.isMoment(value[i])){ }else if(!moment.isMoment(value[i])){
bindValue[i] = undefined; bindValue[i] = undefined;
console.log('RangePickerDiy组件没有获取到正确的值', value); // console.log('RangePickerDiy组件没有获取到正确的值', value);
}else{ }else{
bindValue[i] = value[i]; bindValue[i] = value[i];
} }
......
...@@ -85,6 +85,7 @@ export function changeFromDraftState2(editorState) { ...@@ -85,6 +85,7 @@ export function changeFromDraftState2(editorState) {
} }
export function preHandle(values) { export function preHandle(values) {
// console.trace('123');
for (var key in values) { for (var key in values) {
if (!values[key]) continue; if (!values[key]) continue;
if (key.indexOf('$') > -1) { if (key.indexOf('$') > -1) {
...@@ -118,13 +119,14 @@ export function preHandle(values) { ...@@ -118,13 +119,14 @@ export function preHandle(values) {
j.split('$').map((g,index) => { j.split('$').map((g,index) => {
if(moment.isMoment(childObj[j][index])){ if(moment.isMoment(childObj[j][index])){
childObj[g] = childObj[j][index].valueOf(); childObj[g] = childObj[j][index].valueOf();
childObj[j][index] = childObj[j][index].valueOf(); // childObj[j][index] = childObj[j][index].valueOf();
} }
}); });
if(j === 'LckrMFujFgw$LckrXpIoQdc'){ if(j === 'LckrMFujFgw$LckrXpIoQdc'){
console.log(values[key][k][j], key, k, j); // console.log(values[key][k]['LckrMFujFgw'], key, k, j);
// console.log(values[key][k]['LckrXpIoQdc'], key, k, j);
} }
// delete childObj[j]; delete childObj[j];
// 我写的代码 // 我写的代码
// 欢哥写的代码. // 欢哥写的代码.
...@@ -167,6 +169,9 @@ export function deepCopy(obj, parent = null) { ...@@ -167,6 +169,9 @@ export function deepCopy(obj, parent = null) {
if (React.isValidElement(obj)) { if (React.isValidElement(obj)) {
return React.cloneElement(obj); return React.cloneElement(obj);
} }
// if(moment.isMoment(obj)){
// return moment().clone)
// }
if (['boolean', 'string', 'number'].indexOf(typeof obj) > -1 || !obj) { if (['boolean', 'string', 'number'].indexOf(typeof obj) > -1 || !obj) {
return obj; return obj;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论