Procházet zdrojové kódy

添加陪验列表和上传图片

panxingxin před 5 roky
rodič
revize
7a8a86dfa4

+ 3 - 1
src/app/app-routing.module.ts

@@ -29,7 +29,9 @@ const routes: Routes = [
   { path: 'enter-store-detail/:code/:entergoodsid', loadChildren: './enter-store-detail/enter-store-detail.module#EnterStoreDetailPageModule' },
   { path: 'store-qc-search', loadChildren: './store-qc-search/store-qc-search.module#StoreQcSearchPageModule' },
   { path: 'sample-count-zero', loadChildren: './sample-count-zero/sample-count-zero.module#SampleCountZeroPageModule' },
-  { path: 'store-pending-search', loadChildren: './store-pending-search/store-pending-search.module#StorePendingSearchPageModule' }
+  { path: 'store-pending-search', loadChildren: './store-pending-search/store-pending-search.module#StorePendingSearchPageModule' },
+  { path: 'inspection', loadChildren: './inspection/inspection.module#InspectionPageModule' },
+  { path: 'inspection-list/:poCode/:scCode', loadChildren: './inspection-list/inspection-list.module#InspectionListPageModule' }
   // { path: 'scanning', loadChildren: './scanning/scanning.module#ScanningPageModule', canActivate: [LoginGuardGuard] }
 ];
 @NgModule({

+ 26 - 0
src/app/inspection-list/inspection-list.module.ts

@@ -0,0 +1,26 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { Routes, RouterModule } from '@angular/router';
+
+import { IonicModule } from '@ionic/angular';
+
+import { InspectionListPage } from './inspection-list.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: InspectionListPage
+  }
+];
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    RouterModule.forChild(routes)
+  ],
+  declarations: [InspectionListPage]
+})
+export class InspectionListPageModule {}

+ 53 - 0
src/app/inspection-list/inspection-list.page.html

@@ -0,0 +1,53 @@
+<ion-header>
+  <ion-toolbar>
+    <ion-buttons slot="start">
+      <ion-back-button defaultHref="inspection"></ion-back-button>
+    </ion-buttons>
+    <ion-title>陪验列表</ion-title>
+    <ion-buttons slot="end">
+      <ion-icon name="cloud-upload" slot="end" (click)="choosePicture()"></ion-icon>
+      <ion-icon name="camera" slot="end" (click)="takePicture()"></ion-icon>
+    </ion-buttons>
+  </ion-toolbar>
+</ion-header>
+
+<ion-content>
+  <ion-list *ngFor="let ins of inspectionList">
+    <ion-item-group>
+      <ion-item-divider sticky>
+        <ion-label>
+          详细信息
+        </ion-label>
+      </ion-item-divider>
+    </ion-item-group>
+    <ion-item>
+      <ion-label>
+        我司货号:
+      </ion-label>
+      <ion-input [(ngModel)]="ins.scpCode" readonly></ion-input>
+    </ion-item>
+    <ion-item>
+      <ion-label>
+        po号:
+      </ion-label>
+      <ion-input [(ngModel)]="ins.poCode" readonly></ion-input>
+    </ion-item>
+    <ion-item>
+      <ion-label>
+        sc号:
+      </ion-label>
+      <ion-input [(ngModel)]="ins.scCode" readonly></ion-input>
+    </ion-item>
+  </ion-list>
+  <ion-item>
+    <ion-label>QC日志图片:</ion-label>
+    <ion-thumbnail *ngFor="let photo of imgList index as i">
+        <ion-icon name="close-circle-outline" (click)="deletePicture(i)"></ion-icon>
+      <ion-img [src]="photo" (click)="showFullScreenImage(photo)">
+      </ion-img>
+    </ion-thumbnail>
+  </ion-item>
+  <div class="ion-padding">
+    <ion-button color="primary" expand="block" (click)="upload()" [disabled]="imgList.length===0">上传</ion-button>
+  </div>
+</ion-content>

+ 0 - 0
src/app/inspection-list/inspection-list.page.scss


+ 27 - 0
src/app/inspection-list/inspection-list.page.spec.ts

@@ -0,0 +1,27 @@
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { InspectionListPage } from './inspection-list.page';
+
+describe('InspectionListPage', () => {
+  let component: InspectionListPage;
+  let fixture: ComponentFixture<InspectionListPage>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ InspectionListPage ],
+      schemas: [CUSTOM_ELEMENTS_SCHEMA],
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(InspectionListPage);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 122 - 0
src/app/inspection-list/inspection-list.page.ts

@@ -0,0 +1,122 @@
+import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute } from '@angular/router'
+import { UserData } from '../../providers/user-data';
+import { Camera } from '@ionic-native/camera/ngx';
+import { CameraSetting } from '../../providers/camera-photo'
+import { commonService } from '../../providers/common.service'
+import { ImagePicker, ImagePickerOptions } from '@ionic-native/image-picker/ngx';
+import { Base64 } from '@ionic-native/base64/ngx';
+import { ToastController } from '@ionic/angular';
+
+@Component({
+  selector: 'app-inspection-list',
+  templateUrl: './inspection-list.page.html',
+  styleUrls: ['./inspection-list.page.scss'],
+})
+export class InspectionListPage implements OnInit {
+
+  public inspectionList = []
+  public imgList = []
+  public imageData = ''
+
+  constructor(private activeRoute: ActivatedRoute,
+    public userData: UserData,
+    public commonService: commonService,
+    private cameraSetting: CameraSetting,
+    private base64: Base64,
+    private imagePicker: ImagePicker,
+    private camera: Camera,
+    private toastCtrl: ToastController) { }
+
+  ngOnInit() {
+  }
+
+  ionViewDidEnter() {
+    this.activeRoute.paramMap.subscribe(async params => {
+      let data = await this.userData.getInspectionList(params['params']['poCode'], params['params']['scCode'])
+      this.inspectionList = data
+    })
+  }
+
+  choosePicture() {
+    const options: ImagePickerOptions = {
+      maximumImagesCount: 30,
+      outputType: 1,
+      width: 1800,
+      height: 1350,
+      quality: 90
+    };
+
+    this.imagePicker.getPictures(options).then((results) => {
+      for (var i = 0; i < results.length; i++) {
+        this.base64.encodeFile(results[i]).then((base64File: string) => {
+          this.imgList.push(
+            base64File
+          )
+          let imageData = base64File.split('base64,')[1]
+          if (this.imageData) {
+            this.imageData = this.imageData + ',' + imageData
+          } else {
+            this.imageData = '' + imageData
+          }
+        }, (err) => {
+          console.log(err);
+        });
+      }
+    }, (err) => { });
+    // this.showPicture(qc, this.cameraSetting.albumOption)
+  }
+
+  takePicture() {
+    this.showPicture(this.cameraSetting.takePhotoOption)
+  }
+  showPicture(options) {
+    this.camera.getPicture(options).then((imageData) => {
+      this.imgList.push(
+        'data:image/png;base64,' + imageData
+      )
+      if (this.imageData) {
+        this.imageData = this.imageData + ',' + imageData
+      } else {
+        this.imageData = '' + imageData
+      }
+    }, (err) => {
+      // Handle error
+      console.log("Camera issue: " + err);
+    });
+  }
+
+  deletePicture(index) {
+    this.imgList.splice(index, 1)
+    let arr = this.imageData.split(',')
+    arr.splice(index, 1)
+    this.imageData = arr.toString()
+  }
+
+  async upload() {
+    let scId = this.inspectionList[0].scId
+    let result: boolean = true
+    for (let i of this.inspectionList) {
+      if (i.scId !== scId) {
+        result = false
+      }
+    }
+    if (this.imgList.length !== 0) {
+      if (result === false) {
+        const toast = await this.toastCtrl.create({
+          message: '筛选出的数据scId不一致,无法上传',
+          duration: 3000,
+          position: 'top'
+        });
+        await toast.present();
+      } else {
+        let form = {
+          scId: scId,
+          files: this.imageData
+        }
+        await this.userData.inspectionUpload(form)
+      }
+    }
+  }
+
+}

+ 26 - 0
src/app/inspection/inspection.module.ts

@@ -0,0 +1,26 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { Routes, RouterModule } from '@angular/router';
+
+import { IonicModule } from '@ionic/angular';
+
+import { InspectionPage } from './inspection.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: InspectionPage
+  }
+];
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    RouterModule.forChild(routes)
+  ],
+  declarations: [InspectionPage]
+})
+export class InspectionPageModule {}

+ 24 - 0
src/app/inspection/inspection.page.html

@@ -0,0 +1,24 @@
+<ion-header>
+  <ion-toolbar>
+    <ion-buttons slot="start">
+      <ion-menu-button></ion-menu-button>
+    </ion-buttons>
+    <ion-title>陪验搜索</ion-title>
+  </ion-toolbar>
+</ion-header>
+
+<ion-content>
+  <ion-list>
+    <ion-item>
+      <ion-label>po号:</ion-label>
+      <ion-input [(ngModel)]="poCode"></ion-input>
+    </ion-item>
+    <ion-item>
+      <ion-label>sc号:</ion-label>
+      <ion-input [(ngModel)]="scCode"></ion-input>
+    </ion-item>
+  </ion-list>
+  <div class="ion-padding">
+    <ion-button color="primary" type="submit" expand="block" (click)="search(poCode,scCode)">搜 索</ion-button>
+  </div>
+</ion-content>

+ 0 - 0
src/app/inspection/inspection.page.scss


+ 27 - 0
src/app/inspection/inspection.page.spec.ts

@@ -0,0 +1,27 @@
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { InspectionPage } from './inspection.page';
+
+describe('InspectionPage', () => {
+  let component: InspectionPage;
+  let fixture: ComponentFixture<InspectionPage>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ InspectionPage ],
+      schemas: [CUSTOM_ELEMENTS_SCHEMA],
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(InspectionPage);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 19 - 0
src/app/inspection/inspection.page.ts

@@ -0,0 +1,19 @@
+import { Component, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
+
+@Component({
+  selector: 'app-inspection',
+  templateUrl: './inspection.page.html',
+  styleUrls: ['./inspection.page.scss'],
+})
+export class InspectionPage implements OnInit {
+
+  constructor(private router: Router) { }
+
+  ngOnInit() {
+  }
+
+  search(poCode, scCode) {
+    this.router.navigateByUrl(`/inspection-list/${poCode}/${scCode}`)
+  }
+}

+ 6 - 1
src/app/menu/menu.ts

@@ -51,7 +51,7 @@ export const menu_list = [
             id: 7000,
             name: '入库单列表',
             icon: 'list-box',
-            url: 'enter-store-list'
+            url: 'inspection'
         },
         {
             id: 8000,
@@ -63,6 +63,11 @@ export const menu_list = [
             name: '待抽箱',
             icon: 'timer',
             url: 'warehouse-manage-pending'
+        }, {
+            id: 12000,
+            name: '陪验申请',
+            icon: 'home',
+            url: 'inspection'
         }]
     },{
         title: 'QC',

+ 21 - 0
src/providers/user-data.ts

@@ -456,6 +456,27 @@ export class UserData {
     });
   }
 
+  // 获取陪验列表
+  async getInspectionList(poCode,scCode): Promise<any> {
+    return new Promise((resolve, reject) => {
+      console.log(`${environment.APP_SERVE_URL}/inventory/isnspection/page?poCode=${poCode}&scCode=${scCode}`)
+      this.api.request('get',`${environment.APP_SERVE_URL}/inventory/isnspection/page?poCode=${poCode}&scCode=${scCode}`,{},{}).then((data)=>{
+        resolve(data['data'].records)
+      }).catch(e => {console.log(e)})
+    });
+  }
+
+  // 陪验员上传图片
+  async inspectionUpload(form: any): Promise<any> {
+    this.nativeHttp.setDataSerializer('urlencoded');
+    return new Promise((resolve, reject) => {
+      this.api.request('post',`${environment.APP_SERVE_URL}/inventory/isnspection/mobile/picture`,form,{}).then((data)=>{
+        this.api.showToast('上传成功')
+        resolve(data)
+      }).catch(e => {console.log(e)})
+    });
+  }
+
   setUsername(username: string): Promise<any> {
     return this.storage.set('username', username);
   }