生产订单
This commit is contained in:
parent
13ca3ff660
commit
da45bb7597
103
src/api/orderItem.ts
Normal file
103
src/api/orderItem.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
// 生产订单 类型定义
|
||||
export interface OrderItem {
|
||||
id?: number
|
||||
|
||||
name?: string
|
||||
|
||||
code?: string
|
||||
|
||||
sort?: number
|
||||
|
||||
quantity?: number
|
||||
|
||||
projectId?: number
|
||||
|
||||
parentId?: number
|
||||
|
||||
sfProduct?: number
|
||||
|
||||
procurement?: number
|
||||
|
||||
beginTime?: string
|
||||
|
||||
endTime?: string
|
||||
|
||||
actualStartTime?: string
|
||||
|
||||
actualEndTime?: string
|
||||
|
||||
remark?: string
|
||||
|
||||
createTime?: string
|
||||
|
||||
createBy?: string
|
||||
|
||||
assingWorkId?: string
|
||||
|
||||
assingWorkTime?: string
|
||||
|
||||
assingWorkOperationId?: string
|
||||
|
||||
assingWorkOperationTime?: string
|
||||
|
||||
starter?: number
|
||||
|
||||
}
|
||||
|
||||
// 生产订单 API
|
||||
export const orderItemApi = {
|
||||
// 分页查询
|
||||
page(params: { page: number; pageSize: number; code?: string; projectId?: number; beginTime?: string; endTime?: string }) {
|
||||
return request({ url: '/biz/orderItem/page', method: 'get', params })
|
||||
},
|
||||
|
||||
// 获取详情
|
||||
detail(id: string) {
|
||||
return request({ url: `/biz/orderItem/${id}`, method: 'get' })
|
||||
},
|
||||
|
||||
// 新增
|
||||
create(data: OrderItem) {
|
||||
return request({ url: '/biz/orderItem', method: 'post', data })
|
||||
},
|
||||
|
||||
// 修改
|
||||
update(data: OrderItem) {
|
||||
return request({ url: '/biz/orderItem', method: 'put', data })
|
||||
},
|
||||
|
||||
// 删除
|
||||
delete(ids: string[]) {
|
||||
return request({ url: `/biz/orderItem/${ids.join(',')}`, method: 'delete' })
|
||||
},
|
||||
|
||||
// 导出
|
||||
export(params?: { ids?: string[]; code?: string; projectId?: number; beginTime?: string; endTime?: string }) {
|
||||
const p: Record<string, any> = {}
|
||||
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||
if (params?.code !== undefined && params?.code !== null) p.code = params.code
|
||||
if (params?.projectId !== undefined && params?.projectId !== null) p.projectId = params.projectId
|
||||
if (params?.beginTime !== undefined && params?.beginTime !== null) p.beginTime = params.beginTime
|
||||
if (params?.endTime !== undefined && params?.endTime !== null) p.endTime = params.endTime
|
||||
return request({ url: `/biz/orderItem/export`, method: 'get', params: p, responseType: 'blob' })
|
||||
},
|
||||
|
||||
// 导入
|
||||
importData(file: File) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return request<{ success: number; fail: number; errors: string[] }>({
|
||||
url: `/biz/orderItem/import`,
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
|
||||
// 下载导入模板
|
||||
downloadTemplate() {
|
||||
return request({ url: `/biz/orderItem/template`, method: 'get', responseType: 'blob' })
|
||||
}
|
||||
}
|
||||
512
src/views/biz/orderItem/index.vue
Normal file
512
src/views/biz/orderItem/index.vue
Normal file
@ -0,0 +1,512 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<n-card>
|
||||
<!-- 搜索表单 -->
|
||||
<div class="search-form">
|
||||
<n-form inline :model="searchForm" label-placement="left">
|
||||
<n-form-item label="物料编码">
|
||||
<n-input v-model:value="searchForm.code" placeholder="请输入物料编码" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="产品id">
|
||||
<n-input v-model:value="searchForm.projectId" placeholder="请输入产品id" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="开始时间">
|
||||
<n-date-picker v-model:value="searchForm.beginTime" type="datetime" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="结束时间">
|
||||
<n-date-picker v-model:value="searchForm.endTime" type="datetime" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item>
|
||||
<n-space>
|
||||
<n-button type="primary" @click="handleSearch">
|
||||
<template #icon><n-icon><SearchOutline /></n-icon></template>
|
||||
搜索
|
||||
</n-button>
|
||||
<n-button @click="handleReset">
|
||||
<template #icon><n-icon><RefreshOutline /></n-icon></template>
|
||||
重置
|
||||
</n-button>
|
||||
</n-space>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</div>
|
||||
|
||||
<!-- 工具栏 -->
|
||||
<div class="table-toolbar">
|
||||
<n-space>
|
||||
<n-button type="primary" @click="handleAdd">
|
||||
<template #icon><n-icon><AddOutline /></n-icon></template>
|
||||
新增
|
||||
</n-button>
|
||||
<n-button @click="importModalVisible = true">
|
||||
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
|
||||
导入
|
||||
</n-button>
|
||||
<n-button @click="handleExport">
|
||||
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
||||
导出{{ selectedIds.length > 0 ? `(${selectedIds.length})` : '' }}
|
||||
</n-button>
|
||||
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
|
||||
<template #icon><n-icon><TrashOutline /></n-icon></template>
|
||||
删除
|
||||
</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="tableData"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
:row-key="(row) => row.id"
|
||||
:scroll-x="1200"
|
||||
@update:page="handlePageChange"
|
||||
@update:page-size="handlePageSizeChange"
|
||||
@update:checked-row-keys="handleCheck"
|
||||
/>
|
||||
</n-card>
|
||||
|
||||
<!-- 新增/编辑弹窗 -->
|
||||
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 600px">
|
||||
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
|
||||
<n-form-item label="物料名称" path="name">
|
||||
<n-input v-model:value="formData.name" placeholder="请输入物料名称" />
|
||||
</n-form-item>
|
||||
<n-form-item label="物料编码" path="code">
|
||||
<n-input v-model:value="formData.code" placeholder="请输入物料编码" />
|
||||
</n-form-item>
|
||||
<n-form-item label="产品序列" path="sort">
|
||||
<n-input v-model:value="formData.sort" placeholder="请输入产品序列" />
|
||||
</n-form-item>
|
||||
<n-form-item label="生产数量" path="quantity">
|
||||
<n-input v-model:value="formData.quantity" placeholder="请输入生产数量" />
|
||||
</n-form-item>
|
||||
<n-form-item label="产品id" path="projectId">
|
||||
<n-input v-model:value="formData.projectId" placeholder="请输入产品id" />
|
||||
</n-form-item>
|
||||
<n-form-item label="父主键id" path="parentId">
|
||||
<n-input v-model:value="formData.parentId" placeholder="请输入父主键id" />
|
||||
</n-form-item>
|
||||
<n-form-item label="是否半成品, 1是 0不是" path="sfProduct">
|
||||
<n-input v-model:value="formData.sfProduct" placeholder="请输入是否半成品, 1是 0不是" />
|
||||
</n-form-item>
|
||||
<n-form-item label="是否采购, 1是 0不是" path="procurement">
|
||||
<n-input v-model:value="formData.procurement" placeholder="请输入是否采购, 1是 0不是" />
|
||||
</n-form-item>
|
||||
<n-form-item label="开始时间" path="beginTime">
|
||||
<n-date-picker v-model:value="formData.beginTime" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="结束时间" path="endTime">
|
||||
<n-date-picker v-model:value="formData.endTime" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="实际开始时间" path="actualStartTime">
|
||||
<n-date-picker v-model:value="formData.actualStartTime" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="实际结束时间" path="actualEndTime">
|
||||
<n-date-picker v-model:value="formData.actualEndTime" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="派工接收人" path="assingWorkId">
|
||||
<n-input v-model:value="formData.assingWorkId" placeholder="请输入派工接收人" />
|
||||
</n-form-item>
|
||||
<n-form-item label="派工时间" path="assingWorkTime">
|
||||
<n-date-picker v-model:value="formData.assingWorkTime" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="派工操作人" path="assingWorkOperationId">
|
||||
<n-input v-model:value="formData.assingWorkOperationId" placeholder="请输入派工操作人" />
|
||||
</n-form-item>
|
||||
<n-form-item label="派工操作时间;派工操作时间" path="assingWorkOperationTime">
|
||||
<n-date-picker v-model:value="formData.assingWorkOperationTime" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="是否开工;是否开工" path="starter">
|
||||
<n-input v-model:value="formData.starter" placeholder="请输入是否开工;是否开工" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<n-space justify="end">
|
||||
<n-button @click="modalVisible = false">取消</n-button>
|
||||
<n-button type="primary" @click="handleSubmit">确定</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-modal>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<n-modal v-model:show="importModalVisible" preset="card" title="导入生产订单" style="width: 500px">
|
||||
<n-space vertical>
|
||||
<n-alert type="info">
|
||||
<template #header>导入说明</template>
|
||||
<ul style="margin: 0; padding-left: 16px; line-height: 1.8">
|
||||
<li>请先下载导入模板,按模板格式填写数据</li>
|
||||
<li>支持 .xlsx 或 .xls 格式</li>
|
||||
</ul>
|
||||
</n-alert>
|
||||
<n-space>
|
||||
<n-button type="primary" @click="handleDownloadTemplate">
|
||||
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
||||
下载模板
|
||||
</n-button>
|
||||
</n-space>
|
||||
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
|
||||
<n-upload-dragger>
|
||||
<div style="margin-bottom: 12px">
|
||||
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon>
|
||||
</div>
|
||||
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
|
||||
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx 或 .xls 格式</n-p>
|
||||
</n-upload-dragger>
|
||||
</n-upload>
|
||||
</n-space>
|
||||
<template #footer>
|
||||
<n-button @click="importModalVisible = false">关闭</n-button>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, h, onMounted } from 'vue'
|
||||
import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
|
||||
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
|
||||
import { orderItemApi, type OrderItem } from '@/api/orderItem'
|
||||
|
||||
const message = useMessage()
|
||||
const dialog = useDialog()
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
code: '',
|
||||
projectId: null as number | null,
|
||||
beginTime: null as number | null,
|
||||
endTime: null as number | null,
|
||||
})
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<OrderItem[]>([])
|
||||
const loading = ref(false)
|
||||
const selectedIds = ref<number[]>([])
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50]
|
||||
})
|
||||
|
||||
// 弹窗
|
||||
const modalVisible = ref(false)
|
||||
const modalTitle = ref('')
|
||||
const importModalVisible = ref(false)
|
||||
const formRef = ref()
|
||||
const defaultFormData: OrderItem = {
|
||||
name: '',
|
||||
code: '',
|
||||
sort: undefined,
|
||||
quantity: undefined,
|
||||
projectId: undefined,
|
||||
parentId: undefined,
|
||||
sfProduct: undefined,
|
||||
procurement: undefined,
|
||||
beginTime: undefined,
|
||||
endTime: undefined,
|
||||
actualStartTime: undefined,
|
||||
actualEndTime: undefined,
|
||||
assingWorkId: '',
|
||||
assingWorkTime: undefined,
|
||||
assingWorkOperationId: '',
|
||||
assingWorkOperationTime: undefined,
|
||||
starter: undefined,
|
||||
}
|
||||
const formData = reactive<OrderItem>({ ...defaultFormData })
|
||||
|
||||
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||
|
||||
// 表单校验规则
|
||||
const formRules = {
|
||||
}
|
||||
|
||||
// 表格列
|
||||
const columns: DataTableColumns<OrderItem> = [
|
||||
{ type: 'selection' },
|
||||
{ title: '主键id', key: 'id' },
|
||||
{ title: '物料名称', key: 'name' },
|
||||
{ title: '物料编码', key: 'code' },
|
||||
{ title: '产品序列', key: 'sort' },
|
||||
{ title: '生产数量', key: 'quantity' },
|
||||
{ title: '产品id', key: 'projectId' },
|
||||
{ title: '是否半成品, 1是 0不是', key: 'sfProduct' },
|
||||
{ title: '是否采购, 1是 0不是', key: 'procurement' },
|
||||
{ title: '开始时间', key: 'beginTime' },
|
||||
{ title: '结束时间', key: 'endTime' },
|
||||
{ title: '实际开始时间', key: 'actualStartTime' },
|
||||
{ title: '实际结束时间', key: 'actualEndTime' },
|
||||
{ title: '备注', key: 'remark' },
|
||||
{ title: '创建时间', key: 'createTime', width: 180 },
|
||||
{ title: '创建人', key: 'createBy' },
|
||||
{ title: '派工接收人', key: 'assingWorkId' },
|
||||
{ title: '派工时间', key: 'assingWorkTime' },
|
||||
{ title: '派工操作人', key: 'assingWorkOperationId' },
|
||||
{ title: '派工操作时间;派工操作时间', key: 'assingWorkOperationTime' },
|
||||
{ title: '是否开工;是否开工', key: 'starter' },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'actions',
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
render(row) {
|
||||
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [
|
||||
h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, {
|
||||
default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑']
|
||||
}),
|
||||
h(NButton, { size: 'small', quaternary: true, type: 'error', onClick: () => handleDelete(row) }, {
|
||||
default: () => [h(NIcon, null, { default: () => h(TrashOutline) }), ' 删除']
|
||||
})
|
||||
])
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
// 加载数据
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await orderItemApi.page({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
code: searchForm.code || undefined,
|
||||
projectId: searchForm.projectId || undefined,
|
||||
beginTime: searchForm.beginTime || undefined,
|
||||
endTime: searchForm.endTime || undefined,
|
||||
})
|
||||
tableData.value = res.list
|
||||
pagination.itemCount = res.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
searchForm.code = ''
|
||||
|
||||
searchForm.projectId = null
|
||||
|
||||
searchForm.beginTime = null
|
||||
|
||||
searchForm.endTime = null
|
||||
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 分页
|
||||
function handlePageChange(page: number) {
|
||||
pagination.page = page
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handlePageSizeChange(pageSize: number) {
|
||||
pagination.pageSize = pageSize
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 选择
|
||||
function handleCheck(keys: Array<string | number>) {
|
||||
selectedIds.value = keys as number[]
|
||||
}
|
||||
|
||||
// 新增
|
||||
function handleAdd() {
|
||||
modalTitle.value = '新增生产订单'
|
||||
Object.assign(formData, defaultFormData)
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
// 编辑
|
||||
function handleEdit(row: OrderItem) {
|
||||
modalTitle.value = '编辑生产订单'
|
||||
Object.assign(formData, row)
|
||||
if (formData.beginTime && typeof formData.beginTime === 'string') {
|
||||
formData.beginTime = new Date(formData.beginTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
if (formData.endTime && typeof formData.endTime === 'string') {
|
||||
formData.endTime = new Date(formData.endTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
if (formData.actualStartTime && typeof formData.actualStartTime === 'string') {
|
||||
formData.actualStartTime = new Date(formData.actualStartTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
if (formData.actualEndTime && typeof formData.actualEndTime === 'string') {
|
||||
formData.actualEndTime = new Date(formData.actualEndTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
if (formData.createTime && typeof formData.createTime === 'string') {
|
||||
formData.createTime = new Date(formData.createTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
if (formData.assingWorkTime && typeof formData.assingWorkTime === 'string') {
|
||||
formData.assingWorkTime = new Date(formData.assingWorkTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
if (formData.assingWorkOperationTime && typeof formData.assingWorkOperationTime === 'string') {
|
||||
formData.assingWorkOperationTime = new Date(formData.assingWorkOperationTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
// 提交
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate()
|
||||
try {
|
||||
const submitData = { ...formData } as OrderItem
|
||||
if (typeof submitData.beginTime === 'number') {
|
||||
submitData.beginTime = new Date(submitData.beginTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (typeof submitData.endTime === 'number') {
|
||||
submitData.endTime = new Date(submitData.endTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (typeof submitData.actualStartTime === 'number') {
|
||||
submitData.actualStartTime = new Date(submitData.actualStartTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (typeof submitData.actualEndTime === 'number') {
|
||||
submitData.actualEndTime = new Date(submitData.actualEndTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (typeof submitData.createTime === 'number') {
|
||||
submitData.createTime = new Date(submitData.createTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (typeof submitData.assingWorkTime === 'number') {
|
||||
submitData.assingWorkTime = new Date(submitData.assingWorkTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (typeof submitData.assingWorkOperationTime === 'number') {
|
||||
submitData.assingWorkOperationTime = new Date(submitData.assingWorkOperationTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (submitData.id) {
|
||||
await orderItemApi.update(submitData)
|
||||
message.success('修改成功')
|
||||
} else {
|
||||
await orderItemApi.create(submitData)
|
||||
message.success('新增成功')
|
||||
}
|
||||
modalVisible.value = false
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
function handleDelete(row: OrderItem) {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: '确定要删除该记录吗?',
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await orderItemApi.delete([row.id!])
|
||||
message.success('删除成功')
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
function handleBatchDelete() {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await orderItemApi.delete(selectedIds.value)
|
||||
message.success('删除成功')
|
||||
selectedIds.value = []
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 导出
|
||||
async function handleExport() {
|
||||
try {
|
||||
const params: Record<string, any> = {}
|
||||
if (selectedIds.value.length > 0) params.ids = selectedIds.value
|
||||
if (searchForm.code) params.code = searchForm.code
|
||||
if (searchForm.projectId != null) params.projectId = searchForm.projectId
|
||||
if (searchForm.beginTime != null) params.beginTime = searchForm.beginTime
|
||||
if (searchForm.endTime != null) params.endTime = searchForm.endTime
|
||||
const blob = await orderItemApi.export(params)
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = '生产订单数据.xlsx'
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
|
||||
// 下载导入模板
|
||||
async function handleDownloadTemplate() {
|
||||
try {
|
||||
const blob = await orderItemApi.downloadTemplate()
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = '生产订单导入模板.xlsx'
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
|
||||
// 导入上传
|
||||
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
|
||||
if (!file.file) return
|
||||
try {
|
||||
const result = await orderItemApi.importData(file.file)
|
||||
if (result.fail > 0) {
|
||||
dialog.warning({
|
||||
title: '导入结果',
|
||||
content: `成功: ${result.success} 条,失败: ${result.fail} 条\n错误信息: ${(result.errors || []).join('\n') || '无'}`,
|
||||
positiveText: '确定'
|
||||
})
|
||||
} else {
|
||||
message.success(`导入成功,共 ${result.success} 条数据`)
|
||||
importModalVisible.value = false
|
||||
}
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
|
||||
// 加载字典选项
|
||||
async function loadDictOptions() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
loadDictOptions()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user