<template>
  <div>
    <el-card class="!border-none" v-loading="pager.loading" shadow="never">
      <el-form class="mb-[-16px]" inline>
        <el-form-item label="公司名称" prop="company_id">
          <el-input
            class="w-[280px]"
            v-model="queryParams.name"
            clearable
            placeholder="请输入公司"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="resetPage">查询</el-button>
          <el-button @click="resetParams">重置</el-button>
        </el-form-item>
      </el-form>
      <div class="mt-4">
        <el-table :data="pager.lists" @selection-change="handleSelectionChange">
          <el-table-column label="编号" prop="id" show-overflow-tooltip />
          <el-table-column label="镇公司" show-overflow-tooltip >
            <template #default="{ row }">
              {{row.extend?.company_name}}
            </template>
          </el-table-column>
          <el-table-column label="所属地区" show-overflow-tooltip>
            <template #default="{ row }">
              <!-- <dict-value :options="dictData.show_status" :value="row.status" /> -->

              {{
                row.area_name +
                row.street_name +
                row.village_name +
                row.brigade_name
              }}
            </template>
          </el-table-column>
          <el-table-column label="队长姓名" prop="phone" show-overflow-tooltip>
            <template #default="{ row }">
              {{row.extend?.nickname}}
            </template>
          </el-table-column>
          <el-table-column label="档案名称" prop="name" show-overflow-tooltip />
          <el-table-column label="联系电话" prop="phone" show-overflow-tooltip />
          <el-table-column label="更新时间" prop="update_time" show-overflow-tooltip />
          <el-table-column label="建档时间" prop="create_time" show-overflow-tooltip />
          
          <!-- <el-table-column label="所属生产队队长" prop="type_name" show-overflow-tooltip />
          <el-table-column label="所属镇管理" prop="type_name" show-overflow-tooltip />
          <el-table-column label="所属区域经理" prop="type_name" show-overflow-tooltip />
          <el-table-column label="最近更新时间" prop="type_name" show-overflow-tooltip /> -->
          <el-table-column label="操作" align="center" width="auto" fixed="right">
            <template #default="{ row }">
              <el-button v-perms="['flow/edit']" type="primary" link>
                <router-link
                  :to="{
                    path: 'user_informationg/details',
                    query: {
                      id: row.id,
                    },
                  }"
                >
                  详情
                </router-link>
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="flex mt-4 justify-end">
        <pagination v-model="pager" @change="getLists" />
      </div>
    </el-card>
    <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
  </div>
</template>

<script lang="ts" setup name="flowTypeLists">
import { usePaging } from "@/hooks/usePaging";
import { useDictData } from "@/hooks/useDictOptions";
// import { apiCateLists, apiCateStatus } from "@/api/examined";
import { fileManagelist, fileManageDetil } from "@/api/informationg";
import { getRoutePath } from "@/router";

// import { timeFormat } from "@/utils/util";
// import feedback from "@/utils/feedback";
// import { getRoutePath } from "router";
import EditPopup from "./editCate.vue";
console.log(getRoutePath);
const editRef = shallowRef<InstanceType<typeof EditPopup>>();
// 是否显示编辑框
const showEdit = ref(false);

// 查询条件
const queryParams = reactive({
  name: "",
});

// 选中数据
const selectData = ref<any[]>([]);

// 表格选择后回调事件
const handleSelectionChange = (val: any[]) => {
  selectData.value = val.map(({ id }) => id);
};

// 获取字典数据
const { dictData } = useDictData("");

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
  fetchFun: fileManagelist,
  params: queryParams,
});


// 添加
// const handleAdd = async () => {
//   showEdit.value = true;
//   await nextTick();
//   editRef.value?.open("add");
// };

// // 编辑
// const handleEdit = async (data: any) => {
//   showEdit.value = true;
//   await nextTick();
//   editRef.value?.open("edit");
//   editRef.value?.setFormData(data);
// };

// 删除
// const handleDelete = async (id: number | any[]) => {
//   await feedback.confirm("确定要删除？");
//   await apiFlowTypeDelete({ id });
//   getLists();
// };
// 状态
// const changeStatus = (row: any) => {
//   apiCateStatus({ id: row.id, status: row.status });
// };
getLists();
</script>
