update
This commit is contained in:
55
src/components/XAutoComplete/index.vue
Normal file
55
src/components/XAutoComplete/index.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, reactive} from "vue";
|
||||
|
||||
const {api, fieldName, apiPo, init} = defineProps({
|
||||
api: {
|
||||
type: Function,
|
||||
default: async () => {
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
apiPo: {
|
||||
type: Object,
|
||||
default: {}
|
||||
},
|
||||
fieldName: {
|
||||
type: Object,
|
||||
default: {value: 'id', label: 'name'},
|
||||
},
|
||||
init: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const list = reactive([]);
|
||||
|
||||
const popupChange = async (visible) => {
|
||||
if (visible) {
|
||||
api && api(apiPo).then(({data}) => {
|
||||
list.length = 0;
|
||||
list.push(...data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (init) api && api(apiPo).then(({data}) => {
|
||||
list.length = 0;
|
||||
list.push(...data.map(v => v.name));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-auto-complete
|
||||
v-bind="$attrs"
|
||||
:data="list"
|
||||
:field-names="fieldName"
|
||||
placeholder="请输入或选择">
|
||||
</a-auto-complete>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
26
src/components/XMention/index.vue
Normal file
26
src/components/XMention/index.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<script setup>
|
||||
const {placeholder} = defineProps({
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请输入话题'
|
||||
}
|
||||
});
|
||||
const emits = defineEmits(['success']);
|
||||
|
||||
const change = (e) => {
|
||||
emits('success', e.split(' '));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-mention
|
||||
prefix="#"
|
||||
@change="change"
|
||||
:allow-clear="true"
|
||||
:placeholder="placeholder">
|
||||
</a-mention>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import {onMounted, reactive} from "vue";
|
||||
|
||||
const {api, fieldName, apiPo, init} = defineProps({
|
||||
const {api, fieldName, apiPo, init, defaultValue} = defineProps({
|
||||
api: {
|
||||
type: Function,
|
||||
default: async () => {
|
||||
@@ -19,7 +19,11 @@ const {api, fieldName, apiPo, init} = defineProps({
|
||||
init: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
defaultValue: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const list = reactive([]);
|
||||
|
||||
@@ -45,6 +49,7 @@ onMounted(() => {
|
||||
v-bind="$attrs"
|
||||
:options="list"
|
||||
:field-names="fieldName"
|
||||
:default-value="defaultValue"
|
||||
@popup-visible-change="popupChange"
|
||||
placeholder="请选择">
|
||||
</a-select>
|
||||
|
||||
@@ -14,11 +14,13 @@ const value = computed({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-time-picker
|
||||
<a-range-picker
|
||||
v-model:model-value="value"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
v-bind="$attrs"
|
||||
show-time
|
||||
type="time-range">
|
||||
</a-time-picker>
|
||||
</a-range-picker>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user