From e9a7b476aae1266875f70f3507b23b8fa126b993 Mon Sep 17 00:00:00 2001 From: xingyu Date: Fri, 12 May 2023 18:38:19 +0800 Subject: [PATCH] feat: wx news init --- src/components/CardList/src/CardList.vue | 12 +- src/views/mp/freePublish/NewsList.vue | 150 ++++++++++++++++++++++ src/views/mp/freePublish/data.ts | 25 ++++ src/views/mp/freePublish/index.vue | 151 ++++------------------- 4 files changed, 209 insertions(+), 129 deletions(-) create mode 100644 src/views/mp/freePublish/NewsList.vue create mode 100644 src/views/mp/freePublish/data.ts diff --git a/src/components/CardList/src/CardList.vue b/src/components/CardList/src/CardList.vue index ffc2ab09..893daf4e 100644 --- a/src/components/CardList/src/CardList.vue +++ b/src/components/CardList/src/CardList.vue @@ -72,11 +72,12 @@ import { computed, onMounted, ref } from 'vue' import { EditOutlined, EllipsisOutlined, RedoOutlined, TableOutlined } from '@ant-design/icons-vue' import { List, Card, Image, Typography, Tooltip, Slider, Avatar } from 'ant-design-vue' import { Dropdown } from '@/components/Dropdown' -import { BasicForm, useForm } from '@/components/Form' +import { BasicForm, useForm, FormSchema } from '@/components/Form' import { propTypes } from '@/utils/propTypes' import { Button } from '@/components/Button' import { isFunction } from '@/utils/is' import { useSlider, grid } from './data' + const ListItem = List.Item const CardMeta = Card.Meta const TypographyText = Typography.Text @@ -87,7 +88,10 @@ const props = defineProps({ // 请求API的参数 params: propTypes.object.def({}), //api - api: propTypes.func + api: propTypes.func, + searchSchema: { + type: Array + } }) //暴露内部方法 const emit = defineEmits(['getMethod', 'delete']) @@ -102,7 +106,7 @@ const height = computed(() => { }) //表单 const [registerForm, { validate }] = useForm({ - schemas: [{ field: 'type', component: 'Input', label: '类型' }], + schemas: props.searchSchema as FormSchema[], labelWidth: 80, baseColProps: { span: 6 }, actionColOptions: { span: 24 }, @@ -129,7 +133,7 @@ async function fetch(p = {}) { const { api, params } = props if (api && isFunction(api)) { const res = await api({ ...params, page: page.value, pageSize: pageSize.value, ...p }) - data.value = res.items + data.value = res.list total.value = res.total } } diff --git a/src/views/mp/freePublish/NewsList.vue b/src/views/mp/freePublish/NewsList.vue new file mode 100644 index 00000000..91828aaa --- /dev/null +++ b/src/views/mp/freePublish/NewsList.vue @@ -0,0 +1,150 @@ + + diff --git a/src/views/mp/freePublish/data.ts b/src/views/mp/freePublish/data.ts new file mode 100644 index 00000000..32718ea7 --- /dev/null +++ b/src/views/mp/freePublish/data.ts @@ -0,0 +1,25 @@ +import { ref } from 'vue' +// 每行个数 +export const grid = ref(12) +// slider属性 +export const useSlider = (min = 6, max = 12) => { + // 每行显示个数滑动条 + const getMarks = () => { + const l = {} + for (let i = min; i < max + 1; i++) { + l[i] = { + style: { + color: '#fff' + }, + label: i + } + } + return l + } + return { + min, + max, + marks: getMarks(), + step: 1 + } +} diff --git a/src/views/mp/freePublish/index.vue b/src/views/mp/freePublish/index.vue index f0c4007c..969c245d 100644 --- a/src/views/mp/freePublish/index.vue +++ b/src/views/mp/freePublish/index.vue @@ -1,138 +1,39 @@ -