|
|
@@ -164,13 +164,8 @@ import { ElMessage } from "element-plus";
|
|
|
import ProTable from "@/components/ProTable/index.vue";
|
|
|
import { ColumnProps, ProTableInstance } from "@/components/ProTable/interface";
|
|
|
import { Plus } from "@element-plus/icons-vue";
|
|
|
-import {
|
|
|
- delThaliById as delVoucherById,
|
|
|
- getThaliList,
|
|
|
- updateNum,
|
|
|
- updateStatus as updateVoucherStatus
|
|
|
-} from "@/api/modules/voucherManagement";
|
|
|
-import { delThaliById as delCouponById, updateStatus as updateCouponStatus } from "@/api/modules/couponManagement";
|
|
|
+import { delThaliById, getThaliList, updateNum, updateStatus } from "@/api/modules/voucherManagement";
|
|
|
+import { delCouponById, updateCouponSingleQty, updateCouponStatus } from "@/api/modules/couponManagement";
|
|
|
import { ElMessageBox } from "element-plus/es";
|
|
|
import { localGet, usePermission } from "@/utils";
|
|
|
|
|
|
@@ -211,6 +206,12 @@ const rules = reactive<FormRules<RuleForm>>({
|
|
|
callback(new Error("库存不得大于10000"));
|
|
|
return;
|
|
|
}
|
|
|
+ // 验证新库存值不能小于剩余库存
|
|
|
+ const currentQty = Number(formInventory.value.singleQty) || 0;
|
|
|
+ if (numValue < currentQty) {
|
|
|
+ callback(new Error(`库存不能小于剩余库存(${currentQty})`));
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
callback();
|
|
|
},
|
|
|
@@ -563,7 +564,7 @@ const deleteRow = (row: any) => {
|
|
|
id: row.id,
|
|
|
groupType: localGet("businessSection")
|
|
|
};
|
|
|
- return delVoucherById(params);
|
|
|
+ return delThaliById(params);
|
|
|
} else {
|
|
|
// 优惠券删除逻辑
|
|
|
const params = {
|
|
|
@@ -591,14 +592,14 @@ const handleClick = () => {
|
|
|
const changeTypes = async (row: any, status: number) => {
|
|
|
if (isVoucher.value) {
|
|
|
// 代金券上架/下架逻辑
|
|
|
- const res = await updateVoucherStatus({ id: row.id, status: status, approvalComments: "" });
|
|
|
+ const res = await updateStatus({ id: row.id, status: status, approvalComments: "" });
|
|
|
if (res && res.code == 200) {
|
|
|
ElMessage.success("操作成功");
|
|
|
proTable.value?.getTableList();
|
|
|
}
|
|
|
} else {
|
|
|
// 优惠券上架/下架逻辑
|
|
|
- const res = await updateCouponStatus({ id: row.id, status: status, approvalComments: "" });
|
|
|
+ const res = await updateCouponStatus({ counponId: row.id });
|
|
|
if (res && res.code == 200) {
|
|
|
ElMessage.success("操作成功");
|
|
|
proTable.value?.getTableList();
|
|
|
@@ -621,14 +622,24 @@ const handleSubmit = async () => {
|
|
|
if (!ruleFormRef.value) return;
|
|
|
await ruleFormRef.value.validate(async valid => {
|
|
|
if (valid) {
|
|
|
- const res = await updateNum({
|
|
|
+ const params = {
|
|
|
id: formInventory.value.id,
|
|
|
singleQty: formInventory.value.newInventory
|
|
|
- });
|
|
|
- if (res && res.code == 200) {
|
|
|
- ElMessage.success("修改成功");
|
|
|
- closeDialog();
|
|
|
- proTable.value?.getTableList();
|
|
|
+ };
|
|
|
+ if (isVoucher.value) {
|
|
|
+ const res = await updateNum(params);
|
|
|
+ if (res && res.code == 200) {
|
|
|
+ ElMessage.success("修改成功");
|
|
|
+ closeDialog();
|
|
|
+ proTable.value?.getTableList();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const res = await updateCouponSingleQty(params);
|
|
|
+ if (res && res.code == 200) {
|
|
|
+ ElMessage.success("修改成功");
|
|
|
+ closeDialog();
|
|
|
+ proTable.value?.getTableList();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|