|
@@ -143,20 +143,69 @@ export const jGPrint = function (data, type, callback, printLogParams, printPage
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-export const groupLessThan = function(numbers, targetSum) {
|
|
+export const groupLessThan = function(html) {
|
|
- let currentSum = 0;
|
|
+ const pageMidHeight = 535
|
|
- let result = [];
|
|
+ const pageHeight = pageMidHeight*2
|
|
- for (let i = 0; i < numbers.length; i++) {
|
|
+ const arr = []
|
|
- currentSum += numbers[i].h;
|
|
+ const result = []
|
|
- if (currentSum <= targetSum) {
|
|
+ for (let i = 0; i < html.length; i++) {
|
|
- result.push(numbers[i].t);
|
|
+ const h = html[i].clientHeight
|
|
- } else {
|
|
+ const pz = h<=pageMidHeight ? '0.5' : (h/pageHeight).toFixed(2)
|
|
- result.push('&-NEWPAGE-&');
|
|
+ arr.push({
|
|
- currentSum = numbers[i].h;
|
|
+ h: h,
|
|
- result.push(numbers[i].t);
|
|
+ pz: pz,
|
|
- }
|
|
+ t: '<div style="height:'+(pz<=0.5?pageMidHeight:'auto')+'px'+';border:1px solid #fff;">'+html[i].innerHTML+'</div>',
|
|
|
|
+ flag: 0
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- return result;
|
|
+ console.log(arr)
|
|
|
|
+
|
|
|
|
+ const a = arr.filter(item => item.pz <= 0.5)
|
|
|
|
+
|
|
|
|
+ const b = arr.filter(item => item.pz >0.5 && item.pz <= 1)
|
|
|
|
+
|
|
|
|
+ const c = arr.filter(item => item.pz > 1)
|
|
|
|
+
|
|
|
|
+ for(let i=0;i<c.length;i++){
|
|
|
|
+ const pz = Number(c[i].pz.split('.')[1])
|
|
|
|
+
|
|
|
|
+ const hasOther = b.findIndex(item => (item.pz + pz) < 1)
|
|
|
|
+ if(hasOther>=0){
|
|
|
|
+ result.push(c[i].t + b[hasOther].t)
|
|
|
|
+
|
|
|
|
+ b.splice(hasOther,1)
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ const hasOtherA = a.findIndex(item => (item.pz + pz) < 1)
|
|
|
|
+ if(hasOtherA>=0){
|
|
|
|
+ result.push(c[i].t + a[hasOtherA].t)
|
|
|
|
+
|
|
|
|
+ b.splice(hasOther,1)
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ result.push(c[i].t)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for(let i=0;i<b.length;i++){
|
|
|
|
+ result.push(b[i].t)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(a.length%2!=0){
|
|
|
|
+ a.push({t:''})
|
|
|
|
+ }
|
|
|
|
+ for(let i=0;i<a.length;i=i+2){
|
|
|
|
+ result.push(a[i].t + a[i+1].t)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return result
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -189,9 +238,9 @@ export const jGPlPrint = function (data, type, callback, printLogParams, taskNam
|
|
|
|
|
|
|
|
|
|
LODOP.On_Return = function (TaskID, Value) {
|
|
LODOP.On_Return = function (TaskID, Value) {
|
|
- console.log(TaskID, Value, printLogParams)
|
|
+ console.log(TaskID, Value!=0, printLogParams)
|
|
|
|
|
|
- if (Value) {
|
|
+ if (Number(Value)) {
|
|
if(printLogParams){
|
|
if(printLogParams){
|
|
console.log('已打印,统计打印次数')
|
|
console.log('已打印,统计打印次数')
|
|
printLog(printLogParams, callback)
|
|
printLog(printLogParams, callback)
|
|
@@ -209,7 +258,7 @@ export const jGPlPrint = function (data, type, callback, printLogParams, taskNam
|
|
if(data.length>1){
|
|
if(data.length>1){
|
|
|
|
|
|
for(var i=0;i<data.length;i++){
|
|
for(var i=0;i<data.length;i++){
|
|
- LODOP.NewPage();
|
|
+ LODOP.NewPageA();
|
|
LODOP.ADD_PRINT_HTM(0, 0, '100%', '99%', data[i])
|
|
LODOP.ADD_PRINT_HTM(0, 0, '100%', '99%', data[i])
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|