feat:添加工单管理页面
parent
adcc386002
commit
3e34a93625
@ -0,0 +1,51 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
export interface TicketManagementVO {
|
||||||
|
id?: number
|
||||||
|
subjectId?: string
|
||||||
|
planId?: string
|
||||||
|
planNo?: string
|
||||||
|
deviceName?: string
|
||||||
|
planType?: string | number
|
||||||
|
configName?: string
|
||||||
|
jobStatus?: string | number
|
||||||
|
jobResult?: string
|
||||||
|
jobUser?: string
|
||||||
|
taskTime?: string
|
||||||
|
taskEndTime?: string
|
||||||
|
remark?: string
|
||||||
|
creator?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TicketResultVO {
|
||||||
|
id?: number
|
||||||
|
inspectionItemName?: string
|
||||||
|
inspectionMethod?: string
|
||||||
|
judgmentCriteria?: string
|
||||||
|
inspectionResult?: string | number
|
||||||
|
images?: string
|
||||||
|
remark?: string
|
||||||
|
inspectionTime?: string
|
||||||
|
inspector?: string
|
||||||
|
managementId?: string | number
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TicketManagementApi = {
|
||||||
|
getTicketManagementPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/mes/ticket-management/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
batchUpdateTicketStatus: async (params: { ids: string; jobStatus: string | number }) => {
|
||||||
|
return await request.put({ url: `/mes/ticket-management/batchUpdateStatus`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
getTicketResultsPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/mes/ticket-results/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
batchUpdateTicketResults: async (data: TicketResultVO[]) => {
|
||||||
|
return await request.put({ url: `/mes/ticket-results/batchUpdate`, data })
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,169 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog v-model="dialogVisible" :title="dialogTitle" width="1100px">
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
:row-key="getRowKey"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" label="序号" align="center" width="70" />
|
||||||
|
<el-table-column label="检验项名称" align="center" prop="inspectionItemName" min-width="180" />
|
||||||
|
<el-table-column label="检验方式" align="center" prop="inspectionMethod" min-width="140" />
|
||||||
|
<el-table-column label="判定基准" align="center" prop="judgmentCriteria" min-width="160" />
|
||||||
|
<el-table-column label="检验结果" align="center" prop="inspectionResult" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag v-if="String(scope.row.inspectionResult) === '0'" type="info">待检测</el-tag>
|
||||||
|
<el-tag v-else-if="String(scope.row.inspectionResult) === '1'" type="success">通过</el-tag>
|
||||||
|
<el-tag v-else-if="String(scope.row.inspectionResult) === '2'" type="danger">不通过</el-tag>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="图片" align="center" prop="images" width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-image
|
||||||
|
v-if="scope.row.images"
|
||||||
|
:src="parseFirstImage(scope.row.images)"
|
||||||
|
:preview-src-list="parseImages(scope.row.images)"
|
||||||
|
preview-teleported
|
||||||
|
fit="cover"
|
||||||
|
style="width: 64px; height: 64px"
|
||||||
|
/>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" min-width="160" />
|
||||||
|
<el-table-column label="操作" align="center" width="200" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-radio-group
|
||||||
|
v-if="String(scope.row.inspectionResult) === '0'"
|
||||||
|
v-model="decisionMap[String(scope.row.id)]"
|
||||||
|
>
|
||||||
|
<el-radio :label="'1'">通过</el-radio>
|
||||||
|
<el-radio :label="'2'">不通过</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
v-model:current-page="queryParams.pageNo"
|
||||||
|
v-model:page-size="queryParams.pageSize"
|
||||||
|
:background="true"
|
||||||
|
:page-sizes="[10, 20, 30, 50, 100]"
|
||||||
|
:pager-count="7"
|
||||||
|
:total="total"
|
||||||
|
class="mt-15px mb-15px flex justify-end"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="handleSave" :loading="submitLoading">保 存</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { TicketManagementApi, TicketResultVO } from '@/api/mes/ticketManagement'
|
||||||
|
|
||||||
|
defineOptions({ name: 'TicketResultDialog' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('检验结果')
|
||||||
|
const loading = ref(false)
|
||||||
|
const submitLoading = ref(false)
|
||||||
|
|
||||||
|
const list = ref<TicketResultVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const managementId = ref<number | undefined>(undefined)
|
||||||
|
const decisionMap = reactive<Record<string, '1' | '2' | undefined>>({})
|
||||||
|
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10
|
||||||
|
})
|
||||||
|
|
||||||
|
const open = async (options: { managementId: number; title?: string }) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = options.title || '检验结果'
|
||||||
|
managementId.value = options.managementId
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
await getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open })
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
if (!managementId.value) return
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await TicketManagementApi.getTicketResultsPage({
|
||||||
|
pageNo: queryParams.pageNo,
|
||||||
|
pageSize: queryParams.pageSize,
|
||||||
|
managementId: managementId.value
|
||||||
|
})
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSizeChange = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCurrentChange = () => {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
const payload: TicketResultVO[] = []
|
||||||
|
for (const row of list.value) {
|
||||||
|
if (!row?.id) continue
|
||||||
|
if (String(row.inspectionResult) !== '0') continue
|
||||||
|
const decision = decisionMap[String(row.id)]
|
||||||
|
if (!decision) continue
|
||||||
|
payload.push({ ...(row as any), inspectionResult: decision })
|
||||||
|
}
|
||||||
|
if (!payload.length) {
|
||||||
|
message.error('请先为待检测记录选择通过或不通过')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
submitLoading.value = true
|
||||||
|
try {
|
||||||
|
await TicketManagementApi.batchUpdateTicketResults(payload)
|
||||||
|
message.success('更新成功')
|
||||||
|
await getList()
|
||||||
|
} catch {
|
||||||
|
message.error('更新失败')
|
||||||
|
} finally {
|
||||||
|
submitLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getRowKey = (row: TicketResultVO) => {
|
||||||
|
return String(row.id ?? '')
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseImages = (value: any): string[] => {
|
||||||
|
if (!value) return []
|
||||||
|
if (Array.isArray(value)) return value.map(String).filter(Boolean)
|
||||||
|
return String(value)
|
||||||
|
.split(',')
|
||||||
|
.map((v) => v.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseFirstImage = (value: any): string => {
|
||||||
|
return parseImages(value)[0] || ''
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -0,0 +1,209 @@
|
|||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="单号" prop="planNo">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.planNo"
|
||||||
|
placeholder="请输入单号"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="类型" prop="planType">
|
||||||
|
<el-select v-model="queryParams.planType" placeholder="请选择类型" clearable class="!w-240px">
|
||||||
|
<el-option v-for="opt in planTypeOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="作业状态" prop="jobStatus">
|
||||||
|
<el-select v-model="queryParams.jobStatus" placeholder="请选择作业状态" clearable class="!w-240px">
|
||||||
|
<el-option
|
||||||
|
v-for="opt in getStrDictOptions('job_status')"
|
||||||
|
:key="String(opt.value)"
|
||||||
|
:label="opt.label"
|
||||||
|
:value="opt.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="结果" prop="jobResult">
|
||||||
|
<el-select v-model="queryParams.jobResult" placeholder="请选择结果" clearable class="!w-240px">
|
||||||
|
<el-option v-for="opt in jobResultOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="resetQuery">
|
||||||
|
<Icon icon="ep:refresh" class="mr-5px" /> 重置
|
||||||
|
</el-button>
|
||||||
|
<el-button type="primary" @click="handleQuery">
|
||||||
|
<Icon icon="ep:search" class="mr-5px" /> 查询
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<div class="mb-10px">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
@click="handleBatchCancel"
|
||||||
|
:disabled="!selectedIds.length"
|
||||||
|
:loading="cancelLoading"
|
||||||
|
>
|
||||||
|
取消任务
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
<el-table-column type="index" label="序号" align="center" width="70" />
|
||||||
|
<el-table-column label="单号" align="center" prop="planNo" min-width="160" />
|
||||||
|
<el-table-column label="设备名称" align="center" prop="deviceName" min-width="160" />
|
||||||
|
<el-table-column label="类型" align="center" prop="planType" width="90">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag v-if="String(scope.row.planType) === '1'" type="primary">点检</el-tag>
|
||||||
|
<el-tag v-else-if="String(scope.row.planType) === '2'" type="success">保养</el-tag>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="计划配置名称" align="center" prop="configName" min-width="160" />
|
||||||
|
<el-table-column label="作业状态" align="center" prop="jobStatus" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="'job_status'" :value="scope.row.jobStatus" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="作业人" align="center" prop="operatorName" width="140" />
|
||||||
|
<el-table-column label="作业时间" align="center" prop="taskTime" :formatter="dateFormatter" width="180" />
|
||||||
|
<el-table-column label="计划结束作业时间" align="center" prop="taskEndTime" :formatter="dateFormatter" width="180" />
|
||||||
|
<el-table-column label="结果" align="center" prop="jobResult" width="90">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag v-if="scope.row.jobResult == '1'" type="success">OK</el-tag>
|
||||||
|
<el-tag v-else-if="scope.row.jobResult === 'NG'" type="danger">NG</el-tag>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" min-width="160" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" width="180" />
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<TicketResultDialog ref="resultDialogRef" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import { getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { useDictStoreWithOut } from '@/store/modules/dict'
|
||||||
|
import { TicketManagementApi, TicketManagementVO } from '@/api/mes/ticketManagement'
|
||||||
|
import TicketResultDialog from './components/TicketResultDialog.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'WorkOrderManagement' })
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
const dictStore = useDictStoreWithOut()
|
||||||
|
|
||||||
|
const planTypeOptions = [
|
||||||
|
{ label: '点检', value: '1' },
|
||||||
|
{ label: '保养', value: '2' }
|
||||||
|
]
|
||||||
|
const jobResultOptions = [
|
||||||
|
{ label: 'OK', value: 'OK' },
|
||||||
|
{ label: 'NG', value: 'NG' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const list = ref<TicketManagementVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const selectedIds = ref<number[]>([])
|
||||||
|
const cancelLoading = ref(false)
|
||||||
|
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
planNo: undefined as string | undefined,
|
||||||
|
planType: undefined as string | undefined,
|
||||||
|
jobStatus: undefined as string | undefined,
|
||||||
|
jobResult: undefined as string | undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
const queryFormRef = ref()
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await TicketManagementApi.getTicketManagementPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSelectionChange = (rows: TicketManagementVO[]) => {
|
||||||
|
selectedIds.value = rows
|
||||||
|
.map((r) => r.id)
|
||||||
|
.filter((id): id is number => typeof id === 'number')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleBatchCancel = async () => {
|
||||||
|
if (!selectedIds.value.length) return
|
||||||
|
try {
|
||||||
|
await message.confirm('确认取消选中的任务吗?')
|
||||||
|
cancelLoading.value = true
|
||||||
|
await TicketManagementApi.batchUpdateTicketStatus({ ids: selectedIds.value.join(','), jobStatus: '2' })
|
||||||
|
message.success('取消任务成功')
|
||||||
|
selectedIds.value = []
|
||||||
|
await getList()
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
cancelLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultDialogRef = ref<InstanceType<typeof TicketResultDialog>>()
|
||||||
|
|
||||||
|
const handleRowClick = async (row: TicketManagementVO, column: any) => {
|
||||||
|
if (column?.type === 'selection') return
|
||||||
|
if (!row?.id) return
|
||||||
|
await resultDialogRef.value?.open({
|
||||||
|
managementId: row.id,
|
||||||
|
title: row.planNo ? `检验结果-${row.planNo}` : '检验结果'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await dictStore.setDictMap()
|
||||||
|
await getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue