From 4742cf0361f3b9173e592bbd48ca0f182944a6ec Mon Sep 17 00:00:00 2001 From: blink Date: Sun, 31 Jan 2021 09:19:27 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9A=84=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/note/note.component.html | 2 +- src/app/note/note.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/note/note.component.html b/src/app/note/note.component.html index c49e79f..ffb31be 100644 --- a/src/app/note/note.component.html +++ b/src/app/note/note.component.html @@ -162,7 +162,7 @@ {{data.jingzhong}} {{data.price}} - {{data.amount}} + {{data.amount}} 0张 Date: Tue, 5 Oct 2021 14:44:22 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E6=9C=80=E7=BB=88=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.xml | 1 - package.json | 5 +++-- src/app/note/note.component.html | 14 +++++++------- src/app/note/note.component.ts | 14 ++++++++------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/config.xml b/config.xml index 668592a..7a0ad67 100644 --- a/config.xml +++ b/config.xml @@ -112,5 +112,4 @@ - diff --git a/package.json b/package.json index 8f82709..ff695d7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "ng": "ng", "start": "ng serve", - "build": "ionic cordova build android --prod", + "build": "ionic cordova build android", + "build-prod": "ionic cordova build android --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" @@ -35,7 +36,6 @@ "big.js": "^5.2.2", "clone-deep": "^4.0.1", "compressorjs": "^1.0.6", - "cordova-android": "^7.0.0", "cordova-plugin-android-permissions": "^1.0.2", "cordova-plugin-appminimize": "^1.0.1", "cordova-plugin-camera": "^4.1.0", @@ -75,6 +75,7 @@ "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", "codelyzer": "^6.0.0", + "cordova-android": "^9.1.0", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~5.0.0", diff --git a/src/app/note/note.component.html b/src/app/note/note.component.html index ffb31be..3dff7c2 100644 --- a/src/app/note/note.component.html +++ b/src/app/note/note.component.html @@ -22,10 +22,10 @@ - + 车队 - 出发时间 + 回厂时间 货料来源 货料种类 @@ -49,7 +49,7 @@ - {{data.startTime}} + {{data.endTime}} {{data.origin}} {{data.type}} @@ -75,12 +75,12 @@ - +
- + 来源 车牌号 @@ -126,12 +126,12 @@
- +
- + 来源 车牌号 diff --git a/src/app/note/note.component.ts b/src/app/note/note.component.ts index 3e60209..96a8890 100644 --- a/src/app/note/note.component.ts +++ b/src/app/note/note.component.ts @@ -33,10 +33,11 @@ export class NoteComponent implements OnInit, AfterViewInit { editRowIndex: number; config: any = {}; isHidden = false; + isReady = false; scroll = { x: '1000px', y: '500px' }; setOfCheckedId = new Set(); // 选中的id @ViewChild('tableBox') tableBox: ElementRef; - @ViewChild('tableHeader') tableHeader: ElementRef; + // @ViewChild('tableHeader') tableHeader: ElementRef; constructor( private alertCtrl: AlertController, private file: FileService, @@ -70,21 +71,22 @@ export class NoteComponent implements OnInit, AfterViewInit { }); }, 10); } - }) - + }); } ngAfterViewInit(): void { this.getResize(); - } getResize() { const width = this.tableBox.nativeElement.offsetWidth; const height = this.tableBox.nativeElement.offsetHeight; // 计算高度 - const scrollHeight = height - 45 - 61; + const scrollHeight = height - 120; this.scroll.y = scrollHeight + 'px'; - this.scroll.x = width + 'px'; + this.scroll.x = width - 15 + 'px'; + setTimeout(() => { + this.isReady = true; + }, 100); } /** * @description 读取账本文件 From d87e86141ccacba52b523a1417e2323179b4fa99 Mon Sep 17 00:00:00 2001 From: blink Date: Sun, 17 Oct 2021 20:54:56 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/common/total/total.component.html | 8 +- src/app/common/total/total.component.ts | 366 +++++++++++++--------- 2 files changed, 219 insertions(+), 155 deletions(-) diff --git a/src/app/common/total/total.component.html b/src/app/common/total/total.component.html index ff4ffb0..55b4803 100644 --- a/src/app/common/total/total.component.html +++ b/src/app/common/total/total.component.html @@ -3,7 +3,13 @@

{{date | date:'yyyy-MM-dd'}} 统计(单位:吨)

-

车队  共计:{{carTotal.total}}({{carTotal.count}}车) +

车队  共计: + {{carTotal.total}}({{carTotal.count}}车) + + + {{car.type}}:{{car.jingzhong}}({{car.count}}车) + +

{{car.carNo}}({{car.person}}):
diff --git a/src/app/common/total/total.component.ts b/src/app/common/total/total.component.ts index 8dfcd1a..15b1405 100644 --- a/src/app/common/total/total.component.ts +++ b/src/app/common/total/total.component.ts @@ -1,172 +1,230 @@ import { AccountBook } from './../model/model'; import { Component, OnInit, Input } from '@angular/core'; -import { Big } from "big.js"; +import { Big } from 'big.js'; import { CameraService } from '../camera/camera.service'; import html2canvas from 'html2canvas'; import { SocialSharing } from '@ionic-native/social-sharing/ngx'; import { ModalController } from '@ionic/angular'; @Component({ - selector: 'app-total', - templateUrl: './total.component.html', - styleUrls: ['./total.component.scss'], + selector: 'app-total', + templateUrl: './total.component.html', + styleUrls: ['./total.component.scss'], }) export class TotalComponent implements OnInit { + @Input() + accountBook: AccountBook; + date = ''; + cars: any[] = []; + outCars: any[] = []; + guozhaCars: any[] = []; + total = '0'; + carTotal = { total: '0', count: 0 }; + carDetail = []; + outCarTotal = { total: '0', count: 0 }; + guozhaCarTotal = { total: '0', count: 0 }; + constructor( + private camera: CameraService, + private socialSharing: SocialSharing, + private modal: ModalController + ) {} - @Input() - accountBook: AccountBook - date = ''; - cars: any[] = []; - outCars: any[] = []; - guozhaCars: any[] = []; - total = '0'; - carTotal = { total: '0', count: 0 }; - outCarTotal = { total: '0', count: 0 }; - guozhaCarTotal = { total: '0', count: 0 }; - constructor( - private camera: CameraService, - private socialSharing: SocialSharing, - private modal: ModalController - ) { } + ngOnInit() { + this.init(); + } + init() { + this.date = this.accountBook.date; + // this.cars = this.accountBook.cars; + this.cars = this.initCar(); + this.outCars = this.initOutCar(); + this.guozhaCars = this.initGuozhaCar(); + this.carTotal = this.getTotalCar(); + this.outCarTotal = this.getOutTotalCar(); + this.guozhaCarTotal = this.getGuozhaTotalCar(); + this.total = this.initTotal(); + this.carDetail = this.getDetailCar(); + } + initCar() { + const cars = []; + this.accountBook.cars.forEach((car) => { + const obj = {}; + let total = '0'; + let totalCount = 0; + const car1: string[] = []; + const car2 = []; + car.datas.forEach((d) => { + const jingzhong = d.jingzhong.trim(); + if (jingzhong && jingzhong !== '0') { + const index = car1.indexOf(d.type); + if (index !== -1) { + car2[index].count++; + car2[index].jingzhong = new Big(car2[index].jingzhong) + .plus(d.jingzhong || '0') + .toString(); + } else { + car2.push({ + type: d.type, + count: 1, + jingzhong: d.jingzhong || '0', + }); + car1.push(d.type); + } + total = new Big(total).plus(d.jingzhong || '0').toString(); + totalCount++; + } + }); + const persons = []; + car.persons.forEach((person) => persons.push(person.userName)); + Reflect.set(obj, 'carNo', car.carNo); + Reflect.set(obj, 'person', persons.join('、')); + Reflect.set(obj, 'total', total); + Reflect.set(obj, 'types', car2), + Reflect.set(obj, 'totalCount', totalCount); + cars.push(obj); + }); + return cars; + } + initOutCar() { + const cars = []; + const outCars = this.accountBook.outCars || []; + const car1: string[] = []; + outCars.forEach((car) => { + const jingzhong = car.jingzhong.trim(); + if (jingzhong && jingzhong !== '0') { + const index = car1.indexOf(car.origin + car.type); + if (index !== -1) { + cars[index].count++; + cars[index].jingzhong = new Big(cars[index].jingzhong) + .plus(car.jingzhong || '0') + .toString(); + } else { + cars.push({ + origin: car.origin, + type: car.type, + count: 1, + jingzhong: car.jingzhong || '0', + }); + car1.push(car.origin + car.type); + } + } + }); + return cars; + } + initGuozhaCar() { + const cars = []; + const guozhaCars = this.accountBook.guozhaCars || []; + const car1: string[] = []; + guozhaCars.forEach((car) => { + const jingzhong = car.jingzhong.trim(); + if (jingzhong && jingzhong !== '0') { + const index = car1.indexOf(car.origin + car.type); + if (index !== -1) { + cars[index].count++; + cars[index].jingzhong = new Big(cars[index].jingzhong) + .plus(car.jingzhong || '0') + .toString(); + } else { + cars.push({ + origin: car.origin, + type: car.type, + count: 1, + jingzhong: car.jingzhong || '0', + }); + car1.push(car.origin + car.type); + } + } + }); + return cars; + } - ngOnInit() { - this.init(); - } - init() { - this.date = this.accountBook.date; - // this.cars = this.accountBook.cars; - this.cars = this.initCar(); - this.outCars = this.initOutCar(); - this.guozhaCars = this.initGuozhaCar(); - this.carTotal = this.getTotalCar(); - this.outCarTotal = this.getOutTotalCar(); - this.guozhaCarTotal = this.getGuozhaTotalCar(); - this.total = this.initTotal(); - } - initCar() { - const cars = []; - this.accountBook.cars.forEach(car => { - const obj = {}; - let total = '0'; - let totalCount = 0; - const car1: string[] = []; - const car2 = []; - car.datas.forEach((d) => { - const jingzhong = d.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { - const index = car1.indexOf(d.type) - if (index !== -1) { - car2[index].count++; - car2[index].jingzhong = new Big(car2[index].jingzhong).plus(d.jingzhong || '0').toString(); - } else { - car2.push({ type: d.type, count: 1, jingzhong: d.jingzhong || '0' }) - car1.push(d.type); - } - total = new Big(total).plus(d.jingzhong || '0').toString(); - totalCount++; - } - }) - const persons = []; - car.persons.forEach(person => persons.push(person.userName)); - Reflect.set(obj, 'carNo', car.carNo); - Reflect.set(obj, 'person', persons.join('、')); - Reflect.set(obj, 'total', total); - Reflect.set(obj, 'types', car2), - Reflect.set(obj, 'totalCount', totalCount) - cars.push(obj); - }) - return cars; - } - initOutCar() { - const cars = []; - const outCars = this.accountBook.outCars || []; - const car1: string[] = []; - outCars.forEach(car => { - const jingzhong = car.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { - const index = car1.indexOf(car.origin + car.type) - if (index !== -1) { - cars[index].count++; - cars[index].jingzhong = new Big(cars[index].jingzhong).plus(car.jingzhong || '0').toString(); - } else { - cars.push({ origin: car.origin, type: car.type, count: 1, jingzhong: car.jingzhong || '0' }) - car1.push(car.origin + car.type); - } - } - }); - return cars; - } - initGuozhaCar(){ - const cars = []; - const guozhaCars = this.accountBook.guozhaCars || []; - const car1: string[] = []; - guozhaCars.forEach(car => { - const jingzhong = car.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { - const index = car1.indexOf(car.origin + car.type) - if (index !== -1) { - cars[index].count++; - cars[index].jingzhong = new Big(cars[index].jingzhong).plus(car.jingzhong || '0').toString(); - } else { - cars.push({ origin: car.origin, type: car.type, count: 1, jingzhong: car.jingzhong || '0' }) - car1.push(car.origin + car.type); - } - } - }); - return cars; - } + initTotal() { + let total = '0'; + this.cars.forEach((car) => { + total = new Big(car.total).plus(total).toString(); + }); + this.outCars.forEach((outCar) => { + total = new Big(outCar.jingzhong).plus(total).toString(); + }); + return total; + } - initTotal() { - let total = '0'; - this.cars.forEach(car => { - total = new Big(car.total).plus(total).toString(); - }); - this.outCars.forEach(outCar => { - total = new Big(outCar.jingzhong).plus(total).toString(); - }); - return total; - } + getTotalCar() { + let total = { total: '0', count: 0 }; + this.cars.forEach((car) => { + total.total = new Big(car.total || '0') + .plus(total.total) + .toString(); + total.count = total.count + car.totalCount; + }); + return total; + } - getTotalCar() { - let total = { total: '0', count: 0 }; - this.cars.forEach(car => { - total.total = new Big(car.total || '0').plus(total.total).toString(); - total.count = total.count + car.totalCount; - }); - return total; - } + getDetailCar() { + const types = []; + const detail = []; + this.cars.forEach((car) => { + car.types.forEach((type) => { + const index = types.indexOf(type.type); + if (index !== -1) { + const count = detail[index].count; + const jingzhong = detail[index].jingzhong; + detail[index].count = new Big(type.count).plus(count).toString(); + detail[index].jingzhong = new Big(type.jingzhong).plus(jingzhong).toString(); + } else { + types.push(type.type); + detail.push({ + type: type.type, + count: type.count, + jingzhong: type.jingzhong + }); + } + }); + }); + return detail; + } - getOutTotalCar() { - let total = { total: '0', count: 0 }; - this.outCars.forEach(car => { - total.total = new Big(car.jingzhong || '0').plus(total.total).toString(); - total.count = total.count + car.count; - }); - return total; - } + getOutTotalCar() { + let total = { total: '0', count: 0 }; + this.outCars.forEach((car) => { + total.total = new Big(car.jingzhong || '0') + .plus(total.total) + .toString(); + total.count = total.count + car.count; + }); + return total; + } - getGuozhaTotalCar() { - let total = { total: '0', count: 0 }; - this.guozhaCars.forEach(car => { - total.total = new Big(car.jingzhong || '0').plus(total.total).toString(); - total.count = total.count + car.count; - }); - return total; - } + getGuozhaTotalCar() { + let total = { total: '0', count: 0 }; + this.guozhaCars.forEach((car) => { + total.total = new Big(car.jingzhong || '0') + .plus(total.total) + .toString(); + total.count = total.count + car.count; + }); + return total; + } - /** - * 分享 - */ - share() { - const element = document.getElementById('content_box'); - this.modal.getTop().then((modal: any) => { - html2canvas(modal).then(canvas => { - canvas.toBlob(content => { - this.camera.saveFile(content, new Date().toDateString()).then((path: string) => { - this.socialSharing.share(null, null, path, null).then(() => { }, err => console.log('分享失败', err)) - }); - }); - }) - }) - } + /** + * 分享 + */ + share() { + const element = document.getElementById('content_box'); + this.modal.getTop().then((modal: any) => { + html2canvas(modal).then((canvas) => { + canvas.toBlob((content) => { + this.camera + .saveFile(content, new Date().toDateString()) + .then((path: string) => { + this.socialSharing + .share(null, null, path, null) + .then( + () => {}, + (err) => console.log('分享失败', err) + ); + }); + }); + }); + }); + } } From ede35efd090294ce4423c3c72f985e44eb019d7d Mon Sep 17 00:00:00 2001 From: blink Date: Sun, 10 Jul 2022 16:03:39 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=96=E6=9D=A5?= =?UTF-8?q?=E8=BD=A6=E8=BE=86=E7=9A=84=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.ts | 14 ++++---- .../common/pictures/pictures.component.scss | 2 +- src/app/common/pictures/pictures.component.ts | 8 +++++ src/app/common/total/total.component.html | 10 ++++-- src/app/common/total/total.component.ts | 36 +++++++++++++++---- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 31f5702..bc68cd4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -46,14 +46,14 @@ export class AppComponent { if (this.device.isMobile()) { this.persmission.getPermission().then(() => { this.file.init(); + this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); + // 键盘监听 + this.keyboardEvent(); + this.statusBar.styleDefault(); + this.splashScreen.hide(); + this.orientationEvent(); + this.registerBackButtonAction(); }); - this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); - // 键盘监听 - this.keyboardEvent(); - this.statusBar.styleDefault(); - this.splashScreen.hide(); - this.orientationEvent(); - this.registerBackButtonAction(); } else { const config = this.storage.get('config');; if (!config) { diff --git a/src/app/common/pictures/pictures.component.scss b/src/app/common/pictures/pictures.component.scss index f19c8bc..e93244b 100644 --- a/src/app/common/pictures/pictures.component.scss +++ b/src/app/common/pictures/pictures.component.scss @@ -1,5 +1,5 @@ .img { - width: 90px; + width: 150px; margin: 5px 0px; display: inline-block; } diff --git a/src/app/common/pictures/pictures.component.ts b/src/app/common/pictures/pictures.component.ts index 08873ff..58110cd 100644 --- a/src/app/common/pictures/pictures.component.ts +++ b/src/app/common/pictures/pictures.component.ts @@ -100,4 +100,12 @@ export class PicturesComponent implements OnInit { }); } + shareAll() { + this.share.share(null, null, this.pictures, null ).then(() => { + this.toast.success('分享成功'); + }).catch(() => { + this.toast.fail('分享失败'); + }) + } + } diff --git a/src/app/common/total/total.component.html b/src/app/common/total/total.component.html index 55b4803..e86fcaf 100644 --- a/src/app/common/total/total.component.html +++ b/src/app/common/total/total.component.html @@ -21,8 +21,14 @@ {{car.total}} ({{car.totalCount}}车)
-

外来车辆  共计:{{outCarTotal.total}}({{outCarTotal.count}}车)

+

外来车辆  共计: + {{outCarTotal.total}}({{outCarTotal.count}}车) + + + {{car.type}}:{{car.jingzhong}}({{car.count}}车) + + +

{{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} diff --git a/src/app/common/total/total.component.ts b/src/app/common/total/total.component.ts index 15b1405..2eda7c6 100644 --- a/src/app/common/total/total.component.ts +++ b/src/app/common/total/total.component.ts @@ -20,7 +20,8 @@ export class TotalComponent implements OnInit { guozhaCars: any[] = []; total = '0'; carTotal = { total: '0', count: 0 }; - carDetail = []; + carDetail = [];// 公司车辆拉货详情 + outcarDetail = []; // 外来车辆拉货详情 outCarTotal = { total: '0', count: 0 }; guozhaCarTotal = { total: '0', count: 0 }; constructor( @@ -43,6 +44,7 @@ export class TotalComponent implements OnInit { this.guozhaCarTotal = this.getGuozhaTotalCar(); this.total = this.initTotal(); this.carDetail = this.getDetailCar(); + this.outcarDetail = this.getOutDetailCar(); } initCar() { const cars = []; @@ -75,11 +77,11 @@ export class TotalComponent implements OnInit { }); const persons = []; car.persons.forEach((person) => persons.push(person.userName)); - Reflect.set(obj, 'carNo', car.carNo); - Reflect.set(obj, 'person', persons.join('、')); - Reflect.set(obj, 'total', total); - Reflect.set(obj, 'types', car2), - Reflect.set(obj, 'totalCount', totalCount); + obj['carNo'] = car.carNo; + obj['person'] = persons.join('、'); + obj['total'] = total; + obj['types'] = car2; + obj['totalCount'] = totalCount; cars.push(obj); }); return cars; @@ -183,6 +185,28 @@ export class TotalComponent implements OnInit { return detail; } + getOutDetailCar() { + const types = []; + const detail = []; + this.outCars.forEach((car) => { + const index = types.indexOf(car.type); + if (index !== -1) { + const count = detail[index].count; + const jingzhong = detail[index].jingzhong; + detail[index].count = new Big(car.count).plus(count).toString(); + detail[index].jingzhong = new Big(car.jingzhong).plus(jingzhong).toString(); + } else { + types.push(car.type); + detail.push({ + type: car.type, + count: car.count, + jingzhong: car.jingzhong + }); + } + }); + return detail; + } + getOutTotalCar() { let total = { total: '0', count: 0 }; this.outCars.forEach((car) => { From 9aa7a5a2bb869833ae7c0b4e710d4f3b515f1287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B4=AA=E4=BA=AE?= Date: Mon, 25 Jul 2022 16:48:40 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=9C=E7=8F=AD?= =?UTF-8?q?=E7=99=BD=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/common/model/model.ts | 4 +++ src/app/note/note.component.html | 2 ++ src/app/note/note.component.ts | 58 +++++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/app/common/model/model.ts b/src/app/common/model/model.ts index 03892c1..f4385d5 100644 --- a/src/app/common/model/model.ts +++ b/src/app/common/model/model.ts @@ -112,6 +112,10 @@ export interface OutCar { * 来源 */ origin: string; + /** + * 夜班 + */ + night?: boolean; /** * 类型 */ diff --git a/src/app/note/note.component.html b/src/app/note/note.component.html index 3dff7c2..28952e3 100644 --- a/src/app/note/note.component.html +++ b/src/app/note/note.component.html @@ -85,6 +85,7 @@ 来源 车牌号 货料种类 + 夜班 毛重(吨) 皮重(吨) 扣秤(%) @@ -103,6 +104,7 @@ {{data.origin}} {{data.carNo}} {{data.type}} + {{data.night ? "夜班": "白班"}} {{data.maozhong}} {{data.pizhong}} diff --git a/src/app/note/note.component.ts b/src/app/note/note.component.ts index 96a8890..ecb2612 100644 --- a/src/app/note/note.component.ts +++ b/src/app/note/note.component.ts @@ -28,7 +28,7 @@ export class NoteComponent implements OnInit, AfterViewInit { activeTabIndex = 0; selectedCar: Car = null; selectedPerson: Person[] = []; - accountBook: AccountBook = { id: '', date: '', cars: [], outCars: [], guozhaCars:[]}; + accountBook: AccountBook = { id: '', date: '', cars: [], outCars: [], guozhaCars: [] }; editCarIndex: number; editRowIndex: number; config: any = {}; @@ -279,7 +279,7 @@ export class NoteComponent implements OnInit, AfterViewInit { const outCars = cloneDeep(this.accountBook.outCars); outCars.push(outCar); this.accountBook.outCars = outCars; - } else if(this.activeTabIndex < this.accountBook.cars.length) { + } else if (this.activeTabIndex < this.accountBook.cars.length) { const car = this.accountBook.cars[this.activeTabIndex]; const row = { id: uuidv4(), carNo: car.carNo, startTime: '', @@ -336,8 +336,8 @@ export class NoteComponent implements OnInit, AfterViewInit { resolve(true); } }) - } else if(this.activeTabIndex === this.accountBook.cars.length) { - + } else if (this.activeTabIndex === this.accountBook.cars.length) { + this.accountBook.outCars.forEach((car, i) => { if (this.setOfCheckedId.has(car.id)) { const data = cloneDeep(this.accountBook.outCars); @@ -534,7 +534,7 @@ export class NoteComponent implements OnInit, AfterViewInit { } else { if (this.activeTabIndex === this.accountBook.cars.length) { this.setOutCellValue('type', blah); - } else if(this.activeTabIndex > this.accountBook.cars.length) { + } else if (this.activeTabIndex > this.accountBook.cars.length) { this.setGuozhaCellValue('type', blah); } else { this.setCellValue('type', blah); @@ -587,7 +587,7 @@ export class NoteComponent implements OnInit, AfterViewInit { if (blah[type]) { if (this.activeTabIndex === this.accountBook.cars.length) { this.setOutCellValue(type, blah[type]); - } else if(this.activeTabIndex > this.accountBook.cars.length) { + } else if (this.activeTabIndex > this.accountBook.cars.length) { this.setGuozhaCellValue(type, blah[type]); } else { this.setCellValue(type, blah[type]); @@ -726,11 +726,11 @@ export class NoteComponent implements OnInit, AfterViewInit { return false; } - if(this.activeTabIndex > this.accountBook.cars.length){ - const newrow = { + if (this.activeTabIndex > this.accountBook.cars.length) { + const newrow = { id: uuidv4(), - pizhong: '', maozhong: '', - jingzhong: '', amount: '', img: [], + pizhong: '', maozhong: '', + jingzhong: '', amount: '', img: [], thumbnail: [], koucheng: '0', price: '0' } const copyRow = this.accountBook.guozhaCars.filter(car => car.id === id).pop(); @@ -792,6 +792,32 @@ export class NoteComponent implements OnInit, AfterViewInit { await alert.present(); } + /** + * 编辑夜班白班 + * @param z index + */ + async editNight(z: number) { + const alert = await this.alertCtrl.create({ + header: '白/夜班', + backdropDismiss: false, + inputs: [{ type: 'radio', label: '白班', value: false }, { type: 'radio', label: '夜班', value: true }], + buttons: [ + { + text: '取消', + role: 'cancel', + cssClass: 'secondary', + handler: () => { } + }, { + text: '确定', + handler: (blah: string) => { + this.setOutCellValue(type, blah[type]) + } + } + ] + }); + await alert.present(); + } + setOutCellValue(type: string, value: string) { if (!this.editable) { return false; @@ -854,13 +880,13 @@ export class NoteComponent implements OnInit, AfterViewInit { this.setCellValue('thumbnail', ''); } - async editGuozha(oldValue: string, z: number, type: string){ + async editGuozha(oldValue: string, z: number, type: string) { if (!this.editable) { return false; } this.editRowIndex = z; - const config = { origin: '来源', type:'果渣', carNo: '车牌号', maozhong: "毛重", pizhong: '皮重', amount: '料款', koucheng: '扣秤' }; - const config1 = { type: 'text', origin: 'text', carNo:'text', maozhong: "number", pizhong: 'number', amount: 'number', koucheng: 'number' }; + const config = { origin: '来源', type: '果渣', carNo: '车牌号', maozhong: "毛重", pizhong: '皮重', amount: '料款', koucheng: '扣秤' }; + const config1 = { type: 'text', origin: 'text', carNo: 'text', maozhong: "number", pizhong: 'number', amount: 'number', koucheng: 'number' }; const title = config[type]; const inputType = config1[type]; const inputs: AlertInput[] = [ @@ -896,7 +922,7 @@ export class NoteComponent implements OnInit, AfterViewInit { await alert.present(); } - setGuozhaCellValue(type: string, value: string){ + setGuozhaCellValue(type: string, value: string) { if (!this.editable) { return false; } @@ -933,7 +959,7 @@ export class NoteComponent implements OnInit, AfterViewInit { this.save(true); } - async openGuozhaPicture(index: number){ + async openGuozhaPicture(index: number) { const thumbnails = this.accountBook.guozhaCars[index].thumbnail; const pictures = this.accountBook.guozhaCars[index].img; @@ -948,7 +974,7 @@ export class NoteComponent implements OnInit, AfterViewInit { await modal.present(); } - openGuozhaCamera(z: number){ + openGuozhaCamera(z: number) { if (!this.editable) { this.toast.info('只有当天的账本可以修改'); return false; From 25a4d0d95966cc976d37e8aaae261a342fd842b6 Mon Sep 17 00:00:00 2001 From: blink Date: Thu, 28 Jul 2022 00:09:50 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/common/total/total.component.html | 47 +++-- src/app/common/total/total.component.scss | 43 +++- src/app/common/total/total.component.ts | 227 ++++++++++++++++++---- src/app/note/note.component.ts | 7 +- 4 files changed, 264 insertions(+), 60 deletions(-) diff --git a/src/app/common/total/total.component.html b/src/app/common/total/total.component.html index e86fcaf..f4360f7 100644 --- a/src/app/common/total/total.component.html +++ b/src/app/common/total/total.component.html @@ -1,8 +1,15 @@ -
-

{{date | date:'yyyy-MM-dd'}} 统计(单位:吨)

- +

{{date | date:'yyyy-MM-dd'}} 总计: + {{total}} + (吨) +

+
复制文字
+ +

车队  共计: {{carTotal.total}}({{carTotal.count}}车) @@ -21,6 +28,8 @@ {{car.total}} ({{car.totalCount}}车)

+ +

外来车辆  共计: {{outCarTotal.total}}({{outCarTotal.count}}车) @@ -29,20 +38,24 @@

-
- - {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} - ({{outCar.count}}车)   - -
- - -
- 总计:  - {{total}} +
+
+

白班:{{outCarTotal1.total}}

+ + {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} + ({{outCar.count}}车)
+
+
+
+

夜班:{{outCarTotal2.total}}

+ + {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} + ({{outCar.count}}车)
+
+
-
+
+ \ No newline at end of file diff --git a/src/app/common/total/total.component.scss b/src/app/common/total/total.component.scss index 2a3b9c3..7d7f979 100644 --- a/src/app/common/total/total.component.scss +++ b/src/app/common/total/total.component.scss @@ -5,8 +5,7 @@ margin: 0px 0px; } .car, -.outcar, -.total { +.outcar{ display: flex; flex-direction: row; } @@ -42,12 +41,42 @@ .total { font-size: 18px; font-weight: bold; - padding-left: 16px; - margin: 0px 0px; - & > span { - color: #e94f4f; - } + padding-left: 8px; + // margin: 0px 0px; + color: #e94f4f; } .box{ transform: scale(0.8); } +.outDetail{ + display: flex; +} +.day { + display: inline-block; + box-sizing: border-box; + padding-left: 8px; + width: 50%; +} +.night { + width: 50%; + box-sizing: border-box; + padding-left: 8px; + flex: 1; +} + + +.day>p,.night>p{ + color: #108ee9; + font-weight: bold; + font-size: 15px; + margin-bottom: 6px; +} +.day>p>span,.night>p>span{ + color: #e94f4f; + padding-left: 8px; +} +.copyText{ + float: right; + right: 8px; + top: -20px; +} diff --git a/src/app/common/total/total.component.ts b/src/app/common/total/total.component.ts index 2eda7c6..97ec398 100644 --- a/src/app/common/total/total.component.ts +++ b/src/app/common/total/total.component.ts @@ -4,7 +4,10 @@ import { Big } from 'big.js'; import { CameraService } from '../camera/camera.service'; import html2canvas from 'html2canvas'; import { SocialSharing } from '@ionic-native/social-sharing/ngx'; -import { ModalController } from '@ionic/angular'; +import { ModalController, ToastController } from '@ionic/angular'; +import * as moment from 'moment'; +import { ToastService } from 'ng-zorro-antd-mobile'; + @Component({ selector: 'app-total', @@ -17,17 +20,23 @@ export class TotalComponent implements OnInit { date = ''; cars: any[] = []; outCars: any[] = []; + outCars1: any[] = []; guozhaCars: any[] = []; total = '0'; carTotal = { total: '0', count: 0 }; - carDetail = [];// 公司车辆拉货详情 - outcarDetail = []; // 外来车辆拉货详情 + carDetail = []; // 公司车辆拉货详情 + outcarDetail = []; // 外来车辆拉货详情(白) + outcarDetail1 = []; // 外来车辆拉货详情(夜) outCarTotal = { total: '0', count: 0 }; + outCarTotal1 = { total: '0', count: 0 }; + outCarTotal2 = { total: '0', count: 0 }; guozhaCarTotal = { total: '0', count: 0 }; constructor( private camera: CameraService, private socialSharing: SocialSharing, - private modal: ModalController + private modal: ModalController, + private toast: ToastService, + private toastCtrl: ToastController ) {} ngOnInit() { @@ -38,6 +47,7 @@ export class TotalComponent implements OnInit { // this.cars = this.accountBook.cars; this.cars = this.initCar(); this.outCars = this.initOutCar(); + this.outCars1 = this.initOutCar1(); this.guozhaCars = this.initGuozhaCar(); this.carTotal = this.getTotalCar(); this.outCarTotal = this.getOutTotalCar(); @@ -45,6 +55,7 @@ export class TotalComponent implements OnInit { this.total = this.initTotal(); this.carDetail = this.getDetailCar(); this.outcarDetail = this.getOutDetailCar(); + this.outcarDetail1 = this.getOutDetailCar1(); } initCar() { const cars = []; @@ -91,22 +102,53 @@ export class TotalComponent implements OnInit { const outCars = this.accountBook.outCars || []; const car1: string[] = []; outCars.forEach((car) => { - const jingzhong = car.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { - const index = car1.indexOf(car.origin + car.type); - if (index !== -1) { - cars[index].count++; - cars[index].jingzhong = new Big(cars[index].jingzhong) - .plus(car.jingzhong || '0') - .toString(); - } else { - cars.push({ - origin: car.origin, - type: car.type, - count: 1, - jingzhong: car.jingzhong || '0', - }); - car1.push(car.origin + car.type); + if (!car.night) { + const jingzhong = car.jingzhong.trim(); + if (jingzhong && jingzhong !== '0') { + const index = car1.indexOf(car.origin + car.type); + if (index !== -1) { + cars[index].count++; + cars[index].jingzhong = new Big(cars[index].jingzhong) + .plus(car.jingzhong || '0') + .toString(); + } else { + cars.push({ + origin: car.origin, + type: car.type, + count: 1, + jingzhong: car.jingzhong || '0', + }); + car1.push(car.origin + car.type); + } + } + } + }); + return cars; + } + // 夜间外来车辆 + initOutCar1() { + const cars = []; + const outCars = this.accountBook.outCars || []; + const car1: string[] = []; + outCars.forEach((car) => { + if (car.night) { + const jingzhong = car.jingzhong.trim(); + if (jingzhong && jingzhong !== '0') { + const index = car1.indexOf(car.origin + car.type); + if (index !== -1) { + cars[index].count++; + cars[index].jingzhong = new Big(cars[index].jingzhong) + .plus(car.jingzhong || '0') + .toString(); + } else { + cars.push({ + origin: car.origin, + type: car.type, + count: 1, + jingzhong: car.jingzhong || '0', + }); + car1.push(car.origin + car.type); + } } } }); @@ -169,20 +211,24 @@ export class TotalComponent implements OnInit { const index = types.indexOf(type.type); if (index !== -1) { const count = detail[index].count; - const jingzhong = detail[index].jingzhong; - detail[index].count = new Big(type.count).plus(count).toString(); - detail[index].jingzhong = new Big(type.jingzhong).plus(jingzhong).toString(); + const jingzhong = detail[index].jingzhong; + detail[index].count = new Big(type.count) + .plus(count) + .toString(); + detail[index].jingzhong = new Big(type.jingzhong) + .plus(jingzhong) + .toString(); } else { - types.push(type.type); - detail.push({ - type: type.type, - count: type.count, - jingzhong: type.jingzhong - }); - } + types.push(type.type); + detail.push({ + type: type.type, + count: type.count, + jingzhong: type.jingzhong, + }); + } }); }); - return detail; + return detail; } getOutDetailCar() { @@ -194,26 +240,84 @@ export class TotalComponent implements OnInit { const count = detail[index].count; const jingzhong = detail[index].jingzhong; detail[index].count = new Big(car.count).plus(count).toString(); - detail[index].jingzhong = new Big(car.jingzhong).plus(jingzhong).toString(); + detail[index].jingzhong = new Big(car.jingzhong) + .plus(jingzhong) + .toString(); } else { types.push(car.type); detail.push({ type: car.type, count: car.count, - jingzhong: car.jingzhong + jingzhong: car.jingzhong, }); } }); - return detail; + this.outCars1.forEach((car) => { + const index = types.indexOf(car.type); + if (index !== -1) { + const count = detail[index].count; + const jingzhong = detail[index].jingzhong; + detail[index].count = new Big(car.count).plus(count).toString(); + detail[index].jingzhong = new Big(car.jingzhong) + .plus(jingzhong) + .toString(); + } else { + types.push(car.type); + detail.push({ + type: car.type, + count: car.count, + jingzhong: car.jingzhong, + }); + } + }); + return detail; + } + + getOutDetailCar1() { + const types = []; + const detail = []; + this.outCars1.forEach((car) => { + const index = types.indexOf(car.type); + if (index !== -1) { + const count = detail[index].count; + const jingzhong = detail[index].jingzhong; + detail[index].count = new Big(car.count).plus(count).toString(); + detail[index].jingzhong = new Big(car.jingzhong) + .plus(jingzhong) + .toString(); + } else { + types.push(car.type); + detail.push({ + type: car.type, + count: car.count, + jingzhong: car.jingzhong, + }); + } + }); + return detail; } getOutTotalCar() { let total = { total: '0', count: 0 }; this.outCars.forEach((car) => { + const j = new Big(car.jingzhong || '0'); + total.total = j.plus(total.total).toString(); + total.count = total.count + car.count; + this.outCarTotal1.total = new Big(car.jingzhong || '0') + .plus(this.outCarTotal1.total) + .toString(); + this.outCarTotal1.count = this.outCarTotal1.count + car.count; + }); + this.outCars1.forEach((car) => { + const j = new Big(car.jingzhong || '0'); total.total = new Big(car.jingzhong || '0') .plus(total.total) .toString(); total.count = total.count + car.count; + this.outCarTotal2.total = j + .plus(this.outCarTotal2.total) + .toString(); + this.outCarTotal2.count = this.outCarTotal2.count + car.count; }); return total; } @@ -251,4 +355,59 @@ export class TotalComponent implements OnInit { }); }); } + /** + * 复制文字 + */ + copyText() { + const copyToClipboard = str => { + const el = document.createElement('textarea'); + el.value = str; + el.setAttribute('readonly', ''); + el.style.position = 'absolute'; + el.style.left = '-9999px'; + document.body.appendChild(el); + const selected = + document.getSelection().rangeCount > 0 + ? document.getSelection().getRangeAt(0) + : false; + el.select(); + document.execCommand('copy'); + document.body.removeChild(el); + if (selected) { + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); + } + }; + const date = moment(this.accountBook.date).format('YYYY-MM-DD'); + let day = ''; + let night = ''; + this.outCars.forEach((car) => { + day += ` + ${car.origin}-${car.type}-${car.jingzhong}-${car.count}车`; + }); + this.outCars1.forEach((car) => { + night += ` + ${car.origin}-${car.type}-${car.jingzhong}-${car.count}车`; + }); + const msg = ` +${date}: + +车队:拉料-${this.carTotal.total} + +外来-白班:${day} +白班小计: ${this.outCarTotal1.total} + +外来-夜班:${night} +夜班小计: ${this.outCarTotal2.total} + +今日统计: ${this.total}`; + copyToClipboard(msg); + this.toastCtrl.create({ + message:'复制成功', + duration: 1000, + position: 'middle' + }).then(toast => { + toast.present(); + }) + } } diff --git a/src/app/note/note.component.ts b/src/app/note/note.component.ts index ecb2612..ca1f15e 100644 --- a/src/app/note/note.component.ts +++ b/src/app/note/note.component.ts @@ -797,6 +797,7 @@ export class NoteComponent implements OnInit, AfterViewInit { * @param z index */ async editNight(z: number) { + this.editRowIndex = z; const alert = await this.alertCtrl.create({ header: '白/夜班', backdropDismiss: false, @@ -810,7 +811,9 @@ export class NoteComponent implements OnInit, AfterViewInit { }, { text: '确定', handler: (blah: string) => { - this.setOutCellValue(type, blah[type]) + console.log(blah); + this.setOutCellValue('night', blah); + // this.setOutCellValue(type, blah[type]) } } ] @@ -818,7 +821,7 @@ export class NoteComponent implements OnInit, AfterViewInit { await alert.present(); } - setOutCellValue(type: string, value: string) { + setOutCellValue(type: string, value: any) { if (!this.editable) { return false; } From b65582e772b860ca01ad5ec6a3f16f68746b31f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B4=AA=E4=BA=AE?= Date: Thu, 28 Jul 2022 10:00:55 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/note/note.component.scss | 4 ++ src/app/note/note.component.ts | 78 +++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/app/note/note.component.scss b/src/app/note/note.component.scss index c836de0..a58cffb 100644 --- a/src/app/note/note.component.scss +++ b/src/app/note/note.component.scss @@ -45,3 +45,7 @@ .am-toast.am-toast-nomask.am-toast.am-toast-nomask.am-toast.am-toast-nomask-top { top: 60px; } +.delete { + color: "#ffffff"; + background: "#e94f4f"; +} diff --git a/src/app/note/note.component.ts b/src/app/note/note.component.ts index ecb2612..9ec99b6 100644 --- a/src/app/note/note.component.ts +++ b/src/app/note/note.component.ts @@ -320,12 +320,65 @@ export class NoteComponent implements OnInit, AfterViewInit { this.toast.info('请勾选一行', 1500); return false; } - this.modal.alert('删除', '确定要删除么', [ - { text: '取消', onPress: () => { } }, - { - text: '删除', - onPress: () => - new Promise(resolve => { + // this.modal.alert('删除', '确定要删除么', [ + // { text: '取消', onPress: () => { } }, + // { + // text: '删除', + // onPress: () => + // new Promise(resolve => { + // if (this.isHidden) { + // this.accountBook.cars[this.activeTabIndex].datas.forEach((data, i) => { + // if (this.setOfCheckedId.has(data.id)) { + // const data = cloneDeep(this.accountBook.cars[this.activeTabIndex].datas); + // data.splice(i, 1); + // this.accountBook.cars[this.activeTabIndex].datas = data; + // this.save(true); + // resolve(true); + // } + // }) + // } else if (this.activeTabIndex === this.accountBook.cars.length) { + + // this.accountBook.outCars.forEach((car, i) => { + // if (this.setOfCheckedId.has(car.id)) { + // const data = cloneDeep(this.accountBook.outCars); + // data.splice(i, 1); + // this.accountBook.outCars = data; + // this.save(true); + // resolve(true); + // } + // }) + // } else { + // this.accountBook.guozhaCars.forEach((car, i) => { + // if (this.setOfCheckedId.has(car.id)) { + // const data = cloneDeep(this.accountBook.guozhaCars); + // data.splice(i, 1); + // this.accountBook.guozhaCars = data; + // this.save(true); + // resolve(true); + // } + // }) + // } + + // }), + // style: { + // color: '#ffffff', + // background: '#e94f4f' + // } + // } + // ]); + + this.alertCtrl.create({ + header: '删除', + message:'确定要删除么', + buttons: [ + { + text:'取消', + role: 'cancel', + }, + { + text:'删除', + cssClass: 'delete', + handler: ()=>{ if (this.isHidden) { this.accountBook.cars[this.activeTabIndex].datas.forEach((data, i) => { if (this.setOfCheckedId.has(data.id)) { @@ -333,7 +386,6 @@ export class NoteComponent implements OnInit, AfterViewInit { data.splice(i, 1); this.accountBook.cars[this.activeTabIndex].datas = data; this.save(true); - resolve(true); } }) } else if (this.activeTabIndex === this.accountBook.cars.length) { @@ -344,7 +396,6 @@ export class NoteComponent implements OnInit, AfterViewInit { data.splice(i, 1); this.accountBook.outCars = data; this.save(true); - resolve(true); } }) } else { @@ -354,18 +405,13 @@ export class NoteComponent implements OnInit, AfterViewInit { data.splice(i, 1); this.accountBook.guozhaCars = data; this.save(true); - resolve(true); } }) } - - }), - style: { - color: '#ffffff', - background: '#e94f4f' + } } - } - ]); + ] + }) } /** * 添加车辆弹出框 From 57512fa48ca4b8a09435035d6fac61a618cb2eb1 Mon Sep 17 00:00:00 2001 From: blink Date: Thu, 28 Jul 2022 23:26:00 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/common/total/total.component.html | 18 ++- src/app/common/total/total.component.scss | 13 -- src/app/common/total/total.component.ts | 149 +++++++++++++++++----- 3 files changed, 130 insertions(+), 50 deletions(-) diff --git a/src/app/common/total/total.component.html b/src/app/common/total/total.component.html index f4360f7..0b020b9 100644 --- a/src/app/common/total/total.component.html +++ b/src/app/common/total/total.component.html @@ -1,9 +1,11 @@ - +

{{date | date:'yyyy-MM-dd'}} 总计: {{total}} (吨)

-
复制文字
+
分享文字
+
+

白班:{{outCarTotal1.total}}

- + {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} ({{outCar.count}}车)
+
小计:
+ +   {{car.type}}:{{car.jingzhong}}({{car.count}}车) +

夜班:{{outCarTotal2.total}}

- + {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} ({{outCar.count}}车)
+
小计:
+ +   {{car.type}}:{{car.jingzhong}}({{car.count}}车) +
diff --git a/src/app/common/total/total.component.scss b/src/app/common/total/total.component.scss index 7d7f979..c4b1f24 100644 --- a/src/app/common/total/total.component.scss +++ b/src/app/common/total/total.component.scss @@ -9,15 +9,6 @@ display: flex; flex-direction: row; } -.carlabel { - width: 100px; - text-align: right; - font-size: 16px; - font-weight: bold; -} -.carbox { - flex: 1; -} .title { font-size: 14px; font-weight: bold; @@ -42,12 +33,8 @@ font-size: 18px; font-weight: bold; padding-left: 8px; - // margin: 0px 0px; color: #e94f4f; } -.box{ - transform: scale(0.8); -} .outDetail{ display: flex; } diff --git a/src/app/common/total/total.component.ts b/src/app/common/total/total.component.ts index 97ec398..58ad4a4 100644 --- a/src/app/common/total/total.component.ts +++ b/src/app/common/total/total.component.ts @@ -19,14 +19,16 @@ export class TotalComponent implements OnInit { accountBook: AccountBook; date = ''; cars: any[] = []; - outCars: any[] = []; - outCars1: any[] = []; + outCars: any[] = []; // 外来车辆 + outCars1: any[] = []; // 白天外来车 + outCars2: any[] = []; // 黑夜外来车 guozhaCars: any[] = []; total = '0'; carTotal = { total: '0', count: 0 }; carDetail = []; // 公司车辆拉货详情 - outcarDetail = []; // 外来车辆拉货详情(白) - outcarDetail1 = []; // 外来车辆拉货详情(夜) + outcarDetail = []; // 外来车辆拉货详情 + outcarDetail1 = []; // 外来车辆拉货详情(白) + outcarDetail2 = []; // 外来车辆拉货详情(夜) outCarTotal = { total: '0', count: 0 }; outCarTotal1 = { total: '0', count: 0 }; outCarTotal2 = { total: '0', count: 0 }; @@ -48,14 +50,19 @@ export class TotalComponent implements OnInit { this.cars = this.initCar(); this.outCars = this.initOutCar(); this.outCars1 = this.initOutCar1(); + this.outCars2 = this.initOutCar2(); this.guozhaCars = this.initGuozhaCar(); this.carTotal = this.getTotalCar(); this.outCarTotal = this.getOutTotalCar(); + this.outCarTotal1 = this.getOutTotalCar1(); + this.outCarTotal2 = this.getOutTotalCar2(); this.guozhaCarTotal = this.getGuozhaTotalCar(); this.total = this.initTotal(); this.carDetail = this.getDetailCar(); this.outcarDetail = this.getOutDetailCar(); this.outcarDetail1 = this.getOutDetailCar1(); + this.outcarDetail2 = this.getOutDetailCar2(); + } initCar() { const cars = []; @@ -98,6 +105,33 @@ export class TotalComponent implements OnInit { return cars; } initOutCar() { + const cars = []; + const outCars = this.accountBook.outCars || []; + const car1: string[] = []; + outCars.forEach((car) => { + const jingzhong = car.jingzhong.trim(); + if (jingzhong && jingzhong !== '0') { + const index = car1.indexOf(car.origin + car.type); + if (index !== -1) { + cars[index].count++; + cars[index].jingzhong = new Big(cars[index].jingzhong) + .plus(car.jingzhong || '0') + .toString(); + } else { + cars.push({ + origin: car.origin, + type: car.type, + count: 1, + jingzhong: car.jingzhong || '0', + }); + car1.push(car.origin + car.type); + } + } + }); + return cars; + } + // 白天外来车辆 + initOutCar1() { const cars = []; const outCars = this.accountBook.outCars || []; const car1: string[] = []; @@ -125,8 +159,9 @@ export class TotalComponent implements OnInit { }); return cars; } - // 夜间外来车辆 - initOutCar1() { + + // 黑夜外来车辆 + initOutCar2() { const cars = []; const outCars = this.accountBook.outCars || []; const car1: string[] = []; @@ -154,6 +189,7 @@ export class TotalComponent implements OnInit { }); return cars; } + // initGuozhaCar() { const cars = []; const guozhaCars = this.accountBook.guozhaCars || []; @@ -252,6 +288,12 @@ export class TotalComponent implements OnInit { }); } }); + return detail; + } + + getOutDetailCar1() { + const types = []; + const detail = []; this.outCars1.forEach((car) => { const index = types.indexOf(car.type); if (index !== -1) { @@ -272,11 +314,10 @@ export class TotalComponent implements OnInit { }); return detail; } - - getOutDetailCar1() { + getOutDetailCar2() { const types = []; const detail = []; - this.outCars1.forEach((car) => { + this.outCars2.forEach((car) => { const index = types.indexOf(car.type); if (index !== -1) { const count = detail[index].count; @@ -306,21 +347,36 @@ export class TotalComponent implements OnInit { this.outCarTotal1.total = new Big(car.jingzhong || '0') .plus(this.outCarTotal1.total) .toString(); - this.outCarTotal1.count = this.outCarTotal1.count + car.count; }); + return total; + } + + getOutTotalCar1() { + let total = { total: '0', count: 0 }; this.outCars1.forEach((car) => { const j = new Big(car.jingzhong || '0'); - total.total = new Big(car.jingzhong || '0') - .plus(total.total) + total.total = j.plus(total.total).toString(); + total.count = total.count + car.count; + this.outCarTotal1.total = new Big(car.jingzhong || '0') + .plus(this.outCarTotal1.total) .toString(); + }); + return total; + } + + getOutTotalCar2() { + let total = { total: '0', count: 0 }; + this.outCars2.forEach((car) => { + const j = new Big(car.jingzhong || '0'); + total.total = j.plus(total.total).toString(); total.count = total.count + car.count; - this.outCarTotal2.total = j + this.outCarTotal2.total = new Big(car.jingzhong || '0') .plus(this.outCarTotal2.total) .toString(); - this.outCarTotal2.count = this.outCarTotal2.count + car.count; }); return total; } + getGuozhaTotalCar() { let total = { total: '0', count: 0 }; @@ -381,33 +437,60 @@ export class TotalComponent implements OnInit { const date = moment(this.accountBook.date).format('YYYY-MM-DD'); let day = ''; let night = ''; - this.outCars.forEach((car) => { + this.outCars1.forEach((car) => { day += ` - ${car.origin}-${car.type}-${car.jingzhong}-${car.count}车`; + ${car.origin}-${car.type}:${car.jingzhong}(${car.count}车)`; }); - this.outCars1.forEach((car) => { + this.outCars2.forEach((car) => { night += ` - ${car.origin}-${car.type}-${car.jingzhong}-${car.count}车`; + ${car.origin}-${car.type}:${car.jingzhong}(${car.count}车)`; + }); + let dayDetail = ''; + this.outcarDetail1.forEach(car => { + dayDetail += ` + ${car.type}:${car.jingzhong}(${car.count}车)`; + }); + let nightDetail = ''; + this.outcarDetail2.forEach(car => { + nightDetail += ` + ${car.type}:${car.jingzhong}(${car.count}车)`; }); + let car = ''; + this.cars.forEach(c => { + car += ` + ${c.carNo}:`; + c.types.forEach(t => { + car += ` + ${t.type}:${t.jingzhong}(${t.count}车)` + }) + }); + let carDetail = ''; + this.carDetail.forEach(c => { + carDetail += ` ${c.type}:${c.jingzhong}(${c.count}车) + `; + }) + const msg = ` -${date}: +${date} 单位(吨): -车队:拉料-${this.carTotal.total} +车队: ${car} +车队小计:${this.carTotal.total}(${this.carTotal.count}车) +${carDetail} +白班:${day} +白班小计: ${this.outCarTotal1.total}(${this.outCarTotal1.count}车)${dayDetail} -外来-白班:${day} -白班小计: ${this.outCarTotal1.total} - -外来-夜班:${night} -夜班小计: ${this.outCarTotal2.total} +夜班:${night} +夜班小计: ${this.outCarTotal2.total}(${this.outCarTotal2.count}车)${nightDetail} 今日统计: ${this.total}`; - copyToClipboard(msg); - this.toastCtrl.create({ - message:'复制成功', - duration: 1000, - position: 'middle' - }).then(toast => { - toast.present(); - }) + // copyToClipboard(msg); + // this.toastCtrl.create({ + // message:'复制成功', + // duration: 1000, + // position: 'middle' + // }).then(toast => { + // toast.present(); + // }) + this.socialSharing.share(msg, null, null, null); } } From 32bd57e152e7a70d2f62b30f4977d7453a91779d Mon Sep 17 00:00:00 2001 From: blink Date: Sat, 30 Jul 2022 17:26:15 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=B2=BE=E7=A1=AE=E5=B0=8F=E6=95=B0=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/note/note.component.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/note/note.component.ts b/src/app/note/note.component.ts index 2adf682..260e11b 100644 --- a/src/app/note/note.component.ts +++ b/src/app/note/note.component.ts @@ -411,7 +411,9 @@ export class NoteComponent implements OnInit, AfterViewInit { } } ] - }) + }).then(alert => { + alert.present(); + }); } /** * 添加车辆弹出框 @@ -879,21 +881,21 @@ export class NoteComponent implements OnInit, AfterViewInit { if (type === 'maozhong') { const koucheng = this.accountBook.outCars[this.editRowIndex].koucheng || '0'; const pizhong = this.accountBook.outCars[this.editRowIndex].pizhong || '0'; - const jingzhong = new Big(value).minus(pizhong).times(new Big(100).minus(koucheng).div(100)).toString(); + const jingzhong = new Big(value).minus(pizhong).times(new Big(100).minus(koucheng).div(100)).toFixed(2).toString(); this.accountBook.outCars[this.editRowIndex].jingzhong = jingzhong; const price = this.accountBook.outCars[this.editRowIndex].price || '0'; this.accountBook.outCars[this.editRowIndex].amount = new Big(price).times(jingzhong).toString(); } else if (type === 'pizhong') { const koucheng = this.accountBook.outCars[this.editRowIndex].koucheng || '0'; const maozhong = this.accountBook.outCars[this.editRowIndex].maozhong || '0'; - const jingzhong = new Big(maozhong).minus(value).times(new Big(100).minus(koucheng).div(100)).toString(); + const jingzhong = new Big(maozhong).minus(value).times(new Big(100).minus(koucheng).div(100)).toFixed(2).toString(); this.accountBook.outCars[this.editRowIndex].jingzhong = jingzhong; const price = this.accountBook.outCars[this.editRowIndex].price || '0'; this.accountBook.outCars[this.editRowIndex].amount = new Big(price).times(jingzhong).toString(); } else if (type === 'koucheng') { const maozhong = this.accountBook.outCars[this.editRowIndex].maozhong || '0'; const pizhong = this.accountBook.outCars[this.editRowIndex].pizhong || '0'; - const jingzhong = new Big(maozhong).minus(pizhong).times(new Big(100).minus(value).div(100)).toString(); + const jingzhong = new Big(maozhong).minus(pizhong).times(new Big(100).minus(value).div(100)).toFixed(2).toString(); this.accountBook.outCars[this.editRowIndex].jingzhong = jingzhong; const price = this.accountBook.outCars[this.editRowIndex].price || '0'; this.accountBook.outCars[this.editRowIndex].amount = new Big(price).times(jingzhong).toString(); @@ -983,21 +985,21 @@ export class NoteComponent implements OnInit, AfterViewInit { if (type === 'maozhong') { const koucheng = this.accountBook.guozhaCars[this.editRowIndex].koucheng || '0'; const pizhong = this.accountBook.guozhaCars[this.editRowIndex].pizhong || '0'; - const jingzhong = new Big(value).minus(pizhong).times(new Big(100).minus(koucheng).div(100)).toString(); + const jingzhong = new Big(value).minus(pizhong).times(new Big(100).minus(koucheng).div(100)).toFixed(2).toString(); this.accountBook.guozhaCars[this.editRowIndex].jingzhong = jingzhong; const price = this.accountBook.guozhaCars[this.editRowIndex].price || '0'; this.accountBook.guozhaCars[this.editRowIndex].amount = new Big(price).times(jingzhong).toString(); } else if (type === 'pizhong') { const koucheng = this.accountBook.guozhaCars[this.editRowIndex].koucheng || '0'; const maozhong = this.accountBook.guozhaCars[this.editRowIndex].maozhong || '0'; - const jingzhong = new Big(maozhong).minus(value).times(new Big(100).minus(koucheng).div(100)).toString(); + const jingzhong = new Big(maozhong).minus(value).times(new Big(100).minus(koucheng).div(100)).toFixed(2).toString(); this.accountBook.guozhaCars[this.editRowIndex].jingzhong = jingzhong; const price = this.accountBook.guozhaCars[this.editRowIndex].price || '0'; this.accountBook.guozhaCars[this.editRowIndex].amount = new Big(price).times(jingzhong).toString(); } else if (type === 'koucheng') { const maozhong = this.accountBook.guozhaCars[this.editRowIndex].maozhong || '0'; const pizhong = this.accountBook.guozhaCars[this.editRowIndex].pizhong || '0'; - const jingzhong = new Big(maozhong).minus(pizhong).times(new Big(100).minus(value).div(100)).toString(); + const jingzhong = new Big(maozhong).minus(pizhong).times(new Big(100).minus(value).div(100)).toFixed(2).toString(); this.accountBook.guozhaCars[this.editRowIndex].jingzhong = jingzhong; const price = this.accountBook.guozhaCars[this.editRowIndex].price || '0'; this.accountBook.guozhaCars[this.editRowIndex].amount = new Big(price).times(jingzhong).toString(); From 543bfef5ecf9130bad8dc0ddcd88c44a46f06927 Mon Sep 17 00:00:00 2001 From: blink Date: Sat, 30 Jul 2022 17:27:54 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/common/total/total.component.html | 12 ++++++++---- src/app/common/total/total.component.scss | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/common/total/total.component.html b/src/app/common/total/total.component.html index 0b020b9..2a48ecd 100644 --- a/src/app/common/total/total.component.html +++ b/src/app/common/total/total.component.html @@ -44,8 +44,10 @@

白班:{{outCarTotal1.total}}

- {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} - ({{outCar.count}}车)
+
+ {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} + ({{outCar.count}}车) +
小计:
@@ -55,8 +57,10 @@

夜班:{{outCarTotal2.total}}

- {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} - ({{outCar.count}}车)
+
+ {{outCar.origin}}-{{outCar.type}}:{{outCar.jingzhong}} + ({{outCar.count}}车) +
小计:
diff --git a/src/app/common/total/total.component.scss b/src/app/common/total/total.component.scss index c4b1f24..3e90d23 100644 --- a/src/app/common/total/total.component.scss +++ b/src/app/common/total/total.component.scss @@ -62,6 +62,12 @@ color: #e94f4f; padding-left: 8px; } +.day>.row,.night>.row { + display: inline-block; + font-size: 13px; + width: 50%; +} + .copyText{ float: right; right: 8px; From c753e7f9d111e3c38bd7e0ba5b33efeb0fa84f8f Mon Sep 17 00:00:00 2001 From: blink Date: Mon, 15 Aug 2022 22:01:12 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=AA=E5=8E=BB?= =?UTF-8?q?=E7=9A=AE=E7=BB=9F=E8=AE=A1=EF=BC=8C=E6=8A=8A=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E5=8E=9F=E6=96=99=E6=98=BE=E7=A4=BA=E5=9C=A8=E7=9B=B8=E8=BF=91?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/common/total/total.component.html | 2 + src/app/common/total/total.component.ts | 187 ++++++++++++++++------ 2 files changed, 138 insertions(+), 51 deletions(-) diff --git a/src/app/common/total/total.component.html b/src/app/common/total/total.component.html index 2a48ecd..bd4b6c7 100644 --- a/src/app/common/total/total.component.html +++ b/src/app/common/total/total.component.html @@ -53,6 +53,7 @@   {{car.type}}:{{car.jingzhong}}({{car.count}}车) +   未去皮:{{outcarDetailoutpi1.total}}({{outcarDetailoutpi1.count}}车)

夜班:{{outCarTotal2.total}}

@@ -66,6 +67,7 @@   {{car.type}}:{{car.jingzhong}}({{car.count}}车) +   未去皮:{{outcarDetailoutpi2.total}}({{outcarDetailoutpi2.count}}车)
diff --git a/src/app/common/total/total.component.ts b/src/app/common/total/total.component.ts index 58ad4a4..ac2345a 100644 --- a/src/app/common/total/total.component.ts +++ b/src/app/common/total/total.component.ts @@ -8,7 +8,6 @@ import { ModalController, ToastController } from '@ionic/angular'; import * as moment from 'moment'; import { ToastService } from 'ng-zorro-antd-mobile'; - @Component({ selector: 'app-total', templateUrl: './total.component.html', @@ -29,6 +28,8 @@ export class TotalComponent implements OnInit { outcarDetail = []; // 外来车辆拉货详情 outcarDetail1 = []; // 外来车辆拉货详情(白) outcarDetail2 = []; // 外来车辆拉货详情(夜) + outcarDetailoutpi1 = { total: '0', count: 0 } // 外来车辆详情没有皮重(白) + outcarDetailoutpi2 = { total: '0', count: 0 } // 外来车辆详情没有皮重(夜) outCarTotal = { total: '0', count: 0 }; outCarTotal1 = { total: '0', count: 0 }; outCarTotal2 = { total: '0', count: 0 }; @@ -62,7 +63,6 @@ export class TotalComponent implements OnInit { this.outcarDetail = this.getOutDetailCar(); this.outcarDetail1 = this.getOutDetailCar1(); this.outcarDetail2 = this.getOutDetailCar2(); - } initCar() { const cars = []; @@ -106,39 +106,76 @@ export class TotalComponent implements OnInit { } initOutCar() { const cars = []; - const outCars = this.accountBook.outCars || []; const car1: string[] = []; - outCars.forEach((car) => { - const jingzhong = car.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { - const index = car1.indexOf(car.origin + car.type); - if (index !== -1) { - cars[index].count++; - cars[index].jingzhong = new Big(cars[index].jingzhong) - .plus(car.jingzhong || '0') - .toString(); - } else { - cars.push({ - origin: car.origin, - type: car.type, - count: 1, - jingzhong: car.jingzhong || '0', - }); - car1.push(car.origin + car.type); - } + let outCars = this.accountBook.outCars || []; + const types: string[] = []; + outCars = outCars.filter(car => car.jingzhong.trim() && car.jingzhong !== '0'); + let type = ''; + outCars.forEach((outcar) => { + type = outcar.type; + if (!types.includes(type)) { + const filOutCars = outCars.filter(c =>c.type === type); + filOutCars.forEach(car =>{ + const index = car1.indexOf(car.origin + car.type); + if (index !== -1) { + cars[index].count++; + cars[index].jingzhong = new Big(cars[index].jingzhong) + .plus(car.jingzhong || '0') + .toString(); + } else { + cars.push({ + origin: car.origin, + type: car.type, + count: 1, + jingzhong: car.jingzhong || '0', + }); + car1.push(car.origin + car.type); + } + }); + types.push(type); } }); return cars; } // 白天外来车辆 initOutCar1() { + // const cars = []; + // const outCars = this.accountBook.outCars || []; + // const car1: string[] = []; + // outCars.forEach((car) => { + // if (!car.night) { + // const jingzhong = car.jingzhong.trim(); + // if (jingzhong && jingzhong !== '0') { + // const index = car1.indexOf(car.origin + car.type); + // if (index !== -1) { + // cars[index].count++; + // cars[index].jingzhong = new Big(cars[index].jingzhong) + // .plus(car.jingzhong || '0') + // .toString(); + // } else { + // cars.push({ + // origin: car.origin, + // type: car.type, + // count: 1, + // jingzhong: car.jingzhong || '0', + // }); + // car1.push(car.origin + car.type); + // } + // } + // } + // }); + // return cars; const cars = []; - const outCars = this.accountBook.outCars || []; const car1: string[] = []; - outCars.forEach((car) => { - if (!car.night) { - const jingzhong = car.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { + let outCars = this.accountBook.outCars || []; + const types: string[] = []; + outCars = outCars.filter(car => car.jingzhong.trim() && car.jingzhong !== '0' && !car.night); + let type = ''; + outCars.forEach((outcar) => { + type = outcar.type; + if (!types.includes(type)) { + const filOutCars = outCars.filter(c =>c.type === type); + filOutCars.forEach(car =>{ const index = car1.indexOf(car.origin + car.type); if (index !== -1) { cars[index].count++; @@ -154,7 +191,8 @@ export class TotalComponent implements OnInit { }); car1.push(car.origin + car.type); } - } + }); + types.push(type); } }); return cars; @@ -162,13 +200,43 @@ export class TotalComponent implements OnInit { // 黑夜外来车辆 initOutCar2() { + // const cars = []; + // const outCars = this.accountBook.outCars || []; + // const car1: string[] = []; + // outCars.forEach((car) => { + // if (car.night) { + // const jingzhong = car.jingzhong.trim(); + // if (jingzhong && jingzhong !== '0') { + // const index = car1.indexOf(car.origin + car.type); + // if (index !== -1) { + // cars[index].count++; + // cars[index].jingzhong = new Big(cars[index].jingzhong) + // .plus(car.jingzhong || '0') + // .toString(); + // } else { + // cars.push({ + // origin: car.origin, + // type: car.type, + // count: 1, + // jingzhong: car.jingzhong || '0', + // }); + // car1.push(car.origin + car.type); + // } + // } + // } + // }); + // return cars; const cars = []; - const outCars = this.accountBook.outCars || []; const car1: string[] = []; - outCars.forEach((car) => { - if (car.night) { - const jingzhong = car.jingzhong.trim(); - if (jingzhong && jingzhong !== '0') { + let outCars = this.accountBook.outCars || []; + const types: string[] = []; + outCars = outCars.filter(car => car.jingzhong.trim() && car.jingzhong !== '0' && car.night); + let type = ''; + outCars.forEach((outcar) => { + type = outcar.type; + if (!types.includes(type)) { + const filOutCars = outCars.filter(c =>c.type === type); + filOutCars.forEach(car =>{ const index = car1.indexOf(car.origin + car.type); if (index !== -1) { cars[index].count++; @@ -184,12 +252,13 @@ export class TotalComponent implements OnInit { }); car1.push(car.origin + car.type); } - } + }); + types.push(type); } }); return cars; } - // + // initGuozhaCar() { const cars = []; const guozhaCars = this.accountBook.guozhaCars || []; @@ -312,6 +381,14 @@ export class TotalComponent implements OnInit { }); } }); + let outCars = this.accountBook.outCars || []; + outCars = outCars.filter(car => car.jingzhong.trim() && car.jingzhong !== '0' && !car.night); + outCars.forEach(car =>{ + if (!car.pizhong || !car.pizhong.trim() || car.pizhong === '0' ) { + this.outcarDetailoutpi1.total = new Big(this.outcarDetailoutpi1.total).plus(car.jingzhong).toString(); + this.outcarDetailoutpi1.count++; + } + }); return detail; } getOutDetailCar2() { @@ -335,6 +412,14 @@ export class TotalComponent implements OnInit { }); } }); + let outCars = this.accountBook.outCars || []; + outCars = outCars.filter(car => car.jingzhong.trim() && car.jingzhong !== '0' && car.night); + outCars.forEach(car =>{ + if (!car.pizhong || !car.pizhong.trim() || car.pizhong === '0' ) { + this.outcarDetailoutpi2.total = new Big(this.outcarDetailoutpi2.total).plus(car.jingzhong).toString(); + this.outcarDetailoutpi2.count++; + } + }); return detail; } @@ -376,7 +461,6 @@ export class TotalComponent implements OnInit { }); return total; } - getGuozhaTotalCar() { let total = { total: '0', count: 0 }; @@ -415,7 +499,7 @@ export class TotalComponent implements OnInit { * 复制文字 */ copyText() { - const copyToClipboard = str => { + const copyToClipboard = (str) => { const el = document.createElement('textarea'); el.value = str; el.setAttribute('readonly', ''); @@ -423,15 +507,15 @@ export class TotalComponent implements OnInit { el.style.left = '-9999px'; document.body.appendChild(el); const selected = - document.getSelection().rangeCount > 0 - ? document.getSelection().getRangeAt(0) - : false; + document.getSelection().rangeCount > 0 + ? document.getSelection().getRangeAt(0) + : false; el.select(); document.execCommand('copy'); document.body.removeChild(el); if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); } }; const date = moment(this.accountBook.date).format('YYYY-MM-DD'); @@ -446,30 +530,30 @@ export class TotalComponent implements OnInit { ${car.origin}-${car.type}:${car.jingzhong}(${car.count}车)`; }); let dayDetail = ''; - this.outcarDetail1.forEach(car => { + this.outcarDetail1.forEach((car) => { dayDetail += ` ${car.type}:${car.jingzhong}(${car.count}车)`; }); let nightDetail = ''; - this.outcarDetail2.forEach(car => { + this.outcarDetail2.forEach((car) => { nightDetail += ` ${car.type}:${car.jingzhong}(${car.count}车)`; }); - let car = ''; - this.cars.forEach(c => { + let car = ''; + this.cars.forEach((c) => { car += ` ${c.carNo}:`; - c.types.forEach(t => { + c.types.forEach((t) => { car += ` - ${t.type}:${t.jingzhong}(${t.count}车)` - }) + ${t.type}:${t.jingzhong}(${t.count}车)`; + }); }); let carDetail = ''; - this.carDetail.forEach(c => { + this.carDetail.forEach((c) => { carDetail += ` ${c.type}:${c.jingzhong}(${c.count}车) `; - }) - + }); + const msg = ` ${date} 单位(吨): @@ -491,6 +575,7 @@ ${carDetail} // }).then(toast => { // toast.present(); // }) + console.log(msg); this.socialSharing.share(msg, null, null, null); } } From a6aaea62bdb0b8f400b4cc105f9dce50f55d5cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B4=AA=E4=BA=AE?= Date: Tue, 16 Aug 2022 09:59:51 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=8B?= =?UTF-8?q?=E5=88=A4=E6=96=ADid=E7=9A=84=E6=96=B9=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E7=9C=8B=E7=9C=8B=E8=83=BD=E4=B8=8D=E8=83=BD=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E4=B8=8D=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/note/note.component.html | 6 +++--- src/app/note/note.component.ts | 28 ++++++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/app/note/note.component.html b/src/app/note/note.component.html index 28952e3..ba36d35 100644 --- a/src/app/note/note.component.html +++ b/src/app/note/note.component.html @@ -39,7 +39,7 @@ - @@ -98,7 +98,7 @@ - {{data.origin}} @@ -150,7 +150,7 @@ - {{data.origin}} diff --git a/src/app/note/note.component.ts b/src/app/note/note.component.ts index 260e11b..d9e1e58 100644 --- a/src/app/note/note.component.ts +++ b/src/app/note/note.component.ts @@ -35,7 +35,8 @@ export class NoteComponent implements OnInit, AfterViewInit { isHidden = false; isReady = false; scroll = { x: '1000px', y: '500px' }; - setOfCheckedId = new Set(); // 选中的id + // setOfCheckedId = new Set(); // 选中的id + setOfCheckedId = ''; // 选中的id @ViewChild('tableBox') tableBox: ElementRef; // @ViewChild('tableHeader') tableHeader: ElementRef; constructor( @@ -114,7 +115,8 @@ export class NoteComponent implements OnInit, AfterViewInit { * @param index any */ changeTab(index: any) { - this.setOfCheckedId.clear(); + // this.setOfCheckedId.clear(); + this.setOfCheckedId = ''; setTimeout(() => { this.activeTabIndex = index.index; if (this.activeTabIndex >= this.accountBook.cars.length) { @@ -316,7 +318,7 @@ export class NoteComponent implements OnInit, AfterViewInit { if (!this.editable) { return false; } - if (!this.setOfCheckedId.size) { + if (!this.setOfCheckedId.length) { this.toast.info('请勾选一行', 1500); return false; } @@ -381,7 +383,7 @@ export class NoteComponent implements OnInit, AfterViewInit { handler: ()=>{ if (this.isHidden) { this.accountBook.cars[this.activeTabIndex].datas.forEach((data, i) => { - if (this.setOfCheckedId.has(data.id)) { + if (this.setOfCheckedId === data.id) { const data = cloneDeep(this.accountBook.cars[this.activeTabIndex].datas); data.splice(i, 1); this.accountBook.cars[this.activeTabIndex].datas = data; @@ -391,7 +393,7 @@ export class NoteComponent implements OnInit, AfterViewInit { } else if (this.activeTabIndex === this.accountBook.cars.length) { this.accountBook.outCars.forEach((car, i) => { - if (this.setOfCheckedId.has(car.id)) { + if (this.setOfCheckedId === car.id) { const data = cloneDeep(this.accountBook.outCars); data.splice(i, 1); this.accountBook.outCars = data; @@ -400,7 +402,7 @@ export class NoteComponent implements OnInit, AfterViewInit { }) } else { this.accountBook.guozhaCars.forEach((car, i) => { - if (this.setOfCheckedId.has(car.id)) { + if (this.setOfCheckedId === car.id) { const data = cloneDeep(this.accountBook.guozhaCars); data.splice(i, 1); this.accountBook.guozhaCars = data; @@ -747,9 +749,11 @@ export class NoteComponent implements OnInit, AfterViewInit { * @memberof NoteComponent */ onItemChecked(id: string, checked: boolean): void { - this.setOfCheckedId.clear(); + // this.setOfCheckedId.clear(); + this.setOfCheckedId = ''; if (checked) { - this.setOfCheckedId.add(id); + // this.setOfCheckedId.add(id); + this.setOfCheckedId = id; } } @@ -765,10 +769,10 @@ export class NoteComponent implements OnInit, AfterViewInit { * 复制一行 */ copy() { - let id = ''; - this.setOfCheckedId.forEach(a => { - id = a - }); + let id = this.setOfCheckedId; + // this.setOfCheckedId.forEach(a => { + // id = a + // }); if (!id) { this.toast.info('请勾选一行', 1500); return false;