OpcInfo.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="main">
  3. <img :src="imgUrl" width="1920px" alt="">
  4. <!-- <div class="icon" style="right:20px">
  5. <a-button type="primary" icon="appstore" size="large" @click="visibleRight=true" />
  6. </div>-->
  7. <div v-if="dotList !=null && dotList.length>0">
  8. <div v-for="item in dotList" :key="item.id">
  9. <VueDragResize
  10. v-show="item.positionFlag"
  11. :isActive="item.isActive"
  12. :w="item.width"
  13. :h="item.height"
  14. :minh="20"
  15. :x="item.xposition"
  16. :y="item.yposition"
  17. :isDraggable="item.isActive"
  18. :isResizable="item.isActive"
  19. :stickSize="5"
  20. >
  21. <a-tooltip>
  22. <template slot="title">
  23. {{ item.description }}
  24. </template>
  25. <div class="info" @click="handleInfo(item)" @click.right.prevent="handleView(item)">
  26. <span :style="{'color':item.warnFirstColor}" v-if="(+item.result)<=item.warnFirst&&item.warnFirst!==null">{{ item.result + item.unit }}</span>
  27. <span :style="{'color':item.warnSecondColor}" v-else-if="item.warnFirst<(+item.result)&&(+item.result)<item.warnSecond">{{ item.result + item.unit }}</span>
  28. <span :style="{'color':item.warnThirdColor}" v-else-if="item.warnThird<(+item.result)&&(+item.result)<item.warnFour">{{ item.result + item.unit }}</span>
  29. <span :style="{'color':item.warnFourColor}" v-else-if="(+item.result)>=item.warnFour&&item.warnFirst!==null">{{ item.result + item.unit }}</span>
  30. <span v-else>{{ item.result + item.unit }}</span>
  31. </div>
  32. </a-tooltip>
  33. </VueDragResize>
  34. <VueDragResize
  35. v-if="item.type===2"
  36. v-show="item.result===0||item.result===null"
  37. :isActive="item.isActive"
  38. :w="35"
  39. :h="35"
  40. :minh="20"
  41. :x="item.imgXPosition"
  42. :y="item.imgYPosition"
  43. :isDraggable="item.isActive"
  44. :isResizable="item.isActive"
  45. :stickSize="5"
  46. >
  47. <a-tooltip>
  48. <template slot="title">
  49. {{ item.description }}
  50. </template>
  51. <img src="@/assets/stop.png" alt="" width="35px" height="35px">
  52. </a-tooltip>
  53. </VueDragResize>
  54. </div>
  55. </div>
  56. <!-- <a-drawer
  57. title="点位列表"
  58. placement="right"
  59. :closable="false"
  60. :width="350"
  61. :visible="visibleRight"
  62. @close="onCloseRight"
  63. >
  64. <div>
  65. <a-tree-select
  66. style="width: 60%;margin-right:10px;"
  67. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  68. :treeData="treeData"
  69. :treeNodeFilterProp="'title'"
  70. :showSearch="true"
  71. v-model="positionId"
  72. placeholder="请选择"
  73. @change="handleChange"
  74. >
  75. </a-tree-select>
  76. </div>
  77. <br>
  78. <a-table
  79. :columns="columns"
  80. :data-source="dotList"
  81. :pagination="{ pageSize: 100 }"
  82. :scroll="{ y: 650 }"
  83. >
  84. <span slot="action" slot-scope="text, record,index">
  85. <a @click="disposition(record,index)">配置</a>
  86. <a-button style="color:#ccc" v-show="record.positionFlag" type="link" icon="eye-invisible" @click="handleShow(index,0)" />
  87. <a-button v-show="!record.positionFlag" type="link" icon="eye" @click="handleShow(index,1)" />
  88. </span>
  89. </a-table>
  90. </a-drawer> -->
  91. <div class="btn">
  92. <a-button-group>
  93. <a-button v-for="item in list" :key="item.id" :disabled="positionId===item.id" @click="getOpcInfo(item.id)">{{ item.name }}</a-button>
  94. </a-button-group>
  95. </div>
  96. <BaseChartInfo ref="baseChartInfo" @ok="handleOk"/>
  97. <detail ref="detailModal" @ok="handleOk" />
  98. </div>
  99. </template>
  100. <script>
  101. import VueDragResize from 'vue-drag-resize'
  102. import { getSbPositionTree, fetchSbPosition, querySbPosition } from '@/api/sb/position'
  103. import { queryRemoteOpc, updateRemoteOpc,
  104. fetchRemoteOpc
  105. } from '@/api/remote/opc'
  106. import Detail from '@/views/remote/opc/modules/Detail.vue'
  107. import BaseChartInfo from './modules/BaseChartInfo.vue'
  108. export default {
  109. name: 'Opc',
  110. components: {
  111. VueDragResize,
  112. BaseChartInfo,
  113. Detail
  114. },
  115. data () {
  116. return {
  117. visibleRight: false,
  118. positionId: '',
  119. treeData: [],
  120. parentId: '',
  121. list: [],
  122. optDot: null,
  123. imgUrl: '',
  124. dotList: [],
  125. timer: null,
  126. columns: [
  127. {
  128. title: '位号',
  129. dataIndex: 'positionNum',
  130. key: 'positionNum'
  131. },
  132. {
  133. title: '操作',
  134. key: 'action',
  135. scopedSlots: { customRender: 'action' }
  136. }
  137. ]
  138. }
  139. },
  140. created () {
  141. this.parentId = this.$route.query.parentId
  142. this.positionId = this.$route.query.line
  143. this.getOpcInfo(this.positionId)
  144. querySbPosition({ parentId: this.parentId }).then(res => {
  145. this.list = res.data
  146. })
  147. this.getImg()
  148. getSbPositionTree({ opcFlag: 1 }).then(res => {
  149. this.treeData = res.data
  150. })
  151. this.timer = setInterval(() => {
  152. this.getOpcInfo(this.positionId)
  153. }, 5000)
  154. },
  155. destroyed () {
  156. clearInterval(this.timer)
  157. },
  158. methods: {
  159. resize (newRect) {
  160. console.log(newRect)
  161. const params = {
  162. ...this.dotList[this.optDot],
  163. height: newRect.height,
  164. width: newRect.width,
  165. xposition: newRect.left,
  166. yposition: newRect.top
  167. }
  168. updateRemoteOpc(params).then(res => {
  169. console.log(res)
  170. this.dotList[this.optDot].isActive = false
  171. })
  172. },
  173. onCloseRight () {
  174. this.visibleRight = false
  175. },
  176. disposition (val, i) {
  177. val.isActive = true
  178. val.positionFlag = 1
  179. this.optDot = i
  180. this.visibleRight = false
  181. },
  182. handleShow (val, key) {
  183. this.dotList[val].positionFlag = key
  184. },
  185. getOpcInfo (positionId) {
  186. this.positionId = positionId
  187. queryRemoteOpc({ line: this.positionId })
  188. .then((res) => {
  189. this.dotList = res.data
  190. this.dotList.forEach(item => {
  191. item.isActive = false
  192. if (item.result == null) {
  193. item.result = '-'
  194. }
  195. })
  196. })
  197. this.getImg()
  198. },
  199. getImg () {
  200. fetchSbPosition({ id: this.positionId }).then(res => {
  201. this.imgUrl = res.data.opcImg
  202. })
  203. },
  204. handleChange () {
  205. this.getOpcInfo(this.positionId)
  206. this.getImg()
  207. },
  208. handleInfo (remoteOpc) {
  209. const model = this.$refs.baseChartInfo
  210. model.base(remoteOpc)
  211. },
  212. handleView (record) {
  213. fetchRemoteOpc({ id: record.id }).then(res => {
  214. const modal = this.$refs.detailModal
  215. modal.base(res.data)
  216. })
  217. },
  218. handleOk () {
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="less" scoped>
  224. .main{
  225. position: relative;
  226. }
  227. .info{
  228. font-size: 13px;
  229. font-weight: bold;
  230. color: rgba(127, 125, 119, 0.27);
  231. padding:0 2px;
  232. // transform: scale(0.5);
  233. }
  234. .icon{
  235. font-size: 30px;
  236. color: #fff;
  237. position: absolute;
  238. top:20px;
  239. }
  240. .btn{
  241. position: fixed;
  242. bottom: 10px;
  243. left:50%;
  244. transform: translateX(-50%);
  245. }
  246. </style>