diff --git a/pages/approval/borrow_approval.vue b/pages/approval/borrow_approval.vue
index 46da02b..0450954 100644
--- a/pages/approval/borrow_approval.vue
+++ b/pages/approval/borrow_approval.vue
@@ -26,7 +26,7 @@
>
- {{ getStatusText(item.status) }}
+ {{ item.action == 1 ? '已审核' : getStatusText(item.status) }}
@@ -43,11 +43,10 @@
-
-
+
+
+
+ 审批附件
+
+
+
+
+
+
+
+
+
+
@@ -109,7 +130,10 @@
id: '',
detail: {},
approveItems: [],
- auditRemark: ''
+ auditRemark: '',
+ maxMedia: 20,
+ // 审批附件列表
+ auditAttachment: []
}
},
computed: {
@@ -191,12 +215,98 @@
urls
})
},
+ // 上传图片
+ uploadfn(imgUrl) {
+ return new Promise((resolve, reject) => {
+ uni.uploadFile({
+ url: 'https://fdesk.hnxinyouhe.com/upload?scene=itemsimg',
+ filePath: imgUrl,
+ name: 'file',
+ header: {
+ 'Fdesk-Corp-Abbr': uni.getStorageSync('corp_abbr'),
+ 'Fdesk-Auth-Token': 'Bearer ' + uni.getStorageSync('token'),
+ 'Fdesk-Language': uni.getStorageSync('i18locale') ? uni.getStorageSync('i18locale') : 'zh',
+ 'Fdesk-Login-Type': 'feishu',
+ 'Fdesk-System-Code': 'fdesk'
+ },
+ success: (uploadFileRes) => {
+ const res = JSON.parse(uploadFileRes.data || '{}')
+ if (res && res.data && res.data.file_name) {
+ resolve(res.data)
+ } else {
+ reject('上传失败')
+ }
+ },
+ fail: (err) => reject(err)
+ })
+ })
+ },
+ // 选择图片
+ selectMedia(e) {
+ this.auditAttachment = Array.isArray(this.auditAttachment) ? this.auditAttachment : []
+ const allowCount = this.maxMedia - this.auditAttachment.length
+ const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
+ const paths = tempFilePaths.slice(0, allowCount)
+ if (paths.length === 0) return
+
+ const startIndex = this.auditAttachment.length
+ // 先占位
+ paths.forEach(p => {
+ this.auditAttachment.push({
+ __local_path: p,
+ original_name: '',
+ file_path: ''
+ })
+ })
+
+ Promise.all(
+ paths.map((p, i) =>
+ this.uploadfn(p)
+ .then(data => ({ i, ok: true, data }))
+ .catch(err => ({ i, ok: false, err }))
+ )
+ ).then(results => {
+ // 写入成功结果
+ results.forEach(r => {
+ if (!r.ok) return
+ const idx = startIndex + r.i
+ const row = this.auditAttachment[idx]
+ if (!row) return
+ row.original_name = r.data.original_name
+ row.file_path = r.data.file_name
+ delete row.__local_path
+ })
+
+ // 移除失败项
+ const failed = results.filter(r => !r.ok).map(r => r.i).sort((a, b) => b - a)
+ if (failed.length) {
+ failed.forEach(i => {
+ const idx = startIndex + i
+ this.auditAttachment.splice(idx, 1)
+ this.$nextTick(() => {
+ if (this.$refs.mediaPicker && this.$refs.mediaPicker.clearFiles) {
+ this.$refs.mediaPicker.clearFiles(idx)
+ }
+ })
+ })
+ uni.showToast({
+ title: '部分图片上传失败,已自动移除,请重试',
+ icon: 'none'
+ })
+ }
+ })
+ },
+ // 删除图片
+ delfn(e) {
+ this.auditAttachment.splice(e.index, 1)
+ },
buildPayload(action) {
return {
requisition_id: this.detail.id || this.id,
action, // 'approve' | 'reject'
- approve_id:this.detail.approve_id,
- comment: this.auditRemark || ''
+ approve_id: this.detail.approve_id,
+ comment: this.auditRemark || '',
+ attachment: this.auditAttachment
// items: this.approveItems.map((it) => ({
// requisition_item_id: it.requisition_item_id,
// requisition_item_name: it.requisition_item_name,
@@ -209,6 +319,14 @@
showToast({ title: '没有可审核的物品' })
return
}
+ // 检查附件是否上传完成
+ if (Array.isArray(this.auditAttachment)) {
+ const uploading = this.auditAttachment.some(a => !a || !a.file_path)
+ if (uploading) {
+ showToast({ title: '附件上传中,请稍后再提交' })
+ return
+ }
+ }
const payload = this.buildPayload(action)
request({
@@ -216,7 +334,7 @@
method: 'POST',
data: payload
}).then((res) => {
- const msg = (res.data && (res.data.message || res.data.msg)) || '操作完成'
+ const msg = (res.data && (res.data.data.message || res.data.data.msg)) || '操作完成'
showToast({ title: msg })
if (res.data && Number(res.data.code) === 200) {
setTimeout(() => {
@@ -447,4 +565,16 @@
background: rgb(48, 116, 247);
color: #fff;
}
+ .media-upload-wrapper {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 16rpx;
+ }
+ .addimg {
+ width: 100rpx;
+ height: 100rpx;
+ }
+ ::v-deep .uni-file-picker {
+ width: 100%;
+ }
diff --git a/pages/approval/return_approval_detail.vue b/pages/approval/return_approval_detail.vue
index 4690229..d6bade7 100644
--- a/pages/approval/return_approval_detail.vue
+++ b/pages/approval/return_approval_detail.vue
@@ -106,6 +106,23 @@
{{ detail.handle_remark || (detail.audit_info && detail.audit_info.handle_remark ? detail.audit_info.handle_remark : '-') }}
+
+
+
+
+ 审核附件
+
+
+
+
+
@@ -151,6 +168,7 @@ export default {
this.detail = res.data.data || {}
this.detail.item_return = Array.isArray(this.detail.item_return) ? this.detail.item_return : []
this.detail.return_attachment = Array.isArray(this.detail.return_attachment) ? this.detail.return_attachment : []
+ this.detail.return_approve_attachment = Array.isArray(this.detail.return_approve_attachment) ? this.detail.return_approve_attachment : []
} else {
showToast({ title: res.data.message || '获取详情失败' })
}
@@ -194,6 +212,17 @@ export default {
uni.previewImage({
urls: [url]
})
+ },
+ // 预览审核附件
+ previewHandleAttachment(startIndex) {
+ const urls = (this.detail.return_approve_attachment || [])
+ .map((a) => a.file_path_pull)
+ .filter(Boolean)
+ if (!urls.length) return
+ uni.previewImage({
+ current: urls[startIndex] || urls[0],
+ urls
+ })
}
}
}
@@ -346,4 +375,15 @@ export default {
border-radius: 12rpx;
flex-shrink: 0;
}
+.img-grid {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12rpx;
+}
+.img {
+ width: 210rpx;
+ height: 210rpx;
+ border-radius: 16rpx;
+ background: #f2f4f7;
+}
\ No newline at end of file
diff --git a/pages/approval/return_approval_detils.vue b/pages/approval/return_approval_detils.vue
index 42d3abf..c3da3e9 100644
--- a/pages/approval/return_approval_detils.vue
+++ b/pages/approval/return_approval_detils.vue
@@ -88,6 +88,27 @@
/>
+
+
+
+ 审批附件
+
+
+
+
+
+
+
+
+
+
@@ -110,7 +131,10 @@
return {
id: '',
detail: {},
- auditRemark: ''
+ auditRemark: '',
+ maxMedia: 20,
+ // 审批附件列表
+ auditAttachment: []
}
},
computed: {
@@ -154,7 +178,8 @@
return {
requisition_item_return_id: this.id,
status: action, // '1' 同意 | '2' 驳回
- handle_remark: this.auditRemark || ''
+ handle_remark: this.auditRemark || '',
+ attachment: this.auditAttachment
}
},
doSubmit(action) {
@@ -162,6 +187,14 @@
showToast({ title: '没有可审核的物品' })
return
}
+ // 检查附件是否上传完成
+ if (Array.isArray(this.auditAttachment)) {
+ const uploading = this.auditAttachment.some(a => !a || !a.file_path)
+ if (uploading) {
+ showToast({ title: '附件上传中,请稍后再提交' })
+ return
+ }
+ }
const payload = this.buildPayload(action)
request({
@@ -227,6 +260,91 @@
uni.previewImage({
urls: [url]
})
+ },
+ // 上传图片
+ uploadfn(imgUrl) {
+ return new Promise((resolve, reject) => {
+ uni.uploadFile({
+ url: 'https://fdesk.hnxinyouhe.com/upload?scene=itemsimg',
+ filePath: imgUrl,
+ name: 'file',
+ header: {
+ 'Fdesk-Corp-Abbr': uni.getStorageSync('corp_abbr'),
+ 'Fdesk-Auth-Token': 'Bearer ' + uni.getStorageSync('token'),
+ 'Fdesk-Language': uni.getStorageSync('i18locale') ? uni.getStorageSync('i18locale') : 'zh',
+ 'Fdesk-Login-Type': 'feishu',
+ 'Fdesk-System-Code': 'fdesk'
+ },
+ success: (uploadFileRes) => {
+ const res = JSON.parse(uploadFileRes.data || '{}')
+ if (res && res.data && res.data.file_name) {
+ resolve(res.data)
+ } else {
+ reject('上传失败')
+ }
+ },
+ fail: (err) => reject(err)
+ })
+ })
+ },
+ // 选择图片
+ selectMedia(e) {
+ this.auditAttachment = Array.isArray(this.auditAttachment) ? this.auditAttachment : []
+ const allowCount = this.maxMedia - this.auditAttachment.length
+ const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
+ const paths = tempFilePaths.slice(0, allowCount)
+ if (paths.length === 0) return
+
+ const startIndex = this.auditAttachment.length
+ // 先占位
+ paths.forEach(p => {
+ this.auditAttachment.push({
+ __local_path: p,
+ original_name: '',
+ file_path: ''
+ })
+ })
+
+ Promise.all(
+ paths.map((p, i) =>
+ this.uploadfn(p)
+ .then(data => ({ i, ok: true, data }))
+ .catch(err => ({ i, ok: false, err }))
+ )
+ ).then(results => {
+ // 写入成功结果
+ results.forEach(r => {
+ if (!r.ok) return
+ const idx = startIndex + r.i
+ const row = this.auditAttachment[idx]
+ if (!row) return
+ row.original_name = r.data.original_name
+ row.file_path = r.data.file_name
+ delete row.__local_path
+ })
+
+ // 移除失败项
+ const failed = results.filter(r => !r.ok).map(r => r.i).sort((a, b) => b - a)
+ if (failed.length) {
+ failed.forEach(i => {
+ const idx = startIndex + i
+ this.auditAttachment.splice(idx, 1)
+ this.$nextTick(() => {
+ if (this.$refs.mediaPicker && this.$refs.mediaPicker.clearFiles) {
+ this.$refs.mediaPicker.clearFiles(idx)
+ }
+ })
+ })
+ uni.showToast({
+ title: '部分图片上传失败,已自动移除,请重试',
+ icon: 'none'
+ })
+ }
+ })
+ },
+ // 删除图片
+ delfn(e) {
+ this.auditAttachment.splice(e.index, 1)
}
}
}
@@ -423,4 +541,16 @@
border-radius: 12rpx;
flex-shrink: 0;
}
+ .media-upload-wrapper {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 16rpx;
+ }
+ .addimg {
+ width: 100rpx;
+ height: 100rpx;
+ }
+ ::v-deep .uni-file-picker {
+ width: 100%;
+ }
\ No newline at end of file