This commit is contained in:
mkm 2024-08-01 18:04:21 +08:00
parent 615d64c237
commit 4945bbbe62
6 changed files with 464 additions and 3 deletions

View File

@ -2,7 +2,7 @@ NODE_ENV = 'development'
VITE_NOW_TYPE = 'dist'
# Base API
VITE_APP_BASE_URL='http://192.168.1.22:8545'
VITE_APP_BASE_URL='http://192.168.1.231:8545'
# VITE_APP_BASE_URL='https://test-multi-store.lihaink.cn'
# VITE_APP_BASE_URL='https://multi-store.lihaink.cn'

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

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 采购订单列表
export function apiPurchaseOrderLists(params: any) {
return request.get({ url: '/purchase_order/purchaseorder/lists', params })
}
// 添加采购订单
export function apiPurchaseOrderAdd(params: any) {
return request.post({ url: '/purchase_order/purchaseorder/add', params })
}
// 编辑采购订单
export function apiPurchaseOrderEdit(params: any) {
return request.post({ url: '/purchase_order/purchaseorder/edit', params })
}
// 删除采购订单
export function apiPurchaseOrderDelete(params: any) {
return request.post({ url: '/purchase_order/purchaseorder/delete', params })
}
// 采购订单详情
export function apiPurchaseOrderDetail(params: any) {
return request.get({ url: '/purchase_order/purchaseorder/detail', params })
}

View File

@ -0,0 +1,127 @@
<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="store_id">
<el-input v-model="formData.store_id" clearable placeholder="请输入所属商户" :readonly="true"/>
</el-form-item>
<el-form-item label="零售订单id" prop="order_arr">
<el-input v-model="formData.order_arr" clearable placeholder="请输入零售订单id" :readonly="true"/>
</el-form-item>
<el-form-item label="单据编号" prop="order_id">
<el-input v-model="formData.order_id" clearable placeholder="请输入单据编号" :readonly="true"/>
</el-form-item>
<el-form-item label="单据金额" prop="total">
<el-input v-model="formData.total" clearable placeholder="请输入单据金额" :readonly="true"/>
</el-form-item>
<el-form-item label="实际金额" prop="actual">
<el-input v-model="formData.actual" clearable placeholder="请输入实际金额" :readonly="true"/>
</el-form-item>
<el-form-item label="实收金额" prop="money">
<el-input v-model="formData.money" clearable placeholder="请输入实收金额" :readonly="true"/>
</el-form-item>
<el-form-item label="是否支付" prop="paid">
<el-input v-model="formData.paid" clearable placeholder="请输入是否支付" :readonly="true"/>
</el-form-item>
<el-form-item label="单据附件" prop="file">
<el-input v-model="formData.file" clearable placeholder="请输入单据附件" :readonly="true"/>
</el-form-item>
<el-form-item label="备注信息" prop="data">
<el-input v-model="formData.data" clearable placeholder="请输入备注信息" :readonly="true"/>
</el-form-item>
<el-form-item label="是否采购" prop="is_opurchase">
<el-input v-model="formData.is_opurchase" clearable placeholder="请输入是否采购" :readonly="true"/>
</el-form-item>
<el-form-item label="类型" prop="is_mer">
<el-input v-model="formData.is_mer" clearable placeholder="请输入类型" :readonly="true"/>
</el-form-item>
<el-form-item label="入库状态" prop="storage">
<el-input v-model="formData.storage" clearable placeholder="请输入入库状态" :readonly="true"/>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="purchaseOrderDETAILS">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiPurchaseOrderAdd, apiPurchaseOrderEdit, apiPurchaseOrderDetail } from '@/api/purchase_order'
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: '',
store_id: '',
order_arr: '',
order_id: '',
total: '',
actual: '',
money: '',
paid: '',
file: '',
data: '',
is_opurchase: '',
is_mer: '',
storage: '',
})
//
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 apiPurchaseOrderDetail({
id: row.id
})
setFormData(data)
}
//
const open = () => {
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,158 @@
<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="store_id">
<el-input v-model="formData.store_id" clearable placeholder="请输入所属商户" :readonly="false"/>
</el-form-item>
<el-form-item label="零售订单id" prop="order_arr">
<el-input v-model="formData.order_arr" clearable placeholder="请输入零售订单id" :readonly="false"/>
</el-form-item>
<el-form-item label="单据编号" prop="order_id">
<el-input v-model="formData.order_id" clearable placeholder="请输入单据编号" :readonly="false"/>
</el-form-item>
<el-form-item label="单据金额" prop="total">
<el-input v-model="formData.total" clearable placeholder="请输入单据金额" :readonly="false"/>
</el-form-item>
<el-form-item label="实际金额" prop="actual">
<el-input v-model="formData.actual" clearable placeholder="请输入实际金额" :readonly="false"/>
</el-form-item>
<el-form-item label="实收金额" prop="money">
<el-input v-model="formData.money" clearable placeholder="请输入实收金额" :readonly="false"/>
</el-form-item>
<el-form-item label="是否支付" prop="paid">
<el-input v-model="formData.paid" clearable placeholder="请输入是否支付" :readonly="false"/>
</el-form-item>
<el-form-item label="单据附件" prop="file">
<el-input v-model="formData.file" clearable placeholder="请输入单据附件" :readonly="false"/>
</el-form-item>
<el-form-item label="备注信息" prop="data">
<el-input v-model="formData.data" clearable placeholder="请输入备注信息" :readonly="false"/>
</el-form-item>
<el-form-item label="是否采购" prop="is_opurchase">
<el-input v-model="formData.is_opurchase" clearable placeholder="请输入是否采购" :readonly="false"/>
</el-form-item>
<el-form-item label="类型" prop="is_mer">
<el-input v-model="formData.is_mer" clearable placeholder="请输入类型" :readonly="false"/>
</el-form-item>
<el-form-item label="入库状态" prop="storage">
<el-input v-model="formData.storage" clearable placeholder="请输入入库状态" :readonly="false"/>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="purchaseOrderEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiPurchaseOrderAdd, apiPurchaseOrderEdit, apiPurchaseOrderDetail } from '@/api/purchase_order'
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: '',
store_id: '',
order_arr: '',
order_id: '',
total: '',
actual: '',
money: '',
paid: '',
file: '',
data: '',
is_opurchase: '',
is_mer: '',
storage: '',
})
//
const formRules = reactive<any>({
store_id: [{
required: true,
message: '请输入所属商户',
trigger: ['blur']
}],
order_id: [{
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 apiPurchaseOrderDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiPurchaseOrderEdit(data)
: await apiPurchaseOrderAdd(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,150 @@
<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_id"
clearable
placeholder="请输入所属商户"
/>
</el-form-item>
<el-form-item label="单据编号" prop="order_id">
<el-input
class="w-[280px]"
v-model="queryParams.order_id"
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="['purchase_order.purchase_order/add']"
type="primary"
@click="submitOrder"
>
<template #icon>
<icon name="el-icon-Plus" />
</template>
提交今日商户采购订单
</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="store_id" show-overflow-tooltip />
<el-table-column label="单据编号" prop="order_id" show-overflow-tooltip />
<el-table-column label="单据金额" prop="total" show-overflow-tooltip />
<el-table-column label="实际金额" prop="actual" show-overflow-tooltip />
<el-table-column label="实收金额" prop="money" show-overflow-tooltip />
<el-table-column label="备注信息" prop="data" show-overflow-tooltip />
<el-table-column label="是否采购" prop="is_opurchase" show-overflow-tooltip />
<el-table-column label="类型" prop="is_mer" show-overflow-tooltip />
<el-table-column label="入库状态" prop="storage" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['purchase_order.purchase_order/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['purchase_order.purchase_order/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="purchaseOrderLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import {
apiPurchaseOrderLists,
apiPurchaseOrderDelete,
apiPurchaseOrderAdd
} from '@/api/purchase_order'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
import { ElMessage, type FormInstance } from 'element-plus'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
store_id: '',
order_id: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiPurchaseOrderLists,
params: queryParams
})
//
//
const submitOrder = async () => {
apiPurchaseOrderAdd().then((res) => {
ElMessage.success('提交成功')
})
}
//
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 apiPurchaseOrderDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -47,7 +47,7 @@
>
删除
</el-button>
<router-link
<!-- <router-link
:to="{
path: 'product_import'
}"
@ -55,7 +55,7 @@
v-perms="['store_product.store_product/add']"
>
<el-button type="primary"> 导入商品到门店 </el-button>
</router-link>
</router-link> -->
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />