mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	feat: 新增 @pureadmin/table 图像预览示例
				
					
				
			This commit is contained in:
		
							parent
							
								
									46567cb15c
								
							
						
					
					
						commit
						4ed2bb9e57
					
				@ -56,6 +56,14 @@ const tableDataMore = cloneData.map(item =>
 | 
				
			|||||||
  })
 | 
					  })
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const tableDataImage = cloneData.map((item, index) =>
 | 
				
			||||||
 | 
					  Object.assign(item, {
 | 
				
			||||||
 | 
					    image: `https://xiaoxian521.github.io/pure-admin-table/imgs/${
 | 
				
			||||||
 | 
					      index + 1
 | 
				
			||||||
 | 
					    }.jpg`
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const tableDataSortable = cloneData.map((item, index) =>
 | 
					const tableDataSortable = cloneData.map((item, index) =>
 | 
				
			||||||
  Object.assign(item, {
 | 
					  Object.assign(item, {
 | 
				
			||||||
    date: `${dayjs(new Date()).format("YYYY-MM")}-${index + 1}`
 | 
					    date: `${dayjs(new Date()).format("YYYY-MM")}-${index + 1}`
 | 
				
			||||||
@ -282,4 +290,10 @@ const tableDataExpand = [
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { tableData, tableDataMore, tableDataSortable, tableDataExpand };
 | 
					export {
 | 
				
			||||||
 | 
					  tableData,
 | 
				
			||||||
 | 
					  tableDataMore,
 | 
				
			||||||
 | 
					  tableDataImage,
 | 
				
			||||||
 | 
					  tableDataExpand,
 | 
				
			||||||
 | 
					  tableDataSortable
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										50
									
								
								src/views/pure-table/components/imgPreview.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/views/pure-table/components/imgPreview.vue
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					<script setup lang="ts">
 | 
				
			||||||
 | 
					import { tableDataImage } from "./data";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const columns: TableColumnList = [
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    label: "日期",
 | 
				
			||||||
 | 
					    prop: "date"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    label: "姓名",
 | 
				
			||||||
 | 
					    prop: "name"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    label: "地址",
 | 
				
			||||||
 | 
					    prop: "address"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    label: "视频",
 | 
				
			||||||
 | 
					    slot: "video"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    label: "图像",
 | 
				
			||||||
 | 
					    slot: "image"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					];
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <pure-table :data="tableDataImage" :columns="columns">
 | 
				
			||||||
 | 
					    <template #video>
 | 
				
			||||||
 | 
					      <video width="180" height="180" controls>
 | 
				
			||||||
 | 
					        <source
 | 
				
			||||||
 | 
					          src="https://yiming_chang.gitee.io/pure-admin-doc/video/url.mov"
 | 
				
			||||||
 | 
					          type="video/mp4"
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
 | 
					      </video>
 | 
				
			||||||
 | 
					    </template>
 | 
				
			||||||
 | 
					    <template #image="{ row, index }">
 | 
				
			||||||
 | 
					      <el-image
 | 
				
			||||||
 | 
					        preview-teleported
 | 
				
			||||||
 | 
					        loading="lazy"
 | 
				
			||||||
 | 
					        :src="row.image"
 | 
				
			||||||
 | 
					        :preview-src-list="tableDataImage.map(v => v.image)"
 | 
				
			||||||
 | 
					        :initial-index="index"
 | 
				
			||||||
 | 
					        fit="cover"
 | 
				
			||||||
 | 
					        class="w-[100px] h-[100px]"
 | 
				
			||||||
 | 
					      />
 | 
				
			||||||
 | 
					    </template>
 | 
				
			||||||
 | 
					  </pure-table>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
@ -19,6 +19,7 @@ import Merge from "./merge.vue";
 | 
				
			|||||||
import CustomIndex from "./customIndex.vue";
 | 
					import CustomIndex from "./customIndex.vue";
 | 
				
			||||||
import Layout from "./layout.vue";
 | 
					import Layout from "./layout.vue";
 | 
				
			||||||
import NestProp from "./nestProp.vue";
 | 
					import NestProp from "./nestProp.vue";
 | 
				
			||||||
 | 
					import ImgPreview from "./imgPreview.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export {
 | 
					export {
 | 
				
			||||||
  Base,
 | 
					  Base,
 | 
				
			||||||
@ -41,5 +42,6 @@ export {
 | 
				
			|||||||
  Merge,
 | 
					  Merge,
 | 
				
			||||||
  CustomIndex,
 | 
					  CustomIndex,
 | 
				
			||||||
  Layout,
 | 
					  Layout,
 | 
				
			||||||
  NestProp
 | 
					  NestProp,
 | 
				
			||||||
 | 
					  ImgPreview
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,8 @@ import {
 | 
				
			|||||||
  Merge,
 | 
					  Merge,
 | 
				
			||||||
  CustomIndex,
 | 
					  CustomIndex,
 | 
				
			||||||
  Layout,
 | 
					  Layout,
 | 
				
			||||||
  NestProp
 | 
					  NestProp,
 | 
				
			||||||
 | 
					  ImgPreview
 | 
				
			||||||
} from "./components";
 | 
					} from "./components";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const rendContent = (val: string) =>
 | 
					const rendContent = (val: string) =>
 | 
				
			||||||
@ -157,5 +158,11 @@ export const list = [
 | 
				
			|||||||
    content: rendContent("nestProp"),
 | 
					    content: rendContent("nestProp"),
 | 
				
			||||||
    title: "多种数据格式(深层结构)",
 | 
					    title: "多种数据格式(深层结构)",
 | 
				
			||||||
    component: NestProp
 | 
					    component: NestProp
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    key: "imgPreview",
 | 
				
			||||||
 | 
					    content: rendContent("imgPreview"),
 | 
				
			||||||
 | 
					    title: "图像预览",
 | 
				
			||||||
 | 
					    component: ImgPreview
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user