<template>
|
<div class="page">
|
<div class="page-title">
|
<div>
|
<h2>{{ pageTitle }}</h2>
|
<p>{{ subtitle }}</p>
|
</div>
|
<el-button icon="el-icon-refresh" @click="load">刷新</el-button>
|
</div>
|
|
<div class="toolbar">
|
<el-input v-model="keyword" placeholder="派工单编号 / X号 / 承修单位" clearable style="width:280px" @keyup.enter.native="load"></el-input>
|
<el-button type="primary" icon="el-icon-search" @click="load">查询</el-button>
|
<div class="spacer"></div>
|
<el-tag type="info" size="small">仅完工状态的派工单可进入验收流程</el-tag>
|
</div>
|
|
<div class="table-panel">
|
<el-table :data="filteredRows" border stripe height="calc(100vh - 230px)">
|
<el-table-column prop="workOrderNo" label="派工单编号" width="155" fixed></el-table-column>
|
<el-table-column prop="status" label="验收状态" width="155" fixed>
|
<template slot-scope="{ row }"><el-tag size="mini" :type="acceptanceMeta(row.status).type">{{ acceptanceMeta(row.status).text }}</el-tag></template>
|
</el-table-column>
|
<el-table-column prop="xNo" label="X号" width="64"></el-table-column>
|
<el-table-column prop="contractorName" label="承修单位" min-width="170"></el-table-column>
|
<el-table-column prop="stage" label="当前环节" width="150">
|
<template slot-scope="{ row }">{{ stageText(row.stage) }}</template>
|
</el-table-column>
|
<el-table-column prop="applyTime" label="申请时间" width="160"><template slot-scope="{ row }">{{ formatTime(row.applyTime) }}</template></el-table-column>
|
<el-table-column prop="inspectorResult" label="质检员结论" width="105"></el-table-column>
|
<el-table-column prop="inspectorOpinion" label="质检员意见" min-width="180" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="leaderResult" label="负责人结论" width="110"></el-table-column>
|
<el-table-column prop="leaderOpinion" label="负责人意见" min-width="180" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="rating" label="修后质量评级" width="115"></el-table-column>
|
<el-table-column label="操作" :width="actionWidth" fixed="right">
|
<template slot-scope="{ row }">
|
<template v-if="stage === 'APPLICATION'">
|
<el-button type="primary" size="mini" @click="open(row, 'SUBMIT')">提交验收申请</el-button>
|
</template>
|
<template v-else-if="stage === 'INSPECTOR' || stage === 'LEADER'">
|
<el-button type="success" size="mini" @click="open(row, 'PASS')">通过</el-button>
|
<el-button type="danger" size="mini" plain @click="open(row, 'REJECT')">打回</el-button>
|
</template>
|
<template v-else-if="stage === 'PRINT'">
|
<el-button type="primary" size="mini" icon="el-icon-printer" @click="doPrint(row)">打印输出</el-button>
|
</template>
|
<template v-else-if="stage === 'RATING'">
|
<el-button type="primary" size="mini" @click="open(row, 'RATING')">保存评级</el-button>
|
</template>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="580px" append-to-body>
|
<el-form label-width="100px">
|
<el-form-item label="派工单"><b>{{ activeRow && activeRow.workOrderNo }}</b></el-form-item>
|
<template v-if="stage === 'RATING'">
|
<el-form-item label="质量评级">
|
<el-select v-model="actionForm.rating" style="width:220px">
|
<el-option v-for="item in ratings" :key="item" :label="item" :value="item"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="评级说明"><el-input v-model="actionForm.ratingRemark" type="textarea" :rows="3"></el-input></el-form-item>
|
</template>
|
<template v-else>
|
<el-form-item label="办理意见">
|
<el-input v-model="actionForm.opinion" type="textarea" :rows="3" :placeholder="actionForm.action === 'REJECT' ? '请填写打回原因' : '可填写验收说明'"></el-input>
|
</el-form-item>
|
</template>
|
<el-alert v-if="actionForm.action === 'REJECT'" :closable="false" type="warning" show-icon :title="stage === 'INSPECTOR' ? '打回后回到验收申请环节。' : '打回后回到质检员验收环节。'"></el-alert>
|
</el-form>
|
<template slot="footer">
|
<el-button @click="dialogVisible = false">取消</el-button>
|
<el-button type="primary" :loading="saving" @click="submitAction">确定</el-button>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import api from '@/api'
|
import { acceptanceStatuses, statusMeta } from '@/utils/dict'
|
|
export default {
|
name: 'AcceptanceList',
|
data() {
|
return {
|
rows: [],
|
keyword: '',
|
dialogVisible: false,
|
saving: false,
|
activeRow: null,
|
actionForm: { action: '', opinion: '', rating: '合格', ratingRemark: '' },
|
ratings: ['不合格', '合格', '良好', '优良']
|
}
|
},
|
computed: {
|
stage() { return this.$route.meta.stage },
|
pageTitle() {
|
return { APPLICATION: '验收申请', INSPECTOR: '质检员验收', LEADER: '质检负责人验收', PRINT: '完工验收打印输出', RATING: '修后质量评级' }[this.stage]
|
},
|
subtitle() {
|
return {
|
APPLICATION: '对已完工派工单提交验收申请,提交后进入质检员验收',
|
INSPECTOR: '质检员验收只有通过或打回,打回后回到验收申请',
|
LEADER: '质检负责人验收只有通过或打回,打回后回到质检员验收',
|
PRINT: '对已通过质检负责人验收的派工单执行打印输出',
|
RATING: '对打印输出后的派工单执行修后质量评级'
|
}[this.stage]
|
},
|
filteredRows() {
|
if (!this.keyword) return this.rows
|
const text = this.keyword.toLowerCase()
|
return this.rows.filter(item => [item.workOrderNo, item.xNo, item.contractorName].some(value => String(value || '').toLowerCase().includes(text)))
|
},
|
dialogTitle() {
|
if (this.actionForm.action === 'SUBMIT') return '提交验收申请'
|
if (this.actionForm.action === 'REJECT') return '打回'
|
if (this.actionForm.action === 'PASS') return '验收通过'
|
if (this.actionForm.action === 'RATING') return '修后质量评级'
|
return this.pageTitle
|
},
|
actionWidth() {
|
return ['INSPECTOR', 'LEADER'].includes(this.stage) ? 150 : 145
|
}
|
},
|
watch: {
|
'$route.path': 'onRouteChange'
|
},
|
created() { this.load() },
|
methods: {
|
acceptanceMeta(value) { return statusMeta(acceptanceStatuses, value) },
|
stageText(value) {
|
return { APPLICATION: '验收申请', QUALITY_INSPECTOR: '质检员验收', QUALITY_LEADER: '质检负责人验收', PRINT: '打印输出', RATING: '修后质量评级', COMPLETED: '已完成' }[value] || value
|
},
|
formatTime(value) { return value ? String(value).replace('T', ' ').slice(0, 19) : '-' },
|
onRouteChange() { this.load() },
|
load() {
|
api.get('/acceptances', { params: { stage: this.stage } }).then(res => { this.rows = res.data || [] })
|
},
|
open(row, action) {
|
this.activeRow = row
|
this.actionForm = { action, opinion: '', rating: '合格', ratingRemark: '' }
|
this.dialogVisible = true
|
},
|
submitAction() {
|
if (this.actionForm.action === 'REJECT' && !this.actionForm.opinion) return this.$message.warning('请填写打回原因')
|
this.saving = true
|
api.post('/acceptances/action', {
|
id: this.activeRow.id,
|
action: this.actionForm.action,
|
opinion: this.actionForm.opinion,
|
rating: this.actionForm.rating,
|
ratingRemark: this.actionForm.ratingRemark
|
}).then(() => {
|
this.$message.success('办理成功')
|
this.dialogVisible = false
|
this.load()
|
}).finally(() => { this.saving = false })
|
},
|
doPrint(row) {
|
this.$confirm(`确定对 ${row.workOrderNo} 执行完工验收打印输出吗?`, '打印输出').then(() => api.post('/acceptances/action', { id: row.id, action: 'PRINT' })).then(() => {
|
this.$message.success('已记录打印输出')
|
this.load()
|
}).catch(() => {})
|
}
|
}
|
}
|
</script>
|