index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="check-btns">
  3. <div class="type-check">
  4. <slot name="type-check">
  5. <el-button
  6. :type="displayType == '1'?'primary':'default'"
  7. size="mini"
  8. @click="checkType(1)"
  9. >图表</el-button>
  10. <el-button
  11. :type="displayType == '2'?'primary':'default'"
  12. size="mini"
  13. @click="checkType(2)"
  14. >列表</el-button>
  15. </slot>
  16. </div>
  17. <div class="search-box">
  18. <slot name="search-common">
  19. <el-input
  20. placeholder="请输入内容"
  21. size="mini"
  22. clearable
  23. v-model="searchVal"
  24. suffix-icon="el-icon-search"
  25. class="input-with-select"
  26. @change="searchEquipList()"
  27. >
  28. <el-select
  29. v-model="selectItem"
  30. class="select02"
  31. slot="prepend"
  32. placeholder="请选择"
  33. @change="selClear()">
  34. <el-option label="设备ID" value="1"></el-option>
  35. <el-option label="设备名" value="2"></el-option>
  36. </el-select>
  37. </el-input>
  38. <el-select
  39. v-model="is_online"
  40. class="select01"
  41. clearable
  42. size="mini"
  43. placeholder="请选择在线状态"
  44. @change="isOnlineSelect()"
  45. >
  46. <el-option label="全部" value></el-option>
  47. <el-option label="在线" value="1"></el-option>
  48. <el-option label="离线" value="0"></el-option>
  49. </el-select>
  50. </slot>
  51. <slot name="search-box"></slot>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. props: ['facilityType'],
  58. data(){
  59. return {
  60. displayType:1 ,
  61. selectItem: "1", //1设备号,2用户名
  62. searchVal: "",
  63. f_id:'',
  64. ename:'',
  65. is_online:null
  66. }
  67. },
  68. watch: {},
  69. methods:{
  70. checkType(i){
  71. this.displayType=i;
  72. this.$emit('fun', this.displayType)
  73. },
  74. // 搜索组合数据
  75. searchEquipList() {
  76. if (this.selectItem == 1) {
  77. this.f_id = this.searchVal;
  78. } else if (this.selectItem == 2) {
  79. this.ename = this.searchVal;
  80. }
  81. this.$emit('fun2', {f_id:this.f_id,ename:this.ename})
  82. },
  83. selClear() {
  84. this.searchVal = "";
  85. this.f_id = "";
  86. this.ename = "";
  87. this.$emit('fun2', {f_id:this.f_id,ename:this.ename})
  88. },
  89. isOnlineSelect(){
  90. this.$emit('fun3', this.is_online)
  91. }
  92. },
  93. mounted() {
  94. // 判断当前页面是否为杀虫灯,如果为杀虫灯就先显示列表模式
  95. if (this.facilityType == 'scd') {
  96. this.displayType = 2
  97. this.$emit('fun', this.displayType)
  98. } else {
  99. this.displayType = 1
  100. this.$emit('fun', this.displayType)
  101. }
  102. },
  103. }
  104. </script>
  105. <style lang='less' scoped>
  106. .check-btns{
  107. display:flex;
  108. justify-content: space-between;
  109. margin-bottom:20px;
  110. align-items: center;
  111. .search-box{
  112. text-align: right;
  113. .el-input {
  114. width: 400px;
  115. vertical-align: middle;
  116. }
  117. .select01 {
  118. width: 200px;
  119. vertical-align: middle;
  120. }
  121. /deep/.select02 {
  122. width: 86px;
  123. }
  124. .input-with-select{
  125. width: 260px;
  126. }
  127. }
  128. }
  129. </style>