瀏覽代碼

qc验货初检报告

panxingxin 5 年之前
父節點
當前提交
9db2873351

+ 4 - 1
app.json

@@ -8,7 +8,10 @@
     "pages/sample/detail",
     "pages/contract/index",
     "pages/contract/list",
-    "pages/contract/detail"
+    "pages/contract/detail",
+    "pages/qc/index",
+    "pages/qc/list",
+    "pages/qc/detail"
   ],
   "tabBar": {
     "list": [

+ 3 - 2
menu/menu.js

@@ -1,4 +1,5 @@
 export const menuList = [
-  {name:'QA样品',url:'sample',icon:'../../resources/sample-selected.png'},
-  {name:'QA合同',url:'contract',icon:'../../resources/contract-selected.png'}
+  {name:'QA样品',url:'sample',icon:'../../resources/sample.png'},
+  {name:'QA合同',url:'contract',icon:'../../resources/contract.png'},
+  {name:'QC验货',url:'qc',icon:'../../resources/qc.png'}
 ]

+ 79 - 3
models/dataModel.js

@@ -98,7 +98,7 @@ export function addSampleQaLog(sdpId,mark) {
   })
 }
 
-// 添加qa图片
+// 添加样品单qa图片
 export function addSamplePic(form) {
   return fly.request({
     url: `/inventory/sample/qalog/upload/picture?sdpId=${sdpId}`,
@@ -107,7 +107,7 @@ export function addSamplePic(form) {
   })
 }
 
-// 删除qa图片
+// 删除样品单qa图片
 export function delSamplePic(sdpId, url) {
   return fly.request({
     url: `/inventory/sample/qalog/upload/picture?sdpId=${sdpId}&url=${url}`,
@@ -156,10 +156,86 @@ export function addContractQaLog(sscId,pId,mark) {
   })
 }
 
-// 删除qa图片
+// 添加采购合同qa图片
+export function addContractPic(form) {
+  return fly.request({
+    url: `/inventory/supplier/contract/qalog/upload/picture?sscId=${sscId}&pId=${pId}`,
+    method: 'post',
+    data: form
+  })
+}
+
+// 删除采购合同qa图片
 export function delContractPic(sscId, pId, url) {
   return fly.request({
     url: `/inventory/supplier/contract/qalog/upload/picture?sscId=${sscId}&pId=${pId}&url=${url}`,
     method: 'delete'
   })
+}
+
+// 获取QC验货列表
+export function getQcList(form) {
+  return fly.request({
+    url: '/inventory/qc/contract/list',
+    method: 'get',
+    params: form
+  })
+}
+
+// 获取QC验货详情
+export function getQcDetail(sscId, pId) {
+  return fly.request({
+    url: `/inventory/qc/${sscId}/${pId}`,
+    method: 'get'
+  })
+}
+
+// 获取QC验货qa日志
+export function getQcQaLog(sscId, pId) {
+  return fly.request({
+    url: `/inventory/qc/qclog/upload/${sscId}/${pId}`,
+    method: 'get'
+  })
+}
+
+// 修改QC验货qa日志
+export function changeQcQaLog(sscId, pId, mark) {
+  return fly.request({
+    url: `/inventory/qc/qclog/upload/picture?sscId=${sscId}&pId=${pId}&mark=${mark}`,
+    method: 'put'
+  })
+}
+
+// 添加QC验货qa日志
+export function addQcQaLog(sscId, pId, mark) {
+  return fly.request({
+    url: `/inventory/qc/qclog/upload/log?sscId=${sscId}&pId=${pId}&mark=${mark}`,
+    method: 'post'
+  })
+}
+
+// 添加qa图片
+export function addQcPic(form) {
+  // return fly.request({
+  //   url: `/inventory/sample/qalog/upload/picture?sdpId=${sdpId}`,
+  //   method: 'post',
+  //   data: form
+  // })
+}
+
+// 删除qa图片
+export function delQcPic(sscId, pId, url) {
+  return fly.request({
+    url: `/inventory/qc/qclog/upload/picture?sscId=${sscId}&pId=${pId}&url=${url}`,
+    method: 'delete'
+  })
+}
+
+// 生成QC验货初检报告
+export function generateQcReport(form) {
+  return fly.request({
+    url: '/inventory/qc/qcRepost',
+    method: 'post',
+    body: form
+  })
 }

+ 1 - 1
pages/contract/list.wxml

@@ -1,4 +1,4 @@
-<view class="list" hidden="{{showResult}}" wx:for="{{contractList}}" wx:key="index" data-sscid="{{item.sscId}}" data-pid="{{item.pid}}" bindtap="getDetail">
+<view class="list" wx:for="{{contractList}}" wx:key="index" data-sscid="{{item.sscId}}" data-pid="{{item.pid}}" bindtap="getDetail">
 	<view class="list-item">
 		<label>采购合同号:</label>
 		<input value="{{item.sscCode}}" disabled/>

+ 7 - 7
pages/home/home.js

@@ -17,12 +17,13 @@ Page({
       requestAPI.getMenu().then(res=>{
         let tempList = []
         if(res&&res.data&&res.data.data) {
-          for(let i of res.data.data) {
-            let filterList = menuList.filter(item => {
-              return item.name === i.name
-            })
-            tempList = tempList.concat(filterList)
-          }
+          // for(let i of res.data.data) {
+            // let filterList = menuList.filter(item => {
+            //   return item.name === i.name
+            // })
+            // tempList = tempList.concat(filterList)
+          // }
+          tempList = menuList
           this.setData({
             menuList: tempList,
             isLogin: true
@@ -33,7 +34,6 @@ Page({
   },
 
   getLink: function(event) {
-    console.log(event.currentTarget.dataset.item)
     wx.navigateTo({
       url: `/pages/${event.currentTarget.dataset.item.url}/index`,
     })

+ 155 - 0
pages/qc/detail.js

@@ -0,0 +1,155 @@
+import * as requestAPI from '../../models/dataModel'
+Page({
+  data: {
+    qcDetail: {},
+    mark: '',
+    tempMark: '',
+    sscId: '',
+    pId: '',
+    imageList: [],
+    showAllPic: false,
+    allImgList: []
+  },
+
+  onLoad: function (options) {
+    this.setData({
+      sscId: options.sscId,
+      pId: options.pId
+    })
+    this.getDetail(options.sscId, options.pId)
+    this.getQaLog(options.sscId, options.pId)
+  },
+
+  // 获取采购合同详情
+  getDetail(sscId, pId) {
+    requestAPI.getQcDetail(sscId, pId).then(res => {
+      this.setData({
+        qcDetail: res.data.data
+      })
+    })
+  },
+
+  // 获取qa日志
+  getQaLog(sscId, pId) {
+    requestAPI.getQcQaLog(sscId, pId).then(res => {
+      let allImgList = [] // 全部图片
+      let lessImgList = [] // 部分图片
+      if (res.data.data.length !== 0) {
+        this.setData({
+          mark: res.data.data[0].mark
+        })
+        if(res.data.data[0].picture) {
+          allImgList = res.data.data[0].picture.split(',')
+          for(let i = 0;i<res.data.data[0].picture.split(',').length&&i<2;i++) {
+            lessImgList.push(res.data.data[0].picture.split(',')[i])
+          }
+          this.setData({
+            allImgList: allImgList
+          })
+          this.setData({
+            imageList: this.data.showAllPic?allImgList:lessImgList
+          })
+        }
+      }
+    })
+  },
+
+  getAllImg() {
+    this.setData({
+      showAllPic: true
+    })
+    this.getQaLog(this.data.sscId, this.data.pId)
+  },
+
+  getTempMark(e) {
+    this.setData({
+      tempMark: e.detail.value
+    })
+  },
+
+  // 保存或添加qa日志
+  saveQaLog(e) {
+    this.setData({
+      mark: e.detail.value
+    })
+    if (this.data.mark !== this.data.tempMark) {
+      if (this.data.tempMark) {
+        requestAPI.changeQcQaLog(this.data.sscId, this.data.pId, this.data.mark).then(res => {
+          if (res.data.code === 0) {
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+              duration: 3000
+            })
+            setTimeout(() => {
+              this.getQaLog(this.data.sscId, this.data.pId)
+            }, 500)
+          }
+        })
+      } else {
+        requestAPI.addQcQaLog(this.data.sscId, this.data.pId, this.data.mark).then(res => {
+          if (res.data.code === 0) {
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+              duration: 3000
+            })
+            setTimeout(() => {
+              this.getQaLog(this.data.sscId, this.data.pId)
+            }, 500)
+          }
+        })
+      }
+    }
+  },
+
+  // 拍照
+  takePhoto() {
+    this.getPhotos(1, 'camera')
+  },
+  choosePhoto() {
+    this.getPhotos(9, 'albumn')
+  },
+  getPhotos(count, type) {
+    let _this = this
+    wx.chooseImage({
+      count: count,
+      sizeType: ['original', 'compressed'],
+      sourceType: [type],
+      success(res) {
+        for (let i of res.tempFilePaths) {
+          wx.uploadFile({
+            url: `http://192.168.20.52:9999/inventory/qc/qclog/upload/picture?sscId=${_this.data.sscId}&pId=${_this.data.pId}`, //此处换上你的接口地址 
+            filePath: i,
+            name: 'file',
+            header: {
+              "Content-Type": "multipart/form-data",
+              'Authorization': `Bearer ${wx.getStorageSync('token')}`,
+            },
+            success: function (res) {
+              wx.showToast({
+                title: '上传成功',
+                icon: 'success',
+                duration: 2000
+                })
+              _this.getQaLog(_this.data.sscId, _this.data.pId)
+            }
+          })
+        }
+      }
+    })
+  },
+  // 删除qa图片
+  delImg: function (event) {
+    requestAPI.delQcPic(this.data.sscId, this.data.pId, event.currentTarget.dataset.url).then(res=>{
+      this.getQaLog(this.data.sscId, this.data.pId)
+    })
+  },
+  // 图片预览
+  openPreview: function (event) {
+    wx.previewImage({
+      urls: this.data.imageList,
+      current: event.currentTarget.dataset.current
+    })
+  }
+})

+ 6 - 0
pages/qc/detail.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "mp-icon": "../../components/icon/icon"
+  },
+  "navigationBarTitleText": "QC验货详情"
+}

+ 34 - 0
pages/qc/detail.wxml

@@ -0,0 +1,34 @@
+<view class="detail">
+	<view class="detail-item">
+		<label>我司货号:</label>
+		<input value="{{qcDetail.pcode}}" disabled />
+	</view>
+	<view class="detail-item">
+		<label>客户货号:</label>
+		<input value="{{qcDetail.scpCustomercode}}" disabled />
+	</view>
+	<view class="detail-item">
+		<label>中文品名:</label>
+		<input value="{{qcDetail.scpCnname}}" disabled />
+	</view>
+	<view class="detail-item">
+		<label>Qa日志:</label>
+		<textarea value="{{mark}}" auto-height bindfocus="getTempMark" bindblur="saveQaLog" />
+		</view>
+	<view class="detail-item">
+		<label>图片:</label>
+		<view class="imageList">
+			<view class="image-item" wx:for="{{imageList}}" wx:key="index">
+				<icon type="cancel" size="10" bindtap="delImg" data-index="{{index}}" data-url="{{item}}"/>
+				<image src="{{item}}" mode="scaleToFill" bindtap="openPreview" data-current="{{item}}"></image>
+			</view>
+			<text bindtap="getAllImg" hidden="{{showAllPic||allImgList.length<=2}}">查看更多</text>
+		</view>
+	</view>
+	<view class="detail-btns">
+		<view>
+			<mp-icon icon="camera" color="black" size="{{25}}" bindtap="takePhoto"></mp-icon>
+			<mp-icon icon="album" color="black" size="{{25}}" bindtap="choosePhoto"></mp-icon>
+		</view>
+	</view>
+</view>

+ 47 - 0
pages/qc/detail.wxss

@@ -0,0 +1,47 @@
+page{
+  background-color: #ebebeb;
+}
+.detail {
+  border-radius: 0.5rem;
+  background-color: #fff;
+  margin: 0.2rem;
+}
+.detail-item {
+  display: flex;
+  padding: 0.4rem 1rem;
+}
+.detail-item label {
+  width: 5rem;
+  margin-right: 2rem;
+}
+.detail-item .imageList{
+  display: flex;
+  width: 100%;
+  flex-wrap: wrap;
+  align-items: center;
+}
+.detail-item .imageList .image-item{
+  display: flex;
+  flex-direction: column;
+}
+.detail-item .imageList image {
+  height: 4rem;
+  width: 4rem;
+  margin-right: 5px;
+}
+.detail-item .imageList text {
+  font-size: 14px;
+  text-decoration: underline;
+  color: green;
+  margin-left: 1rem;
+}
+.detail-btns {
+  display: flex;
+  justify-content: center;
+  padding: 0.5rem;
+}
+.detail-btns view{
+  display: flex;
+  width: 8rem;
+  justify-content: space-between;
+}

+ 33 - 0
pages/qc/index.js

@@ -0,0 +1,33 @@
+Page({
+  data: {
+    warehoseIndex: 1,
+    warehoseStatus: 2,
+    warehoseArray: [{id:1, name:'未抽'},
+     {id: 2, name: '已抽'}],
+     pCode: '',
+     sscCode: ''
+  },
+  onLoad: function (options) {
+  },
+  bindPickerChange: function(e) {
+    this.setData({
+      warehoseIndex: e.detail.value,
+      warehoseStatus: this.data.warehoseArray[e.detail.value].id
+    })
+  },
+  bindpCodeInput: function (e) {
+    this.setData({
+      pCode: e.detail.value
+    })
+  },
+  bindSScCodeInput: function (e) {
+    this.setData({
+      sscCode: e.detail.value
+    })
+  },
+  search() {
+    wx.navigateTo({
+      url: `/pages/qc/list?sscCode=${this.data.sscCode}&pCode=${this.data.pCode}&warehoseStatus=${this.data.warehoseStatus}`,
+    })
+  }
+})

+ 3 - 0
pages/qc/index.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 23 - 0
pages/qc/index.wxml

@@ -0,0 +1,23 @@
+<view>
+	<view class="inputView">
+		<label class="inputLabel">采购合同号:</label>
+		<input class="inputText" focus placeholder="请输入采购合同号" bindinput="bindSScCodeInput" />
+	</view>
+
+	<view class="inputView">
+		<label class="inputLabel">我司货号:</label>
+		<input class="inputText" placeholder="请输入我司货号" bindinput="bindpCodeInput" />
+	</view>
+
+	<view class="inputView">
+		<label class="inputLabel">抽箱状态:</label>
+		<picker bindchange="bindPickerChange" value="{{warehoseIndex}}" range="{{warehoseArray}}" range-key="name">
+			<view class="picker">
+				{{warehoseArray[warehoseIndex].name}}
+			</view>
+		</picker>
+	</view>
+	<view class="btnView">
+		<button type="primary" bindtap="search">搜索</button>
+	</view>
+</view>

+ 4 - 0
pages/qc/index.wxss

@@ -0,0 +1,4 @@
+picker {
+  margin-top: 1rem;
+  width: 60%;
+}

+ 134 - 0
pages/qc/list.js

@@ -0,0 +1,134 @@
+import * as requestAPI from '../../models/dataModel'
+Page({
+  data: {
+    qcList: [],
+    sscCode: '',
+    pCode: '',
+    current: 1,
+    size: 5,
+    total: 0,
+    selectQCList: []
+  },
+  onLoad: function (options) {
+    this.setData({
+      pCode: options?options.pCode:this.data.pCode,
+      sscCode: options?options.sscCode:this.data.sscCode
+    })
+  },
+  onReady() {
+    this.getQcList()
+  },
+  onUnload() {
+    if(this.getRecordSelectList().length>0) {
+      wx.setStorageSync('selectQcList', JSON.stringify(this.getRecordSelectList()))
+    }
+  },
+  // 获取样品单列表
+  getQcList() {
+    wx.showLoading({title: '加载中', icon: 'loading'});
+    let form = {
+      current: this.data.current,
+      size: this.data.size,
+      sscCode: this.data.sscCode,
+      pCode: this.data.pCode
+    }
+    requestAPI.getQcList(form).then(res => {
+      for (let i =0; i<res.data.data.records.length;i++) {
+        if(wx.getStorageSync('selectQcList')&&JSON.parse(wx.getStorageSync('selectQcList')).length!==0){
+          let selectList = JSON.parse(wx.getStorageSync('selectQcList'))
+          let filterList = selectList.filter(item=>{return item.pid == res.data.data.records[i].pid&&item.sscId== res.data.data.records[i].sscId})
+          if(filterList.length !== 0) {
+            res.data.data.records.splice(i, 1)
+            break
+            // 搜索全部list有则在全部list里删除
+          } 
+        }
+        res.data.data.records[i].checked = false
+        res.data.data.records[i].productImgUrl = res.data.data.records[i].pictures[0].bigPicture
+      }
+      // 合并已选择的list和全部list
+      if(wx.getStorageSync('selectQcList')&&JSON.parse(wx.getStorageSync('selectQcList')).length!==0){
+        res.data.data.records = JSON.parse(wx.getStorageSync('selectQcList')).concat(res.data.data.records)
+      }
+      this.setData({
+        qcList: res.data.data.records,
+        total: res.data.data.total
+      })
+    })
+  },
+
+  // 获取样品单详情
+  getDetail: function (event) {
+    wx.navigateTo({
+      url: `/pages/qc/detail?sscId=${event.currentTarget.dataset.sscid}&pId=${event.currentTarget.dataset.pid}`,
+    })
+  },
+
+  selectList:function(e) {
+    let tempList = this.data.qcList
+    tempList[e.currentTarget.dataset.index].checked = !tempList[e.currentTarget.dataset.index].checked
+    this.setData({
+      qcList: tempList
+    })
+  },
+
+  // 记录已选择的列
+  getRecordSelectList() {
+    let tempList = []
+    for(let i of this.data.qcList) {
+      if(i.checked) {
+        tempList.push(i)
+      }
+    }
+    return tempList
+  },
+
+  // 下拉刷新
+  onPullDownRefresh: function () {
+    wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画
+    this.onLoad(); //刷新页面
+    setTimeout(function () {
+      wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画
+      wx.stopPullDownRefresh(); //停止下拉动作
+    }, 2000)
+  },
+
+  // 下拉加载
+  onReachBottom: function () {
+    if (this.data.size > this.data.total) {
+      return;
+    } else {
+      this.getQcList();
+      this.setData({
+        size: this.data.size+10
+      })
+    }
+  },
+
+  openPreview: function (event) {
+    wx.previewImage({
+      urls: new Array(event.currentTarget.dataset.url),
+    })
+  },
+
+  // 生成QC验货初检报告
+  generate() {
+    let tempList = []
+    for(let i of this.data.qcList) {
+      if(i.checked) {
+        tempList.push(i)
+      }
+    }
+    requestAPI.generateQcReport(tempList).then(res=>{
+      wx.showToast({
+        title: `生成报告${res.data.data}`,
+        icon: 'success',
+        duration: 3000
+      })
+      wx.removeStorageSync('selectQcList')
+      setTimeout(() => {
+        this.getQcList()
+      }, 500); 
+    })
+  }
+})

+ 3 - 0
pages/qc/list.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 22 - 0
pages/qc/list.wxml

@@ -0,0 +1,22 @@
+<view class="list" wx:for="{{qcList}}" wx:key="index" data-sscid="{{item.sscId}}" data-pid="{{item.pid}}" bindtap="getDetail">
+	<view class="list-item">
+		<label>采购合同号:</label>
+		<input value="{{item.sscCode}}" disabled/>
+		<checkbox catchtap="selectList" data-index="{{index}}" checked="{{item.checked}}"></checkbox>
+	</view>
+	<view class="list-item">
+		<label>我司货号:</label>
+		<input value="{{item.pcode}}" disabled/>
+	</view>
+	<view class="list-item">
+		<label>中文品名:</label>
+		<input value="{{item.scpCnname}}" disabled/>
+	</view>
+	<view class="list-item">
+		<label>图片:</label>
+		<image src="{{item.productImgUrl}}" mode="widthFix" catchtap="openPreview" data-url="{{item.productImgUrl}}"></image>
+	</view>
+</view>
+<view class="generateBtnView">
+  <button class="generateBtn" type="primary" bindtap="generate">生成QC验货初检报告</button>
+</view>

+ 26 - 0
pages/qc/list.wxss

@@ -0,0 +1,26 @@
+page{
+  background-color: #ebebeb;
+}
+.list {
+  border-radius: 0.5rem;
+  background-color: #fff;
+  margin: 0.2rem;
+}
+.list-item {
+  display: flex;
+  padding: 0.4rem 1rem;
+}
+.list-item label {
+  width: 6rem;
+  margin-right: 2rem;
+}
+.list-item image {
+  width: 6rem;
+}
+.generateBtnView button{
+  width: 90% !important;
+  position: fixed;
+  bottom: 0.1rem;
+  left: 5%;
+  z-index: 10;
+}

+ 1 - 1
pages/sample/index.wxml

@@ -1,4 +1,4 @@
-<view class="sample-search">
+<view>
 	<view class="inputView">
 		<label class="inputLabel">样品单号:</label>
 		<input class="inputText" focus placeholder="请输入样品单号" bindinput="bindDocumentInput"/>

+ 1 - 1
pages/sample/list.wxml

@@ -1,4 +1,4 @@
-<view class="list" hidden="{{showResult}}" wx:for="{{sampleList}}" wx:key="index" data-id="{{item.sdpId}}" bindtap="getDetail">
+<view class="list" wx:for="{{sampleList}}" wx:key="index" data-id="{{item.sdpId}}" bindtap="getDetail">
 	<view class="list-item">
 		<label>样品单号:</label>
 		<input value="{{item.sdDocument}}" disabled/>

二進制
resources/contract-selected.png


二進制
resources/contract.png


二進制
resources/qc.png


二進制
resources/sample-selected.png


二進制
resources/sample.png