<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
              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-input
              v-model="queryForm.name"
              placeholder="请输入关键字"
            ></el-input>
          </el-form-item>
          <el-button type="primary" @click="search">
            {{ $t('defalult.cx') }}
          </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="工单编号"
        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="$t('maintenance.zdlx')"
        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="$t('grouping.cjsj')"
        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: '123456',
          shequ: '工单类型',
          mingcheng: '站点类型',
          guimo: '业务类型',
          kaishi1: '站点',
          jieshu1: '街道类型',
          dangqian: '位置',
          kaishi2: '工单描述',
          jieshu2: '2022-10-1',
        },
        {
          id: 2,
          jiedao: '123456',
          shequ: '工单类型',
          mingcheng: '站点类型',
          guimo: '业务类型',
          kaishi1: '站点',
          jieshu1: '街道类型',
          dangqian: '位置',
          kaishi2: '工单描述',
          jieshu2: '2022-10-1',
        },
        {
          id: 3,
          jiedao: '123456',
          shequ: '工单类型',
          mingcheng: '站点类型',
          guimo: '业务类型',
          kaishi1: '站点',
          jieshu1: '街道类型',
          dangqian: '位置',
          kaishi2: '工单描述',
          jieshu2: '2022-10-1',
        },
      ],
      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>
