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

Merge remote-tracking branch 'origin/master'

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