Compare commits

...

2 Commits

4 changed files with 105 additions and 41 deletions

View File

@ -2,9 +2,9 @@ NODE_ENV = 'production'
# Base API # Base API
# 测试域名 # 测试域名
# VITE_NOW_TYPE = 'dist/admin' VITE_NOW_TYPE = 'dist/admin'
# VITE_APP_BASE_URL='https://test-multi-store.lihaink.cn' # VITE_APP_BASE_URL='https://test-multi-store.lihaink.cn'
# VITE_APP_BASE_URL='http://127.0.0.1:8545' VITE_APP_BASE_URL='http://127.0.0.1:8545'
# 正式域名 # 正式域名
VITE_NOW_TYPE = 'build/admin' VITE_NOW_TYPE = 'build/admin'

View File

@ -1,16 +1,26 @@
<template> <template>
<div> <div>
<el-card class="!border-none mb-4" shadow="never"> <el-card class="!border-none mb-4" shadow="never">
<el-form <el-form class="mb-[-16px]" :model="queryParams" inline>
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="门店" prop="store_id"> <el-form-item label="门店" prop="store_id">
<el-select v-model="queryParams.store_id" filterable remote reserve-keyword <el-select
placeholder="输入门店名称搜索" remote-show-suffix :remote-method="remoteMethod" :loading="storeloading" v-model="queryParams.store_id"
style="width: 240px" @change="resetPage"> filterable
<el-option v-for="item in storeList" :key="item.id" :label="item.name" :value="item.id" /> remote
reserve-keyword
placeholder="输入门店名称搜索"
remote-show-suffix
:remote-method="remoteMethod"
:loading="storeloading"
style="width: 240px"
@change="resetPage"
>
<el-option
v-for="item in storeList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- <el-form-item label="导入人员" prop="admin_name"> <!-- <el-form-item label="导入人员" prop="admin_name">
@ -20,10 +30,22 @@
<el-input class="w-[280px]" v-model="queryParams.staff_name" @keydown.enter="resetPage" clearable placeholder="请输入门店确认人员" /> <el-input class="w-[280px]" v-model="queryParams.staff_name" @keydown.enter="resetPage" clearable placeholder="请输入门店确认人员" />
</el-form-item> --> </el-form-item> -->
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" <el-select
v-model="queryParams.status"
placeholder="输入门店名称搜索" placeholder="输入门店名称搜索"
style="width: 240px" @change="resetPage"> style="width: 240px"
<el-option v-for="item in [{id:1,name:'已入库'},{id:0,name:'待确认'},{id:-1,name:'库存不足'}]" :key="item.id" :label="item.name" :value="item.id" /> @change="resetPage"
>
<el-option
v-for="item in [
{ id: 1, name: '已入库' },
{ id: 0, name: '待确认' },
{ id: -1, name: '库存不足' }
]"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -44,10 +66,7 @@
<el-table-column label="门店确认人员" prop="staff_name" show-overflow-tooltip /> <el-table-column label="门店确认人员" prop="staff_name" show-overflow-tooltip />
<el-table-column label="商品图" prop="image" show-overflow-tooltip> <el-table-column label="商品图" prop="image" show-overflow-tooltip>
<template #default="{ row }"> <template #default="{ row }">
<el-image <el-image class="w-[40px] h-[40px]" :src="row.image" />
class="w-[40px] h-[40px]"
:src="row.image"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="商品" prop="store_name" /> <el-table-column label="商品" prop="store_name" />
@ -60,7 +79,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" prop="mark" /> <el-table-column label="备注" prop="mark" />
<el-table-column label="操作" width="120" fixed="right"> <!-- <el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<el-button <el-button
v-if="row.status !== 1" v-if="row.status !== 1"
@ -72,14 +91,20 @@
编辑库存 编辑库存
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column> -->
</el-table> </el-table>
</div> </div>
<div class="flex mt-4 justify-end"> <div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" /> <pagination v-model="pager" @change="getLists" />
</div> </div>
</el-card> </el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> <edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
</div> </div>
</template> </template>
@ -97,7 +122,6 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
// //
const showEdit = ref(false) const showEdit = ref(false)
// //
const queryParams = reactive({ const queryParams = reactive({
store_id: '', store_id: '',
@ -148,23 +172,24 @@ const handleDelete = async (id: number | any[]) => {
getLists() getLists()
const storeloading = ref(false); const storeloading = ref(false)
const storeList = ref([]); const storeList = ref([])
const remoteMethod = (e:string='') => { const remoteMethod = (e = '') => {
storeloading.value = true; storeloading.value = true
apiSystemStoreLists({ apiSystemStoreLists({
name: e, name: e,
page_size: 50 page_size: 50
}).then(res => { })
storeList.value = res.lists; .then((res) => {
storeList.value = res.lists
setTimeout(() => { setTimeout(() => {
storeloading.value = false; storeloading.value = false
}, 300) }, 300)
}).catch(err => { })
.catch((err) => {
setTimeout(() => { setTimeout(() => {
storeloading.value = false; storeloading.value = false
}, 300) }, 300)
}) })
} }
</script> </script>

View File

@ -88,6 +88,12 @@
min-width="100" min-width="100"
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column
label="库存"
prop="stock"
min-width="100"
show-overflow-tooltip
/>
<el-table-column label="分配库存" min-width="150"> <el-table-column label="分配库存" min-width="150">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number <el-input-number
@ -95,6 +101,7 @@
:min="1" :min="1"
:max="row.stock" :max="row.stock"
v-if="row.stock > 0" v-if="row.stock > 0"
@change="handleStock"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -162,6 +169,7 @@ const formRef = shallowRef<FormInstance>()
const { removeTab } = useMultipleTabs() const { removeTab } = useMultipleTabs()
const mode = ref('add') const mode = ref('add')
const warehouse_id = ref('') const warehouse_id = ref('')
const stock = ref(0)
// //
const formData = reactive({ const formData = reactive({
@ -184,6 +192,7 @@ const onBindStore = (e: any[]) => {
storeList.value.push(item) storeList.value.push(item)
} }
}) })
handleStock()
showStore.value = false showStore.value = false
} }
@ -213,6 +222,34 @@ const getUnitList = () => {
getUnitList() getUnitList()
const stock_type = ref(1) 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() const router = useRouter()
// //
@ -221,6 +258,10 @@ const handleSubmit = async () => {
ElMessage.error('请选择仓库') ElMessage.error('请选择仓库')
return return
} }
handleStock()
if (isSubmit.value == false) {
return
}
const product_arr = productList.value.map((item: any) => { const product_arr = productList.value.map((item: any) => {
return { return {
id: item.product_id, id: item.product_id,
@ -236,7 +277,6 @@ const handleSubmit = async () => {
warehouse_id: warehouse_id.value warehouse_id: warehouse_id.value
}).then((res) => { }).then((res) => {
removeTab() removeTab()
return false
if (res.code == 1) { if (res.code == 1) {
ElMessage.success(res.msg) ElMessage.success(res.msg)
setTimeout(() => { setTimeout(() => {

View File

@ -125,7 +125,6 @@
type="danger" type="danger"
link link
@click="handleDelete(row.id)" @click="handleDelete(row.id)"
v-if="row.status == 0"
> >
删除 删除
</el-button> </el-button>