123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <div class="main">
- <img :src="imgUrl" width="1920px" alt="">
- <!-- <div class="icon" style="right:20px">
- <a-button type="primary" icon="appstore" size="large" @click="visibleRight=true" />
- </div>-->
- <div v-if="dotList !=null && dotList.length>0">
- <div v-for="item in dotList" :key="item.id">
- <VueDragResize
- v-show="item.positionFlag"
- :isActive="item.isActive"
- :w="item.width"
- :h="item.height"
- :minh="20"
- :x="item.xposition"
- :y="item.yposition"
- :isDraggable="item.isActive"
- :isResizable="item.isActive"
- :stickSize="5"
- >
- <a-tooltip>
- <template slot="title">
- {{ item.description + '(' + item.time + ')' }}
- </template>
- <!-- <div class="info" @click="handleInfo(item)" @click.right.prevent="handleView(item)">-->
- <div class="info" @click="handleInfo(item)">
- <span :style="{'color':item.warnFirstColor}" v-if="(+item.result)<=item.warnFirst&&item.warnFirst!==null">{{ item.result }}</span>
- <span :style="{'color':item.warnSecondColor}" v-else-if="item.warnFirst<(+item.result)&&(+item.result)<item.warnSecond">{{ item.result }}</span>
- <span :style="{'color':item.warnThirdColor}" v-else-if="item.warnThird<(+item.result)&&(+item.result)<item.warnFour">{{ item.result }}</span>
- <span :style="{'color':item.warnFourColor}" v-else-if="(+item.result)>=item.warnFour&&item.warnFirst!==null">{{ item.result }}</span>
- <span v-else>{{ item.result==null?'-':item.result }}</span>
- </div>
- </a-tooltip>
- </VueDragResize>
- <VueDragResize
- v-if="item.type===2"
- v-show="item.result===0||item.result===null"
- :isActive="item.isActive"
- :w="35"
- :h="35"
- :minh="20"
- :x="item.imgXPosition"
- :y="item.imgYPosition"
- :isDraggable="item.isActive"
- :isResizable="item.isActive"
- :stickSize="5"
- >
- <a-tooltip>
- <template slot="title">
- {{ item.description }}
- </template>
- <img src="@/assets/stop.png" alt="" width="35px" height="35px">
- </a-tooltip>
- </VueDragResize>
- </div>
- </div>
- <!-- <a-drawer
- title="点位列表"
- placement="right"
- :closable="false"
- :width="350"
- :visible="visibleRight"
- @close="onCloseRight"
- >
- <div>
- <a-tree-select
- style="width: 60%;margin-right:10px;"
- :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
- :treeData="treeData"
- :treeNodeFilterProp="'title'"
- :showSearch="true"
- v-model="positionId"
- placeholder="请选择"
- @change="handleChange"
- >
- </a-tree-select>
- </div>
- <br>
- <a-table
- :columns="columns"
- :data-source="dotList"
- :pagination="{ pageSize: 100 }"
- :scroll="{ y: 650 }"
- >
- <span slot="action" slot-scope="text, record,index">
- <a @click="disposition(record,index)">配置</a>
- <a-button style="color:#ccc" v-show="record.positionFlag" type="link" icon="eye-invisible" @click="handleShow(index,0)" />
- <a-button v-show="!record.positionFlag" type="link" icon="eye" @click="handleShow(index,1)" />
- </span>
- </a-table>
- </a-drawer> -->
- <div class="btn">
- <a-button-group>
- <a-button v-for="item in list" :key="item.id" :disabled="positionId===item.id" @click="getOpcInfo(item.id)">{{ item.name }}</a-button>
- </a-button-group>
- </div>
- <detail ref="detailModal" @ok="handleOk" />
- <detail-log ref="detailLogModal" @ok="handleOk" />
- <remote-opc-warn></remote-opc-warn>
- </div>
- </template>
- <script>
- import VueDragResize from 'vue-drag-resize'
- import { getSbPositionTree, fetchSbPosition, querySbPosition } from '@/api/sb/position'
- import {
- updateRemoteOpc,
- fetchRemoteOpc, queryRemoteOpc, queryRemoteOpcFromRedis
- } from '@/api/remote/opc'
- import Detail from '@/views/remote/opc/modules/Detail.vue'
- import DetailLog from '@/views/remote/opc-log/modules/Detail.vue'
- import RemoteOpcWarn from '@/views/socket/RemoteOpcWarn'
- import RemoteOpcList from '@/views/remote/opc/RemoteOpc'
- export default {
- name: 'Opc',
- components: {
- RemoteOpcList,
- VueDragResize,
- RemoteOpcWarn,
- Detail,
- DetailLog
- },
- data () {
- return {
- visibleRight: false,
- positionId: '',
- treeData: [],
- parentId: '',
- list: [],
- optDot: null,
- imgUrl: '',
- dotList: [],
- timer: null,
- columns: [
- {
- title: '位号',
- dataIndex: 'positionNum',
- key: 'positionNum'
- },
- {
- title: '操作',
- key: 'action',
- scopedSlots: { customRender: 'action' }
- }
- ]
- }
- },
- created () {
- this.parentId = this.$route.query.parentId
- this.positionId = this.$route.query.line
- this.getOpcInfo(this.positionId)
- querySbPosition({ parentId: this.parentId }).then(res => {
- this.list = res.data
- this.getOpcInfoFromRedis(this.positionId)
- })
- this.getImg()
- getSbPositionTree({ opcFlag: 1 }).then(res => {
- this.treeData = res.data
- })
- this.timer = setInterval(() => {
- this.getOpcInfoFromRedis(this.positionId)
- }, 5000)
- },
- destroyed () {
- clearInterval(this.timer)
- },
- methods: {
- resize (newRect) {
- console.log(newRect)
- const params = {
- ...this.dotList[this.optDot],
- height: newRect.height,
- width: newRect.width,
- xposition: newRect.left,
- yposition: newRect.top
- }
- updateRemoteOpc(params).then(res => {
- console.log(res)
- this.dotList[this.optDot].isActive = false
- })
- },
- onCloseRight () {
- this.visibleRight = false
- },
- disposition (val, i) {
- val.isActive = true
- val.positionFlag = 1
- this.optDot = i
- this.visibleRight = false
- },
- handleShow (val, key) {
- this.dotList[val].positionFlag = key
- },
- getOpcInfo (positionId) {
- this.positionId = positionId
- queryRemoteOpc({ line: this.positionId })
- .then((res) => {
- this.dotList = res.data
- this.dotList.forEach(item => {
- item.isActive = false
- if (item.result == null) {
- item.result = '-'
- }
- })
- })
- this.getImg()
- },
- getOpcInfoFromRedis (positionId) {
- this.positionId = positionId
- queryRemoteOpcFromRedis({ line: this.positionId })
- .then((res) => {
- this.dotList.forEach(item => {
- item.isActive = false
- res.data.forEach(data => {
- if (item.positionNum === data.positionNum) {
- item.result = data.result
- item.time = data.time
- }
- })
- })
- })
- this.getImg()
- },
- getImg () {
- fetchSbPosition({ id: this.positionId }).then(res => {
- this.imgUrl = res.data.opcImg
- })
- },
- handleChange () {
- this.getOpcInfo(this.positionId)
- this.getImg()
- },
- /* handleInfo (remoteOpc) {
- const model = this.$refs.detailLogModal
- model.base(null, { positionNum: remoteOpc.positionNum })
- }, */
- handleInfo (remoteOpc) {
- const model = this.$refs.detailLogModal
- model.base(remoteOpc)
- },
- handleView (record) {
- fetchRemoteOpc({ id: record.id }).then(res => {
- const modal = this.$refs.detailModal
- modal.base(res.data)
- })
- },
- handleOk () {
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .main{
- position: relative;
- }
- .info{
- font-size: 14px;
- font-weight: bold;
- color: black;
- padding:0 2px;
- // transform: scale(0.5);
- }
- .icon{
- font-size: 30px;
- color: #fff;
- position: absolute;
- top:20px;
- }
- .btn{
- position: fixed;
- bottom: 10px;
- left:50%;
- transform: translateX(-50%);
- }
- </style>
|