generated from Leo_Ding/web-template
即将修改网站-联系我们-混乱中
This commit is contained in:
parent
b64c42f285
commit
7e458744ea
@ -1,225 +1,127 @@
|
|||||||
<template>
|
<template>
|
||||||
<x-search-bar class="mb-8-2">
|
<x-search-bar class="mb-8-2">
|
||||||
<template #default="{ gutter, colSpan }">
|
<template #default="{ gutter, colSpan }">
|
||||||
<a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
|
<a-form-item :label="'零容忍'" name="reportContent">
|
||||||
<a-row :gutter="gutter">
|
<a-textarea :placeholder="'请输入零容忍内容'" v-model:value="reportContent"></a-textarea>
|
||||||
<a-col v-bind="colSpan">
|
</a-form-item>
|
||||||
<a-form-item label="名称" name="name">
|
<a-form-item :label="'举报邮箱'" name="email">
|
||||||
<a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></a-input>
|
<a-input :placeholder="'请输入举报邮箱'" v-model:value="email"></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
<a-form-item :label="'经度'" name="lat">
|
||||||
|
<a-input-number :placeholder="'请输入经度'" v-model:value="lat"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'纬度'" name="lon">
|
||||||
|
<a-input-number :placeholder="'请输入经度'" v-model:value="lon"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'地址'" name="address">
|
||||||
|
<a-input :placeholder="'请输入地址'" v-model:value="address"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'电话'" name="phone">
|
||||||
|
<a-input :placeholder="'请输入电话'" v-model:value="phone"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'编码'" name="reportNum">
|
||||||
|
<a-input :placeholder="'请输入编码'" v-model:value="reportNum"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
<a-col v-bind="colSpan">
|
<a-form-item :label="'海邻公众号'" name="Image">
|
||||||
<a-form-item label="状态" name="status">
|
<x-upload-image v-model="Image" @imgChange="imgChange" />
|
||||||
<a-select v-model:value="searchFormData.status" allowClear>
|
</a-form-item>
|
||||||
<a-select-option value="">全部</a-select-option>
|
<a-form-item :label="'海邻视频号'" name="Image">
|
||||||
<a-select-option value="enabled">启用</a-select-option>
|
<x-upload-image v-model="Image" @imgChange="imgChange" />
|
||||||
<a-select-option value="disabled">停用</a-select-option>
|
</a-form-item>
|
||||||
</a-select>
|
<a-form-item :label="'海邻抖音'" name="Image">
|
||||||
</a-form-item>
|
<x-upload-image v-model="Image" @imgChange="imgChange" />
|
||||||
</a-col>
|
</a-form-item>
|
||||||
|
|
||||||
<a-col class="align-right" v-bind="colSpan">
|
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||||
<a-space>
|
|
||||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
|
||||||
<a-button ghost type="primary" @click="handleSearch">
|
|
||||||
{{ $t('button.search') }}
|
|
||||||
</a-button>
|
|
||||||
</a-space>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</template>
|
</template>
|
||||||
</x-search-bar>
|
</x-search-bar>
|
||||||
<a-row :gutter="8" :wrap="false">
|
|
||||||
<a-col flex="auto">
|
|
||||||
<a-card type="flex">
|
|
||||||
<x-action-bar class="mb-8-2">
|
|
||||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
|
||||||
<template #icon>
|
|
||||||
<plus-outlined></plus-outlined>
|
|
||||||
</template>
|
|
||||||
新增动态
|
|
||||||
</a-button>
|
|
||||||
</x-action-bar>
|
|
||||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
|
||||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
|
||||||
<template #bodyCell="{ column, record }">
|
|
||||||
<template v-if="'reportImage' === column.dataIndex">
|
|
||||||
<!-- <a-image :width="60" :src="record.img || $imageErr.imgErr" />-->
|
|
||||||
<a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'reportContent'">
|
|
||||||
<a-tooltip :title="record.reportContent">
|
|
||||||
<span>{{ record.reportContent }}</span>
|
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'email'">
|
|
||||||
<a-tooltip :title="record.email">
|
|
||||||
<span>{{ record.email }}</span>
|
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'address'">
|
|
||||||
<a-tooltip :title="record.address">
|
|
||||||
<span>{{ record.address }}</span>
|
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'phone'">
|
|
||||||
<a-tooltip :title="record.phone">
|
|
||||||
<span>{{ record.phone }}</span>
|
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'reportNum'">
|
|
||||||
<a-tooltip :title="record.reportNum">
|
|
||||||
<span>{{ record.reportNum }}</span>
|
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
|
|
||||||
<template v-if="'status' === column.dataIndex">
|
|
||||||
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
|
|
||||||
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
|
|
||||||
</template>
|
|
||||||
<template v-if="'action' === column.key">
|
|
||||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
|
||||||
<a-tooltip>
|
|
||||||
<template #title> {{ $t('pages.system.user.edit') }}</template>
|
|
||||||
<edit-outlined /> </a-tooltip></x-action-button>
|
|
||||||
<x-action-button @click="handleDelete(record)">
|
|
||||||
<a-tooltip>
|
|
||||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
|
||||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
</a-card>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
|
|
||||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { message, Modal } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import apis from '@/apis'
|
import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
||||||
import { formatUtcDateTime } from '@/utils/util'
|
|
||||||
import { config } from '@/config'
|
|
||||||
import { statusUserTypeEnum } from '@/enums/system'
|
|
||||||
import { usePagination } from '@/hooks'
|
import { usePagination } from '@/hooks'
|
||||||
|
|
||||||
import EditDialog from './components/EditDialog.vue'
|
|
||||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { delMenu, getDataList } from '@/apis/modules/webSite'
|
import { getWebData,updateWebData} from '@/apis/modules/webSite' // 获取声明接口
|
||||||
import { getWebDataList } from '@/apis/modules/webSite'
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'contactUs',
|
name: 'friendlyLinks',
|
||||||
})
|
})
|
||||||
const { t } = useI18n() // 解构出t方法
|
const { t } = useI18n()
|
||||||
const columns = [
|
const { showLoading, hideLoading} = usePagination()
|
||||||
{ title: '图片', dataIndex: 'reportImage', width: 100, align: 'center' },
|
const affirm = ref(null)
|
||||||
{ title: '零容忍', dataIndex: 'reportContent', key: 'reportContent' },
|
const id = ref(null)
|
||||||
{ title: '举报邮箱', dataIndex: 'email', key: 'email' },
|
const reportContent = ref(null)
|
||||||
{ title: '经度', dataIndex: 'lat', key: 'lat' },
|
const email = ref(null)
|
||||||
{ title: '纬度', dataIndex: 'lon', key: 'lon' },
|
const lat = ref(null)
|
||||||
{ title: '地址', dataIndex: 'address', width: 120, align: 'center' },
|
const lon = ref(null)
|
||||||
{ title: '电话', dataIndex: 'phone', width: 100, align: 'center' },
|
const address = ref(null)
|
||||||
{ title: '编码', dataIndex: 'reportNum', width: 100, align: 'center' },
|
const phone = ref(null)
|
||||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
const reportNum = ref(null)
|
||||||
]
|
const mediaImg = ref(null)
|
||||||
|
// 页面加载时获取声明内容
|
||||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
|
||||||
usePagination()
|
|
||||||
|
|
||||||
const editDialogRef = ref()
|
|
||||||
getPageList()
|
getPageList()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取声明内容
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
async function getPageList() {
|
async function getPageList() {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const { pageSize, current } = paginationState
|
const res = await getWebData() // 假设返回格式为 { data: { affirm: '内容' } }
|
||||||
const { success, data, total } = await apis.webSite
|
if (res?.data) {
|
||||||
.getWebDataList({
|
id.value = res.data.id
|
||||||
pageSize,
|
affirm.value = res.data.affirm
|
||||||
page: current,
|
reportContent.value = res.data.reportContent
|
||||||
...searchFormData.value,
|
email.value = res.data.email
|
||||||
})
|
lat.value = res.data.lat
|
||||||
.catch(() => {
|
lon.value = res.data.lon
|
||||||
throw new Error()
|
address.value = res.data.address
|
||||||
})
|
phone.value = res.data.phone
|
||||||
hideLoading()
|
reportNum.value = res.data.reportNum
|
||||||
if (config('http.code.success') === success) {
|
console.log(affirm.value)
|
||||||
listData.value = data
|
console.log(id.value)
|
||||||
paginationState.total = total
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
|
message.error('获取声明内容失败')
|
||||||
|
} finally {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function isEmptyRichText(html) {
|
||||||
* 删除
|
return !html || html.replace(/<[^>]+>/g, '').trim() === ''
|
||||||
*/
|
|
||||||
function handleDelete({ id }) {
|
|
||||||
Modal.confirm({
|
|
||||||
title: t('pages.system.user.delTip'),
|
|
||||||
content: t('button.confirm'),
|
|
||||||
okText: t('button.confirm'),
|
|
||||||
onOk: () => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
; (async () => {
|
|
||||||
try {
|
|
||||||
const { success } = await apis.webSite.delMenu(id).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
if (config('http.code.success') === success) {
|
|
||||||
resolve()
|
|
||||||
message.success(t('component.message.success.delete'))
|
|
||||||
await getPageList()
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页
|
* 提交声明内容
|
||||||
*/
|
*/
|
||||||
function onTableChange({ current, pageSize }) {
|
async function handleSearch() {
|
||||||
paginationState.current = current
|
// console.log('affirm:', affirm.value)
|
||||||
paginationState.pageSize = pageSize
|
// if (isEmptyRichText(affirm.value)) {
|
||||||
getPageList()
|
// message.warning('请输入声明内容')
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
/**
|
try {
|
||||||
* 搜索
|
showLoading()
|
||||||
*/
|
await apis.webSite.updateWebData(id.value, {
|
||||||
function handleSearch() {
|
affirm: affirm.value,
|
||||||
resetPagination()
|
reportContent: reportContent.value,
|
||||||
getPageList()
|
email: email.value,
|
||||||
}
|
lat: lat.value,
|
||||||
/**
|
lon: lon.value,
|
||||||
* 重置
|
address: address.value,
|
||||||
*/
|
phone: phone.value,
|
||||||
function handleResetSearch() {
|
reportNum: reportNum.value,
|
||||||
searchFormData.value = {}
|
})
|
||||||
resetPagination()
|
message.success('保存成功')
|
||||||
getPageList()
|
} catch (e) {
|
||||||
}
|
message.error('保存失败,请重试')
|
||||||
/**
|
} finally {
|
||||||
* 编辑完成
|
hideLoading()
|
||||||
*/
|
}
|
||||||
async function onOk() {
|
|
||||||
message.success(t('component.message.success.delete'))
|
|
||||||
await getPageList()
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,169 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-card
|
|
||||||
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
|
|
||||||
:style="{
|
|
||||||
position: 'sticky',
|
|
||||||
top: appStore.mainOffsetTop,
|
|
||||||
height: appStore.mainHeight,
|
|
||||||
}">
|
|
||||||
<template #title>
|
|
||||||
<a-input-search placeholder="搜索部门"></a-input-search>
|
|
||||||
</template>
|
|
||||||
<x-scrollbar class="pa-8-2">
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<a-tree
|
|
||||||
block-node
|
|
||||||
:selected-keys="selectedKeys"
|
|
||||||
:tree-data="listData"
|
|
||||||
:field-names="{ key: 'id', children: 'children' }"
|
|
||||||
@select="onSelect">
|
|
||||||
<template #title="{ title }">
|
|
||||||
<span class="ant-tree-title__name">{{ title }}</span>
|
|
||||||
<span class="ant-tree-title__actions">
|
|
||||||
<a-dropdown
|
|
||||||
:trigger="['click']"
|
|
||||||
@click.stop>
|
|
||||||
<x-action-button>
|
|
||||||
<more-outlined></more-outlined>
|
|
||||||
</x-action-button>
|
|
||||||
<template #overlay>
|
|
||||||
<a-menu>
|
|
||||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
|
||||||
添加子部门
|
|
||||||
</a-menu-item>
|
|
||||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
|
||||||
编辑
|
|
||||||
</a-menu-item>
|
|
||||||
<a-menu-item @click="handleDelete">删除</a-menu-item>
|
|
||||||
</a-menu>
|
|
||||||
</template>
|
|
||||||
</a-dropdown>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</a-tree>
|
|
||||||
<empty
|
|
||||||
v-if="!listData.length"
|
|
||||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
|
|
||||||
</a-spin>
|
|
||||||
</x-scrollbar>
|
|
||||||
<template #actions>
|
|
||||||
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
|
|
||||||
<plus-outlined></plus-outlined>
|
|
||||||
新建部门
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</a-card>
|
|
||||||
|
|
||||||
<edit-department-dialog
|
|
||||||
ref="editDepartmentDialogRef"
|
|
||||||
@ok="onOk"></edit-department-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { useAppStore } from '@/store'
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import { usePagination } from '@/hooks'
|
|
||||||
import apis from '@/apis'
|
|
||||||
import { Empty, Modal, message } from 'ant-design-vue'
|
|
||||||
import { config } from '@/config'
|
|
||||||
import { head, get, find } from 'lodash-es'
|
|
||||||
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
|
||||||
import EditDepartmentDialog from './EditDepartmentDialog.vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits(['change', 'update:value'])
|
|
||||||
|
|
||||||
const appStore = useAppStore()
|
|
||||||
const { listData, loading, showLoading, hideLoading } = usePagination()
|
|
||||||
|
|
||||||
const editDepartmentDialogRef = ref()
|
|
||||||
const selectedKeys = ref([props.value])
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.value,
|
|
||||||
(val) => {
|
|
||||||
if (val === selectedKeys.value?.[0]) return
|
|
||||||
selectedKeys.value = [val]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
getList()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取列表
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
async function getList() {
|
|
||||||
try {
|
|
||||||
showLoading()
|
|
||||||
const { code, data } = await apis.common.getPageList().catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
hideLoading()
|
|
||||||
if (config('http.code.success') === code) {
|
|
||||||
const { records } = data
|
|
||||||
listData.value = records
|
|
||||||
if (listData.value.length) {
|
|
||||||
selectedKeys.value = [get(head(listData.value), 'id')]
|
|
||||||
trigger()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
hideLoading()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
function handleDelete({ id }) {
|
|
||||||
Modal.confirm({
|
|
||||||
title: '删除提示',
|
|
||||||
content: '确认删除?',
|
|
||||||
okText: '确认',
|
|
||||||
onOk: () => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
;(async () => {
|
|
||||||
try {
|
|
||||||
const { code } = await apis.common.del(id).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
if (config('http.code.success') === code) {
|
|
||||||
resolve()
|
|
||||||
message.success('删除成功')
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelect(keys) {
|
|
||||||
if (!keys.length) return
|
|
||||||
selectedKeys.value = keys
|
|
||||||
trigger()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onOk() {
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
function trigger() {
|
|
||||||
const value = head(selectedKeys.value)
|
|
||||||
const record = find(listData.value, { id: value })
|
|
||||||
emit('update:value', value)
|
|
||||||
emit('change', record)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
|
||||||
@ -1,131 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
:open="modal.open"
|
|
||||||
:title="modal.title"
|
|
||||||
:width="480"
|
|
||||||
:confirm-loading="modal.confirmLoading"
|
|
||||||
:after-close="onAfterClose"
|
|
||||||
:cancel-text="cancelText"
|
|
||||||
@ok="handleOk"
|
|
||||||
@cancel="handleCancel">
|
|
||||||
<a-form
|
|
||||||
ref="formRef"
|
|
||||||
:model="formData"
|
|
||||||
:rules="formRules"
|
|
||||||
:label-col="{ style: { width: '90px' } }">
|
|
||||||
<a-form-item
|
|
||||||
label="部门名称"
|
|
||||||
name="name">
|
|
||||||
<a-input v-model:value="formData.name"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item
|
|
||||||
label="上级部门"
|
|
||||||
name="parent_id">
|
|
||||||
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item
|
|
||||||
label="部门负责人"
|
|
||||||
name="name">
|
|
||||||
<a-input v-model:value="formData.name"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { cloneDeep } from 'lodash-es'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { config } from '@/config'
|
|
||||||
import apis from '@/apis'
|
|
||||||
import { useForm, useModal } from '@/hooks'
|
|
||||||
|
|
||||||
const emit = defineEmits(['ok'])
|
|
||||||
|
|
||||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
|
||||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
|
||||||
const cancelText = ref('取消')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新建
|
|
||||||
*/
|
|
||||||
function handleCreate() {
|
|
||||||
showModal({
|
|
||||||
type: 'create',
|
|
||||||
title: '新建部门',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑
|
|
||||||
*/
|
|
||||||
function handleEdit(record = {}) {
|
|
||||||
showModal({
|
|
||||||
type: 'edit',
|
|
||||||
title: '编辑部门',
|
|
||||||
})
|
|
||||||
formRecord.value = record
|
|
||||||
formData.value = cloneDeep(record)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确定
|
|
||||||
*/
|
|
||||||
function handleOk() {
|
|
||||||
formRef.value
|
|
||||||
.validateFields()
|
|
||||||
.then(async (values) => {
|
|
||||||
try {
|
|
||||||
showLoading()
|
|
||||||
const params = {
|
|
||||||
...values,
|
|
||||||
}
|
|
||||||
let result = null
|
|
||||||
switch (modal.value.type) {
|
|
||||||
case 'create':
|
|
||||||
result = await apis.common.create(params).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'edit':
|
|
||||||
result = await apis.common.update(params).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
hideLoading()
|
|
||||||
if (config('http.code.success') === result?.code) {
|
|
||||||
hideModal()
|
|
||||||
emit('ok')
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
hideLoading()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
hideLoading()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消
|
|
||||||
*/
|
|
||||||
function handleCancel() {
|
|
||||||
hideModal()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭后
|
|
||||||
*/
|
|
||||||
function onAfterClose() {
|
|
||||||
resetForm()
|
|
||||||
cancelText.value = '取消'
|
|
||||||
hideLoading()
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
handleCreate,
|
|
||||||
handleEdit,
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
|
||||||
@ -1,184 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
|
|
||||||
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
|
||||||
<a-form ref="formRef" :model="formData" :rules="formRules">
|
|
||||||
<a-card class="mb-8-2">
|
|
||||||
<a-row :gutter="12">
|
|
||||||
<a-col :span="24">
|
|
||||||
<a-form-item :label="'声明'" name="affirm">
|
|
||||||
<a-input :placeholder="'请输入声明内容'" v-model:value="formData.affirm"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="24">
|
|
||||||
<a-form-item :label="'状态'" name="status">
|
|
||||||
<a-radio-group v-model:value="formData.status" :options="[
|
|
||||||
{ label: '启用', value: 'enabled' },
|
|
||||||
{ label: '停用', value: 'disabled' },
|
|
||||||
]"></a-radio-group>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-card>
|
|
||||||
</a-form>
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { cloneDeep } from 'lodash-es'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { config } from '@/config'
|
|
||||||
import apis from '@/apis'
|
|
||||||
import { useForm, useModal } from '@/hooks'
|
|
||||||
import { message } from 'ant-design-vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
|
|
||||||
const emit = defineEmits(['ok'])
|
|
||||||
const { t } = useI18n() // 解构出t方法
|
|
||||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
|
||||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
|
||||||
const cancelText = ref(t('button.cancel'))
|
|
||||||
const okText = ref(t('button.confirm'))
|
|
||||||
const rolesValue = ref([])
|
|
||||||
const roles = ref([])
|
|
||||||
const img = ref('')
|
|
||||||
formRules.value = {
|
|
||||||
name: { required: true, message: '请输入名称' },
|
|
||||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* select 选择框
|
|
||||||
*/
|
|
||||||
const handleChange = (value) => {
|
|
||||||
rolesValue.value = value
|
|
||||||
}
|
|
||||||
const imgChange = (value) => {
|
|
||||||
formData.value.img = value
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 新建
|
|
||||||
*/
|
|
||||||
function handleCreate() {
|
|
||||||
showModal({
|
|
||||||
type: 'create',
|
|
||||||
title: '添加公司动态',
|
|
||||||
})
|
|
||||||
formData.value.status = 'enabled'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑
|
|
||||||
*/
|
|
||||||
async function handleEdit(record = {}) {
|
|
||||||
showModal({
|
|
||||||
type: 'edit',
|
|
||||||
title: t('pages.system.user.edit'),
|
|
||||||
})
|
|
||||||
const { data, success } = await apis.webSite.getMenu(record.id).catch()
|
|
||||||
if (!success) {
|
|
||||||
hideModal()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
formData.value = { ...data }
|
|
||||||
formData.value.pushAt=dayjs(data.pushAt)
|
|
||||||
console.log(formData.value)
|
|
||||||
// img.value = config('http.apiBasic') + data.img
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确定
|
|
||||||
*/
|
|
||||||
function handleOk() {
|
|
||||||
// if (!formData.value.img) return message.error('请上传图片');
|
|
||||||
formRef.value.validateFields().then(async (values) => {
|
|
||||||
console.log(values)
|
|
||||||
try {
|
|
||||||
showLoading()
|
|
||||||
const params = {
|
|
||||||
...values,
|
|
||||||
// img: formData.value.img,
|
|
||||||
pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
|
|
||||||
// type: 10 ,
|
|
||||||
// // 10对应friendlyLinks
|
|
||||||
}
|
|
||||||
let result = null
|
|
||||||
console.log(modal.value.type)
|
|
||||||
switch (modal.value.type) {
|
|
||||||
case 'create':
|
|
||||||
result = await apis.webSite.createMenu(params).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'edit':
|
|
||||||
// result = await apis.webSite.updateMenu(formData.value.id, params).catch(() => {
|
|
||||||
result = await apis.webSite.updateMenu(formData.value.id, params).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
hideLoading()
|
|
||||||
if (config('http.code.success') === result?.success) {
|
|
||||||
hideModal()
|
|
||||||
emit('ok')
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error)
|
|
||||||
hideLoading()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.log(e)
|
|
||||||
hideLoading()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对权限组 过数据格式
|
|
||||||
*/
|
|
||||||
function formatArr(data, type = '') {
|
|
||||||
const rolesArr = []
|
|
||||||
data.forEach((item) => {
|
|
||||||
roles.value.forEach((r) => {
|
|
||||||
if (type === 'edit') {
|
|
||||||
if (item.role_id === r.value) {
|
|
||||||
rolesArr.push({
|
|
||||||
value: item.role_id,
|
|
||||||
label: r.label,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else if (r.value === item) {
|
|
||||||
rolesArr.push({
|
|
||||||
role_id: item,
|
|
||||||
role_name: r.label,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return rolesArr
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消
|
|
||||||
*/
|
|
||||||
function handleCancel() {
|
|
||||||
img.value = ''
|
|
||||||
hideModal()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭后
|
|
||||||
*/
|
|
||||||
function onAfterClose() {
|
|
||||||
resetForm()
|
|
||||||
hideLoading()
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
handleCreate,
|
|
||||||
handleEdit,
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
|
||||||
@ -36,8 +36,8 @@ async function getPageList() {
|
|||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
affirm = res.data.affirm
|
affirm = res.data.affirm
|
||||||
id = res.data.id // 新增
|
id = res.data.id // 新增
|
||||||
//console.log(affirm)
|
console.log(affirm)
|
||||||
//console.log(id)
|
console.log(id)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error('获取声明内容失败')
|
message.error('获取声明内容失败')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user