|
@@ -0,0 +1,454 @@
|
|
|
+<!-- 添加采样 -->
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ :title="comonentVar.modelTitle"
|
|
|
+ :visible.sync="comonentVar.dialogVisible"
|
|
|
+ :destroy-on-close="true"
|
|
|
+ :close-on-click-modal="true"
|
|
|
+ @close="modelOnClose"
|
|
|
+ >
|
|
|
+ <div v-if="isYaoKong" class="model-form">
|
|
|
+ <!-- label-width 设置了:label 和 input 就不会换行 -->
|
|
|
+ <el-form ref="modelYaoKongOpt" :model="modelYaoKongOpt" label-width="30px">
|
|
|
+ <el-form-item prop="p1">
|
|
|
+ <el-radio-group v-model="modelYaoKongOpt.p1">
|
|
|
+ <el-radio label="1">分</el-radio>
|
|
|
+ <el-radio label="2">合</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-tabs v-model="activeYaoKongTabName" type="border-card">
|
|
|
+ <el-tab-pane label="直控" name="tab1" style="height: 10rem; text-align: center;">
|
|
|
+ <div class="submit" style="padding-top: 5%;">
|
|
|
+ <el-button
|
|
|
+ style="padding: 1rem 3rem;"
|
|
|
+ type="primary"
|
|
|
+ class="dark-button"
|
|
|
+ size="big"
|
|
|
+ :disabled="yaoKongCommand.result3===0"
|
|
|
+ @click="commitYaokong1"
|
|
|
+ >确定执行</el-button>
|
|
|
+ </div>
|
|
|
+ <div style="font-weight: bold;margin: 1rem 0;">操作结果:<span :class="`yaokong_pre_result${yaoKongCommand.result3}`">{{ yaoKongCommand.result3Text }}</span></div>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="选控" name="tab2" style="text-align: center;">
|
|
|
+ <div class="submit" style="padding-top: 1%;">
|
|
|
+ <el-button
|
|
|
+ style="padding: 1rem 3.5rem;"
|
|
|
+ type="primary"
|
|
|
+ class="dark-button"
|
|
|
+ size="big"
|
|
|
+ :disabled="yaoKongCommand.result!==-1"
|
|
|
+ @click="commitYaokong_PreCtrl"
|
|
|
+ >预控</el-button>
|
|
|
+ </div>
|
|
|
+ <div style="font-weight: bold;margin: 1rem 0;">预控结果:<span :class="`yaokong_pre_result${yaoKongCommand.result}`">{{ yaoKongCommand.resultText }}</span></div>
|
|
|
+ <div style="border: 1px dashed #ccc" />
|
|
|
+ <div class="submit" style="padding-top: 4%;">
|
|
|
+ <el-button
|
|
|
+ style="padding: 1rem 3.5rem;"
|
|
|
+ type="primary"
|
|
|
+ :class="yaoKongCommand.result===1?dark-button:''"
|
|
|
+ size="big"
|
|
|
+ :disabled="yaoKongCommand.result!==1"
|
|
|
+ @click="commitYaokong_RunCtrl"
|
|
|
+ >遥控</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="submit" style="padding-top: 4%;">
|
|
|
+ <el-button
|
|
|
+ style="padding: 1rem 3.5rem;"
|
|
|
+ size="big"
|
|
|
+ :disabled="yaoKongCommand.result!==1"
|
|
|
+ @click="commitYaokong_Cancel"
|
|
|
+ >撤消</el-button>
|
|
|
+ </div>
|
|
|
+ <div style="font-weight: bold;margin: 1rem 0;">操作结果:<span :class="`yaokong_pre_result${yaoKongCommand.result2}`">{{ yaoKongCommand.result2Text }}</span></div>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ </el-form>
|
|
|
+ <div class="buttons" style="margin-top:20px">
|
|
|
+ <div class="cancel">
|
|
|
+ <el-button class="lightButton" icon="el-icon-circle-close" size="big" @click="cancelForm">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="isYaoTiao" class="model-form">
|
|
|
+ <div style="text-align: center;">
|
|
|
+ <div class="submit" style="padding-top: 2%;">
|
|
|
+ <el-button
|
|
|
+ style="padding: 1rem 3rem;"
|
|
|
+ type="primary"
|
|
|
+ class="dark-button"
|
|
|
+ size="big"
|
|
|
+ :disabled="yaoTiaoCommnad.result!==-1"
|
|
|
+ @click="commitYaoTiaoSelect"
|
|
|
+ >发送选择命令</el-button>
|
|
|
+ </div>
|
|
|
+ <div style=" font-weight: bold;margin: 1rem 0;">操作结果:<span :class="`yaokong_pre_result${yaoTiaoCommnad.result}`">{{ yaoTiaoCommnad.resultText }}</span></div>
|
|
|
+ <div style="border: 1px solid #ccc;padding: 3rem 5rem;">
|
|
|
+ <div style="font-size: 1.2rem;">
|
|
|
+ <span>*设定遥调值:</span>
|
|
|
+ <el-input
|
|
|
+ v-model="modelYaoTiaoOpt.value"
|
|
|
+ class=""
|
|
|
+ clearable
|
|
|
+ placeholder="请输入"
|
|
|
+ type="number"
|
|
|
+ maxlength="5"
|
|
|
+ :disabled="yaoTiaoCommnad.result!==1"
|
|
|
+ style="width:180px;margin-right: 2rem;"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div style="margin: 2rem 0;">
|
|
|
+ <el-button
|
|
|
+ style="padding: 1rem 5rem;"
|
|
|
+ type="primary"
|
|
|
+ :class="yaoTiaoCommnad.result===1 ? dark-button:''"
|
|
|
+ size="big"
|
|
|
+ :disabled="yaoTiaoCommnad.result!==1"
|
|
|
+ @click="commitYaoTiaoExecute"
|
|
|
+ >执行</el-button>
|
|
|
+ </div>
|
|
|
+ <div style=" font-weight: bold;margin: 1rem 0;">操作结果:<span :class="`yaokong_pre_result${yaoTiaoCommnad.result2}`">{{ yaoTiaoCommnad.result2Text }}</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="buttons" style="margin-top:20px">
|
|
|
+ <div class="cancel">
|
|
|
+ <el-button class="lightButton" icon="el-icon-circle-close" size="big" @click="cancelForm">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+import { Message } from 'element-ui'
|
|
|
+import {
|
|
|
+ postData,
|
|
|
+ putData
|
|
|
+} from '@/api/common-action'
|
|
|
+export default {
|
|
|
+ name: 'ModelFormSample',
|
|
|
+ // model-parames 模态框参数
|
|
|
+ props: {
|
|
|
+ modelParames: {
|
|
|
+ type: Object,
|
|
|
+ default: function() {
|
|
|
+ return {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sampleData: {
|
|
|
+ type: Array,
|
|
|
+ default: function() {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ comonentVar: {
|
|
|
+ modelTitle: '加载中...',
|
|
|
+ dialogVisible: true
|
|
|
+ },
|
|
|
+ activeYaoKongTabName: 'tab1',
|
|
|
+ // 表单默认数据,选项数组 一定要在这里先定义,否则无法正常获取
|
|
|
+ modelYaoKongOpt: {
|
|
|
+ p1: '1'
|
|
|
+ },
|
|
|
+ modelYaoTiaoOpt: {
|
|
|
+ value: ''
|
|
|
+ },
|
|
|
+ isYaoKong: false,
|
|
|
+ isYaoTiao: false,
|
|
|
+ yaoKongCommand: {
|
|
|
+ result: -1, // 预控结果
|
|
|
+ resultText: '未执行', // 预控结果描述
|
|
|
+ result2: -1, // 选控结果
|
|
|
+ result2Text: '需先进行预控', // 选控结果描述
|
|
|
+ result3: -1, // 直控状态
|
|
|
+ result3Text: '未执行' // 直控状态描述
|
|
|
+ },
|
|
|
+ yaoTiaoCommnad: {
|
|
|
+ result: -1,
|
|
|
+ resultText: '未执行',
|
|
|
+ result2: -1,
|
|
|
+ result2Text: '未执行'
|
|
|
+ },
|
|
|
+ // 下拉框单独定义 避免错位
|
|
|
+ valueTypeOptions: [],
|
|
|
+ checkPointFuctionOptions: [],
|
|
|
+ isupdata: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters([
|
|
|
+ 'roles'
|
|
|
+ ])
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // 初始化
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.initFunctions()
|
|
|
+ console.log('modelParames:', this.modelParames)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 初始化
|
|
|
+ async initFunctions() {
|
|
|
+ // 初始化 值类型 下拉框选项
|
|
|
+ this.valueTypeOptions = JSON.parse(localStorage.getItem('valueTypeOptions'))
|
|
|
+ // 因为 this.modelForm 在前面已经赋值过了,所以这里必须使用 set 的方式赋值,否则无法更新选项
|
|
|
+
|
|
|
+ // 初始化 功能码 下拉框选项
|
|
|
+ this.checkPointFuctionOptions = JSON.parse(localStorage.getItem('checkPointFuctionOptions'))
|
|
|
+ if (this.modelParames.modelFormData.range === 'COIL_STATUS') {
|
|
|
+ this.comonentVar.modelTitle = `遥控操作 ${this.modelParames.deviceName}-${this.modelParames.modelFormData.name}`
|
|
|
+ this.isYaoKong = true
|
|
|
+ this.isYaoTiao = false
|
|
|
+ } else {
|
|
|
+ this.comonentVar.modelTitle = `遥调操作 ${this.modelParames.deviceName}-${this.modelParames.modelFormData.name}`
|
|
|
+ this.isYaoKong = false
|
|
|
+ this.isYaoTiao = true
|
|
|
+ }
|
|
|
+ if (this.modelParames.modelFormData) {
|
|
|
+ if (this.modelParames.modelFormData.id > 0) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ commitYaokong1() {
|
|
|
+ // 直控执行
|
|
|
+ this.yaoKongCommand.result3 = 0
|
|
|
+ this.yaoKongCommand.result3Text = '进行中...'
|
|
|
+ var urlencoded = new URLSearchParams()
|
|
|
+ urlencoded.append('stage', 'execute')
|
|
|
+ urlencoded.append('tag', this.modelParames.modelFormData.iec104)
|
|
|
+ urlencoded.append('v1', this.modelYaoKongOpt.p1 === '1')
|
|
|
+ postData(`/iec104/master/${this.modelParames.curPlanId}/ctrl`, urlencoded).then((res) => {
|
|
|
+ this.yaoKongCommand.result3 = 1
|
|
|
+ this.yaoKongCommand.result3Text = '执行成功'
|
|
|
+ }).catch((_err) => {
|
|
|
+ this.yaoKongCommand.result3 = 2
|
|
|
+ this.yaoKongCommand.result3Text = '执行失败!'
|
|
|
+ const that = this
|
|
|
+ setTimeout(function() {
|
|
|
+ that.yaoKongCommand.result3 = -1
|
|
|
+ that.yaoKongCommand.result3Text = '未执行'
|
|
|
+ }, 3000)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ commitYaokong_PreCtrl() {
|
|
|
+ this.yaoKongCommand.result2 = -1
|
|
|
+ this.yaoKongCommand.result2Text = '需先进行预控'
|
|
|
+ // 预控
|
|
|
+ this.yaoKongCommand.result = 0 // 禁用本身,禁用遥控
|
|
|
+ this.yaoKongCommand.resultText = '进行中...'
|
|
|
+ var urlencoded = new URLSearchParams()
|
|
|
+ urlencoded.append('stage', 'select')
|
|
|
+ urlencoded.append('tag', this.modelParames.modelFormData.iec104)
|
|
|
+ urlencoded.append('v1', this.modelYaoKongOpt.p1 === '1')
|
|
|
+ postData(`/iec104/master/${this.modelParames.curPlanId}/ctrl`, urlencoded).then((res) => {
|
|
|
+ this.yaoKongCommand.result = 1 // 可进行遥控
|
|
|
+ this.yaoKongCommand.resultText = '执行成功'
|
|
|
+ }).catch((_err) => {
|
|
|
+ this.yaoKongCommand.result = 2
|
|
|
+ this.yaoKongCommand.resultText = '执行失败!'
|
|
|
+ const that = this
|
|
|
+ setTimeout(function() {
|
|
|
+ that.yaoKongCommand.result = -1
|
|
|
+ that.yaoKongCommand.resultText = '未执行'
|
|
|
+ }, 3000)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ commitYaokong_RunCtrl() {
|
|
|
+ // 遥控执行
|
|
|
+ this.yaoKongCommand.result2 = 0 // 禁用本身
|
|
|
+ this.yaoKongCommand.result2Text = '进行中...'
|
|
|
+ this.yaoKongCommand.result = -1 // 禁用预控及遥控
|
|
|
+ var urlencoded = new URLSearchParams()
|
|
|
+ urlencoded.append('stage', 'select')
|
|
|
+ urlencoded.append('tag', this.modelParames.modelFormData.iec104)
|
|
|
+ urlencoded.append('v1', this.modelYaoKongOpt.p1 === '1')
|
|
|
+ postData(`/iec104/master/${this.modelParames.curPlanId}/ctrl`, urlencoded).then((res) => {
|
|
|
+ // 操作成功
|
|
|
+ this.yaoKongCommand.result = -1
|
|
|
+ this.yaoKongCommand.resultText = '未执行'
|
|
|
+ this.yaoKongCommand.result2 = 1
|
|
|
+ this.yaoKongCommand.result2Text = '执行成功!'
|
|
|
+ }).catch((_err) => {
|
|
|
+ this.yaoKongCommand.result2 = 2 // 恢复本身
|
|
|
+ this.yaoKongCommand.result2Text = '执行失败!'
|
|
|
+ this.yaoKongCommand.result = -1 // 恢复预控
|
|
|
+ this.yaoKongCommand.resultText = '未执行'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ commitYaokong_Cancel() {
|
|
|
+ // 遥控撤消
|
|
|
+ this.yaoKongCommand.result2 = 0
|
|
|
+ this.yaoKongCommand.result2Text = '进行中...'
|
|
|
+ // 操作成功
|
|
|
+ this.yaoKongCommand.result = -1
|
|
|
+ this.yaoKongCommand.resultText = '未执行'
|
|
|
+ this.yaoKongCommand.result2 = -1
|
|
|
+ this.yaoKongCommand.result2Text = '需先进行预控'
|
|
|
+ },
|
|
|
+ commitYaoTiaoSelect() {
|
|
|
+ // 遥调选择
|
|
|
+ this.yaoTiaoCommnad.result = -1 // 禁用本身
|
|
|
+ this.yaoTiaoCommnad.resultText = '进行中...'
|
|
|
+ this.yaoTiaoCommnad.result2 = -1 // 禁用遥控
|
|
|
+ this.modelYaoTiaoOpt.value = ''
|
|
|
+ var urlencoded = new URLSearchParams()
|
|
|
+ urlencoded.append('tag', this.modelParames.modelFormData.iec104)
|
|
|
+ postData(`/iec104/master/${this.modelParames.curPlanId}/normalized`, urlencoded).then((res) => {
|
|
|
+ // 操作成功
|
|
|
+ this.yaoTiaoCommnad.result2 = -1
|
|
|
+ this.yaoTiaoCommnad.result2Text = '未执行'
|
|
|
+ this.yaoTiaoCommnad.result = 1
|
|
|
+ this.yaoTiaoCommnad.resultText = '执行成功!'
|
|
|
+ }).catch((_err) => {
|
|
|
+ // 禁用 选择 按钮
|
|
|
+ this.yaoTiaoCommnad.result = 2
|
|
|
+ this.yaoTiaoCommnad.resultText = '执行失败!'
|
|
|
+ // 禁用 执行 按钮
|
|
|
+ this.yaoTiaoCommnad.result2 = -1
|
|
|
+ this.yaoTiaoCommnad.result2Text = '未执行'
|
|
|
+ const that = this
|
|
|
+ setTimeout(function() {
|
|
|
+ // 打开 选择 按钮
|
|
|
+ that.yaoTiaoCommnad.result = -1
|
|
|
+ that.yaoTiaoCommnad.resultText = '未执行'
|
|
|
+ }, 3000)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ commitYaoTiaoExecute() {
|
|
|
+ // 遥调执行
|
|
|
+ const v = this.modelYaoTiaoOpt.value.replace(/ /gi, '')
|
|
|
+ if (v === '') {
|
|
|
+ Message({
|
|
|
+ message: '遥调值不能为空!',
|
|
|
+ type: 'error',
|
|
|
+ duration: 3 * 1000,
|
|
|
+ offset: window.screen.height / 3
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (isNaN(v)) {
|
|
|
+ Message({
|
|
|
+ message: '遥调值只能为数字!',
|
|
|
+ type: 'error',
|
|
|
+ duration: 3 * 1000,
|
|
|
+ offset: window.screen.height / 3
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.yaoTiaoCommnad.result2 = 0
|
|
|
+ this.yaoTiaoCommnad.result2Text = '执行中'
|
|
|
+ this.yaoTiaoCommnad.result = -1
|
|
|
+ var urlencoded = new URLSearchParams()
|
|
|
+ urlencoded.append('tag', this.modelParames.modelFormData.iec104)
|
|
|
+ urlencoded.append('value', v)
|
|
|
+ postData(`/iec104/master/${this.modelParames.curPlanId}/normalized`, urlencoded).then((res) => {
|
|
|
+ // 操作成功
|
|
|
+ this.yaoTiaoCommnad.result2 = 1
|
|
|
+ this.yaoTiaoCommnad.result2Text = '执行成功!'
|
|
|
+ }).catch((_err) => {
|
|
|
+ // 禁用 执行 按钮
|
|
|
+ this.yaoTiaoCommnad.result2 = 2
|
|
|
+ this.yaoTiaoCommnad.result2Text = '执行失败!'
|
|
|
+ const that = this
|
|
|
+ setTimeout(function() {
|
|
|
+ // 打开 选择 按钮
|
|
|
+ that.yaoTiaoCommnad.result = -1
|
|
|
+ that.yaoTiaoCommnad.resultText = '未执行'
|
|
|
+ }, 3000)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 关闭model时执行
|
|
|
+ modelOnClose() {
|
|
|
+ this.$emit('toggleModel', 'ModelFormCommandOpt104', false)
|
|
|
+ },
|
|
|
+ // 表单提交按钮
|
|
|
+ submitForm() {
|
|
|
+ if (this.isupdata === false) {
|
|
|
+ // console.log('this.modelForm', this.modelForm)
|
|
|
+ // console.log('sampleData', this.sampleData)
|
|
|
+ const hasThis = this.sampleData.some(item => item.range === this.modelForm.range && item.offset === parseInt(this.modelForm.offset))
|
|
|
+ if (hasThis) {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: '该采样值已存在',
|
|
|
+ offset: window.screen.height / 3
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let checkForm = false
|
|
|
+ this.$refs.modelForm.validate(f => { checkForm = f })
|
|
|
+ if (!checkForm) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ delete this.modelForm.code
|
|
|
+ const putUrl = `/test/plan/${this.modelParames.curPlanId}/point`
|
|
|
+ // const putUrl = `/test/plan/${this.modelForm.id}/point`
|
|
|
+ putData(putUrl, this.modelForm).then(res => {
|
|
|
+ // 保存表单
|
|
|
+ this.comonentVar.dialogVisible = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 表单取消按钮
|
|
|
+ cancelForm() {
|
|
|
+ this.modelForm = {}
|
|
|
+ this.comonentVar.dialogVisible = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss">
|
|
|
+.steps-setting {
|
|
|
+ padding: 10px 0;
|
|
|
+ label {
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+// 表单按钮样式
|
|
|
+
|
|
|
+.yaokong_pre_result2{
|
|
|
+ color: red;
|
|
|
+}
|
|
|
+.yaokong_pre_result0{
|
|
|
+ color: rgb(115, 115, 207);
|
|
|
+}
|
|
|
+.yaokong_pre_result1{
|
|
|
+ color: rgb(9, 240, 86);
|
|
|
+}
|
|
|
+.buttons {
|
|
|
+ display: flex;
|
|
|
+ justify-content: right;
|
|
|
+ padding-bottom: 20px;
|
|
|
+
|
|
|
+ .submit {
|
|
|
+ padding-left: 20px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.model-form {
|
|
|
+ .setting-input {
|
|
|
+ width: 100px;
|
|
|
+ }
|
|
|
+}
|
|
|
+// 按钮公用样式
|
|
|
+.dark-button {
|
|
|
+ background-color: #00706B;
|
|
|
+ border: 1px #00706B solid;
|
|
|
+ color: #fff;
|
|
|
+}
|
|
|
+
|
|
|
+.light-button {
|
|
|
+ color: #00706B;
|
|
|
+ border: 1px #00706B solid;
|
|
|
+}
|
|
|
+</style>
|