修改每日菜谱问题和调整首页布局以及移除不必要的导入

This commit is contained in:
ctw committed 2025-01-17 14:15:01 +08:00
1 parent 611f1d634d
commit 373de198e4
11 files changed
+200 -159

No files matched your search

+43 -29
View File
@@ -1,52 +1,66 @@
<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>
<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';
import { reactive } from "vue"
import { dict } from "/@/stores/dict"
import { getDicts } from "/@/api/admin/dict"
const selectId = defineModel()
export type Props = {
dictCode: string,
placeholder?: string,
dictCode: string
placeholder?: string
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "请选择",
placeholder: "请选择",
})
const state = reactive<any>({
selectId: selectId,
dictList: []
selectId: selectId,
dictList: [],
})
watch(selectId, (newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
getDictOptions()
}, { immediate: true })
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) {
state.dictList = dicts
return
}
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);
if (!props.dictCode) return []
const dicts = dict().getDict(props.dictCode)
if (dicts) {
state.dictList = dicts
return
}
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;
.el-tag + .el-tag {
margin-left: 10px;
}
</style>