生产
This commit is contained in:
@@ -6,35 +6,27 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<el-drawer
|
||||
:visible="visible"
|
||||
:show-close="false"
|
||||
:wrapper-closable="false"
|
||||
class="drawer"
|
||||
custom-class="mes-drawer"
|
||||
:size="size || '50%'"
|
||||
@closed="$emit('destroy')">
|
||||
<SmallTitle slot="title">
|
||||
{{
|
||||
mode.includes('detail')
|
||||
? '详情'
|
||||
: mode.includes('edit')
|
||||
? '编辑'
|
||||
: '新增'
|
||||
}}
|
||||
</SmallTitle>
|
||||
<el-drawer :visible="visible" :show-close="false" :wrapper-closable="false" class="drawer" custom-class="mes-drawer"
|
||||
:size="size || '50%'" @closed="$emit('destroy')">
|
||||
<SmallTitle slot="title">
|
||||
{{
|
||||
mode.includes('detail')
|
||||
? '详情'
|
||||
: mode.includes('edit')
|
||||
? '编辑'
|
||||
: '新增'
|
||||
}}
|
||||
</SmallTitle>
|
||||
|
||||
<div class="drawer-body flex">
|
||||
<div class="drawer-body__content">
|
||||
<section v-for="(section, index) in sections" :key="section.key">
|
||||
<SmallTitle v-if="index != 0">{{ section.name }}</SmallTitle>
|
||||
<div class="drawer-body flex">
|
||||
<div class="drawer-body__content">
|
||||
<section v-for="(section, index) in sections" :key="section.key">
|
||||
<SmallTitle v-if="index != 0">{{ section.name }}</SmallTitle>
|
||||
|
||||
<div
|
||||
class="form-part"
|
||||
v-if="section.key == 'base'"
|
||||
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
||||
<el-skeleton v-if="!showForm" animated />
|
||||
<!-- <BaseInfoForm
|
||||
<div class="form-part" v-if="section.key == 'base'"
|
||||
style="border-bottom: 1px solid #dfdfdf; margin-bottom: 24px">
|
||||
<el-skeleton v-if="!showForm" animated />
|
||||
<!-- <BaseInfoForm
|
||||
key="drawer-dialog-form"
|
||||
v-if="showForm"
|
||||
ref="form"
|
||||
@@ -42,141 +34,87 @@
|
||||
v-model="form"
|
||||
:rows="formRows" /> -->
|
||||
|
||||
<!-- if -->
|
||||
<el-row v-if="mode.includes('detail')" style="margin-bottom: 24px">
|
||||
<el-col :span="8">
|
||||
<div
|
||||
class="title"
|
||||
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||
设备名
|
||||
</div>
|
||||
<div class="value" style="font-size: 14px">
|
||||
{{ form.equipmentName }}
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div
|
||||
class="title"
|
||||
style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||
关联表名
|
||||
</div>
|
||||
<div class="value" style="font-size: 14px">
|
||||
{{ form.plcName }}
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- else -->
|
||||
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
||||
<el-form ref="form" :model="form">
|
||||
<el-col :span="8">
|
||||
<el-form-item
|
||||
class="title"
|
||||
label="设备名"
|
||||
style="font-size: 16px; margin: 8px 0">
|
||||
<el-select
|
||||
v-model="form.equipmentId"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择设备">
|
||||
<el-option
|
||||
v-for="eq in eqList"
|
||||
:key="eq.id"
|
||||
:label="eq.name"
|
||||
:value="eq.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item
|
||||
class="title"
|
||||
label="设备关联表名"
|
||||
style="font-size: 16px; margin: 8px 0">
|
||||
<el-select
|
||||
v-model="form.plcId"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择关联表">
|
||||
<el-option
|
||||
v-for="plc in plcList"
|
||||
:key="plc.id"
|
||||
:label="plc.plcTableName"
|
||||
:value="plc.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
</div>
|
||||
<!-- if -->
|
||||
<el-row v-if="mode.includes('detail')" style="margin-bottom: 24px">
|
||||
<el-col :span="8">
|
||||
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||
设备名
|
||||
</div>
|
||||
<div class="value" style="font-size: 14px">
|
||||
{{ form.equipmentName }}
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div class="title" style="font-weight: 700; font-size: 16px; margin: 8px 0">
|
||||
关联表名
|
||||
</div>
|
||||
<div class="value" style="font-size: 14px">
|
||||
{{ form.plcName }}
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- else -->
|
||||
<el-row v-else style="margin-bottom: 24px" :gutter="20">
|
||||
<el-form ref="form" :model="form">
|
||||
<el-col :span="8">
|
||||
<el-form-item class="title" label="设备名" style="font-size: 16px; margin: 8px 0">
|
||||
<el-select v-model="form.equipmentId" filterable clearable placeholder="请选择设备">
|
||||
<el-option v-for="eq in eqList" :key="eq.id" :label="eq.name" :value="eq.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item class="title" label="设备关联表名" style="font-size: 16px; margin: 8px 0">
|
||||
<el-select v-model="form.plcId" filterable clearable placeholder="请选择关联表">
|
||||
<el-option v-for="plc in plcList" :key="plc.id" :label="plc.plcTableName"
|
||||
:value="plc.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="section.key == 'attrs'"
|
||||
style="position: relative; margin-top: 12px">
|
||||
<div
|
||||
v-if="!mode.includes('detail')"
|
||||
style="position: absolute; top: -40px; right: 0">
|
||||
<el-button @click="handleAddAttr" type="text">
|
||||
<i class="el-icon-plus"></i>
|
||||
添加参数
|
||||
</el-button>
|
||||
</div>
|
||||
<base-table
|
||||
v-loading="attrListLoading"
|
||||
:table-props="section.props"
|
||||
:page="attrQuery?.params.pageNo || 1"
|
||||
:limit="attrQuery?.params.pageSize || 10"
|
||||
:table-data="list"
|
||||
@emitFun="handleEmitFun">
|
||||
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||
<div v-if="section.key == 'attrs'" style="position: relative; margin-top: 12px">
|
||||
<div v-if="!mode.includes('detail')" style="position: absolute; top: -40px; right: 0">
|
||||
<el-button @click="handleAddAttr" type="text">
|
||||
<i class="el-icon-plus"></i>
|
||||
添加参数
|
||||
</el-button>
|
||||
</div>
|
||||
<base-table v-loading="attrListLoading" :table-props="section.props" :page="attrQuery?.params.pageNo || 1"
|
||||
:limit="attrQuery?.params.pageSize || 10" :table-data="list" @emitFun="handleEmitFun">
|
||||
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||
@emitButtonClick="handleAddAttr" -->
|
||||
<method-btn
|
||||
v-if="section.tableBtn && !mode.includes('detail')"
|
||||
slot="handleBtn"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" />
|
||||
</base-table>
|
||||
<method-btn v-if="section.tableBtn && !mode.includes('detail')" slot="handleBtn" label="操作"
|
||||
:method-list="tableBtn" @clickBtn="handleTableBtnClick" />
|
||||
</base-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="attrQuery.params.pageNo"
|
||||
:limit.sync="attrQuery.params.pageSize"
|
||||
@pagination="getAttrList" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="attrQuery.params.pageNo"
|
||||
:limit.sync="attrQuery.params.pageSize" @pagination="getAttrList" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="drawer-body__footer">
|
||||
<el-button style="" @click="handleCancel">取消</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
v-if="!mode.includes('detail')"
|
||||
@click="handleSave">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="drawer-body__footer">
|
||||
<el-button style="" @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" v-if="!mode.includes('detail')" @click="handleSave">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 属性对话框 -->
|
||||
<base-dialog
|
||||
v-if="sections[1].allowAdd"
|
||||
:dialogTitle="attrTitle"
|
||||
:dialogVisible="attrFormVisible"
|
||||
width="45%"
|
||||
:append-to-body="true"
|
||||
custom-class="baseDialog"
|
||||
@close="closeAttrForm"
|
||||
@cancel="closeAttrForm"
|
||||
@confirm="submitAttrForm">
|
||||
<!-- :disabled="mode.includes('detail')" -->
|
||||
<DialogForm
|
||||
v-if="attrFormVisible"
|
||||
ref="attrForm"
|
||||
v-model="attrForm"
|
||||
:rows="attrRows" />
|
||||
</base-dialog>
|
||||
</el-drawer>
|
||||
<!-- 属性对话框 -->
|
||||
<base-dialog v-if="sections[1].allowAdd" :dialogTitle="attrTitle" :dialogVisible="attrFormVisible" width="45%"
|
||||
:append-to-body="true" custom-class="baseDialog" @close="closeAttrForm" @cancel="closeAttrForm"
|
||||
@confirm="submitAttrForm">
|
||||
<!-- :disabled="mode.includes('detail')" -->
|
||||
<DialogForm v-if="attrFormVisible" ref="attrForm" v-model="attrForm" :data-form="attrForm"
|
||||
:rows="attrRows"
|
||||
@update="handleAttrFormUpdate"/>
|
||||
</base-dialog>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -232,7 +170,9 @@ export default {
|
||||
defaultValue: '',
|
||||
description: '',
|
||||
remark: '',
|
||||
alarmContent: '',
|
||||
alarmContent: '',
|
||||
displayTip: false,
|
||||
alarmTip: false,
|
||||
},
|
||||
attrFormVisible: false,
|
||||
attrRows: [
|
||||
@@ -342,7 +282,27 @@ export default {
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
[
|
||||
{
|
||||
switch: true,
|
||||
label: '是否展示',
|
||||
prop: 'displayTip',
|
||||
bind: {
|
||||
'active-value': true,
|
||||
'inactive-value': false,
|
||||
},
|
||||
},
|
||||
{
|
||||
switch: true,
|
||||
label: '超出阈值是否报警',
|
||||
prop: 'alarmTip',
|
||||
bind: {
|
||||
'active-value': true,
|
||||
'inactive-value': false,
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
input: true,
|
||||
@@ -436,7 +396,24 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
methods: {
|
||||
handleAttrFormUpdate(updatedForm) {
|
||||
console.log('updatedForm', updatedForm);
|
||||
|
||||
// 只同步需要的字段,避免覆盖其他数据
|
||||
this.attrForm = {
|
||||
...this.attrForm,
|
||||
...updatedForm,
|
||||
// 确保开关值是布尔类型(双重保险)
|
||||
displayTip: Boolean(updatedForm.displayTip),
|
||||
alarmTip: Boolean(updatedForm.alarmTip),
|
||||
collection: Number(updatedForm.collection) // 采集开关保持数字类型
|
||||
};
|
||||
console.log('开关值同步:', {
|
||||
displayTip: this.attrForm.displayTip,
|
||||
alarmTip: this.attrForm.alarmTip
|
||||
});
|
||||
},
|
||||
handleTableBtnClick({ type, data }) {
|
||||
switch (type) {
|
||||
case 'edit':
|
||||
@@ -502,7 +479,8 @@ export default {
|
||||
name: '',
|
||||
plcParamName: '',
|
||||
unit: '',
|
||||
collection: 1,
|
||||
collection: 1,
|
||||
|
||||
minValue: '',
|
||||
maxValue: '',
|
||||
defaultValue: '',
|
||||
@@ -510,7 +488,9 @@ export default {
|
||||
remark: '',
|
||||
equipmentParamType: '',
|
||||
productionParamType: '',
|
||||
alarmContent: '',
|
||||
alarmContent: '',
|
||||
displayTip: false,
|
||||
alarmTip: false,
|
||||
};
|
||||
this.attrTitle = '添加参数绑定信息';
|
||||
this.attrFormVisible = true;
|
||||
@@ -523,8 +503,15 @@ export default {
|
||||
method: 'get',
|
||||
params: { id: attrId },
|
||||
});
|
||||
if (res.code == 0) {
|
||||
this.attrForm = res.data;
|
||||
if (res.code == 0) {
|
||||
console.log('res.data', res.data);
|
||||
|
||||
this.attrForm = {
|
||||
...res.data,
|
||||
// // 强制转为数字类型,避免字符串类型导致绑定失败
|
||||
// displayTip: Number(res.data.displayTip) || 0,
|
||||
// alarmTip: Number(res.data.alarmTip) || 0
|
||||
};
|
||||
this.attrTitle = '编辑参数绑定信息';
|
||||
this.attrFormVisible = true;
|
||||
}
|
||||
@@ -563,7 +550,8 @@ export default {
|
||||
this.$refs['attrForm'].validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log('this.attrForm', this.attrForm);
|
||||
|
||||
const isEdit = this.attrForm.id != null;
|
||||
this.attrFormSubmitting = true;
|
||||
@@ -583,8 +571,9 @@ export default {
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getAttrList();
|
||||
this.shouldRefreshPageView = true;
|
||||
this.shouldRefreshPageView = true;
|
||||
this.getAttrList();
|
||||
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export default {
|
||||
id: null,
|
||||
code: '',
|
||||
materialId: '',
|
||||
price: '',
|
||||
price: undefined,
|
||||
startTime: new Date().getTime(),
|
||||
endTime: null,
|
||||
remark: '',
|
||||
|
||||
Reference in New Issue
Block a user