projects/mes-test #133

Merged
gtz217 merged 281 commits from projects/mes-test into projects/mes 2023-11-30 09:11:34 +08:00
12 changed files with 733 additions and 111 deletions
Showing only changes of commit 216aa6291d - Show all commits

View File

@ -277,7 +277,6 @@ export default {
} else if (opt.url) { } else if (opt.url) {
// dependswatcher // dependswatcher
if (opt.depends) { if (opt.depends) {
console.log('[handleOptions] setting watch');
this.$watch( this.$watch(
() => this.form[opt.depends], () => this.form[opt.depends],
(id) => { (id) => {
@ -300,7 +299,7 @@ export default {
}); });
}, },
{ {
immediate: true, immediate: false,
} }
); );
return; return;

View File

@ -32,9 +32,28 @@ export default {
updateUrl: '', updateUrl: '',
addUrl: '', addUrl: '',
pageUrl: '', pageUrl: '',
infoUrl: '',
basePath: '',
form: {} form: {}
}; };
}, },
computed: {
addPath() {
return this.basePath + '/create'
},
updatePath() {
return this.basePath + '/update'
},
deletePath() {
return this.basePath + '/delete'
},
infoPath() {
return this.basePath + '/get'
},
pagePath() {
return this.basePath + '/page'
}
},
methods: { methods: {
// utils // utils
http(url, method, payload) { http(url, method, payload) {
@ -46,16 +65,16 @@ export default {
}) })
}, },
put(payload) { put(payload) {
return this.http(this.updateUrl, 'put', payload); return this.http(this.updateUrl == '' ? this.updatePath : this.updateUrl, 'put', payload);
}, },
post(payload) { post(payload) {
return this.http(this.addUrl, 'post', payload); return this.http(this.addUrl == '' ? this.addPath : this.addUrl, 'post', payload);
}, },
recv(payload) { recv(payload) {
return this.http(this.pageUrl, 'get', payload); return this.http(this.pageUrl == '' ? this.pagePath : this.pageUrl, 'get', payload);
}, },
info(payload) { info(payload) {
return this.http(this.infoUrl, 'get', payload); return this.http(this.infoUrl == '' ? this.infoPath : this.infoUrl, 'get', payload);
}, },

View File

@ -1,22 +1,48 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" /> <SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick" />
<!-- 列表 --> <!-- 列表 -->
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list" <base-table
:table-props="tableProps"
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-data="list"
@emitFun="handleEmitFun"> @emitFun="handleEmitFun">
<method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn" <method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
:width="120"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" /> @clickBtn="handleTableBtnClick" />
</base-table> </base-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" /> @pagination="getList" />
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<base-dialog :dialogTitle="title" :dialogVisible="open" @close="cancel" @cancel="cancel" @confirm="submitForm"> <base-dialog
<DialogForm v-if="open" ref="form" v-model="form" :has-files="true" :rows="rows" /> :dialogTitle="title"
:dialogVisible="open"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm
v-if="open"
ref="form"
v-model="form"
:has-files="false"
:rows="rows" />
</base-dialog> </base-dialog>
</div> </div>
</template> </template>
@ -25,32 +51,24 @@
import moment from 'moment'; import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
import {
createEquipmentType,
updateEquipmentType,
deleteEquipmentType,
getEquipmentType,
getEquipmentTypePage,
exportEquipmentTypeExcel,
} from '@/api/base/equipmentType';
// import { getAccessToken } from '@/utils/auth'; // import { getAccessToken } from '@/utils/auth';
export default { export default {
name: 'EquipmentType', name: 'EquipmentLineBind',
components: {}, components: {},
mixins: [basicPageMixin], mixins: [basicPageMixin],
data() { data() {
return { return {
searchBarKeys: ['name'], basePath: '/base/core-equipment-bind-section',
searchBarKeys: ['equipmentName', 'productionLineId'],
tableBtn: [ tableBtn: [
this.$auth.hasPermi('base:core-equipment-type:update') this.$auth.hasPermi('base:core-equipment-bind-section:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '修改', btnName: '修改',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:core-equipment-type:delete') this.$auth.hasPermi('base:core-equipment-bind-section:delete')
? { ? {
type: 'delete', type: 'delete',
btnName: '删除', btnName: '删除',
@ -65,24 +83,38 @@ export default {
width: 180, width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'), filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
}, },
{ prop: 'name', label: '设备类型名称' }, { prop: 'productionLineName', label: '产线名称' },
{ prop: 'code', label: '检测类型编码' }, { prop: 'workshopSectionName', label: '工段名称' },
{ prop: 'remark', label: '备注' }, { prop: 'equipmentName', label: '设备名称' },
{ prop: 'sort', label: '工段中排序' },
{
prop: 'lineDataType',
label: '产线统计类型',
filter: (val) =>
val != null ? ['无类型', '进片数量统计', '出片数量统计'][val] : '',
},
{
prop: 'sectionDataType',
label: '工段统计类型',
filter: (val) =>
val != null ? ['无类型', '进片数量统计', '出片数量统计'][val] : '',
},
// { prop: 'remark', label: '' },
], ],
searchBarFormConfig: [ searchBarFormConfig: [
{ {
type: 'select', type: 'select',
label: '产线', label: '产线',
placeholder: '请选择产线', placeholder: '请选择产线',
param: 'lineId', param: 'productionLineId',
selectOptions: [], selectOptions: [],
filterable: true filterable: true,
}, },
{ {
type: 'input', type: 'input',
label: '设备名', label: '设备名',
placeholder: '请输入设备名称', placeholder: '请输入设备名称',
param: 'name', param: 'equipmentName',
}, },
{ {
type: 'button', type: 'button',
@ -94,7 +126,7 @@ export default {
type: 'separate', type: 'separate',
}, },
{ {
type: this.$auth.hasPermi('base:core-equipment-type:create') type: this.$auth.hasPermi('base:core-equipment-bind-section:create')
? 'button' ? 'button'
: '', : '',
btnName: '新增', btnName: '新增',
@ -114,38 +146,61 @@ export default {
rows: [ rows: [
[ [
{ {
input: true, select: true,
label: '设备类型名称', label: '产线',
prop: 'name', prop: 'productionLineId',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }], rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// bind: { url: '/base/core-production-line/listAll',
// disabled: true, // some condition, like detail mode... bind: { clearable: true, filterable: true },
// } // watch: 'workshopSectionId'
}, },
{ {
input: true, select: true,
label: '设备类型编码', label: '工段',
prop: 'code', prop: 'workshopSectionId',
url: '/base/core-equipment-type/getCode', depends: 'productionLineId',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
bind: { clearable: true, filterable: true },
url: '/base/core-workshop-section/listByParentId',
}, },
], ],
[ [
{ {
select: true, select: true,
label: '父类', label: '设备',
prop: 'parentId', prop: 'equipmentId',
url: '/base/core-equipment-type/page?pageNo=1&pageSize=100', rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
bind: { clearable: true, filterable: true },
url: '/base/core-equipment/listAll',
},
{
input: true,
label: '工段排序',
prop: 'sort',
}, },
{},
], ],
[ [
{ {
upload: true, select: true,
label: '上传资料', options: [
prop: 'files', { label: '无类型', value: 0 },
{ label: '进片数量统计', value: 1 },
{ label: '出片数量统计', value: 2 },
],
label: '产线统计类型',
prop: 'lineDataType',
},
{
select: true,
options: [
{ label: '无类型', value: 0 },
{ label: '进片数量统计', value: 1 },
{ label: '出片数量统计', value: 2 },
],
label: '工段统计类型',
prop: 'sectionDataType',
}, },
], ],
[{ input: true, label: '备注', prop: 'remark' }],
], ],
// //
open: false, open: false,
@ -153,22 +208,15 @@ export default {
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
name: '', equipmentName: null,
productionLineId: null,
}, },
// //
form: {}, form: {},
}; };
}, },
watch: {
// form: {
// handler: function (val, oldVal) {
// console.log('[watch:form]', val, oldVal);
// },
// deep: true,
// },
},
created() { created() {
this.initSearchOptions() this.initSearchOptions();
this.getList(); this.getList();
}, },
methods: { methods: {
@ -191,11 +239,18 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
// //
getEquipmentTypePage(this.queryParams).then((response) => { this.recv(this.queryParams).then(({ code, data }) => {
this.list = response.data.list; // if (code == 0) {
this.total = response.data.total; this.list = data.list;
this.total = data.total;
this.loading = false; this.loading = false;
// }
}); });
// .catch(err => {
// this.list = [];
// this.total = 0;
// this.loading = false;
// })
}, },
/** 取消按钮 */ /** 取消按钮 */
cancel() { cancel() {
@ -206,10 +261,17 @@ export default {
reset() { reset() {
this.form = { this.form = {
id: undefined, id: undefined,
code: undefined, productionLineId: undefined,
name: undefined, //
parentId: undefined, workshopSectionId: undefined,
remark: undefined, //
equipmentId: undefined,
//
sort: undefined,
// 线
lineDataType: undefined,
//
sectionDataType: undefined,
}; };
this.resetForm('form'); this.resetForm('form');
}, },
@ -227,16 +289,16 @@ export default {
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = '添加设备类型'; this.title = '添加设备工段绑定';
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const id = row.id; const id = row.id;
getEquipmentType(id).then((response) => { this.info({ id }).then(({ code, data }) => {
this.form = response.data; this.form = data;
this.open = true; this.open = true;
this.title = '修改设备类型'; this.title = '修改设备工段绑定';
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -247,16 +309,15 @@ export default {
} }
// //
if (this.form.id != null) { if (this.form.id != null) {
updateEquipmentType(this.form).then((response) => { this.put(this.form).then(({ code, data }) => {
this.$modal.msgSuccess('修改成功'); this.$modal.msgSuccess('修改成功');
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
return; return;
} }
// this.post(this.form).then(({ code, data }) => {
createEquipmentType(this.form).then((response) => { this.$modal.msgSuccess('修改成功');
this.$modal.msgSuccess('新增成功');
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -266,7 +327,7 @@ export default {
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id;
this.$modal this.$modal
.confirm('是否确认删除设备类型"' + row.name + '"?') .confirm('是否确认删除绑定"' + row.name + '"?')
.then(function () { .then(function () {
return deleteEquipmentType(id); return deleteEquipmentType(id);
}) })
@ -283,13 +344,13 @@ export default {
params.pageNo = undefined; params.pageNo = undefined;
params.pageSize = undefined; params.pageSize = undefined;
this.$modal this.$modal
.confirm('是否确认导出所有设备类型数据项?') .confirm('是否确认导出所有设备工段绑定?')
.then(() => { .then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportEquipmentTypeExcel(params); // return exportEquipmentTypeExcel(params);
}) })
.then((response) => { .then((response) => {
this.$download.excel(response, '设备类型.xls'); this.$download.excel(response, '设备工段绑定.xls');
this.exportLoading = false; this.exportLoading = false;
}) })
.catch(() => {}); .catch(() => {});

View File

@ -21,7 +21,7 @@
:disabled="disabled" :disabled="disabled"
v-model="dataForm.code" v-model="dataForm.code"
@change="$emit('update', dataForm)" @change="$emit('update', dataForm)"
placeholder="请输入工段排序" /> placeholder="请输入报警编码" />
</el-form-item> </el-form-item>
<!-- <!--
<el-form-item <el-form-item

View File

@ -58,7 +58,7 @@
queryParams: { id: alarmForm.id }, queryParams: { id: alarmForm.id },
}, },
{ {
name: '属性列表', name: '报警明细',
key: 'attrs', key: 'attrs',
props: drawerListProps, props: drawerListProps,
url: '/base/equipment-group-alarm/page', url: '/base/equipment-group-alarm/page',
@ -72,13 +72,13 @@
pageSize: 10, pageSize: 10,
}, },
tableBtn: [ tableBtn: [
this.$auth.hasPermi('base:equipment-group:update') this.$auth.hasPermi('equipment:alarm-group:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '修改', btnName: '修改',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:equipment-group:delete') this.$auth.hasPermi('equipment:alarm-group:delete')
? { ? {
type: 'delete', type: 'delete',
btnName: '删除', btnName: '删除',
@ -119,19 +119,19 @@ export default {
editMode: '', editMode: '',
searchBarKeys: ['name', 'code'], searchBarKeys: ['name', 'code'],
tableBtn: [ tableBtn: [
this.$auth.hasPermi('base:equipment-group:update') this.$auth.hasPermi('equipment:alarm-group:update')
? { ? {
type: 'detail', type: 'detail',
btnName: '查看报警', btnName: '查看报警',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:equipment-group:update') this.$auth.hasPermi('equipment:alarm-group:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '修改', btnName: '修改',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:equipment-group:delete') this.$auth.hasPermi('equipment:alarm-group:delete')
? { ? {
type: 'delete', type: 'delete',
btnName: '删除', btnName: '删除',
@ -193,8 +193,8 @@ export default {
label: '设备分组编码', label: '设备分组编码',
prop: 'code', prop: 'code',
// url: '/base/core-equipment/getCode', // url: '/base/core-equipment/getCode',
} },
] ],
], ],
drawerListProps: [ drawerListProps: [
{ {
@ -250,7 +250,7 @@ export default {
type: 'separate', type: 'separate',
}, },
{ {
type: this.$auth.hasPermi('base:equipment-group:create') type: this.$auth.hasPermi('equipment:alarm-group:create')
? 'button' ? 'button'
: '', : '',
btnName: '新增', btnName: '新增',
@ -259,7 +259,7 @@ export default {
color: 'success', color: 'success',
}, },
// { // {
// type: this.$auth.hasPermi('base:equipment-group:export') ? 'button' : '', // type: this.$auth.hasPermi('equipment:alarm-group:export') ? 'button' : '',
// btnName: '', // btnName: '',
// name: 'export', // name: 'export',
// color: 'warning', // color: 'warning',
@ -375,7 +375,7 @@ export default {
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = '添加设备分组(用于同类型不同厂家的设备区分)'; this.title = '添加设备分组';
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
@ -384,7 +384,7 @@ export default {
getEquipmentGroup(id).then((response) => { getEquipmentGroup(id).then((response) => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = '修改设备分组(用于同类型不同厂家的设备区分)'; this.title = '修改设备分组';
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -445,18 +445,13 @@ export default {
params.pageNo = undefined; params.pageNo = undefined;
params.pageSize = undefined; params.pageSize = undefined;
this.$modal this.$modal
.confirm( .confirm('是否确认导出所有设备分组数据项?')
'是否确认导出所有设备分组(用于同类型不同厂家的设备区分)数据项?'
)
.then(() => { .then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportEquipmentGroupExcel(params); return exportEquipmentGroupExcel(params);
}) })
.then((response) => { .then((response) => {
this.$download.excel( this.$download.excel(response, '设备分组.xls');
response,
'设备分组(用于同类型不同厂家的设备区分).xls'
);
this.exportLoading = false; this.exportLoading = false;
}) })
.catch(() => {}); .catch(() => {});

View File

@ -118,19 +118,19 @@ export default {
return { return {
searchBarKeys: ['groupId', 'equipmentName'], searchBarKeys: ['groupId', 'equipmentName'],
tableBtn: [ tableBtn: [
this.$auth.hasPermi('base:equipment-bind-group:update') this.$auth.hasPermi('equipment:bind-group:update')
? { ? {
type: 'detail', type: 'detail',
btnName: '查看报警', btnName: '查看报警',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:equipment-bind-group:update') this.$auth.hasPermi('equipment:bind-group:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '修改', btnName: '修改',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:equipment-bind-group:delete') this.$auth.hasPermi('equipment:bind-group:delete')
? { ? {
type: 'delete', type: 'delete',
btnName: '删除', btnName: '删除',
@ -199,7 +199,7 @@ export default {
type: 'separate', type: 'separate',
}, },
{ {
type: this.$auth.hasPermi('base:equipment-bind-group:create') type: this.$auth.hasPermi('equipment:bind-group:create')
? 'button' ? 'button'
: '', : '',
btnName: '新增', btnName: '新增',

View File

@ -0,0 +1,187 @@
<!--
filename: dialogForm.vue
author: liubin
date: 2023-09-11 15:55:13
description: DialogForm for equipmentBindSection only
-->
<template>
<el-form
ref="form"
:model="dataForm"
label-width="100px"
v-loading="formLoading">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="报警编码"
prop="code"
:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-input
:disabled="disabled"
v-model="dataForm.code"
@change="$emit('update', dataForm)"
placeholder="请输入工段排序" />
</el-form-item>
<!--
<el-form-item
label="报警编码"
prop="code"
:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-select
v-model="dataForm.code"
placeholder="请选择产线"
@change="handleProductlineChange">
<el-option
v-for="opt in productionLineList"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item> -->
</el-col>
<el-col :span="12">
<el-form-item
label="报警类型"
prop="type"
:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-select
v-model="dataForm.type"
:disabled="disabled"
placeholder="请选择报警类型"
@change="$emit('update', dataForm)">
<el-option
v-for="opt in [
{ label: '布尔型', value: 2 },
{ label: '字符型', value: 1 },
]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="报警级别"
prop="grade"
:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-select
:disabled="disabled"
v-model="dataForm.grade"
placeholder="请选择报警级别"
@change="$emit('update', dataForm)">
<el-option
v-for="opt in getDictDatas(DICT_TYPE.EQU_ALARM_LEVEL)"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
v-if="+dataForm.type == 1"
label="设备报警编码"
prop="alarmCode">
<el-input
:disabled="disabled"
v-model="dataForm.alarmCode"
@change="$emit('update', dataForm)"
placeholder="请输入设备报警编码" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="参数列名"
prop="plcParamName"
:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-input
:disabled="disabled"
v-model="dataForm.plcParamName"
placeholder="请输入参数列名"
@change="$emit('update', dataForm)"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="报警内容"
prop="alarmContent"
:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-input
:disabled="disabled"
v-model="dataForm.alarmContent"
placeholder="请输入报警内容"
@change="$emit('update', dataForm)"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
name: 'DialogForm',
model: {
prop: 'dataForm',
event: 'update',
},
emits: ['update'],
components: {},
props: {
dataForm: {
type: Object,
default: () => ({}),
},
disabled: {
type: Boolean,
default: false,
},
},
data() {
return {
formLoading: true,
};
},
mounted() {
this.getCode('/base/equipment-group-alarm/getCode').then((code) => {
this.formLoading = false;
this.$emit('update', {
...this.dataForm,
code,
});
});
},
methods: {
/** 模拟透传 ref */
validate(cb) {
return this.$refs.form.validate(cb);
},
resetFields(args) {
return this.$refs.form.resetFields(args);
},
async handleProductlineChange(id) {
await this.getWorksectionList(id);
this.dataForm.workshopSectionId = null;
this.$emit('update', this.dataForm);
},
async getCode(url) {
const response = await this.$axios(url);
return response.data;
},
},
};
</script>
<style scoped lang="scss">
.el-date-editor,
.el-select {
width: 100%;
}
</style>

View File

@ -0,0 +1,361 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick" />
<!-- 列表 -->
<base-table
:table-props="tableProps"
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-data="list"
@emitFun="handleEmitFun">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
:width="120"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 对话框(添加 / 修改) -->
<base-dialog
:dialogTitle="title"
:dialogVisible="open"
width="736px"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" v-model="form" :rows="rows" />
</base-dialog>
</div>
</template>
<script>
import {
createEquipmentGroupAlarm,
updateEquipmentGroupAlarm,
deleteEquipmentGroupAlarm,
getEquipmentGroupAlarm,
getEquipmentGroupAlarmPage,
exportEquipmentGroupAlarmExcel,
} from '@/api/base/equipmentGroupAlarm';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
import moment from 'moment';
import { publicFormatter } from '@/utils/dict';
import DialogForm from './dialogForm.vue';
export default {
name: 'EquipmentGroupAlarm',
components: { DialogForm },
mixins: [basicPageMixin],
data() {
return {
searchBarKeys: [''],
tableBtn: [
this.$auth.hasPermi('base:equipment-group-alarm:update')
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('base:equipment-group-alarm:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableProps: [
{
prop: 'createTime',
label: '添加时间',
fixed: true,
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{ width: 240, prop: 'code', label: '报警编码' },
{
prop: 'type',
label: '报警类型',
filter: (val) =>
val != null ? ['-', '字符型', '布尔型', '-'][val] : '-',
},
{
prop: 'grade',
label: '报警级别',
filter: publicFormatter(this.DICT_TYPE.EQU_ALARM_LEVEL),
},
{ prop: 'alarmCode', label: '设备报警编码' },
{ prop: 'plcParamName', label: '参数列名' },
{ prop: 'alarmContent', label: '报警内容' },
],
searchBarFormConfig: [
{
type: 'input',
label: '设备分组编码',
width: '220',
placeholder: '/',
param: 'equipmentGroupCode',
defaultSelect: null,
disabled: true,
},
{
type: 'input',
label: '设备分组名称',
placeholder: '/',
param: 'equipmentGroupName',
defaultSelect: null,
disabled: true,
},
{
type: this.$auth.hasPermi('base:equipment-group-alarm:create')
? 'button'
: '',
btnName: '新增',
name: 'add',
plain: true,
color: 'success',
},
],
rows: [
[
{
input: true,
label: '报警编码', //
prop: 'code',
url: '/base/equipment-group-alarm/getCode',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
{
select: true,
label: '报警类型', //
prop: 'type',
options: [
{ label: '布尔型', value: 2 },
{ label: '字符型', value: 1 },
],
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
],
[
{
select: true,
label: '报警级别', //
prop: 'grade',
options: this.getDictDatas(this.DICT_TYPE.EQU_ALARM_LEVEL),
},
{
input: true,
label: '设备报警编码', //
prop: 'alarmCode',
},
],
[
{
input: true,
label: '参数列名', //
prop: 'plcParamName',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
{
input: true,
label: '报警内容',
prop: 'alarmContent',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
],
],
//
open: false,
//
queryParams: {
pageNo: 1,
pageSize: 10,
equipmentGroupId: null,
},
//
form: {
id: null,
equipmentGroupId: null,
code: null,
type: null,
grade: null,
alarmCode: null,
alarmContent: null,
plcParamName: null,
},
// //
// rules: {
// equipmentGroupId: [{ required: true, message: "IDbase_equipment_group", trigger: "blur" }],
// type: [{ required: true, message: ":1.2.", trigger: "change" }],
// alarmContent: [{ required: true, message: " ", trigger: "blur" }],
// plcParamName: [{ required: true, message: "plc_param_name", trigger: "blur" }],
// }
};
},
// watch: {
// $route(value) {
// console.log('new route info', value)
// }
// },
// created() {
// this.getList();
// },
activated() {
//
const { equipmentGroupName, equipmentGroupCode, equipmentGroupId } =
this.$route.params;
this.setSearchBarFormValue('equipmentGroupName', equipmentGroupName);
this.setSearchBarFormValue('equipmentGroupCode', equipmentGroupCode);
this.queryParams.equipmentGroupId = equipmentGroupId;
// if (!equipmentGroupId) this.getList(); //
this.getList();
},
deactivated() {
this.setSearchBarFormValue('equipmentGroupName', null);
this.setSearchBarFormValue('equipmentGroupCode', null);
this.queryParams.equipmentGroupId = null;
},
methods: {
/** 设置 searchBarForm 的默认值 - 用得比较少 */
setSearchBarFormValue(param, value) {
this.searchBarFormConfig.forEach((config) => {
if (config.param == param) {
config.defaultSelect = value;
}
});
},
/** 查询列表 */
getList() {
this.loading = true;
//
getEquipmentGroupAlarmPage(this.queryParams).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: null,
equipmentGroupId: null,
code: null,
type: null,
grade: null,
alarmCode: null,
alarmContent: null,
plcParamName: null,
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
if (this.queryParams.equipmentGroupId == null)
return this.$message.error('没有检测到设备分组信息');
this.reset();
this.open = true;
this.title = '添加设备分组报警明细';
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
getEquipmentGroupAlarm(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = '修改设备分组报警明细';
});
},
/** 提交按钮 */
submitForm() {
this.$refs['form'].validate((valid) => {
if (!valid) {
return;
}
//
if (this.form.id != null) {
updateEquipmentGroupAlarm({
...this.form,
equipmentGroupId: this.queryParams.equipmentGroupId,
}).then((response) => {
this.$modal.msgSuccess('修改成功');
this.open = false;
this.getList();
});
return;
}
//
createEquipmentGroupAlarm({
...this.form,
equipmentGroupId: this.queryParams.equipmentGroupId,
}).then((response) => {
this.$modal.msgSuccess('新增成功');
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal
.confirm('是否确认删除该报警?')
.then(function () {
return deleteEquipmentGroupAlarm(id);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
//
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal
.confirm('是否确认导出所有设备分组报警明细数据项?')
.then(() => {
this.exportLoading = true;
return exportEquipmentGroupAlarmExcel(params);
})
.then((response) => {
this.$download.excel(response, '设备分组报警明细.xls');
this.exportLoading = false;
})
.catch(() => {});
},
},
};
</script>