media.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <el-table :data="tableData" id="tableStyle" :height="tableHeight" border>
  3. <el-table-column prop="operationName" label="上传工序" />
  4. <el-table-column prop="creator" label="上传人员" />
  5. <el-table-column prop="created" label="上传时间" />
  6. <el-table-column label="操作" prop="operation">
  7. <template #default="{ row }">
  8. <span @click="handleLook(row.filePath)">查看</span>
  9. </template>
  10. </el-table-column>
  11. <template #empty>
  12. <div class="empty">
  13. <Empty />
  14. </div>
  15. </template>
  16. </el-table>
  17. <el-image id="showImg" style="width: 0; height: 0" :min-scale="0.2" :src="srcList[0]" :preview-src-list="srcList"
  18. fit="cover" />
  19. <Pagination position="right" :page="page" :limit="limit" :total="total" @pagination="getPagination" />
  20. </template>
  21. <script lang="ts" setup>
  22. import { useProcessStore } from "@/store";
  23. import { media } from "@/api/process/traceability";
  24. const store = useProcessStore();
  25. const page = ref(1);
  26. const limit = ref(10);
  27. const total = ref(10);
  28. const tableData = ref([]);
  29. const tableHeight = ref(null);
  30. const srcList = ref([]);
  31. const baseUrl = import.meta.env.VITE_APP_UPLOAD_URL;
  32. const handleLook = (path: string) => {
  33. srcList.value = [];
  34. srcList.value.push(baseUrl + path);
  35. setTimeout(() => {
  36. document.getElementById("showImg").click();
  37. }, 0);
  38. };
  39. //动态控制表格高度
  40. const setTableHeight = () => {
  41. tableHeight.value =
  42. Number(document.getElementById("tabBox").offsetHeight) - 60;
  43. };
  44. const getPagination = async () => {
  45. const { data } = await media({
  46. pageNo: page.value,
  47. pageSize: limit.value,
  48. seqNo: store.useSeqNo,
  49. });
  50. total.value = data.totalCount;
  51. tableData.value = data.records;
  52. };
  53. onMounted(() => {
  54. getPagination();
  55. setTableHeight();
  56. });
  57. </script>
  58. <style lang="scss" scoped></style>