<template>
  <MOSTY.PageTree :pageTitle="'车辆双检历史列表'" :searchType="'03'" @getDeptId="getdeptId">
    <template #serach>
      <el-divider />
      <MOSTY.Search :searchArr="searchArr" @submit="onSearch" />
    </template>
    <template #table>
      <el-divider />
      <section class="eltab3">
        <MOSTY.Table :table-columns="data.tableColumn" :tableData="data.tableData" :tableloading="tableloading"
          :tableHeight="'100%'" :isSelect="false" style="width: 100%;" :isSort="false">
          <template #actions="{ row }">
            <span class="operesee" @click="seeInfo(row)">
              <el-icon>
                <View />
              </el-icon>查看</span>
          </template>
        </MOSTY.Table>
        <div class="fenye">
          <Pages :pageConfiger="data.pageConfiger" @changeNo="changeNo" @changeSize="changeSize"></Pages>
        </div>
      </section>

    </template>
  </MOSTY.PageTree>
</template>

<script setup>
import * as MOSTY from "@/components/MyComponents/index";
import { getApi } from "@/api/tobAcco_api.js";
import Pages from "@/components/aboutTable/Pages/index.vue";
import { reactive, onMounted, ref } from "vue";
const emit = defineEmits("changePage");
const searchArr = reactive([
  {
    showType: "input",
    prop: "checktitle",
    width: '250px',
    placeholder: "请输入检查标题"
  }, {
    showType: "daterange",
    prop: "timeValue",
    width: '250px',
  }
])
const data = reactive({
  searchObj: {},
  tableData: [],
  tableColumn: [
    {
      title: "检查标题",
      prop: "checktitle"
    },
    {
      title: "车牌号",
      prop: "carnumber"
    },
    {
      title: "检查人",
      prop: "username"
    },
    {
      title: "检查时间",
      prop: "checktime"
    },
    {
      title: "所属单位",
      prop: "orgname"
    },
    {
      title: "操作",
      prop: "actions",
      slot: true
    }
  ],

  pageConfiger: {
    pageSize: 20,
    pageCurrent: 1,
    total: 0
  },
});
const listQuery = reactive({
  pageCurrent: 1,
  pageSize: 20
});
//获取部门数据
const getdeptId = (val) => {
  listQuery.orgcode = val.id;
  listQuery.pageCurrent = 1;
  getTableData();
};

onMounted(() => {
});
//分页
const changeNo = (val) => {
  listQuery.pageCurrent = val;
  data.pageConfiger.pageCurrent = val;
  getTableData();
};
const changeSize = (val) => {
  listQuery.pageSize = val;
  data.pageConfiger.pageSize = val;
  getTableData();
};
// 查询数据
const onSearch = (obj) => {
  listQuery.checktitle = obj.checktitle;
  listQuery.startTime = obj.timeValue ? obj.timeValue[0] : '';
  listQuery.endTime = obj.timeValue ? obj.timeValue[1] : '';
  getTableData();
};

//选中的数据
const tableloading = ref(false);
function getTableData() {
  tableloading.value = true;
  getApi(listQuery, `/mosty-jcgl/car3inspectionInfo/getPageList`).then((res) => {
    if (res.records) {
      data.tableData = res.records;
      tableloading.value = false;
      data.pageConfiger.total = res.total;
    } else {
      data.tableData = [];
      tableloading.value = false;
    }
  }).finally(() => {
    tableloading.value = false;
  });
}

//查看
const seeInfo = (row) => {
  let arr = {
    title: "车辆双检日志详情",
    saveBtnShow: false,
    wbjlShow: true,
    jcrzShow: true,
    id: row.id ? row.id : null
  };
  emit("changePage", "Details", arr);
};



</script>

<style lang="scss" scoped>
::v-deep .el-date-editor .el-range-input {
  color: black;
}

::v-deep .el-date-editor .el-range-separator {
  color: black;
}


.eltab3 {
  height: calc(100vh - 338px);
}
</style>