调整指令字典中条件参数

This commit is contained in:
zyy 2020-01-08 17:21:17 +08:00
parent c29033177d
commit d79641e0e4
5 changed files with 37 additions and 36 deletions

View File

@ -6,6 +6,11 @@
<div class="param-title">条件参数:</div>
<el-table :data="formModel.conditionList" border class="param-table">
<el-table-column prop="name" label="参数名" />
<el-table-column prop="expression" label="运算">
<template slot-scope="scope">
{{ scope.row.expression=="neq"?'不等于':'等于' }}
</template>
</el-table-column>
<el-table-column prop="value" label="参数值" />
<el-table-column :label="this.$t('global.operate')" width="180">
<template slot-scope="scope">
@ -51,7 +56,7 @@ import { createCommand, editCommand, getCommandDetail } from '@/api/management/d
import CommandEdit from './editParam';
import { getLineCodeList } from '@/api/management/mapline';
import EditCondition from './editCondition';
import CommandEnum from '@/scripts/cmdPlugin/CommandEnum';
import CMD from '@/scripts/cmdPlugin/CommandEnum';
export default {
name: 'DictionaryEdit',
@ -137,18 +142,12 @@ export default {
if (this.$route.query.id) {
getCommandDetail(this.$route.query.id).then(res => {
this.formModel = res.data;
if (!this.formModel.paramList) {
this.formModel.paramList = [];
}
if (!this.formModel.conditionList) {
this.formModel.conditionList = [];
}
this.operateList = Object.values(CommandEnum[this.formModel.operateObject]);
this.operateList = Object.values(CMD[this.formModel.operateObject]);
});
}
},
deviceChange(code) { //
this.operateList = Object.values(CommandEnum[code]);
this.operateList = Object.values(CMD[code]);
},
doSave() {
this.$refs.dataform.validateForm(() => {

View File

@ -23,8 +23,13 @@ export default {
dialogVisible: false,
formModel: {
name: '',
value: ''
}
value: '',
expression:''
},
expressionList:[
{label:'等于',value:'eq'},
{label:'不等于', value:'neq'},
]
};
},
computed: {
@ -33,6 +38,7 @@ export default {
labelWidth: '100px',
items: [
{ prop: 'name', label: '参数名', type: 'text' },
{ prop: 'expression', label:'操作符', type: 'select',options:this.expressionList},
{ prop: 'value', label: '参数值', type: 'text' }
]
};
@ -45,6 +51,9 @@ export default {
],
value: [
{ required: true, message: '请输入内容', trigger: 'blur' }
],
expression:[
{ required: true, message: '请选择操作符', trigger: 'change' }
]
};
},
@ -62,7 +71,8 @@ export default {
if (data) {
this.formModel = {
name: data.name,
value: data.value
value: data.value,
expression:data.expression
};
}
},
@ -79,7 +89,8 @@ export default {
getData() {
return {
name: this.formModel.name,
value: this.formModel.value
value: this.formModel.value,
expression:this.formModel.expression,
};
},
create() {

View File

@ -33,7 +33,6 @@ export default {
labelWidth: '100px',
items: [
{ prop: 'name', label: '参数名', type: 'text' }
// { prop: 'name', label: '', type: 'select', options: this.taskStatusList }
]
};
return form;
@ -41,7 +40,7 @@ export default {
rules() {
return {
name: [
{ required: true, message: '请选择', trigger: 'change' }
{ required: true, message: '请输入内容', trigger: 'blur' }
]
};
},

View File

@ -8,8 +8,8 @@
<script>
import { getCommandList, delCommand } from '@/api/management/dictionary';
import { getLineCodeList } from '@/api/management/mapline';
import ShowCondition from './showCondition';
import CommandEnum from '@/scripts/cmdPlugin/CommandEnum';
import ShowCondition from './showCondition';
export default {
name: 'CommandDictionary',
@ -68,28 +68,28 @@ export default {
prop: 'controlMode',
type: 'tagMore',
columnValue: (row) => { return this.$convertField(row.controlMode, this.$ConstSelect.controlMode, ['value', 'label'], true); },
tagType: (row) => { return 'success'; }
tagType: (row) => { return 'warning'; }
},
{
title: this.$t('system.deviceType'), //
prop: 'operateObject',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.operateObject, this.$ConstSelect.deviceTypeList, ['value', 'label']); },
tagType: (row) => { return 'success'; }
tagType: (row) => { return ''; }
},
{
title: this.$t('system.instructionType'), //
prop: 'operate',
type: 'tag',
columnValue: (row) => { return this.convertField(row.operate, row.operateObject, ['value', 'label']); },
tagType: (row) => { return 'success'; }
columnValue: (row) => { return this.$convertField(row.operate, Object.values(CommandEnum[row.operateObject]), ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('system.parameterName'), //
prop: 'paramList',
type: 'tagMore',
columnValue: (row) => { return this.replace(row.paramList); },
tagType: (row) => { return 'success'; }
tagType: (row) => { return 'warning'; }
},
{
type: 'button',
@ -98,7 +98,8 @@ export default {
buttons: [
{
name: '查看条件参数',
handleClick: this.showCondition
handleClick: this.showCondition,
showControl: (row) => { return row.conditionList.length; }
},
{
name: this.$t('global.edit'),
@ -148,20 +149,6 @@ export default {
}
return getCommandList(params);
},
convertField(fieldValue, operateObject, converFormat) {
if (CommandEnum && CommandEnum[operateObject]) {
const enumList = Object.values(CommandEnum[operateObject]);
if (enumList && converFormat && converFormat.length >= 2) {
const value = converFormat[0];
const label = converFormat[1];
for (let i = 0; i < enumList.length; i++) {
if (fieldValue == enumList[i][value]) {
return enumList[i][label];
}
}
}
}
},
replace(fieldValue) {
const arr = [];
if (fieldValue && fieldValue.length) {

View File

@ -2,6 +2,11 @@
<el-dialog v-dialogDrag title="条件参数" :visible.sync="dialogVisible" width="400px" :before-close="handleClose" center :close-on-click-modal="false">
<el-table :data="conditionList" border class="param-table">
<el-table-column prop="name" label="参数名" />
<el-table-column prop="expression" label="运算">
<template slot-scope="scope">
{{ scope.row.expression=="neq"?'不等于':'等于' }}
</template>
</el-table-column>
<el-table-column prop="value" label="参数值" />
</el-table>
<span slot="footer" class="dialog-footer">