chore: mitt demo
This commit is contained in:
parent
7c4e03f751
commit
d01b74a5b8
@ -1,4 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenDrawer } from '@vben/common-ui';
|
import { useVbenDrawer } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
@ -6,6 +8,7 @@ import { Card } from 'ant-design-vue';
|
|||||||
|
|
||||||
import { useVbenForm } from '#/adapter';
|
import { useVbenForm } from '#/adapter';
|
||||||
|
|
||||||
|
import { emitter } from '../mitt';
|
||||||
import { querySchema } from './data';
|
import { querySchema } from './data';
|
||||||
import dictDataDrawer from './dict-data-drawer.vue';
|
import dictDataDrawer from './dict-data-drawer.vue';
|
||||||
|
|
||||||
@ -36,6 +39,12 @@ const [QueryForm] = useVbenForm({
|
|||||||
},
|
},
|
||||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const testValue = ref('');
|
||||||
|
|
||||||
|
emitter.on('rowClick', (dictType) => {
|
||||||
|
testValue.value = dictType;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -48,6 +57,7 @@ const [QueryForm] = useVbenForm({
|
|||||||
{{ $t('pages.common.add') }}
|
{{ $t('pages.common.add') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</Card>
|
</Card>
|
||||||
|
{{ testValue }}
|
||||||
<DictDataDrawer />
|
<DictDataDrawer />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
10
apps/web-antd/src/views/system/dict/mitt.ts
Normal file
10
apps/web-antd/src/views/system/dict/mitt.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { mitt } from '@vben/utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dictType: string
|
||||||
|
*/
|
||||||
|
type Events = {
|
||||||
|
rowClick: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const emitter = mitt<Events>();
|
@ -3,9 +3,11 @@ import { useVbenModal } from '@vben/common-ui';
|
|||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import { Card } from 'ant-design-vue';
|
import { Card } from 'ant-design-vue';
|
||||||
|
import { uniqueId } from 'lodash-es';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter';
|
import { useVbenForm } from '#/adapter';
|
||||||
|
|
||||||
|
import { emitter } from '../mitt';
|
||||||
import { querySchema } from './data';
|
import { querySchema } from './data';
|
||||||
import dictTypeModel from './dict-type-model.vue';
|
import dictTypeModel from './dict-type-model.vue';
|
||||||
|
|
||||||
@ -38,6 +40,10 @@ const [QueryForm] = useVbenForm({
|
|||||||
},
|
},
|
||||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function handleRowClickTest() {
|
||||||
|
emitter.emit('rowClick', uniqueId('mitt-'));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -50,6 +56,10 @@ const [QueryForm] = useVbenForm({
|
|||||||
{{ $t('pages.common.add') }}
|
{{ $t('pages.common.add') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</Card>
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<a-button @click="handleRowClickTest">测试mitt</a-button>
|
||||||
|
左侧向右侧传值
|
||||||
|
</Card>
|
||||||
<DictTypeModal />
|
<DictTypeModal />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user