This commit is contained in:
andy 2026-07-24 14:34:20 +08:00
commit 5e8bcd2114
31 changed files with 10345 additions and 148 deletions

View File

@ -5,8 +5,17 @@ VITE_APP_TITLE = 伊特机械MES
VITE_APP_ENV = 'development'
# 开发环境
<<<<<<< HEAD
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://localhost/api'
#VITE_APP_BASE_API = 'http://localhost:9100/gateway'
#VITE_APP_BASE_API = '/dev-api'

View File

@ -7,6 +7,6 @@ VITE_APP_ENV = 'production'
# 若依管理系统/生产环境
#VITE_APP_BASE_API = '/prod-api'
# 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
VITE_BUILD_COMPRESS = gzip

View 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' })
}
}

View 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

File diff suppressed because it is too large Load Diff

6
pnpm-workspace.yaml Normal file
View 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

View 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"
})
}
}

View 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
})
}
}

View File

@ -114,5 +114,12 @@ export const deviceApi = {
responseType:"blob"
})
},
getDeviceList(params:{sectionIds:any}){
return request({
url:"/biz/device/getDeviceList",
method:"get",
params
})
}
}

View 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' })
}
}

View File

@ -256,6 +256,8 @@ export function processItemToEntity(
storageEntry: item.storageEntry,
workCenterName:item.workCenterName
}
}

View File

@ -32,6 +32,8 @@ export interface ProcessRouteStep {
changeTime?: string
isBind?: boolean
}
// 工艺路线工序明细 API
@ -41,6 +43,7 @@ export const processRouteStepApi = {
return request({ url: '/biz/processRouteStep/page', method: 'get', params })
},
// 获取详情
detail(id: number) {
return request({ url: `/biz/processRouteStep/${id}`, method: 'get' })
@ -85,5 +88,13 @@ export const processRouteStepApi = {
// 下载导入模板
downloadTemplate() {
return request({ url: `/biz/processRouteStep/template`, method: 'get', responseType: 'blob' })
},
list(params:{id:number}) {
return request({
url:"/biz/processRouteStep/list",
method:'get',
params
})
}
}

View File

@ -1,5 +1,32 @@
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) {
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({
url: `/mes/dispatch/my-tasks`,
method: 'get',

116
src/api/qcItem.ts Normal file
View 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
View 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' })
}
}

View File

@ -68,10 +68,11 @@ export const sectionApi = {
})
},
list() {
list(params:{sectionName:string}) {
return request({
url:"/biz/section/list",
method:"get"
method:"get",
params
})
}

View 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' })
}
}

View File

@ -134,7 +134,17 @@ export const userApi = {
url:"sys/user/list",
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> {
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'
})
}
}

View File

@ -282,6 +282,7 @@ const routes: RouteRecordRaw[] = [
component: () => import('@/views/biz/flowingAround/index.vue'),
meta: { title: '流转记录表', icon: 'ListOutline' }
},
{
path: 'biz/outsourcing',
name: 'outsourcing',

View File

@ -1,7 +1,7 @@
import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios'
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响应结构
interface ApiResponse<T = any> {
@ -117,7 +117,6 @@ async function decryptResponseData(data: string): Promise<any> {
// 后端 API 统一使用 /api 前缀
const service: AxiosInstance = axios.create({
baseURL:'/api',
//baseURL: BASE_API,
timeout: 30000
})

View 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>

View File

@ -52,13 +52,26 @@
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
: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>
<!-- 新增/编辑弹窗 -->
@ -95,6 +108,17 @@
style="width: 200px"
/>
</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-input v-model:value="formData.manufacturer" placeholder="请输入生产厂家" />
</n-form-item>
@ -161,12 +185,15 @@ import { deviceApi, type Device } from '@/api/device'
import { dictDataApi } from '@/api/org'
import {sectionApi, type Section} from '@/api/section'
import { SysUser, userApi } from '@/api/system'
const message = useMessage()
const dialog = useDialog()
const router = useRouter()
//
const deviceManagerList = ref<{label:string,value:any}[]>([])
let sectionList = reactive<{label:string,value:any}[]>([])
//
@ -207,6 +234,7 @@ const defaultFormData: Device = {
status:0,
deviceFlag:'mes_equipment',
synEquipId: null as number | null,
deviceManagerList: null as any | null
}
const formData = reactive<Device>({ ...defaultFormData })
@ -218,6 +246,17 @@ const deviceFlagList = ref<{ label: string; value: any ;class:any}[]>([])
//
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 ?? '-'
},
{ title: '设备类型', key: 'deviceType' },
{ title: '设备负责人', key: 'deviceManagerName' },
{ title: '所属工段', key: 'sectionName' },
{ title: '设备型号', key: 'spec' },
{ title: '生产厂家', key: 'manufacturer' },
@ -319,8 +359,11 @@ function goRealtimeBoard() {
//
function handleEdit(row: Device) {
modalTitle.value = '编辑设备表'
Object.assign(formData, row)
console.log(formData);
modalVisible.value = true
}
@ -329,6 +372,7 @@ async function handleSubmit() {
await formRef.value?.validate()
try {
const submitData = { ...formData } as Device
if (typeof submitData.manufactureDate === 'number') {
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) }))
}
//
async function handleUser() {
const res = await userApi.getEquipmentManager()
deviceManagerList.value = res
}
onMounted(() => {
loadData()
handleUser()
loadSection()
loadDictOptions()
})

View 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: 'IDmes_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>

View File

@ -198,6 +198,7 @@
@assign="(p) => disphand(p, order)"
@outsource="(p) => openOutsource(order, p)"
@view-model="(p) => openPlmModel(order, p)"
@submit-detail = "(p) => openDetailModel(order,p)"
/>
</div>
</div>
@ -205,8 +206,11 @@
</n-spin>
</div>
<!--模型抽屉 -->
<PlmModelDrawer ref="plmModelDrawerRef" />
<div class="board-pagination">
<n-pagination
v-model:page="pagination.page"
@ -246,6 +250,7 @@
:can-edit="hasPermission('biz:orderItem:edit')"
:can-assign="hasPermission('biz:orderItem:assign')"
:can-outsource="hasPermission('biz:orderProcessPlan:add')"
:can-submitDetail="hasPermission('biz:submitLog:detail')"
@edit="(p) => handleEdit(p, detailData!)"
@assign="(p) => disphand(p, detailData!)"
@outsource="(p) => openOutsource(detailData!, p)"
@ -347,6 +352,7 @@
:key="i"
:obj="n"
:index="i"
:section="dispatchform.workCenterName"
listname="list"
@addhand="addpgnum"
@delehand="deletenum(i)"
@ -522,6 +528,13 @@
</n-upload>
</n-space>
</n-modal>
<!-- 汇报详情弹窗 -->
<n-modal v-model:show="submitLogModalVisible" preset="card" title="导入工序计划" style="width: 500px">
</n-modal>
</div>
</template>
@ -555,6 +568,9 @@ import ProcessCard from './components/ProcessCard.vue'
import PlmModelDrawer from '@/components/PlmModelDrawer.vue'
import type { PlmModelOpenContext } from '@/api/plmModel'
import Pgitem from './pgitem.vue'
import { submitLogApi } from '@/api/submitLog.ts'
const message = useMessage()
const dialog = useDialog()
@ -593,14 +609,15 @@ const dispatchmodal = ref(false)
const dispatchLoading = ref(false)
const dispatchformRef = ref()
const dispatchform = reactive<any>({
id: '', name: '', beginTime: '', endTime: '', quantity: '',
list: [{ sectionId:'',deviceId:'',userList: '', quantity: '' }],
id: '', name: '', beginTime: '', endTime: '', quantity: '',workCenterName:'',
list: [{ sectionId:'',deviceId:'', quantity: '' }],
})
const dispatchrules = {}
const importModalVisible = ref(false)
const plmModelDrawerRef = ref<InstanceType<typeof PlmModelDrawer> | null>(null)
const outsourceModalVisible = ref(false)
const outsourceOptionsLoading = ref(false)
const outsourceSubmitLoading = ref(false)
@ -640,6 +657,18 @@ function openPlmModel(order: OrderProcessPlanVO, process?: ProcessPlanItemVO) {
plmModelDrawerRef.value?.open(ctx)
}
//
const submitLogModalVisible = ref<Boolean>(false)
//
function openDetailModel(order:ProcessPlanItemVO,procces?:OrderProcessPlanVO) {
submitLogModalVisible.value = true
const processId = procces.planId
}
const batchOptions = [
{ label: '全部展开', key: 'expandAll' },
{ label: '全部收起', key: 'collapseAll' },
@ -1006,6 +1035,7 @@ async function handleSubmit() {
function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
const entity = processItemToEntity(process, order?.orderItemId)
dispatchmodal.value = true
dispatchformRef.value?.restoreValidation()
dispatchform.id = entity.id
@ -1015,11 +1045,14 @@ function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
dispatchform.quantity = entity.quantity
dispatchform.orderItemId = entity.orderItemId
dispatchform.sort = entity.sort
dispatchform.list = [{ sectionId:'',deviceId:'',userList: '', quantity: '' }]
dispatchform.workCenterName = entity.workCenterName
dispatchform.list = [{ sectionId:'',deviceId:'', quantity: '' }]
}
function addpgnum() {
dispatchform.list.push({ sectionId:'',deviceId:'',userList: '', quantity: '' })
dispatchform.list.push({ sectionId:'',deviceId:'', quantity: '' })
}
function deletenum(index: number) {

View File

@ -82,6 +82,12 @@
ghost
@click="emit('outsource', process)"
>委外</n-button>
<n-button
size="tiny"
quaternary
ghost
@click="emit('submitDetail', process)"
>汇报</n-button>
<n-button
size="tiny"
:type="process.processStatus === 4 ? 'success' : 'default'"
@ -108,6 +114,7 @@ const props = defineProps<{
canEdit?: boolean
canAssign?: boolean
canOutsource?: boolean
canSubmitDetail?: boolean
}>()
const emit = defineEmits<{
@ -115,6 +122,7 @@ const emit = defineEmits<{
assign: [process: ProcessPlanItemVO]
viewModel: [process: ProcessPlanItemVO]
outsource: [process: ProcessPlanItemVO]
submitDetail: [process: ProcessPlanItemVO]
}>()
const totalQty = computed(() => props.process.quantity ?? 0)

View File

@ -5,11 +5,6 @@
<n-form-item
label="指派工段"
:path="`${listname}[${index}].sectionId`"
:rule="{
required:true,
message:`请选择工段`,
trigger: 'blur'
}"
>
<n-select
v-model:value="obj.sectionId"
@ -17,10 +12,9 @@
placeholder="请选择工段"
:options="sectionList"
:loading="loadingRef"
clearable
disabled
remote
:clear-filter-after-select="false"
@change="searchSection"
/>
</n-form-item>
</n-gi>
@ -50,39 +44,6 @@
</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-form-item
label="数量"
@ -129,14 +90,13 @@
AddOutline,
TrashOutline,
} from '@vicons/ionicons5'
import { any, 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'
import { label } from 'three/tsl'
const props = withDefaults(defineProps<{
listname:any
obj:any,
index:any
section:string
}>(), {
obj:{}
})
@ -196,30 +156,40 @@ import { number } from 'echarts'
//
async function loadSection() {
const data = await sectionApi.list()
sectionList =data.map((d:any)=>{
return {
label:d.sectionName,
value:d.id+''
}
//section
const res = await sectionApi.list({sectionName:props.section})
const mesSection = res.MesSection;
const mesDevice = res.MesDevice
console.log(mesSection);
sectionList.push({
label:mesSection.sectionName,
value:mesSection.id
})
props.obj.sectionId = mesSection.id
}
function searchSection(sectionId?:number){
if(!sectionId) return
props.obj.deviceId = ''
deviceList.value = []
deviceApi.list(sectionId).then(res=>{
deviceList.value = res.map((n:any)=>{
deviceList.value = mesDevice.map((n:any)=>{
return {
label:n.name,
label:n.deviceName,
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()
slehand()
// handleDevice()

View 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、Worddoc/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 }`
// 使Blobnew 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>

View File

@ -49,13 +49,26 @@
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
: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>
<!-- 新增/编辑弹窗 -->

View 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>

View 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+34
},
{
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=idvalue=
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>

View File

@ -15,28 +15,6 @@
<n-form-item-gi :span="6" label="工序名称">
<n-input v-model:value="searchForm.processName" 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" label="创建人">
<n-input v-model:value="searchForm.processId" placeholder="请输入创建人" clearable />
</n-form-item-gi> -->
<n-form-item-gi :span="6">
<n-space>
<n-button type="primary" @click="search">
@ -55,33 +33,15 @@
</n-form-item-gi>
</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>
</div>
<AssingWorkTreeTable
ref="treeTableRef"
/>
<!-- 表格 -->
<n-data-table
<!-- <n-data-table
:columns="columns"
size="small"
striped
@ -107,7 +67,7 @@
{{ pagination.itemCount }}
</template>
</n-pagination>
</div>
</div> -->
</n-card>
<PlmModelDrawer ref="plmModelDrawerRef" />
@ -180,6 +140,54 @@
</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>
</template>
@ -196,6 +204,7 @@ import {
import {
NButton,
NDropdown,
NIcon,
NSpace,
NPagination,
@ -209,7 +218,9 @@ import {
import {
SearchOutline,
RefreshOutline
RefreshOutline,
SyncOutline,
EllipsisHorizontalOutline
} from '@vicons/ionicons5'
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 SumbitDetailCard from '@/components/SumbitDetailCard.vue'
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()
@ -314,6 +333,12 @@ const columns = [
key: 'processName',
minWidth: 200
},
{
align:'center',
title: '工序名称',
key: 'processCode',
minWidth: 200
},
{
align:'center',
title: '派工状态',
@ -478,45 +503,65 @@ const columns = [
{ default: () => '完工汇报'}
))
}
buttons.push(h(NButton, {
size: 'small',
type: 'info',
ghost: true,
onClick: () => openPlmModel(row),
}, { default: () => '模型' }))
buttons.push(h(NButton, {
size: 'small',
type: 'info',
ghost: true,
disabled: row.cancelBtnDisable,
onClick: ()=> cancelQuality(row)
}, { 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 }) : '-'
}
}
]
function dropdownIcon(icon: Component) {
return () => h(NIcon, null, { default: () => h(icon) })
}
//
function search() {
pagination.page = 1
searchForm.page = 1
searchForm.pageSize = 20
getlist()
treeTableRef.value?.loadTableData({...searchForm})
}
//
function reset() {
searchForm.processId =''
searchForm.processName = ''
treeTableRef.value?.loadTableData({...searchForm})
}
//
function getlist() {
searchForm.page = pagination.page
searchForm.pageSize = pagination.pageSize
mytasks(searchForm).then((rps:any) => {
datalist.value = rps.records
pagination.itemCount = rps.total
@ -527,15 +572,12 @@ function getlist() {
function handlePageChange(page: number) {
pagination.page = page
searchForm.page = page
getlist()
}
function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
searchForm.page = 1
searchForm.pageSize = pageSize
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(() => {
getlist()
getUserList()
loadDictOptions()
})