补全工序单元预设设定值插件渲染
Some checks failed
Release pipeline / publish (push) Has been cancelled
Release pipeline / Always run job (push) Has been cancelled

This commit is contained in:
sheng
2026-06-26 14:15:53 +08:00
parent 502e6cdd32
commit 9eacf495f1
2 changed files with 410 additions and 2 deletions

View File

@@ -25,6 +25,7 @@
<script>
import { i18nMixin } from '@/composables/useI18n'
import { getUnitAll } from '@/api/production-master-data/material-unit'
function isJson (value) {
if (typeof value !== 'string') return false
@@ -162,6 +163,386 @@ const JsonPlugin = {
`
}
const deviceSettingForms = {
DvPlugin: {
title: 'OCV 通用设定',
fields: [
{ prop: 'ocv_min_read_range', label: 'OCV读取下限', unit: 'mV' },
{ prop: 'ocv_max_read_range', label: 'OCV读取上限', unit: 'mV' },
{ prop: 'ir_min_read_range', label: 'IR读取下限', unit: 'mΩ' },
{ prop: 'ir_max_read_range', label: 'IR读取上限', unit: 'mΩ' },
{ prop: 'NG_threshold', label: 'NG阈值', unit: '个' },
{ prop: 'pin_count', label: '接触检查不良报警次数', unit: '0不报警' },
{ prop: 'K_ext', label: 'K值开关', type: 'checkbox' },
{ prop: 'process_code', label: '工序编码' },
{ prop: 'K_min_read_range', label: 'K值读取下限', unit: 'mV/h' },
{ prop: 'K_max_read_range', label: 'K值读取上限', unit: 'mV/h' }
],
defaults: {
ocv_min_read_range: undefined,
ocv_max_read_range: undefined,
ir_min_read_range: undefined,
ir_max_read_range: undefined,
K_min_read_range: undefined,
K_max_read_range: undefined,
pin_count: undefined,
process_code: undefined,
NG_threshold: 0
}
},
OcvrPlugin: {
title: 'DCIR 通用设定',
fields: [
{
prop: 'SETWKMODE',
label: '工作模式',
type: 'select',
options: [
{ label: '静置-充电1', value: '0' },
{ label: '静置-放电1', value: '1' },
{ label: '静置-充电1-充电2', value: '2' },
{ label: '静置-放电1-放电2', value: '3' },
{ label: '静置-充电1-充电2-静置-充电1-充电2', value: '4' },
{ label: '静置-放电1-放电2-静置-放电1-放电2', value: '5' },
{ label: '静置-充电1-充电2-静置-放电1-放电2', value: '6' },
{ label: '静置-放电1-放电2-静置-充电1-充电2', value: '7' },
{ label: '静置-放电-静置-充电', value: '8' },
{ label: '静置-充电-静置-放电', value: '9' }
]
},
{ prop: 'VDROP', label: '最大压降' },
{ prop: 'SETUPV', label: '电压上限', unit: 'mV' },
{ prop: 'SETLWV', label: '电压下限', unit: 'mV' },
{ prop: 'DCR1_up', label: 'DCR1上限', unit: 'mΩ' },
{ prop: 'DCR1_low', label: 'DCR1下限', unit: 'mΩ' },
{ prop: 'DCR2_up', label: 'DCR2上限', unit: 'mΩ' },
{ prop: 'DCR2_low', label: 'DCR2下限', unit: 'mΩ' },
{ prop: 'REST_T', label: '静置时间', unit: 's' },
{ prop: 'NG_threshold', label: 'NG阈值', unit: '个' },
{ prop: 'contact_alarm', label: '接触报警次数', unit: '0不报警' },
{ prop: 'time_interval', label: '过程数据保存时间', unit: 'ms' },
{ prop: 'I1_1', label: '阶段1电流1', unit: 'mA' },
{ prop: 'I1_2', label: '阶段1电流2', unit: 'mA' },
{ prop: 'T1_1', label: '阶段1工作时间1', unit: 's' },
{ prop: 'T1_2', label: '阶段1工作时间2', unit: 's' },
{ prop: 'REST_T_1', label: '阶段1静置时间', unit: 's' },
{ prop: 'CT_1', label: '阶段1采样时间', unit: 's' },
{ prop: 'I2_1', label: '阶段2电流1', unit: 'mA' },
{ prop: 'I2_2', label: '阶段2电流2', unit: 'mA' },
{ prop: 'T2_1', label: '阶段2工作时间1', unit: 's' },
{ prop: 'T2_2', label: '阶段2工作时间2', unit: 's' },
{ prop: 'REST_T_2', label: '阶段2静置时间', unit: 's' },
{ prop: 'CT_2', label: '阶段2采样时间', unit: 's' }
],
defaults: {
SETUPV: undefined,
SETLWV: undefined,
REST_T: undefined,
VDROP: undefined,
contact_alarm: undefined,
time_interval: undefined,
DCR1_up: undefined,
DCR1_low: undefined,
DCR2_up: undefined,
DCR2_low: undefined,
I1_1: undefined,
I2_1: undefined,
I1_2: undefined,
I2_2: undefined,
T1_1: undefined,
T2_1: undefined,
T1_2: undefined,
T2_2: undefined,
REST_T_1: undefined,
REST_T_2: undefined,
CT_1: undefined,
CT_2: undefined,
SETWKMODE: undefined,
NG_threshold: 0
}
}
}
const DeviceSettingPlugin = {
name: 'ProcessStepDeviceSettingPlugin',
props: {
type: { type: String, default: '' },
settingJson: { default: '' }
},
data () {
return {
activeTab: 'process',
json: { process: {} },
form: {}
}
},
computed: {
config () {
return deviceSettingForms[this.type] || deviceSettingForms.DvPlugin
}
},
watch: {
settingJson: {
handler (val) {
const parsed = parseSetting(val, { process: {} })
this.json = parsed
this.form = { ...this.config.defaults, ...(parsed.process || {}) }
},
immediate: true
},
form: {
handler (val) {
this.json = { ...this.json, process: { ...val } }
},
deep: true
}
},
methods: {
handleFormSubmit () {
this.$emit('submit', this.json)
}
},
template: `
<el-tabs v-model="activeTab" type="card">
<el-tab-pane label="设定值" name="process">
<el-divider content-position="left">{{ config.title }}</el-divider>
<el-form :model="form" label-position="right" label-width="160px" size="mini" class="device-setting-form">
<el-row :gutter="16">
<el-col v-for="field in config.fields" :key="field.prop" :span="12">
<el-form-item :label="field.label">
<el-checkbox
v-if="field.type === 'checkbox'"
v-model="form[field.prop]"
true-label="1"
false-label=""
/>
<el-select
v-else-if="field.type === 'select'"
v-model="form[field.prop]"
placeholder="请选择"
clearable
filterable
style="width:100%"
>
<el-option
v-for="option in field.options"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
<el-input v-else v-model="form[field.prop]" placeholder="请输入内容" clearable>
<template v-if="field.unit" slot="append">{{ field.unit }}</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-tab-pane>
<el-tab-pane label="json" name="json">
<tree-view :data="json" />
</el-tab-pane>
</el-tabs>
`
}
const NonStandardSettingPlugin = {
name: 'ProcessStepNonStandardSettingPlugin',
props: { settingJson: { default: '' } },
data () {
return {
activeTab: 'process',
json: { process: [] },
rows: [],
searchForm: { name: '', code: '' },
dialogVisible: false,
editIndex: -1,
form: { code: '', name: '', value: '', unit: '', remark: '' },
rules: {
code: [{ required: true, message: '请输入参数', trigger: 'blur' }],
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
value: [{ required: true, message: '请输入默认值', trigger: 'blur' }],
unit: [{ required: true, message: '请选择单位', trigger: 'change' }]
},
unitOptions: [],
unitMap: {}
}
},
computed: {
filteredRows () {
const name = (this.searchForm.name || '').trim()
const code = (this.searchForm.code || '').trim()
return this.rows.filter(row => {
const matchName = !name || String(row.name || '').includes(name)
const matchCode = !code || String(row.code || '').includes(code)
return matchName && matchCode
})
}
},
watch: {
settingJson: {
handler (val) {
const parsed = parseSetting(val, { process: [] })
const process = Array.isArray(parsed.process) ? parsed.process : []
this.json = { ...parsed, process }
this.rows = process.map(item => ({ ...item }))
},
immediate: true
},
rows: {
handler (val) {
this.json = { ...this.json, process: val.map(item => ({ ...item })) }
},
deep: true
}
},
created () {
getUnitAll().then(res => {
const list = (res && res.data && (res.data.data || res.data.list || res.data)) || []
this.unitOptions = Array.isArray(list) ? list : []
this.unitMap = this.unitOptions.reduce((map, item) => {
map[item.code] = item.name
return map
}, {})
}).catch(() => {
this.unitOptions = []
this.unitMap = {}
})
},
methods: {
openAdd () {
this.editIndex = -1
this.form = { code: '', name: '', value: '', unit: '', remark: '' }
this.dialogVisible = true
this.$nextTick(() => this.$refs.form && this.$refs.form.clearValidate())
},
openEdit (row) {
this.editIndex = this.rows.indexOf(row)
this.form = { ...row }
this.dialogVisible = true
this.$nextTick(() => this.$refs.form && this.$refs.form.clearValidate())
},
removeRow (row) {
const index = this.rows.indexOf(row)
if (index !== -1) this.rows.splice(index, 1)
},
submitRow () {
this.$refs.form.validate(valid => {
if (!valid) return
const duplicate = this.rows.some((item, index) => {
return index !== this.editIndex && (item.name === this.form.name || item.code === this.form.code)
})
if (duplicate) {
this.$message.error('名称或参数已存在')
return
}
if (this.editIndex >= 0) {
this.$set(this.rows, this.editIndex, { ...this.form })
} else {
this.rows.push({ ...this.form })
}
this.dialogVisible = false
})
},
handleFormSubmit () {
this.$emit('submit', this.json)
}
},
template: `
<el-tabs v-model="activeTab" type="card">
<el-tab-pane label="设定值" name="process">
<div class="non-standard-setting">
<div class="setting-search-card">
<el-card class="box-card" style="height:550px">
<div slot="header">
<span>查询</span>
</div>
<el-form label-position="top" :model="searchForm" size="mini">
<el-form-item label="名称">
<el-input v-model.trim="searchForm.name" placeholder="请输入名称" clearable />
</el-form-item>
<el-form-item label="参数">
<el-input v-model.trim="searchForm.code" placeholder="请输入参数" clearable />
</el-form-item>
</el-form>
</el-card>
</div>
<div class="setting-table">
<el-table :data="filteredRows" border height="550" style="width:100%">
<el-table-column prop="name" label="名称" width="220" show-overflow-tooltip />
<el-table-column prop="code" label="参数" width="180" show-overflow-tooltip />
<el-table-column prop="value" label="默认值" min-width="140" show-overflow-tooltip />
<el-table-column label="单位" width="140" show-overflow-tooltip>
<template slot-scope="{ row }">{{ unitMap[row.unit] || row.unit }}</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip />
<el-table-column label="操作" width="100" fixed="right" align="center">
<template slot-scope="{ row }">
<el-button type="text" icon="el-icon-edit" @click="openEdit(row)" />
<el-button type="text" icon="el-icon-delete" style="color:#F56C6C" @click="removeRow(row)" />
</template>
</el-table-column>
</el-table>
<div class="setting-actions">
<el-button type="primary" size="small" @click="openAdd">新增一行</el-button>
</div>
</div>
</div>
<el-dialog
:title="editIndex >= 0 ? '编辑' : '新增'"
:visible.sync="dialogVisible"
append-to-body
width="800px"
>
<el-form ref="form" :model="form" :rules="rules" label-width="100px" size="mini">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="参数" prop="code">
<el-input v-model="form.code" placeholder="请输入参数" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="默认值" prop="value">
<el-input v-model="form.value" placeholder="请输入默认值" clearable />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="单位" prop="unit">
<el-select v-model="form.unit" placeholder="请选择单位" filterable clearable style="width:100%">
<el-option
v-for="item in unitOptions"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注">
<el-input v-model="form.remark" placeholder="请输入备注" clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitRow">确定</el-button>
</div>
</el-dialog>
</el-tab-pane>
<el-tab-pane label="json" name="json">
<tree-view :data="json" />
</el-tab-pane>
</el-tabs>
`
}
const FormationPlugin = {
name: 'ProcessStepFormationPlugin',
props: {
@@ -457,7 +838,7 @@ const FormationPlugin = {
export default {
name: 'ProcessStepSettingDialog',
components: { WaitPlugin, JsonPlugin, FormationPlugin },
components: { WaitPlugin, JsonPlugin, FormationPlugin, DeviceSettingPlugin, NonStandardSettingPlugin },
mixins: [i18nMixin('page.production_master_data.process_model.process_step')],
props: {
type: { type: String, default: '' },
@@ -471,6 +852,8 @@ export default {
pluginComponent () {
if (this.type === 'WaitPlugin') return 'WaitPlugin'
if (this.type === 'FormationPlugin') return 'FormationPlugin'
if (this.type === 'DvPlugin' || this.type === 'OcvrPlugin') return 'DeviceSettingPlugin'
if (this.type === 'NonStandardProcessSettingPlugin') return 'NonStandardSettingPlugin'
return 'JsonPlugin'
}
},
@@ -497,6 +880,25 @@ export default {
margin-right: 4px;
color: #409EFF;
}
.device-setting-form /deep/ .el-form-item--mini.el-form-item {
margin-bottom: 10px;
}
.non-standard-setting {
display: flex;
flex-direction: row;
justify-content: center;
}
.setting-search-card {
width: 20%;
margin-right: 20px;
}
.setting-table {
width: 80%;
}
.setting-actions {
margin-top: 10px;
text-align: right;
}
/deep/ .formation-row-cycle {
background-color: #ffc0ff !important;
}

View File

@@ -362,6 +362,12 @@ export default {
isFormationSettingRow (row) {
return ['FORMATION', 'YC', 'HC', 'IC', 'FORMATION_SS'].includes(row.device_category_code)
},
getSettingWidth (row) {
if (row.setting_plugin_width) return `${row.setting_plugin_width}%`
if (this.isFormationSettingRow(row) || row.setting_plugin === 'FormationPlugin') return '90%'
if (['DvPlugin', 'OcvrPlugin', 'NonStandardProcessSettingPlugin'].includes(row.setting_plugin)) return '80%'
return '35%'
},
resetForm () {
this.formData = { code: '', name: '', device_category_id: '', is_denglu_process: '0', remark: '' }
this.editId = ''
@@ -437,7 +443,7 @@ export default {
this.settingTitle = `${row.name}${this.$t(this.key('preset_setting'))}`
this.settingType = row.setting_plugin || (this.isFormationSettingRow(row) ? 'FormationPlugin' : '')
this.settingCode = row.code
this.settingWidth = row.setting_plugin_width ? `${row.setting_plugin_width}%` : (this.isFormationSettingRow(row) ? '90%' : '35%')
this.settingWidth = this.getSettingWidth(row)
this.settingPluginData = row.default_setting || {}
this.settingVisible = true
},