|
|
@@ -250,11 +250,54 @@
|
|
|
@pagination="getList"
|
|
|
/>
|
|
|
</el-card>
|
|
|
- </div>
|
|
|
+ <!-- 库存修改弹框 -->
|
|
|
+ <el-dialog v-model="inventoryDialog.visible" title="修改库存" width="500px" :close-on-click-modal="false">
|
|
|
+ <div v-loading="inventoryDialog.loading">
|
|
|
+ <el-form ref="inventoryFormRef" :model="inventoryForm" :rules="inventoryRules" label-width="110px">
|
|
|
+ <el-form-item label="总库存" prop="totalInventory">
|
|
|
+ <el-input-number
|
|
|
+ v-model="inventoryForm.totalInventory"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="请输入总库存"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="当前可用库存" prop="nowInventory">
|
|
|
+ <el-input-number
|
|
|
+ v-model="inventoryForm.nowInventory"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="请输入当前可用库存"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="虚拟库存" prop="virtualInventory">
|
|
|
+ <el-input-number
|
|
|
+ v-model="inventoryForm.virtualInventory"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder="请输入虚拟库存"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="inventoryDialog.visible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="inventoryDialog.submitLoading" @click="submitInventory">确定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="Base" lang="ts">
|
|
|
-import { listBase, getBase, delBase, brandList, categoryTree, shelfReview, changeProductType, getProductStatusCount } from '@/api/product/base';
|
|
|
+import { listBase, getBase, delBase, brandList ,updateBase, categoryTree, shelfReview, changeProductType, getProductStatusCount } from '@/api/product/base';
|
|
|
+import { getPriceInventory, updatePriceInventory } from '@/api/product/priceInventory';
|
|
|
+import { PriceInventoryForm } from '@/api/product/priceInventory/types';
|
|
|
import { BaseVO, BaseQuery, BaseForm, StatusCountVo } from '@/api/product/base/types';
|
|
|
import { BrandVO } from '@/api/product/brand/types';
|
|
|
import { listBrand } from '@/api/product/brand';
|
|
|
@@ -529,14 +572,13 @@ const handleView = (row: BaseVO) => {
|
|
|
|
|
|
/** 上下架操作 */
|
|
|
const handleShelf = async (row: BaseVO) => {
|
|
|
- // productStatus字段定义为string类型:1=已上架,0=下架,2=上架中
|
|
|
- const isOnShelf = row.productStatus === '1';
|
|
|
+ const isOnShelf = row.productStatus === 1;
|
|
|
const action = isOnShelf ? '下架' : '上架';
|
|
|
await proxy?.$modal.confirm(`确认${action}该商品吗?`);
|
|
|
|
|
|
try {
|
|
|
// 上架:状态改为2(上架中),下架:状态改为0(下架)
|
|
|
- const productStatus = isOnShelf ? '0' : '2';
|
|
|
+ const productStatus = isOnShelf ? 0 : 2;
|
|
|
await shelfReview({
|
|
|
id: row.id,
|
|
|
productStatus: productStatus,
|
|
|
@@ -556,10 +598,65 @@ const handlePrice = (row: BaseVO) => {
|
|
|
// TODO: 打开价格设置对话框
|
|
|
};
|
|
|
|
|
|
-/** 供货存管理 */
|
|
|
-const handleSupply = (row: BaseVO) => {
|
|
|
- console.log('供货存管理', row);
|
|
|
- // TODO: 打开供货存管理对话框
|
|
|
+/** 库存修改弹框 */
|
|
|
+const inventoryDialog = reactive({
|
|
|
+ visible: false,
|
|
|
+ loading: false,
|
|
|
+ submitLoading: false
|
|
|
+});
|
|
|
+
|
|
|
+const inventoryFormRef = ref<ElFormInstance>();
|
|
|
+
|
|
|
+const inventoryForm = reactive<PriceInventoryForm>({
|
|
|
+ productId: undefined,
|
|
|
+ totalInventory: undefined,
|
|
|
+ nowInventory: undefined,
|
|
|
+ virtualInventory: undefined
|
|
|
+});
|
|
|
+
|
|
|
+const inventoryRules = {
|
|
|
+ totalInventory: [{ required: true, message: '总库存不能为空', trigger: 'blur' }],
|
|
|
+ nowInventory: [{ required: true, message: '当前可用库存不能为空', trigger: 'blur' }],
|
|
|
+ virtualInventory: [{ required: true, message: '虚拟库存不能为空', trigger: 'blur' }]
|
|
|
+};
|
|
|
+
|
|
|
+/** 打开库存修改弹框 */
|
|
|
+const handleSupply = async (row: BaseVO) => {
|
|
|
+ inventoryForm.id = row.id;
|
|
|
+ inventoryForm.totalInventory = undefined;
|
|
|
+ inventoryForm.nowInventory = undefined;
|
|
|
+ inventoryForm.virtualInventory = undefined;
|
|
|
+ inventoryDialog.loading = true;
|
|
|
+ inventoryDialog.visible = true;
|
|
|
+ try {
|
|
|
+ const res = await getBase(row.id);
|
|
|
+ if (res.data) {
|
|
|
+ inventoryForm.totalInventory = res.data.totalInventory;
|
|
|
+ inventoryForm.nowInventory = res.data.nowInventory;
|
|
|
+ inventoryForm.virtualInventory = res.data.virtualInventory;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取库存信息失败:', error);
|
|
|
+ } finally {
|
|
|
+ inventoryDialog.loading = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 提交库存修改 */
|
|
|
+const submitInventory = async () => {
|
|
|
+ await inventoryFormRef.value?.validate();
|
|
|
+ inventoryDialog.submitLoading = true;
|
|
|
+ try {
|
|
|
+ await updateBase({ ...inventoryForm });
|
|
|
+ proxy?.$modal.msgSuccess('库存修改成功');
|
|
|
+ inventoryDialog.visible = false;
|
|
|
+ await getList();
|
|
|
+ } catch (error) {
|
|
|
+ console.error('库存修改失败:', error);
|
|
|
+ proxy?.$modal.msgError('库存修改失败');
|
|
|
+ } finally {
|
|
|
+ inventoryDialog.submitLoading = false;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
/** 停售操作 */
|