工序计划
This commit is contained in:
parent
edceeafe48
commit
b3cf7ac3c0
93
src/api/orderProcessPlan.ts
Normal file
93
src/api/orderProcessPlan.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
// 工序计划 类型定义
|
||||
export interface OrderProcessPlan {
|
||||
id?: number
|
||||
|
||||
name?: string
|
||||
|
||||
code?: string
|
||||
|
||||
sort?: number
|
||||
|
||||
orderItemId?: number
|
||||
|
||||
beginTime?: string
|
||||
|
||||
endTime?: string
|
||||
|
||||
procurement?: number
|
||||
|
||||
outsource?: number
|
||||
|
||||
quantity?: number
|
||||
|
||||
transferNum?: number
|
||||
|
||||
transferOutNum?: number
|
||||
|
||||
createTime?: string
|
||||
|
||||
createBy?: string
|
||||
|
||||
qualityInspection?: number
|
||||
|
||||
storageEntry?: number
|
||||
|
||||
}
|
||||
|
||||
// 工序计划 API
|
||||
export const orderProcessPlanApi = {
|
||||
// 分页查询
|
||||
page(params: { page: number; pageSize: number; id?: number; name?: string; code?: string; orderItemId?: number }) {
|
||||
return request({ url: '/biz/orderProcessPlan/page', method: 'get', params })
|
||||
},
|
||||
|
||||
// 获取详情
|
||||
detail(id: string) {
|
||||
return request({ url: `/biz/orderProcessPlan/${id}`, method: 'get' })
|
||||
},
|
||||
|
||||
// 新增
|
||||
create(data: OrderProcessPlan) {
|
||||
return request({ url: '/biz/orderProcessPlan', method: 'post', data })
|
||||
},
|
||||
|
||||
// 修改
|
||||
update(data: OrderProcessPlan) {
|
||||
return request({ url: '/biz/orderProcessPlan', method: 'put', data })
|
||||
},
|
||||
|
||||
// 删除
|
||||
delete(ids: string[]) {
|
||||
return request({ url: `/biz/orderProcessPlan/${ids.join(',')}`, method: 'delete' })
|
||||
},
|
||||
|
||||
// 导出
|
||||
export(params?: { ids?: string[]; id?: number; name?: string; code?: string; orderItemId?: number }) {
|
||||
const p: Record<string, any> = {}
|
||||
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||
if (params?.id !== undefined && params?.id !== null) p.id = params.id
|
||||
if (params?.name !== undefined && params?.name !== null) p.name = params.name
|
||||
if (params?.code !== undefined && params?.code !== null) p.code = params.code
|
||||
if (params?.orderItemId !== undefined && params?.orderItemId !== null) p.orderItemId = params.orderItemId
|
||||
return request({ url: `/biz/orderProcessPlan/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/orderProcessPlan/import`,
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
|
||||
// 下载导入模板
|
||||
downloadTemplate() {
|
||||
return request({ url: `/biz/orderProcessPlan/template`, method: 'get', responseType: 'blob' })
|
||||
}
|
||||
}
|
||||
@ -203,8 +203,8 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/test/test/index.vue'),
|
||||
meta: { title: '测试菜单', icon: 'StarOutline' }
|
||||
},
|
||||
// 开发工具
|
||||
{
|
||||
// 开发工具
|
||||
path: 'tool/gen',
|
||||
name: 'ToolGen',
|
||||
component: () => import('@/views/tool/gen/index.vue'),
|
||||
@ -330,22 +330,27 @@ export function resetRouter() {
|
||||
|
||||
// 路由守卫
|
||||
router.beforeEach(async (to, _from, next) => {
|
||||
console.log('路由测试');
|
||||
const userStore = useUserStore()
|
||||
|
||||
//document.title = `${to.meta.title || ''} - CSY Admin`
|
||||
|
||||
console.log('开始动态路由11', to.meta, _from);
|
||||
if (to.meta.requiresAuth === false) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
console.log('开始动态路由2222', to.meta, _from);
|
||||
|
||||
if (!userStore.token) {
|
||||
next({ name: 'Login', query: { redirect: to.fullPath } })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!userStore.user) {
|
||||
try {
|
||||
console.log('开始动态路由4444', userStore.user, to.meta, _from);
|
||||
|
||||
await userStore.getInfo()
|
||||
// 添加动态路由(只添加新的,不影响已有的)
|
||||
addDynamicRoutes(userStore.menus)
|
||||
|
||||
527
src/views/biz/orderProcessPlan/index.vue
Normal file
527
src/views/biz/orderProcessPlan/index.vue
Normal file
@ -0,0 +1,527 @@
|
||||
<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.id" placeholder="请输入主键" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="工序名称">
|
||||
<n-input v-model:value="searchForm.name" placeholder="请输入工序名称" clearable />
|
||||
</n-form-item>
|
||||
<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.orderItemId" placeholder="请输入生产订单id" 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="生产订单id" path="orderItemId">
|
||||
<n-input v-model:value="formData.orderItemId" placeholder="请输入生产订单id" />
|
||||
</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="procurement">
|
||||
<n-radio-group v-model:value="formData.procurement">
|
||||
<n-space>
|
||||
<n-radio v-for="opt in procurementOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
<n-form-item label="是否委外" path="outsource">
|
||||
<n-radio-group v-model:value="formData.outsource">
|
||||
<n-space>
|
||||
<n-radio v-for="opt in outsourceOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
<n-form-item label="生产总数" path="quantity">
|
||||
<n-input v-model:value="formData.quantity" placeholder="请输入生产总数" />
|
||||
</n-form-item>
|
||||
<n-form-item label="转入数量" path="transferNum">
|
||||
<n-input v-model:value="formData.transferNum" placeholder="请输入转入数量" />
|
||||
</n-form-item>
|
||||
<n-form-item label="转出数量" path="transferOutNum">
|
||||
<n-input v-model:value="formData.transferOutNum" placeholder="请输入转出数量" />
|
||||
</n-form-item>
|
||||
<n-form-item label="是否质检" path="qualityInspection">
|
||||
<n-radio-group v-model:value="formData.qualityInspection">
|
||||
<n-space>
|
||||
<n-radio v-for="opt in qualityInspectionOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
<n-form-item label="是否直接入库" path="storageEntry">
|
||||
<n-radio-group v-model:value="formData.storageEntry">
|
||||
<n-space>
|
||||
<n-radio v-for="opt in storageEntryOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
</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 { orderProcessPlanApi, type OrderProcessPlan } from '@/api/orderProcessPlan'
|
||||
import { dictDataApi } from '@/api/org'
|
||||
|
||||
const message = useMessage()
|
||||
const dialog = useDialog()
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
id: null as number | null,
|
||||
name: '',
|
||||
code: '',
|
||||
orderItemId: null as number | null,
|
||||
})
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<OrderProcessPlan[]>([])
|
||||
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: OrderProcessPlan = {
|
||||
name: '',
|
||||
code: '',
|
||||
sort: undefined,
|
||||
orderItemId: undefined,
|
||||
beginTime: undefined,
|
||||
endTime: undefined,
|
||||
procurement: undefined,
|
||||
outsource: undefined,
|
||||
quantity: undefined,
|
||||
transferNum: undefined,
|
||||
transferOutNum: undefined,
|
||||
qualityInspection: undefined,
|
||||
storageEntry: undefined,
|
||||
}
|
||||
const formData = reactive<OrderProcessPlan>({ ...defaultFormData })
|
||||
|
||||
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||
const procurementOptions = ref<{ label: string; value: any }[]>([])
|
||||
const outsourceOptions = ref<{ label: string; value: any }[]>([])
|
||||
const qualityInspectionOptions = ref<{ label: string; value: any }[]>([])
|
||||
const storageEntryOptions = ref<{ label: string; value: any }[]>([])
|
||||
|
||||
// 表单校验规则
|
||||
const formRules = {
|
||||
}
|
||||
|
||||
// 表格列
|
||||
const columns: DataTableColumns<OrderProcessPlan> = [
|
||||
{ type: 'selection' },
|
||||
{ title: '主键', key: 'id' },
|
||||
{ title: '工序名称', key: 'name' },
|
||||
{ title: '工序编码', key: 'code' },
|
||||
{ title: '工序顺序', key: 'sort' },
|
||||
{ title: '生产订单id', key: 'orderItemId' },
|
||||
{ title: '生产开始时间', key: 'beginTime' },
|
||||
{ title: '生产结束时间', key: 'endTime' },
|
||||
{ title: '是否采购', key: 'procurement',
|
||||
render(row) {
|
||||
const val = row.procurement
|
||||
const opt = procurementOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '是否委外', key: 'outsource',
|
||||
render(row) {
|
||||
const val = row.outsource
|
||||
const opt = outsourceOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '生产总数', key: 'quantity' },
|
||||
{ title: '转入数量', key: 'transferNum' },
|
||||
{ title: '转出数量', key: 'transferOutNum' },
|
||||
{ title: '是否质检', key: 'qualityInspection',
|
||||
render(row) {
|
||||
const val = row.qualityInspection
|
||||
const opt = qualityInspectionOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '是否直接入库', key: 'storageEntry',
|
||||
render(row) {
|
||||
const val = row.storageEntry
|
||||
const opt = storageEntryOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{
|
||||
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 orderProcessPlanApi.page({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
id: searchForm.id || undefined,
|
||||
name: searchForm.name || undefined,
|
||||
code: searchForm.code || undefined,
|
||||
orderItemId: searchForm.orderItemId || undefined,
|
||||
})
|
||||
tableData.value = res.list
|
||||
pagination.itemCount = res.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
searchForm.id = null
|
||||
|
||||
searchForm.name = ''
|
||||
|
||||
searchForm.code = ''
|
||||
|
||||
searchForm.orderItemId = 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: OrderProcessPlan) {
|
||||
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.createTime && typeof formData.createTime === 'string') {
|
||||
formData.createTime = new Date(formData.createTime.replace(' ', 'T')).getTime()
|
||||
}
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
// 提交
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate()
|
||||
try {
|
||||
const submitData = { ...formData } as OrderProcessPlan
|
||||
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.createTime === 'number') {
|
||||
submitData.createTime = new Date(submitData.createTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||
}
|
||||
if (submitData.id) {
|
||||
await orderProcessPlanApi.update(submitData)
|
||||
message.success('修改成功')
|
||||
} else {
|
||||
await orderProcessPlanApi.create(submitData)
|
||||
message.success('新增成功')
|
||||
}
|
||||
modalVisible.value = false
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
function handleDelete(row: OrderProcessPlan) {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: '确定要删除该记录吗?',
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await orderProcessPlanApi.delete([row.id!])
|
||||
message.success('删除成功')
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
function handleBatchDelete() {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await orderProcessPlanApi.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.id != null) params.id = searchForm.id
|
||||
if (searchForm.name) params.name = searchForm.name
|
||||
if (searchForm.code) params.code = searchForm.code
|
||||
if (searchForm.orderItemId != null) params.orderItemId = searchForm.orderItemId
|
||||
const blob = await orderProcessPlanApi.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 orderProcessPlanApi.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 orderProcessPlanApi.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() {
|
||||
try {
|
||||
const data = await dictDataApi.listByType('sys_yes_no')
|
||||
procurementOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
} catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('sys_yes_no')
|
||||
outsourceOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
} catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('sys_yes_no')
|
||||
qualityInspectionOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
} catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('sys_yes_no')
|
||||
storageEntryOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
} catch {}
|
||||
}
|
||||
|
||||
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