<template>
  <div class="app-container">
    <!-- 筛选start -->
    <div class="filter-container mb-20">
      <div class="left">
        <div>
          <span class="" style="margin-right: 30px">现场档案列表</span>
          <el-button icon="el-icon-plus" type="success" @click="addItem()"
            >新增</el-button
          >
        </div>

        <div style="margin-top: 20px">

          <div class="filter-item">
            站点:
            <el-select
              v-model="region"
              placeholder="请选择"
              style="width: 150px"
            >
              <el-option label="站点一" value="1"></el-option>
              <el-option label="站点二" value="2"></el-option>
            </el-select>
          </div>

          <div class="filter-item">
            电试日期:
             <el-date-picker
              v-model="value4"
              type="dates"
              placeholder="请选择"
              style="width: 150px"
            >
            </el-date-picker>
          </div>

         
          <div class="filter-item">
            状态:
            <el-select
              v-model="region"
              placeholder="请选择"
              style="width: 200px"
            >
              <el-option label="已执行" value="1"></el-option>
              <el-option label="未执行" value="2"></el-option>
            </el-select>
          </div>
          <el-button type="primary" icon="el-icon-search" class="search-button"
            >搜索</el-button
          >
        </div>
      </div>

      <div class="right">
        <el-button type="primary">导出</el-button>
      </div>
    </div>
    <!-- 筛选end -->

    <!-- 表格start -->
    <el-table
      :data="tableData"
      border
      stripe
      :header-cell-style="headClass"
       :cell-style="cellStyle"
  
    >
      <el-table-column prop="xh" label="序号" width="">
      </el-table-column>
      <el-table-column prop="siteName" label="站点名称" width="">
      </el-table-column>
      <el-table-column prop="siteCode" label="站点编号" width="">
      </el-table-column>
      <el-table-column prop="siteRoute" label="线路" width="">
      </el-table-column>
      <el-table-column prop="supervision" label="监察" width="">
      </el-table-column>
      <el-table-column prop="updataTime" label="更新时间" width="">
      </el-table-column>
      <el-table-column prop="defect" label="缺陷统计" width="">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="180">
        <template #default="scope">
          <el-button
            @click="checkVideo(scope.$index, scope.row)"
            type="text"
            size="small"
            class="delete-text"
            >查看</el-button
          >
          <el-button
            type="text"
            size="small"
            @click.prevent="editRow(scope.row)"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格end -->

    <!-- 分页start -->
    <div class="paginationBlock">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400"
      >
      </el-pagination>
    </div>

    <!-- 分页end -->

    <!--弹框组件开始-----------------------start-->
    <dialog-component
      v-if="showDialog"
      ref="dialogComponent"
      :dialog-title="dialogTitle"
      :item-info="tableItem"
      @closeDialog="closeDialog"
    ></dialog-component>
    <!--弹框组件开始-----------------------end-->

     <!--弹框组件开始-----------------------start-->
    <check-video
      v-if="showDialog"
      ref="checkVideo"
      :dialog-title="dialogTitle"
      :item-info="tableItem"
      @closeDialog="closeDialog"
    ></check-video>
    <!--视频弹框组件开始-----------------------end-->


  </div>
</template>

<script>
import DialogComponent from "./dialogComponent";
import checkVideo from "./checkVideo";

export default {
  name: "VariableList",

  components: { DialogComponent,checkVideo },

  data() {
    return {
      select: 1,
      currentPage4: 4,

      value4: "请选择",

      showDialog: false,

      region: "",
      tableData: [
        {
           xh: "1",
          siteName: "测试站点1",
          siteCode: "cszd1",
          siteRoute: "变线1",
          supervision: "李四",
          updataTime: "2021-09-22 18:22:22",
          defect: "5",
        },
        {
          xh: "1",
          siteName: "测试站点1",
          siteCode: "cszd1",
          siteRoute: "变线1",
          supervision: "李四",
          updataTime: "2021-09-22 18:22:22",
          defect: "10",
        },
        {
          xh: "1",
          siteName: "测试站点1",
          siteCode: "cszd1",
          siteRoute: "变线1",
          supervision: "李四",
          updataTime: "2021-09-22 18:22:22",
          defect: "4",
        },
        {
          xh: "1",
          siteName: "测试站点1",
          siteCode: "cszd1",
          siteRoute: "变线1",
          supervision: "李四",
          updataTime: "2021-09-22 18:22:22",
          defect: "3",
        },
        {
          xh: "1",
          siteName: "测试站点1",
          siteCode: "cszd1",
          siteRoute: "变线1",
          supervision: "李四",
          updataTime: "2021-09-22 18:22:22",
          defect: "2",
        },
       
      ],
    };
  },
  methods: {

    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },

    // 表头样式设置
    headClass() {
      return "background:#FAFAFA;";
    },

    // 查看视频
    checkVideo() {

      this.tableItem = {
        id: "",
        stationName: "",
        watchName: "",
        watchCode: "",
        siteList: [],
        done: "",
        guaZai: "",
        checked:true,
        resource:''
      };
      this.dialogTitle = "现场档案详情";
      this.showDialog = true;
      this.$nextTick(() => {
        this.$refs["checkVideo"].showDialog = true;
      });
    },




    // 添加操作
    addItem() {
      this.tableItem = {
        id: "",
        stationName: "",
        xh: "",
        siteName: "",
        siteList: [],
        done: "",
        guaZai: "",
        checked: true,
      };
      this.dialogTitle = "新增";
      this.showDialog = true;
      this.$nextTick(() => {
        this.$refs["dialogComponent"].showDialog = true;
      });
    },
    // 编辑操作
    editRow(row) {
      console.log(row);
      this.tableItem = row;
      this.dialogTitle = "编辑";
      this.showDialog = true;
      this.$nextTick(() => {
        this.$refs["dialogComponent"].showDialog = true;
      });
    },
    // 关闭操作
    closeDialog(flag) {
      if (flag) {
        // 重新刷新表格内容
        this.fetchData();
      }
      this.showDialog = false;
    },

   
  },
};
</script>

<style lang="scss" scoped>
</style>
