|
@@ -0,0 +1,139 @@
|
|
|
|
+import * as requestAPI from '../../models/dataModel'
|
|
|
|
+Page({
|
|
|
|
+ data: {
|
|
|
|
+ sampleDetail: {},
|
|
|
|
+ mark: '',
|
|
|
|
+ tempMark: '',
|
|
|
|
+ sdpId: '',
|
|
|
|
+ imageList: []
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ onLoad: function (options) {
|
|
|
|
+ this.setData({
|
|
|
|
+ sdpId: options.sdpId
|
|
|
|
+ })
|
|
|
|
+ this.getDetail(options.sdpId)
|
|
|
|
+ this.getQaLog(options.sdpId)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 获取样品单详情
|
|
|
|
+ getDetail(sdpId) {
|
|
|
|
+ requestAPI.getSampleDetail(sdpId).then(res => {
|
|
|
|
+ this.setData({
|
|
|
|
+ sampleDetail: res.data.data
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 获取qa日志
|
|
|
|
+ getQaLog(sdpId) {
|
|
|
|
+ requestAPI.getSampleQaLog(sdpId).then(res => {
|
|
|
|
+ if (res.data.data.length !== 0) {
|
|
|
|
+ this.setData({
|
|
|
|
+ mark: res.data.data[0].mark
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ 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.changeSampleQaLog(this.data.sdpId, this.data.mark).then(res => {
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '保存成功',
|
|
|
|
+ icon: 'success',
|
|
|
|
+ duration: 3000
|
|
|
|
+ })
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.getQaLog(this.data.sdpId)
|
|
|
|
+ }, 500)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ requestAPI.addSampleQaLog(this.data.sdpId, this.data.mark).then(res => {
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '保存成功',
|
|
|
|
+ icon: 'success',
|
|
|
|
+ duration: 3000
|
|
|
|
+ })
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.getQaLog(this.data.sdpId)
|
|
|
|
+ }, 500)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 拍照
|
|
|
|
+ takePhoto() {
|
|
|
|
+ this.getPhotos(1, 'camera')
|
|
|
|
+ },
|
|
|
|
+ choosePhoto() {
|
|
|
|
+ this.getPhotos(9, 'albumn')
|
|
|
|
+ },
|
|
|
|
+ getPhotos(count, type) {
|
|
|
|
+ let tempList = this.data.imageList
|
|
|
|
+ let _this = this
|
|
|
|
+ wx.chooseImage({
|
|
|
|
+ count: count,
|
|
|
|
+ sizeType: ['original', 'compressed'],
|
|
|
|
+ sourceType: [type],
|
|
|
|
+ success(res) {
|
|
|
|
+ for (let i of res.tempFilePaths) {
|
|
|
|
+ console.log(i)
|
|
|
|
+ wx.uploadFile({
|
|
|
|
+ url: `http://192.168.20.111:9999/inventory/sample/qalog/upload/picture?sdpId=${_this.data.sdpId}`, //此处换上你的接口地址
|
|
|
|
+ filePath: i,
|
|
|
|
+ name: 'file',
|
|
|
|
+ header: {
|
|
|
|
+ "Content-Type": "multipart/form-data",
|
|
|
|
+ 'Authorization': `Bearer ${wx.getStorageSync('token')}`,
|
|
|
|
+ },
|
|
|
|
+ success: function (res) {
|
|
|
|
+ console.log(res);
|
|
|
|
+ // let data = JSON.parse(res.data); // 这个很关键
|
|
|
|
+ // tempList.push(data.data.url);
|
|
|
|
+ // _this.setData({
|
|
|
|
+ // imageList: tempList
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ // for(let i of res.tempFilePaths) {
|
|
|
|
+ // tempList.push(i)
|
|
|
|
+ // }
|
|
|
|
+ // _this.setData({
|
|
|
|
+ // imageList: tempList
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ delImg: function (event) {
|
|
|
|
+ console.log('s')
|
|
|
|
+ let tempList = this.data.imageList
|
|
|
|
+ tempList.splice(event.currentTarget.dataset.index, 1)
|
|
|
|
+ this.setData({
|
|
|
|
+ imageList: tempList
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ openPreview: function (event) {
|
|
|
|
+ wx.previewImage({
|
|
|
|
+ urls: this.data.imageList,
|
|
|
|
+ current: event.currentTarget.dataset.current
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+})
|