From 8daf487cac9d49bbfa0376f3558a542eefc7fa74 Mon Sep 17 00:00:00 2001 From: zhaojinfeng <121016171@qq.com> Date: Mon, 14 Aug 2023 16:46:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A9=BF=E6=A2=AD=E6=A1=86=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/select-transfer-modal/index.vue | 217 +++++++++++++++++++++++ stories/SelectTransferModal.stories.ts | 84 +++++++++ types/auto-imports.d.ts | 4 +- types/components.d.ts | 2 + 4 files changed, 304 insertions(+), 3 deletions(-) create mode 100644 packages/select-transfer-modal/index.vue create mode 100644 stories/SelectTransferModal.stories.ts diff --git a/packages/select-transfer-modal/index.vue b/packages/select-transfer-modal/index.vue new file mode 100644 index 0000000..f3d0e72 --- /dev/null +++ b/packages/select-transfer-modal/index.vue @@ -0,0 +1,217 @@ + + + + + + diff --git a/stories/SelectTransferModal.stories.ts b/stories/SelectTransferModal.stories.ts new file mode 100644 index 0000000..4173292 --- /dev/null +++ b/stories/SelectTransferModal.stories.ts @@ -0,0 +1,84 @@ +/* + * @Author: zhaojinfeng 121016171@qq.com + * @Date: 2023-08-14 11:07:15 + * @LastEditors: zhaojinfeng 121016171@qq.com + * @LastEditTime: 2023-08-14 16:45:09 + * @FilePath: \vue3\stories\SelectTransferModal.stories.ts + * @Description: + * + */ +import type { Meta, StoryObj } from '@storybook/vue3' +import ThSelectTransferModal from '../packages/select-transfer-modal/index.vue' + +// 模拟800毫秒钟的接口请求 +function request(e: Record<'pageNum' | 'pageSize', number>) { + return new Promise((resolve) => { + setTimeout(() => { + const rows: any[] = [] + for (let index = 0; index < e.pageSize; index++) { + const id = (e.pageNum - 1) * e.pageSize + index + rows.push({ + id, + name: `name${id}`, + value: `value${id}`, + }) + } + resolve({ + code: 200, + rows, + total: 9999, + message: 'ok', + }) + }, 800) + }) +} + +const meta = { + title: '表单组件/SelectTransferModal', + tags: ['表单组件', 'autodocs'], + args: { + value: [2], + show: false, + defaultParams: {}, + formItems: [{ label: 'label1', prop: 'prop1' }, { label: 'label2', prop: 'prop2', selectOptions: [{ label: '1', value: '1' }, { label: '2', value: '2' }] }], + request, + optionRight: 'value', + layout: 'total, sizes, prev, pager, next, jumper', + pageSizes: [10, 20, 30, 50], + pagerCount: document.body.clientWidth < 992 ? 5 : 7, + props: { key: 'id', label: 'name', disabled: 'disabled' }, + hidePagination: false, + title: '选择', + width: '70%', + zIndex: 2023, + }, + render: args => ({ + components: { ThSelectTransferModal }, + setup() { + return { args } + }, + template: ``, + }), +} satisfies Meta +export default meta + +type Story = StoryObj + +export const Base: Story = { + name: '基本使用', +} diff --git a/types/auto-imports.d.ts b/types/auto-imports.d.ts index 459da67..102591a 100644 --- a/types/auto-imports.d.ts +++ b/types/auto-imports.d.ts @@ -4,8 +4,8 @@ // Generated by unplugin-auto-import export {} declare global { - const $$: typeof import('vue/macros')['$$'] const $: typeof import('vue/macros')['$'] + const $$: typeof import('vue/macros')['$$'] const $computed: typeof import('vue/macros')['$computed'] const $customRef: typeof import('vue/macros')['$customRef'] const $ref: typeof import('vue/macros')['$ref'] @@ -307,7 +307,6 @@ declare module 'vue' { readonly $shallowRef: UnwrapRef readonly $toRef: UnwrapRef readonly EffectScope: UnwrapRef - readonly ElMessage: UnwrapRef readonly asyncComputed: UnwrapRef readonly autoResetRef: UnwrapRef readonly computed: UnwrapRef @@ -596,7 +595,6 @@ declare module '@vue/runtime-core' { readonly $shallowRef: UnwrapRef readonly $toRef: UnwrapRef readonly EffectScope: UnwrapRef - readonly ElMessage: UnwrapRef readonly asyncComputed: UnwrapRef readonly autoResetRef: UnwrapRef readonly computed: UnwrapRef diff --git a/types/components.d.ts b/types/components.d.ts index d89108a..eeaf760 100644 --- a/types/components.d.ts +++ b/types/components.d.ts @@ -27,6 +27,7 @@ declare module 'vue' { ElSpace: typeof import('element-plus/es')['ElSpace'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] + ElTransfer: typeof import('element-plus/es')['ElTransfer'] Header: typeof import('./../packages/header/index.vue')['default'] MaskText: typeof import('./../packages/mask-text/index.vue')['default'] PreviewOffice: typeof import('./../packages/preview-office/index.vue')['default'] @@ -34,6 +35,7 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] SelectTableModal: typeof import('./../packages/select-table-modal/index.vue')['default'] + SelectTransferModal: typeof import('./../packages/select-transfer-modal/index.vue')['default'] UploadAvatar: typeof import('./../packages/upload-avatar/index.vue')['default'] UploadSingleFile: typeof import('./../packages/upload-single-file/index.vue')['default'] UploadTable: typeof import('./../packages/upload-table/index.vue')['default']