Opc.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.length>0">
  8. <VueDragResize
  9. v-for="item in dotList"
  10. :key="item.id"
  11. v-show="item.positionFlag"
  12. :isActive="item.isActive"
  13. :w="item.width"
  14. :h="item.height"
  15. :minh="20"
  16. :x="item.xposition"
  17. :y="item.yposition"
  18. :isDraggable="item.isActive"
  19. :isResizable="item.isActive"
  20. :stickSize="5"
  21. @dragstop="resize">
  22. <a-tooltip>
  23. <template slot="title">
  24. {{ item.positionNum }}
  25. </template>
  26. <div class="info" @click="handleInfo(item)"> {{ item.positionNum }}</div>
  27. </a-tooltip>
  28. </VueDragResize>
  29. </div>
  30. <a-drawer
  31. title="点位配置"
  32. placement="right"
  33. :closable="false"
  34. :width="350"
  35. :visible="visibleRight"
  36. @close="onCloseRight"
  37. >
  38. <div>
  39. <a-tree-select
  40. style="width: 60%;margin-right:10px;"
  41. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  42. :treeData="treeData"
  43. :treeNodeFilterProp="'title'"
  44. :showSearch="true"
  45. v-model="positionId"
  46. placeholder="请选择"
  47. >
  48. </a-tree-select>
  49. <a-button type="primary" @click="getOpcInfo">搜索</a-button>
  50. </div>
  51. <br>
  52. <a-table
  53. :columns="columns"
  54. :data-source="dotList"
  55. :pagination="{ pageSize: 100 }"
  56. :scroll="{ y: 650 }"
  57. >
  58. <span slot="action" slot-scope="text, record,index">
  59. <a @click="disposition(record,index)">配置</a>
  60. <a-button style="color:#ccc" v-show="record.positionFlag" type="link" icon="eye-invisible" @click="handleShow(index,0)" />
  61. <a-button v-show="!record.positionFlag" type="link" icon="eye" @click="handleShow(index,1)" />
  62. </span>
  63. </a-table>
  64. </a-drawer>
  65. <BaseChartInfo ref="baseChartInfo" @ok="handleOk"/>
  66. </div>
  67. </template>
  68. <script>
  69. import VueDragResize from 'vue-drag-resize'
  70. import { getSbPositionTree, fetchSbPosition } from '@/api/sb/position'
  71. import { queryRemoteOpc, updateRemoteOpc } from '@/api/remote/opc'
  72. import BaseChartInfo from './modules/BaseChartInfo.vue'
  73. export default {
  74. name: 'Opc',
  75. components: {
  76. VueDragResize,
  77. BaseChartInfo
  78. },
  79. data () {
  80. return {
  81. visibleRight: false,
  82. positionId: '',
  83. treeData: [],
  84. optDot: null,
  85. imgUrl: '',
  86. dotList: [],
  87. columns: [
  88. {
  89. title: '位号',
  90. dataIndex: 'positionNum',
  91. key: 'positionNum'
  92. },
  93. {
  94. title: '操作',
  95. key: 'action',
  96. scopedSlots: { customRender: 'action' }
  97. }
  98. ]
  99. }
  100. },
  101. created () {
  102. this.positionId = this.$route.query.line
  103. this.setTree()
  104. this.getOpcInfo()
  105. },
  106. methods: {
  107. resize (newRect) {
  108. console.log(newRect)
  109. const params = {
  110. ...this.dotList[this.optDot],
  111. height: newRect.height,
  112. width: newRect.width,
  113. xposition: newRect.left,
  114. yposition: newRect.top
  115. }
  116. updateRemoteOpc(params).then(res => {
  117. console.log(res)
  118. this.dotList[this.optDot].isActive = false
  119. })
  120. },
  121. onCloseRight () {
  122. this.visibleRight = false
  123. },
  124. disposition (val, i) {
  125. val.isActive = true
  126. val.positionFlag = 1
  127. this.optDot = i
  128. this.visibleRight = false
  129. },
  130. handleShow (val, key) {
  131. this.dotList[val].positionFlag = key
  132. },
  133. getOpcInfo () {
  134. fetchSbPosition({ id: this.positionId }).then(res => {
  135. this.imgUrl = res.data.opcImg
  136. console.log(this.imgUrl)
  137. })
  138. queryRemoteOpc({ line: this.positionId })
  139. .then((res) => {
  140. console.log(res.data)
  141. this.dotList = res.data
  142. this.dotList.forEach(item => {
  143. item.isActive = false
  144. })
  145. })
  146. },
  147. setTree (record = {}) {
  148. getSbPositionTree({ opcFlag: 1 }).then(res => {
  149. this.treeData = res.data
  150. })
  151. },
  152. handleInfo (remoteOpc) {
  153. const model = this.$refs.baseChartInfo
  154. model.base(remoteOpc)
  155. },
  156. handleOk () {
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="less" scoped>
  162. .main{
  163. position: relative;
  164. }
  165. .info{
  166. font-size: 12px;
  167. // transform: scale(0.5);
  168. }
  169. .icon{
  170. font-size: 30px;
  171. color: #fff;
  172. position: absolute;
  173. top:20px;
  174. }
  175. </style>