MediaServerManger.vue 5.5 KB

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