<template>
  <div class="app-container">
    <!-- 筛选start -->
    <div class="filter-container mb-10">
      <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-input
            v-model="userName"
            placeholder="请输入内容"
            style="width: 180px"
          ></el-input>
        </div>
        <div class="filter-item" >
          手机号：
          <el-input
            v-model="phone"
            placeholder="请输入内容"
            style="width: 180px"
          ></el-input>
        </div>

          <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-select
              v-model="role"
              placeholder="请选择"
              style="width: 200px"
            >
              <el-option label="角色1" value="1"></el-option>
              <el-option label="角色2" 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"
    >
      <el-table-column prop="xh" label="序号" width="70">
      </el-table-column>
      <el-table-column prop="userName" label="姓名" width="">
      </el-table-column>
      <el-table-column prop="sex" label="性别" width="">
      </el-table-column>
      <el-table-column prop="contact" label="联系方式" width="">
      </el-table-column>
      <el-table-column prop="password" label="密码" width="">
      </el-table-column>
      <el-table-column prop="ownerCompany" label="所属企业" width="">
      </el-table-column>
      <el-table-column prop="role" label="角色" width="">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="180">
        <template #default="scope">
          <el-button
            @click="checkItem(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-->




  </div>
</template>

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

export default {
  name: "VariableList",

  components: { DialogComponent, },

  data() {
    return {

      userName:'',
      phone:'',
      region: "",
      role:'',

      currentPage4: 4,

      showDialog: true,

      tableData: [
        {
           xh: "1",
          userName: "张三",
          sex: "男",
          contact: "12345678989 ",
          password: "123456",
          role: "维保 ",
          ownerCompany: "伍继",
        },
         {
          xh: "1",
          userName: "张三",
          sex: "男",
          contact: "12345678989 ",
          password: "123456",
          ownerCompany: "伍继",
           role: "维保 ",
        },
         {
          xh: "1",
          userName: "张三",
          sex: "男",
          contact: "12345678989 ",
          password: "123456",
          ownerCompany: "伍继",
           role: "维保 ",
        },
         {
          xh: "1",
          userName: "张三",
          sex: "男",
          contact: "12345678989 ",
          password: "123456",
          ownerCompany: "伍继",
           role: "维保 ",
        },
        {
          xh: "1",
          userName: "张三",
          sex: "男",
          contact: "12345678989 ",
          password: "123456",
          ownerCompany: "伍继",
           role: "维保 ",
        },
       
      ],
    };

  },
  methods: {

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

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

    // 查看视频
    checkItem(row) {
      console.log(row);
      this.tableItem = row;
      this.dialogTitle = "查看";
      this.showDialog = true;
      this.$nextTick(() => {
        this.$refs["dialogComponent"].showDialog = true;
      });
    },

    // 添加操作
    addItem() {
      this.tableItem = {
        id: "",
        stationName: "",
        xh: "",
        userName: "",
        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>
