From 1bb586ba3f6f8f73c9387d0e60cb98eecb2d93e8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 7 Aug 2024 12:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E9=85=8D=E7=BD=AE=E9=94=99=E8=AF=AF=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E5=BA=93=E5=AD=98=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 4 +- .../store/system_store_storage/index.vue | 99 ++++++++++++------- src/views/warehouse/import.vue | 42 +++++++- src/views/warehouse_product/index.vue | 1 - 4 files changed, 105 insertions(+), 41 deletions(-) diff --git a/.env.production b/.env.production index c4a2a9ae..87b74375 100644 --- a/.env.production +++ b/.env.production @@ -3,8 +3,8 @@ NODE_ENV = 'production' # 测试域名 VITE_NOW_TYPE = 'dist/admin' -VITE_APP_BASE_URL='https://test-multi-store.lihaink.cn' -# VITE_APP_BASE_URL='http://127.0.0.1:8545' +# VITE_APP_BASE_URL='https://test-multi-store.lihaink.cn' +VITE_APP_BASE_URL='http://127.0.0.1:8545' # 正式域名 # VITE_NOW_TYPE = 'build/admin' diff --git a/src/views/store/system_store_storage/index.vue b/src/views/store/system_store_storage/index.vue index ee8df986..7c83a19a 100644 --- a/src/views/store/system_store_storage/index.vue +++ b/src/views/store/system_store_storage/index.vue @@ -1,16 +1,26 @@ @@ -97,7 +122,6 @@ const editRef = shallowRef>() // 是否显示编辑框 const showEdit = ref(false) - // 查询条件 const queryParams = reactive({ store_id: '', @@ -148,23 +172,24 @@ const handleDelete = async (id: number | any[]) => { getLists() -const storeloading = ref(false); -const storeList = ref([]); -const remoteMethod = (e:string='') => { - storeloading.value = true; +const storeloading = ref(false) +const storeList = ref([]) +const remoteMethod = (e = '') => { + storeloading.value = true apiSystemStoreLists({ name: e, page_size: 50 - }).then(res => { - storeList.value = res.lists; - setTimeout(()=>{ - storeloading.value = false; - },300) - }).catch(err => { - setTimeout(()=>{ - storeloading.value = false; - },300) }) + .then((res) => { + storeList.value = res.lists + setTimeout(() => { + storeloading.value = false + }, 300) + }) + .catch((err) => { + setTimeout(() => { + storeloading.value = false + }, 300) + }) } - diff --git a/src/views/warehouse/import.vue b/src/views/warehouse/import.vue index a75939ae..cb0edf9b 100644 --- a/src/views/warehouse/import.vue +++ b/src/views/warehouse/import.vue @@ -88,6 +88,12 @@ min-width="100" show-overflow-tooltip /> + @@ -162,6 +169,7 @@ const formRef = shallowRef() const { removeTab } = useMultipleTabs() const mode = ref('add') const warehouse_id = ref('') +const stock = ref(0) // 表单数据 const formData = reactive({ @@ -184,6 +192,7 @@ const onBindStore = (e: any[]) => { storeList.value.push(item) } }) + handleStock() showStore.value = false } @@ -213,6 +222,34 @@ const getUnitList = () => { getUnitList() const stock_type = ref(1) +const isSubmit = ref(true) + +const handleStock = () => { + // const counts = storeList.value.length + const product_arr = productList.value.map((item: any) => { + return { + id: item.product_id, + stock: item.new_stock || 0, + stocks: item.stock || 0 + } + }) + const store_arr = storeList.value.length + if (store_arr > 0 && product_arr.length > 0) { + try { + product_arr.forEach((item) => { + const stock = item.stock * store_arr + if (stock > item.stocks) { + isSubmit.value = false + throw new Error('超出仓库库存,请重新设置') + } + }) + } catch (e) { + ElMessage.error('超出仓库库存,请重新设置') + return + } + } + isSubmit.value = true +} const router = useRouter() // 提交按钮 @@ -221,6 +258,10 @@ const handleSubmit = async () => { ElMessage.error('请选择仓库') return } + handleStock() + if (isSubmit.value == false) { + return + } const product_arr = productList.value.map((item: any) => { return { id: item.product_id, @@ -236,7 +277,6 @@ const handleSubmit = async () => { warehouse_id: warehouse_id.value }).then((res) => { removeTab() - return false if (res.code == 1) { ElMessage.success(res.msg) setTimeout(() => { diff --git a/src/views/warehouse_product/index.vue b/src/views/warehouse_product/index.vue index 1e308514..4c08c831 100644 --- a/src/views/warehouse_product/index.vue +++ b/src/views/warehouse_product/index.vue @@ -125,7 +125,6 @@ type="danger" link @click="handleDelete(row.id)" - v-if="row.status == 0" > 删除