|
@@ -0,0 +1,154 @@
|
|
|
+import * as requestAPI from '../../models/dataModel'
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ contractDetail: {},
|
|
|
+ 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.getContractDetail(sscId, pId).then(res => {
|
|
|
+ this.setData({
|
|
|
+ contractDetail: res.data.data
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取qa日志
|
|
|
+ getQaLog(sscId, pId) {
|
|
|
+ requestAPI.getContractQaLog(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.changeContractQaLog(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.addContractQaLog(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/supplier/contract/qalog/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.delContractPic(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
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|