Sfoglia il codice sorgente

更新user-data,待备样等部分下拉刷新

panxingxin 5 anni fa
parent
commit
de95f5f653

+ 9 - 9
src/app/contract-detail/contract-detail.page.ts

@@ -35,22 +35,22 @@ export class ContractDetailPage implements OnInit {
       if (val) {
         this.sscId = val
         let data = await this.userData.getContractDetail(val)
-        if (JSON.parse(data).data.length !== 0) {
-          this.sscCode = JSON.parse(data).data[0].scbCode
-          this.scpModifiedtime = JSON.parse(data).data[0].scpModifiedtime
-          this.contractDetailList = JSON.parse(data).data
+        if (data.data.length !== 0) {
+          this.sscCode = data.data[0].scbCode
+          this.scpModifiedtime = data.data[0].scpModifiedtime
+          this.contractDetailList = data.data
           for (let i of this.contractDetailList) {
             i.imgList = [] // 初始化图片列表
             i['qaIdList'] = []
             i.imgsrc = i.pictures[0].smallPicture
             let qadata = await this.userData.getQAlog(val, i.pid)
-            if (JSON.parse(qadata).data.length !== 0) {
-              for (let j of JSON.parse(qadata).data) {
+            if (qadata.data.length !== 0) {
+              for (let j of qadata.data) {
                 i['qaIdList'].push(j.id) // qa记录的id数组
               }
-              i.qalog = JSON.parse(qadata).data[0].mark
-              i.imgList = JSON.parse(qadata).data[0].picture.split(",")
-              i.imageData = JSON.parse(qadata).data[0].picture
+              i.qalog = qadata.data[0].mark
+              i.imgList = qadata.data[0].picture.split(",")
+              i.imageData = qadata.data[0].picture
             }
           }
         }

+ 1 - 1
src/app/enter-store-list/enter-store-list.page.html

@@ -3,7 +3,7 @@
     <ion-buttons slot="start">
       <ion-menu-button></ion-menu-button>
     </ion-buttons>
-    <ion-title>入库单</ion-title>
+    <ion-title>入库单列表</ion-title>
   </ion-toolbar>
 </ion-header>
 

+ 1 - 2
src/app/enter-store/enter-store.page.ts

@@ -110,7 +110,6 @@ export class EnterStorePage implements OnInit {
     if (item) {
       this.scanCode = item.scanCode
       this.storeDetailList = new Array(item)
-      console.log(item)
     } else {
       if (this.scanCode.split('_').length === 2) {
         let filterData = []
@@ -119,7 +118,7 @@ export class EnterStorePage implements OnInit {
           this.storeDetailList = filterData
         } else {
           let data = await this.userData.getStoreDetail(Number(this.scanCode.split('_')[0]), Number(this.scanCode.split('_')[1]))
-          this.storeDetailList = new Array(JSON.parse(data).data)
+          this.storeDetailList = new Array(data.data)
         }
       }
     }

+ 9 - 9
src/app/sample-detail/sample-detail.page.ts

@@ -43,23 +43,23 @@ export class SampleDetailPage implements OnInit {
     this.storage.get('sdId').then(async (val) => {
       if (val) {
         let data = await this.userData.getSampleDetail(val)
-        if (JSON.parse(data).data.length !== 0) {
-          this.sdpPost = JSON.parse(data).data[0].sdpPost
-          this.sdpModifydate = JSON.parse(data).data[0].sdpModifydate
-          this.sampleDetailList = JSON.parse(data).data
+        if (data.data.length !== 0) {
+          this.sdpPost = data.data[0].sdpPost
+          this.sdpModifydate = data.data[0].sdpModifydate
+          this.sampleDetailList = data.data
           for (let i of this.sampleDetailList) {
             i.imgList = [] // 初始化图片列表
             i['qaIdList'] = []
             i.imgsrc = i.pictures[0].smallPicture
             let qadata = await this.userData.getSampleQAlog(i.sdpId)
-            if (JSON.parse(qadata).data.length !== 0) {
-              for (let j of JSON.parse(qadata).data) {
+            if (qadata.data.length !== 0) {
+              for (let j of qadata.data) {
                 i['qaIdList'].push(j.id) // qa记录的id数组
               }
-              i.qalog = JSON.parse(qadata).data[0].mark
+              i.qalog = qadata.data[0].mark
               // i.imgUrl = JSON.parse(data).data[0].picture.split(",")[0]
-              i.imgList = JSON.parse(qadata).data[0].picture.split(",")
-              i.imageData = JSON.parse(qadata).data[0].picture
+              i.imgList = qadata.data[0].picture.split(",")
+              i.imageData = qadata.data[0].picture
             }
           }
         }

+ 0 - 25
src/app/store-pending/store-pending.page.ts

@@ -50,32 +50,7 @@ export class StorePendingPage implements OnInit {
 
   // 获取扫描详情
   async getStoreQCDetail(pending) {
-    // this.storage.set('store-pending', pending).then(() => {
       this.router.navigateByUrl(`/store-qc-scanning/${pending.sscId}/${pending.pid}`)
-    // })
-    // let data = await this.userData.getQCDetail(pending.sscId, pending.pId)
-
-    // this.storeQCDetailList = new Array(data)
-
-    // for (let i of this.storeQCDetailList) {
-    //   // 获取QA日志
-    //   let qalogdata = await this.userData.getQAlog(i.sscId, i.pid)
-    //   if (JSON.parse(qalogdata).data.length !== 0) {
-    //     i.qalog = JSON.parse(qalogdata).data[0].mark
-    //     i.qaimgUrl = JSON.parse(qalogdata).data[0].picture.split(",")[0]
-    //   }
-    //   let qclogdata = await this.userData.getQClog(i.sscId, i.pid)
-    //   if (JSON.parse(qclogdata).data.length !== 0) {
-    //     i.qclog = JSON.parse(qclogdata).data[0].mark
-    //     i.qcimgUrl = JSON.parse(qclogdata).data[0].picture.split(",")[0]
-    //   }
-    //   // 处理意见转换boolean
-    //   if (i.dealpropose == 1) {
-    //     i.deal = true
-    //   } else {
-    //     i.deal = false
-    //   }
-    // }
   }
   async rejectSample(pending) {
     await this.userData.rejectSample(pending.sscId,pending.pid)

+ 5 - 5
src/app/store-qc-detail/store-qc-detail.page.ts

@@ -78,13 +78,13 @@ export class StoreQCDetailPage implements OnInit {
           i.qaimgList = JSON.parse(qalogdata).data[0].picture.split(",")
         }
         let qclogdata = await this.userData.getQClog(i.sscId, i.pid)
-        if (JSON.parse(qclogdata).data.length !== 0) {
-          for (let j of JSON.parse(qclogdata).data) {
+        if (qclogdata.data.length !== 0) {
+          for (let j of qclogdata.data) {
             i['qcIdList'].push(j.id) // qc记录的id数组
           }
-          i.qclog = JSON.parse(qclogdata).data[0].mark
-          i.qcimgList = JSON.parse(qclogdata).data[0].picture.split(",")
-          i.imageData = JSON.parse(qclogdata).data[0].picture
+          i.qclog = qclogdata.data[0].mark
+          i.qcimgList = qclogdata.data[0].picture.split(",")
+          i.imageData = qclogdata.data[0].picture
         }
         // 处理意见转换boolean
         if (i.dealpropose == 1) {

+ 5 - 6
src/app/store-qc-scanning/store-qc-scanning.page.ts

@@ -112,16 +112,15 @@ export class StoreQCScanningPage implements OnInit {
             i.qaimgList = JSON.parse(qalogdata).data[0].picture.split(",")
           }
           let qclogdata = await this.userData.getQClog(i.sscId, i.pid)
-          if (JSON.parse(qclogdata).data.length !== 0) {
-            for (let j of JSON.parse(qclogdata).data) {
+          if (qclogdata.data.length !== 0) {
+            for (let j of qclogdata.data) {
               i['qcIdList'].push(j.id) // qc记录的id数组
             }
-            i.qclog = JSON.parse(qclogdata).data[0].mark
-            i.qcimgList = JSON.parse(qclogdata).data[0].picture.split(",")
+            i.qclog = qclogdata.data[0].mark
+            i.qcimgList = qclogdata.data[0].picture.split(",")
             if (!i.imageData) {
-              i.imageData = JSON.parse(qclogdata).data[0].picture
+              i.imageData = qclogdata.data[0].picture
             }
-            // i.qcimgUrl = JSON.parse(qclogdata).data[0].picture.split(",")[0]
           }
           // 处理意见转换boolean(无deal)
 

+ 4 - 2
src/app/store-qc/store-qc.page.ts

@@ -14,6 +14,7 @@ export class StoreQCPage implements OnInit {
   current: number = 1
   size: number = 10
   form = {}
+  total = 0
   constructor(public userData: UserData, private storage: Storage, private router: Router ) { }
 
   ngOnInit() {
@@ -33,7 +34,8 @@ export class StoreQCPage implements OnInit {
     this.form['current'] = this.current
     this.form['size'] = this.size
     let data = await this.userData.getQCList(this.form)
-    this.qcList = data
+    this.qcList = data.data.records
+    this.total = data.data.total
   }
 
   async doRefresh(event) {
@@ -54,7 +56,7 @@ export class StoreQCPage implements OnInit {
     this.size += 10
     this.getList()
     event.target.complete();
-    if (this.qcList.length < this.size) {
+    if (this.total < this.size) {
       event.target.disabled = true;
     }
   }

+ 5 - 3
src/app/store-sample-pending/store-sample-pending.page.ts

@@ -14,6 +14,7 @@ export class StoreSamplePendingPage implements OnInit {
   storeSampleLists = []
   current: number = 1
   size: number = 10
+  total = 0
   constructor(
     private keyboard: Keyboard,
     private barcodeScanner: BarcodeScanner,
@@ -35,7 +36,8 @@ export class StoreSamplePendingPage implements OnInit {
 
   async getList() {
     let data = await this.userData.getStoreSamplePendingList(this.current, this.size)
-    this.storeSampleLists = data
+    this.total = data.data.total
+    this.storeSampleLists = data.data.records
     for (let i of this.storeSampleLists) {
       i['lendName'] = i.lend ? '已借出' : '未借出'
       i['statusName'] = i.active ? '正常' : '已销毁'
@@ -53,7 +55,7 @@ export class StoreSamplePendingPage implements OnInit {
     this.size += 10
     this.getList()
     event.target.complete();
-    if (this.storeSampleLists.length < this.size) {
+    if (this.total < this.size) {
       event.target.disabled = true;
     }
   }
@@ -62,7 +64,7 @@ export class StoreSamplePendingPage implements OnInit {
   async getStoreSampleDetail() {
     this.keyboard.hide()
     let data = await this.userData.getStoreSampleDetail(this.scanCode)
-    let code = JSON.parse(data).data.code
+    let code = data.data.code
     await this.userData.changeShelfLend(code)
     this.getList();
   }

+ 2 - 2
src/app/store-sample/store-sample.page.html

@@ -28,12 +28,12 @@
           <ion-item>
             <ion-icon name="briefcase"></ion-icon>
             <ion-label>货架:</ion-label>
-            <ion-input [(ngModel)]='storeSample.shelves'></ion-input>
+            <ion-input [(ngModel)]='storeSample.shelves' readonly></ion-input>
           </ion-item>
           <ion-item>
             <ion-icon name="square"></ion-icon>
             <ion-label>货号:</ion-label>
-            <ion-input [(ngModel)]='storeSample.code'></ion-input>
+            <ion-input [(ngModel)]='storeSample.code' readonly></ion-input>
           </ion-item>
           <ion-item>
             <ion-icon name="checkbox-outline"></ion-icon>

+ 5 - 5
src/app/store-sample/store-sample.page.ts

@@ -25,10 +25,10 @@ export class StoreSamplePage implements OnInit {
   }]
   public code = ''
   size: number = 10
+  total = 0
   constructor(public userData: UserData, public commonService: commonService, private router: Router, private storage: Storage) { }
 
   ngOnInit() {
-
   }
 
   ionViewDidEnter() {
@@ -63,7 +63,6 @@ export class StoreSamplePage implements OnInit {
       } else {
         this.getList()
       }
-
     }
   }
 
@@ -74,7 +73,7 @@ export class StoreSamplePage implements OnInit {
       this.size += 10
       await this.getList()
       event.target.complete();
-      if (this.storeSampleList.length < this.size) {
+      if (this.total < this.size) {
         event.target.disabled = true;
       }
     }
@@ -82,8 +81,9 @@ export class StoreSamplePage implements OnInit {
 
   async getList() {
     let data = await this.userData.getStoreSampleList(this.size)
-    this.getCnName(data)
-    this.storeSampleList = data
+    this.getCnName(data.data.records)
+    this.storeSampleList = data.data.records
+    this.total = data.data.total
   }
 
   getCnName(data) {

+ 0 - 6
src/app/warehouse-manage-pending/warehouse-manage-pending.page.html

@@ -17,12 +17,6 @@
     </ion-refresher-content>
   </ion-refresher>
 
-<!--  <ion-item>-->
-<!--    <ion-label>样品扫描:</ion-label>-->
-<!--    <ion-input #scanInput clear-on-edit (ionChange)="getStoreSampleDetail()" [(ngModel)]="scanCode"></ion-input>-->
-<!--  </ion-item>-->
-
-
   <ion-card *ngFor="let warehouseManage of warehouseManageLists">
 
     <ion-card-content class="storeSample-content">

+ 4 - 2
src/app/warehouse-manage-pending/warehouse-manage-pending.page.ts

@@ -17,6 +17,7 @@ export class WarehouseManagePendingPage implements OnInit {
     public commonService: commonService,
     public userData: UserData) { }
   scanCode: string;
+  total = 0
   pId = ''
   sscId = ''
   ngOnInit() {
@@ -40,14 +41,15 @@ export class WarehouseManagePendingPage implements OnInit {
     this.size += 10
     this.getList()
     event.target.complete();
-    if (this.warehouseManageLists.length < this.size) {
+    if (this.total< this.size) {
       event.target.disabled = true;
     }
   }
 
   async getList() {
     const data = await this.userData.getWarehouseManagePendingList(this.current, this.size);
-    this.warehouseManageLists = data;
+    this.warehouseManageLists = data.data.records;
+    this.total = data.data.total
     for (const i of this.warehouseManageLists) {
       i.lendName = i.lend ? '已借出' : '未借出';
       i.statusName = i.active ? '正常' : '已销毁';

+ 73 - 0
src/providers/api.ts

@@ -0,0 +1,73 @@
+import { Injectable } from '@angular/core';
+import { HTTP } from '@ionic-native/http/ngx';
+import { finalize } from 'rxjs/operators';
+import { Events, LoadingController, ToastController } from '@ionic/angular';
+import { from } from 'rxjs';
+import errorCode from './errorCode'
+import { Router } from '@angular/router';
+import { Storage } from '@ionic/storage';
+
+@Injectable({
+    providedIn: 'root'
+})
+export class api {
+    constructor(private nativeHttp: HTTP,
+        private router: Router,
+        public events: Events,
+        private toastCtrl: ToastController,
+        public storage: Storage,
+        private loadingCtrl: LoadingController) {
+    }
+
+    async request(method, url, data, header, type?) {
+        let token = await this.getToken()
+        if (!header.Authorization) {
+            header.Authorization = `Bearer ${token}`
+        }
+        const loading = await this.loadingCtrl.create();
+        await loading.present();
+        return new Promise((resolve, reject) => {
+            this.nativeHttp.setDataSerializer(type ? type : 'json')
+            from(this.nativeHttp[method](url, data, header)).pipe(finalize(() => loading.dismiss())
+            ).subscribe(async res => {
+                const status = Number(res['status']) || 200
+                const message = JSON.parse(res['data']).msg || errorCode[status] || errorCode['default']
+                if (status === 401) {
+                    this.router.navigateByUrl('login')
+                    this.events.publish('user:logout')
+                }
+                if (status !== 200 || JSON.parse(res['data']).code === 1) {
+                    this.showToast(message)
+                    reject()
+                }
+                resolve(JSON.parse(res['data']))
+            }, async err => {
+                let status = Number(err.status)
+                let message = JSON.parse(err.error).msg || errorCode[err.status] || errorCode['default']
+                if (status === 401) {
+                    this.router.navigateByUrl('login')
+                    this.events.publish('user:logout')
+                }
+                this.showToast(message)
+                reject(err)
+            })
+        })
+    }
+    getToken(): Promise<any> {
+        return this.storage.get('access_token').then((val) => {
+            return val;
+        });
+    }
+    setDataSerializer(type) {
+        this.nativeHttp.setDataSerializer(type);
+    }
+
+    async showToast(message) {
+        const toast = await this.toastCtrl.create({
+            message: message,
+            duration: 3000,
+            position: 'top'
+        });
+        await toast.present();
+    }
+}

+ 14 - 0
src/providers/errorCode.ts

@@ -0,0 +1,14 @@
+export default {
+    '000': '操作太频繁,请勿重复请求',
+    '401': '当前操作没有权限',
+    '403': '当前操作没有权限',
+    '404': '资源不存在',
+    '417': '未绑定登录账号,请使用密码登录后绑定',
+    '423': '演示环境不能操作,如需了解联系冷冷',
+    '426': '用户名不存在或密码错误',
+    '428': '验证码错误,请重新输入',
+    '429': '请求过频繁',
+    '479': '演示环境,没有权限操作',
+    'default': '系统未知错误,请反馈给管理员'
+  }
+  

File diff suppressed because it is too large
+ 149 - 1169
src/providers/user-data.ts