feat:批量发货
This commit is contained in:
1 parent
407cec8df6
commit
a53435091e
5 files changed
+126
-3
No files matched your search
+2
-2
@@ -4,9 +4,9 @@ NODE_ENV=development
|
||||
VITE_DEV=true
|
||||
|
||||
# 请求路径
|
||||
VITE_BASE_URL='https://yffzpapi.zianxin.com'
|
||||
# VITE_BASE_URL='https://yffzpapi.zianxin.com'
|
||||
|
||||
#VITE_BASE_URL='http://localhost:48088'
|
||||
VITE_BASE_URL='http://localhost:48088'
|
||||
|
||||
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
|
||||
VITE_UPLOAD_TYPE=server
|
||||
|
||||
@@ -121,6 +121,11 @@ export interface TradeOrderSummaryRespVO {
|
||||
afterSalePrice?: string
|
||||
}
|
||||
|
||||
// 用户发货模版
|
||||
export function importMchTemplate() {
|
||||
return request.download({ url: '/trade/order/get-import-template' })
|
||||
}
|
||||
|
||||
// 查询交易订单列表
|
||||
export const exportOrderExcel = async (params: any) => {
|
||||
return await request.download({ url: `/trade/order/export-excel`, params })
|
||||
@@ -201,3 +206,4 @@ export const getOrderByPickUpVerifyCode = async (pickUpVerifyCode: string) => {
|
||||
params: { pickUpVerifyCode }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" title="用户导入" width="500">
|
||||
<el-upload ref="uploadRef" v-model:file-list="fileList" :action="importUrl" :auto-upload="false"
|
||||
:disabled="formLoading" :headers="uploadHeaders" :limit="1" :on-error="submitFormError" :on-exceed="handleExceed"
|
||||
:on-success="submitFormSuccess" accept=".xlsx, .xls" drag>
|
||||
<Icon icon="ep:upload" />
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip text-center">
|
||||
<div class="el-upload__tip">
|
||||
可先点击"导出"按钮,下载模板,按照模板填写商户发货信息后,再导入。
|
||||
</div>
|
||||
<span>仅允许导入 xls、xlsx 格式文件。</span>
|
||||
<el-link :underline="false" style="font-size: 12px; vertical-align: baseline" type="primary"
|
||||
@click="importTemplate">
|
||||
下载模板
|
||||
</el-link>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import * as TradeOrderApi from '@/api/mall/trade/order'
|
||||
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||
import download from '@/utils/download'
|
||||
|
||||
defineOptions({ name: 'OrderMchImport' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
const uploadRef = ref()
|
||||
const importUrl =
|
||||
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/trade/order/import'
|
||||
const uploadHeaders = ref() // 上传 Header 头
|
||||
const fileList = ref([]) // 文件列表
|
||||
const updateSupport = ref(0) // 是否更新已经存在的用户数据
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = () => {
|
||||
dialogVisible.value = true
|
||||
updateSupport.value = 0
|
||||
fileList.value = []
|
||||
resetForm()
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
if (fileList.value.length == 0) {
|
||||
message.error('请上传文件')
|
||||
return
|
||||
}
|
||||
// 提交请求
|
||||
uploadHeaders.value = {
|
||||
Authorization: 'Bearer ' + getAccessToken(),
|
||||
'tenant-id': getTenantId()
|
||||
}
|
||||
formLoading.value = true
|
||||
uploadRef.value!.submit()
|
||||
}
|
||||
|
||||
/** 文件上传成功 */
|
||||
const emits = defineEmits(['success'])
|
||||
const submitFormSuccess = (response: any) => {
|
||||
if (response.code !== 0) {
|
||||
message.error(response.msg)
|
||||
formLoading.value = false
|
||||
return
|
||||
}
|
||||
formLoading.value = false
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
message.success('批量发货成功!')
|
||||
emits('success')
|
||||
}
|
||||
|
||||
/** 上传错误提示 */
|
||||
const submitFormError = (): void => {
|
||||
message.error('上传失败,请您重新上传!')
|
||||
formLoading.value = false
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = async (): Promise<void> => {
|
||||
// 重置上传状态和文件
|
||||
formLoading.value = false
|
||||
await nextTick()
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
|
||||
/** 文件数超出提示 */
|
||||
const handleExceed = (): void => {
|
||||
message.error('最多只能上传一个文件!')
|
||||
}
|
||||
|
||||
/** 下载模板操作 */
|
||||
const importTemplate = async () => {
|
||||
const res = await TradeOrderApi.importMchTemplate()
|
||||
download.excel(res, '商户发货模版.xls')
|
||||
}
|
||||
</script>
|
||||
@@ -62,6 +62,8 @@ const submitForm = async () => {
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = unref(formData)
|
||||
console.log("expressType:", expressType.value);
|
||||
console.log("data:", data);
|
||||
if (expressType.value === 'express' && data.id) {
|
||||
// 选择快递物流时调用快递100接口
|
||||
await TradeOrderApi.deliveryOrder100({ id: data.id })
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
<Icon class="mr-5px" icon="ep:download" />
|
||||
导出
|
||||
</el-button>
|
||||
<el-button :loading="exportLoading" plain @click="orderMchImportRef?.open">
|
||||
<Icon class="mr-5px" icon="ep:upload" />
|
||||
导入商户发货信息
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
@@ -136,6 +140,7 @@
|
||||
<!-- 各种操作的弹窗 -->
|
||||
<OrderDeliveryForm ref="deliveryFormRef" @success="getList" />
|
||||
<OrderUpdateRemarkForm ref="updateRemarkForm" @success="getList" />
|
||||
<OrderMchImport ref="orderMchImportRef" @success="getList" />
|
||||
|
||||
<el-dialog v-model="showLabelDialog" title="" width="500px">
|
||||
<!-- 如果是图片 -->
|
||||
@@ -168,6 +173,7 @@ import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
|
||||
import { DeliveryTypeEnum, TradeOrderStatusEnum } from '@/utils/constants'
|
||||
import download from '@/utils/download'
|
||||
import { OrderTableColumn } from './components'
|
||||
import OrderMchImport from './components/OrderMchImport.vue'
|
||||
|
||||
defineOptions({ name: 'TradeOrder' })
|
||||
|
||||
@@ -175,6 +181,7 @@ const message = useMessage() // 消息弹窗
|
||||
|
||||
const { currentRoute, push } = useRouter() // 路由跳转
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const orderMchImportRef = ref()
|
||||
const exportLoading = ref(false)
|
||||
const total = ref(2) // 列表的总页数
|
||||
const list = ref<TradeOrderApi.OrderVO[]>([]) // 列表的数据
|
||||
@@ -291,7 +298,7 @@ const handleCommand = (command: string, row: TradeOrderApi.OrderVO) => {
|
||||
updateRemarkForm.value?.open(row)
|
||||
break
|
||||
case 'delivery':
|
||||
deliveryFormRef.value?.open(row.id) // 直接传递id而不是整个row对象
|
||||
deliveryFormRef.value?.open(row) // 直接传递id而不是整个row对象
|
||||
break
|
||||
case 'print':
|
||||
// 打印功能:直接在新窗口打开物流面单
|
||||
|
||||
Reference in new issue
Block a user