OpcInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. :isActive="item.isActive"
  11. :w="item.width"
  12. :h="item.height"
  13. :minh="20"
  14. :x="item.xposition"
  15. :y="item.yposition"
  16. :isDraggable="item.isActive"
  17. :isResizable="item.isActive"
  18. :stickSize="5"
  19. >
  20. <a-tooltip>
  21. <template slot="title">
  22. {{ item.description + '(' + item.time + ')' }}
  23. </template>
  24. <!-- <div class="info" @click="handleInfo(item)" @click.right.prevent="handleView(item)">-->
  25. <div v-if="item.type===1||item.type===5" class="info" @click="handleInfo(item)">
  26. <span :style="{'color':item.warnFirstColor}" v-if="(+item.result)<=item.warnFirst&&item.warnFirst!==null">{{ item.result }}</span>
  27. <span :style="{'color':item.warnSecondColor}" v-else-if="item.warnFirst<(+item.result)&&(+item.result)<item.warnSecond">{{ item.result }}</span>
  28. <span :style="{'color':item.warnThirdColor}" v-else-if="item.warnThird<(+item.result)&&(+item.result)<item.warnFour">{{ item.result }}</span>
  29. <span :style="{'color':item.warnFourColor}" v-else-if="(+item.result)>=item.warnFour&&item.warnFirst!==null">{{ item.result }}</span>
  30. <span v-else>{{ item.result==null?'-':item.result }}</span>
  31. </div>
  32. </a-tooltip>
  33. </VueDragResize>
  34. <VueDragResize
  35. v-if="item.type===2"
  36. v-show="item.result===0"
  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
  52. v-if="item.imgPosition===1"
  53. src="@/assets/kg_red_left.png"
  54. @click="handleInfo(item)"
  55. alt=""
  56. width="30px"
  57. height="30px">
  58. <img
  59. v-if="item.imgPosition===2"
  60. src="@/assets/kg_red_top.png"
  61. @click="handleInfo(item)"
  62. alt=""
  63. width="30px"
  64. height="30px">
  65. <img
  66. v-if="item.imgPosition===3"
  67. src="@/assets/kg_red_right.png"
  68. @click="handleInfo(item)"
  69. alt=""
  70. width="30px"
  71. height="30px">
  72. <img
  73. v-if="item.imgPosition===4"
  74. src="@/assets/kg_red_down.png"
  75. @click="handleInfo(item)"
  76. alt=""
  77. width="30px"
  78. height="30px">
  79. </a-tooltip>
  80. </VueDragResize>
  81. <VueDragResize
  82. v-if="item.type===2"
  83. v-show="item.result===1"
  84. :isActive="item.isActive"
  85. :w="35"
  86. :h="35"
  87. :minh="20"
  88. :x="item.imgXPosition"
  89. :y="item.imgYPosition"
  90. :isDraggable="item.isActive"
  91. :isResizable="item.isActive"
  92. :stickSize="5"
  93. >
  94. <a-tooltip>
  95. <template slot="title">
  96. {{ item.description }}
  97. </template>
  98. <img
  99. v-if="item.imgPosition===null || item.imgPosition===1"
  100. src="@/assets/kg_green_left.png"
  101. @click="handleInfo(item)"
  102. alt=""
  103. width="30px"
  104. height="30px">
  105. <img
  106. v-if="item.imgPosition===2"
  107. src="@/assets/kg_green_top.png"
  108. @click="handleInfo(item)"
  109. alt=""
  110. width="30px"
  111. height="30px">
  112. <img
  113. v-if="item.imgPosition===3"
  114. src="@/assets/kg_green_right.png"
  115. @click="handleInfo(item)"
  116. alt=""
  117. width="30px"
  118. height="30px">
  119. <img
  120. v-if="item.imgPosition===4"
  121. src="@/assets/kg_green_down.png"
  122. @click="handleInfo(item)"
  123. alt=""
  124. width="30px"
  125. height="30px">
  126. </a-tooltip>
  127. </VueDragResize>
  128. <VueDragResize
  129. v-if="item.type===3"
  130. v-show="item.result===1"
  131. :isActive="item.isActive"
  132. :w="35"
  133. :h="35"
  134. :minh="20"
  135. :x="item.imgXPosition"
  136. :y="item.imgYPosition"
  137. :isDraggable="item.isActive"
  138. :isResizable="item.isActive"
  139. :stickSize="5"
  140. >
  141. <a-tooltip>
  142. <template slot="title">
  143. {{ item.description }}
  144. </template>
  145. <img
  146. style="z-index: 100"
  147. @click="handleInfo(item)"
  148. src="@/assets/green.png"
  149. alt=""
  150. width="30px"
  151. height="30px">
  152. </a-tooltip>
  153. </VueDragResize>
  154. <VueDragResize
  155. v-if="item.type===4"
  156. v-show="item.result===0"
  157. :isActive="item.isActive"
  158. :w="35"
  159. :h="35"
  160. :minh="20"
  161. :x="item.imgXPosition"
  162. :y="item.imgYPosition"
  163. :isDraggable="item.isActive"
  164. :isResizable="item.isActive"
  165. :stickSize="5"
  166. >
  167. <a-tooltip>
  168. <template slot="title">
  169. {{ item.description }}
  170. </template>
  171. <img
  172. style="z-index: 100"
  173. @click="handleInfo(item)"
  174. src="@/assets/stop.png"
  175. alt=""
  176. width="30px"
  177. height="30px">
  178. </a-tooltip>
  179. </VueDragResize>
  180. <VueDragResize
  181. v-if="item.type===5"
  182. :isActive="item.isActive"
  183. :w="item.imgWidth"
  184. :h="item.imgHeight"
  185. :minh="20"
  186. :minw="20"
  187. :x="item.imgXPosition"
  188. :y="item.imgYPosition"
  189. :isDraggable="item.isActive"
  190. :isResizable="item.isActive"
  191. :stickSize="5"
  192. >
  193. <a-tooltip>
  194. <template slot="title">
  195. {{ item.description }} <br />
  196. 液位: {{ item.result }}
  197. </template>
  198. <LiquidLevel :value="item" :width="item.imgWidth" :height="item.imgHeight"/>
  199. </a-tooltip>
  200. </VueDragResize>
  201. </div>
  202. </div>
  203. <!-- <a-drawer
  204. title="点位列表"
  205. placement="right"
  206. :closable="false"
  207. :width="350"
  208. :visible="visibleRight"
  209. @close="onCloseRight"
  210. >
  211. <div>
  212. <a-tree-select
  213. style="width: 60%;margin-right:10px;"
  214. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  215. :treeData="treeData"
  216. :treeNodeFilterProp="'title'"
  217. :showSearch="true"
  218. v-model="positionId"
  219. placeholder="请选择"
  220. @change="handleChange"
  221. >
  222. </a-tree-select>
  223. </div>
  224. <br>
  225. <a-table
  226. :columns="columns"
  227. :data-source="dotList"
  228. :pagination="{ pageSize: 100 }"
  229. :scroll="{ y: 650 }"
  230. >
  231. <span slot="action" slot-scope="text, record,index">
  232. <a @click="disposition(record,index)">配置</a>
  233. <a-button style="color:#ccc" v-show="record.positionFlag" type="link" icon="eye-invisible" @click="handleShow(index,0)" />
  234. <a-button v-show="!record.positionFlag" type="link" icon="eye" @click="handleShow(index,1)" />
  235. </span>
  236. </a-table>
  237. </a-drawer> -->
  238. <div class="btn">
  239. <a-button-group>
  240. <a-button v-for="item in list" :key="item.id" :disabled="positionId===item.id" @click="getOpcInfo(item.id)">{{ item.name }}</a-button>
  241. <a-button @click="back()">返回主页</a-button>
  242. </a-button-group>
  243. </div>
  244. <detail ref="detailModal" @ok="handleOk" />
  245. <detail-log ref="detailLogModal" @ok="handleOk" />
  246. <!-- <remote-opc-warn></remote-opc-warn>-->
  247. </div>
  248. </template>
  249. <script>
  250. import VueDragResize from 'vue-drag-resize'
  251. import LiquidLevel from '@/components/LiquidLevel'
  252. import { getSbPositionTree, fetchSbPosition, querySbPosition } from '@/api/remote/remote-position'
  253. import {
  254. updateRemoteOpc,
  255. fetchRemoteOpc, queryRemoteOpc, queryRemoteOpcFromRedis
  256. } from '@/api/remote/opc'
  257. import Detail from '@/views/remote/opc/modules/Detail.vue'
  258. import DetailLog from '@/views/remote/opc-log/modules/Detail.vue'
  259. import RemoteOpcWarn from '@/views/socket/RemoteOpcWarn'
  260. import RemoteOpcList from '@/views/remote/opc/RemoteOpc'
  261. export default {
  262. name: 'Opc',
  263. components: {
  264. RemoteOpcList,
  265. VueDragResize,
  266. LiquidLevel,
  267. RemoteOpcWarn,
  268. Detail,
  269. DetailLog
  270. },
  271. data () {
  272. return {
  273. visibleRight: false,
  274. positionId: '',
  275. treeData: [],
  276. parentId: '',
  277. list: [],
  278. optDot: null,
  279. imgUrl: '',
  280. dotList: [],
  281. timer: null,
  282. columns: [
  283. {
  284. title: '位号',
  285. dataIndex: 'positionNum',
  286. key: 'positionNum'
  287. },
  288. {
  289. title: '操作',
  290. key: 'action',
  291. scopedSlots: { customRender: 'action' }
  292. }
  293. ]
  294. }
  295. },
  296. created () {
  297. this.parentId = this.$route.query.parentId
  298. this.positionId = this.$route.query.line
  299. this.getOpcInfo(this.positionId)
  300. querySbPosition({ parentId: this.parentId }).then(res => {
  301. this.list = res.data
  302. this.getOpcInfoFromRedis(this.positionId)
  303. })
  304. this.getImg()
  305. getSbPositionTree().then(res => {
  306. this.treeData = res.data
  307. })
  308. this.timer = setInterval(() => {
  309. this.getOpcInfoFromRedis(this.positionId)
  310. }, 5000)
  311. },
  312. destroyed () {
  313. clearInterval(this.timer)
  314. },
  315. methods: {
  316. resize (newRect) {
  317. console.log(newRect)
  318. const params = {
  319. ...this.dotList[this.optDot],
  320. height: newRect.height,
  321. width: newRect.width,
  322. xposition: newRect.left,
  323. yposition: newRect.top
  324. }
  325. updateRemoteOpc(params).then(res => {
  326. console.log(res)
  327. this.dotList[this.optDot].isActive = false
  328. })
  329. },
  330. onCloseRight () {
  331. this.visibleRight = false
  332. },
  333. disposition (val, i) {
  334. val.isActive = true
  335. val.positionFlag = 1
  336. this.optDot = i
  337. this.visibleRight = false
  338. },
  339. handleShow (val, key) {
  340. this.dotList[val].positionFlag = key
  341. },
  342. back () {
  343. const a = document.createElement('a')
  344. a.href = '/sb/position/opc/for/producer'
  345. a.click()
  346. },
  347. getOpcInfo (positionId) {
  348. this.positionId = positionId
  349. queryRemoteOpc({ line: this.positionId })
  350. .then((res) => {
  351. this.dotList = res.data
  352. this.dotList.forEach(item => {
  353. item.isActive = false
  354. if (item.result == null) {
  355. item.result = '-'
  356. }
  357. })
  358. })
  359. this.getImg()
  360. },
  361. getOpcInfoFromRedis (positionId) {
  362. this.positionId = positionId
  363. queryRemoteOpcFromRedis({ line: this.positionId })
  364. .then((res) => {
  365. this.dotList.forEach(item => {
  366. item.isActive = false
  367. res.data.forEach(data => {
  368. if (item.positionNum === data.positionNum) {
  369. item.result = data.result
  370. item.time = data.time
  371. }
  372. })
  373. })
  374. })
  375. this.getImg()
  376. },
  377. getImg () {
  378. fetchSbPosition({ id: this.positionId }).then(res => {
  379. this.imgUrl = res.data.opcImg
  380. })
  381. },
  382. handleChange () {
  383. this.getOpcInfo(this.positionId)
  384. this.getImg()
  385. },
  386. /* handleInfo (remoteOpc) {
  387. const model = this.$refs.detailLogModal
  388. model.base(null, { positionNum: remoteOpc.positionNum })
  389. }, */
  390. handleInfo (remoteOpc) {
  391. const model = this.$refs.detailLogModal
  392. model.base(remoteOpc)
  393. },
  394. handleView (record) {
  395. fetchRemoteOpc({ id: record.id }).then(res => {
  396. const modal = this.$refs.detailModal
  397. modal.base(res.data)
  398. })
  399. },
  400. backParent () {
  401. const a = document.createElement('a')
  402. a.href = '/sb/position/opc/for/producer'
  403. a.target = '_blank'
  404. a.click()
  405. },
  406. handleOk () {
  407. }
  408. }
  409. }
  410. </script>
  411. <style lang="less" scoped>
  412. .main{
  413. position: relative;
  414. }
  415. .info{
  416. font-size: 14px;
  417. font-weight: bold;
  418. color: black;
  419. padding:0 2px;
  420. // transform: scale(0.5);
  421. }
  422. .icon{
  423. font-size: 30px;
  424. color: #fff;
  425. position: absolute;
  426. top:20px;
  427. }
  428. .btn{
  429. position: fixed;
  430. bottom: 10px;
  431. left:50%;
  432. transform: translateX(-50%);
  433. }
  434. </style>