在资产管理中新增库存类型字段,支持有限库存和无限库存两种模式,编辑时禁止修改库存类型,同时在SKU管理中为无限库存资产新增生成库存按钮并移除库存数量编辑功能

This commit is contained in:
WUSIJIAN
2026-01-14 13:58:26 +08:00
parent f8af956f06
commit 70a956febe
3 changed files with 32 additions and 7 deletions

View File

@@ -62,6 +62,14 @@
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="库存类型">
<el-radio-group v-model="ruleForm.unlimitedStock" :disabled="isEdit">
<el-radio :value="false">有限库存</el-radio>
<el-radio :value="true">无限库存</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<!-- 分类属性值选择 -->
@@ -486,6 +494,7 @@ interface RuleForm {
description: string;
onlineTime: string;
offlineTime: string;
unlimitedStock: boolean;
physicalAssetConfig: {
shipping: {
deliveryMethod: string;
@@ -588,6 +597,7 @@ const getInitialForm = (): RuleForm => ({
description: '',
onlineTime: '',
offlineTime: '',
unlimitedStock: false,
physicalAssetConfig: {
shipping: {
deliveryMethod: 'express',
@@ -892,6 +902,7 @@ const openDialog = (row?: any, edit?: boolean) => {
ruleForm.description = data.description || '';
ruleForm.onlineTime = data.onlineTime || '';
ruleForm.offlineTime = data.offlineTime || '';
ruleForm.unlimitedStock = data.unlimitedStock || false;
// 主图预览 (支持 imageUrl 和 fileURL)
const mainImg = data.imageUrl || data.fileURL;
@@ -1096,6 +1107,9 @@ const buildRequestBody = async (): Promise<any> => {
body.offlineTime = ruleForm.offlineTime;
}
// 库存类型
body.unlimitedStock = ruleForm.unlimitedStock;
// 主图 (已在上传时直接赋值给 ruleForm.mainImage)
if (ruleForm.mainImage) {
body.imageURL = ruleForm.mainImage;

View File

@@ -78,9 +78,10 @@
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="操作" width="120" align="center">
<el-table-column label="操作" width="180" align="center">
<template #default="scope">
<el-button size="small" text type="primary" @click="onEditSku(scope.row)">编辑</el-button>
<el-button v-if="scope.row.unlimitedStock" size="small" text type="success" @click="onGenerateStock(scope.row)">生成库存</el-button>
<el-button size="small" text type="danger" @click="onDeleteSku(scope.row)">删除</el-button>
</template>
</el-table-column>
@@ -131,10 +132,6 @@
<el-input-number v-model="skuForm.price" :min="0" :precision="2" :step="0.01" controls-position="right" />
<span style="margin-left: 8px"></span>
</el-form-item>
<el-form-item label="库存数量" prop="stock">
<el-input-number v-model="skuForm.stock" :min="0" :disabled="skuForm.unlimitedStock" controls-position="right" />
<el-checkbox v-model="skuForm.unlimitedStock" style="margin-left: 10px">无限库存</el-checkbox>
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="skuForm.status">
<el-radio :value="1">激活</el-radio>
@@ -199,6 +196,7 @@ const editSkuId = ref('');
const assetId = ref('');
const assetName = ref('');
const assetType = ref('');
const unlimitedStock = ref(false); // 资产是否无限库存
const assetSpecAttrs = ref<AssetSpecAttr[]>([]);
const fileAddressPrefix = ref('');
const skuImagePreview = ref('');
@@ -264,10 +262,11 @@ const skuRules: FormRules = {
};
// 打开弹窗
const openDialog = (row: { id: string; name: string; type?: string }) => {
const openDialog = (row: { id: string; name: string; type?: string; unlimitedStock?: boolean }) => {
assetId.value = row.id;
assetName.value = row.name;
assetType.value = row.type || '';
unlimitedStock.value = row.unlimitedStock || false;
dialogVisible.value = true;
resetQuery();
getSkuList();
@@ -479,6 +478,12 @@ const onDeleteSku = (row: any) => {
.catch(() => {});
};
// 生成库存
const onGenerateStock = (row: any) => {
// TODO: 实现生成库存功能
ElMessage.info(`生成库存功能待实现SKU: ${row.skuName}`);
};
// 重置 SKU 表单
const resetSkuForm = () => {
skuForm.skuName = '';

View File

@@ -112,6 +112,7 @@ interface AssetRow {
onlineTime: string;
offlineTime: string;
status: number;
unlimitedStock: boolean;
createdAt: string;
updatedAt: string;
}
@@ -222,7 +223,12 @@ const onEdit = (row: AssetRow) => {
// 管理SKU
const onAddSku = (row: AssetRow) => {
skuDialogRef.value.openDialog(row);
skuDialogRef.value.openDialog({
id: row.id,
name: row.name,
type: row.type,
unlimitedStock: row.unlimitedStock,
});
};
// 分页大小改变