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

View File

@@ -276,7 +276,11 @@ export default {
content: "您确认要审核" + examine + " " + v.goodsName + " ?", content: "您确认要审核" + examine + " " + v.goodsName + " ?",
loading: true, loading: true,
onOk: () => { 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(); this.$Modal.remove();
if (res.success) { if (res.success) {
this.$Message.success("审核成功"); this.$Message.success("审核成功");