提交
This commit is contained in:
commit
5e8bcd2114
@ -5,8 +5,17 @@ VITE_APP_TITLE = 伊特机械MES
|
|||||||
VITE_APP_ENV = 'development'
|
VITE_APP_ENV = 'development'
|
||||||
|
|
||||||
# 开发环境
|
# 开发环境
|
||||||
|
<<<<<<< HEAD
|
||||||
VITE_APP_BASE_API = 'http://192.168.5.232:8888/api'
|
VITE_APP_BASE_API = 'http://192.168.5.232:8888/api'
|
||||||
|
=======
|
||||||
|
|
||||||
|
#VITE_APP_BASE_API = 'http://192.168.12.4:8888/api'
|
||||||
|
>>>>>>> f1e25f58a96a8b7737687ce50afef4b34cda2541
|
||||||
#VITE_APP_BASE_API = 'http://192.168.5.14:9100/gateway'
|
#VITE_APP_BASE_API = 'http://192.168.5.14:9100/gateway'
|
||||||
|
|
||||||
|
VITE_APP_BASE_API = 'http://localhost/api'
|
||||||
|
#VITE_APP_BASE_API = 'http://localhost:9100/gateway'
|
||||||
|
|
||||||
#VITE_APP_BASE_API = '/dev-api'
|
#VITE_APP_BASE_API = '/dev-api'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,6 @@ VITE_APP_ENV = 'production'
|
|||||||
# 若依管理系统/生产环境
|
# 若依管理系统/生产环境
|
||||||
#VITE_APP_BASE_API = '/prod-api'
|
#VITE_APP_BASE_API = '/prod-api'
|
||||||
# VITE_APP_BASE_API = 'https://api.evo-techina.com'
|
# VITE_APP_BASE_API = 'https://api.evo-techina.com'
|
||||||
VITE_APP_BASE_API = 'http://192.168.6.107:8888/api'
|
VITE_APP_BASE_API = 'http://localhost:8888/api'
|
||||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||||
VITE_BUILD_COMPRESS = gzip
|
VITE_BUILD_COMPRESS = gzip
|
||||||
80
mes-ui/src/api/maintenanceRecord.ts
Normal file
80
mes-ui/src/api/maintenanceRecord.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// MES设备维修保养记录表 类型定义
|
||||||
|
export interface MaintenanceRecord {
|
||||||
|
recordId?: string
|
||||||
|
|
||||||
|
equipmentId?: string
|
||||||
|
|
||||||
|
recordType?: string
|
||||||
|
|
||||||
|
itemContent?: string
|
||||||
|
|
||||||
|
handleContent?: string
|
||||||
|
|
||||||
|
executorId?: number
|
||||||
|
|
||||||
|
startTime?: string
|
||||||
|
|
||||||
|
endTime?: string
|
||||||
|
|
||||||
|
recordStatus?: string
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
updateTime?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MES设备维修保养记录表 API
|
||||||
|
export const maintenanceRecordApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; recordId?: string }) {
|
||||||
|
return request({ url: '/biz/maintenanceRecord/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(recordId: string) {
|
||||||
|
return request({ url: `/biz/maintenanceRecord/${recordId}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: MaintenanceRecord) {
|
||||||
|
return request({ url: '/biz/maintenanceRecord', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: MaintenanceRecord) {
|
||||||
|
return request({ url: '/biz/maintenanceRecord', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(recordIds: string[]) {
|
||||||
|
return request({ url: `/biz/maintenanceRecord/${recordIds.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; recordId?: string }) {
|
||||||
|
const p: Record<string, any> = {}
|
||||||
|
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||||
|
if (params?.recordId !== undefined && params?.recordId !== null) p.recordId = params.recordId
|
||||||
|
return request({ url: `/biz/maintenanceRecord/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/maintenanceRecord/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/maintenanceRecord/template`, method: 'get', responseType: 'blob' })
|
||||||
|
}
|
||||||
|
}
|
||||||
441
mes-ui/src/views/biz/maintenanceRecord/index.vue
Normal file
441
mes-ui/src/views/biz/maintenanceRecord/index.vue
Normal file
@ -0,0 +1,441 @@
|
|||||||
|
<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.recordId" placeholder="请输入维保记录编号(后端代码自动生成,唯一主键)" 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.recordId"
|
||||||
|
: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="设备ID,关联mes_equipment设备表主键" path="equipmentId">
|
||||||
|
<n-input v-model:value="formData.equipmentId" placeholder="请输入设备ID,关联mes_equipment设备表主键" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="记录类型:maintain=保养,repair=维修" path="recordType">
|
||||||
|
<n-select v-model:value="formData.recordType" placeholder="请选择记录类型:maintain=保养,repair=维修" :options="[]" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="故障现象/保养项目详情" path="itemContent">
|
||||||
|
<n-input v-model:value="formData.itemContent" type="textarea" placeholder="请输入故障现象/保养项目详情" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="维修处理措施/保养执行内容" path="handleContent">
|
||||||
|
<n-input v-model:value="formData.handleContent" type="textarea" placeholder="请输入维修处理措施/保养执行内容" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="执行人ID,关联sys_user系统用户表主键" path="executorId">
|
||||||
|
<n-input v-model:value="formData.executorId" placeholder="请输入执行人ID,关联sys_user系统用户表主键" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="维保作业开始时间" path="startTime">
|
||||||
|
<n-date-picker v-model:value="formData.startTime" 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="单据状态:pending=待处理,finished=已完成" path="recordStatus">
|
||||||
|
<n-select v-model:value="formData.recordStatus" placeholder="请选择单据状态:pending=待处理,finished=已完成" :options="recordStatusOptions" />
|
||||||
|
</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="导入MES设备维修保养记录表" 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 { maintenanceRecordApi, type MaintenanceRecord } from '@/api/maintenanceRecord'
|
||||||
|
import { dictDataApi } from '@/api/org'
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
recordId: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<MaintenanceRecord[]>([])
|
||||||
|
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: MaintenanceRecord = {
|
||||||
|
equipmentId: '',
|
||||||
|
recordType: '',
|
||||||
|
itemContent: '',
|
||||||
|
handleContent: '',
|
||||||
|
executorId: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
recordStatus: '',
|
||||||
|
}
|
||||||
|
const formData = reactive<MaintenanceRecord>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
const recordStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
equipmentId: { required: true, message: '请输入设备ID,关联mes_equipment设备表主键', trigger: 'blur' },
|
||||||
|
recordType: { required: true, message: '请输入记录类型:maintain=保养,repair=维修', trigger: 'blur' },
|
||||||
|
itemContent: { required: true, message: '请输入故障现象/保养项目详情', trigger: 'blur' },
|
||||||
|
handleContent: { required: true, message: '请输入维修处理措施/保养执行内容', trigger: 'blur' },
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns: DataTableColumns<MaintenanceRecord> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title: '维保记录编号(后端代码自动生成,唯一主键)', key: 'recordId' },
|
||||||
|
{ title: '设备ID,关联mes_equipment设备表主键', key: 'equipmentId' },
|
||||||
|
{ title: '记录类型:maintain=保养,repair=维修', key: 'recordType' },
|
||||||
|
{ title: '故障现象/保养项目详情', key: 'itemContent' },
|
||||||
|
{ title: '维修处理措施/保养执行内容', key: 'handleContent' },
|
||||||
|
{ title: '执行人ID,关联sys_user系统用户表主键', key: 'executorId' },
|
||||||
|
{ title: '维保作业开始时间', key: 'startTime' },
|
||||||
|
{ title: '维保作业结束时间,待处理单据为空', key: 'endTime' },
|
||||||
|
{ title: '单据状态:pending=待处理,finished=已完成', key: 'recordStatus',
|
||||||
|
render(row) {
|
||||||
|
const val = row.recordStatus
|
||||||
|
const opt = recordStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
return opt ? opt.label : (val ?? '-')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '单据创建时间', key: 'createTime', width: 180 },
|
||||||
|
{ title: '单据最后更新时间', key: 'updateTime', width: 180 },
|
||||||
|
{
|
||||||
|
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 maintenanceRecordApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
recordId: searchForm.recordId || undefined,
|
||||||
|
})
|
||||||
|
tableData.value = res.list
|
||||||
|
pagination.itemCount = res.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
function handleSearch() {
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchForm.recordId = ''
|
||||||
|
|
||||||
|
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 = '新增MES设备维修保养记录表'
|
||||||
|
Object.assign(formData, defaultFormData)
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
function handleEdit(row: MaintenanceRecord) {
|
||||||
|
modalTitle.value = '编辑MES设备维修保养记录表'
|
||||||
|
Object.assign(formData, row)
|
||||||
|
if (formData.startTime && typeof formData.startTime === 'string') {
|
||||||
|
formData.startTime = new Date(formData.startTime.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()
|
||||||
|
}
|
||||||
|
if (formData.updateTime && typeof formData.updateTime === 'string') {
|
||||||
|
formData.updateTime = new Date(formData.updateTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
async function handleSubmit() {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
try {
|
||||||
|
const submitData = { ...formData } as MaintenanceRecord
|
||||||
|
if (typeof submitData.startTime === 'number') {
|
||||||
|
submitData.startTime = new Date(submitData.startTime).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 (typeof submitData.updateTime === 'number') {
|
||||||
|
submitData.updateTime = new Date(submitData.updateTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (submitData.recordId) {
|
||||||
|
await maintenanceRecordApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await maintenanceRecordApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: MaintenanceRecord) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await maintenanceRecordApi.delete([row.recordId!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await maintenanceRecordApi.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.recordId) params.recordId = searchForm.recordId
|
||||||
|
const blob = await maintenanceRecordApi.export(params)
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = 'MES设备维修保养记录表数据.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
async function handleDownloadTemplate() {
|
||||||
|
try {
|
||||||
|
const blob = await maintenanceRecordApi.downloadTemplate()
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = 'MES设备维修保养记录表导入模板.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导入上传
|
||||||
|
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
|
||||||
|
if (!file.file) return
|
||||||
|
try {
|
||||||
|
const result = await maintenanceRecordApi.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_status')
|
||||||
|
recordStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: d.dictValue }))
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
6029
package-lock.json
generated
Normal file
6029
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
pnpm-workspace.yaml
Normal file
6
pnpm-workspace.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
allowBuilds:
|
||||||
|
'@parcel/watcher': set this to true or false
|
||||||
|
core-js: set this to true or false
|
||||||
|
electron-winstaller: set this to true or false
|
||||||
|
esbuild: set this to true or false
|
||||||
|
vue-demi: set this to true or false
|
||||||
81
src/api/AssingWorkDetail.ts
Normal file
81
src/api/AssingWorkDetail.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// AssingWorkDetail 类型定义
|
||||||
|
export interface AssingWorkDetail {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
assingWorkId?: number
|
||||||
|
|
||||||
|
userId?: number
|
||||||
|
|
||||||
|
deviceId?: number
|
||||||
|
|
||||||
|
num?: number
|
||||||
|
|
||||||
|
source?: number
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssingWorkDetail API
|
||||||
|
export const assingWorkDetailApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; id?: number }) {
|
||||||
|
return request({ url: '/biz/assingWorkDetail/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: string) {
|
||||||
|
return request({ url: `/biz/assingWorkDetail/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: AssingWorkDetail) {
|
||||||
|
return request({ url: '/biz/assingWorkDetail', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: AssingWorkDetail) {
|
||||||
|
return request({ url: '/biz/assingWorkDetail', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: string[]) {
|
||||||
|
return request({ url: `/biz/assingWorkDetail/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; id?: 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
|
||||||
|
return request({ url: `/biz/assingWorkDetail/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/assingWorkDetail/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/assingWorkDetail/template`, method: 'get', responseType: 'blob' })
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//根据派工id获取详情信息
|
||||||
|
selectAssingWorkDetailListByAssingWorkId(assingWorkId:number) {
|
||||||
|
return request({
|
||||||
|
url:`/biz/assingWorkDetail/getAssingWorkDetailList/${assingWorkId}`,
|
||||||
|
method:"get"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
94
src/api/basicProcessPlan.ts
Normal file
94
src/api/basicProcessPlan.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// 基础主数据--工序表 类型定义
|
||||||
|
export interface BasicProcessPlan {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
name?: string
|
||||||
|
|
||||||
|
code?: string
|
||||||
|
|
||||||
|
sort?: number
|
||||||
|
|
||||||
|
procurement?: number
|
||||||
|
|
||||||
|
outsource?: number
|
||||||
|
|
||||||
|
qualityInspection?: number
|
||||||
|
|
||||||
|
storageEntry?: number
|
||||||
|
|
||||||
|
workCenterName?: string
|
||||||
|
|
||||||
|
departmentName?: string
|
||||||
|
|
||||||
|
operDescription?: string
|
||||||
|
|
||||||
|
createBy?: number
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 基础主数据--工序表 API
|
||||||
|
export const basicProcessPlanApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; id?: number; name?: string }) {
|
||||||
|
return request({ url: '/biz/basicProcessPlan/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: string) {
|
||||||
|
return request({ url: `/biz/basicProcessPlan/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: BasicProcessPlan) {
|
||||||
|
return request({ url: '/biz/basicProcessPlan', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: BasicProcessPlan) {
|
||||||
|
return request({ url: '/biz/basicProcessPlan', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: string[]) {
|
||||||
|
return request({ url: `/biz/basicProcessPlan/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; id?: number; name?: string }) {
|
||||||
|
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
|
||||||
|
return request({ url: `/biz/basicProcessPlan/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/basicProcessPlan/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/basicProcessPlan/template`, method: 'get', responseType: 'blob' })
|
||||||
|
},
|
||||||
|
|
||||||
|
//获取分页列表
|
||||||
|
list(params:any) {
|
||||||
|
return request({
|
||||||
|
url:"/biz/basicProcessPlan/list",
|
||||||
|
method:"get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -114,5 +114,12 @@ export const deviceApi = {
|
|||||||
responseType:"blob"
|
responseType:"blob"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
getDeviceList(params:{sectionIds:any}){
|
||||||
|
return request({
|
||||||
|
url:"/biz/device/getDeviceList",
|
||||||
|
method:"get",
|
||||||
|
params
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
80
src/api/maintenanceRecord.ts
Normal file
80
src/api/maintenanceRecord.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// MES设备维修保养记录表 类型定义
|
||||||
|
export interface MaintenanceRecord {
|
||||||
|
recordId?: string
|
||||||
|
|
||||||
|
equipmentId?: string
|
||||||
|
|
||||||
|
recordType?: string
|
||||||
|
|
||||||
|
itemContent?: string
|
||||||
|
|
||||||
|
handleContent?: string
|
||||||
|
|
||||||
|
executorId?: number
|
||||||
|
|
||||||
|
startTime?: string
|
||||||
|
|
||||||
|
endTime?: string
|
||||||
|
|
||||||
|
recordStatus?: string
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
updateTime?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MES设备维修保养记录表 API
|
||||||
|
export const maintenanceRecordApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; recordId?: string }) {
|
||||||
|
return request({ url: '/biz/maintenanceRecord/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(recordId: string) {
|
||||||
|
return request({ url: `/biz/maintenanceRecord/${recordId}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: MaintenanceRecord) {
|
||||||
|
return request({ url: '/biz/maintenanceRecord', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: MaintenanceRecord) {
|
||||||
|
return request({ url: '/biz/maintenanceRecord', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(recordIds: string[]) {
|
||||||
|
return request({ url: `/biz/maintenanceRecord/${recordIds.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; recordId?: string }) {
|
||||||
|
const p: Record<string, any> = {}
|
||||||
|
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||||
|
if (params?.recordId !== undefined && params?.recordId !== null) p.recordId = params.recordId
|
||||||
|
return request({ url: `/biz/maintenanceRecord/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/maintenanceRecord/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/maintenanceRecord/template`, method: 'get', responseType: 'blob' })
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -255,6 +255,8 @@ export function processItemToEntity(
|
|||||||
qualityInspection: item.qualityInspection,
|
qualityInspection: item.qualityInspection,
|
||||||
|
|
||||||
storageEntry: item.storageEntry,
|
storageEntry: item.storageEntry,
|
||||||
|
|
||||||
|
workCenterName:item.workCenterName
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@ export interface ProcessRouteStep {
|
|||||||
|
|
||||||
changeTime?: string
|
changeTime?: string
|
||||||
|
|
||||||
|
isBind?: boolean
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 工艺路线工序明细 API
|
// 工艺路线工序明细 API
|
||||||
@ -41,6 +43,7 @@ export const processRouteStepApi = {
|
|||||||
return request({ url: '/biz/processRouteStep/page', method: 'get', params })
|
return request({ url: '/biz/processRouteStep/page', method: 'get', params })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// 获取详情
|
// 获取详情
|
||||||
detail(id: number) {
|
detail(id: number) {
|
||||||
return request({ url: `/biz/processRouteStep/${id}`, method: 'get' })
|
return request({ url: `/biz/processRouteStep/${id}`, method: 'get' })
|
||||||
@ -85,5 +88,13 @@ export const processRouteStepApi = {
|
|||||||
// 下载导入模板
|
// 下载导入模板
|
||||||
downloadTemplate() {
|
downloadTemplate() {
|
||||||
return request({ url: `/biz/processRouteStep/template`, method: 'get', responseType: 'blob' })
|
return request({ url: `/biz/processRouteStep/template`, method: 'get', responseType: 'blob' })
|
||||||
|
},
|
||||||
|
|
||||||
|
list(params:{id:number}) {
|
||||||
|
return request({
|
||||||
|
url:"/biz/processRouteStep/list",
|
||||||
|
method:'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,32 @@
|
|||||||
import { request } from '@/utils/request'
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
export interface AssingWork {
|
||||||
|
id:number,
|
||||||
|
processId:number,
|
||||||
|
processName:number,
|
||||||
|
userId:string,
|
||||||
|
quantity:number,
|
||||||
|
rework:number,
|
||||||
|
reworkNum:number,
|
||||||
|
completeQuantity:number,
|
||||||
|
completedTime:Date,
|
||||||
|
createTime:Date,
|
||||||
|
createBy:number,
|
||||||
|
status:number,
|
||||||
|
reason:string,
|
||||||
|
pauseTime:Date,
|
||||||
|
assingStatus:number,
|
||||||
|
assingCode:string,
|
||||||
|
parentId:number,
|
||||||
|
reworkSort:number,
|
||||||
|
workshopId:number,
|
||||||
|
sectionId:number,
|
||||||
|
deviceId:number,
|
||||||
|
traceId:number,
|
||||||
|
qcNum:number
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//派工列表
|
//派工列表
|
||||||
export function disworlist(params:any) {
|
export function disworlist(params:any) {
|
||||||
return request({
|
return request({
|
||||||
@ -38,7 +65,7 @@ export function pauseresume(data:any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//我的派工任务
|
//我的派工任务
|
||||||
export function mytasks(params:any) {
|
export function mytasks(params:{page:number,pageSize:number,processName:string}) {
|
||||||
return request({
|
return request({
|
||||||
url: `/mes/dispatch/my-tasks`,
|
url: `/mes/dispatch/my-tasks`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|||||||
116
src/api/qcItem.ts
Normal file
116
src/api/qcItem.ts
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
import { any } from 'three/tsl'
|
||||||
|
|
||||||
|
// 质检项表 类型定义
|
||||||
|
export interface QcItem {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
name?: string
|
||||||
|
|
||||||
|
spec?: string
|
||||||
|
|
||||||
|
plans?: string
|
||||||
|
|
||||||
|
desc?: string
|
||||||
|
|
||||||
|
createby?: number
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
updateTime?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 质检项表 API
|
||||||
|
export const qcItemApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; id?: number; name?: string }) {
|
||||||
|
return request({ url: '/biz/qcItem/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: string) {
|
||||||
|
return request({ url: `/biz/qcItem/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: QcItem) {
|
||||||
|
return request({ url: '/biz/qcItem', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: QcItem) {
|
||||||
|
return request({ url: '/biz/qcItem', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: string[]) {
|
||||||
|
return request({ url: `/biz/qcItem/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; id?: number; name?: string }) {
|
||||||
|
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
|
||||||
|
return request({ url: `/biz/qcItem/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/qcItem/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/qcItem/template`, method: 'get', responseType: 'blob' })
|
||||||
|
},
|
||||||
|
|
||||||
|
//上传文件
|
||||||
|
uploadFile(file:File) {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append("file",file)
|
||||||
|
return request({
|
||||||
|
url:"/sys/file/upload",
|
||||||
|
method:"post",
|
||||||
|
data:formData
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//查询文件列表
|
||||||
|
getPlansFiles(data:{plans:string}) {
|
||||||
|
return request({
|
||||||
|
url:"/biz/qcItem/getPlanFiles",
|
||||||
|
method:"post",
|
||||||
|
data:data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
//创建关联
|
||||||
|
createQcProcessRelate(data:any) {
|
||||||
|
return request({
|
||||||
|
url:"/biz/qcItem/createQcProcessRelate",
|
||||||
|
method:"post",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//显示质检项关联列表
|
||||||
|
list(params:any) {
|
||||||
|
return request({
|
||||||
|
url:"/biz/qcItem/list",
|
||||||
|
method:"get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
71
src/api/qcitemProcess.ts
Normal file
71
src/api/qcitemProcess.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// 质检项和工序关联表 类型定义
|
||||||
|
export interface QcitemProcess {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
qcItemId?: number
|
||||||
|
|
||||||
|
processId?: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 质检项和工序关联表 API
|
||||||
|
export const qcitemProcessApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; id?: number }) {
|
||||||
|
return request({ url: '/biz/qcitemProcess/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: number) {
|
||||||
|
return request({ url: `/biz/qcitemProcess/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: QcitemProcess) {
|
||||||
|
return request({ url: '/biz/qcitemProcess', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
//质检项关联
|
||||||
|
qualityItemcreate(data: QcitemProcess) {
|
||||||
|
return request({ url: '/biz/qcitemProcess/create', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: QcitemProcess) {
|
||||||
|
return request({ url: '/biz/qcitemProcess', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: number[]) {
|
||||||
|
return request({ url: `/biz/qcitemProcess/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: number[]; id?: 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
|
||||||
|
return request({ url: `/biz/qcitemProcess/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/qcitemProcess/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/qcitemProcess/template`, method: 'get', responseType: 'blob' })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -68,10 +68,11 @@ export const sectionApi = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
list() {
|
list(params:{sectionName:string}) {
|
||||||
return request({
|
return request({
|
||||||
url:"/biz/section/list",
|
url:"/biz/section/list",
|
||||||
method:"get"
|
method:"get",
|
||||||
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
76
src/api/stationHandover.ts
Normal file
76
src/api/stationHandover.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// 工位交接记录表 类型定义
|
||||||
|
export interface StationHandover {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
deviceId?: number
|
||||||
|
|
||||||
|
stationId?: number
|
||||||
|
|
||||||
|
handoverPersonId?: number
|
||||||
|
|
||||||
|
receiverPersonId?: number
|
||||||
|
|
||||||
|
handoverTime?: string
|
||||||
|
|
||||||
|
remark?: string
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
createBy?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 工位交接记录表 API
|
||||||
|
export const stationHandoverApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; deviceIds?: string }) {
|
||||||
|
return request({ url: '/biz/stationHandover/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: number) {
|
||||||
|
return request({ url: `/biz/stationHandover/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: StationHandover) {
|
||||||
|
return request({ url: '/biz/stationHandover', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: StationHandover) {
|
||||||
|
return request({ url: '/biz/stationHandover', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: number[]) {
|
||||||
|
return request({ url: `/biz/stationHandover/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: number[]; id?: 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
|
||||||
|
return request({ url: `/biz/stationHandover/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/stationHandover/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/stationHandover/template`, method: 'get', responseType: 'blob' })
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -134,7 +134,17 @@ export const userApi = {
|
|||||||
url:"sys/user/list",
|
url:"sys/user/list",
|
||||||
method:'get'
|
method:'get'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
//获取设备负责人
|
||||||
|
getEquipmentManager() {
|
||||||
|
return request({
|
||||||
|
url:"/sys/user/getEquipmentManager",
|
||||||
|
method:"get"
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 角色管理 ====================
|
// ==================== 角色管理 ====================
|
||||||
@ -423,6 +433,13 @@ export const fileApi = {
|
|||||||
|
|
||||||
rename(id: number, newName: string): Promise<void> {
|
rename(id: number, newName: string): Promise<void> {
|
||||||
return request({ url: `/sys/file/${id}/rename`, method: 'put', data: { newName } })
|
return request({ url: `/sys/file/${id}/rename`, method: 'put', data: { newName } })
|
||||||
|
},
|
||||||
|
downloadPlanFile(id:number) {
|
||||||
|
return request({
|
||||||
|
url:`/sys/file/download/${id}`,
|
||||||
|
method:"get",
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -282,6 +282,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
component: () => import('@/views/biz/flowingAround/index.vue'),
|
component: () => import('@/views/biz/flowingAround/index.vue'),
|
||||||
meta: { title: '流转记录表', icon: 'ListOutline' }
|
meta: { title: '流转记录表', icon: 'ListOutline' }
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: 'biz/outsourcing',
|
path: 'biz/outsourcing',
|
||||||
name: 'outsourcing',
|
name: 'outsourcing',
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
const BASE_API = import.meta.env.VITE_APP_BASE_API
|
// const BASE_API = import.meta.env.VITE_APP_BASE_API
|
||||||
|
|
||||||
// API响应结构
|
// API响应结构
|
||||||
interface ApiResponse<T = any> {
|
interface ApiResponse<T = any> {
|
||||||
@ -117,7 +117,6 @@ async function decryptResponseData(data: string): Promise<any> {
|
|||||||
// 后端 API 统一使用 /api 前缀
|
// 后端 API 统一使用 /api 前缀
|
||||||
const service: AxiosInstance = axios.create({
|
const service: AxiosInstance = axios.create({
|
||||||
baseURL:'/api',
|
baseURL:'/api',
|
||||||
//baseURL: BASE_API,
|
|
||||||
timeout: 30000
|
timeout: 30000
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
654
src/views/biz/basicProcessPlan/index.vue
Normal file
654
src/views/biz/basicProcessPlan/index.vue
Normal file
@ -0,0 +1,654 @@
|
|||||||
|
<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.name" placeholder="请输入工序名称" 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 @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"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
:scroll-x="1200"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:item-count="pagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
@update:checked-row-keys="handleCheck"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ pagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</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-grid x-gap="12" :cols="2">
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否采购" path="procurement">
|
||||||
|
<n-radio-group v-model:value="formData.procurement" name="procurement">
|
||||||
|
<n-space>
|
||||||
|
<n-radio :value="1">是</n-radio>
|
||||||
|
<n-radio :value="0">否</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否委外" path="outsource">
|
||||||
|
<n-radio-group v-model:value="formData.outsource" name="outsource">
|
||||||
|
<n-space>
|
||||||
|
<n-radio :value="1">是</n-radio>
|
||||||
|
<n-radio :value="0">否</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
|
||||||
|
<n-grid x-gap="12" :cols="2">
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否质检" path="qualityInspection">
|
||||||
|
<n-radio-group v-model:value="formData.qualityInspection" name="qualityInspection">
|
||||||
|
<n-space>
|
||||||
|
<n-radio :value="1">是</n-radio>
|
||||||
|
<n-radio :value="0">否</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否直接入库" path="storageEntry">
|
||||||
|
<n-radio-group v-model:value="formData.storageEntry" name="storageEntry">
|
||||||
|
<n-space>
|
||||||
|
<n-radio :value="1">是</n-radio>
|
||||||
|
<n-radio :value="0">否</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
<n-form-item label="工作中心" path="workCenterName">
|
||||||
|
<n-input v-model:value="formData.workCenterName" placeholder="请输入工作中心" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="生产车间" path="departmentName">
|
||||||
|
<n-input v-model:value="formData.departmentName" placeholder="请输入生产车间(工序级)" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="工序说明" path="operDescription">
|
||||||
|
<n-input v-model:value="formData.operDescription" type="textarea" 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>
|
||||||
|
|
||||||
|
<!--关联质检项抽屉-->
|
||||||
|
<n-drawer v-model:show="qualityItemModel" :width="800" >
|
||||||
|
<n-drawer-content title="质检项列表">
|
||||||
|
<n-space justify="space-between" class="mb-3">
|
||||||
|
<n-checkbox v-model:checked="isAllCheck" @update:checked="handleAllCheck">
|
||||||
|
全选当前筛选工序
|
||||||
|
</n-checkbox>
|
||||||
|
<n-tag type="info">已勾选 {{ selectQualityItemIds.length }} 道质检项</n-tag>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-data-table
|
||||||
|
:columns="qualityItemColums"
|
||||||
|
:data="qualityItemList"
|
||||||
|
:row-key="getRowKey"
|
||||||
|
max-height="700"
|
||||||
|
v-model:checked-row-keys="selectQualityItemIds"
|
||||||
|
:scroll-x="1200"
|
||||||
|
:loading="relateLoading"
|
||||||
|
@update:checked-row-keys="onCheckedChange"
|
||||||
|
/>
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="relatePagination.page"
|
||||||
|
v-model:page-size="relatePagination.pageSize"
|
||||||
|
:item-count="relatePagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handleRelatePageChange"
|
||||||
|
@update:page-size="handleRelatePageSizeChange"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ relatePagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
|
<!-- 底部操作按钮 -->
|
||||||
|
<template #footer>
|
||||||
|
<n-space justify="end">
|
||||||
|
<n-button @click="qualityItemModel = false">取消</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-drawer-content>
|
||||||
|
</n-drawer>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, h, onMounted,computed } from 'vue'
|
||||||
|
import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions, NTag } from 'naive-ui'
|
||||||
|
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
|
||||||
|
import { basicProcessPlanApi, type BasicProcessPlan } from '@/api/basicProcessPlan'
|
||||||
|
import { qcItemApi,QcItem } from '@/api/qcItem'
|
||||||
|
import {qcitemProcessApi,QcitemProcess} from '@/api/qcitemProcess'
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
//关联质检项
|
||||||
|
const qualityItemModel = ref<boolean>(false)
|
||||||
|
const selectQualityItemIds = ref<number[]>([])
|
||||||
|
const qualityItemList = ref<QcItem[]>([])
|
||||||
|
const qualityItemRelate = ref<QcitemProcess>({
|
||||||
|
processId: undefined,
|
||||||
|
qualityItemIds: undefined
|
||||||
|
})
|
||||||
|
const relateLoading = ref<boolean>(false)
|
||||||
|
const relatePagination = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
itemCount: 0,
|
||||||
|
showSizePicker: true,
|
||||||
|
pageSizes: [10, 20, 50]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
id: null as number | null,
|
||||||
|
name: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<BasicProcessPlan[]>([])
|
||||||
|
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: BasicProcessPlan = {
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
sort: undefined,
|
||||||
|
procurement: undefined,
|
||||||
|
outsource: undefined,
|
||||||
|
qualityInspection: undefined,
|
||||||
|
storageEntry: undefined,
|
||||||
|
workCenterName: '',
|
||||||
|
departmentName: '',
|
||||||
|
operDescription: '',
|
||||||
|
}
|
||||||
|
const formData = reactive<BasicProcessPlan>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns: DataTableColumns<BasicProcessPlan> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title: '工序名称', key: 'name' },
|
||||||
|
{ title: '工序编码', key: 'code' },
|
||||||
|
{ title: '工序顺序', key: 'sort' },
|
||||||
|
{ title: '是否采购', key: 'procurement',
|
||||||
|
render(row) {
|
||||||
|
var opt = row.procurement
|
||||||
|
return h(NTag,{type: opt ? 'success' : 'error', size: 'small'},{default: () => (opt ? '是' : '否')})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '是否委外', key: 'outsource',
|
||||||
|
render(row) {
|
||||||
|
var opt = row.outsource
|
||||||
|
return h(NTag,{type: opt ? 'success' : 'error', size: 'small'},{default: () => (opt ? '是' : '否')})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '是否质检', key: 'qualityInspection',
|
||||||
|
render(row) {
|
||||||
|
var opt = row.qualityInspection
|
||||||
|
return h(NTag,{type: opt ? 'success' : 'error', size: 'small'},{default: () => (opt ? '是' : '否')})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '是否直接入库', key: 'storageEntry',
|
||||||
|
render(row) {
|
||||||
|
var opt = row.qualityInspection
|
||||||
|
return h(NTag,{type: opt ? 'success' : 'error', size: 'small'},{default: () => (opt ? '是' : '否')})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '工作中心', key: 'workCenterName' },
|
||||||
|
{ title: '生产车间', key: 'departmentName' },
|
||||||
|
{ title: '工序说明', key: 'operDescription' },
|
||||||
|
{ title: '创建人', key: 'createBy' },
|
||||||
|
{ title: '创建时间', key: 'createTime', width: 180 },
|
||||||
|
{
|
||||||
|
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) }), ' 删除']
|
||||||
|
}),
|
||||||
|
h(NButton, { size: 'small', quaternary: true, onClick: () => handleOpenRelateModel(row) }, {
|
||||||
|
default: () => ['关联质检项']
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
async function loadData() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await basicProcessPlanApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
id: searchForm.id || undefined,
|
||||||
|
name: searchForm.name || 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 = ''
|
||||||
|
|
||||||
|
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: BasicProcessPlan) {
|
||||||
|
modalTitle.value = '编辑基础主数据--工序表'
|
||||||
|
Object.assign(formData, row)
|
||||||
|
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 BasicProcessPlan
|
||||||
|
if (typeof submitData.createTime === 'number') {
|
||||||
|
submitData.createTime = new Date(submitData.createTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (submitData.id) {
|
||||||
|
await basicProcessPlanApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await basicProcessPlanApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: BasicProcessPlan) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await basicProcessPlanApi.delete([row.id!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await basicProcessPlanApi.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
|
||||||
|
const blob = await basicProcessPlanApi.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 basicProcessPlanApi.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 basicProcessPlanApi.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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//开启关联质检项抽屉
|
||||||
|
function handleOpenRelateModel(row) {
|
||||||
|
relateLoading.value = true
|
||||||
|
qualityItemModel.value = true
|
||||||
|
qualityItemRelate.processId = row.id
|
||||||
|
getQualityList(row.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getQualityList(id) {
|
||||||
|
|
||||||
|
try{
|
||||||
|
const res = await qcItemApi.list({
|
||||||
|
id:id,
|
||||||
|
page:relatePagination.page,
|
||||||
|
pageSize:relatePagination.pageSize
|
||||||
|
})
|
||||||
|
|
||||||
|
qualityItemList.value = res.data.list
|
||||||
|
relatePagination.itemCount = res.data.total
|
||||||
|
|
||||||
|
//回显
|
||||||
|
selectQualityItemIds.value = qualityItemList.value.filter(item=> item.isBind).map(item=>item.id)
|
||||||
|
relateLoading.value = false
|
||||||
|
}catch(error) {
|
||||||
|
console.log("异常信息:"+error);
|
||||||
|
message.error("获取质检列表失败")
|
||||||
|
relateLoading.value = false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//取消/全选
|
||||||
|
const isAllCheck = computed({
|
||||||
|
get() {
|
||||||
|
return qualityItemList.value.length > 0 && selectQualityItemIds.value.length === qualityItemList.value.length
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
if(val) {
|
||||||
|
selectQualityItemIds.value = qualityItemList.value.map(item=> item.id)
|
||||||
|
}else{
|
||||||
|
selectQualityItemIds.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleAllCheck = (val:boolean) => {
|
||||||
|
isAllCheck.value = val
|
||||||
|
}
|
||||||
|
|
||||||
|
const onCheckedChange = async (keys:number[]) =>{
|
||||||
|
selectQualityItemIds.value = keys
|
||||||
|
qualityItemRelate.qualityItemIds = selectQualityItemIds.value
|
||||||
|
try{
|
||||||
|
await qcitemProcessApi.qualityItemcreate(qualityItemRelate);
|
||||||
|
message.success("关联成功")
|
||||||
|
getQualityList(qualityItemRelate.processId)
|
||||||
|
|
||||||
|
}catch(error) {
|
||||||
|
message.error("关联失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const getRowKey = (row: any) => row.id
|
||||||
|
const qualityItemColums: DataTableColumns<QcItem> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title:"质检项名称", key:"name"},
|
||||||
|
{ title: "关联状态",key:"isBind",
|
||||||
|
render(row) {
|
||||||
|
const val = row.isBind;
|
||||||
|
if (val) {
|
||||||
|
return h(NTag, { type: "success" }, { default: () => "已关联" });
|
||||||
|
} else {
|
||||||
|
return h(NTag, { type: "default" }, { default: () => "未关联" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
function handleRelatePageChange(page: number) {
|
||||||
|
relatePagination.page = page
|
||||||
|
getQualityList(qualityItemRelate.processId)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRelatePageSizeChange(pageSize: number) {
|
||||||
|
relatePagination.pageSize = pageSize
|
||||||
|
relatePagination.page = 1
|
||||||
|
getQualityList(qualityItemRelate.processId)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -52,13 +52,26 @@
|
|||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:pagination="pagination"
|
|
||||||
:row-key="(row) => row.id"
|
:row-key="(row) => row.id"
|
||||||
:scroll-x="1200"
|
:scroll-x="1200"
|
||||||
@update:page="handlePageChange"
|
|
||||||
@update:page-size="handlePageSizeChange"
|
|
||||||
@update:checked-row-keys="handleCheck"
|
|
||||||
/>
|
/>
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:item-count="pagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
@update:checked-row-keys="handleCheck"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ pagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
||||||
<!-- 新增/编辑弹窗 -->
|
<!-- 新增/编辑弹窗 -->
|
||||||
@ -95,6 +108,17 @@
|
|||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
/>
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
<n-form-item label="设备负责人" path="deviceManager">
|
||||||
|
<n-select
|
||||||
|
v-model:value="formData.deviceManagerList"
|
||||||
|
:options="deviceManagerList"
|
||||||
|
multiple
|
||||||
|
placeholder="请选择设备类型"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
<n-form-item label="生产厂家" path="manufacturer">
|
<n-form-item label="生产厂家" path="manufacturer">
|
||||||
<n-input v-model:value="formData.manufacturer" placeholder="请输入生产厂家" />
|
<n-input v-model:value="formData.manufacturer" placeholder="请输入生产厂家" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
@ -161,12 +185,15 @@ import { deviceApi, type Device } from '@/api/device'
|
|||||||
|
|
||||||
import { dictDataApi } from '@/api/org'
|
import { dictDataApi } from '@/api/org'
|
||||||
import {sectionApi, type Section} from '@/api/section'
|
import {sectionApi, type Section} from '@/api/section'
|
||||||
|
import { SysUser, userApi } from '@/api/system'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
//设备负责人列表
|
||||||
|
const deviceManagerList = ref<{label:string,value:any}[]>([])
|
||||||
|
|
||||||
let sectionList = reactive<{label:string,value:any}[]>([])
|
let sectionList = reactive<{label:string,value:any}[]>([])
|
||||||
|
|
||||||
// 搜索表单
|
// 搜索表单
|
||||||
@ -207,6 +234,7 @@ const defaultFormData: Device = {
|
|||||||
status:0,
|
status:0,
|
||||||
deviceFlag:'mes_equipment',
|
deviceFlag:'mes_equipment',
|
||||||
synEquipId: null as number | null,
|
synEquipId: null as number | null,
|
||||||
|
deviceManagerList: null as any | null
|
||||||
}
|
}
|
||||||
const formData = reactive<Device>({ ...defaultFormData })
|
const formData = reactive<Device>({ ...defaultFormData })
|
||||||
|
|
||||||
@ -218,6 +246,17 @@ const deviceFlagList = ref<{ label: string; value: any ;class:any}[]>([])
|
|||||||
|
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
const formRules = {
|
const formRules = {
|
||||||
|
deviceName:[{ required: true, message: '请输入设备名称', trigger: 'blur' },],
|
||||||
|
sectionId:[{
|
||||||
|
required: true,
|
||||||
|
validator(rule:any,value: any) {
|
||||||
|
if(!value){
|
||||||
|
return new Error(`请选择所属工段`)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
trigger: ['blur']
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表格列
|
// 表格列
|
||||||
@ -229,6 +268,7 @@ const columns: DataTableColumns<Device> = [
|
|||||||
render: (row) => row.synEquipId ?? '-'
|
render: (row) => row.synEquipId ?? '-'
|
||||||
},
|
},
|
||||||
{ title: '设备类型', key: 'deviceType' },
|
{ title: '设备类型', key: 'deviceType' },
|
||||||
|
{ title: '设备负责人', key: 'deviceManagerName' },
|
||||||
{ title: '所属工段', key: 'sectionName' },
|
{ title: '所属工段', key: 'sectionName' },
|
||||||
{ title: '设备型号', key: 'spec' },
|
{ title: '设备型号', key: 'spec' },
|
||||||
{ title: '生产厂家', key: 'manufacturer' },
|
{ title: '生产厂家', key: 'manufacturer' },
|
||||||
@ -319,9 +359,12 @@ function goRealtimeBoard() {
|
|||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
function handleEdit(row: Device) {
|
function handleEdit(row: Device) {
|
||||||
modalTitle.value = '编辑设备表'
|
|
||||||
Object.assign(formData, row)
|
modalTitle.value = '编辑设备表'
|
||||||
modalVisible.value = true
|
Object.assign(formData, row)
|
||||||
|
console.log(formData);
|
||||||
|
|
||||||
|
modalVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
@ -329,6 +372,7 @@ async function handleSubmit() {
|
|||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
try {
|
try {
|
||||||
const submitData = { ...formData } as Device
|
const submitData = { ...formData } as Device
|
||||||
|
|
||||||
if (typeof submitData.manufactureDate === 'number') {
|
if (typeof submitData.manufactureDate === 'number') {
|
||||||
submitData.manufactureDate = new Date(submitData.manufactureDate).toISOString().slice(0, 19).replace('T', ' ')
|
submitData.manufactureDate = new Date(submitData.manufactureDate).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
}
|
}
|
||||||
@ -463,8 +507,15 @@ async function loadSection() {
|
|||||||
sectionList = data.map((d:any)=> ({ label: d.sectionName, value: (Number(d.id) || d.id) }))
|
sectionList = data.map((d:any)=> ({ label: d.sectionName, value: (Number(d.id) || d.id) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//加载人员
|
||||||
|
async function handleUser() {
|
||||||
|
const res = await userApi.getEquipmentManager()
|
||||||
|
deviceManagerList.value = res
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadData()
|
loadData()
|
||||||
|
handleUser()
|
||||||
loadSection()
|
loadSection()
|
||||||
loadDictOptions()
|
loadDictOptions()
|
||||||
})
|
})
|
||||||
|
|||||||
457
src/views/biz/maintenanceRecord/index.vue
Normal file
457
src/views/biz/maintenanceRecord/index.vue
Normal file
@ -0,0 +1,457 @@
|
|||||||
|
<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.recordId" placeholder="请输入维保记录编号" 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.recordId"
|
||||||
|
: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" label-placement="left" label-width="100px">
|
||||||
|
<n-form-item label="设备ID,关联mes_equipment设备表主键" path="equipmentId">
|
||||||
|
<n-input v-model:value="formData.equipmentId" placeholder="请输入设备ID,关联mes_equipment设备表主键" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="记录类型:maintain=保养,repair=维修" path="recordType">
|
||||||
|
<n-select v-model:value="formData.recordType" placeholder="请选择记录类型:maintain=保养,repair=维修" :options="[]" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="故障现象/保养项目详情" path="itemContent">
|
||||||
|
<n-input v-model:value="formData.itemContent" type="textarea" placeholder="请输入故障现象/保养项目详情" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="维修处理措施/保养执行内容" path="handleContent">
|
||||||
|
<n-input v-model:value="formData.handleContent" type="textarea" placeholder="请输入维修处理措施/保养执行内容" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="执行人ID,关联sys_user系统用户表主键" path="executorId">
|
||||||
|
<n-input v-model:value="formData.executorId" placeholder="请输入执行人ID,关联sys_user系统用户表主键" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="维保作业开始时间" path="startTime">
|
||||||
|
<n-date-picker v-model:value="formData.startTime" 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="单据状态:pending=待处理,finished=已完成" path="recordStatus">
|
||||||
|
<n-select v-model:value="formData.recordStatus" placeholder="请选择单据状态:pending=待处理,finished=已完成" :options="recordStatusOptions" />
|
||||||
|
</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="导入MES设备维修保养记录表" 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 { maintenanceRecordApi, type MaintenanceRecord } from '@/api/maintenanceRecord'
|
||||||
|
import { dictDataApi } from '@/api/org'
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
recordId: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<MaintenanceRecord[]>([])
|
||||||
|
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: MaintenanceRecord = {
|
||||||
|
equipmentId: '',
|
||||||
|
recordType: '',
|
||||||
|
itemContent: '',
|
||||||
|
handleContent: '',
|
||||||
|
executorId: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
endTime: undefined,
|
||||||
|
recordStatus: '',
|
||||||
|
}
|
||||||
|
const formData = reactive<MaintenanceRecord>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
const recordStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
// equipmentId: { required: true, message: '请输入设备ID,关联mes_equipment设备表主键', trigger: 'blur' },
|
||||||
|
// recordType: { required: true, message: '请输入记录类型:maintain=保养,repair=维修', trigger: 'blur' },
|
||||||
|
// itemContent: { required: true, message: '请输入故障现象/保养项目详情', trigger: 'blur' },
|
||||||
|
// handleContent: { required: true, message: '请输入维修处理措施/保养执行内容', trigger: 'blur' },
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns: DataTableColumns<MaintenanceRecord> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title: '维保记录编号', key: 'recordId' },
|
||||||
|
{ title: '设备ID', key: 'equipmentId' },
|
||||||
|
{ title: '记录类型', key: 'recordType' },
|
||||||
|
{ title: '故障现象/保养项目', key: 'itemContent' },
|
||||||
|
{ title: '维修处理措施/保养执行内容', key: 'handleContent' },
|
||||||
|
{ title: '执行人ID', key: 'executorId' },
|
||||||
|
{ title: '维保作业开始时间', key: 'startTime' },
|
||||||
|
{ title: '维保作业结束时间', key: 'endTime' },
|
||||||
|
{ title: '单据状态', key: 'recordStatus',
|
||||||
|
render(row) {
|
||||||
|
const val = row.recordStatus
|
||||||
|
const opt = recordStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
return opt ? opt.label : (val ?? '-')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '单据创建时间', key: 'createTime', width: 180 },
|
||||||
|
{ title: '单据最后更新时间', key: 'updateTime', width: 180 },
|
||||||
|
{
|
||||||
|
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 maintenanceRecordApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
recordId: searchForm.recordId || undefined,
|
||||||
|
})
|
||||||
|
tableData.value = res.list
|
||||||
|
pagination.itemCount = res.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
function handleSearch() {
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchForm.recordId = ''
|
||||||
|
|
||||||
|
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 = '新增MES设备维修保养记录表'
|
||||||
|
Object.assign(formData, defaultFormData)
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
function handleEdit(row: MaintenanceRecord) {
|
||||||
|
modalTitle.value = '编辑MES设备维修保养记录表'
|
||||||
|
Object.assign(formData, row)
|
||||||
|
if (formData.startTime && typeof formData.startTime === 'string') {
|
||||||
|
formData.startTime = new Date(formData.startTime.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()
|
||||||
|
}
|
||||||
|
if (formData.updateTime && typeof formData.updateTime === 'string') {
|
||||||
|
formData.updateTime = new Date(formData.updateTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
async function handleSubmit() {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
try {
|
||||||
|
const submitData = { ...formData } as MaintenanceRecord
|
||||||
|
if (typeof submitData.startTime === 'number') {
|
||||||
|
submitData.startTime = new Date(submitData.startTime).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 (typeof submitData.updateTime === 'number') {
|
||||||
|
submitData.updateTime = new Date(submitData.updateTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (submitData.recordId) {
|
||||||
|
await maintenanceRecordApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await maintenanceRecordApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: MaintenanceRecord) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await maintenanceRecordApi.delete([row.recordId!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await maintenanceRecordApi.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.recordId) params.recordId = searchForm.recordId
|
||||||
|
const blob = await maintenanceRecordApi.export(params)
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = 'MES设备维修保养记录表数据.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
async function handleDownloadTemplate() {
|
||||||
|
try {
|
||||||
|
const blob = await maintenanceRecordApi.downloadTemplate()
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = 'MES设备维修保养记录表导入模板.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导入上传
|
||||||
|
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
|
||||||
|
if (!file.file) return
|
||||||
|
try {
|
||||||
|
const result = await maintenanceRecordApi.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_status')
|
||||||
|
recordStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: d.dictValue }))
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.maintenance-page {
|
||||||
|
padding: 16px;
|
||||||
|
.search-card, .btn-card {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
// 全局卡片统一圆角
|
||||||
|
:deep(.el-card) {
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
// 表格单元格加宽内边距
|
||||||
|
:deep(.el-table__cell) {
|
||||||
|
padding: 12px 10px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -198,6 +198,7 @@
|
|||||||
@assign="(p) => disphand(p, order)"
|
@assign="(p) => disphand(p, order)"
|
||||||
@outsource="(p) => openOutsource(order, p)"
|
@outsource="(p) => openOutsource(order, p)"
|
||||||
@view-model="(p) => openPlmModel(order, p)"
|
@view-model="(p) => openPlmModel(order, p)"
|
||||||
|
@submit-detail = "(p) => openDetailModel(order,p)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -205,8 +206,11 @@
|
|||||||
</n-spin>
|
</n-spin>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--模型抽屉 -->
|
||||||
<PlmModelDrawer ref="plmModelDrawerRef" />
|
<PlmModelDrawer ref="plmModelDrawerRef" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="board-pagination">
|
<div class="board-pagination">
|
||||||
<n-pagination
|
<n-pagination
|
||||||
v-model:page="pagination.page"
|
v-model:page="pagination.page"
|
||||||
@ -246,6 +250,7 @@
|
|||||||
:can-edit="hasPermission('biz:orderItem:edit')"
|
:can-edit="hasPermission('biz:orderItem:edit')"
|
||||||
:can-assign="hasPermission('biz:orderItem:assign')"
|
:can-assign="hasPermission('biz:orderItem:assign')"
|
||||||
:can-outsource="hasPermission('biz:orderProcessPlan:add')"
|
:can-outsource="hasPermission('biz:orderProcessPlan:add')"
|
||||||
|
:can-submitDetail="hasPermission('biz:submitLog:detail')"
|
||||||
@edit="(p) => handleEdit(p, detailData!)"
|
@edit="(p) => handleEdit(p, detailData!)"
|
||||||
@assign="(p) => disphand(p, detailData!)"
|
@assign="(p) => disphand(p, detailData!)"
|
||||||
@outsource="(p) => openOutsource(detailData!, p)"
|
@outsource="(p) => openOutsource(detailData!, p)"
|
||||||
@ -347,6 +352,7 @@
|
|||||||
:key="i"
|
:key="i"
|
||||||
:obj="n"
|
:obj="n"
|
||||||
:index="i"
|
:index="i"
|
||||||
|
:section="dispatchform.workCenterName"
|
||||||
listname="list"
|
listname="list"
|
||||||
@addhand="addpgnum"
|
@addhand="addpgnum"
|
||||||
@delehand="deletenum(i)"
|
@delehand="deletenum(i)"
|
||||||
@ -522,6 +528,13 @@
|
|||||||
</n-upload>
|
</n-upload>
|
||||||
</n-space>
|
</n-space>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 汇报详情弹窗 -->
|
||||||
|
<n-modal v-model:show="submitLogModalVisible" preset="card" title="导入工序计划" style="width: 500px">
|
||||||
|
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -555,6 +568,9 @@ import ProcessCard from './components/ProcessCard.vue'
|
|||||||
import PlmModelDrawer from '@/components/PlmModelDrawer.vue'
|
import PlmModelDrawer from '@/components/PlmModelDrawer.vue'
|
||||||
import type { PlmModelOpenContext } from '@/api/plmModel'
|
import type { PlmModelOpenContext } from '@/api/plmModel'
|
||||||
import Pgitem from './pgitem.vue'
|
import Pgitem from './pgitem.vue'
|
||||||
|
import { submitLogApi } from '@/api/submitLog.ts'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
@ -593,14 +609,15 @@ const dispatchmodal = ref(false)
|
|||||||
const dispatchLoading = ref(false)
|
const dispatchLoading = ref(false)
|
||||||
const dispatchformRef = ref()
|
const dispatchformRef = ref()
|
||||||
const dispatchform = reactive<any>({
|
const dispatchform = reactive<any>({
|
||||||
id: '', name: '', beginTime: '', endTime: '', quantity: '',
|
id: '', name: '', beginTime: '', endTime: '', quantity: '',workCenterName:'',
|
||||||
list: [{ sectionId:'',deviceId:'',userList: '', quantity: '' }],
|
list: [{ sectionId:'',deviceId:'', quantity: '' }],
|
||||||
})
|
})
|
||||||
const dispatchrules = {}
|
const dispatchrules = {}
|
||||||
|
|
||||||
const importModalVisible = ref(false)
|
const importModalVisible = ref(false)
|
||||||
const plmModelDrawerRef = ref<InstanceType<typeof PlmModelDrawer> | null>(null)
|
const plmModelDrawerRef = ref<InstanceType<typeof PlmModelDrawer> | null>(null)
|
||||||
|
|
||||||
|
|
||||||
const outsourceModalVisible = ref(false)
|
const outsourceModalVisible = ref(false)
|
||||||
const outsourceOptionsLoading = ref(false)
|
const outsourceOptionsLoading = ref(false)
|
||||||
const outsourceSubmitLoading = ref(false)
|
const outsourceSubmitLoading = ref(false)
|
||||||
@ -640,6 +657,18 @@ function openPlmModel(order: OrderProcessPlanVO, process?: ProcessPlanItemVO) {
|
|||||||
plmModelDrawerRef.value?.open(ctx)
|
plmModelDrawerRef.value?.open(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//汇报记录详情
|
||||||
|
const submitLogModalVisible = ref<Boolean>(false)
|
||||||
|
|
||||||
|
|
||||||
|
//汇报详情
|
||||||
|
function openDetailModel(order:ProcessPlanItemVO,procces?:OrderProcessPlanVO) {
|
||||||
|
|
||||||
|
submitLogModalVisible.value = true
|
||||||
|
const processId = procces.planId
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const batchOptions = [
|
const batchOptions = [
|
||||||
{ label: '全部展开', key: 'expandAll' },
|
{ label: '全部展开', key: 'expandAll' },
|
||||||
{ label: '全部收起', key: 'collapseAll' },
|
{ label: '全部收起', key: 'collapseAll' },
|
||||||
@ -1006,6 +1035,7 @@ async function handleSubmit() {
|
|||||||
|
|
||||||
function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
|
function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
|
||||||
const entity = processItemToEntity(process, order?.orderItemId)
|
const entity = processItemToEntity(process, order?.orderItemId)
|
||||||
|
|
||||||
dispatchmodal.value = true
|
dispatchmodal.value = true
|
||||||
dispatchformRef.value?.restoreValidation()
|
dispatchformRef.value?.restoreValidation()
|
||||||
dispatchform.id = entity.id
|
dispatchform.id = entity.id
|
||||||
@ -1015,11 +1045,14 @@ function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
|
|||||||
dispatchform.quantity = entity.quantity
|
dispatchform.quantity = entity.quantity
|
||||||
dispatchform.orderItemId = entity.orderItemId
|
dispatchform.orderItemId = entity.orderItemId
|
||||||
dispatchform.sort = entity.sort
|
dispatchform.sort = entity.sort
|
||||||
dispatchform.list = [{ sectionId:'',deviceId:'',userList: '', quantity: '' }]
|
dispatchform.workCenterName = entity.workCenterName
|
||||||
|
dispatchform.list = [{ sectionId:'',deviceId:'', quantity: '' }]
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addpgnum() {
|
function addpgnum() {
|
||||||
dispatchform.list.push({ sectionId:'',deviceId:'',userList: '', quantity: '' })
|
dispatchform.list.push({ sectionId:'',deviceId:'', quantity: '' })
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletenum(index: number) {
|
function deletenum(index: number) {
|
||||||
|
|||||||
@ -82,6 +82,12 @@
|
|||||||
ghost
|
ghost
|
||||||
@click="emit('outsource', process)"
|
@click="emit('outsource', process)"
|
||||||
>委外</n-button>
|
>委外</n-button>
|
||||||
|
<n-button
|
||||||
|
size="tiny"
|
||||||
|
quaternary
|
||||||
|
ghost
|
||||||
|
@click="emit('submitDetail', process)"
|
||||||
|
>汇报</n-button>
|
||||||
<n-button
|
<n-button
|
||||||
size="tiny"
|
size="tiny"
|
||||||
:type="process.processStatus === 4 ? 'success' : 'default'"
|
:type="process.processStatus === 4 ? 'success' : 'default'"
|
||||||
@ -108,6 +114,7 @@ const props = defineProps<{
|
|||||||
canEdit?: boolean
|
canEdit?: boolean
|
||||||
canAssign?: boolean
|
canAssign?: boolean
|
||||||
canOutsource?: boolean
|
canOutsource?: boolean
|
||||||
|
canSubmitDetail?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -115,6 +122,7 @@ const emit = defineEmits<{
|
|||||||
assign: [process: ProcessPlanItemVO]
|
assign: [process: ProcessPlanItemVO]
|
||||||
viewModel: [process: ProcessPlanItemVO]
|
viewModel: [process: ProcessPlanItemVO]
|
||||||
outsource: [process: ProcessPlanItemVO]
|
outsource: [process: ProcessPlanItemVO]
|
||||||
|
submitDetail: [process: ProcessPlanItemVO]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const totalQty = computed(() => props.process.quantity ?? 0)
|
const totalQty = computed(() => props.process.quantity ?? 0)
|
||||||
|
|||||||
@ -5,11 +5,6 @@
|
|||||||
<n-form-item
|
<n-form-item
|
||||||
label="指派工段"
|
label="指派工段"
|
||||||
:path="`${listname}[${index}].sectionId`"
|
:path="`${listname}[${index}].sectionId`"
|
||||||
:rule="{
|
|
||||||
required:true,
|
|
||||||
message:`请选择工段`,
|
|
||||||
trigger: 'blur'
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
<n-select
|
<n-select
|
||||||
v-model:value="obj.sectionId"
|
v-model:value="obj.sectionId"
|
||||||
@ -17,10 +12,9 @@
|
|||||||
placeholder="请选择工段"
|
placeholder="请选择工段"
|
||||||
:options="sectionList"
|
:options="sectionList"
|
||||||
:loading="loadingRef"
|
:loading="loadingRef"
|
||||||
clearable
|
disabled
|
||||||
remote
|
remote
|
||||||
:clear-filter-after-select="false"
|
:clear-filter-after-select="false"
|
||||||
@change="searchSection"
|
|
||||||
/>
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
@ -50,39 +44,6 @@
|
|||||||
</n-grid>
|
</n-grid>
|
||||||
<n-grid>
|
<n-grid>
|
||||||
|
|
||||||
<n-gi :span="10">
|
|
||||||
<n-form-item
|
|
||||||
label="分配人员"
|
|
||||||
:path="`${listname}[${index}].userList`"
|
|
||||||
:rule="{
|
|
||||||
required: true,
|
|
||||||
message: '请选择员工',
|
|
||||||
trigger: 'blur',
|
|
||||||
validator: (rule, value, callback) => {
|
|
||||||
// value 多选为数组,单选是单个值
|
|
||||||
if (!Array.isArray(value) || value.length === 0) {
|
|
||||||
callback(new Error('请选择员工'))
|
|
||||||
} else {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<!--multiple-->
|
|
||||||
<n-select
|
|
||||||
v-model:value="obj.userList"
|
|
||||||
filterable
|
|
||||||
placeholder="请输入用户名称搜索"
|
|
||||||
:options="yglist"
|
|
||||||
:loading="loadingRef"
|
|
||||||
clearable
|
|
||||||
multiple
|
|
||||||
remote
|
|
||||||
:clear-filter-after-select="false"
|
|
||||||
@search="slehand"
|
|
||||||
/>
|
|
||||||
</n-form-item>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi :span="10">
|
<n-gi :span="10">
|
||||||
<n-form-item
|
<n-form-item
|
||||||
label="数量"
|
label="数量"
|
||||||
@ -129,14 +90,13 @@
|
|||||||
AddOutline,
|
AddOutline,
|
||||||
TrashOutline,
|
TrashOutline,
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
import { any, label } from 'three/tsl';
|
import { label } from 'three/tsl'
|
||||||
import { Value } from 'three/examples/jsm/inspector/ui/Values.js';
|
|
||||||
import { bind } from 'echarts/types/src/export/api/util.js'
|
|
||||||
import { number } from 'echarts'
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
listname:any
|
listname:any
|
||||||
obj:any,
|
obj:any,
|
||||||
index:any
|
index:any
|
||||||
|
section:string
|
||||||
}>(), {
|
}>(), {
|
||||||
obj:{}
|
obj:{}
|
||||||
})
|
})
|
||||||
@ -196,30 +156,40 @@ import { number } from 'echarts'
|
|||||||
|
|
||||||
//加载工段
|
//加载工段
|
||||||
async function loadSection() {
|
async function loadSection() {
|
||||||
const data = await sectionApi.list()
|
//根据section 进行匹配
|
||||||
sectionList =data.map((d:any)=>{
|
const res = await sectionApi.list({sectionName:props.section})
|
||||||
return {
|
const mesSection = res.MesSection;
|
||||||
label:d.sectionName,
|
const mesDevice = res.MesDevice
|
||||||
value:d.id+''
|
console.log(mesSection);
|
||||||
}
|
|
||||||
})
|
sectionList.push({
|
||||||
|
label:mesSection.sectionName,
|
||||||
}
|
value:mesSection.id
|
||||||
|
})
|
||||||
function searchSection(sectionId?:number){
|
props.obj.sectionId = mesSection.id
|
||||||
if(!sectionId) return
|
|
||||||
props.obj.deviceId = ''
|
deviceList.value = mesDevice.map((n:any)=>{
|
||||||
deviceList.value = []
|
|
||||||
deviceApi.list(sectionId).then(res=>{
|
|
||||||
deviceList.value = res.map((n:any)=>{
|
|
||||||
return {
|
return {
|
||||||
label:n.name,
|
label:n.deviceName,
|
||||||
value:n.id+''
|
value:n.id+''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function searchSection(sectionId?:number){
|
||||||
|
// if(!sectionId) return
|
||||||
|
// props.obj.deviceId = ''
|
||||||
|
// deviceList.value = []
|
||||||
|
// deviceApi.list(sectionId).then(res=>{
|
||||||
|
// deviceList.value = res.map((n:any)=>{
|
||||||
|
// return {
|
||||||
|
// label:n.name,
|
||||||
|
// value:n.id+''
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
loadSection()
|
loadSection()
|
||||||
slehand()
|
slehand()
|
||||||
// handleDevice()
|
// handleDevice()
|
||||||
|
|||||||
810
src/views/biz/qualityItem/index.vue
Normal file
810
src/views/biz/qualityItem/index.vue
Normal file
@ -0,0 +1,810 @@
|
|||||||
|
<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.name" placeholder="请输入质检项名称" 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"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
:scroll-x="1200"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:item-count="pagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
@update:checked-row-keys="handleCheck"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ pagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</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="spec">
|
||||||
|
<n-input v-model:value="formData.spec" placeholder="请输入质检规格" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="质检方案" path="plans">
|
||||||
|
<n-upload
|
||||||
|
multiple
|
||||||
|
directory-dnd
|
||||||
|
auto-upload="false"
|
||||||
|
:max="5"
|
||||||
|
v-model:file-list="fileList"
|
||||||
|
@before-upload ="handleBeforeUpload"
|
||||||
|
@remove="handleRemove"
|
||||||
|
>
|
||||||
|
<n-upload-dragger>
|
||||||
|
<div style="margin-bottom: 12px">
|
||||||
|
<n-icon size="48" :depth="3">
|
||||||
|
<ArchiveIcon />
|
||||||
|
</n-icon>
|
||||||
|
</div>
|
||||||
|
<n-text style="font-size: 16px">
|
||||||
|
点击或者拖动文件到该区域来上传
|
||||||
|
</n-text>
|
||||||
|
<n-p depth="3" style="margin: 8px 0 0 0">
|
||||||
|
文件上传,PDF或Word;文件大小20MB以内
|
||||||
|
</n-p>
|
||||||
|
</n-upload-dragger>
|
||||||
|
</n-upload>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="质检描述" path="description">
|
||||||
|
<n-input v-model:value="formData.description" type="textarea" 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>
|
||||||
|
|
||||||
|
<!--质检方案显示抽屉-->
|
||||||
|
<n-drawer v-model:show="plansShow" :width="502">
|
||||||
|
<n-drawer-content :title="title" closable>
|
||||||
|
<n-virtual-list
|
||||||
|
ref="virtualListInst"
|
||||||
|
style="max-height: 240px"
|
||||||
|
:item-size="42"
|
||||||
|
:items="sysFileList"
|
||||||
|
>
|
||||||
|
<template #default="{ item, index }">
|
||||||
|
<div :key="item.key" class="item" style="height: 42px">
|
||||||
|
<n-grid x-gap="22">
|
||||||
|
<n-gi span="12">
|
||||||
|
<n-icon v-if="item.fileSuffix == '.pdf'"><DocumentOutline /> </n-icon>
|
||||||
|
<n-icon v-if="item.fileSuffix == '.docx'"><NewspaperOutline /> </n-icon>
|
||||||
|
{{ item.originalName }}
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="6">
|
||||||
|
{{ calculateSize(item.fileSize) }}
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="4">
|
||||||
|
<Button @click="downloadPlans(item)"><n-icon><DownloadOutline /></n-icon></Button>
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-virtual-list>
|
||||||
|
</n-drawer-content>
|
||||||
|
</n-drawer>
|
||||||
|
<!--关联工序抽屉-->
|
||||||
|
<n-drawer v-model:show="processModel" :width="800" >
|
||||||
|
<n-drawer-content title="工序列表">
|
||||||
|
<!-- 全选栏 -->
|
||||||
|
<n-space justify="space-between" class="mb-3">
|
||||||
|
<n-checkbox v-model:checked="isAllCheck" @update:checked="handleAllCheck">
|
||||||
|
全选当前筛选工序
|
||||||
|
</n-checkbox>
|
||||||
|
<n-tag type="info">已勾选 {{ selectedProcessIds.length }} 道工序</n-tag>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<!-- 工序表格,带复选框 -->
|
||||||
|
<n-data-table
|
||||||
|
:columns="processColumns"
|
||||||
|
:data="processList"
|
||||||
|
max-height="700"
|
||||||
|
v-model:checked-row-keys="selectedProcessIds"
|
||||||
|
:row-key="rowKey"
|
||||||
|
:scroll-x="1200"
|
||||||
|
:loading="relateLoading"
|
||||||
|
@update:checked-row-keys="handleUpateCheck"
|
||||||
|
/>
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="relatePagination.page"
|
||||||
|
v-model:page-size="relatePagination.pageSize"
|
||||||
|
:item-count="relatePagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handleRelatePageChange"
|
||||||
|
@update:page-size="handleRelatePageSizeChange"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ relatePagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 底部操作按钮 -->
|
||||||
|
<template #footer>
|
||||||
|
<n-space justify="end">
|
||||||
|
<n-button @click="processModel = false">取消</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-drawer-content>
|
||||||
|
</n-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, h, onMounted,computed } from 'vue'
|
||||||
|
import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns,
|
||||||
|
type UploadCustomRequestOptions,UploadFileInfo, DataTableRowKey, NTag } from 'naive-ui'
|
||||||
|
import { SearchOutline, RefreshOutline, AddOutline,
|
||||||
|
TrashOutline, CreateOutline, CloudUploadOutline,NewspaperOutline,DocumentOutline,
|
||||||
|
DownloadOutline,ArchiveOutline as ArchiveIcon } from '@vicons/ionicons5'
|
||||||
|
import { qcItemApi, type QcItem } from '@/api/qcItem'
|
||||||
|
import { fileApi,SysFile } from '@/api/system'
|
||||||
|
import Button from 'naive-ui/es/button/src/Button'
|
||||||
|
import { basicProcessPlanApi,BasicProcessPlan } from '@/api/basicProcessPlan'
|
||||||
|
import {qcitemProcessApi,QcitemProcess} from '@/api/qcitemProcess'
|
||||||
|
import { number } from 'echarts'
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
|
||||||
|
//关联工序
|
||||||
|
const processModel = ref<Boolean>(false)
|
||||||
|
const processList = ref<BasicProcessPlan[]>([])
|
||||||
|
const selectedProcessIds = ref<number[]>([])
|
||||||
|
const qcProcessRelate =ref<QcitemProcess> ({
|
||||||
|
qualityItemId: undefined,
|
||||||
|
processId: undefined,
|
||||||
|
})
|
||||||
|
const relateLoading = ref<boolean>(false)
|
||||||
|
const relatePagination = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 2,
|
||||||
|
itemCount: 0,
|
||||||
|
showSizePicker: true,
|
||||||
|
pageSizes: [10, 20, 50]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//上传文件
|
||||||
|
const fileList = ref<UploadFileInfo[]>([])
|
||||||
|
|
||||||
|
//质检方案抽屉显示隐藏
|
||||||
|
const title = ref<string>()
|
||||||
|
const plansShow = ref<Boolean>(false)
|
||||||
|
const sysFileList = ref<SysFile>([])
|
||||||
|
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
name: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<QcItem[]>([])
|
||||||
|
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: QcItem = {
|
||||||
|
name: '',
|
||||||
|
spec: '',
|
||||||
|
plans: '',
|
||||||
|
desc: '',
|
||||||
|
createby: undefined,
|
||||||
|
}
|
||||||
|
const formData = reactive<QcItem>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns: DataTableColumns<QcItem> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title: '质检项名称', key: 'name' },
|
||||||
|
{ title: '质检规格', key: 'spec' },
|
||||||
|
{ title: '质检方案', key: 'plans',
|
||||||
|
render(row) {
|
||||||
|
return h(NButton,{size:"small", onClick: () => handlePlans(row)},{
|
||||||
|
default: () => ['下载方案']
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: '质检描述', key: 'description' },
|
||||||
|
{ title: '创建人', key: 'userName' },
|
||||||
|
{ title: '创建时间', key: 'createTime', width: 180 },
|
||||||
|
{ title: '修改时间', key: 'updateTime', width: 180 },
|
||||||
|
{
|
||||||
|
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) }), ' 删除']
|
||||||
|
}),
|
||||||
|
h(NButton, { size: 'small', quaternary: true, onClick: () => handleProccess(row) }, {
|
||||||
|
default: () => [' 关联工序']
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
async function loadData() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await qcItemApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
name: searchForm.name || undefined,
|
||||||
|
})
|
||||||
|
tableData.value = res.list
|
||||||
|
pagination.itemCount = res.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
function handleSearch() {
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchForm.name = ''
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
async function handleEdit(row: QcItem) {
|
||||||
|
|
||||||
|
modalTitle.value = '编辑质检项表'
|
||||||
|
const res = await qcItemApi.getPlansFiles({ plans: row.plans })
|
||||||
|
|
||||||
|
const fileArr = res || []
|
||||||
|
|
||||||
|
fileList.value = fileArr.map(item => {
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
name: item.originalName,
|
||||||
|
file: null, // 回显已有文件,无原生File对象填空
|
||||||
|
size: item.fileSize,
|
||||||
|
type: item.fileType === 'pdf'
|
||||||
|
? 'application/pdf'
|
||||||
|
: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
status: 'finished', // 固定为已完成
|
||||||
|
response: item, // 存储后端完整文件信息,下载时取用
|
||||||
|
url: item.url // 文件预览/下载地址
|
||||||
|
} as UploadFileInfo
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Object.assign(formData, row)
|
||||||
|
if (formData.createTime && typeof formData.createTime === 'string') {
|
||||||
|
formData.createTime = new Date(formData.createTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
if (formData.updateTime && typeof formData.updateTime === 'string') {
|
||||||
|
formData.updateTime = new Date(formData.updateTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
async function handleSubmit() {
|
||||||
|
|
||||||
|
let plans = []
|
||||||
|
console.log(fileList.value);
|
||||||
|
|
||||||
|
fileList.value.forEach(item=>{
|
||||||
|
plans.push(item.url)
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log();
|
||||||
|
|
||||||
|
formData.plans = plans.join(",")
|
||||||
|
|
||||||
|
console.log(formData);
|
||||||
|
|
||||||
|
await formRef.value?.validate()
|
||||||
|
|
||||||
|
try {
|
||||||
|
const submitData = { ...formData } as QcItem
|
||||||
|
if (typeof submitData.createTime === 'number') {
|
||||||
|
submitData.createTime = new Date(submitData.createTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (typeof submitData.updateTime === 'number') {
|
||||||
|
submitData.updateTime = new Date(submitData.updateTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (submitData.id) {
|
||||||
|
await qcItemApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await qcItemApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: QcItem) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await qcItemApi.delete([row.id!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await qcItemApi.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
|
||||||
|
const blob = await qcItemApi.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 qcItemApi.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 qcItemApi.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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//文件上传前校验
|
||||||
|
const handleBeforeUpload = async (data: {
|
||||||
|
file: UploadFileInfo
|
||||||
|
fileList: UploadFileInfo[]
|
||||||
|
})=> {
|
||||||
|
const file = data.file
|
||||||
|
//文件格式校验
|
||||||
|
const allowMime = [
|
||||||
|
'application/pdf',
|
||||||
|
'application/msword',
|
||||||
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
if(!allowMime.includes(file.type)){
|
||||||
|
message.error(`仅支持上传 PDF、Word(doc/docx)格式文件,当前文件:${file.name}`)
|
||||||
|
return false // 拦截上传
|
||||||
|
}
|
||||||
|
|
||||||
|
//限制文件大小20MB
|
||||||
|
const maxSize = 20 * 1024 *1024
|
||||||
|
if(file.file.size > maxSize) {
|
||||||
|
message.error(`文件${file.name}超出20MB限制`)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await qcItemApi.uploadFile(file.file)
|
||||||
|
message.success(`${file.name} 上传成功`)
|
||||||
|
//保存url路径
|
||||||
|
file.url = res.url
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
message.error(`${file.name} 上传失败`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//文件清除
|
||||||
|
const handleRemove = (data: {
|
||||||
|
file: UploadFileInfo
|
||||||
|
fileList: UploadFileInfo[]
|
||||||
|
}) =>{
|
||||||
|
fileList.value = fileList.value.filter(item => item.id !== data.file.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
//显示抽屉
|
||||||
|
const handlePlans = async (row) => {
|
||||||
|
title.value = row.name + "质检方案"
|
||||||
|
plansShow.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 打印入参,确认传给后端的 plans 是否有值
|
||||||
|
console.log('请求参数 plans:', row.plans)
|
||||||
|
const res = await qcItemApi.getPlansFiles({ plans: row.plans })
|
||||||
|
sysFileList.value = res
|
||||||
|
console.log('接口返回成功数据:', res);
|
||||||
|
} catch (err) {
|
||||||
|
// 打印完整错误,看是401/404/500/参数问题
|
||||||
|
console.error('请求失败详情:', err)
|
||||||
|
// 提取后端返回的提示信息
|
||||||
|
const msg = err || '获取文件列表接口异常'
|
||||||
|
message.error(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算文件大小
|
||||||
|
function calculateSize(fileSize) {
|
||||||
|
if (fileSize === 0) return '0 B'
|
||||||
|
const unitArr = ['B', 'KB', 'MB', 'GB']
|
||||||
|
let size = fileSize
|
||||||
|
let index = 0
|
||||||
|
while (size >= 1024 && index < unitArr.length - 1) {
|
||||||
|
size /= 1024
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
return size.toFixed(2) + ' ' + unitArr[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
//下载文件
|
||||||
|
async function downloadPlans(row: any) {
|
||||||
|
try {
|
||||||
|
// res 现在是 axios完整响应 { data:Blob, headers }
|
||||||
|
const res = await fileApi.downloadPlanFile(row.id)
|
||||||
|
const blobData = res // 真实二进制Blob
|
||||||
|
let fileName = ''
|
||||||
|
let ext = ''
|
||||||
|
|
||||||
|
const nameArr = row.url.split('/')
|
||||||
|
const fullName = nameArr.pop()!
|
||||||
|
|
||||||
|
const extMatch = fullName.match(/\.(pdf|doc|docx)$/i)
|
||||||
|
if (extMatch) ext = extMatch[1].toLowerCase()
|
||||||
|
fileName = `${row.originalName }`
|
||||||
|
|
||||||
|
// 关键:直接使用接口返回的Blob,不要new Blob重复包装
|
||||||
|
const url = URL.createObjectURL(blobData)
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = url
|
||||||
|
a.download = fileName
|
||||||
|
document.body.appendChild(a)
|
||||||
|
a.click()
|
||||||
|
|
||||||
|
// 释放内存
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
document.body.removeChild(a)
|
||||||
|
message.success(`${fileName} 下载成功`)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('下载失败', err)
|
||||||
|
message.error('文件下载失败,请重试')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//关联工序抽屉
|
||||||
|
function handleProccess(row) {
|
||||||
|
relateLoading.value = true
|
||||||
|
processModel.value = true
|
||||||
|
qcProcessRelate.qualityItemId = row.id
|
||||||
|
getProcessList(row.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function getProcessList(id) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await basicProcessPlanApi.list({
|
||||||
|
id:id,
|
||||||
|
page:relatePagination.page,
|
||||||
|
pageSize:relatePagination.pageSize
|
||||||
|
});
|
||||||
|
processList.value = res.records
|
||||||
|
relatePagination.itemCount = res.total
|
||||||
|
//回显
|
||||||
|
selectedProcessIds.value = processList.value.filter(item=> item.isBind).map(item => item.id)
|
||||||
|
relateLoading.value = false
|
||||||
|
} catch (error) {
|
||||||
|
console.log("异常信息:"+error);
|
||||||
|
message.error("获取关联异常")
|
||||||
|
relateLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//取消/全选
|
||||||
|
const isAllCheck = computed({
|
||||||
|
get() {
|
||||||
|
return processList.value.length > 0 && selectedProcessIds.value.length === processList.value.length
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
if(val) {
|
||||||
|
selectedProcessIds.value = processList.value.map(item=> item.id)
|
||||||
|
}else{
|
||||||
|
selectedProcessIds.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleAllCheck = (val:boolean) => {
|
||||||
|
isAllCheck.value = val
|
||||||
|
}
|
||||||
|
function rowKey(row: RowData) {
|
||||||
|
return row.id
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUpateCheck = async (keys: Array<string | number>,) =>{
|
||||||
|
selectedProcessIds.value = keys
|
||||||
|
|
||||||
|
qcProcessRelate.processIds = selectedProcessIds.value
|
||||||
|
qcProcessRelate.page = relatePagination.page
|
||||||
|
qcProcessRelate.pageSize = relateLoading.pageSize
|
||||||
|
try{
|
||||||
|
await qcitemProcessApi.create(qcProcessRelate);
|
||||||
|
message.success("关联成功")
|
||||||
|
getProcessList(qcProcessRelate.qualityItemId)
|
||||||
|
}catch(error) {
|
||||||
|
message.error("关联失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const processColumns: DataTableColumns<BasicProcessPlan> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title:"工序名称",key:"name"},
|
||||||
|
{ title: "关联状态",key:"isBind",
|
||||||
|
render(row) {
|
||||||
|
const val = row.isBind;
|
||||||
|
if (val) {
|
||||||
|
return h(NTag, { type: "success" }, { default: () => "已关联" });
|
||||||
|
} else {
|
||||||
|
return h(NTag, { type: "default" }, { default: () => "未关联" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
function handleRelatePageChange(page: number) {
|
||||||
|
relatePagination.page = page
|
||||||
|
getProcessList(qcProcessRelate.qualityItemId)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRelatePageSizeChange(pageSize: number) {
|
||||||
|
relatePagination.pageSize = pageSize
|
||||||
|
relatePagination.page = 1
|
||||||
|
getProcessList(qcProcessRelate.qualityItemId)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.menu-tree-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
max-height: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
border: 1px solid #E5E7EB;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -49,13 +49,26 @@
|
|||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:pagination="pagination"
|
|
||||||
:row-key="(row) => row.id"
|
:row-key="(row) => row.id"
|
||||||
:scroll-x="1200"
|
:scroll-x="1200"
|
||||||
@update:page="handlePageChange"
|
|
||||||
@update:page-size="handlePageSizeChange"
|
|
||||||
@update:checked-row-keys="handleCheck"
|
|
||||||
/>
|
/>
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:item-count="pagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
@update:checked-row-keys="handleCheck"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ pagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
||||||
<!-- 新增/编辑弹窗 -->
|
<!-- 新增/编辑弹窗 -->
|
||||||
|
|||||||
492
src/views/biz/stationhandover/index.vue
Normal file
492
src/views/biz/stationhandover/index.vue
Normal file
@ -0,0 +1,492 @@
|
|||||||
|
<!-- 设备上下级记录 -->
|
||||||
|
<template>
|
||||||
|
<div class="page-container">
|
||||||
|
<n-card>
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<div class="search-form">
|
||||||
|
<n-form inline :model="searchForm" label-placement="left">
|
||||||
|
<n-form-item label="设备工段">
|
||||||
|
<n-select
|
||||||
|
placeholder="请指定工段"
|
||||||
|
clearable
|
||||||
|
multiple
|
||||||
|
style="width: 200px"
|
||||||
|
:options="sectionList"
|
||||||
|
@update:value="handleUpdateValue"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="设备/工位">
|
||||||
|
<n-select
|
||||||
|
v-model:value="searchForm.deviceIds"
|
||||||
|
placeholder="请指定工段"
|
||||||
|
clearable
|
||||||
|
multiple
|
||||||
|
style="width: 200px"
|
||||||
|
:options="deviceList"
|
||||||
|
/>
|
||||||
|
</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="deviceId">
|
||||||
|
<n-select
|
||||||
|
v-model:value="formData.deviceId"
|
||||||
|
placeholder="请指定工段"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
:options="deviceList"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="交接人" path="handoverPerson">
|
||||||
|
<n-select
|
||||||
|
v-model:value="formData.handoverPersonId"
|
||||||
|
placeholder="请选择交接人"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
:options="userList"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="接收人" path="receiverPerson">
|
||||||
|
<n-select
|
||||||
|
v-model:value="formData.receiverPersonId"
|
||||||
|
placeholder="请选择交接人"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
:options="userList"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="交接时间" path="handoverTime">
|
||||||
|
<n-date-picker v-model:value="formData.handoverTime" type="datetime" clearable style="width: 100%" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="备注" path="remark">
|
||||||
|
<n-input v-model:value="formData.remark" type="textarea" 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 { stationHandoverApi, type StationHandover } from '@/api/stationHandover'
|
||||||
|
import { sectionApi,Section } from '@/api/section'
|
||||||
|
import { deviceApi,Device} from '@/api/device'
|
||||||
|
import { userApi,SysUser } from '@/api/system'
|
||||||
|
import { label } from 'three/tsl'
|
||||||
|
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
//工段列表
|
||||||
|
const sectionList = ref<Section[]>([])
|
||||||
|
//工位列表
|
||||||
|
const deviceList = ref<Device[]>([])
|
||||||
|
//人员列表
|
||||||
|
const userList = ref<SysUser[]>([])
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
deviceIds: null as number[] | null
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<StationHandover[]>([])
|
||||||
|
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: StationHandover = {
|
||||||
|
deviceId: undefined,
|
||||||
|
stationId: undefined,
|
||||||
|
handoverPersonId: undefined,
|
||||||
|
receiverPersonId: undefined,
|
||||||
|
handoverTime: undefined,
|
||||||
|
}
|
||||||
|
const formData = reactive<StationHandover>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns: DataTableColumns<StationHandover> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title: '主键', key: 'id' },
|
||||||
|
{ title: '设备/工位', key: 'deviceName' },
|
||||||
|
{ title: '上机人', key: 'handoverPerson' },
|
||||||
|
{ title: '接收人', key: 'receiverPerson' },
|
||||||
|
{ title: '交接时间', key: 'handoverTime' },
|
||||||
|
{ title: '交接备注', key: 'remark' },
|
||||||
|
{ title: '创建时间', key: 'createTime', width: 180 },
|
||||||
|
{
|
||||||
|
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 deviceIds = searchForm.deviceIds != null ?JSON.stringify(searchForm.deviceIds) :null
|
||||||
|
const res = await stationHandoverApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
deviceIds: deviceIds || undefined,
|
||||||
|
})
|
||||||
|
tableData.value = res.list
|
||||||
|
pagination.itemCount = res.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
function handleSearch() {
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchForm.deviceIds = 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() {
|
||||||
|
loadDevice(null)
|
||||||
|
modalTitle.value = '新增工位交接记录表'
|
||||||
|
Object.assign(formData, defaultFormData)
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
function handleEdit(row: StationHandover) {
|
||||||
|
loadDevice(null)
|
||||||
|
modalTitle.value = '编辑工位交接记录表'
|
||||||
|
Object.assign(formData, row)
|
||||||
|
if (formData.handoverTime && typeof formData.handoverTime === 'string') {
|
||||||
|
formData.handoverTime = new Date(formData.handoverTime.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 StationHandover
|
||||||
|
if (typeof submitData.handoverTime === 'number') {
|
||||||
|
submitData.handoverTime = new Date(submitData.handoverTime).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 stationHandoverApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await stationHandoverApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: StationHandover) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await stationHandoverApi.delete([row.id!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await stationHandoverApi.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
|
||||||
|
const blob = await stationHandoverApi.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 stationHandoverApi.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 stationHandoverApi.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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//加载工段
|
||||||
|
async function loadSection() {
|
||||||
|
const res = await sectionApi.list();
|
||||||
|
sectionList.value = res.map((n:any) =>{
|
||||||
|
return {
|
||||||
|
label:n.sectionName,
|
||||||
|
value:n.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function handleUpdateValue(key:any) {
|
||||||
|
|
||||||
|
console.log(key);
|
||||||
|
loadDevice(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
//加载设备/工位
|
||||||
|
async function loadDevice(sectionIdList:number[]) {
|
||||||
|
const sectionIds = sectionIdList != null ?JSON.stringify(sectionIdList) :null
|
||||||
|
const res = await deviceApi.getDeviceList({
|
||||||
|
sectionIds
|
||||||
|
})
|
||||||
|
deviceList.value = res.map((n:any)=>{
|
||||||
|
return {
|
||||||
|
label:n.deviceName,
|
||||||
|
value:n.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//加载人员
|
||||||
|
async function loadUserList() {
|
||||||
|
const res = await userApi.getPathList();
|
||||||
|
userList.value = res.map((n:any)=>{
|
||||||
|
return {
|
||||||
|
label:n.username,
|
||||||
|
value:n.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
loadSection()
|
||||||
|
loadDevice(null)
|
||||||
|
loadUserList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
448
src/views/production/componets/AssingWorkTreeTable.vue
Normal file
448
src/views/production/componets/AssingWorkTreeTable.vue
Normal file
@ -0,0 +1,448 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="toolbar">
|
||||||
|
<n-space>
|
||||||
|
<n-button
|
||||||
|
size="small"
|
||||||
|
:disabled="tableLoading || !AssingWorkTableData.length"
|
||||||
|
@click="AssingWorkToggleExpandAll"
|
||||||
|
>
|
||||||
|
{{ AssingWorkAllExpanded ? '全部收起' : '全部展开' }}
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</div>
|
||||||
|
<n-data-table
|
||||||
|
v-model:expanded-row-keys="AssingWorkExpandedKeys"
|
||||||
|
:columns="AssingWorkColumns"
|
||||||
|
:data="AssingWorkTableData"
|
||||||
|
:loading="tableLoading"
|
||||||
|
:row-key="RowKey"
|
||||||
|
:scroll-x="600"
|
||||||
|
:max-height="1000"
|
||||||
|
size="small"
|
||||||
|
style="margin-bottom:15px"
|
||||||
|
/>
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:item-count="pagination.itemCount"
|
||||||
|
:page-sizes="[2,10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ pagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
computed,
|
||||||
|
h,
|
||||||
|
reactive,
|
||||||
|
onMounted,
|
||||||
|
watch,
|
||||||
|
} from 'vue'
|
||||||
|
|
||||||
|
import { mytasks,type AssingWork } from '@/api/production';
|
||||||
|
import { NButton, NSpace, NIcon, NTag, NDatePicker, NDataTable, useMessage, useDialog, DataTableColumn, DataTableColumns } from 'naive-ui'
|
||||||
|
import { dictDataApi } from '@/api/org'
|
||||||
|
import { assingWorkDetailApi,AssingWorkDetail } from '@/api/AssingWorkDetail'
|
||||||
|
|
||||||
|
|
||||||
|
const qcAssingStatusOptions = ref<{ label: string; value: any;class:any }[]>([])
|
||||||
|
const tableLoading = ref<Boolean>(false)
|
||||||
|
const AssingWorkTableData = ref<AssingWork[]>([])
|
||||||
|
const AssingWorkExpandedKeys = ref<Array<string |number>>([])
|
||||||
|
|
||||||
|
const processName = ref<string>()
|
||||||
|
|
||||||
|
const AssingWorkColumns :DataTableColumns<AssingWork> = [
|
||||||
|
|
||||||
|
{
|
||||||
|
type:"expand",
|
||||||
|
expandable:()=>true,
|
||||||
|
renderExpand:(row) => renderAssingWorkExpand(row)
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"物料名称",
|
||||||
|
key:"materialName",
|
||||||
|
minWidth:150,
|
||||||
|
render(row:any) {
|
||||||
|
var opt = row.materialName
|
||||||
|
if(opt) return opt
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"物料编码",
|
||||||
|
key:"materialCode",
|
||||||
|
minWidth:150,
|
||||||
|
render(row:any) {
|
||||||
|
var opt = row.materialCode
|
||||||
|
if(opt) return opt
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"派工编号",
|
||||||
|
key:"assingCode",
|
||||||
|
minWidth:150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工序名称',
|
||||||
|
key: 'processName',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工序名称',
|
||||||
|
key: 'processCode',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '派工状态',
|
||||||
|
key: 'assingStatus',
|
||||||
|
minWidth: 150,
|
||||||
|
render(row:any) {
|
||||||
|
const val = row.assingStatus
|
||||||
|
const opt = qcAssingStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
if (!opt) return val ?? '-'
|
||||||
|
|
||||||
|
return h(NTag, { type: opt.class, size: 'small' }, { default: () => opt.label })
|
||||||
|
|
||||||
|
}
|
||||||
|
//派工状态0待执行 1执行中 2质检中+3已汇报一4已关闭
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '车间名称',
|
||||||
|
key: 'workshopName',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工段名称',
|
||||||
|
key: 'sectionName',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工位名称',
|
||||||
|
key: 'deviceName',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工人名称',
|
||||||
|
key: 'userName',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '数量',
|
||||||
|
minWidth: 100,
|
||||||
|
key: 'quantity'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '是否返工',
|
||||||
|
key: 'rework',
|
||||||
|
minWidth: 100,
|
||||||
|
render(row:any) {
|
||||||
|
const quit = row.rework === 1
|
||||||
|
return h(NTag, {type: quit ? 'error' : 'success', size: 'small'}, {default: () => (quit ? '是' : '否')})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '返工次数',
|
||||||
|
key: 'reworkNum',
|
||||||
|
minWidth: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '完成数量',
|
||||||
|
key: 'completedQuantity',
|
||||||
|
minWidth: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '完成时间',
|
||||||
|
key: 'completedTime',
|
||||||
|
minWidth: 180
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '创建人',
|
||||||
|
key: 'createBy',
|
||||||
|
minWidth: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '是否质检打回',
|
||||||
|
key: 'qualityReturn',
|
||||||
|
minWidth: 120,
|
||||||
|
render(row:any) {
|
||||||
|
const quit = row.qualityReturn === 1
|
||||||
|
return h(NTag, {type: quit ? 'error' : 'success', size: 'small'}, {default: () => (quit ? '是' : '否')})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '质检打回数量',
|
||||||
|
key: 'qualityReturnNum',
|
||||||
|
minWidth: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工序状态',
|
||||||
|
key: 'status',
|
||||||
|
minWidth: 100,
|
||||||
|
render(row:any) {
|
||||||
|
if(row.status == 0){
|
||||||
|
return h(NTag, {
|
||||||
|
type:'success',
|
||||||
|
size: 'small'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => '启用'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if(row.status == 1){
|
||||||
|
return h(NTag, {
|
||||||
|
type:'warning',
|
||||||
|
size: 'small'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => '已暂停'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if(row.status == 2){
|
||||||
|
return h(NTag, {
|
||||||
|
type:'warning',
|
||||||
|
size: 'small'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => '已改派'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '暂停/改派时间',
|
||||||
|
key: 'pauseTime',
|
||||||
|
minWidth: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '暂停/改派原因',
|
||||||
|
key: 'reason',
|
||||||
|
minWidth: 150
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
//懒加载子级
|
||||||
|
const loadingRowIds = ref<Set<number>>(new Set())
|
||||||
|
|
||||||
|
const AssingWorkDetailColums:DataTableColumns<AssingWorkDetail> = [
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"工位/设备",
|
||||||
|
key:"deviceName",
|
||||||
|
width:100,
|
||||||
|
render(row:any) {
|
||||||
|
var opt = row.deviceName
|
||||||
|
if(opt) return opt
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"操作人",
|
||||||
|
key:"userName",
|
||||||
|
width:150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"数量",
|
||||||
|
key:"num",
|
||||||
|
width:150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"来源",
|
||||||
|
key:"source",
|
||||||
|
width:150,
|
||||||
|
render(row:any) {
|
||||||
|
var opt = row.deviceName
|
||||||
|
if(opt == 1) return '设备'
|
||||||
|
if(opt == 2) return '终端'
|
||||||
|
if(opt == 3) return '后台'
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:"center",
|
||||||
|
title:"创建时间",
|
||||||
|
key:"createTime",
|
||||||
|
width:150
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
//分页
|
||||||
|
const pagination = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
itemCount: 0
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function handlePageChange(page: number) {
|
||||||
|
pagination.page = page
|
||||||
|
getlist()
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePageSizeChange(pageSize: number) {
|
||||||
|
pagination.pageSize = pageSize
|
||||||
|
pagination.page = 1
|
||||||
|
getlist()
|
||||||
|
}
|
||||||
|
|
||||||
|
// //获取列表数据
|
||||||
|
function getlist() {
|
||||||
|
try{
|
||||||
|
mytasks({
|
||||||
|
page:pagination.page,
|
||||||
|
pageSize:pagination.pageSize,
|
||||||
|
processName:processName.value
|
||||||
|
}).then((rps:any) => {
|
||||||
|
AssingWorkTableData.value = rps.records
|
||||||
|
pagination.itemCount = rps.total
|
||||||
|
})
|
||||||
|
}catch(error) {
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadTableData = async(params:Record<string,any>) => {
|
||||||
|
processName.value = params.processName
|
||||||
|
getlist()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function RowKey(row:AssingWork) {
|
||||||
|
return row.id
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailRowKey(row:any) {
|
||||||
|
return row.id
|
||||||
|
}
|
||||||
|
|
||||||
|
const AssingWorkAllExpanded = computed(()=>{
|
||||||
|
const total = AssingWorkTableData.value.length
|
||||||
|
if(!total) return false
|
||||||
|
return AssingWorkExpandedKeys.value.length >= total
|
||||||
|
})
|
||||||
|
|
||||||
|
function AssingWorkToggleExpandAll() {
|
||||||
|
if(AssingWorkAllExpanded.value) {
|
||||||
|
AssingWorkExpandedKeys.value = []
|
||||||
|
}else{
|
||||||
|
AssingWorkExpandedKeys.value = AssingWorkTableData.value.map(RowKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 缓存:key=派工id,value=明细数组
|
||||||
|
const expandDataMap = new Map<number, any[]>()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function renderAssingWorkExpand(row: AssingWork) {
|
||||||
|
// 1. 首次展开,发起请求
|
||||||
|
if (!expandDataMap.has(row.id)) {
|
||||||
|
expandDataMap.set(row.id, [])
|
||||||
|
loadingRowIds.value.add(row.id)
|
||||||
|
|
||||||
|
// 异步请求,不阻塞当前渲染
|
||||||
|
getAssingWorkDetail(row.id).then((detailList) => {
|
||||||
|
expandDataMap.set(row.id, detailList)
|
||||||
|
loadingRowIds.value.delete(row.id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 根据缓存状态渲染
|
||||||
|
if (loadingRowIds.value.has(row.id)) {
|
||||||
|
return h('div', { style: 'padding:12px' }, '加载中...')
|
||||||
|
}
|
||||||
|
|
||||||
|
const tableData = expandDataMap.get(row.id)!
|
||||||
|
return h('div', { style: 'padding: 0 16px 12px' }, [
|
||||||
|
h(NDataTable, {
|
||||||
|
columns: AssingWorkDetailColums,
|
||||||
|
data: tableData,
|
||||||
|
rowKey: DetailRowKey,
|
||||||
|
size: 'small',
|
||||||
|
bordered: true,
|
||||||
|
striped: true,
|
||||||
|
scrollX: 1360
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function getAssingWorkDetail(assingWorkId:number) {
|
||||||
|
const res = await assingWorkDetailApi.selectAssingWorkDetailListByAssingWorkId(assingWorkId)
|
||||||
|
console.log(res);
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 加载字典选项
|
||||||
|
async function loadDictOptions() {
|
||||||
|
try {
|
||||||
|
const data = await dictDataApi.listByType('assing_status')
|
||||||
|
qcAssingStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
|
||||||
|
}catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
getlist()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
loadTableData
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.toolbar {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@ -15,28 +15,6 @@
|
|||||||
<n-form-item-gi :span="6" label="工序名称">
|
<n-form-item-gi :span="6" label="工序名称">
|
||||||
<n-input v-model:value="searchForm.processName" placeholder="请输入工序名称" clearable />
|
<n-input v-model:value="searchForm.processName" placeholder="请输入工序名称" clearable />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
|
|
||||||
<!-- <n-form-item-gi :span="6" label="数里">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请输入数里" clearable />
|
|
||||||
</n-form-item-gi> -->
|
|
||||||
<!-- <n-form-item-gi :span="6" label="是否返工">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请选择" clearable />
|
|
||||||
</n-form-item-gi>
|
|
||||||
<n-form-item-gi :span="6" label="返工次数">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请输入返工次数" clearable />
|
|
||||||
</n-form-item-gi>
|
|
||||||
<n-form-item-gi :span="6" label="完成数里">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请输入完成数里" clearable />
|
|
||||||
</n-form-item-gi>
|
|
||||||
<n-form-item-gi :span="6" label="完成时间">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请选择完成时间" clearable />
|
|
||||||
</n-form-item-gi>
|
|
||||||
<n-form-item-gi :span="6" label="创建时间">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请选择创建时间" clearable />
|
|
||||||
</n-form-item-gi>
|
|
||||||
<n-form-item-gi :span="6" label="创建人">
|
|
||||||
<n-input v-model:value="searchForm.processId" placeholder="请输入创建人" clearable />
|
|
||||||
</n-form-item-gi> -->
|
|
||||||
<n-form-item-gi :span="6">
|
<n-form-item-gi :span="6">
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button type="primary" @click="search">
|
<n-button type="primary" @click="search">
|
||||||
@ -54,34 +32,16 @@
|
|||||||
</n-space>
|
</n-space>
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
</n-grid>
|
</n-grid>
|
||||||
|
|
||||||
|
|
||||||
<!-- <n-form-item label="用户类型">
|
|
||||||
<n-select
|
|
||||||
v-model:value="searchForm.userType"
|
|
||||||
placeholder="请选择用户类型"
|
|
||||||
:options="userTypeOptions"
|
|
||||||
clearable
|
|
||||||
style="width: 140px"
|
|
||||||
/>
|
|
||||||
</n-form-item> -->
|
|
||||||
<!-- <n-form-item label="状态">
|
|
||||||
<n-select
|
|
||||||
v-model:value="searchForm.status"
|
|
||||||
placeholder="请选择状态"
|
|
||||||
:options="statusOptions"
|
|
||||||
clearable
|
|
||||||
style="width: 120px"
|
|
||||||
/>
|
|
||||||
</n-form-item> -->
|
|
||||||
|
|
||||||
</n-form>
|
</n-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<AssingWorkTreeTable
|
||||||
|
ref="treeTableRef"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<n-data-table
|
<!-- <n-data-table
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
size="small"
|
size="small"
|
||||||
striped
|
striped
|
||||||
@ -107,7 +67,7 @@
|
|||||||
共 {{ pagination.itemCount }} 条
|
共 {{ pagination.itemCount }} 条
|
||||||
</template>
|
</template>
|
||||||
</n-pagination>
|
</n-pagination>
|
||||||
</div>
|
</div> -->
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
||||||
<PlmModelDrawer ref="plmModelDrawerRef" />
|
<PlmModelDrawer ref="plmModelDrawerRef" />
|
||||||
@ -180,6 +140,54 @@
|
|||||||
|
|
||||||
</n-modal>
|
</n-modal>
|
||||||
|
|
||||||
|
<!--改派弹框-->
|
||||||
|
<n-modal
|
||||||
|
v-model:show="reassignmodal"
|
||||||
|
title="改派"
|
||||||
|
preset="card"
|
||||||
|
style="width: 400px"
|
||||||
|
:mask-closable="false"
|
||||||
|
>
|
||||||
|
<n-form
|
||||||
|
ref="reassformRef"
|
||||||
|
:model="reassform"
|
||||||
|
:rules="reassrules"
|
||||||
|
label-placement="top"
|
||||||
|
label-width="80"
|
||||||
|
>
|
||||||
|
<n-form-item label="工序编号">
|
||||||
|
<n-input v-model:value="gxobg.id" disabled />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="工序名称">
|
||||||
|
<n-input v-model:value="gxobg.name" disabled />
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
|
<n-form-item label="改派工人" path="">
|
||||||
|
<n-select
|
||||||
|
v-model:value="reassform.userId"
|
||||||
|
placeholder="请指定改派的员工"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
:options="reassignEmployees"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="改派原因" path="reason">
|
||||||
|
<n-input type="textarea" v-model:value="reassform.reason" placeholder="请输入改派原因" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<n-space justify="end">
|
||||||
|
<n-button @click="reassignmodal = false">取消</n-button>
|
||||||
|
<n-button
|
||||||
|
type="primary"
|
||||||
|
:loading="reassLoading"
|
||||||
|
@click="reassSubmit"
|
||||||
|
:disabled="reassdisedbtn"
|
||||||
|
>确定</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -196,6 +204,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
NButton,
|
NButton,
|
||||||
|
NDropdown,
|
||||||
NIcon,
|
NIcon,
|
||||||
NSpace,
|
NSpace,
|
||||||
NPagination,
|
NPagination,
|
||||||
@ -209,7 +218,9 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
SearchOutline,
|
SearchOutline,
|
||||||
RefreshOutline
|
RefreshOutline,
|
||||||
|
SyncOutline,
|
||||||
|
EllipsisHorizontalOutline
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
|
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
@ -224,6 +235,14 @@ import AssingWorkVue from '@/views/biz/flowingAround/assingWork.vue'
|
|||||||
import { qualityTestingApi, type QualityTesting } from '@/api/qualityTesting'
|
import { qualityTestingApi, type QualityTesting } from '@/api/qualityTesting'
|
||||||
import SumbitDetailCard from '@/components/SumbitDetailCard.vue'
|
import SumbitDetailCard from '@/components/SumbitDetailCard.vue'
|
||||||
import { SubmitLog } from '@/api/submitLog'
|
import { SubmitLog } from '@/api/submitLog'
|
||||||
|
import {
|
||||||
|
transfer
|
||||||
|
} from '@/api/production'
|
||||||
|
import { SysUser, userApi } from '@/api/system'
|
||||||
|
import AssingWorkTreeTable from '../componets/AssingWorkTreeTable.vue'
|
||||||
|
|
||||||
|
const treeTableRef = ref<InstanceType<typeof AssingWorkTreeTable>>()
|
||||||
|
|
||||||
|
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
|
|
||||||
@ -280,7 +299,7 @@ const columns = [
|
|||||||
// type: 'selection',
|
// type: 'selection',
|
||||||
// minWidth:60
|
// minWidth:60
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
align:"center",
|
align:"center",
|
||||||
title:"物料名称",
|
title:"物料名称",
|
||||||
key:"materialName",
|
key:"materialName",
|
||||||
@ -314,6 +333,12 @@ const columns = [
|
|||||||
key: 'processName',
|
key: 'processName',
|
||||||
minWidth: 200
|
minWidth: 200
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '工序名称',
|
||||||
|
key: 'processCode',
|
||||||
|
minWidth: 200
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align:'center',
|
align:'center',
|
||||||
title: '派工状态',
|
title: '派工状态',
|
||||||
@ -478,45 +503,65 @@ const columns = [
|
|||||||
{ default: () => '完工汇报'}
|
{ default: () => '完工汇报'}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons.push(h(NButton, {
|
buttons.push(h(NButton, {
|
||||||
size: 'small',
|
size: 'small',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
ghost: true,
|
ghost: true,
|
||||||
onClick: () => openPlmModel(row),
|
disabled: row.cancelBtnDisable,
|
||||||
}, { default: () => '模型' }))
|
|
||||||
|
|
||||||
buttons.push(h(NButton, {
|
|
||||||
size: 'small',
|
|
||||||
type: 'info',
|
|
||||||
ghost: true,
|
|
||||||
onClick: ()=> cancelQuality(row)
|
onClick: ()=> cancelQuality(row)
|
||||||
}, { default: () => '质检撤回' }))
|
}, { default: () => '质检撤回' }))
|
||||||
|
|
||||||
|
|
||||||
|
buttons.push(
|
||||||
|
h(NDropdown, {
|
||||||
|
trigger:'click',
|
||||||
|
options:[
|
||||||
|
{label:"改派",key:'transfer'},
|
||||||
|
{type: 'divider' }, // 分割线
|
||||||
|
],
|
||||||
|
onSelect:(key:string)=>{
|
||||||
|
switch(key) {
|
||||||
|
case "transfer":
|
||||||
|
handlreass(row)
|
||||||
|
break
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
// 下拉触发按钮:三点图标 / 更多文字
|
||||||
|
default: () => h(NButton, { size: 'small', quaternary: true }, {
|
||||||
|
default: () => [h(NIcon, null, { default: () => h(EllipsisHorizontalOutline) })]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
)
|
||||||
return buttons.length > 0 ? h(NSpace, {justify:'center'}, { default: () => buttons }) : '-'
|
return buttons.length > 0 ? h(NSpace, {justify:'center'}, { default: () => buttons }) : '-'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
function dropdownIcon(icon: Component) {
|
||||||
|
return () => h(NIcon, null, { default: () => h(icon) })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//搜索数据
|
//搜索数据
|
||||||
function search() {
|
function search() {
|
||||||
pagination.page = 1
|
treeTableRef.value?.loadTableData({...searchForm})
|
||||||
searchForm.page = 1
|
|
||||||
searchForm.pageSize = 20
|
|
||||||
getlist()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//重置
|
//重置
|
||||||
function reset() {
|
function reset() {
|
||||||
searchForm.processId =''
|
searchForm.processId =''
|
||||||
searchForm.processName = ''
|
searchForm.processName = ''
|
||||||
|
treeTableRef.value?.loadTableData({...searchForm})
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取列表数据
|
//获取列表数据
|
||||||
function getlist() {
|
function getlist() {
|
||||||
|
searchForm.page = pagination.page
|
||||||
|
searchForm.pageSize = pagination.pageSize
|
||||||
mytasks(searchForm).then((rps:any) => {
|
mytasks(searchForm).then((rps:any) => {
|
||||||
datalist.value = rps.records
|
datalist.value = rps.records
|
||||||
pagination.itemCount = rps.total
|
pagination.itemCount = rps.total
|
||||||
@ -527,15 +572,12 @@ function getlist() {
|
|||||||
|
|
||||||
function handlePageChange(page: number) {
|
function handlePageChange(page: number) {
|
||||||
pagination.page = page
|
pagination.page = page
|
||||||
searchForm.page = page
|
|
||||||
getlist()
|
getlist()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePageSizeChange(pageSize: number) {
|
function handlePageSizeChange(pageSize: number) {
|
||||||
pagination.pageSize = pageSize
|
pagination.pageSize = pageSize
|
||||||
pagination.page = 1
|
pagination.page = 1
|
||||||
searchForm.page = 1
|
|
||||||
searchForm.pageSize = pageSize
|
|
||||||
getlist()
|
getlist()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,8 +806,79 @@ async function cancelSubmit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//改派
|
||||||
|
//改派员工列
|
||||||
|
const reassignEmployees = ref<Array<{value: number, username: string}>>([])
|
||||||
|
|
||||||
|
let reassLoading = ref(false)
|
||||||
|
let reassdisedbtn = ref(false)
|
||||||
|
|
||||||
|
let reassignmodal = ref(false)
|
||||||
|
|
||||||
|
const reassformRef = ref()
|
||||||
|
|
||||||
|
let reassform = reactive<any>({
|
||||||
|
id:null, //派工id
|
||||||
|
reason:null, //改派原因
|
||||||
|
userId:null //改派设备
|
||||||
|
})
|
||||||
|
|
||||||
|
const reassrules = {
|
||||||
|
userid: [{ required: true, message: '请选择员工', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlreass(n:any) {
|
||||||
|
|
||||||
|
gxobg.name = n.processName
|
||||||
|
gxobg.id = n.processId
|
||||||
|
|
||||||
|
reassignmodal.value = true
|
||||||
|
reassLoading.value = false
|
||||||
|
reassdisedbtn.value = false
|
||||||
|
reassformRef.value?.restoreValidation()
|
||||||
|
reassform.id = n.id
|
||||||
|
reassform.reason = ''
|
||||||
|
reassform.userid = ''
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function reassSubmit() {
|
||||||
|
reassformRef.value?.validate((v:any) => {
|
||||||
|
if(!v){
|
||||||
|
reassLoading.value = true
|
||||||
|
reassdisedbtn.value = true
|
||||||
|
transfer(reassform).then(() => {
|
||||||
|
message.success('操作成功!')
|
||||||
|
setTimeout(()=> {
|
||||||
|
reassignmodal.value = false
|
||||||
|
reassLoading.value = false
|
||||||
|
reassdisedbtn.value = false
|
||||||
|
getlist()
|
||||||
|
},1000)
|
||||||
|
}).catch(() => {
|
||||||
|
reassdisedbtn.value = false
|
||||||
|
reassLoading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//获取员工列
|
||||||
|
async function getUserList() {
|
||||||
|
const res = await userApi.getPathList();
|
||||||
|
|
||||||
|
reassignEmployees.value = res.map((user:SysUser)=>(
|
||||||
|
{
|
||||||
|
label: user.username,
|
||||||
|
value: user.id
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getlist()
|
getlist()
|
||||||
|
getUserList()
|
||||||
loadDictOptions()
|
loadDictOptions()
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user