generated from Leo_Ding/web-template
优化
This commit is contained in:
parent
f91b1537b6
commit
42ee373a62
@ -142,7 +142,7 @@ function handleOk() {
|
||||
...values,
|
||||
img: formData.value.img,
|
||||
pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
|
||||
type: 'news'
|
||||
typer: 'news'
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
|
||||
@ -137,6 +137,7 @@ async function getPageList() {
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
type:'news',
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
@ -144,7 +145,7 @@ async function getPageList() {
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data.filter(item => item.type === "news")
|
||||
listData.value = data
|
||||
console.log('消息:',this.listData.value)
|
||||
paginationState.total = total
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ function handleOk() {
|
||||
...values,
|
||||
img: formData.value.img,
|
||||
pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
|
||||
type: 'banner'
|
||||
typer: 'banner'
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
|
||||
@ -130,6 +130,7 @@ async function getPageList() {
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
type:'banner',
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
@ -137,7 +138,7 @@ async function getPageList() {
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data.filter(item => item.type === "banner")
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<a-textarea :placeholder="'请输入零容忍内容'" v-model:value="reportContent"></a-textarea>
|
||||
</a-form-item>
|
||||
<a-form-item :label="'零容忍图片'" name="reportImage">
|
||||
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
||||
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
||||
<gx-upload v-model="reportImage" :fileNumber="1" />
|
||||
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||
</a-form-item>
|
||||
@ -28,44 +28,22 @@
|
||||
<a-input :placeholder="'请输入编码'" v-model:value="reportNum"></a-input>
|
||||
</a-form-item>
|
||||
<template v-if="Array.isArray(socialMedia)">
|
||||
<a-form-item
|
||||
v-for="(itemImg, index) in socialMedia"
|
||||
:key="index"
|
||||
<a-form-item v-for="(itemImg, index) in socialMedia" :key="index"
|
||||
:label="itemImg.name || `社交媒体${index + 1}`">
|
||||
<a-input
|
||||
class="inputPhone"
|
||||
v-model:value="itemImg.name"
|
||||
placeholder="请输入图片名称"
|
||||
/>
|
||||
<gx-upload
|
||||
v-model="itemImg.image"
|
||||
:fileNumber="1"
|
||||
/>
|
||||
<a-input class="inputPhone" v-model:value="itemImg.name" placeholder="请输入图片名称" />
|
||||
<gx-upload v-model="itemImg.image" :fileNumber="1" />
|
||||
<p class="hint">106*106px,图片大小不超过50kb</p>
|
||||
<a-input
|
||||
class="inputPhone"
|
||||
v-model:value="itemImg.link"
|
||||
placeholder="请输入跳转链接"
|
||||
/>
|
||||
<a-button
|
||||
danger
|
||||
@click="removeSocialMedia(index)"
|
||||
size="small"
|
||||
style="margin-bottom: 20px">删除
|
||||
<a-input class="inputPhone" v-model:value="itemImg.link" placeholder="请输入跳转链接" />
|
||||
<a-button danger @click="removeSocialMedia(index)" size="small" style="margin-bottom: 20px">删除
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button
|
||||
type="dashed"
|
||||
block
|
||||
@click="addSocialMedia">新增社交媒体
|
||||
<a-button type="dashed" block @click="addSocialMedia">新增社交媒体
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
|
||||
</template>
|
||||
<a-form-item :label="'网站声明'">
|
||||
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
||||
</a-form-item>
|
||||
|
||||
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
@ -77,7 +55,7 @@ import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
||||
import { usePagination } from '@/hooks'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { spliceUrl } from '@/utils/util'
|
||||
import { getWebData,updateWebData} from '@/apis/modules/webSite'
|
||||
import { getWebData, updateWebData } from '@/apis/modules/webSite'
|
||||
import XSearchBar from '@/components/SearchBar/SearchBar.vue'
|
||||
import GxUpload from '@/components/GxUpload/index.vue' // 获取声明接口
|
||||
import { config } from '@/config'
|
||||
@ -114,14 +92,14 @@ async function getPageList() {
|
||||
id.value = res.data.id
|
||||
affirm.value = res.data.affirm
|
||||
reportContent.value = res.data.reportContent
|
||||
reportImage.value = [config('http.apiBasic')+res.data.reportImage]
|
||||
reportImage.value = [config('http.apiBasic') + res.data.reportImage]
|
||||
email.value = res.data.email
|
||||
lat.value = res.data.lat
|
||||
lon.value = res.data.lon
|
||||
address.value = res.data.address
|
||||
phone.value = res.data.phone
|
||||
reportNum.value = res.data.reportNum
|
||||
socialMedia.value = Array.isArray(res.data.socialMedia) ? res.data.socialMedia.map(item=>({link:item.link,name:item.name,image:[config('http.apiBasic')+item.image]})) : []
|
||||
socialMedia.value = Array.isArray(res.data.socialMedia) ? res.data.socialMedia.map(item => ({ link: item.link, name: item.name, image: [config('http.apiBasic') + item.image] })) : []
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('获取声明内容失败')
|
||||
@ -159,9 +137,10 @@ async function handleSearch() {
|
||||
? reportImage.value[0]
|
||||
: reportImage?.value;
|
||||
const reportImageFormatted = {
|
||||
reportImage: spliceUrl(reportImageRaw)};
|
||||
reportImage: spliceUrl(reportImageRaw)
|
||||
};
|
||||
|
||||
await apis.webSite.updateWebData(id.value, {
|
||||
const {success}=await apis.webSite.updateWebData(id.value, {
|
||||
affirm: affirm.value,
|
||||
reportContent: reportContent.value,
|
||||
reportImage: reportImageFormatted.reportImage,
|
||||
@ -174,6 +153,11 @@ async function handleSearch() {
|
||||
reportNum: reportNum.value,
|
||||
socialMedia: formattedSocialMedia,
|
||||
})
|
||||
if(success){
|
||||
getPageList()
|
||||
message.success('保存成功')
|
||||
|
||||
}
|
||||
// await apis.webSite.updateWebData(id.value, {
|
||||
// affirm: affirm.value,
|
||||
// reportContent: reportContent.value,
|
||||
@ -189,7 +173,6 @@ async function handleSearch() {
|
||||
//
|
||||
// socialMedia: socialMedia.value,
|
||||
// })
|
||||
message.success('保存成功')
|
||||
} catch (e) {
|
||||
message.error('保存失败,请重试')
|
||||
} finally {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
||||
<x-editor v-model="form.affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
||||
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
@ -20,9 +20,9 @@ defineOptions({
|
||||
})
|
||||
const { t } = useI18n()
|
||||
const { showLoading, hideLoading} = usePagination()
|
||||
let affirm = null // 初始化声明内容
|
||||
let id = null // 初始化声明内容
|
||||
|
||||
let affirm = ref() // 初始化声明内容
|
||||
let id = ref() // 初始化声明内容
|
||||
let form=ref({})
|
||||
// 页面加载时获取声明内容
|
||||
getPageList()
|
||||
|
||||
@ -32,12 +32,10 @@ getPageList()
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const res = await getWebData() // 假设返回格式为 { data: { affirm: '内容' } }
|
||||
if (res?.data) {
|
||||
affirm = res.data.affirm
|
||||
id = res.data.id // 新增
|
||||
console.log(affirm)
|
||||
console.log(id)
|
||||
const {data,success} = await getWebData() // 假设返回格式为 { data: { affirm: '内容' } }
|
||||
if (success) {
|
||||
console.log(data,'data')
|
||||
form.value={...data}
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('获取声明内容失败')
|
||||
@ -46,22 +44,16 @@ async function getPageList() {
|
||||
}
|
||||
}
|
||||
|
||||
function isEmptyRichText(html) {
|
||||
return !html || html.replace(/<[^>]+>/g, '').trim() === ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交声明内容
|
||||
*/
|
||||
async function handleSearch() {
|
||||
console.log('affirm:', affirm)
|
||||
if (isEmptyRichText(affirm)) {
|
||||
message.warning('请输入声明内容')
|
||||
return
|
||||
}
|
||||
try {
|
||||
showLoading()
|
||||
await apis.webSite.updateWebData(id, { affirm: affirm })
|
||||
const {data,success} = await apis.webSite.updateWebData(form.value.id, form.value)
|
||||
if(success){
|
||||
getPageList()
|
||||
}
|
||||
message.success('保存成功')
|
||||
} catch (e) {
|
||||
message.error('保存失败,请重试')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user