CzRger před 2 měsíci
rodič
revize
15c1a2745c
1 změnil soubory, kde provedl 12 přidání a 3 odebrání
  1. 12 3
      snowy-admin-web/src/components/Table/index.vue

+ 12 - 3
snowy-admin-web/src/components/Table/index.vue

@@ -106,6 +106,9 @@
 			"
 		>
 			<template #[item]="scope" v-for="item in renderSlots">
+				<template v-if="scope.column.dataIndex === 'INDEX'">
+					{{scope.index + 1}}
+				</template>
 				<slot
 					v-if="item && renderTableProps.columns && renderTableProps.columns.length > 0"
 					:name="item"
@@ -126,6 +129,12 @@
 	const route = useRoute()
 	const emit = defineEmits(['expand', 'update:filterParam'])
 	const renderSlots = Object.keys(slots)
+	const tableIndexColumn = {
+		title: '序号',
+		dataIndex: 'INDEX',
+		width: 50,
+		align: 'center'
+	}
 
 	const props = defineProps(
 		Object.assign({}, tableProps(), {
@@ -241,7 +250,7 @@
 	watch(
 		() => props.columns,
 		(newVal) => {
-			data.columnsSetting = newVal
+			data.columnsSetting = [tableIndexColumn, ...newVal]
 		}
 	)
 
@@ -294,7 +303,7 @@
 	}
 	// 列设置
 	const columnChange = (v) => {
-		data.columnsSetting = v
+		data.columnsSetting = [tableIndexColumn, ...v]
 		getTableProps()
 	}
 	// 列清空
@@ -319,7 +328,7 @@
 				})) ||
 			false
 		data.needTotalList = initTotalList(props.columns)
-		data.columnsSetting = props.columns
+		data.columnsSetting = [tableIndexColumn, ...props.columns]
 		loadData()
 	}