修复库存开关按钮无效问题,增加商品上下架sku联动,修复商品绑定耗材编辑回显问题

This commit is contained in:
2026-03-30 18:07:58 +08:00
parent e5cdf0a3dc
commit be12089ffe
2 changed files with 34 additions and 5 deletions

View File

@@ -46,10 +46,12 @@
</template>
<template #isStock="scope">
<el-switch
disabled
v-if="!scope.row.productId"
v-model="scope.row[scope.prop]"
:active-value="1"
:inactive-value="0"
:disabled="!scope.row.type"
@click="isStockChange(scope.row)"
></el-switch>
</template>
@@ -160,6 +162,7 @@
<el-table-column label="耗材名称" prop="consInfoId">
<template v-slot="scope">
<el-select
filterable
v-model="scope.row.consInfoId"
reserve-keyword
placeholder="请输入关键词"
@@ -167,9 +170,9 @@
>
<el-option
v-for="item in options"
:key="item.id"
:key="item.id * 1"
:label="item.conName"
:value="item.id"
:value="item.id * 1"
></el-option>
</el-select>
<!-- <div class="tips" v-if="scope.row.stockNumber">库存{{ scope.row.stockNumber }}</div> -->
@@ -401,13 +404,25 @@ function createItem(val: IObject) {
haocaiData.value.consList.push(item);
}
// 上架
function handleSwitchChange(data: any) {
async function handleSwitchChange(data: any) {
console.log(data);
let obj = {
type: data.productId ? "sku" : "product",
id: data.id,
isSale: data.isSale,
};
UserAPI.onOff(obj);
await UserAPI.onOff(obj);
ElMessage.success("修改成功!");
if (data.productId) {
//sku
contentRef.value?.fetchPageData();
} else {
//product
data.skuList.map((v) => {
v.isSale = data.isSale;
});
}
}
// 售罄
function handleSwitchChangeTwo(data: any) {
@@ -417,6 +432,7 @@ function handleSwitchChangeTwo(data: any) {
isSoldOut: data.isSoldStock,
};
UserAPI.markIsSoldOut(obj);
ElMessage.success("修改成功!");
}
function handleSwitchChangethree(data: any) {
let obj = {
@@ -427,6 +443,18 @@ function handleSwitchChangethree(data: any) {
UserAPI.markIsSoldOut(obj);
}
async function isStockChange(data: any) {
console.log(data);
let obj = {
type: "product",
id: data.id,
isSale: data.isStock,
optType: "stock ",
};
await UserAPI.onOff(obj);
ElMessage.success("修改成功!");
return;
}
// 退款退回
async function handleSwitchhaocai(row: IObject) {
let res = await UserAPI.refundToStock({ isReturn: row.isRefundStock, id: row.id });

View File

@@ -9,6 +9,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
table: {
border: true,
highlightCurrentRow: true,
expandRowKeys: [],
rowKey: 'id',
treeProps: {
children: 'skuList' // 指定子节点存储的字段为 customChildren