123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
- <el-col :span="24" class="one">
- <cSearch :is_title="false"></cSearch>
- </el-col>
- <el-col :span="24" class="two">
- <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" label-width="auto">
- <template #logo_url="{ item }">
- <cUpload
- :model="item.model"
- :limit="1"
- url="/visit/api/files/config/upload"
- :list="form[item.model]"
- listType="picture-card"
- @change="onUpload"
- ></cUpload>
- </template>
- <template #group_url="{ item }">
- <cUpload
- :model="item.model"
- :limit="1"
- url="/visit/api/files/config/upload"
- :list="form[item.model]"
- listType="picture-card"
- @change="onUpload"
- ></cUpload>
- </template>
- <template #friend_url="{ item }">
- <cUpload
- :model="item.model"
- :limit="1"
- url="/visit/api/files/config/upload"
- :list="form[item.model]"
- listType="picture-card"
- @change="onUpload"
- ></cUpload>
- </template>
- <template #user_url="{ item }">
- <cUpload
- :model="item.model"
- :limit="1"
- url="/visit/api/files/config/upload"
- :list="form[item.model]"
- listType="picture-card"
- @change="onUpload"
- ></cUpload>
- </template>
- <template #agreement>
- <cEditor v-model="form.agreement" url="/visit/api/files/config/upload"></cEditor>
- </template>
- </cForm>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script setup lang="ts">
- // 基础
- import type { Ref } from 'vue';
- import { ref, reactive, onMounted } from 'vue';
- import { ElMessage } from 'element-plus';
- import type { FormRules } from 'element-plus';
- // 接口
- import { ConfigStore } from '@/stores/basic/config';
- import type { IQueryResult } from '@/util/types.util';
- const configAxios = ConfigStore();
- // 加载中
- const loading: Ref<any> = ref(false);
- // 表单
- let form: Ref<any> = ref({});
- let fields: Ref<any[]> = ref([
- { label: 'logo', model: 'logo_url', custom: true },
- { label: '群组logo', model: 'group_url', custom: true },
- { label: '好友logo', model: 'friend_url', custom: true },
- { label: '用户默认头像', model: 'user_url', custom: true },
- { label: '用户协议和隐私协议', model: 'agreement', custom: true },
- { label: '底部文案', model: 'bottom_title' }
- ]);
- const rules = reactive<FormRules>({});
- // 请求
- onMounted(async () => {
- loading.value = true;
- await search();
- loading.value = false;
- });
- const search = async () => {
- let res: IQueryResult = await configAxios.query();
- if (res.errcode == '0') {
- form.value = res.data;
- }
- };
- const onUpload = (e: { model: string; value: Array<[]> }) => {
- const { model, value } = e;
- form.value[model] = value;
- };
- const toSave = async (data) => {
- let res: IQueryResult;
- if (data._id) res = await configAxios.update(data);
- else res = await configAxios.create(data);
- if (res.errcode == 0) {
- ElMessage({ type: `success`, message: `维护信息成功` });
- search();
- }
- };
- </script>
- <style scoped lang="scss"></style>
|