feat:多钱包、电子钱包、字典select组件
This commit is contained in:
1 parent
cd30aecc5e
commit
5a77526b0f
12 files changed
+964
No files matched your search
@@ -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>
|
||||
@@ -1,6 +1,7 @@
|
||||
import Pagination from '/@/components/Pagination/index.vue';
|
||||
import RightToolbar from '/@/components/RightToolbar/index.vue';
|
||||
import DictTag from '/@/components/DictTag/index.vue';
|
||||
import DictSelect from "/@/components/DictSelect/index.vue"
|
||||
import UploadExcel from '/@/components/Upload/Excel.vue';
|
||||
import UploadFile from '/@/components/Upload/index.vue';
|
||||
import UploadImg from '/@/components/Upload/Image.vue';
|
||||
@@ -32,6 +33,7 @@ import { App } from 'vue';
|
||||
export default {
|
||||
install(app: App) {
|
||||
app.component('DictTag', DictTag);
|
||||
app.component('DictSelect',DictSelect)
|
||||
app.component('Pagination', Pagination);
|
||||
app.component('RightToolbar', RightToolbar);
|
||||
app.component('uploadExcel', UploadExcel);
|
||||
|
||||
Reference in new issue
Block a user