feat:多钱包、电子钱包、字典select组件

This commit is contained in:
dzc committed 2024-12-30 16:15:59 +08:00
1 parent cd30aecc5e
commit 5a77526b0f
12 files changed
+964

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
<template>
<el-select style="width: 100%;" v-model="state.selectId" :placeholder="props.placeholder" clearable
@visible-change="(e: boolean) => e && getDictOptions()">
<el-option v-for="v in state.dictList" :key="v.code" :label="v.label" :value="v.value" />
</el-select>
</template>
<script setup lang="ts" name="dict-select">
import { reactive, computed, defineModel, withDefaults, defineProps } from 'vue';
import { dict } from '/@/stores/dict';
import { getDicts } from '/@/api/admin/dict';
const selectId = defineModel()
export type Props = {
dictCode: string,
placeholder?: string,
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "请选择",
})
const state = reactive<any>({
selectId: selectId,
dictList: []
})
watch(selectId, (newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
getDictOptions()
}, { immediate: true })
async function getDictOptions() {
if (!props.dictCode) return []
const dicts = dict().getDict(props.dictCode)
if (dicts) return dicts
const res = await getDicts(props.dictCode)
if (!res) return []
state.dictList = res.data.map((p: any) => ({ label: p.label, value: p.value, elTagType: p.listClass, elTagClass: p.cssClass }));
dict().setDict(props.dictCode, state.dictList);
}
</script>
<style scoped>
.el-tag+.el-tag {
margin-left: 10px;
}
</style>