This commit is contained in:
mkm 2024-07-31 18:06:50 +08:00
parent f0f2380d13
commit eb4a2b6eda
9 changed files with 1186 additions and 0 deletions

26
src/api/warehouse.ts Normal file
View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 仓库信息列表
export function apiWarehouseLists(params: any) {
return request.get({ url: '/warehouse/warehouse/lists', params })
}
// 添加仓库信息
export function apiWarehouseAdd(params: any) {
return request.post({ url: '/warehouse/warehouse/add', params })
}
// 编辑仓库信息
export function apiWarehouseEdit(params: any) {
return request.post({ url: '/warehouse/warehouse/edit', params })
}
// 删除仓库信息
export function apiWarehouseDelete(params: any) {
return request.post({ url: '/warehouse/warehouse/delete', params })
}
// 仓库信息详情
export function apiWarehouseDetail(params: any) {
return request.get({ url: '/warehouse/warehouse/detail', params })
}

View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 商品仓储信息列表
export function apiWarehouseProductLists(params: any) {
return request.get({ url: '/warehouse_product/warehouseproduct/lists', params })
}
// 添加商品仓储信息
export function apiWarehouseProductAdd(params: any) {
return request.post({ url: '/warehouse_product/warehouseproduct/add', params })
}
// 编辑商品仓储信息
export function apiWarehouseProductEdit(params: any) {
return request.post({ url: '/warehouse_product/warehouseproduct/edit', params })
}
// 删除商品仓储信息
export function apiWarehouseProductDelete(params: any) {
return request.post({ url: '/warehouse_product/warehouseproduct/delete', params })
}
// 商品仓储信息详情
export function apiWarehouseProductDetail(params: any) {
return request.get({ url: '/warehouse_product/warehouseproduct/detail', params })
}

View File

@ -0,0 +1,232 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form class="mb-[-16px]" :model="queryParams" inline>
<el-form-item label="门店" prop="store_id">
<!-- <el-input class="w-[280px]" v-model="queryParams.store_name" clearable placeholder="请输入门店id" /> -->
<el-select
v-model="queryParams.store_id"
filterable
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-form-item>
<el-form-item label="用户" prop="uid">
<!-- <el-input class="w-[280px]" v-model="queryParams.uid" clearable placeholder="请输入用户id" /> -->
<el-select
v-model="queryParams.user_id"
filterable
remote
reserve-keyword
placeholder="输入用户名称搜索"
remote-show-suffix
:remote-method="remoteMethodUser"
:loading="userloading"
style="width: 240px"
@change="resetPage"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="`${item.nickname} (ID:${item.id})`"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="时间" prop="create_time">
<el-date-picker
v-model="startEndTime"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
unlink-panels
:shortcuts="shortcuts"
@change="resetPage"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<!-- <el-button v-perms="['store_finance_flow.store_finance_flow/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button v-perms="['store_finance_flow.store_finance_flow/delete']" :disabled="!selectData.length"
@click="handleDelete(selectData)">
删除
</el-button> -->
<div>
<el-table
:data="pager.lists"
@selection-change="handleSelectionChange"
row-key="id"
:tree-props="{ children: 'list' }"
>
<el-table-column label="ID" prop="id" min-width="100" show-overflow-tooltip />
<el-table-column
label="交易单号"
prop="order_sn"
min-width="120"
show-overflow-tooltip
/>
<el-table-column
label="交易时间"
prop="create_time"
min-width="120"
show-overflow-tooltip
/>
<el-table-column
label="金额"
prop="number"
min-width="100"
show-overflow-tooltip
>
<template #default="{ row }">
<span v-if="row.number > 0" class="text-success">{{ row.number }}</span>
<span v-else class="text-danger">{{ row.number }}</span>
</template>
</el-table-column>
<el-table-column label="门店名称" prop="store_name" show-overflow-tooltip />
<el-table-column
label="用户"
prop="nickname"
min-width="80"
show-overflow-tooltip
/>
<el-table-column
label="收益/扣除"
prop="financial_type_name"
show-overflow-tooltip
/>
<el-table-column label="支付方式" prop="pay_type_name" show-overflow-tooltip />
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
<details-popup ref="detailsRef" :dict-data="dictData" />
</div>
</template>
<script lang="ts" setup name="storeFinanceFlowLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiStoreFinanceFlowLists, apiStoreFinanceFlowDelete } from '@/api/store_finance_flow'
import { apiSystemStoreLists } from '@/api/system_store'
import { apiUserLists } from '@/api/user'
import shortcuts from '@/utils/shortcuts'
import moment from 'moment'
//
const showEdit = ref(false)
//
const queryParams = reactive({
store_name: '',
store_id: '',
user_id: '',
create_time: '',
financial_type: 3,
financial_pm: 1,
start_time: '',
end_time: ''
})
const startEndTime = ref([])
watch(
() => startEndTime.value,
(n, o) => {
queryParams.start_time = moment(n[0]).format('YYYY-MM-DD') + ' 00:00:00'
queryParams.end_time = moment(n[1]).format('YYYY-MM-DD') + ' 23:59:59'
},
{ deep: true }
)
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiStoreFinanceFlowLists,
params: queryParams
})
getLists()
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)
})
}
const userloading = ref(false)
const userList = ref([])
const remoteMethodUser = (e = '') => {
userloading.value = true
apiUserLists({
nickname: e,
page_size: 50
})
.then((res) => {
userList.value = res.lists
setTimeout(() => {
userloading.value = false
}, 300)
})
.catch((err) => {
setTimeout(() => {
userloading.value = false
}, 300)
})
}
</script>

View File

@ -0,0 +1,107 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
title="详情"
:async="true"
width="550px"
:cancelButtonText="false"
:confirmButtonText="false"
>
<el-form ref="formRef" :model="formData" label-width="90px">
<el-form-item label="仓库名称" prop="name">
<el-input v-model="formData.name" clearable placeholder="请输入仓库名称" :readonly="true"/>
</el-form-item>
<el-form-item label="仓库编号" prop="code">
<el-input v-model="formData.code" clearable placeholder="请输入仓库编号" :readonly="true"/>
</el-form-item>
<el-form-item label="联系人员" prop="contacts">
<el-input v-model="formData.contacts" clearable placeholder="请输入联系人员" :readonly="true"/>
</el-form-item>
<el-form-item label="联系电话" prop="tel">
<el-input v-model="formData.tel" clearable placeholder="请输入联系电话" :readonly="true"/>
</el-form-item>
<el-form-item label="仓库地址" prop="address">
<el-input v-model="formData.address" clearable placeholder="请输入仓库地址" :readonly="true"/>
</el-form-item>
<el-form-item label="备注信息" prop="notes">
<el-input v-model="formData.notes" clearable placeholder="请输入备注信息" :readonly="true"/>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="formData.sort" clearable placeholder="请输入排序" :readonly="true"/>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="warehouseDETAILS">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiWarehouseAdd, apiWarehouseEdit, apiWarehouseDetail } from '@/api/warehouse'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const formData = reactive({
id: '',
name: '',
code: '',
contacts: '',
tel: '',
address: '',
notes: '',
sort: '',
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiWarehouseDetail({
id: row.id
})
setFormData(data)
}
//
const open = () => {
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,133 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="仓库名称" prop="name">
<el-input v-model="formData.name" clearable placeholder="请输入仓库名称" :readonly="false"/>
</el-form-item>
<el-form-item label="仓库编号" prop="code">
<el-input v-model="formData.code" clearable placeholder="请输入仓库编号" :readonly="false"/>
</el-form-item>
<el-form-item label="联系人员" prop="contacts">
<el-input v-model="formData.contacts" clearable placeholder="请输入联系人员" :readonly="false"/>
</el-form-item>
<el-form-item label="联系电话" prop="tel">
<el-input v-model="formData.tel" clearable placeholder="请输入联系电话" :readonly="false"/>
</el-form-item>
<el-form-item label="仓库地址" prop="address">
<el-input v-model="formData.address" clearable placeholder="请输入仓库地址" :readonly="false"/>
</el-form-item>
<el-form-item label="备注信息" prop="notes">
<el-input v-model="formData.notes" clearable placeholder="请输入备注信息" :readonly="false"/>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="formData.sort" clearable placeholder="请输入排序" :readonly="false"/>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="warehouseEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiWarehouseAdd, apiWarehouseEdit, apiWarehouseDetail } from '@/api/warehouse'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑仓库信息' : '新增仓库信息'
})
//
const formData = reactive({
id: '',
name: '',
code: '',
contacts: '',
tel: '',
address: '',
notes: '',
sort: '',
})
//
const formRules = reactive<any>({
name: [{
required: true,
message: '请输入仓库名称',
trigger: ['blur']
}]
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiWarehouseDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiWarehouseEdit(data)
: await apiWarehouseAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,140 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="仓库名称" prop="name">
<el-input class="w-[280px]" v-model="queryParams.name" clearable placeholder="请输入仓库名称" />
</el-form-item>
<el-form-item label="联系人员" prop="contacts">
<el-input class="w-[280px]" v-model="queryParams.contacts" clearable placeholder="请输入联系人员" />
</el-form-item>
<el-form-item label="联系电话" prop="tel">
<el-input class="w-[280px]" v-model="queryParams.tel" clearable placeholder="请输入联系电话" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['admin.warehouse/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
v-perms="['admin.warehouse/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="" prop="id" show-overflow-tooltip />
<el-table-column label="仓库名称" prop="name" show-overflow-tooltip />
<el-table-column label="仓库编号" prop="code" show-overflow-tooltip />
<el-table-column label="联系人员" prop="contacts" show-overflow-tooltip />
<el-table-column label="联系电话" prop="tel" show-overflow-tooltip />
<el-table-column label="仓库地址" prop="address" show-overflow-tooltip />
<el-table-column label="备注信息" prop="notes" show-overflow-tooltip />
<el-table-column label="排序" prop="sort" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['admin.warehouse/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['admin.warehouse/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="warehouseLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiWarehouseLists, apiWarehouseDelete } from '@/api/warehouse'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
name: '',
contacts: '',
tel: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiWarehouseLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiWarehouseDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -0,0 +1,118 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
title="详情"
:async="true"
width="550px"
:cancelButtonText="false"
:confirmButtonText="false"
>
<el-form ref="formRef" :model="formData" label-width="90px">
<el-form-item label="仓库ID" prop="warehouse_id">
<el-input v-model="formData.warehouse_id" clearable placeholder="请输入仓库ID" :readonly="true"/>
</el-form-item>
<el-form-item label="商品ID" prop="product_id">
<el-input v-model="formData.product_id" clearable placeholder="请输入商品ID" :readonly="true"/>
</el-form-item>
<el-form-item label="0 = 出库 1 = 获得" prop="financial_pm">
<el-select class="flex-1" v-model="formData.financial_pm" clearable placeholder="请选择0 = 出库 1 = 获得" :disabled="true">
<el-option
v-for="(item, index) in dictData."
:key="index"
:label="item.name"
:value="parseInt(item.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="批次" prop="batch">
<el-input v-model="formData.batch" clearable placeholder="请输入批次" :readonly="true"/>
</el-form-item>
<el-form-item label="数量" prop="nums">
<el-input v-model="formData.nums" clearable placeholder="请输入数量" :readonly="true"/>
</el-form-item>
<el-form-item label="价格" prop="price">
<el-input v-model="formData.price" clearable placeholder="请输入价格" :readonly="true"/>
</el-form-item>
<el-form-item label="总价" prop="total_price">
<el-input v-model="formData.total_price" clearable placeholder="请输入总价" :readonly="true"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-input v-model="formData.status" clearable placeholder="请输入状态" :readonly="true"/>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="warehouseProductDETAILS">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiWarehouseProductAdd, apiWarehouseProductEdit, apiWarehouseProductDetail } from '@/api/warehouse_product'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const formData = reactive({
id: '',
warehouse_id: '',
product_id: '',
financial_pm: '',
batch: '',
nums: '',
price: '',
total_price: '',
status: '',
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiWarehouseProductDetail({
id: row.id
})
setFormData(data)
}
//
const open = () => {
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,232 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="仓库" prop="warehouse_id">
<el-input
v-model="formData.warehouse_name"
clearable
placeholder="请输入仓库ID"
:readonly="false"
@click="showWarehouse = true"
/>
</el-form-item>
<el-form-item label="商品ID" prop="product_id">
<el-input
v-model="formData.product_id"
clearable
placeholder="请输入商品ID"
:readonly="false"
/>
</el-form-item>
<el-form-item label="状态" prop="financial_pm">
<el-select v-model="formData.financial_pm" clearable placeholder="请选择出入库">
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.warehouse_produc_pm"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="批次" prop="batch">
<el-input
v-model="formData.batch"
clearable
placeholder="请输入批次"
:readonly="false"
/>
</el-form-item>
<el-form-item label="数量" prop="nums">
<el-input
v-model="formData.nums"
clearable
placeholder="请输入数量"
:readonly="false"
/>
</el-form-item>
<el-form-item label="价格" prop="price">
<el-input
v-model="formData.price"
clearable
placeholder="请输入价格"
:readonly="false"
/>
</el-form-item>
<el-form-item label="总价" prop="total_price">
<el-input
v-model="formData.total_price"
clearable
placeholder="请输入总价"
:readonly="false"
/>
</el-form-item>
</el-form>
</popup>
<el-dialog v-model="showWarehouse" title="选择仓库" width="70%">
<warehouse-pop @onBindStore="onBindProduct"></warehouse-pop>
</el-dialog>
</div>
</template>
<script lang="ts" setup name="warehouseProductEdit">
import { watermarkProps, type FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import {
apiWarehouseProductAdd,
apiWarehouseProductEdit,
apiWarehouseProductDetail
} from '@/api/warehouse_product'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
const showWarehouse = ref(false) //
const productList = ref([])
const onBindProduct = (e: any[]) => {
e.forEach((item: any) => {
if (!productList.value.find((t: any) => t.id == item.id)) {
productList.value.push(item)
}
})
showWarehouse.value = false
}
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑商品仓储信息' : '新增商品仓储信息'
})
//
const formData = reactive({
id: '',
warehouse_id: '',
product_id: '',
financial_pm: '',
batch: '',
nums: '',
price: '',
total_price: '',
status: '',
warehouse_name: ''
})
//
const formRules = reactive<any>({
warehouse_id: [
{
required: true,
message: '请输入仓库ID',
trigger: ['blur']
}
],
product_id: [
{
required: true,
message: '请输入商品ID',
trigger: ['blur']
}
],
financial_pm: [
{
required: true,
message: '请选择0 = 出库 1 = 获得',
trigger: ['blur']
}
],
batch: [
{
required: true,
message: '请输入批次',
trigger: ['blur']
}
],
nums: [
{
required: true,
message: '请输入数量',
trigger: ['blur']
}
],
price: [
{
required: true,
message: '请输入价格',
trigger: ['blur']
}
],
total_price: [
{
required: true,
message: '请输入总价',
trigger: ['blur']
}
],
status: [
{
required: true,
message: '请输入状态',
trigger: ['blur']
}
]
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiWarehouseProductDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData }
mode.value == 'edit' ? await apiWarehouseProductEdit(data) : await apiWarehouseProductAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,172 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form class="mb-[-16px]" :model="queryParams" inline>
<el-form-item label="仓库ID" prop="warehouse_id">
<el-input
class="w-[280px]"
v-model="queryParams.warehouse_id"
clearable
placeholder="请输入仓库"
/>
</el-form-item>
<el-form-item label="商品" prop="product_id">
<el-input
class="w-[280px]"
v-model="queryParams.product_id"
clearable
placeholder="请输入商品"
/>
</el-form-item>
<el-form-item label="出入库状态" prop="financial_pm">
<el-select
style="width: 240px"
v-model="queryParams.financial_pm"
clearable
placeholder="请选择出入库"
>
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.warehouse_produc_pm"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button
v-perms="['warehouse_product.warehouse_product/add']"
type="primary"
@click="handleAdd"
>
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
v-perms="['warehouse_product.warehouse_product/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="" prop="id" show-overflow-tooltip />
<el-table-column label="仓库" prop="warehouse_id" show-overflow-tooltip />
<el-table-column label="商品" prop="product_id" show-overflow-tooltip />
<el-table-column
label="出入库"
prop="financial_pm_name"
show-overflow-tooltip
/>
<el-table-column label="批次" prop="batch" show-overflow-tooltip />
<el-table-column label="数量" prop="nums" show-overflow-tooltip />
<el-table-column label="价格" prop="price" show-overflow-tooltip />
<el-table-column label="总价" prop="total_price" show-overflow-tooltip />
<el-table-column label="状态" prop="status" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['warehouse_product.warehouse_product/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['warehouse_product.warehouse_product/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
</div>
</template>
<script lang="ts" setup name="warehouseProductLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiWarehouseProductLists, apiWarehouseProductDelete } from '@/api/warehouse_product'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
warehouse_id: '',
product_id: '',
financial_pm: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('warehouse_produc_pm')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiWarehouseProductLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiWarehouseProductDelete({ id })
getLists()
}
getLists()
</script>