<template>
  <div class="manage-container">
    <el-row>
      <el-form ref="form" :model="form" label-width="100px">
        <vab-query-form>
          <el-form-item :label="$t('defalult.sj')">
            <el-date-picker
              type="month"
              :placeholder="$t('defalult.xzrq')"
            ></el-date-picker>
          </el-form-item>
          <el-form-item :label="$t('dataEnquiry.jd')">
            <el-select v-model="value" :placeholder="$t('dataEnquiry.qxzjd')">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('dataEnquiry.sq')">
            <el-select v-model="value" placeholder="请选择社区">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('dataEnquiry.zdmc')">
            <el-input
              v-model="queryForm.name"
              :placeholder="$t('dataEnquiry.qsrzdmc')"
            ></el-input>
          </el-form-item>
          <el-button type="primary" @click="search">
            {{ $t('defalult.cx') }}
          </el-button>
          <el-button type="primary" @click="search">
            {{ $t('defalult.chongz') }}
          </el-button>
          <el-button type="primary" @click="search">
            {{ $t('defalult.dc') }}
          </el-button>
        </vab-query-form>
      </el-form>
    </el-row>
    <el-table
      v-loading="listLoading"
      :data="data"
      border
      stripe
      style="width: 100%"
    >
      <el-table-column
        prop="id"
        :label="$t('trigger.xh')"
        width="60"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="jiedao"
        :label="$t('maintenance.sbmc')"
        width="120"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="shequ"
        :label="$t('dataEnquiry.jd')"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="mingcheng"
        label="设施名称"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="guimo"
        label="运行时长(min)"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="kaishi1"
        label="停用时长(min)"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="jieshu1"
        label="故障时长(min)"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="dangqian"
        label="设施运行率(%)"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="kaishi2"
        label="设施故障率"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column fixed="right" :label="$t('defalult.cz')" align="center">
        <template #default="{ row }">
          <el-button type="text" @click="handleDelete(row)">
            {{ $t('defalult.sc') }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <vab-query-form>
      <vab-query-form-right-panel>
        <el-pagination
          :background="background"
          :current-page="queryForm.page"
          :layout="layout"
          :page-size="queryForm.size"
          :total="total"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        ></el-pagination>
      </vab-query-form-right-panel>
    </vab-query-form>
  </div>
</template>
<script>
// import { getList } from '@/api/group'
export default {
  name: 'Index',
  components: {},
  data() {
    return {
      data: [
        {
          id: 1,
          jiedao: '设备名称',
          shequ: '街道',
          mingcheng: '设施名字',
          guimo: '40',
          kaishi1: '28',
          jieshu1: '222',
          dangqian: '37',
          kaishi2: '87',
        },
        {
          id: 2,
          jiedao: '设备名称',
          shequ: '街道',
          mingcheng: '设施名字',
          guimo: '40',
          kaishi1: '28',
          jieshu1: '222',
          dangqian: '37',
          kaishi2: '87',
        },
        {
          id: 3,
          jiedao: '设备名称',
          shequ: '街道',
          mingcheng: '设施名字',
          guimo: '50',
          kaishi1: '28',
          jieshu1: '222',
          dangqian: '37',
          kaishi2: '87',
        },
      ],
      options: [
        {
          value: '选项1',
          label: '黄金糕',
        },
        {
          value: '选项2',
          label: '双皮奶',
        },
        {
          value: '选项3',
          label: '蚵仔煎',
        },
        {
          value: '选项4',
          label: '龙须面',
        },
        {
          value: '选项5',
          label: '北京烤鸭',
        },
      ],
      lazy: true,
      activeName: 'first',
      layout: 'total, sizes, prev, pager, next, jumper',
      total: 0,
      input: '',
      textarea: '',
      list: [],
      background: true,
      listLoading: true,
      elementLoadingText: '正在加载...',
      queryForm: {
        page: 1,
        size: 20,
        name: '',
      },
    };
  },
  computed: {
    height() {
      return 500;
    },
  },
  created() {
    this.fetchData();
  },
  methods: {
    async fetchData() {
      this.listLoading = true;
      // const { data, total } = await getList(this.queryForm)
      // this.projectData = data.items
      // this.total = total
      // console.log(this.projectData)
      setTimeout(() => {
        this.listLoading = false;
      }, 500);
    },
    handleAdd() {
      this.$refs['edit'].showEdit();
    },
    handleEdit(row) {
      this.$refs['edit'].showEdit(row);
    },
    handleQuery() {
      this.queryForm.page = 1;
      this.fetchData();
    },
    handleSizeChange(val) {
      this.queryForm.size = val;
      this.fetchData();
    },
    handleCurrentChange(val) {
      this.queryForm.page = val;
      this.fetchData();
    },
    handleDelete(row) {
      // let that = this
      if (row.id) {
        this.$confirm('你确定要删除当前项吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            this.$message({
              type: 'success',
              message: '删除成功',
            });
            // const { msg } = doDelete({ groupId: row.id })
            // this.$message({
            //   type: 'success',
            //   message: msg == undefined ? '删除成功' : msg,
            // })
            // setTimeout(function () {
            //   that.fetchData()
            // }, 1000)
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除',
            });
          });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.manage-container {
  width: 100%;
  .vab-query-form {
    margin-bottom: 30px;
    .el-input {
      width: 180px;
      margin-right: 20px;
    }
  }
}
</style>

<style lang="scss">
.el-submenu__title:hover {
  background-color: rgba(#1890ff, 0.085) !important;
  color: hsla(208, 100%, 55%, 0.95) !important;
}
</style>
