Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #102 from Jzow/master
Browse files Browse the repository at this point in the history
Add product stock modal views
  • Loading branch information
Jzow authored Oct 20, 2023
2 parents 3f719e6 + 2472ffd commit e3b07c3
Show file tree
Hide file tree
Showing 5 changed files with 414 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/api/product/model/productModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface ProductStockResp {
id: number | string;
warehouseId: number | string;
warehouseName: string;
initStockQuantity: number;
lowStockQuantity: number;
highStockQuantity: number;
}
11 changes: 10 additions & 1 deletion src/api/product/product.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {defHttp} from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
import {BaseDataResp} from "@/api/model/baseModel";
import {ProductStockResp} from "@/api/product/model/productModel";

enum Api {
getBarCode = '/product/getBarCode',
getStock = '/product/getStock',
}

export function getBarCode() {
Expand All @@ -12,4 +13,12 @@ export function getBarCode() {
url: Api.getBarCode,
}
);
}

export function getStock() {
return defHttp.get<BaseDataResp<ProductStockResp>>(
{
url: Api.getStock,
}
);
}
122 changes: 122 additions & 0 deletions src/views/product/info/components/BatchSetPriceModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<template>
<a-modal
:title="title"
:width="500"
v-model:open="openPriceModal"
:confirm-loading="confirmLoading"
:mask-style="{'top':'93px','left':'154px'}"
:mask-closable="false"
@ok="handleOk"
@cancel="handleCancel"
style="top:30%;height: 30%;">
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="请输入价格">
<a-input-number placeholder="请输入价格" v-model:value="batchPrice" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>

<script lang="ts">
import { ref, reactive, UnwrapRef } from 'vue';
import {Button, Form, FormItem, InputNumber, Modal, Spin} from "ant-design-vue";
import {Rule} from 'ant-design-vue/es/form';
interface FormState {
batchPrice: number;
}
export default {
name: 'BatchSetPriceModal',
components: {
'a-modal': Modal,
'a-button': Button,
'a-spin': Spin,
'a-form': Form,
'a-form-item': FormItem,
'a-input-number': InputNumber
},
setup(_, context) {
const title = ref('批量设置');
const openPriceModal = ref(false);
const isReadOnly = ref(false);
const batchPrice = ref('');
const batchType = ref('');
const model = reactive({});
const labelCol = {
xs: { span: 24 },
sm: { span: 5 },
};
const wrapperCol = {
xs: { span: 24 },
sm: { span: 16 },
};
const confirmLoading = ref(false);
const formRef = ref();
const rules: Record<string, Rule[]> = {
batchPrice: [
{required: true, message: '请输入价格', trigger: 'change'},
]
}
const add = (type) => {
openPriceModal.value = true
batchType.value = type;
if (type === 'purchase') {
title.value = '采购价-批量设置';
} else if (type === 'retail') {
title.value = '零售价-批量设置';
} else if (type === 'sale') {
title.value = '销售价-批量设置';
} else if (type === 'low') {
title.value = '最低售价-批量设置';
}
// formRef.value.resetFields();
};
const edit = (record) => {
openPriceModal.value = true
};
const close = () => {
openPriceModal.value = false
};
const handleOk = () => {
const price = batchPrice.value
context.emit('ok', price, batchType.value);
openPriceModal.value = false
};
const handleCancel = () => {
close();
};
return {
title,
isReadOnly,
batchType,
model,
labelCol,
wrapperCol,
confirmLoading,
formRef,
add,
edit,
close,
handleOk,
handleCancel,
openPriceModal,
batchPrice,
rules
};
}
};
</script>

<style scoped>
</style>
107 changes: 107 additions & 0 deletions src/views/product/info/components/BatchSetStockModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<a-modal
:title="title"
:width="500"
v-model:open="openStockModal"
:confirm-loading="confirmLoading"
:mask-style="{'top':'93px','left':'154px'}"
:mask-closable="false"
@ok="handleOk"
@cancel="handleCancel"
style="top:30%;height: 30%;">
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="请输入数量">
<a-input-number placeholder="请输入数量" v-model:value="batchNumber" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>

<script lang="ts">
import { ref, reactive, UnwrapRef } from 'vue';
import {Button, Form, FormItem, InputNumber, Modal, Spin} from "ant-design-vue";
export default {
name: 'BatchSetStockModal',
components: {
'a-modal': Modal,
'a-button': Button,
'a-spin': Spin,
'a-form': Form,
'a-form-item': FormItem,
'a-input-number': InputNumber
},
setup(_, context) {
const title = ref('批量设置');
const openStockModal = ref(false);
const isReadOnly = ref(false);
const batchNumber = ref('');
const batchType = ref('');
const model = reactive({});
const labelCol = {
xs: { span: 24 },
sm: { span: 5 },
};
const wrapperCol = {
xs: { span: 24 },
sm: { span: 16 },
};
const confirmLoading = ref(false);
const formRef = ref();
const add = (type) => {
openStockModal.value = true
batchType.value = type;
if (type === 'initStock') {
title.value = '期初库存-批量设置';
} else if (type === 'lowSafeStock') {
title.value = '最低安全库存-批量设置';
} else if (type === 'highSafeStock') {
title.value = '最高安全库存-批量设置';
}
};
const edit = (record) => {
openStockModal.value = true
};
const close = () => {
openStockModal.value = false
};
const handleOk = () => {
const stockNumber = batchNumber.value
context.emit('ok', stockNumber, batchType.value);
openStockModal.value = false
};
const handleCancel = () => {
close();
};
return {
title,
isReadOnly,
batchType,
model,
labelCol,
wrapperCol,
confirmLoading,
formRef,
add,
edit,
close,
handleOk,
handleCancel,
openStockModal,
batchNumber,
};
}
};
</script>

<style scoped>
</style>
Loading

0 comments on commit e3b07c3

Please sign in to comment.