更新订单模块,包括基础URL更换、API接口调整、表单输入项更改、表格列更改、弹窗组件更改等。

This commit is contained in:
mkm 2024-09-30 16:44:59 +08:00
parent 4530c68ea3
commit ee27e58d53
7 changed files with 584 additions and 57 deletions

View File

@ -6,6 +6,6 @@ VITE_NOW_TYPE = 'dist'
# VITE_APP_BASE_URL='http://192.168.1.10:8546'
# VITE_APP_BASE_URL='https://test-multi-store.lihaink.cn'
# VITE_APP_BASE_URL='https://multi-store.lihaink.cn'
VITE_APP_BASE_URL='http://192.168.1.6:8545'
VITE_APP_BASE_URL='http://192.168.1.22:8545'
# VITE_APP_BASE_URL='https://ceshi-multi-store.lihaink.cn'

View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 预订单表列表
export function apiBeforehandOrderLists(params: any) {
return request.get({ url: '/beforehand_order/beforehandorder/lists', params })
}
// 添加预订单表
export function apiBeforehandOrderAdd(params: any) {
return request.post({ url: '/beforehand_order/beforehandorder/add', params })
}
// 编辑预订单表
export function apiBeforehandOrderEdit(params: any) {
return request.post({ url: '/beforehand_order/beforehandorder/edit', params })
}
// 删除预订单表
export function apiBeforehandOrderDelete(params: any) {
return request.post({ url: '/beforehand_order/beforehandorder/delete', params })
}
// 预订单表详情
export function apiBeforehandOrderDetail(params: any) {
return request.get({ url: '/beforehand_order/beforehandorder/detail', params })
}

View File

@ -0,0 +1,38 @@
import request from '@/utils/request'
// 预订单购物详情表列表
export function apiBeforehandOrderCartInfoLists(params: any) {
return request.get({ url: '/beforehand_order_cart_info/beforehandordercartinfo/lists', params })
}
// 添加预订单购物详情表
export function apiBeforehandOrderCartInfoAdd(params: any) {
return request.post({ url: '/beforehand_order_cart_info/beforehandordercartinfo/add', params })
}
// 编辑预订单购物详情表
export function apiBeforehandOrderCartInfoEdit(params: any) {
return request.post({ url: '/beforehand_order_cart_info/beforehandordercartinfo/edit', params })
}
export function apiBeforehandOrderCartInfoAppendAdd(params: any) {
return request.post({
url: '/beforehand_order_cart_info/beforehandordercartinfo/append_add',
params
})
}
// 删除预订单购物详情表
export function apiBeforehandOrderCartInfoDelete(params: any) {
return request.post({
url: '/beforehand_order_cart_info/beforehandordercartinfo/delete',
params
})
}
// 预订单购物详情表详情
export function apiBeforehandOrderCartInfoDetail(params: any) {
return request.get({
url: '/beforehand_order_cart_info/beforehandordercartinfo/detail',
params
})
}

View File

@ -93,7 +93,7 @@ import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
import { onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { apiWarehouseOrderAdd } from '@/api/warehouse_order'
import { apiBeforehandOrderAdd } from '@/api/beforehand_order'
import { apiWarehouseLists } from '@/api/warehouse'
import { apiSupplierLists } from '@/api/supplier'
@ -122,12 +122,6 @@ const formData = reactive({
completed_amount: 0
})
const warehouse = () => {
apiWarehouseLists({}).then((res) => {
warehouseList.value = res.lists
})
}
const showProduct = ref(false) //
//
const productList = ref([])
@ -183,7 +177,7 @@ const handleSubmit = async () => {
expiration_date: item.expiration_date
}
})
apiWarehouseOrderAdd({
apiBeforehandOrderAdd({
product_arr,
...formData
}).then((res) => {
@ -192,7 +186,7 @@ const handleSubmit = async () => {
// ElMessage.success(res.msg)
setTimeout(() => {
router.push({
path: '/warehouse/warehouse_order'
path: '/order/beforehand_order'
})
}, 2000)
// } else {
@ -200,5 +194,4 @@ const handleSubmit = async () => {
// }
})
}
warehouse()
</script>

View File

@ -0,0 +1,363 @@
<template>
<el-drawer v-model="showDialog" title="订单详情" :size="1200">
<div class="flex items-center justify-between m-4">
<div class="flex flex-col">
<div style="color: gray">单号</div>
<div style="color: black">{{ formData.order_id }}</div>
</div>
</div>
<div class="flex items-center justify-between m-4">
<div class="flex flex-col">
<div style="color: gray">总价</div>
<div style="color: black">{{ formData.total_price }}</div>
</div>
<div class="flex flex-col flex-2">
<div style="color: gray">时间</div>
<div style="color: black">{{ formData.create_time }}</div>
</div>
<el-button @click="xlsx(formData.id, 1)"> 打印订单 </el-button>
</div>
<el-button type="primary" @click="dialogShop = true"> 追加 </el-button>
<el-tabs v-model="activeName" class="demo-tabs mt-3" type="border-card">
<el-tab-pane label="明细" name="second">
<div>
<div>
<el-table :data="pager.lists" v-loading="pager.loading">
<el-table-column
label="商品信息"
prop="store_name"
show-overflow-tooltip
>
<template #default="{ row }">
<div class="flex items-center">
<el-image
:src="row.image"
class="w-16 h-16 mr-2"
:preview-teleported="true"
></el-image>
<div>{{ row.store_name }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="数量" prop="cart_num" 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="操作" 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="handleDeletes(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end" v-if="pager.lists.length < pager.count">
<pagination v-model="pager" @change="getLists" />
</div>
</div>
</el-tab-pane>
</el-tabs>
</el-drawer>
<el-dialog v-model="dialogShop" title="追加商品" width="1200">
<el-form ref="formRef" :model="updateInfo" label-width="90px">
<div class="mb-2">
<el-button type="primary" @click="showProduct = true">添加商品</el-button>
</div>
<el-table :data="productList">
<el-table-column label="商品ID" prop="id" show-overflow-tooltip />
<el-table-column label="商品图片" prop="image" min-width="80">
<template #default="{ row }">
<el-image
style="width: 50px; height: 50px"
:src="row.image"
:preview-teleported="true"
/>
</template>
</el-table-column>
<el-table-column
label="商品名称"
prop="store_name"
min-width="180"
show-overflow-tooltip
/>
<el-table-column
label="分类"
prop="cate_name"
min-width="80"
show-overflow-tooltip
/>
<el-table-column
label="单位"
prop="unit_name"
min-width="80"
show-overflow-tooltip
/>
<el-table-column label="数量" min-width="150">
<template #default="{ row }">
<el-input v-model="row.num" @change="handleChange(row)" />
</template>
</el-table-column>
<el-table-column label="价格" min-width="150">
<template #default="{ row }">
<el-input v-model="row.purchases" @change="handleChange(row)" />
</template>
</el-table-column>
<el-table-column label="总价" min-width="150">
<template #default="{ row }">
<el-input v-model="row.total_price" />
</template>
</el-table-column>
<el-table-column label="生产日期" min-width="140">
<template #default="{ row }">
<el-date-picker
:readonly="false"
class="flex-1 !flex"
v-model="row.manufacture"
clearable
type="date"
value-format="YYYY-MM-DD"
placeholder="选择生产日期"
>
</el-date-picker>
</template>
</el-table-column>
<el-table-column label="保质期" min-width="140">
<template #default="{ row }">
<el-date-picker
:readonly="false"
class="flex-1 !flex"
v-model="row.expiration_date"
clearable
type="date"
value-format="YYYY-MM-DD"
placeholder="选择保质期"
>
</el-date-picker>
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button type="danger" link @click="handleDeleteProdut(row.id)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogShop = false">取消</el-button>
<el-button type="primary" @click="goodsOfferUpdate"> 确认 </el-button>
</div>
</template>
</el-dialog>
<el-dialog v-model="showProduct" title="选择商品" width="70%">
<product-pop
@onBindStore="onBindProduct"
:warehouse_id="warehouse_id"
:is_warehouse="is_warehouse"
></product-pop>
</el-dialog>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</template>
<script lang="ts" setup name="storeOrderDETAILS">
import { ElMessage, type FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import {
apiBeforehandOrderCartInfoLists,
apiBeforehandOrderCartInfoDelete,
apiBeforehandOrderCartInfoAppendAdd
} from '@/api/beforehand_order_cart_info'
import { apiWarehouseOrderRentryExport, apiWarehouseOrderExport } from '@/api/warehouse_order'
import type { PropType } from 'vue'
import { usePaging } from '@/hooks/usePaging'
import { useRoute } from 'vue-router'
import feedback from '@/utils/feedback'
import EditPopup from './editProduct.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
const route = useRoute()
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const showDialog = ref(false)
const dialogShop = ref(false)
const activeName = ref('second')
const warehouse_id = ref(0)
const is_warehouse = ref(0)
const financial_pm = ref(0)
//
const formData = ref({
id: '',
code: '',
total_price: '',
supplier_name: '',
warehouse_name: '',
system_store: '',
financial_pm: ''
})
const updateInfo = ref({})
const goodsOfferUpdate = () => {
const product_arr = productList.value.map((item: any) => {
return {
id: item.id,
nums: item.num || 0,
purchase: item.purchases || 0,
prices: item.purchase || 0,
total_price: item.total_price || 0,
manufacture: item.manufacture,
expiration_date: item.expiration_date
}
})
apiBeforehandOrderCartInfoAppendAdd({
id: queryParams.bhoid,
product_arr: product_arr
}).then((res) => {
console.log(res)
dialogShop.value = false
getLists()
})
}
const queryParams = reactive({
bhoid: '',
pay_type: ''
})
//
const setFormData = async (data: Record<any, any>) => {
formData.value = { ...data }
}
const getDetail = async (row: Record<string, any>) => {
formData.value = { ...row }
queryParams.bhoid = row.id
warehouse_id.value = row.warehouse_id
if (row.financial_pm == 0) {
is_warehouse.value = 1
} else {
financial_pm.value = 1
}
productList.value = []
// setFormData(data)
getLists()
}
const xlsx = (id, type) => {
if (formData.value.financial_pm == 1) {
apiWarehouseOrderRentryExport({
id: id
}).then((res) => {
window.open(res.url, '_blank')
ElMessage.success('导出成功')
})
} else {
apiWarehouseOrderExport({
id: id,
type: type
}).then((res) => {
window.open(res.url, '_blank')
ElMessage.success('导出成功')
})
}
}
const showProduct = ref(false) //
//
const productList = ref([])
//
const handleDeleteProdut = (id: number) => {
productList.value = productList.value.filter((item: any) => item.id !== id)
}
//
const onBindProduct = (e: any[]) => {
e.forEach((item: any) => {
if (!productList.value.find((t: any) => t.id == item.id)) {
productList.value.push(item)
}
})
showProduct.value = false
}
function handleChange(row) {
row.total_price = row.num * row.purchases
}
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
}
})
if (product_arr.length > 0) {
try {
product_arr.forEach((item) => {
const stock = item.stock * 1
if (stock > item.stocks) {
isSubmit.value = false
throw new Error('超出仓库库存,请重新设置')
}
})
} catch (e) {
ElMessage.error('超出仓库库存,请重新设置')
return
}
}
isSubmit.value = true
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDeletes = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiBeforehandOrderCartInfoDelete({ id })
getLists()
}
//
const open = () => {
showDialog.value = true
}
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiBeforehandOrderCartInfoLists,
params: queryParams
})
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,139 @@
<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_name">
<el-input v-model="formData.store_name" disabled />
</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="purchase">
<el-input
v-model="formData.purchase"
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>
</div>
</template>
<script lang="ts" setup name="warehouseOrderEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import {
apiBeforehandOrderCartInfoEdit,
apiBeforehandOrderCartInfoDetail
} from '@/api/beforehand_order_cart_info'
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: '',
bhoid: '',
store_name: '',
total_price: '',
nums: '',
purchase: ''
})
//
const formRules = reactive<any>({
warehouse_id: [
{
required: true,
message: '请输入仓库',
trigger: ['blur']
}
],
total_price: [
{
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 apiBeforehandOrderCartInfoDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData }
await apiBeforehandOrderCartInfoEdit(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

@ -2,34 +2,14 @@
<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-form-item label="订单号" prop="order_id">
<el-input
class="w-[280px]"
v-model="queryParams.warehouse_id"
v-model="queryParams.order_id"
clearable
placeholder="请输入仓库"
placeholder="请输入订单号"
/>
</el-form-item>
<el-form-item label="供应商" prop="supplier_id">
<el-select
v-model="queryParams.supplier_id"
filterable
remote
reserve-keyword
placeholder="输入供应商名称搜索"
remote-show-suffix
:remote-method="remoteMethodUser"
:loading="userloading"
style="width: 240px"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="item.mer_name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="日期" prop="create_time">
<el-date-picker
v-model="startEndTime"
@ -46,7 +26,7 @@
<el-button @click="resetParams">重置</el-button>
<export-data
class="ml-2.5"
:fetch-fun="apiWarehouseOrderLists"
:fetch-fun="apiBeforehandOrderLists"
:params="queryParams"
:page-size="pager.size"
/>
@ -60,21 +40,17 @@
}"
class="ml-4"
>
<el-button type="primary"> 入库 </el-button>
<el-button type="primary"> 添加 </el-button>
</router-link>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="id" prop="id" show-overflow-tooltip width="55" />
<el-table-column label="操作时间" prop="create_time" show-overflow-tooltip />
<el-table-column label="仓库" prop="warehouse_name" show-overflow-tooltip />
<el-table-column label="供应商" prop="supplier_name" show-overflow-tooltip />
<el-table-column label="单号" prop="code" show-overflow-tooltip />
<el-table-column label="单号" prop="order_id" show-overflow-tooltip />
<el-table-column label="状态" prop="financial_pm_name" show-overflow-tooltip />
<el-table-column label="填写人员" prop="admin_name" show-overflow-tooltip />
<!-- <el-table-column label="批次" prop="batch" show-overflow-tooltip /> -->
<el-table-column label="已结" prop="completed_amount" show-overflow-tooltip />
<el-table-column label="未结" prop="outstanding_amount" show-overflow-tooltip />
<el-table-column label="总价格" prop="total_price" show-overflow-tooltip />
<el-table-column label="备注" prop="mark" show-overflow-tooltip />
@ -83,14 +59,6 @@
<el-button type="primary" link @click="handleDetai(row)"
>详情</el-button
>
<el-button
v-perms="['warehouse_order.warehouse_order/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['warehouse_order.warehouse_order/delete']"
type="danger"
@ -113,14 +81,14 @@
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
/> -->
<details-popup
v-if="showDetails"
ref="detailsRef"
@success="getLists"
@close="showDetails = false"
:dictData="dictData"
/> -->
/>
</div>
</template>
@ -131,12 +99,12 @@ import { apiWarehouseOrderLists, apiWarehouseOrderDelete } from '@/api/warehouse
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
// import EditPopup from './edit.vue'
// import DetailsPopup from './details.vue'
import DetailsPopup from './details.vue'
import { apiSystemStoreLists } from '@/api/system_store'
import moment from 'moment'
import { apiSupplierLists } from '@/api/supplier'
import { apiBeforehandOrderLists } from '@/api/beforehand_order'
// const editRef = shallowRef<InstanceType<typeof EditPopup>>()
// const detailsRef = shallowRef<InstanceType<typeof DetailsPopup>>()
const detailsRef = shallowRef<InstanceType<typeof DetailsPopup>>()
//
const showEdit = ref(false)
@ -144,7 +112,7 @@ const showDetails = ref(false)
//
const queryParams = reactive({
warehouse_id: '',
order_id: '',
product_name: '',
financial_pm: 1,
store_id: '',
@ -166,7 +134,7 @@ const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiWarehouseOrderLists,
fetchFun: apiBeforehandOrderLists,
params: queryParams
})
@ -235,7 +203,7 @@ const userloading = ref(false)
const userList = ref([])
const remoteMethodUser = (e = '') => {
userloading.value = true
apiSupplierLists({ mer_name: e })
apiBeforehandOrderLists({ mer_name: e })
.then((res) => {
userList.value = res.lists
setTimeout(() => {