<template>
  <layout-card>
    <div id="printContent">
      <el-divider content-position="left">安全例会</el-divider>
      <el-descriptions border :column="2">
        <el-descriptions-item class="my-content" label="安全例会标题"
          >{{ data.form.SAFETY_MEETING_TITLE }}
        </el-descriptions-item>
        <el-descriptions-item label="安全例会内容"
          >{{ data.form.SAFETY_MEETING_CONTENT }}
        </el-descriptions-item>
      </el-descriptions>
      <el-divider content-position="left">涉及人</el-divider>
      <div class="print_no_use">
        <layout-table :data="data.form.people" :show-pagination="false">
          <el-table-column label="序号" type="index" />
          <el-table-column prop="DEPARTMENT_NAME" label="部门" />
          <el-table-column prop="POST_NAME" label="岗位" />
          <el-table-column prop="NAME" label="姓名" />
        </layout-table>
      </div>
      <table class="print_use">
        <thead>
          <tr>
            <th width="55">序号</th>
            <th>部门</th>
            <th>岗位</th>
            <th>姓名</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in data.form.people" :key="index">
            <td>{{ index + 1 }}</td>
            <td>{{ item.DEPARTMENT_NAME }}</td>
            <td>{{ item.POST_NAME }}</td>
            <td>{{ item.NAME }}</td>
          </tr>
        </tbody>
      </table>
      <el-divider content-position="left">附件</el-divider>
      <el-descriptions>
        <el-descriptions-item>
          <img
            v-for="(item, index) in data.form.file"
            :key="index"
            v-viewer
            :src="item.url"
            style="width: 200px; height: 200px"
          />
        </el-descriptions-item>
      </el-descriptions>
      <el-divider content-position="left">反馈情况</el-divider>
      <div class="print_no_use">
        <layout-table :data="data.feedbackList" :show-pagination="false" border>
          <el-table-column label="序号" type="index" />
          <el-table-column prop="NAME" label="反馈人" />
          <el-table-column label="是否反馈">
            <template #default="{ row }">
              <span>{{ row.FEED_BACK ? "是" : "否" }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="FEED_BACK" label="意见" />
          <el-table-column prop="CHECK_STANDARD" label="签字">
            <template #default="{ row }">
              <img
                v-if="row.FILEPATH"
                v-viewer
                :src="FILE_URL + row.FILEPATH"
                style="width: 100px; height: 100px"
              />
            </template>
          </el-table-column>
        </layout-table>
      </div>
      <table class="print_use">
        <thead>
          <tr>
            <th width="55">序号</th>
            <th>反馈人</th>
            <th>是否反馈</th>
            <th>意见</th>
            <th>签字</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in data.feedbackList" :key="index">
            <td>{{ index + 1 }}</td>
            <td>{{ item.NAME }}</td>
            <td>{{ item.FEED_BACK ? "是" : "否" }}</td>
            <td>{{ item.FEED_BACK }}</td>
            <td>
              <img
                v-if="item.FILEPATH"
                :src="FILE_URL + item.FILEPATH"
                style="width: 100px; height: 100px"
              />
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="tc mt-10">
      <el-button v-print="'#printContent'" type="primary">打印</el-button>
    </div>
  </layout-card>
</template>

<script setup>
import { useRoute } from "vue-router";
import { getSafetyMeetingView } from "@/request/safety_meeting.js";
import { addingPrefixToFile } from "@/assets/js/utils.js";
import { reactive } from "vue";
const route = useRoute();
const FILE_URL = import.meta.env.VITE_FILE_URL;
const { SAFETY_MEETING_ID } = route.query;

const data = reactive({
  form: {
    people: [],
    file: [],
  },
  feedbackList: [],
});
const fnGetData = async () => {
  const resData = await getSafetyMeetingView({ SAFETY_MEETING_ID });
  data.form = {
    ...resData.pd,
    people: resData.people,
  };
  if (resData.imgs) {
    data.form.file = addingPrefixToFile(resData.imgs);
  }
  if (resData.feedbackList) {
    data.feedbackList = resData.feedbackList;
  }
};
fnGetData();
</script>

<style scoped lang="scss"></style>
