fix(商品审核): 优化审核功能,使用FormData处理请求数据,提升代码可读性和维护性

This commit is contained in:
Ryan Ran
2025-09-23 14:01:53 +08:00
parent bb864e72b3
commit bb610a7cd8
2 changed files with 52 additions and 46 deletions

View File

@@ -179,9 +179,9 @@
<Radio :label="2">审核拒绝</Radio>
</RadioGroup>
</FormItem>
<FormItem label="审核备注" prop="reason" v-if="goodsAuditForm.auth_flag === 2">
<!-- <FormItem label="审核备注" prop="reason" v-if="goodsAuditForm.auth_flag === 2">
<Input v-model="goodsAuditForm.reason" type="textarea" :rows="3" placeholder="请输入拒绝原因" />
</FormItem>
</FormItem> -->
</Form>
<div slot="footer">
<Button type="text" @click="auditModalVisible = false">取消</Button>
@@ -651,13 +651,18 @@ export default {
examine = "拒绝";
this.goodsAuditForm.authFlag = "REFUSE";
}
this.$Modal.confirm({
title: "确认审核",
content: "您确认要审核" + examine + " " + v.goodsName + " ?",
loading: true,
onOk: () => {
this.goodsAuditForm.goodsIds=v.id;
authGoods(this.goodsAuditForm).then((res) => {
let formData = new FormData();
formData.append('goodsIds', v.id);
formData.append('authFlag', this.goodsAuditForm.authFlag);
authGoods(formData).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("审核成功");
@@ -692,13 +697,10 @@ export default {
// 提交审核
submitAudit() {
const auditForm = {
authFlag: this.goodsAuditForm.auth_flag === 1 ? 'PASS' : 'REFUSE',
reason: this.goodsAuditForm.reason || '',
goodsId:this.currentAuditGoods.id
};
authGoods(auditForm).then((res) => {
let formData = new FormData();
formData.append('goodsIds', this.currentAuditGoods.id);
formData.append('authFlag', this.goodsAuditForm.auth_flag === 1 ? 'PASS' : 'REFUSE');
authGoods(formData).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success('审核成功');
@@ -831,14 +833,14 @@ export default {
onOk: () => {
// 提取所有选中商品的ID
const goodsIds = this.selectedRows.map(item => item.id);
const params = {
goodsId: goodsIds, // 传递ID数组
authFlag: this.batchAuditForm.auth_flag === 1 ? 'PASS' : 'REFUSE',
reason: this.batchAuditForm.reason || ''
};
let formData = new FormData();
formData.append('goodsId', goodsIds);
formData.append('authFlag', this.batchAuditForm.auth_flag === 1 ? 'PASS' : 'REFUSE');
formData.append('reason', this.batchAuditForm.reason || '');
// 修正直接调用authGoods不传递'batch'参数
authGoods(params).then((res) => {
authGoods(formData).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success(`批量审核${actionText}成功`);

View File

@@ -276,7 +276,11 @@ export default {
content: "您确认要审核" + examine + " " + v.goodsName + " ?",
loading: true,
onOk: () => {
authGoods(v.id, this.goodsAuditForm).then((res) => {
let formData = new FormData();
formData.append('goodsIds', v.id);
formData.append('authFlag', this.goodsAuditForm.authFlag);
authGoods(formData).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("审核成功");