<template>
  <div class="manage-container">
    <el-row>
      <el-form ref="form" :model="form" label-width="80px">
        <vab-query-form>
          <el-form-item label="时间">
            <el-date-picker
              v-model="value1"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="站点名称">
            <el-input
              v-model="queryForm.name"
              placeholder="请输入站点名称"
            ></el-input>
          </el-form-item>
          <el-form-item label="站点类型">
            <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="问题描述">
            <el-input
              v-model="queryForm.name"
              placeholder="请输入问题描述"
            ></el-input>
          </el-form-item>
          <el-button type="primary" @click="search">查询</el-button>
          <el-button type="primary" @click="search">导出</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="序号"
        width="60"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="jiedao"
        label="上报时间"
        width="120"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="shequ"
        label="优先级"
        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="站点类型"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="kaishi1"
        label="站点名称"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="jieshu1"
        label="问题描述"
        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
        prop="jieshu2"
        label="联系方式"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="jieshu3"
        label="问题状态"
        width="200"
        align="center"
      ></el-table-column>
      <el-table-column fixed="right" label="操作" align="center">
        <template #default="{ row }">
          <el-button type="text" @click="handleDelete(row)">工单进度</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: '2022-10-01 12:00:00',
          shequ: '普通',
          mingcheng: '系统内部',
          guimo: '水环境监控',
          kaishi1: '站点名称',
          jieshu1: '问题描述',
          dangqian: '图片',
          kaishi2: '上报人员',
          jieshu2: '1555555555',
          jieshu3: '处理中',
        },
        {
          id: 2,
          jiedao: '2022-10-01 12:00:00',
          shequ: '普通',
          mingcheng: '系统内部',
          guimo: '水环境监控',
          kaishi1: '站点名称',
          jieshu1: '问题描述',
          dangqian: '图片',
          kaishi2: '上报人员',
          jieshu2: '1555555555',
          jieshu3: '处理中',
        },
        {
          id: 3,
          jiedao: '2022-10-01 12:00:00',
          shequ: '普通',
          mingcheng: '系统内部',
          guimo: '水环境监控',
          kaishi1: '站点名称',
          jieshu1: '问题描述',
          dangqian: '图片',
          kaishi2: '上报人员',
          jieshu2: '1555555555',
          jieshu3: '处理中',
        },
      ],
      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>
