信号量管理
This commit is contained in:
@ -60,9 +60,10 @@ export function optionDel(id) {
|
||||
}
|
||||
|
||||
// 获取选项下拉
|
||||
export function select() {
|
||||
export function select(params) {
|
||||
return request({
|
||||
url: '/system/signal/select',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
@ -42,7 +42,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="signalName" align="center" label="信号名称">
|
||||
</el-table-column>
|
||||
<el-table-column prop="signalValue" align="center" label="信号量">
|
||||
<el-table-column align="center" label="信号量">
|
||||
<template slot-scope="scope">{{ scope.row.status == 1 ? scope.row.signalValue : '无' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="signalValueRange" align="center" label="信号量范围">
|
||||
</el-table-column>
|
||||
@ -50,8 +51,12 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="signalType" align="center" label="类型">
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" align="center" label="备注">
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300px">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="scope.row.status == 2" size="mini" type="text" icon="el-icon-edit" @click="handleOptionUpdate(scope.row)">
|
||||
信号量选项</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button class="text-danger" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
@ -70,7 +75,13 @@
|
||||
<el-form-item label="信号名称" prop="signalName">
|
||||
<el-input v-model="form.signalName" placeholder="请输入信号名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="信号量" prop="signalValue">
|
||||
<el-form-item label="信号量选项" prop="status">
|
||||
<el-select :disabled="!!form.id" v-model="form.status" clearable placeholder="请选择">
|
||||
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.status == 1" label="信号量" prop="signalValue">
|
||||
<el-input v-model="form.signalValue" placeholder="请输入信号量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="信号量范围" prop="signalValueRange">
|
||||
@ -82,12 +93,48 @@
|
||||
<el-form-item label="类型">
|
||||
<el-input v-model="form.signalType" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog :title="optionForm.signalName + ' 信号量选项编辑'" :visible.sync="optionOpen">
|
||||
<el-form ref="optionForm" :model="optionForm" label-width="100px" style="max-height: 500px;overflow: auto;">
|
||||
<section v-for="(item, index) in optionForm.optionList" :key="index">
|
||||
<el-row>
|
||||
<el-col :span="7">
|
||||
<el-form-item label="选项名称" :prop="'optionList.' + index + '.optionName'"
|
||||
:rules="{ required: true, message: '选项不能为空', trigger: 'blur' }">
|
||||
<el-input v-model="item.optionName"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="7">
|
||||
<el-form-item label="选项值" :prop="'optionList.' + index + '.optionVal'"
|
||||
:rules="{ required: true, message: '选项值不能为空', trigger: 'blur' }">
|
||||
<el-input v-model="item.optionVal"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="选项值范围">
|
||||
<el-input v-model="item.signalValueRange"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col class="text-center" :span="2">
|
||||
<el-button type="text" @click.prevent="removeOption(item)">移除</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</section>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="info" @click="addOption">新 增</el-button>
|
||||
<el-button type="primary" @click="submitOption">确 定</el-button>
|
||||
<el-button @click="optionOpen = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@ -101,7 +148,7 @@ export default {
|
||||
ids: [],
|
||||
// 表格数据
|
||||
tableData: [],
|
||||
// 显示搜索条件
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
@ -116,6 +163,10 @@ export default {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
},
|
||||
statusList: [
|
||||
{ 'label': '无选项', 'value': 1 },
|
||||
{ 'label': '有选项', 'value': 2 }
|
||||
],
|
||||
rules: {
|
||||
signalCode: [
|
||||
{ required: true, message: "信号编码不能为空", trigger: "blur" },
|
||||
@ -123,13 +174,22 @@ export default {
|
||||
signalName: [
|
||||
{ required: true, message: "信号名称不能为空", trigger: "blur" },
|
||||
],
|
||||
status: [
|
||||
{ required: true, message: "信号选项类型不能为空", trigger: "blur" },
|
||||
],
|
||||
signalValue: [
|
||||
{ required: true, message: "信号量不能为空", trigger: "blur" },
|
||||
],
|
||||
signalValueRange: [
|
||||
{ required: true, message: "信号量范围不能为空", trigger: "blur" },
|
||||
]
|
||||
],
|
||||
},
|
||||
optionOpen: false,
|
||||
optionForm: {
|
||||
signalName: '',
|
||||
signalCode: '',
|
||||
optionList: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -160,6 +220,49 @@ export default {
|
||||
this.open = true;
|
||||
this.title = "添加信号";
|
||||
},
|
||||
handleOptionUpdate (row) {
|
||||
this.optionOpen = true;
|
||||
this.resetForm("optionForm");
|
||||
this.optionForm.optionList = [{ 'optionName': '', 'optionVal': '', 'signalValueRange': '' }];
|
||||
this.optionForm.signalCode = row.signalCode;
|
||||
this.optionForm.signalName = row.signalName;
|
||||
select({ signalCode: row.signalCode }).then(res => {
|
||||
if (200 == res.code) {
|
||||
this.optionForm.optionList.unshift(...res.select);
|
||||
} else {
|
||||
this.msgError(res.msg);
|
||||
}
|
||||
})
|
||||
},
|
||||
removeOption (option) {
|
||||
let index = this.optionForm.optionList.indexOf(option);
|
||||
if (index !== -1) {
|
||||
this.optionForm.optionList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
addOption () {
|
||||
this.optionForm.optionList.push({ 'optionName': '', 'optionVal': '', 'signalValueRange': '' });
|
||||
},
|
||||
submitOption () {
|
||||
this.$refs.optionForm.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.optionForm.optionList.length == 0) return;
|
||||
let snap = new Set(this.optionForm.optionList.map(v => v.optionVal));
|
||||
if ( this.optionForm.optionList.length != snap.size) {
|
||||
this.msgError('选项值不能重复');
|
||||
return;
|
||||
}
|
||||
optionSave(this.optionForm).then(({ code, msg }) => {
|
||||
if (200 == code) {
|
||||
this.optionOpen = false;
|
||||
this.msgSuccess(msg);
|
||||
} else {
|
||||
this.msgError(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate (row) {
|
||||
this.reset();
|
||||
@ -169,9 +272,13 @@ export default {
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submit () {
|
||||
save(this.form).then(res => {
|
||||
this.open = false;
|
||||
this.getList()
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
save(this.form).then(res => {
|
||||
this.open = false;
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
|
Reference in New Issue
Block a user