Merge branch 'master' of https://git.evo-techina.com/sgc/mes-vue
This commit is contained in:
commit
07a806dcfe
96
src/api/assingRework.ts
Normal file
96
src/api/assingRework.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
// AssingRework 类型定义
|
||||
export interface AssingRework {
|
||||
id?: number
|
||||
|
||||
processId?: number
|
||||
|
||||
userId?: number
|
||||
|
||||
quantity?: number
|
||||
|
||||
completedQuantity?: number
|
||||
|
||||
completedTime?: string
|
||||
|
||||
createTime?: string
|
||||
|
||||
createBy?: string
|
||||
|
||||
qualityReturn?: number
|
||||
|
||||
qualityReturnNum?: string
|
||||
|
||||
qualityIds?: string
|
||||
|
||||
status?: number
|
||||
|
||||
reason?: string
|
||||
|
||||
pauseTime?: string
|
||||
|
||||
assingStatus?: number
|
||||
|
||||
返工派工单号?: string
|
||||
|
||||
}
|
||||
|
||||
// AssingRework API
|
||||
export const assingReworkApi = {
|
||||
// 分页查询
|
||||
page(params: { page: number; pageSize: number; id?: number; status?: number }) {
|
||||
return request({ url: '/biz/assingRework/page', method: 'get', params })
|
||||
},
|
||||
|
||||
// 获取详情
|
||||
detail(id: string) {
|
||||
return request({ url: `/biz/assingRework/${id}`, method: 'get' })
|
||||
},
|
||||
|
||||
// 新增
|
||||
create(data: AssingRework) {
|
||||
return request({ url: '/biz/assingRework', method: 'post', data })
|
||||
},
|
||||
|
||||
// 修改
|
||||
update(data: AssingRework) {
|
||||
return request({ url: '/biz/assingRework', method: 'put', data })
|
||||
},
|
||||
|
||||
// 删除
|
||||
delete(ids: string[]) {
|
||||
return request({ url: `/biz/assingRework/${ids.join(',')}`, method: 'delete' })
|
||||
},
|
||||
|
||||
// 获取列表
|
||||
allList() {
|
||||
return request({ url: '/mes/dispatch/all', method: 'get' })
|
||||
},
|
||||
|
||||
// 导出
|
||||
export(params?: { ids?: string[]; id?: number; status?: number }) {
|
||||
const p: Record<string, any> = {}
|
||||
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||
if (params?.id !== undefined && params?.id !== null) p.id = params.id
|
||||
if (params?.status !== undefined && params?.status !== null) p.status = params.status
|
||||
return request({ url: `/biz/assingRework/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/assingRework/import`,
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
|
||||
// 下载导入模板
|
||||
downloadTemplate() {
|
||||
return request({ url: `/biz/assingRework/template`, method: 'get', responseType: 'blob' })
|
||||
}
|
||||
}
|
||||
80
src/api/qcResultDetail.ts
Normal file
80
src/api/qcResultDetail.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
// 质检结果明细表 类型定义
|
||||
export interface QcResultDetail {
|
||||
id?: number
|
||||
|
||||
qcId?: number
|
||||
|
||||
resultType?: number
|
||||
|
||||
qty?: string
|
||||
|
||||
traceCode?: string
|
||||
|
||||
defectCode?: string
|
||||
|
||||
handleAction?: string
|
||||
|
||||
actionStatus?: number
|
||||
|
||||
remark?: string
|
||||
|
||||
createTime?: string
|
||||
|
||||
updateTime?: string
|
||||
|
||||
}
|
||||
|
||||
// 质检结果明细表 API
|
||||
export const qcResultDetailApi = {
|
||||
// 分页查询
|
||||
page(params : { page: number; pageSize: number; id?: number; resultType?: number,traceCode:string,defectCode:string }) {
|
||||
return request({ url: '/biz/qcResultDetail/page', method: 'get', params })
|
||||
},
|
||||
|
||||
// 获取详情
|
||||
detail(id: number) {
|
||||
return request({ url: `/biz/qcResultDetail/${id}`, method: 'get' })
|
||||
},
|
||||
|
||||
// 新增
|
||||
create(data: QcResultDetail) {
|
||||
return request({ url: '/biz/qcResultDetail', method: 'post', data })
|
||||
},
|
||||
|
||||
// 修改
|
||||
update(data: QcResultDetail) {
|
||||
return request({ url: '/biz/qcResultDetail', method: 'put', data })
|
||||
},
|
||||
|
||||
// 删除
|
||||
delete(ids: number[]) {
|
||||
return request({ url: `/biz/qcResultDetail/${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/qcResultDetail/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/qcResultDetail/import`,
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
|
||||
// 下载导入模板
|
||||
downloadTemplate() {
|
||||
return request({ url: `/biz/qcResultDetail/template`, method: 'get', responseType: 'blob' })
|
||||
}
|
||||
}
|
||||
101
src/api/qualityTesting.ts
Normal file
101
src/api/qualityTesting.ts
Normal file
@ -0,0 +1,101 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
import {QcResultDetail} from "@/api/qcResultDetail.ts";
|
||||
|
||||
// 质检单表 类型定义
|
||||
export interface QualityTesting {
|
||||
id?: number
|
||||
|
||||
qcNo?: string
|
||||
|
||||
sourceType?: number
|
||||
|
||||
sourceId?: number
|
||||
|
||||
sourceName?: string
|
||||
|
||||
orderId?: number
|
||||
|
||||
processId?: number
|
||||
|
||||
itemId?: number
|
||||
|
||||
totalQty?: number
|
||||
|
||||
status?: number
|
||||
|
||||
inspectorId?: number
|
||||
|
||||
inspectTime?: string
|
||||
|
||||
traceType?: number
|
||||
|
||||
createBy?: number
|
||||
|
||||
createTime?: string
|
||||
|
||||
updateTime?: string
|
||||
|
||||
}
|
||||
|
||||
// 质检单表 API
|
||||
export const qualityTestingApi = {
|
||||
// 分页查询
|
||||
page(params: { page: number; pageSize: number; qcNo?: string; status?: number }) {
|
||||
return request({ url: '/mes/qc/list', method: 'get', params })
|
||||
},
|
||||
|
||||
// 获取详情
|
||||
detail(id: number) {
|
||||
return request({ url: `/mes/qc/${id}`, method: 'get' })
|
||||
},
|
||||
|
||||
// 新增
|
||||
create(data: QualityTesting) {
|
||||
return request({ url: '/mes/qc', method: 'post', data })
|
||||
},
|
||||
|
||||
// 修改
|
||||
update(data: QualityTesting) {
|
||||
return request({ url: '/mes/qc', method: 'put', data })
|
||||
},
|
||||
|
||||
// 删除
|
||||
delete(ids: number[]) {
|
||||
return request({ url: `/mes/qc/${ids.join(',')}`, method: 'delete' })
|
||||
},
|
||||
//提交判定明细
|
||||
submit(data: QcResultDetail[]) {
|
||||
return request({ url: '/mes/qc/judge', method: 'put', data })
|
||||
},
|
||||
//质检撤回
|
||||
cancel(id: number) {
|
||||
return request({ url: `/mes/dispatch/revoke/${id}`, method: 'put' })
|
||||
},
|
||||
|
||||
// 导出
|
||||
export(params?: { ids?: number[]; id?: number; status?: number }) {
|
||||
const p: Record<string, any> = {}
|
||||
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||
if (params?.id !== undefined && params?.id !== null) p.id = params.id
|
||||
if (params?.status !== undefined && params?.status !== null) p.status = params.status
|
||||
return request({ url: `/mes/qc/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/qualityTesting/import`,
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
|
||||
// 下载导入模板
|
||||
downloadTemplate() {
|
||||
return request({ url: `/biz/qualityTesting/template`, method: 'get', responseType: 'blob' })
|
||||
}
|
||||
}
|
||||
@ -19,8 +19,8 @@ export interface SubmitLog {
|
||||
// 派工工单汇报记录 API
|
||||
export const submitLogApi = {
|
||||
// 分页查询
|
||||
page(params: { page: number; pageSize: number; id?: number }) {
|
||||
return request({ url: '/biz/submitLog/page', method: 'get', params })
|
||||
page(params: { page: number; pageSize: number; assingStatus?: number }) {
|
||||
return request({ url: '/mes/report/page', method: 'get', params })
|
||||
},
|
||||
|
||||
// 获取详情
|
||||
@ -66,5 +66,10 @@ export const submitLogApi = {
|
||||
// 下载导入模板
|
||||
downloadTemplate() {
|
||||
return request({ url: `/biz/submitLog/template`, method: 'get', responseType: 'blob' })
|
||||
},
|
||||
|
||||
//汇报统计
|
||||
statistics(params?: {time?:string; type?:string}){
|
||||
return request({url:'/mes/report/statistics',method:'get',params})
|
||||
}
|
||||
}
|
||||
|
||||
218
src/views/biz/qualityTesting/detail.vue
Normal file
218
src/views/biz/qualityTesting/detail.vue
Normal file
@ -0,0 +1,218 @@
|
||||
<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
|
||||
v-model:value="searchForm.resultType"
|
||||
:options="qcResultTypeOptions"
|
||||
placeholder="请选择判定类型"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="追溯码">
|
||||
<n-input v-model:value="searchForm.traceCode" placeholder="请输入批次号/SN码" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="缺陷码">
|
||||
<n-input v-model:value="searchForm.defectCode" placeholder="请输入批次号/SN码" 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>
|
||||
|
||||
<!-- 表格 -->
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
</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 { qcResultDetailApi, type QcResultDetail } from '@/api/qcResultDetail'
|
||||
import { dictDataApi } from '@/api/org'
|
||||
|
||||
import {useRoute} from "vue-router";
|
||||
const qcId = ref<number>(0)
|
||||
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<QcResultDetail[]>([])
|
||||
const loading = ref(false)
|
||||
const selectedIds = ref<number[]>([])
|
||||
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50]
|
||||
})
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
qcId:qcId,
|
||||
resultType: undefined, //判定类型
|
||||
traceCode: undefined,//追溯码
|
||||
defectCode: undefined,//缺陷吗
|
||||
})
|
||||
|
||||
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||
const actionStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||
//判定类型
|
||||
const qcResultTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
//执行状态
|
||||
const qcActionStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||
|
||||
|
||||
// 表格列
|
||||
const columns: DataTableColumns<QcResultDetail> = [
|
||||
{ type: 'selection' },
|
||||
{ title: '判定类型', key: 'resultType',
|
||||
render(row) {
|
||||
const val = row.resultType
|
||||
const opt = qcResultTypeOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '判定数量', key: 'qty' },
|
||||
{ title: '批次号/SN码', key: 'traceCode' },
|
||||
{ title: '缺陷码', key: 'defectCode' },
|
||||
{ title: '后续动作', key: 'handleAction' },
|
||||
{ title: '执行状态', key: 'actionStatus',
|
||||
render(row) {
|
||||
const val = row.actionStatus
|
||||
const opt = qcActionStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '备注/原因描述', key: 'remark' },
|
||||
{ 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 qcResultDetailApi.page(searchForm)
|
||||
tableData.value = res.list
|
||||
pagination.itemCount = res.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
searchForm.traceCode = undefined
|
||||
searchForm.defectCode = undefined
|
||||
searchForm.resultType = undefined
|
||||
|
||||
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[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 加载字典选项
|
||||
async function loadDictOptions() {
|
||||
try {
|
||||
const data = await dictDataApi.listByType('sys_status')
|
||||
actionStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
} catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_result_type')
|
||||
qcResultTypeOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_action_status')
|
||||
qcActionStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const route = useRoute()
|
||||
qcId.value =Number(route.params.id)
|
||||
loadData()
|
||||
loadDictOptions()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
931
src/views/biz/qualityTesting/index.vue
Normal file
931
src/views/biz/qualityTesting/index.vue
Normal file
@ -0,0 +1,931 @@
|
||||
<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.qcNo" placeholder="请输入质检编号" clearable />
|
||||
</n-form-item>
|
||||
<n-form-item label="质检状态">
|
||||
<n-select
|
||||
v-model:value="searchForm.status"
|
||||
:options="qcStatusOptions"
|
||||
placeholder="请选择质检状态"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</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"
|
||||
size="small"
|
||||
remote
|
||||
:border="false"
|
||||
:single-line="false"
|
||||
striped
|
||||
/>
|
||||
<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"
|
||||
>
|
||||
<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="质检编号">
|
||||
<n-input v-model:value="formData.qcNo" placeholder="请输入质检编号" disabled />
|
||||
</n-form-item>
|
||||
|
||||
|
||||
<n-grid x-gap="12" :cols="2">
|
||||
<n-gi>
|
||||
<n-form-item label="来源类型" path="sourceType">
|
||||
<n-select
|
||||
v-model:value="formData.sourceType"
|
||||
:options="qcSourceTypeOptions"
|
||||
placeholder="请选择来源类型"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="业务来源" path="sourceId">
|
||||
<n-select
|
||||
v-model:value="formData.sourceId"
|
||||
:options="assingWork"
|
||||
placeholder="请选择业务来源"
|
||||
clearable
|
||||
:disabled="assingWorkDisabled"
|
||||
style="width: 200px"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
<n-grid x-gap="12" :cols="2">
|
||||
<n-gi>
|
||||
<n-form-item label="报检总数" path="totalQty">
|
||||
<n-input-number v-model:value="formData.totalQty" placeholder="请输入报检总数" :min="1" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="质检状态" >
|
||||
<n-select v-model:value="formData.status" placeholder="请选择状态:0待检/1检验中/2已判定/3已关闭" :options="qcStatusOptions" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
<n-form-item label="追溯类型" path="traceType">
|
||||
<n-select
|
||||
v-model:value="formData.traceType"
|
||||
:options="qcTraceTypeOptions"
|
||||
placeholder="请选择追溯类型:0无/1批次/2SN"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</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-modal v-model:show="detailVisible" preset="card" :title="detailTitle" style="width: 800px">
|
||||
<n-card title="主表信息" hoverable style="margin-bottom: 12px" >
|
||||
<n-descriptions :column="2" bordered>
|
||||
<n-descriptions-item
|
||||
v-for="item in mappedInfoList"
|
||||
:key="item.key"
|
||||
:label="item.label"
|
||||
>
|
||||
{{ formatDisplayValue(item.key, item.value) }}
|
||||
</n-descriptions-item>
|
||||
</n-descriptions>
|
||||
</n-card>
|
||||
<n-card title="明细列表" hoverable style="margin-bottom: 12px">
|
||||
<n-data-table
|
||||
:columns="detailColumns"
|
||||
:data="detailTableData"
|
||||
:loading="loading"
|
||||
:row-key="(row) => row.id"
|
||||
:scroll-x="1200"
|
||||
/>
|
||||
</n-card>
|
||||
<!-- <n-card title="追溯码" hoverable>-->
|
||||
<!-- 追溯码:{{}}-->
|
||||
<!-- </n-card>-->
|
||||
</n-modal>
|
||||
|
||||
<!--提交判定明细面板-->
|
||||
<n-modal v-model:show="submitDetailModalVisible" preset="card" title="提交判定明细" style="width: 800px">
|
||||
<n-collapse default-expanded-names="['ok', 'scrap', 'rework','concession']">
|
||||
<n-collapse-item title="合格" name="ok">
|
||||
<n-form ref="formRef" :model="formDetailOKData" :rules="formRules" label-placement="left" label-width="100px">
|
||||
<n-grid x-gap="12" :cols="2">
|
||||
<n-gi>
|
||||
<n-form-item label="判定数量" path="qty">
|
||||
<n-input-number v-model:value="formDetailOKData.qty" placeholder="请输入判定数量" :min="0" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="批次号或SN码" path="traceCode" v-show="traceCodeShow">
|
||||
<n-input v-model:value="formDetailOKData.traceCode" placeholder="请输入批次号或SN码(启用追溯时必填)" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
<n-form-item label="备注" >
|
||||
<n-input
|
||||
v-model:value="formDetailOKData.remark"
|
||||
type="textarea"
|
||||
placeholder="输入备注原因"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-collapse-item>
|
||||
<n-collapse-item title="报废" name="scrap">
|
||||
<n-form ref="formRef" :model="formDetailScrapData" :rules="formRules" label-placement="left" label-width="100px">
|
||||
|
||||
<n-grid x-gap="12" :cols="2">
|
||||
<n-gi>
|
||||
<n-form-item label="判定数量" path="qty">
|
||||
<n-input-number v-model:value="formDetailScrapData.qty" placeholder="请输入判定数量" :min="0" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="批次号或SN码" path="traceCode" v-show="traceCodeShow">
|
||||
<n-input v-model:value="formDetailScrapData.traceCode" placeholder="请输入批次号或SN码(启用追溯时必填)" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
<n-form-item label="备注" >
|
||||
<n-input
|
||||
v-model:value="formDetailScrapData.remark"
|
||||
type="textarea"
|
||||
placeholder="输入备注原因"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-collapse-item>
|
||||
<n-collapse-item title="返工" name="rework">
|
||||
<n-form ref="formRef" :model="formDetailReworkData" :rules="formRules" label-placement="left" label-width="100px">
|
||||
<n-grid x-gap="12" :cols="2">
|
||||
<n-gi>
|
||||
<n-form-item label="判定数量" path="qty">
|
||||
<n-input-number v-model:value="formDetailReworkData.qty" placeholder="请输入判定数量" :min="0" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="批次号或SN码" path="traceCode" v-show="traceCodeShow">
|
||||
<n-input v-model:value="formDetailReworkData.traceCode" placeholder="请输入批次号或SN码(启用追溯时必填)" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
<n-form-item label="备注" >
|
||||
<n-input
|
||||
v-model:value="formDetailReworkData.remark"
|
||||
type="textarea"
|
||||
placeholder="输入备注原因"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-collapse-item>
|
||||
<n-collapse-item title="让步接收" name="concession">
|
||||
<n-form ref="formRef" :model="formDetailConcessionData" :rules="formRules" label-placement="left" label-width="100px">
|
||||
<n-grid x-gap="12" :cols="2">
|
||||
<n-gi>
|
||||
<n-form-item label="判定数量" path="qty">
|
||||
<n-input-number v-model:value="formDetailConcessionData.qty" placeholder="请输入判定数量" :min="0" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="批次号或SN码" path="traceCode" v-show="traceCodeShow">
|
||||
<n-input v-model:value="formDetailConcessionData.traceCode" placeholder="请输入批次号或SN码(启用追溯时必填)" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
<n-form-item label="备注" >
|
||||
<n-input
|
||||
v-model:value="formDetailConcessionData.remark"
|
||||
type="textarea"
|
||||
placeholder="输入备注原因"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-collapse-item>
|
||||
</n-collapse>
|
||||
<template #footer>
|
||||
<n-space justify="end">
|
||||
<n-button @click="submitDetailModalVisible = false">取消</n-button>
|
||||
<n-button type="primary" @click="handleSubmitResultDetail">确定</n-button>
|
||||
</n-space>
|
||||
</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,
|
||||
NDropdown
|
||||
} from 'naive-ui'
|
||||
import {
|
||||
SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline,
|
||||
EllipsisHorizontalOutline
|
||||
} from '@vicons/ionicons5'
|
||||
import { qualityTestingApi, type QualityTesting } from '@/api/qualityTesting'
|
||||
import {assingReworkApi} from '@/api/assingRework'
|
||||
import { dictDataApi } from '@/api/org'
|
||||
|
||||
import {Language} from "@xterm/xterm/src/vs/base/common/platform.ts";
|
||||
|
||||
import value = Language.value;
|
||||
import {QcResultDetail} from "@/api/qcResultDetail.ts";
|
||||
import router from "@/router";
|
||||
|
||||
const message = useMessage()
|
||||
const dialog = useDialog()
|
||||
|
||||
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<QualityTesting[]>([])
|
||||
const loading = ref(false)
|
||||
const selectedIds = ref<number[]>([])
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50]
|
||||
})
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
qcNo: null as number | null,
|
||||
status: null as number | null,
|
||||
})
|
||||
|
||||
// 弹窗
|
||||
const modalVisible = ref(false)
|
||||
const modalTitle = ref('')
|
||||
const importModalVisible = ref(false)
|
||||
//质检单详情
|
||||
const detailVisible = ref(false)
|
||||
const detailTitle = ref('')
|
||||
|
||||
//提交判定明细
|
||||
const submitDetailModalVisible = ref(false)
|
||||
const traceCodeShow = ref(false)
|
||||
|
||||
|
||||
const infoDataMapping = {
|
||||
id: '质检单编号',
|
||||
qcNo: '质检单编号',
|
||||
sourceType: '来源类型',
|
||||
sourceId: '来源编号',
|
||||
orderId: '订单编号',
|
||||
processId: '工序编号',
|
||||
itemId: '物料编号',
|
||||
totalQty: '报检总数',
|
||||
status: '质检状态',
|
||||
inspectorId: '质检员编号',
|
||||
inspectTime: '质检时间',
|
||||
traceType: '追溯类型',
|
||||
}
|
||||
const infoDataMap = new Map(Object.entries(infoDataMapping))
|
||||
const mappedInfoList = ref<Array<{ label: string; key: string; value: any }>>([])
|
||||
//详情列表名
|
||||
const detailColumns: DataTableColumns<Object> = [
|
||||
{
|
||||
title: '判定类型',
|
||||
key: 'resultType',
|
||||
width: 80,
|
||||
render: (row) => {
|
||||
const val = row.resultType
|
||||
const opt = qcResultTypeOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '判定数量',
|
||||
key: 'qty',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '批次号',
|
||||
key: 'traceCode',
|
||||
width: 80,
|
||||
render: (row) => {
|
||||
const val = row.traceCode
|
||||
return val ?? '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '不良代码',
|
||||
key: 'defectCode',
|
||||
width: 80,
|
||||
render: (row) => {
|
||||
const val = row.defectCode
|
||||
return val ?? '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '后续动作',
|
||||
key: 'handleAction',
|
||||
width: 80,
|
||||
|
||||
},
|
||||
{
|
||||
title: '动作执行状态',
|
||||
key: 'actionStatus',
|
||||
width: 80,
|
||||
render: (row) => {
|
||||
const val = row.actionStatus
|
||||
const opt = qcActionStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const detailTableData = ref<Object[]>([])
|
||||
|
||||
|
||||
const formRef = ref()
|
||||
const defaultFormData: QualityTesting = {
|
||||
qcNo: '',
|
||||
sourceType: undefined,
|
||||
sourceId: undefined,
|
||||
orderId: undefined,
|
||||
processId: undefined,
|
||||
itemId: undefined,
|
||||
totalQty: undefined,
|
||||
status: undefined,
|
||||
inspectorId: undefined,
|
||||
inspectTime: undefined,
|
||||
traceType: undefined,
|
||||
}
|
||||
const formData = reactive<QualityTesting>({ ...defaultFormData })
|
||||
|
||||
const defaultFormDetailData:QcResultDetail = {
|
||||
qcId: undefined,
|
||||
resultType: undefined,
|
||||
qty: 0,
|
||||
traceCode: undefined,
|
||||
defectCode: undefined,
|
||||
handleAction: undefined,
|
||||
actionStatus: undefined
|
||||
}
|
||||
const formDetailOKData = reactive<QcResultDetail>({ ...defaultFormDetailData, resultType: 1,handleAction:'下一道工序',actionStatus:1 })
|
||||
const formDetailScrapData = reactive<QcResultDetail>({ ...defaultFormDetailData,resultType: 2,handleAction:'报废次品',actionStatus:1 })
|
||||
const formDetailReworkData = reactive<QcResultDetail>({ ...defaultFormDetailData,resultType: 3,handleAction:'返工',actionStatus:1 })
|
||||
const formDetailConcessionData = reactive<QcResultDetail>({ ...defaultFormDetailData,resultType: 4,handleAction:'让步接收',actionStatus:1 })
|
||||
|
||||
const assingWorkDisabled = ref(true)
|
||||
|
||||
const assingWork = ref<{ label: string; value: any }[]>([])
|
||||
|
||||
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||
const statusOptions = ref<{ label: string; value: any }[]>([])
|
||||
//质检状态字典
|
||||
const qcStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||
//业务来源字典
|
||||
const qcSourceTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
//追溯状态字段
|
||||
const qcTraceTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
//判定类型
|
||||
const qcResultTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
//动作执行状态
|
||||
const qcActionStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||
// 表单校验规则
|
||||
const formRules = {
|
||||
sourceType: [{ required: true, type: 'number', message: '请选择来源类型:1工序汇报/2委外/3手工', trigger: 'change' }],
|
||||
totalQty: [{ required: true,type: 'number', message: '请输入报检总数', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
// 表格列
|
||||
const columns: DataTableColumns<QualityTesting> = [
|
||||
{ type: 'selection' },
|
||||
{ title: '质检编号', key: 'qcNo' },
|
||||
{ title: '来源类型', key: 'sourceType',
|
||||
render(row) {
|
||||
const val = row.sourceType
|
||||
const opt = qcSourceTypeOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
// { title: '来源业务ID(汇报单/派工单等)', key: 'sourceId' },
|
||||
// { title: '关联生产订单ID', key: 'orderId' },
|
||||
// { title: '关联工序计划ID', key: 'processId' },
|
||||
// { title: '物料ID', key: 'itemId' },
|
||||
{ title: '报检总数', key: 'totalQty' },
|
||||
{ title: '质检状态', key: 'status',
|
||||
render(row) {
|
||||
const val = row.status
|
||||
const opt = qcStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '检验员', key: 'inspector' },
|
||||
{ title: '检验完成时间', key: 'inspectTime' },
|
||||
{ title: '追溯类型', key: 'traceType',
|
||||
render(row) {
|
||||
const val = row.traceType
|
||||
const opt = qcTraceTypeOptions.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) }), ' 删除']
|
||||
}),
|
||||
h(NDropdown, {
|
||||
trigger: 'click', // 点击展开
|
||||
options: [
|
||||
{ label: '查看详情', key: 'view' },
|
||||
{ type: 'divider' }, // 分割线
|
||||
{ label: '提交判定明细', key: 'submitResultDetail' },
|
||||
{ type: 'divider' }, // 分割线
|
||||
{ label: '查询判定明细', key: 'queryResultDetail' },
|
||||
{ type: 'divider' }, // 分割线
|
||||
{ label: '质检撤回', key: 'cancelQuality' },
|
||||
],
|
||||
// 下拉菜单项点击事件
|
||||
onSelect: (key: string) => {
|
||||
switch (key) {
|
||||
case 'view':
|
||||
handleDetail(row)
|
||||
break
|
||||
case 'submitResultDetail':
|
||||
submitResultDetail(row)
|
||||
break
|
||||
case 'queryResultDetail':
|
||||
queryResultDetail(row)
|
||||
break
|
||||
case 'cancelQuality':
|
||||
handleCancelQuality(row)
|
||||
break
|
||||
}
|
||||
}
|
||||
}, {
|
||||
// 下拉触发按钮:三点图标 / 更多文字
|
||||
default: () => h(NButton, { size: 'small', quaternary: true }, {
|
||||
default: () => [h(NIcon, null, { default: () => h(EllipsisHorizontalOutline) })]
|
||||
})
|
||||
})
|
||||
])
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
// 加载数据
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await qualityTestingApi.page({
|
||||
page:pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
qcNo:searchForm.qcNo,
|
||||
status: searchForm.status
|
||||
})
|
||||
tableData.value = res.list
|
||||
pagination.itemCount = res.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
searchForm.id = null
|
||||
searchForm.status = null
|
||||
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 分页
|
||||
function handlePageChange(page: number) {
|
||||
pagination.page = page
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handlePageSizeChange(pageSize: number) {
|
||||
pagination.pageSize = pageSize
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 选择
|
||||
function handleCheck(keys: Array<string | number>) {
|
||||
selectedIds.value = keys as number[]
|
||||
}
|
||||
|
||||
// 新增
|
||||
function handleAdd() {
|
||||
modalTitle.value = '新增质检单表'
|
||||
assingWorkDisabled.value = false
|
||||
Object.assign(formData, defaultFormData)
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
// 编辑
|
||||
function handleEdit(row: QualityTesting) {
|
||||
modalTitle.value = '编辑质检单表'
|
||||
assingWorkDisabled.value = true
|
||||
Object.assign(formData, row)
|
||||
if (formData.inspectTime && typeof formData.inspectTime === 'string') {
|
||||
formData.inspectTime = new Date(formData.inspectTime.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 QualityTesting
|
||||
if (typeof submitData.inspectTime === 'number') {
|
||||
submitData.inspectTime = new Date(submitData.inspectTime).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.id) {
|
||||
await qualityTestingApi.update(submitData)
|
||||
message.success('修改成功')
|
||||
} else {
|
||||
await qualityTestingApi.create(submitData)
|
||||
message.success('新增成功')
|
||||
}
|
||||
modalVisible.value = false
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
function handleDelete(row: QualityTesting) {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: '确定要删除该记录吗?',
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await qualityTestingApi.delete([row.id!])
|
||||
message.success('删除成功')
|
||||
loadData()
|
||||
} catch (error) {
|
||||
// 错误已在拦截器处理
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
function handleBatchDelete() {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await qualityTestingApi.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.status != null) params.status = searchForm.status
|
||||
const blob = await qualityTestingApi.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 qualityTestingApi.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 qualityTestingApi.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')
|
||||
statusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_status')
|
||||
qcStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('source_type')
|
||||
qcSourceTypeOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_trace_type')
|
||||
qcTraceTypeOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_result_type')
|
||||
qcResultTypeOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_action_status')
|
||||
qcActionStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
}
|
||||
|
||||
//查看质检单详情
|
||||
async function handleDetail(row: QualityTesting) {
|
||||
detailTitle.value = '查看质检单详情'
|
||||
detailVisible.value = true
|
||||
const data = await qualityTestingApi.detail(row.id!)
|
||||
|
||||
// 映射后的数据
|
||||
mappedInfoList.value = Object.entries(data.info)
|
||||
.filter(([key]) => infoDataMap.has(key)) // 只保留配置里有的字段
|
||||
.map(([key, value]) => ({
|
||||
label: infoDataMap.get(key) || key, // 中文标签
|
||||
key, // 原字段名
|
||||
value // 原始值
|
||||
}))
|
||||
|
||||
detailTableData.value = data.detail
|
||||
}
|
||||
|
||||
function formatDisplayValue(key: string, value: any): string {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
// 根据字段类型格式化
|
||||
switch (key) {
|
||||
case 'sourceType': {
|
||||
const sourceOpt = qcSourceTypeOptions.value.find(o => o.value === value || String(o.value) === String(value))
|
||||
return sourceOpt ? sourceOpt.label : String(value)
|
||||
}
|
||||
case 'status': {
|
||||
const statusOpt = qcStatusOptions.value.find(o => o.value === value || String(o.value) === String(value))
|
||||
return statusOpt ? statusOpt.label : String(value)
|
||||
}
|
||||
case 'traceType': {
|
||||
const traceOpt = qcTraceTypeOptions.value.find(o => o.value === value || String(o.value) === String(value))
|
||||
return traceOpt ? traceOpt.label : String(value)
|
||||
}
|
||||
case 'inspectTime':
|
||||
case 'createTime':
|
||||
case 'updateTime':
|
||||
return value ? new Date(value).toLocaleString('zh-CN') : '-'
|
||||
default:
|
||||
return String(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//加载派工单
|
||||
async function loadAssignWorkOrder() {
|
||||
const data = await assingReworkApi.allList()
|
||||
console.log(data)
|
||||
assingWork.value = data.map(d => ({ label: d.assingCode, value: (Number(d.id) || d.id) }))
|
||||
console.log(assingWork)
|
||||
}
|
||||
|
||||
//提交判定明细
|
||||
async function submitResultDetail(row) {
|
||||
Object.assign(formDetailOKData, reactive<QcResultDetail>({ ...defaultFormDetailData, resultType: 1,handleAction:'下一道工序',actionStatus:1 }))
|
||||
Object.assign(formDetailScrapData, reactive<QcResultDetail>({ ...defaultFormDetailData,resultType: 2,handleAction:'报废次品',actionStatus:1 }))
|
||||
Object.assign(formDetailReworkData, reactive<QcResultDetail>({ ...defaultFormDetailData,resultType: 3,handleAction:'返工',actionStatus:1 }))
|
||||
Object.assign(formDetailConcessionData, reactive<QcResultDetail>({ ...defaultFormDetailData,resultType: 4,handleAction:'让步接收',actionStatus:1 }))
|
||||
if (row.traceType != 1) {
|
||||
traceCodeShow.value = true
|
||||
}
|
||||
submitDetailModalVisible.value = true
|
||||
formDetailOKData.qcId = row.id
|
||||
formDetailScrapData.qcId = row.id
|
||||
formDetailReworkData.qcId = row.id
|
||||
formDetailConcessionData.qcId = row.id
|
||||
}
|
||||
|
||||
async function handleSubmitResultDetail() {
|
||||
try {
|
||||
const submitParam = [formDetailOKData,formDetailScrapData,formDetailReworkData,formDetailConcessionData]
|
||||
await qualityTestingApi.submit(submitParam)
|
||||
message.success('提交成功')
|
||||
}catch ( error) {
|
||||
message.error('提交失败'+error)
|
||||
}
|
||||
submitDetailModalVisible.value = false
|
||||
loadData()
|
||||
}
|
||||
|
||||
|
||||
//查询判定明细
|
||||
function queryResultDetail(row) {
|
||||
let path = `detail/${row.id}`;
|
||||
router.push(path)
|
||||
}
|
||||
|
||||
//质检撤回
|
||||
function handleCancelQuality(row) {
|
||||
dialog.warning({
|
||||
title: '提示',
|
||||
content: '确定要撤回ID:'+row.id+'质检记录吗?',
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await qualityTestingApi.cancel(row.id)
|
||||
message.success('撤回成功')
|
||||
loadData()
|
||||
} catch (error) {
|
||||
console.log("撤回失败"+error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
loadDictOptions()
|
||||
loadAssignWorkOrder()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
@ -4,8 +4,14 @@
|
||||
<!-- 搜索表单 -->
|
||||
<div class="search-form">
|
||||
<n-form inline :model="searchForm" label-placement="left">
|
||||
<n-form-item label="主键id;主键id">
|
||||
<n-input v-model:value="searchForm.id" placeholder="请输入主键id;主键id" clearable />
|
||||
<n-form-item label="派工状态">
|
||||
<n-select
|
||||
v-model:value="searchForm.assingStatus"
|
||||
:options="qcAssingStatusOptions"
|
||||
placeholder="请选择派工状态"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item>
|
||||
<n-space>
|
||||
@ -25,11 +31,11 @@
|
||||
<!-- 工具栏 -->
|
||||
<div class="table-toolbar">
|
||||
<n-space>
|
||||
<n-button type="primary" @click="handleAdd">
|
||||
<template #icon><n-icon><AddOutline /></n-icon></template>
|
||||
新增
|
||||
<n-button type="primary" @click="handleStatistics">
|
||||
<template #icon></template>
|
||||
汇报统计
|
||||
</n-button>
|
||||
<n-button @click="importModalVisible = true">
|
||||
<!-- <n-button @click="importModalVisible = true">
|
||||
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
|
||||
导入
|
||||
</n-button>
|
||||
@ -40,7 +46,7 @@
|
||||
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
|
||||
<template #icon><n-icon><TrashOutline /></n-icon></template>
|
||||
删除
|
||||
</n-button>
|
||||
</n-button> -->
|
||||
</n-space>
|
||||
</div>
|
||||
|
||||
@ -49,13 +55,28 @@
|
||||
: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"
|
||||
size="small"
|
||||
remote
|
||||
:border="false"
|
||||
:single-line="false"
|
||||
striped
|
||||
/>
|
||||
<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"
|
||||
>
|
||||
<template #prefix>
|
||||
共 {{ pagination.itemCount }} 条
|
||||
</template>
|
||||
</n-pagination>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
<!-- 新增/编辑弹窗 -->
|
||||
@ -109,22 +130,71 @@
|
||||
<n-button @click="importModalVisible = false">关闭</n-button>
|
||||
</template>
|
||||
</n-modal>
|
||||
|
||||
<!--汇报详情面板 -->
|
||||
<n-modal v-model:show="reportDetailVisible" preset="card" title="汇报详情" style="width: 1000px">
|
||||
<n-card title="质检信息" hoverable style="margin-bottom: 12px" >
|
||||
<div v-if="qualityTestings.length === 0" style="height:520px;display:flex;align-items:center;justify-content:center;color:#999">
|
||||
暂无质检单据数据
|
||||
</div>
|
||||
<n-tabs
|
||||
type="line"
|
||||
animated
|
||||
placement="left"
|
||||
style="height: 520px"
|
||||
v-else
|
||||
>
|
||||
<n-tab-pane
|
||||
v-for="item in qualityTestings"
|
||||
:name="item.qcNo"
|
||||
:tab="item.qcNo">
|
||||
<n-card title="质检基础信息" style="margin-bottom:12px">
|
||||
<n-descriptions :column="3">
|
||||
<n-descriptions-item label="资源类型">{{formatDisplayValue("resourceType",item.resourceType) }}</n-descriptions-item>
|
||||
<n-descriptions-item label="质检状态">{{formatDisplayValue("status",item.qcStatus) }}</n-descriptions-item>
|
||||
<n-descriptions-item label="总数量">{{ item.totalQty }}</n-descriptions-item>
|
||||
</n-descriptions>
|
||||
</n-card>
|
||||
|
||||
<!--汇报表格-->
|
||||
<n-card title="汇报列表">
|
||||
<n-data-table
|
||||
:columns="submitColumns"
|
||||
:data="item.submitLogs"
|
||||
:scroll-x="700"
|
||||
max-height="320"
|
||||
:pagination="{ pageSize:3 }"
|
||||
>
|
||||
<!--空数据提示插槽-->
|
||||
<template #empty>
|
||||
<div style="padding:40px;text-align:center;color:#999">
|
||||
当前没有数据
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</n-data-table>
|
||||
|
||||
</n-card>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
</n-card>
|
||||
</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 { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline, Options } from '@vicons/ionicons5'
|
||||
import { submitLogApi, type SubmitLog } from '@/api/submitLog'
|
||||
import { dictDataApi } from '@/api/org'
|
||||
import router from '@/router'
|
||||
|
||||
|
||||
const message = useMessage()
|
||||
const dialog = useDialog()
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
id: null as number | null,
|
||||
})
|
||||
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<SubmitLog[]>([])
|
||||
@ -135,7 +205,12 @@ const pagination = reactive({
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50]
|
||||
pageSizes: [10, 20, 50,100]
|
||||
})
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
page:pagination.page as number,
|
||||
})
|
||||
|
||||
// 弹窗
|
||||
@ -149,9 +224,18 @@ const defaultFormData: SubmitLog = {
|
||||
quantity: undefined,
|
||||
}
|
||||
const formData = reactive<SubmitLog>({ ...defaultFormData })
|
||||
//汇报详情弹窗
|
||||
const reportDetailVisible = ref(false)
|
||||
|
||||
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||
|
||||
//判定状态字典
|
||||
const qcResultTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
//业务来源字典
|
||||
const qcSourceTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
//质检状态字典
|
||||
const qcStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||
//派工状态字典
|
||||
const qcAssingStatusOptions = ref<{ label: string; value: any }[]>([])
|
||||
// 表单校验规则
|
||||
const formRules = {
|
||||
}
|
||||
@ -159,12 +243,18 @@ const formRules = {
|
||||
// 表格列
|
||||
const columns: DataTableColumns<SubmitLog> = [
|
||||
{ type: 'selection' },
|
||||
{ title: '主键id;主键id', key: 'id' },
|
||||
{ title: '派工id;派工id', key: 'assingWorkId' },
|
||||
{ title: '工序id;工序id', key: 'processId' },
|
||||
{ title: '提交数量;提交数量', key: 'quantity' },
|
||||
{ title: '提交时间', key: 'createTime', width: 180 },
|
||||
{ title: '提交人;提交人', key: 'createBy' },
|
||||
{ title: '工序名称', key: 'processName' },
|
||||
{ title: '工序编号', key: 'processCode' },
|
||||
{ title: '派工编号', key: 'assingCode' },
|
||||
{ title: '派工人', key: 'userName' },
|
||||
{ title: '派工状态', key: 'assingStatus',
|
||||
render: (row) => {
|
||||
const val = row.assingStatus
|
||||
const opt = qcAssingStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
},
|
||||
{ title: '派工完成时间', key: 'completedTime'},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'actions',
|
||||
@ -172,17 +262,34 @@ const columns: DataTableColumns<SubmitLog> = [
|
||||
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, onClick: () => handleViewReport(row) }, {
|
||||
default: () => [h(NIcon, null, { default: () => h(null) }), ' 汇报信息']
|
||||
}),
|
||||
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: () => 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) }), ' 删除']
|
||||
// })
|
||||
])
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
//汇报详情属性
|
||||
const qualityTestings = ref()
|
||||
const submitColumns = ref([
|
||||
{ title: "提交人", key: "sumbitUser" },
|
||||
{ title: "提交时间", key: "submitCreateTime" },
|
||||
{ title: "提交数量", key: "quantity" },
|
||||
{ title: "单据状态", key: "submitStatus",
|
||||
render: (row) => {
|
||||
const val = row.submitStatus
|
||||
const opt = qcResultTypeOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||
return opt ? opt.label : (val ?? '-')
|
||||
}
|
||||
}
|
||||
])
|
||||
// 加载数据
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
@ -190,10 +297,12 @@ async function loadData() {
|
||||
const res = await submitLogApi.page({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
id: searchForm.id || undefined,
|
||||
assingStatus: searchForm.assingStatus
|
||||
})
|
||||
tableData.value = res.list
|
||||
pagination.itemCount = res.total
|
||||
console.log(pagination.itemCount);
|
||||
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@ -201,13 +310,13 @@ async function loadData() {
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
searchForm.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
searchForm.id = null
|
||||
searchForm.assingStatus = null
|
||||
|
||||
handleSearch()
|
||||
}
|
||||
@ -312,7 +421,7 @@ 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.assingStatus != null) params.id = searchForm.assingStatus
|
||||
const blob = await submitLogApi.export(params)
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
@ -363,6 +472,59 @@ async function handleImportUpload({ file }: UploadCustomRequestOptions) {
|
||||
|
||||
// 加载字典选项
|
||||
async function loadDictOptions() {
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_result_type')
|
||||
qcResultTypeOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('source_type')
|
||||
qcSourceTypeOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('qc_status')
|
||||
qcStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
try {
|
||||
const data = await dictDataApi.listByType('assing_status')
|
||||
qcAssingStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch {}
|
||||
}
|
||||
|
||||
//查看汇报信息
|
||||
|
||||
function handleViewReport(row) {
|
||||
reportDetailVisible.value = true
|
||||
|
||||
qualityTestings.value = row.qualityTestings
|
||||
|
||||
}
|
||||
|
||||
|
||||
function formatDisplayValue(key:string,value: any){
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
//根据字段类型格式化
|
||||
switch(key) {
|
||||
case 'resourceType': {
|
||||
const sourceOpt = qcSourceTypeOptions.value.find(o => o.value === value || String(o.value) === String(value))
|
||||
return sourceOpt ? sourceOpt.label : String(value)
|
||||
}
|
||||
case 'status': {
|
||||
const statusOpt = qcStatusOptions.value.find(o => o.value === value || String(o.value) === String(value))
|
||||
return statusOpt ? statusOpt.label : String(value)
|
||||
}
|
||||
|
||||
case 'qcNo':
|
||||
return value ? new Date(value).toLocaleString('zh-CN') : '-'
|
||||
default:
|
||||
return String(value)
|
||||
}
|
||||
}
|
||||
|
||||
//汇报统计
|
||||
function handleStatistics() {
|
||||
let path = 'statistic'
|
||||
router.push(path)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
202
src/views/biz/submitLog/statistics.vue
Normal file
202
src/views/biz/submitLog/statistics.vue
Normal file
@ -0,0 +1,202 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<n-card class="page-layout">
|
||||
<!-- 搜索表单 -->
|
||||
<div class="search-form">
|
||||
<n-form inline :model="searchForm" label-placement="left">
|
||||
<n-form-item label="统计方式">
|
||||
<n-select
|
||||
v-model:value="searchForm.type"
|
||||
:options="statisticTypeOptions"
|
||||
placeholder="请选择统计方式"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="统计时间">
|
||||
<n-date-picker
|
||||
v-model:formatted-value="searchForm.timestamp"
|
||||
format="yyyy-MM-dd"
|
||||
type="date"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</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="stats-section">
|
||||
<div class="stats-cards">
|
||||
<n-card class="stat-card" size="small" :bordered="false" content-style="background: transparent">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">提交总数</span>
|
||||
<span class="stat-value">{{ stats.totalQty }}</span>
|
||||
</div>
|
||||
</n-card>
|
||||
<n-card class="stat-card success" size="small" :bordered="false" content-style="background: transparent">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">合格</span>
|
||||
<span class="stat-value">{{ stats.successQty }}</span>
|
||||
</div>
|
||||
</n-card>
|
||||
<n-card class="stat-card fail" size="small" :bordered="false" content-style="background: transparent">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">报废</span>
|
||||
<span class="stat-value">{{ stats.scrapQty }}</span>
|
||||
</div>
|
||||
</n-card>
|
||||
</div>
|
||||
<n-grid :cols="1" :x-gap="24" class="stats-charts">
|
||||
<n-gi>
|
||||
<n-card title="汇报统计图" size="small" :bordered="false" content-style="background: transparent">
|
||||
<div ref="statisticChartRef" class="chart-box"></div>
|
||||
</n-card>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
</div>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, h, onMounted } from 'vue'
|
||||
import { dictDataApi } from '@/api/org'
|
||||
import { submitLogApi } from '@/api/submitLog'
|
||||
|
||||
//字典数据
|
||||
const statisticTypeOptions = ref<{ label: string; value: any }[]>([])
|
||||
|
||||
//统计属性
|
||||
const searchForm =reactive({
|
||||
type: null as string,
|
||||
timestamp: null as string
|
||||
})
|
||||
|
||||
const stats = reactive({
|
||||
totalQty:0,
|
||||
successQty:0,
|
||||
scrapQty:0,
|
||||
outputRate:0,
|
||||
scrapRate:0,
|
||||
})
|
||||
|
||||
const statisticChartRef = ref<HTMLElement | null>(null)
|
||||
|
||||
let statisticChart: any = null
|
||||
|
||||
function handleSearch() {
|
||||
loadStatistics()
|
||||
}
|
||||
|
||||
function handleReset(){
|
||||
searchForm.type = null
|
||||
searchForm.timestamp = null
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
async function loadStatistics() {
|
||||
try{
|
||||
const res = await submitLogApi.statistics({
|
||||
type: searchForm.type,
|
||||
time: searchForm.timestamp
|
||||
})
|
||||
|
||||
Object.assign(stats,res)
|
||||
|
||||
updateCharts()
|
||||
}catch{}
|
||||
}
|
||||
|
||||
|
||||
function updateCharts(){
|
||||
import('echarts').then((echarts)=>{
|
||||
if(statisticChartRef.value) {
|
||||
if (!statisticChart) statisticChart = echarts.init(statisticChartRef.value)
|
||||
|
||||
const data = [{name:"产出率",value:stats.outputRate},{name:"报废率",value:stats.scrapRate}]
|
||||
statisticChart.setOption({
|
||||
tooltip: { trigger: 'item' },
|
||||
series: [{ type: 'pie', radius: '60%', data }]
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//加载字典选项
|
||||
async function loadDictOptions() {
|
||||
|
||||
try{
|
||||
const data = await dictDataApi.listByType('statistic_type')
|
||||
statisticTypeOptions.value = data.map(d=>({label:d.dictLabel,value: (Number(d.dictValue) || d.dictValue) }))
|
||||
}catch{}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
onMounted(()=>{
|
||||
loadStatistics()
|
||||
loadDictOptions()
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.page-layout {
|
||||
.stats-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stats-cards {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.stat-card {
|
||||
flex: 1;
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
.stat-value {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
}
|
||||
}
|
||||
&.success .stat-value { color: #18a058; }
|
||||
&.fail .stat-value { color: #d03050; }
|
||||
}
|
||||
.stats-charts {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.chart-box {
|
||||
height: 260px;
|
||||
text-align: center;
|
||||
}
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user