MediaServerManger.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div id="mediaServerManger">
  3. <el-container>
  4. <el-header>
  5. <uiHeader></uiHeader>
  6. </el-header>
  7. <el-main id="msMain">
  8. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
  9. <span style="font-size: 1rem; font-weight: bold;">节点列表</span>
  10. </div>
  11. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
  12. <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加节点</el-button>
  13. </div>
  14. <el-row :gutter="12">
  15. <el-col :span="num" v-for="item in mediaServerList" :key="item.id">
  16. <el-card shadow="hover" :body-style="{ padding: '0px'}" class="server-card">
  17. <div class="card-img-zlm"></div>
  18. <div style="padding: 14px;text-align: left">
  19. <span style="font-size: 16px">{{item.id}}</span>
  20. <el-button icon="el-icon-edit" style="padding: 0;float: right;" type="text" @click="edit(item)">编辑</el-button>
  21. <el-button icon="el-icon-delete" style="margin-right: 10px;padding: 0;float: right;" type="text" @click="del(item)">移除</el-button>
  22. <div style="margin-top: 13px; line-height: 12px; ">
  23. <span style="font-size: 14px; color: #999; margin-top: 5px; ">{{item.ip}}</span>
  24. <span style="font-size: 14px; color: #999; margin-top: 5px; float: right;">{{item.createTime}}</span>
  25. </div>
  26. </div>
  27. <i v-if="item.status" class="iconfont icon-online server-card-status-online" title="在线"></i>
  28. <i v-if="!item.status" class="iconfont icon-online server-card-status-offline" title="离线"></i>
  29. </el-card>
  30. </el-col>
  31. </el-row>
  32. <mediaServerEdit ref="mediaServerEdit" ></mediaServerEdit>
  33. </el-main>
  34. </el-container>
  35. </div>
  36. </template>
  37. <script>
  38. import uiHeader from './UiHeader.vue'
  39. import MediaServer from './service/MediaServer'
  40. import mediaServerEdit from './dialog/MediaServerEdit'
  41. export default {
  42. name: 'mediaServerManger',
  43. components: {
  44. uiHeader,mediaServerEdit
  45. },
  46. data() {
  47. return {
  48. mediaServerObj : new MediaServer(),
  49. mediaServerList: [], //设备列表
  50. winHeight: window.innerHeight - 200,
  51. updateLooper: false,
  52. currentPage:1,
  53. count:15,
  54. num: this.getNumberByWidth(),
  55. total:0,
  56. };
  57. },
  58. computed: {
  59. },
  60. mounted() {
  61. this.initData();
  62. this.updateLooper = setInterval(this.initData, 2000);
  63. },
  64. destroyed() {
  65. clearTimeout(this.updateLooper);
  66. },
  67. methods: {
  68. initData: function() {
  69. this.getServerList()
  70. },
  71. currentChange: function(val){
  72. this.currentPage = val;
  73. this.getServerList();
  74. },
  75. handleSizeChange: function(val){
  76. this.count = val;
  77. this.getServerList();
  78. },
  79. getServerList: function(){
  80. this.mediaServerObj.getMediaServerList((data)=>{
  81. this.mediaServerList = data.data;
  82. })
  83. },
  84. add: function (){
  85. this.$refs.mediaServerEdit.openDialog(null, this.initData)
  86. },
  87. edit: function (row){
  88. this.$refs.mediaServerEdit.openDialog(row, this.initData)
  89. },
  90. del: function (row){
  91. this.$confirm('确认删除此节点?', '提示', {
  92. confirmButtonText: '确定',
  93. cancelButtonText: '取消',
  94. type: 'warning'
  95. }).then(() => {
  96. this.mediaServerObj.delete(row.id, (data)=>{
  97. if (data.code === 0) {
  98. this.$message({
  99. type: 'success',
  100. message: '删除成功!'
  101. });
  102. }
  103. })
  104. }).catch(() => {
  105. });
  106. },
  107. getNumberByWidth(){
  108. let candidateNums = [1, 2, 3, 4, 6, 8, 12, 24]
  109. let clientWidth = window.innerWidth - 30;
  110. let interval = 20;
  111. let itemWidth = 360;
  112. let num = (clientWidth + interval)/(itemWidth + interval)
  113. let result = Math.ceil(24/num);
  114. let resultVal = 24;
  115. for (let i = 0; i < candidateNums.length; i++) {
  116. let value = candidateNums[i]
  117. if (i + 1 >= candidateNums.length) {
  118. return 24;
  119. }
  120. if (value <= result && candidateNums[i + 1] > result ) {
  121. return value;
  122. }
  123. }
  124. return resultVal;
  125. },
  126. dateFormat: function(/** timestamp=0 **/) {
  127. var ts = arguments[0] || 0;
  128. var t,y,m,d,h,i,s;
  129. t = ts ? new Date(ts*1000) : new Date();
  130. y = t.getFullYear();
  131. m = t.getMonth()+1;
  132. d = t.getDate();
  133. h = t.getHours();
  134. i = t.getMinutes();
  135. s = t.getSeconds();
  136. // 可根据需要在这里定义时间格式
  137. return y+'-'+(m<10?'0'+m:m)+'-'+(d<10?'0'+d:d)+' '+(h<10?'0'+h:h)+':'+(i<10?'0'+i:i)+':'+(s<10?'0'+s:s);
  138. }
  139. }
  140. };
  141. </script>
  142. <style>
  143. .server-card{
  144. position: relative;
  145. margin-bottom: 20px;
  146. }
  147. .card-img-zlm{
  148. width: 200px; height: 200px;
  149. background: url('~@static/images/zlm-logo.png') no-repeat center;
  150. background-position: center;
  151. background-size: contain;
  152. margin: 0 auto;
  153. }
  154. .server-card-status-online{
  155. position: absolute;
  156. right: 20px;
  157. top: 20px;
  158. color: #3caf36;
  159. font-size: 18px;
  160. }
  161. .server-card-status-offline{
  162. position: absolute;
  163. right: 20px;
  164. top: 20px;
  165. color: #808080;
  166. font-size: 18px;
  167. }
  168. .server-card:hover {
  169. border: 1px solid #adadad;
  170. }
  171. </style>