forked from mengyxu/noob-components
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.2 KiB
104 lines
2.2 KiB
<template> |
|
<SearchRow :title="t('table.title') + ' (V2)'"> |
|
<template #default> |
|
<NoobInput v-model="example.aaa" :width="180"></NoobInput> |
|
<NoobSelect v-model="example.bbb" dict="test"></NoobSelect> |
|
<NoobSelect v-model="example.ccc" stateProp="test" :width="120"></NoobSelect> |
|
</template> |
|
</SearchRow> |
|
<ListTableV2 |
|
:data="data" |
|
:columns="columns" |
|
:page="true" |
|
:border="true" |
|
:example="example" |
|
:row-key="'id'" |
|
@query="handleQuery" |
|
></ListTableV2> |
|
</template> |
|
|
|
<script lang="ts" setup> |
|
import { useStore } from "vuex"; |
|
import { reactive, onMounted, ref } from "vue"; |
|
import { ListTableV2, SearchRow, NoobInput, NoobSelect, Infomation } from "noob-mengyxu"; |
|
import { useI18n } from "vue3-i18n"; |
|
|
|
const { state } = useStore(); |
|
const { t } = useI18n(); |
|
|
|
const example = reactive({ |
|
page: 1, |
|
size: 10, |
|
aaa: "", |
|
bbb: "b", |
|
ccc: "c", |
|
}); |
|
|
|
// Generate 100 rows of data across multiple pages |
|
const generateData = () => { |
|
const rows = []; |
|
const now = Math.floor(Date.now() / 1000); // Unix timestamp in seconds |
|
for (let i = 1; i <= 100; i++) { |
|
rows.push({ |
|
id: i, |
|
caseName: `案件${i}`, |
|
taskName: `任务${i}`, |
|
userId: `user${i}`, |
|
content: `内容${i}`, |
|
createTime: now - i * 60, // timestamps in seconds |
|
}); |
|
} |
|
return rows; |
|
}; |
|
|
|
const allData = generateData(); |
|
|
|
const data = reactive({ |
|
data: allData.slice(0, 10), |
|
total: allData.length, |
|
}); |
|
|
|
const columns = [ |
|
{ |
|
key: "id", |
|
name: "ID", |
|
}, |
|
{ |
|
key: "caseName", |
|
i18n: "table.props.0", |
|
}, |
|
{ |
|
key: "taskName", |
|
i18n: "table.props.1", |
|
}, |
|
{ |
|
key: "userId", |
|
i18n: "table.props.2", |
|
}, |
|
{ |
|
key: "content", |
|
i18n: "table.props.3", |
|
}, |
|
{ |
|
key: "createTime", |
|
i18n: "table.props.4", |
|
timestamp: 'unix', |
|
}, |
|
]; |
|
|
|
const handleQuery = () => { |
|
// Simulate pagination - slice data based on page and size |
|
const start = (example.page - 1) * example.size; |
|
const end = start + example.size; |
|
data.data = allData.slice(start, end); |
|
console.log("Query:", example.page, example.size, "showing", start, "-", end); |
|
}; |
|
|
|
onMounted(() => { |
|
console.log("Table V2 mounted"); |
|
}); |
|
</script> |
|
|
|
<style lang="scss" scoped> |
|
//@import url(); 引入公共css类 |
|
</style>
|
|
|