<template>
  <MOSTY.PageTree :pageTitle="'危险物品库存清单'" :searchType="'01'" @getDeptId="getdeptId">
    <template #serach>
      <el-divider />
      <MOSTY.Search :searchArr="searchArr" @submit="onSearch" />
    </template>
    <template #table>
      <section class="eltab7">
        <MOSTY.Table :table-columns="tableColumn" :tableData="tableData" :tableloading="tableloading" :isSelect="true"
          :isSort="true">
          <template #goodscompany="{ row }">
            <dict-tag v-if="row.goodscompany" :options="D_BZ_WPDW" :value="row.goodscompany" :tag="false" />
            <span v-else>无</span>
          </template>
        </MOSTY.Table>
      </section>
      <div class="fenye">
        <MOSTY.Pages :pageConfiger="listQuery" @changeNo="handleCurrentChange" @changeSize="handleSizeChange" />
      </div>
    </template>
  </MOSTY.PageTree>
  <!-- 新增 -->
  <div v-if="comprehensiveShow" class="dialog-box">
    <Wxzyxq @close="comprehensiveShow = false" />
  </div>
</template>

<script setup>
// 引入
import { reactive, onMounted, ref, getCurrentInstance } from "vue";
import Wxzyxq from "@/views/yxkzgl/wxzyxq.vue";
import { postApi } from "@/api/tobAcco_api.js";
import * as MOSTY from "@/components/MyComponents/index";
import { useRouter } from "vue-router";
const router = useRouter();
const { proxy } = getCurrentInstance();
const { D_BZ_WPDW } = proxy.$dict("D_BZ_WPDW");
const totalHeight = ref()
// 数据
const comprehensiveShow = ref(false);
const searchArr = reactive([
  {
    showType: "input",
    prop: "goodsname",
    width: '250px',
    placeholder: "请输入物品名称进行查询"
  }
])
const tableColumn = reactive([
  {
    title: "物品名称",
    prop: "goodsname",
  },
  {
    title: "物品规格",
    prop: "goodsspec",
  },
  {
    title: "物品型号",
    prop: "goodsmodel",
  },
  {
    title: "物品数量",
    prop: "goodsnumber",
  },
  {
    title: "物品单位",
    prop: "goodscompany",
    slot: true
  },
  {
    title: "备注",
    prop: "bz"
  }
])
const tableData = ref([]);
// 分页
const listQuery = reactive({
  pageCurrent: 1,
  pageSize: 20,
  total: 0,
  orgcode: ""
});
const total = ref(0);
//获取部门数据
const getdeptId = (val) => {
  listQuery.orgcode = val.id;
  listQuery.pageCurrent = 1;
  getListData();
};
function onSearch(obj) {
  listQuery.goodsname = obj.goodsname;
  listQuery.pageCurrent = 1;
  getListData()
}
// 获取表格数据
const tableloading = ref(false);
function getListData() {
  tableloading.value = true;
  postApi(listQuery, `/mosty-jcgl/dangergoodsPurchaseChild/queryDangergoodsList`).then((res) => {
    if (res.records) {
      tableloading.value = false;
      tableData.value = res.records;
      listQuery.total = res.total;
    } else {
      tableData.value = [];
      tableloading.value = false;
    }
  }).finally(() => {
    tableloading.value = false;
  });
}
//分页
const handleSizeChange = (currentSize) => {
  listQuery.pageSize = currentSize;
  getListData();
};
const handleCurrentChange = (currentPage) => {
  listQuery.pageCurrent = currentPage;
  getListData();
};

</script>

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