<template>
  <div class="full-container-p24">
    <div class="df jcsb">
      <div class="df aic">
        <el-input
          placeholder="请输入安检名称"
          prefix-icon="el-icon-search"
          v-model="term"
          clearable
          class="mr10"
          style="width: 200px"
        ></el-input>
        <el-button type="primary" @click="getSecurityCheckShipList(1)">
          查询
        </el-button>
      </div>
    </div>
    <div style="margin-top: 24px">
      <el-table border :data="tableData" stripe style="width: 100%">
        <el-table-column
          type="index"
          label="序号"
          width="80"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="shipname"
          label="船舶名称"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="securityCheckName"
          label="安检名称"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createTime"
          label="发起安检日期"
          min-width="120"
          align="center"
        >
          <template v-slot="scope">
            {{ subTimeStr(scope.row.createTime) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="shipOwnerName"
          label="船东名称"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="shipOwnerPhone"
          label="船东手机号"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="age"
          label="船龄"
          min-width="80"
          align="center"
          v-if="type == 2"
        ></el-table-column>
        <el-table-column label="操作" min-width="120" align="center">
          <template v-slot="scope">
            <el-button type="primary" link>详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="df aic jcfe mt40 mr20">
        <el-pagination
          background
          layout="prev, pager, next"
          :current-page="currentPage"
          :total="total"
          @current-change="pageChange"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, h, reactive, toRefs, onMounted } from "vue";
import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
import store from "../../store";
import router from "../../router";
import md5 from "md5";
import api from "../../apis/fetch";
import { subTimeStr } from "../../utils/utils";

function goToAdd() {
  router.push("/shipSecurityManage/checkShip");
}
let currentPage = ref(1);
let term = ref("");
let tableData = ref([]);
let total = ref(0);
let type = ref(3);
async function getSecurityCheckShipList(page) {
  currentPage.value = page || currentPage.value;
  let res = await api.getSecurityCheckShipList({
    currentPage: currentPage.value,
    size: 10,
    term: term.value,
    type: type.value,
  });
  if (res.data.status == 0) {
    tableData.value = res.data.result;
    total.value = res.data.total;
  } else {
    tableData.value = [];
    total.value = 0;
  }
}

async function getSecurityTemplateDetail(id) {
  router.push({
    path: "/shipSecurityManage/shipCheckTemplateDetail",
    query: {
      id,
    },
  });
}

function pageChange(e) {
  currentPage.value = e;
  getSecurityCheckShipList();
}
onMounted(() => {
  getSecurityCheckShipList();
});
</script>
<style scoped>
.seach-btn {
  display: inline-block;
  width: 60px;
  height: 38px;
  background: #0094fe;
  border-radius: 2px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  text-align: center;
  line-height: 38px;
  margin-left: 10px;
  cursor: pointer;
}

.cargo-owner-add {
  width: 80px;
  height: 32px;
  border-radius: 2px;
  border: 1px solid #0094fe;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #0094fe;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
}

:deep().el-dialog {
  width: 560px;
  padding: 20px 50px;
  border-radius: 6px;
}

:deep() .el-dialog__title {
  font-size: 18px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #0094fe;
}
</style>
