Commit 7bc8236ce3e56f61f832cbe04d2ab5aec3e41871

Authored by ww
1 parent 74c987bf

wip: data board

  1 +<script lang="ts" setup>
  2 + import { PageWrapper } from '/@/components/Page';
  3 + import { Button } from 'ant-design-vue';
  4 + const handleBack = () => {};
  5 +</script>
  6 +
  7 +<template>
  8 + <PageWrapper title="水电表看板" @back="handleBack" content="已创建组件: 3个">
  9 + <template #extra>
  10 + <Button type="primary">创建组件</Button>
  11 + </template>
  12 + <section class="bg-light-50 h-full w-full"> </section>
  13 + </PageWrapper>
  14 +</template>
  1 +<script lang="ts" setup>
  2 + import { List, Card, Statistic, Dropdown, Menu } from 'ant-design-vue';
  3 + import { ref, unref } from 'vue';
  4 + import { PageWrapper } from '/@/components/Page';
  5 + import {
  6 + MoreOutlined,
  7 + ShareAltOutlined,
  8 + EditOutlined,
  9 + DeleteOutlined,
  10 + } from '@ant-design/icons-vue';
  11 + import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
  12 + import { useMessage } from '/@/hooks/web/useMessage';
  13 + import { useRoute, useRouter } from 'vue-router';
  14 + const ListItem = List.Item;
  15 + const MenuItem = Menu.Item;
  16 +
  17 + const router = useRouter();
  18 + const { createMessage } = useMessage();
  19 +
  20 + const data = ref([{ title: 1 }, { title: 2 }, { title: 3 }]);
  21 + //分页相关
  22 + const page = ref(1);
  23 + const pageSize = ref(36);
  24 + const total = ref(0);
  25 + const paginationProp = ref({
  26 + showSizeChanger: false,
  27 + showQuickJumper: true,
  28 + pageSize,
  29 + current: page,
  30 + total,
  31 + showTotal: (total) => `总 ${total} 条`,
  32 + onChange: pageChange,
  33 + onShowSizeChange: pageSizeChange,
  34 + });
  35 +
  36 + function pageChange(p, pz) {
  37 + page.value = p;
  38 + pageSize.value = pz;
  39 + }
  40 + function pageSizeChange(_current, size) {
  41 + pageSize.value = size;
  42 + }
  43 +
  44 + const { clipboardRef } = useCopyToClipboard();
  45 + const handleCopyShareUrl = () => {
  46 + clipboardRef.value = '123';
  47 + unref(clipboardRef) && createMessage.success('复制成功');
  48 + };
  49 +
  50 + const handleEdit = () => {
  51 + router.push('/data/board/detail');
  52 + };
  53 +
  54 + const handleRemove = () => {};
  55 +</script>
  56 +
  57 +<template>
  58 + <PageWrapper>
  59 + <template #header> 自定义看板 </template>
  60 + <List
  61 + :pagination="paginationProp"
  62 + :data-source="data"
  63 + :grid="{ gutter: 5, column: 4, xs: 1, sm: 2, md: 2, lg: 3, xl: 3, xxl: 3 }"
  64 + >
  65 + <template #renderItem="{ item }">
  66 + <ListItem>
  67 + <Card class="data-card cursor-pointer">
  68 + <template #extra>
  69 + <Dropdown>
  70 + <template #overlay>
  71 + <Menu>
  72 + <MenuItem key="edit" @click="handleEdit">
  73 + <EditOutlined />
  74 + <span>编辑</span>
  75 + </MenuItem>
  76 + <MenuItem key="remove" @click="handleRemove">
  77 + <DeleteOutlined />
  78 + <span>删除</span>
  79 + </MenuItem>
  80 + </Menu>
  81 + </template>
  82 + <MoreOutlined class="rotate-90 transform cursor-pointer" />
  83 + </Dropdown>
  84 + </template>
  85 + <!-- <template #cover>title</template> -->
  86 + <section>
  87 + <div class="flex justify-between items-center">
  88 + <div>设备看板名</div>
  89 + <div class="flex content-center">
  90 + <Statistic value="12">
  91 + <template #suffix>
  92 + <span class="text-sm">个组件</span>
  93 + </template>
  94 + </Statistic>
  95 + </div>
  96 + </div>
  97 + <div class="flex justify-between mt-4">
  98 + <div>
  99 + <span>看板类型</span>
  100 + <span>
  101 + <ShareAltOutlined @click="handleCopyShareUrl" />
  102 + </span>
  103 + </div>
  104 + <div>2021-02-11 12:00:00</div>
  105 + </div>
  106 + </section>
  107 + </Card>
  108 + </ListItem>
  109 + </template>
  110 + </List>
  111 + </PageWrapper>
  112 +</template>
  113 +
  114 +<style scoped>
  115 + .data-card:deep(.ant-card-head) {
  116 + padding: 0;
  117 + height: 40px;
  118 + min-height: 40px;
  119 + }
  120 + .data-card:deep(.ant-card-extra) {
  121 + padding: 8px;
  122 + }
  123 +</style>