index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <el-row style="height: 100%" :gutter="10">
  3. <el-col :span="18" style="height: 100%">
  4. <el-row style="height: 66%" :gutter="10">
  5. <el-col :span="8" style="height: 100%">
  6. <el-card class="tableHeight">
  7. <div slot="header" class="clearfix">
  8. <span>网络组参数设置</span>
  9. <el-select v-model="selectedGroupId" size="mini" style="width: 40%;float: right;background-color: #8CC0FB;"
  10. @change="selectChange">
  11. <el-option v-for="item in networkGroupList"
  12. :key="item.id"
  13. :label="item.name"
  14. :value="item.id"/>
  15. </el-select>
  16. </div>
  17. <el-table height="90%" :data="Params" style="width: 100%;overflow-y: auto" fit size="mini">
  18. <el-table-column width="80" prop="key" label="属性"></el-table-column>
  19. <el-table-column width="80" prop="value" label="值"></el-table-column>
  20. <el-table-column label="操作" align="center">
  21. <template slot-scope="scope">
  22. <el-switch v-if="scope.row.key === '链路开关'" active-text="开" inactive-text="关"
  23. v-model="linkVUProps.linkSwitchBoolean" :change="switchChange()">
  24. </el-switch>
  25. <el-switch v-if="scope.row.key === '静默状态'" active-text="非静默" inactive-text="静默"
  26. v-model="linkVUProps.linkSilentBoolean" :change="switchChange()">
  27. </el-switch>
  28. <el-select v-if="scope.row.key === '通信速率'" v-model="linkVUProps.linkSpeed" size="mini"
  29. placeholder="选择速率">
  30. <el-option v-for="item in linkVUSpeedOptions" :key="item.value" :label="item.label"
  31. :value="item.label"></el-option>
  32. </el-select>
  33. <el-select v-if="scope.row.key === '传输模式'" v-model="linkVUProps.linkQuality" size="mini"
  34. placeholder="选择质量">
  35. <el-option v-for="item in linkVUQualityOptions" :key="item.value" :label="item.label"
  36. :value="item.label"></el-option>
  37. </el-select>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. <div >
  42. <el-button size="mini" type="success" style="float: right"
  43. :disabled="!editable">修改参数</el-button>
  44. <el-button size="mini" type="info" style="float: right"
  45. :disabled="editable()"
  46. @click="getParams"
  47. >刷新</el-button>
  48. </div>
  49. </el-card>
  50. </el-col>
  51. <el-col :span="16" style="height: 100%">
  52. <el-card class="radar" border>
  53. <div slot="header" class="clearfix" >
  54. <span>通信状态显示</span>
  55. </div>
  56. <div class="echarts-box">
  57. <div ref="chart" id="radarEchart"></div>
  58. </div>
  59. </el-card>
  60. </el-col>
  61. </el-row>
  62. <el-row style="height: calc(34% - 6px); margin-top: 6px;" :gutter="10">
  63. <el-card class="box-card">
  64. <div slot="header" class="clearfix" style="height: 28px">
  65. <span>已接收消息</span>
  66. </div>
  67. <el-table :data="receivedMessage" size="mini" height="tableHeight">
  68. <el-table-column prop="time" label="时间"></el-table-column>
  69. <el-table-column prop="translation" label="传输双方" ></el-table-column>
  70. <el-table-column prop="type" label="主题"></el-table-column>
  71. <el-table-column prop="status" label="状态" width="150">
  72. </el-table-column>
  73. </el-table>
  74. </el-card>
  75. </el-row>
  76. </el-col>
  77. <el-col :span="6" style="height: 100%;overflow-y: auto">
  78. <el-row style="height: calc(36%)">
  79. <el-card class="box-card">
  80. <div slot="header" class="clearfix" style="height: 28px">
  81. <span>已发送消息</span>
  82. </div>
  83. <el-table :data="sendMessage" fit size="mini" height="sendMessageHeight">
  84. <el-table-column width="80" prop="time" label="时间"></el-table-column>
  85. <el-table-column width="90" prop="translation" label="传输双方"></el-table-column>
  86. <el-table-column prop="type" label="主题"></el-table-column>
  87. <el-table-column width="60" prop="status" label="状态"></el-table-column>
  88. </el-table>
  89. </el-card>
  90. </el-row>
  91. <el-row style="height: calc(64% - 6px); margin-top: 6px;">
  92. <el-card class="target">
  93. <div slot="header" class="clearfix" style="height: 28px">
  94. <span>成员列表</span>
  95. </div>
  96. <el-table height="tableHeight" :data="members" border fit size="mini">
  97. <el-table-column prop="id" label="平台ID"> </el-table-column>
  98. <el-table-column prop="isOnline" label="是否在网"> </el-table-column>
  99. <el-table-column prop="status" label="静默状态"> </el-table-column>
  100. <el-table-column prop="linkModel" label="连接方式"> </el-table-column>
  101. </el-table>
  102. </el-card>
  103. </el-row>
  104. </el-col>
  105. </el-row>
  106. </template>
  107. <script>
  108. import {Message} from "element-ui";
  109. export default {
  110. data() {
  111. return {
  112. selectedGroupId: null,
  113. selectedGroup: null,
  114. networkGroupList: [],
  115. chartInstance: null,
  116. nodes: [],
  117. edges: [],
  118. sendMessage: [],
  119. receivedMessage: [],
  120. members: [],
  121. tableHeight: "calc(100vh - 30px)",
  122. Params: [{
  123. key: "链路开关",
  124. value: "开"
  125. },
  126. {
  127. key: "静默状态",
  128. value: "非静默"
  129. },
  130. {
  131. key: "通信速率",
  132. value: "速率1"
  133. },
  134. {
  135. key: "传输模式",
  136. value: "模式1"
  137. }
  138. ],
  139. linkVUProps: {
  140. linkSwitch: 1,
  141. linkSilent: 1,
  142. linkSwitchBoolean: true,
  143. linkSilentBoolean: true,
  144. linkSpeed: null,
  145. platInfo: null,
  146. linkEdit: null,
  147. linkQuality: null,
  148. },
  149. linkJProps: {
  150. WorkMode: 1,
  151. WireLessStatus: 1,
  152. WorkModeBoolean: true,
  153. WireLessStatusBoolean: true,
  154. PlatType: null,
  155. },
  156. linkVUSpeedOptions: [
  157. {value: 0, label: "无报告"},
  158. {value: 1, label: "2.4kbps"},
  159. {value: 2, label: "4.8kbps"},
  160. {value: 3, label: "6.4kbps"},
  161. {value: 4, label: "128kbps"},
  162. {value: 5, label: "256kbps"},
  163. {value: 6, label: "512kbps"},
  164. {value: 7, label: "1Mbps"},
  165. {value: 8, label: "2Mbps"},
  166. ],
  167. linkVUQualityOptions: [
  168. {value: 1, label: "可靠性"},
  169. {value: 2, label: "实时性"},
  170. ],
  171. };
  172. },
  173. created() {
  174. },
  175. activated() {
  176. this.init();
  177. },
  178. deactivated() {
  179. if(this.interval){
  180. clearInterval(this.interval)
  181. }
  182. },
  183. mounted() {
  184. this.init();
  185. // 页面加载设置高度自适应
  186. window.onresize = () => {
  187. this.resizeDom();
  188. };
  189. // 页面加载设置高度自适应
  190. this.resizeDom();
  191. this.interval=setInterval(this.fetchData, 5000)
  192. },
  193. methods: {
  194. async init() {
  195. await this.getNetworkGroupList();
  196. this.initGroup()
  197. if (this.selectedGroupId != null) {
  198. this.initChart()
  199. this.initSend()
  200. this.initReceived()
  201. this.initMembers()
  202. this.getParams()
  203. }
  204. },
  205. initGroup() {
  206. let flag = true;
  207. if (this.selectedGroupId !== 0) {
  208. for (let i = 0; i < this.networkGroupList.length; i++) {
  209. if (this.selectedGroupId === this.networkGroupList[i].id) {
  210. flag = false;
  211. this.selectedGroup = this.networkGroupList[i]
  212. }
  213. }
  214. if (flag) {
  215. this.selectedGroupId = null;
  216. this.selectedGroup = null;
  217. }
  218. }
  219. },
  220. selectChange() {
  221. for (let i = 0; i < this.networkGroupList.length; i++) {
  222. if (this.selectedGroupId === this.networkGroupList[i].id) {
  223. this.selectedGroup = this.networkGroupList[i];
  224. break
  225. }
  226. }
  227. this.initChart();
  228. this.initSend();
  229. this.initReceived();
  230. this.initMembers();
  231. },
  232. getNetworkGroupList() {
  233. this.$http({
  234. url: this.$http.adornUrl("/communication/getNetworkGroups"),
  235. method: "get",
  236. }).then(({data}) => {
  237. if (data && data.code === 0) {
  238. this.networkGroupList = data.data;
  239. if (this.networkGroupList.length === 0) {
  240. Message.info("暂未设置网络组信息")
  241. }
  242. } else {
  243. this.networkGroupList = [];
  244. Message.error("无法获取网络组信息")
  245. }
  246. })
  247. },
  248. editable() {
  249. return this.selectedGroupId === 0;
  250. },
  251. fetchData(){
  252. if(this.selectedGroupId!=null){
  253. this.initMembers();
  254. this.initChart();
  255. this.initSend();
  256. this.initReceived();
  257. }
  258. },
  259. initChart() {
  260. this.$http({
  261. url: this.$http.adornUrl("/communication/getChart?id=" + this.selectedGroupId),
  262. method: "get",
  263. }).then(({data}) => {
  264. if (data && data.code === 0) {
  265. this.nodes = data.nodes;
  266. this.edges = data.edges;
  267. if (this.chartInstance == null) {
  268. this.createChartInstance(this.$refs.chart);
  269. }
  270. this.chartInstance.setOption({
  271. series: [{
  272. data: this.nodes,
  273. links: this.edges,
  274. }]
  275. })
  276. }
  277. })
  278. },
  279. initSend() {
  280. this.$http({
  281. url: this.$http.adornUrl("/communication/getSendMessage?id=" + this.selectedGroupId),
  282. method: "get",
  283. }).then(({data}) => {
  284. if (data && data.code === 0) {
  285. this.sendMessage = data.data;
  286. }
  287. })
  288. },
  289. initReceived() {
  290. this.$http({
  291. url: this.$http.adornUrl("/communication/getSendMessage?id=" + this.selectedGroupId),
  292. method: "get",
  293. }).then(({data}) => {
  294. if (data && data.code === 0) {
  295. this.receivedMessage = data.data;
  296. }
  297. })
  298. },
  299. initMembers(){
  300. this.$http({
  301. url: this.$http.adornUrl("/communication/getMembers?id=" + this.selectedGroupId),
  302. method: "get",
  303. }).then(({data}) => {
  304. if (data && data.code === 0) {
  305. this.members = data.data;
  306. }
  307. })
  308. },
  309. getParams(){},
  310. createChartInstance(dom) {
  311. this.chartInstance = this.$echarts.init(dom)
  312. const chartOption = {
  313. title: {},
  314. animation: true,
  315. series: [
  316. {
  317. type: "graph",
  318. layout: "force",
  319. symbolSize: 30,
  320. roam: true,
  321. label: {
  322. show: true,
  323. },
  324. edgeSymbol: ["circle"],
  325. edgeSymbolSize: [4, 10],
  326. edgeLabel: {
  327. fontSize: 12,
  328. },
  329. emphasis: {
  330. focus: "adjacency",
  331. lineStyle: {
  332. width: 10,
  333. },
  334. },
  335. force: {
  336. repulsion: 1000,
  337. edgeLength: [10, 50],
  338. },
  339. draggable: true,
  340. cursor: "pointer",
  341. lineStyle: {
  342. opacity: 0.9,
  343. width: 2,
  344. curveness: 0.2,
  345. },
  346. },
  347. ],
  348. };
  349. this.chartInstance.setOption(chartOption)
  350. },
  351. //通过窗体高宽计算容器高宽,渲染echart图表的div的宽高度以达到自适应目的
  352. resizeDom() {
  353. const boxHeight =
  354. document.getElementsByClassName("echarts-box")[0].clientHeight;
  355. var Echart = document.getElementById("radarEchart");
  356. Echart.style.height = boxHeight - 65 + "px";
  357. this.$echarts.init(document.getElementById("radarEchart")).resize();
  358. },
  359. //变更参数
  360. handleEdit() {
  361. console.log("aaa")
  362. },
  363. switchChange() {
  364. if (this.currentLink === 1) {
  365. this.linkVUProps.linkSilent =
  366. this.linkVUProps.linkSilentBoolean == true ? 1 : 0;
  367. this.linkVUProps.linkSwitch =
  368. this.linkVUProps.linkSwitchBoolean == true ? 1 : 0;
  369. } else if (this.currentLink === 2) {
  370. this.linkJProps.WireLessStatus =
  371. this.linkJProps.WireLessStatusBoolean == true ? 1 : 0;
  372. this.linkJProps.WorkMode =
  373. this.linkJProps.WorkModeBoolean == true ? 1 : 2;
  374. }
  375. },
  376. }
  377. }
  378. </script>
  379. <style scoped>
  380. .echarts-box {
  381. height: 100%;
  382. width: 100%;
  383. }
  384. .radar {
  385. height: 100%;
  386. }
  387. </style>