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