generated from Leo_Ding/web-template
banner图管理
This commit is contained in:
parent
47ae92eb62
commit
6902d127cf
2
.env.dev
2
.env.dev
@ -12,7 +12,7 @@ VITE_ROUTER_BASE=/
|
||||
VITE_ROUTER_HISTORY=hash
|
||||
|
||||
# api
|
||||
VITE_API_BASIC=http://10.10.1.36:8040
|
||||
VITE_API_BASIC=http://10.10.1.31:8040
|
||||
VITE_API_HTTP=/api/v1/
|
||||
# storage
|
||||
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
||||
@ -3,7 +3,7 @@ export default () => ({
|
||||
port: 8080,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://10.10.1.36:8040/api',
|
||||
target: 'http://10.10.1.31:8040/api',
|
||||
// target: 'http://127.0.0.1:8045/api',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace('/api', ''),
|
||||
|
||||
13
src/apis/modules/banner.js
Normal file
13
src/apis/modules/banner.js
Normal file
@ -0,0 +1,13 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
//获取banner列表
|
||||
export const getBannerList = (params) => request.basic.get('/api/v1/banners', params)
|
||||
|
||||
//获取单个banner
|
||||
export const getBanner = (id) => request.basic.get(`/api/v1/banners/${id}`)
|
||||
//创建banner
|
||||
export const createBanner = (data) => request.basic.post('/api/v1/banners', data)
|
||||
//更新banner
|
||||
export const updateBanner = (id, data) => request.basic.put(`/api/v1/banners/${id}`, data)
|
||||
//删除banner
|
||||
export const deleteBanner = (id) => request.basic.delete(`/api/v1/banners/${id}`)
|
||||
@ -54,6 +54,18 @@
|
||||
<div class="content unicode" style="display: block;">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">banner</div>
|
||||
<div class="code-name">&#xe653;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">d</div>
|
||||
<div class="code-name">&#xe608;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">礼物 活动</div>
|
||||
@ -126,9 +138,9 @@
|
||||
<pre><code class="language-css"
|
||||
>@font-face {
|
||||
font-family: 'iconfont';
|
||||
src: url('iconfont.woff2?t=1765335998037') format('woff2'),
|
||||
url('iconfont.woff?t=1765335998037') format('woff'),
|
||||
url('iconfont.ttf?t=1765335998037') format('truetype');
|
||||
src: url('iconfont.woff2?t=1765347926881') format('woff2'),
|
||||
url('iconfont.woff?t=1765347926881') format('woff'),
|
||||
url('iconfont.ttf?t=1765347926881') format('truetype');
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
|
||||
@ -154,6 +166,24 @@
|
||||
<div class="content font-class">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont icon-banner"></span>
|
||||
<div class="name">
|
||||
banner
|
||||
</div>
|
||||
<div class="code-name">.icon-banner
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont icon-d"></span>
|
||||
<div class="name">
|
||||
d
|
||||
</div>
|
||||
<div class="code-name">.icon-d
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont icon-liwuhuodong"></span>
|
||||
<div class="name">
|
||||
@ -262,6 +292,22 @@
|
||||
<div class="content symbol">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-banner"></use>
|
||||
</svg>
|
||||
<div class="name">banner</div>
|
||||
<div class="code-name">#icon-banner</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-d"></use>
|
||||
</svg>
|
||||
<div class="name">d</div>
|
||||
<div class="code-name">#icon-d</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-liwuhuodong"></use>
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 5085063 */
|
||||
src: url('iconfont.woff2?t=1765335998037') format('woff2'),
|
||||
url('iconfont.woff?t=1765335998037') format('woff'),
|
||||
url('iconfont.ttf?t=1765335998037') format('truetype');
|
||||
src: url('iconfont.woff2?t=1765347926881') format('woff2'),
|
||||
url('iconfont.woff?t=1765347926881') format('woff'),
|
||||
url('iconfont.ttf?t=1765347926881') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
@ -13,6 +13,14 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-banner:before {
|
||||
content: "\e653";
|
||||
}
|
||||
|
||||
.icon-d:before {
|
||||
content: "\e608";
|
||||
}
|
||||
|
||||
.icon-liwuhuodong:before {
|
||||
content: "\e600";
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -5,6 +5,20 @@
|
||||
"css_prefix_text": "icon-",
|
||||
"description": "",
|
||||
"glyphs": [
|
||||
{
|
||||
"icon_id": "38932738",
|
||||
"name": "banner",
|
||||
"font_class": "banner",
|
||||
"unicode": "e653",
|
||||
"unicode_decimal": 58963
|
||||
},
|
||||
{
|
||||
"icon_id": "1231612",
|
||||
"name": "d",
|
||||
"font_class": "d",
|
||||
"unicode": "e608",
|
||||
"unicode_decimal": 58888
|
||||
},
|
||||
{
|
||||
"icon_id": "201525",
|
||||
"name": "礼物 活动",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -51,4 +51,5 @@ export default {
|
||||
contractMgt: '合同管理(待开发)',
|
||||
activityMgt: '活动管理(待开发)',
|
||||
userUpgrade: '用户升级管理(待开发)',
|
||||
bannerMgt: '轮播图管理',
|
||||
}
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
import { SettingOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: 'bannerMgt',
|
||||
name: 'bannerMgt',
|
||||
component: 'bannerMgt/index.vue',
|
||||
meta: {
|
||||
icon: 'icon-banner',
|
||||
title: '轮播图管理',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'contractMgt',
|
||||
name: 'contractMgt',
|
||||
|
||||
158
src/views/bannerMgt/components/EditDialog.vue
Normal file
158
src/views/bannerMgt/components/EditDialog.vue
Normal file
@ -0,0 +1,158 @@
|
||||
<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="24">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="$t('pages.system.role.form.name')" name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="$t('pages.system.role.form.sequence')" name="sequence">
|
||||
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="$t('pages.system.role.form.status')" name="status">
|
||||
<a-radio-group v-model:value="formData.status" :options="[
|
||||
{ label: $t('pages.system.role.form.status.enabled'), value: 'enabled' },
|
||||
{ label: $t('pages.system.role.form.status.disabled'), value: 'disabled' },
|
||||
]"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'描述'">
|
||||
<a-textarea v-model:value="formData.description"></a-textarea>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'上传图片'" name="permissions">
|
||||
<GxUpload :fileNumber="1" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
import GxUpload from '@/components/GxUpload/index.vue'
|
||||
const emit = defineEmits(['ok'])
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
formData.value.enabled='enabled'
|
||||
formRules.value = {
|
||||
name: { required: true, message: t('pages.system.role.form.name.placeholder') },
|
||||
code: { required: true, message: t('pages.system.role.form.code.placeholder') },
|
||||
status: { required: true, message: t('pages.system.role.form.status.placeholder') },
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.role.add'),
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.role.edit'),
|
||||
})
|
||||
|
||||
const { data, success } = await apis.role.getRole(record.id).catch()
|
||||
if (!success) {
|
||||
message.error(t('component.message.error.save'))
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
let menus = []
|
||||
if (data.menus) {
|
||||
for (let item of data.menus) {
|
||||
menus.push(item.menu_id)
|
||||
}
|
||||
}
|
||||
checkedKeys.value = menus
|
||||
formRecord.value = data
|
||||
formData.value = cloneDeep(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
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.banner.createBanner(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.banner.updateBanner(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
199
src/views/bannerMgt/index.vue
Normal file
199
src/views/bannerMgt/index.vue
Normal file
@ -0,0 +1,199 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<a-col v-bind="colSpan">
|
||||
<a-form-item :label="$t('pages.system.role.form.name')" name="name">
|
||||
<a-input :placeholder="$t('pages.system.role.form.code.placeholder')"
|
||||
v-model:value="searchFormData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col class="align-right" v-bind="colSpan">
|
||||
<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>
|
||||
</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 v-action="'add'" 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" :loading="loading" :pagination="paginationState"
|
||||
:scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'statusType' === column.key">
|
||||
<!--状态-->
|
||||
<a-tag v-if="statusTypeEnum.is('enabled', record.status)" color="processing">
|
||||
{{ statusTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
<!--状态-->
|
||||
<a-tag v-if="statusTypeEnum.is('disabled', record.status)" color="processing">
|
||||
{{ statusTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
</template>
|
||||
|
||||
<template v-if="'action' === column.key">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title> {{ $t('pages.system.role.edit') }}</template>
|
||||
<edit-outlined />
|
||||
</a-tooltip>
|
||||
</x-action-button>
|
||||
<x-action-button @click="handleRemove(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>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusTypeEnum } from '@/enums/system'
|
||||
import { usePagination, useForm } from '@/hooks'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({
|
||||
name: 'systemRole',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: '缩略图', dataIndex: 'code', width: 240 },
|
||||
{ title: '名称', dataIndex: 'name' },
|
||||
{ title: t('pages.system.role.form.status'), dataIndex: 'status', key: 'statusType', width: 80 },
|
||||
{ title: t('pages.system.role.form.sequence'), dataIndex: 'sequence', width: 100 },
|
||||
{ title: t('pages.system.role.form.created_at'), key: 'createAt', fixed: 'right', width: 120 },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 120 },
|
||||
]
|
||||
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, searchFormData, resetPagination } =
|
||||
usePagination()
|
||||
const { resetForm } = useForm()
|
||||
const editDialogRef = ref()
|
||||
|
||||
getPageList()
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.role
|
||||
.getRoleList({
|
||||
pageSize,
|
||||
current: current,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除
|
||||
*/
|
||||
function handleRemove({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.role.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.role.delRole(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 }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetForm()
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Loading…
x
Reference in New Issue
Block a user