修改审核页面
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
>
|
||||
<!-- 状态标签(右上角旋转丝带) -->
|
||||
<view class="status-ribbon" :class="'ribbon-' + item.status">
|
||||
<text class="ribbon-text">{{ getStatusText(item.status) }}</text>
|
||||
<text class="ribbon-text">{{ item.action == 1 ? '已审核' : getStatusText(item.status) }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 卡片内容 -->
|
||||
@@ -43,11 +43,10 @@
|
||||
<!-- <text class="info-item">公司名称: {{ item.companyName }}</text> -->
|
||||
<text class="info-item"></text>
|
||||
<!-- 操作按钮 -->
|
||||
<view class="card-actions" v-if="item.status !== 'returned'">
|
||||
<button
|
||||
class="action-btn"
|
||||
<view class="card-actions" v-if="item.action != 1 && item.status == '10'">
|
||||
<button
|
||||
class="action-btn"
|
||||
:class="'btn-' + item.status"
|
||||
v-if="item.status==10"
|
||||
@click.stop="handleAction(item)"
|
||||
>
|
||||
{{ getActionText(item.status) }}
|
||||
|
||||
@@ -85,6 +85,27 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 审批附件 -->
|
||||
<view class="card">
|
||||
<view class="card-head">
|
||||
<text class="card-title">审批附件</text>
|
||||
</view>
|
||||
<view class="media-upload-wrapper">
|
||||
<uni-file-picker
|
||||
ref="mediaPicker"
|
||||
:limit="maxMedia"
|
||||
fileMediatype="image"
|
||||
:auto-upload="false"
|
||||
@select="selectMedia"
|
||||
@delete="delfn"
|
||||
>
|
||||
<view class="upload-icon-wrapper">
|
||||
<image src="/static/image/upload.png" mode="" class="addimg"></image>
|
||||
</view>
|
||||
</uni-file-picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 120rpx;"></view>
|
||||
</view>
|
||||
|
||||
@@ -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%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -106,6 +106,23 @@
|
||||
<text class="value">{{ detail.handle_remark || (detail.audit_info && detail.audit_info.handle_remark ? detail.audit_info.handle_remark : '-') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 审核附件 -->
|
||||
<view class="card" v-if="detail.return_approve_attachment && detail.return_approve_attachment.length > 0">
|
||||
<view class="card-head">
|
||||
<text class="card-title">审核附件</text>
|
||||
</view>
|
||||
<view class="img-grid">
|
||||
<image
|
||||
v-for="(a, i) in detail.return_approve_attachment"
|
||||
:key="a.id || i"
|
||||
class="img"
|
||||
:src="a.file_path_pull || ''"
|
||||
mode="aspectFill"
|
||||
@click="previewHandleAttachment(i)"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
@@ -88,6 +88,27 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 审批附件 -->
|
||||
<view class="card">
|
||||
<view class="card-head">
|
||||
<text class="card-title">审批附件</text>
|
||||
</view>
|
||||
<view class="media-upload-wrapper">
|
||||
<uni-file-picker
|
||||
ref="mediaPicker"
|
||||
:limit="maxMedia"
|
||||
fileMediatype="image"
|
||||
:auto-upload="false"
|
||||
@select="selectMedia"
|
||||
@delete="delfn"
|
||||
>
|
||||
<view class="upload-icon-wrapper">
|
||||
<image src="/static/image/upload.png" mode="" class="addimg"></image>
|
||||
</view>
|
||||
</uni-file-picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 120rpx;"></view>
|
||||
</view>
|
||||
|
||||
@@ -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%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user