This commit is contained in:
2025-05-12 19:45:18 +08:00
parent 396fd4b934
commit 4f1946e790
9 changed files with 119 additions and 29 deletions

View File

@@ -1,6 +1,8 @@
<script setup>
import {onMounted, reactive} from 'vue';
import Api from "../../api/index.js";
import XSelect from "../XSelect/index.vue";
import UploadAvatar from "../upload/UploadAvatar.vue";
const group = reactive([]);
@@ -17,6 +19,16 @@ onMounted(() => {
group.push(...data);
})
})
const getSingle = async () => {
const {data} = await Api.admin.getSingleList();
return {
data: data.list.map(v => ({
id: v.id,
name: v.title
}))
}
}
</script>
<template>
@@ -33,6 +45,27 @@ onMounted(() => {
<a-form-item label="url路径" v-if="[1,3,4].includes(form.type)">
<a-input v-model:model-value="form.url" placeholder="请输入url路径"></a-input>
</a-form-item>
<a-form-item v-if="form.type === 2" label="富文本内容">
<XSelect
v-model:model-value="form.single_id"
:init="true"
:api="getSingle"
placeholder="请选择二级分类">
</XSelect>
</a-form-item>
<a-form-item v-if="form.type === 5" label="弹窗内容">
<a-radio-group v-model:model-value="form.pop_type">
<a-radio :value="1">图片</a-radio>
<a-radio :value="2">视频</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item v-if="form.type === 5">
<UploadAvatar v-if="form.pop_type===1" v-model:files="form.pop_images"></UploadAvatar>
<UploadAvatar v-else v-model:files="form.pop_video" :multiple="false"></UploadAvatar>
</a-form-item>
</template>
<style scoped lang="scss">

View File

@@ -1,7 +1,7 @@
<script setup>
import {reactive} from "vue";
import {onMounted, reactive} from "vue";
const {api, fieldName, apiPo} = defineProps({
const {api, fieldName, apiPo, init} = defineProps({
api: {
type: Function,
default: async () => {
@@ -15,6 +15,10 @@ const {api, fieldName, apiPo} = defineProps({
fieldName: {
type: Object,
default: {value: 'id', label: 'name'},
},
init: {
type: Boolean,
default: false,
}
});
const list = reactive([]);
@@ -27,6 +31,13 @@ const popupChange = async (visible) => {
});
}
}
onMounted(() => {
if (init) api && api(apiPo).then(({data}) => {
list.length = 0;
list.push(...data);
});
});
</script>
<template>

View File

@@ -2,7 +2,7 @@
import XImage from "../XImage/Index.vue";
import Api from "../../api/index.js";
const {size, api} = defineProps({
const {size, api, multiple} = defineProps({
size: {
type: String,
default: '60px'
@@ -10,14 +10,23 @@ const {size, api} = defineProps({
api: {
type: Function,
default: Api.system.uploadFile,
},
multiple: {
type: Boolean,
default: true,
}
});
const files = defineModel('files');
const emits = defineEmits(['success']);
const beforeUpload = (file) => {
api(file).then(({data}) => {
files.value.push(data);
api && api(file).then(({data}) => {
console.log(files.value);
if (!multiple) {
files.value = [data];
} else {
files.value.push(data);
}
emits('success', data);
});
return false;
@@ -26,7 +35,8 @@ const beforeUpload = (file) => {
<template>
<div class="flex flex-wrap gap-[15px]">
<a-upload :style="{width: size,height: size}" @before-upload="beforeUpload" multiple>
<a-upload v-if="!(!multiple && files.length >= 1)" :style="{width: size,height: size}"
@before-upload="beforeUpload" :multiple="multiple">
<template #upload-button>
<div class="upload-button test">
<IconPlus/>