<template>
  <div>
    <el-card>
      <el-form
        :model="searchForm"
        label-width="100px"
        @submit.prevent="fnResetPaginationTransfer"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="安全例会名称" prop="KEYWORDS">
              <el-input v-model="searchForm.KEYWORDS" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPaginationTransfer">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
        v-model:pagination="pagination"
        :data="list"
        @get-data="fnGetDataTransfer"
      >
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="SAFETY_MEETING_TITLE" label="安全例会标题" />
        <el-table-column prop="SAFETY_MEETING_CONTENT" label="安全例会内容" />
        <el-table-column label="安全例会附件">
          <template #default="{ row }">
            <layout-tooltip-img v-if="row.imgs" :imgs="row.imgs.split(',')" />
          </template>
        </el-table-column>
        <el-table-column prop="CREATTIME" label="添加时间" width="150" />
        <el-table-column label="签字人数/涉及人数">
          <template #default="{ row }">
            <el-link type="primary">
              {{ row.SIGNATURES }}/{{ row.ALL_SIGNATURES }}
            </el-link>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template #default="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/safety_meeting/meeting/view',
                  query: { SAFETY_MEETING_ID: row.SAFETY_MEETING_ID },
                })
              "
            >
              详情
            </el-button>
            <el-button
              v-if="row.SIGNATURES === 0"
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/safety_meeting/meeting/add',
                  query: { SAFETY_MEETING_ID: row.SAFETY_MEETING_ID },
                })
              "
            >
              编辑
            </el-button>
          </template>
        </el-table-column>
        <template #button>
          <el-button
            type="primary"
            @click="
              router.push({
                path: '/safety_meeting/meeting/add',
              })
            "
          >
            新增
          </el-button>
        </template>
      </layout-table>
    </layout-card>
  </div>
</template>

<script setup>
import { serialNumber } from "@/assets/js/utils";
import useListData from "@/assets/js/useListData.js";
import { getSafetyMeetingList } from "@/request/safety_meeting.js";
import { useRouter } from "vue-router";
import LayoutTooltipImg from "@/components/tooltip_img/index.vue";

const router = useRouter();
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
  useListData(getSafetyMeetingList);
const fnGetDataTransfer = () => {
  fnGetData({
    DEPTIDS: searchForm.value.DEPTIDS?.join(","),
  });
};
const fnResetPaginationTransfer = () => {
  fnResetPagination({
    DEPTIDS: searchForm.value.DEPTIDS?.join(","),
  });
};
</script>

<style scoped></style>
