数据贯通完成,规程重构

This commit is contained in:
2026-04-27 20:37:59 +08:00
parent 5b38ef734a
commit b7161e9541
13 changed files with 1492 additions and 861 deletions

View File

@@ -1,87 +1,80 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
<el-form-item label="规程编号" prop="specCode">
<el-input v-model="queryParams.specCode" placeholder="规程编号" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="规程名称" prop="specName">
<el-input v-model="queryParams.specName" placeholder="规程名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="规程类型" prop="specType">
<el-select v-model="queryParams.specType" placeholder="全部" clearable>
<el-option v-for="item in specTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="产线" prop="lineId">
<el-select v-model="queryParams.lineId" placeholder="全部" clearable filterable>
<el-option
v-for="line in lineOptions"
:key="line.lineId"
:label="formatLineOption(line)"
:value="line.lineId"
<div class="spec-page">
<!-- 规程类型 tabs -->
<div class="type-tab-bar">
<span
v-for="t in specTypeTab"
:key="t.value"
:class="['type-tab', { active: activeSpecType === t.value }]"
@click="switchSpecType(t.value)"
>{{ t.label }}</span>
</div>
<!-- 产线 tabs -->
<div class="line-tab-bar">
<span
:class="['line-tab', { active: activeLineId === '' }]"
@click="switchLine('')"
>全部</span>
<span
v-for="line in lineOptions"
:key="line.lineId"
:class="['line-tab', { active: activeLineId === line.lineId }]"
@click="switchLine(line.lineId)"
>{{ line.lineName }}</span>
</div>
<!-- 工具栏 -->
<div class="toolbar">
<div class="toolbar-left">
<el-button type="primary" size="mini" icon="el-icon-plus" @click="handleAdd">新增</el-button>
<el-button size="mini" icon="el-icon-edit" :disabled="single" @click="handleUpdate()">修改</el-button>
<el-button size="mini" icon="el-icon-delete" :disabled="multiple" @click="handleDelete()">删除</el-button>
</div>
<div class="toolbar-right">
<el-input
v-model="queryParams.specName"
size="small"
placeholder="规程名称"
clearable
style="width:180px; margin-right:8px"
@keyup.enter.native="handleQuery"
/>
<el-button size="mini" type="primary" @click="handleQuery">查询</el-button>
<el-button size="mini" @click="resetQuery">重置</el-button>
</div>
</div>
<!-- 列表 -->
<el-table
v-loading="loading"
:data="dataList"
size="small"
highlight-current-row
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" />
<el-table-column label="规程编号" prop="specCode" show-overflow-tooltip />
<el-table-column label="规程名称" prop="specName" show-overflow-tooltip />
<el-table-column label="产品类型" prop="productType" show-overflow-tooltip />
<el-table-column label="创建时间" prop="createTime" />
<el-table-column label="启用" align="center">
<template slot-scope="{ row }">
<el-switch
:value="row.isEnabled === 1"
active-color="#5F7BA0"
@change="toggleEnabled(row, $event)"
/>
</el-select>
</el-form-item>
<el-form-item label="产品类型" prop="productType">
<el-input v-model="queryParams.productType" placeholder="产品类型" clearable />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-select v-model="queryParams.isEnabled" placeholder="全部" clearable>
<el-option label="启用" :value="1" />
<el-option label="禁用" :value="0" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<KLPTable v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="规程编号" align="center" prop="specCode" min-width="120" show-overflow-tooltip />
<el-table-column label="规程名称" align="center" prop="specName" min-width="140" show-overflow-tooltip />
<el-table-column label="规程类型" align="center" prop="specType" width="100">
<template slot-scope="scope">
<span>{{ formatSpecType(scope.row.specType) }}</span>
</template>
</el-table-column>
<el-table-column label="产线" align="center" min-width="160" show-overflow-tooltip>
<template slot-scope="scope">
{{ getLineName(scope.row.lineId) }}
<el-table-column label="操作" align="right">
<template slot-scope="{ row }">
<el-button type="text" size="mini" @click="goVersionManage(row)">版本与方案</el-button>
<el-button type="text" size="mini" @click="handleUpdate(row)">修改</el-button>
<el-button type="text" size="mini" class="btn-danger" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
<el-table-column label="产品类型" align="center" prop="productType" min-width="100" show-overflow-tooltip />
<el-table-column label="是否启用" align="center" prop="isEnabled" width="90">
<template slot-scope="scope">
<dict-tag :options="dict.type.common_swicth" :value="scope.row.isEnabled" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-document" @click="goVersionManage(scope.row)">版本与方案</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</KLPTable>
</el-table>
<pagination
v-show="total > 0"
@@ -91,45 +84,43 @@
@pagination="getList"
/>
<el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<!-- 新增/修改 -->
<el-dialog :title="dialogTitle" :visible.sync="open" width="520px" append-to-body @close="reset">
<el-form ref="form" :model="form" :rules="rules" label-width="88px" size="small">
<el-form-item label="规程编号" prop="specCode">
<el-input v-model="form.specCode" placeholder="唯一编号" maxlength="64" show-word-limit />
</el-form-item>
<el-form-item label="规程名称" prop="specName">
<el-input v-model="form.specName" placeholder="规程名称" maxlength="200" show-word-limit />
<el-input v-model="form.specName" maxlength="200" show-word-limit />
</el-form-item>
<el-form-item label="规程类型" prop="specType">
<el-select v-model="form.specType" placeholder="请选择">
<el-option v-for="item in specTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
<el-select v-model="form.specType" style="width:100%">
<el-option v-for="t in specTypeOptions" :key="t.value" :label="t.label" :value="t.value" />
</el-select>
</el-form-item>
<el-form-item label="产线" prop="lineId">
<el-select v-model="form.lineId" placeholder="请选择产线" filterable style="width: 100%">
<el-select v-model="form.lineId" filterable placeholder="请选择" style="width:100%">
<el-option
v-for="line in lineOptions"
:key="line.lineId"
:label="formatLineOption(line)"
:label="line.lineCode ? line.lineName + '' + line.lineCode + '' : line.lineName"
:value="line.lineId"
/>
</el-select>
</el-form-item>
<el-form-item label="产品类型" prop="productType">
<el-input v-model="form.productType" placeholder="可选" maxlength="100" />
<el-input v-model="form.productType" maxlength="100" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-radio-group v-model="form.isEnabled">
<el-radio :label="1">启用</el-radio>
<el-radio :label="0">禁用</el-radio>
</el-radio-group>
<el-switch v-model="form.isEnabled" :active-value="1" :inactive-value="0" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="备注" maxlength="500" show-word-limit rows="2" />
<el-input v-model="form.remark" type="textarea" rows="2" maxlength="500" show-word-limit />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
<div slot="footer">
<el-button size="small" @click="open = false">取消</el-button>
<el-button size="small" type="primary" :loading="btnLoading" @click="submitForm">确定</el-button>
</div>
</el-dialog>
</div>
@@ -139,184 +130,255 @@
import { listProcessSpec, getProcessSpec, delProcessSpec, updateProcessSpec, addProcessSpec } from '@/api/wms/processSpec'
import { listProductionLine } from '@/api/wms/productionLine'
const SPEC_TYPES = [
{ label: '工艺规程', value: 'PROCESS' },
{ label: '标准', value: 'STANDARD' }
]
export default {
name: 'ProcessSpec',
dicts: ['common_swicth'],
data() {
return {
buttonLoading: false,
loading: true,
loading: false,
btnLoading: false,
total: 0,
dataList: [],
ids: [],
single: true,
multiple: true,
showSearch: true,
total: 0,
dataList: [],
title: '',
open: false,
dialogTitle: '',
lineOptions: [],
specTypeOptions: [
{ label: '工艺规程', value: 'PROCESS' },
{ label: '标准', value: 'STANDARD' }
],
specTypeTab: [{ label: '全部', value: '' }, ...SPEC_TYPES],
specTypeOptions: SPEC_TYPES,
activeSpecType: '',
activeLineId: '',
queryParams: {
pageNum: 1,
pageSize: 20,
specCode: undefined,
specName: undefined,
specType: undefined,
lineId: undefined,
productType: undefined,
isEnabled: undefined
lineId: undefined
},
form: {},
rules: {
specCode: [{ required: true, message: '规程编号不能为空', trigger: 'blur' }],
specName: [{ required: true, message: '规程名称不能为空', trigger: 'blur' }],
specType: [{ required: true, message: '规程类型不能为空', trigger: 'change' }],
lineId: [{ required: true, message: '产线不能为空', trigger: 'change' }]
specType: [{ required: true, message: '请选择规程类型', trigger: 'change' }],
lineId: [{ required: true, message: '请选择产线', trigger: 'change' }]
}
}
},
created() {
this.loadLineOptions()
listProductionLine({ pageNum: 1, pageSize: 500 }).then(res => {
this.lineOptions = res.rows || []
})
this.getList()
},
methods: {
formatSpecType(value) {
const hit = this.specTypeOptions.find((x) => x.value === value)
return hit ? hit.label : value
},
formatLineOption(line) {
if (!line) {
return ''
}
return line.lineCode ? `${line.lineName}${line.lineCode}` : line.lineName
},
getLineName(lineId) {
if (lineId == null) {
return ''
}
const hit = this.lineOptions.find((o) => o.lineId === lineId)
return hit ? this.formatLineOption(hit) : lineId
},
loadLineOptions() {
listProductionLine({ pageNum: 1, pageSize: 500 }).then((res) => {
this.lineOptions = res.rows || []
}).catch((err) => {
console.error('加载产线列表失败', err)
})
},
getList() {
this.loading = true
listProcessSpec(this.queryParams).then((response) => {
this.dataList = response.rows
this.total = response.total
this.loading = false
}).catch((err) => {
console.error('加载规程列表失败', err)
this.loading = false
})
listProcessSpec(this.queryParams).then(res => {
this.dataList = res.rows || []
this.total = res.total || 0
}).finally(() => { this.loading = false })
},
cancel() {
this.open = false
this.reset()
switchSpecType(val) {
this.activeSpecType = val
this.queryParams.specType = val || undefined
this.queryParams.pageNum = 1
this.getList()
},
reset() {
this.form = {
specId: undefined,
specCode: undefined,
specName: undefined,
specType: 'PROCESS',
lineId: undefined,
productType: undefined,
isEnabled: 1,
remark: undefined
}
this.resetForm('form')
switchLine(lineId) {
this.activeLineId = lineId
this.queryParams.lineId = lineId || undefined
this.queryParams.pageNum = 1
this.getList()
},
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.resetForm('queryForm')
this.queryParams.specName = undefined
this.handleQuery()
},
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.specId)
this.single = selection.length !== 1
this.multiple = !selection.length
handleSelectionChange(sel) {
this.ids = sel.map(r => r.specId)
this.single = sel.length !== 1
this.multiple = !sel.length
},
reset() {
this.form = { specId: undefined, specCode: undefined, specName: undefined, specType: 'PROCESS', lineId: undefined, productType: undefined, isEnabled: 1, remark: undefined }
this.$refs.form && this.$refs.form.clearValidate()
},
handleAdd() {
this.reset()
this.dialogTitle = '新增规程'
this.open = true
this.title = '添加规程'
},
handleUpdate(row) {
this.loading = true
this.reset()
const specId = row.specId || this.ids
getProcessSpec(specId).then((response) => {
this.loading = false
this.form = response.data
const specId = row ? row.specId : this.ids[0]
getProcessSpec(specId).then(res => {
this.form = res.data || {}
this.dialogTitle = '修改规程'
this.open = true
this.title = '修改规程'
}).catch((err) => {
console.error('获取规程详情失败', err)
this.loading = false
})
},
submitForm() {
this.$refs.form.validate((valid) => {
if (!valid) {
return
}
this.buttonLoading = true
const req = this.form.specId != null ? updateProcessSpec(this.form) : addProcessSpec(this.form)
this.$refs.form.validate(valid => {
if (!valid) return
this.btnLoading = true
const req = this.form.specId ? updateProcessSpec(this.form) : addProcessSpec(this.form)
req.then(() => {
this.$modal.msgSuccess(this.form.specId != null ? '修改成功' : '新增成功')
this.$modal.msgSuccess('保存成功')
this.open = false
this.getList()
}).catch((err) => {
console.error('保存规程失败', err)
}).finally(() => {
this.buttonLoading = false
})
}).finally(() => { this.btnLoading = false })
})
},
handleDelete(row) {
const specIds = row.specId || this.ids
this.$modal.confirm('是否确认删除选中的规程数据').then(() => {
const ids = row ? row.specId : this.ids
this.$modal.confirm('确认删除所选规程').then(() => {
this.loading = true
return delProcessSpec(specIds)
return delProcessSpec(ids)
}).then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
}).catch(() => {}).finally(() => {
this.loading = false
})
this.getList()
}).catch(() => {}).finally(() => { this.loading = false })
},
handleExport() {
this.download('wms/processSpec/export', {
...this.queryParams
}, `processSpec_${new Date().getTime()}.xlsx`)
toggleEnabled(row, val) {
const updated = { ...row, isEnabled: val ? 1 : 0 }
updateProcessSpec(updated).then(() => {
row.isEnabled = updated.isEnabled
}).catch(() => {})
},
goVersionManage(row) {
const specId = row.specId
if (specId == null || specId === '') {
this.$modal.msgWarning('无法获取规程ID请刷新列表后重试')
return
}
// 固定落在「…/processSpec/version」避免列表为 …/processSpec/list 时拼成 …/list/version 导致路由不匹配、query 丢失
const pathCurrent = this.$route.path.replace(/\/$/, '')
const m = pathCurrent.match(/^(.*\/processSpec)(?:\/.*)?$/)
const base = m ? m[1] : pathCurrent
this.$router.push({
path: `${base}/version`,
query: { specId: String(specId) }
})
this.$router.push({ path: `${base}/version`, query: { specId: String(row.specId) } })
}
}
}
</script>
<style scoped>
.spec-page {
padding: 16px 20px;
min-height: 100%;
}
/* ── 双色主题:默认=白底灰边,激活/主操作=深藏青 #5F7BA0 ── */
.type-tab-bar {
display: flex;
gap: 0;
margin-bottom: 10px;
width: fit-content;
border-radius: 4px;
overflow: hidden;
border: 1px solid #dcdfe6;
}
.type-tab {
padding: 5px 14px;
font-size: 12px;
cursor: pointer;
color: #606266;
background: #fff;
border: none;
border-right: 1px solid #dcdfe6;
transition: color .15s, background .15s;
user-select: none;
line-height: 1;
}
.type-tab:last-child { border-right: none; }
.type-tab:hover { color: #5F7BA0; }
.type-tab.active {
color: #fff;
background: #5F7BA0;
}
.line-tab-bar {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-bottom: 12px;
padding: 10px 0;
}
.line-tab {
padding: 4px 12px;
border-radius: 4px;
font-size: 12px;
cursor: pointer;
color: #606266;
background: #fff;
border: 1px solid #dcdfe6;
transition: color .15s, background .15s, border-color .15s;
user-select: none;
line-height: 1;
}
.line-tab:hover { color: #5F7BA0; border-color: #5F7BA0; }
.line-tab.active {
color: #fff;
background: #5F7BA0;
border-color: #5F7BA0;
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.toolbar-left,
.toolbar-right {
display: flex;
align-items: center;
gap: 6px;
}
.el-table {
border-radius: 4px;
overflow: hidden;
}
/* el-button主操作类 → 深藏青;默认类 → 白底灰边 */
::v-deep .el-button--primary {
color: #fff !important;
background: #5F7BA0 !important;
border-color: #5F7BA0 !important;
}
::v-deep .el-button--primary:hover,
::v-deep .el-button--primary:focus {
background: #4d6a8e !important;
border-color: #4d6a8e !important;
}
::v-deep .el-button--primary:active { background: #4a6585 !important; border-color: #4a6585 !important; }
::v-deep .el-button--primary.is-disabled { opacity: .5; }
::v-deep .el-button:not(.el-button--primary):not(.el-button--text):not(.el-button--danger):not(.el-button--info) {
color: #606266 !important;
background: #fff !important;
border-color: #dcdfe6 !important;
}
::v-deep .el-button:not(.el-button--primary):not(.el-button--text):not(.el-button--danger):not(.el-button--info):hover {
color: #5F7BA0 !important;
border-color: #5F7BA0 !important;
}
::v-deep .el-button:not(.el-button--primary):not(.el-button--text):not(.el-button--danger):not(.el-button--info).is-disabled { opacity: .5; }
::v-deep .el-button--text { background: transparent !important; border-color: transparent !important; }
::v-deep .el-button--text.btn-danger { color: #f56c6c !important; }
.btn-danger { color: #f56c6c; }
</style>