Browse Source

添加图片上传

wms3.0_pda
lijuncheng 11 months ago
parent
commit
c2ca07f2cf
  1. 2
      api/httpRequest3.js
  2. 4
      api/index.js
  3. 55
      api/request2.js
  4. 11
      pages/count/job/countDetail.vue
  5. 116
      pages/inspect/coms/inspectEdit.vue
  6. 6
      pages/inspect/coms/uploadCamera.vue
  7. 30
      pages/inspect/job/inspectDetail.vue
  8. 27
      pages/inspect/job/inspectFullDetail.vue

2
api/httpRequest3.js

@ -53,4 +53,6 @@ function service(options = {}) {
});
}
export default service;

4
api/index.js

@ -1226,3 +1226,7 @@ export const issueDirect = (params) => request(
data: params,
method: "post"
});

55
api/request2.js

@ -1,4 +1,5 @@
import request from '@/api/httpRequest3.js'
import storage from '@/common/utils/storage'
// const baseApi = "/api/admin-api"
//公司地址
// 本地地址
@ -2951,3 +2952,57 @@ export function getBalanceByFilter(param) {
data: param,
});
}
/**
* 删除文件
* @param {*}
*
*/
export function deleteFileById(id) {
return request({
url: baseApi + "/infra/file/delete?id=" + id ,
method: "delete",
data: {},
});
}
/**
* 获取文件列表
* @param {*}
*
*/
export function getFileList(tableName, tableId) {
return request({
url: baseApi + "/infra/file/list?tableName=" + tableName + "&tableId=" + tableId,
method: "get",
data: {},
});
}
/**
* 图片上传
* @param {*}
*
*/
export function uploadFile(tableName, tableId,filePath,callBack) {
var token = storage.getStorage(storage.constant.token)
var url = getApp().globalData.request_url+baseApi
uni.uploadFile({
url: url+"/infra/file/upload?tableName="+tableName + "&tableId=" + tableId,
filePath: filePath,
name: 'file',
header: {
"Authorization": "Bearer " + token,
"tenant-id": 1
},
success: (uploadFileRes) => {
callBack(uploadFileRes.data)
console.log(uploadFileRes.data);
},
fail: (error) => {
callBack(undefined)
},
});
}

11
pages/count/job/countDetail.vue

@ -400,7 +400,7 @@
createAddDetailInfo(balance, pack) {
var detail = {
id: "",
id: "0",
scaned: true,
countDetailNumber: "",
ownerCode: balance.ownerCode,
@ -413,16 +413,17 @@
itemDesc1: pack.itemDesc1,
itemDesc2: pack.itemDesc2,
projectCode: "",
qty: balance.qty,
qty: 0,
handleQty: balance.qty,
uom: balance.uom,
number: "",
number: this.jobContent.number,
remark: "",
countQty: balance.qty,
balanceQty: balance.qty,
fromLocationCode: balance.locationCode,
stdPackQty: pack.stdPackQty,
stdPackUnit: pack.stdPackUnit,
creator:this.$store.state.user.id
}
return detail;
@ -509,10 +510,10 @@
});
var params = this.setParams()
console.log("提交参数", JSON.stringify(params));
countJobSubmit(this.id, params).then(res => {
countJobSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成盘点记录" + res.data)
this.showCommitSuccessMessage("提交成功<br>生成盘点记录<br>" + res.data)
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
}

116
pages/inspect/coms/inspectEdit.vue

@ -1,6 +1,6 @@
<template>
<view class="">
<uni-popup ref="editPopup" class="nopadpop camera_pop">
<uni-popup ref="editPopup" class="nopadpop camera_pop" :maskClick="false">
<view class="uni-list popuni_list camera_list">
<view class="list_cell uni-flex uni-row space-between">
<view class="title">箱码</view>
@ -49,8 +49,8 @@
</view>
</view>
<uploadCamera ref="uploadImage" style="margin: 10rpx;" :disabled="disabled"></uploadCamera>
<uploadCamera ref="uploadImage" style="margin: 10rpx;" :disabled="disabled" @delete="deleteImg"
@select="select"></uploadCamera>
</view>
<view class="pop_btn uni-flex uni-row space-between" v-if="!disabled">
<button class="cancel" @click="back">返回</button>
@ -65,6 +65,12 @@
import {
getInspectFailedReasonList,
} from '@/common/directory.js';
import {
uploadFile,
getFileList,
deleteFileById
} from '@/api/request2.js';
import comMessage from '@/mycomponents/common/comMessage.vue'
import uploadCamera from '@/pages/inspect/coms/uploadCamera.vue'
import uom from '@/mycomponents/qty/uom.vue'
@ -81,7 +87,8 @@
failedReasonIndex: 0,
failedReasonArray: [],
dataContent: {},
failedReasonArray: []
failedReasonArray: [],
picInfoList: []
}
},
props: {
@ -101,11 +108,93 @@
this.failedReasonArray = getInspectFailedReasonList();
//
this.dataContent = Object.assign({}, item)
this.getFileList();
this.$refs['editPopup'].open("bottom");
},
getFileList() {
getFileList("jobInspectDetail", this.dataContent.id).then(res => {
if(res.data){
var imageFiles = [];
res.data.forEach(item=>{
var image = this.createImage(item.id, item.url, item.path, item.size)
imageFiles.push(image)
})
}
if (imageFiles.length > 0) {
this.$nextTick(function() {
this.$refs.uploadImage.setFiles(imageFiles);
this.setPhotosInfo();
})
}
})
},
setPhotosInfo(){
var list = this.$refs.uploadImage.getFiles()
var photoItem = "";
for (var i = 0; i < list.length; i++) {
if (list.length - 1 == i) {
photoItem = photoItem + list[i].url
} else {
photoItem = photoItem + list[i].url + ","
}
}
this.dataContent.photos = photoItem;
},
createImage(id, url, fileName, size) {
let image = {
id: id,
name: fileName,
extname: "png",
fileType: "image",
url: url,
size: size,
image: {
width: 175,
height: 175,
location: url,
},
path: url,
progress: 100,
status: "ready"
}
return image;
},
deleteImg(content) {
var id = content.id
if (id != undefined) {
deleteFileById(id).then(res => {
if (res.data) {
uni.showToast({
title: "删除成功"
})
}
}).catch(error => {
console.log(error)
})
} else {
this.getFileList();
}
},
select(content) {
this.uploadFile(content);
},
back() {
this.$refs['editPopup'].close();
this.afterSave()
},
maskClick() {
},
afterSave() {
@ -119,6 +208,8 @@
}
});
},
save() {
var failedQty = Number(this.dataContent.failedQty);
var crackQty = Number(this.dataContent.crackQty);
@ -141,8 +232,21 @@
this.afterSave()
},
uploadFile(content) {
uploadFile("jobInspectDetail", this.dataContent.id, content.path, res => {
if (res != undefined) {
uni.showToast({
title: "上传成功"
})
} else {
uni.showToast({
title: "上传失败"
})
}
this.getFileList();
})
}
}
}

6
pages/inspect/coms/uploadCamera.vue

@ -33,12 +33,14 @@
},
//
select(e) {
console.log('选择文件:', e)
// console.log('', e)
this.$emit("select",e.tempFiles[0])
},
//
deleteImg(e) {
console.log('删除:', e)
// console.log('', e)
this.$emit("delete",e.tempFile)
},
//

30
pages/inspect/job/inspectDetail.vue

@ -39,8 +39,9 @@
takeInspectJob,
cancleTakeInspectJob,
getInspectJobDetail,
getBasicLocationByCode,
inspectJobSubmit
inspectJobSubmit,
deleteFileById,
getFileList
} from '@/api/request2.js';
import {
goHome,
@ -136,6 +137,7 @@
},
onPullDownRefresh() {
this.getDetail();
uni.stopPullDownRefresh();
@ -145,6 +147,29 @@
},
methods: {
deleteFileById(id){
deleteFileById(id).then(res=>{
})
},
getFileList(id){
getFileList("jobInspectDetail", id).then(res => {
if(res.data){
res.data.forEach(res=>{
this.deleteFileById(res.id)
})
}
})
},
clearPicList(subList){
subList.forEach(item=>{
this.getFileList(item.id)
})
},
//
receive(callback) {
uni.showLoading({
@ -179,6 +204,7 @@
that.jobContent.failedQty = this.failedQty
that.jobContent.crackQty = this.crackQty;
that.subList = res.data.subList;
this.clearPicList(that.subList);
that.subList.forEach(res => {
res.batch = that.jobContent.batch
res.goodQty = 0;

27
pages/inspect/job/inspectFullDetail.vue

@ -39,8 +39,9 @@
takeInspectJob,
cancleTakeInspectJob,
getInspectJobDetail,
getBasicLocationByCode,
inspectJobSubmit
inspectJobSubmit,
deleteFileById,
getFileList
} from '@/api/request2.js';
import {
goHome,
@ -147,6 +148,27 @@
},
methods: {
deleteFileById(id){
deleteFileById(id).then(res=>{
})
},
getFileList(id){
getFileList("jobInspectDetail", id).then(res => {
if(res.data){
res.data.forEach(res=>{
this.deleteFileById(res.id)
})
}
})
},
clearPicList(subList){
subList.forEach(item=>{
this.getFileList(item.id)
})
},
//
receive(callback) {
uni.showLoading({
@ -182,6 +204,7 @@
this.jobContent.crackQty = 0;
this.jobContent.notPassedQty = 0;
that.subList = res.data.subList;
this.clearPicList(that.subList);
that.subList.forEach(res => {
res.batch = that.jobContent.batch
res.goodQty = 0;

Loading…
Cancel
Save