cameraInfo-bindClass.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <el-dialog
  3. :visible.sync="showDialog"
  4. :title="title"
  5. :modal-append-to-body="false"
  6. style="text-align:left;"
  7. @close="closeDialog"
  8. >
  9. <div>
  10. <el-input placeholder="输入查询班级名称" v-model="className" style="width:300px;">
  11. <el-button slot="append" icon="el-icon-search"></el-button>
  12. </el-input>
  13. </div>
  14. <el-table
  15. :data="filterData"
  16. v-loading="loading"
  17. height="400"
  18. stripe
  19. >
  20. <el-table-column prop="className" label="班级名称"></el-table-column>
  21. <el-table-column prop="top" label="是否绑定" width="180">
  22. <template slot-scope="{row}">
  23. <el-switch v-model="row.enabled"
  24. active-color="#13ce66" inactive-color="#ff4949"
  25. @change="handleBindClass(row)"
  26. ></el-switch>
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. </el-dialog>
  31. </template>
  32. <script>
  33. import Constant from "@/constant";
  34. import cameraInfoApi from "@/api/base/cameraInfo";
  35. export default {
  36. props: ["cameraInfo"],
  37. data(){
  38. return {
  39. title: "绑定班级",
  40. showDialog: true,
  41. loading: false,
  42. tableData: [],
  43. className: ''
  44. }
  45. },
  46. computed: {
  47. filterData() {
  48. if(this.className.length==0){
  49. return this.tableData;
  50. }
  51. else{
  52. return this.tableData.filter(item=>{
  53. return item.className.indexOf(this.className)!=-1;
  54. });
  55. }
  56. }
  57. },
  58. methods: {
  59. queryClass() {
  60. },
  61. closeDialog() {
  62. this.$emit("close", false);
  63. },
  64. handleBindClass(row) {
  65. cameraInfoApi.bindClass(row).then(response=>{
  66. var jsonData = response.data;
  67. if(!jsonData.result){
  68. this.$message.warning(jsonData.message + "");
  69. }
  70. });
  71. }
  72. },
  73. mounted() {
  74. this.loading = true;
  75. cameraInfoApi.bindClassList(this.cameraInfo.id).then(response=>{
  76. this.loading = false;
  77. var jsonData = response.data;
  78. if(jsonData.result){
  79. this.tableData = jsonData.data;
  80. }
  81. else{
  82. this.$message.warning(jsonData.message + "");
  83. }
  84. });
  85. }
  86. }
  87. </script>
  88. <style>
  89. </style>