在资产管理中新增库存类型字段,支持有限库存和无限库存两种模式,编辑时禁止修改库存类型,同时在SKU管理中为无限库存资产新增生成库存按钮并移除库存数量编辑功能
This commit is contained in:
@@ -62,6 +62,14 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</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>
|
</el-row>
|
||||||
|
|
||||||
<!-- 分类属性值选择 -->
|
<!-- 分类属性值选择 -->
|
||||||
@@ -486,6 +494,7 @@ interface RuleForm {
|
|||||||
description: string;
|
description: string;
|
||||||
onlineTime: string;
|
onlineTime: string;
|
||||||
offlineTime: string;
|
offlineTime: string;
|
||||||
|
unlimitedStock: boolean;
|
||||||
physicalAssetConfig: {
|
physicalAssetConfig: {
|
||||||
shipping: {
|
shipping: {
|
||||||
deliveryMethod: string;
|
deliveryMethod: string;
|
||||||
@@ -588,6 +597,7 @@ const getInitialForm = (): RuleForm => ({
|
|||||||
description: '',
|
description: '',
|
||||||
onlineTime: '',
|
onlineTime: '',
|
||||||
offlineTime: '',
|
offlineTime: '',
|
||||||
|
unlimitedStock: false,
|
||||||
physicalAssetConfig: {
|
physicalAssetConfig: {
|
||||||
shipping: {
|
shipping: {
|
||||||
deliveryMethod: 'express',
|
deliveryMethod: 'express',
|
||||||
@@ -892,6 +902,7 @@ const openDialog = (row?: any, edit?: boolean) => {
|
|||||||
ruleForm.description = data.description || '';
|
ruleForm.description = data.description || '';
|
||||||
ruleForm.onlineTime = data.onlineTime || '';
|
ruleForm.onlineTime = data.onlineTime || '';
|
||||||
ruleForm.offlineTime = data.offlineTime || '';
|
ruleForm.offlineTime = data.offlineTime || '';
|
||||||
|
ruleForm.unlimitedStock = data.unlimitedStock || false;
|
||||||
|
|
||||||
// 主图预览 (支持 imageUrl 和 fileURL)
|
// 主图预览 (支持 imageUrl 和 fileURL)
|
||||||
const mainImg = data.imageUrl || data.fileURL;
|
const mainImg = data.imageUrl || data.fileURL;
|
||||||
@@ -1096,6 +1107,9 @@ const buildRequestBody = async (): Promise<any> => {
|
|||||||
body.offlineTime = ruleForm.offlineTime;
|
body.offlineTime = ruleForm.offlineTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 库存类型
|
||||||
|
body.unlimitedStock = ruleForm.unlimitedStock;
|
||||||
|
|
||||||
// 主图 (已在上传时直接赋值给 ruleForm.mainImage)
|
// 主图 (已在上传时直接赋值给 ruleForm.mainImage)
|
||||||
if (ruleForm.mainImage) {
|
if (ruleForm.mainImage) {
|
||||||
body.imageURL = ruleForm.mainImage;
|
body.imageURL = ruleForm.mainImage;
|
||||||
|
|||||||
@@ -78,9 +78,10 @@
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="120" align="center">
|
<el-table-column label="操作" width="180" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button size="small" text type="primary" @click="onEditSku(scope.row)">编辑</el-button>
|
<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>
|
<el-button size="small" text type="danger" @click="onDeleteSku(scope.row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -131,10 +132,6 @@
|
|||||||
<el-input-number v-model="skuForm.price" :min="0" :precision="2" :step="0.01" controls-position="right" />
|
<el-input-number v-model="skuForm.price" :min="0" :precision="2" :step="0.01" controls-position="right" />
|
||||||
<span style="margin-left: 8px">元</span>
|
<span style="margin-left: 8px">元</span>
|
||||||
</el-form-item>
|
</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-form-item label="状态">
|
||||||
<el-radio-group v-model="skuForm.status">
|
<el-radio-group v-model="skuForm.status">
|
||||||
<el-radio :value="1">激活</el-radio>
|
<el-radio :value="1">激活</el-radio>
|
||||||
@@ -199,6 +196,7 @@ const editSkuId = ref('');
|
|||||||
const assetId = ref('');
|
const assetId = ref('');
|
||||||
const assetName = ref('');
|
const assetName = ref('');
|
||||||
const assetType = ref('');
|
const assetType = ref('');
|
||||||
|
const unlimitedStock = ref(false); // 资产是否无限库存
|
||||||
const assetSpecAttrs = ref<AssetSpecAttr[]>([]);
|
const assetSpecAttrs = ref<AssetSpecAttr[]>([]);
|
||||||
const fileAddressPrefix = ref('');
|
const fileAddressPrefix = ref('');
|
||||||
const skuImagePreview = 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;
|
assetId.value = row.id;
|
||||||
assetName.value = row.name;
|
assetName.value = row.name;
|
||||||
assetType.value = row.type || '';
|
assetType.value = row.type || '';
|
||||||
|
unlimitedStock.value = row.unlimitedStock || false;
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
resetQuery();
|
resetQuery();
|
||||||
getSkuList();
|
getSkuList();
|
||||||
@@ -479,6 +478,12 @@ const onDeleteSku = (row: any) => {
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 生成库存
|
||||||
|
const onGenerateStock = (row: any) => {
|
||||||
|
// TODO: 实现生成库存功能
|
||||||
|
ElMessage.info(`生成库存功能待实现,SKU: ${row.skuName}`);
|
||||||
|
};
|
||||||
|
|
||||||
// 重置 SKU 表单
|
// 重置 SKU 表单
|
||||||
const resetSkuForm = () => {
|
const resetSkuForm = () => {
|
||||||
skuForm.skuName = '';
|
skuForm.skuName = '';
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ interface AssetRow {
|
|||||||
onlineTime: string;
|
onlineTime: string;
|
||||||
offlineTime: string;
|
offlineTime: string;
|
||||||
status: number;
|
status: number;
|
||||||
|
unlimitedStock: boolean;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
@@ -222,7 +223,12 @@ const onEdit = (row: AssetRow) => {
|
|||||||
|
|
||||||
// 管理SKU
|
// 管理SKU
|
||||||
const onAddSku = (row: AssetRow) => {
|
const onAddSku = (row: AssetRow) => {
|
||||||
skuDialogRef.value.openDialog(row);
|
skuDialogRef.value.openDialog({
|
||||||
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
type: row.type,
|
||||||
|
unlimitedStock: row.unlimitedStock,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 分页大小改变
|
// 分页大小改变
|
||||||
|
|||||||
Reference in New Issue
Block a user