This commit is contained in:
Leo_Ding 2026-01-27 18:39:52 +08:00
commit fc57a72f6e
13 changed files with 195 additions and 309 deletions

View File

@ -1,20 +1,26 @@
import request from '@/utils/request' import request from '@/utils/request'
//获取主机列表
export const getHostList = (params) => request.basic.get('/api/v1/power-hosts', params)
//获取算力卡列表 //获取算力卡列表
export const getCardsList = (params) => request.basic.get('/api/v1/cards', params) export const getCardsList = (params) => request.basic.get('/api/v1/cards', params)
// 算力卡删除
export const deleteCard = (id) => request.basic.delete(`/api/v1/cards/${id}`)
// 下架算力卡
export const editCard = (id, params) => request.basic.put(`/api/v1/cards/${id}`, params)
//获取算力中心列表 //获取算力中心列表
export const getCentersList = (params) => request.basic.get('/api/v1/centers', params) export const getCentersList = (params) => request.basic.get('/api/v1/centers', params)
// 编辑算力中心
export const editCeCenter = (id) => request.basic.get(`/api/v1/centers/${id}`)
// 更新算力中心
export const updateCenter = (id, data) => request.basic.put(`/api/v1/centers/${id}`, data)
// 新增算力中心
export const addCenter = (data) => request.basic.post('/api/v1/centers', data)
// 删除算力中心
export const deleteCenter = (id) => request.basic.delete(`/api/v1/centers/${id}`)
//获取单个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}`)

View File

@ -3,7 +3,7 @@
*/ */
import request from '@/utils/request' import request from '@/utils/request'
// 获取主机列表 // 获取主机列表
export const getPageList = (params) => request.basic.get('/api/v1/power-hosts', params) export const getHostList = (params) => request.basic.get('/api/v1/power-hosts', params)
// 删除主机列表 // 删除主机列表
export const delHost = (id) => request.basic.delete(`/api/v1/power-hosts/${id}`) export const delHost = (id) => request.basic.delete(`/api/v1/power-hosts/${id}`)
// 编辑主机列表 // 编辑主机列表

View File

@ -6,6 +6,9 @@ export const getTagList = (params) => request.basic.get('/api/v1/home-top-labels
// 新增标签 // 新增标签
export const createTag = (data) => request.basic.post('/api/v1/home-top-labels', data) export const createTag = (data) => request.basic.post('/api/v1/home-top-labels', data)
//获取单个标签
export const getTag = (id) => request.basic.get(`/api/v1/home-top-labels/${id}`)
// 编辑标签 // 编辑标签
export const updateTag = (id, data) => request.basic.put(`/api/v1/home-top-labels/${id}`, data) export const updateTag = (id, data) => request.basic.put(`/api/v1/home-top-labels/${id}`, data)
@ -15,17 +18,14 @@ export const deleteTag = (id) => request.basic.delete(`/api/v1/home-top-labels/$
//获取产品优势列表 //获取产品优势列表
export const getAdvanceList = (params) => request.basic.get('/api/v1/advance', params) export const getAdvanceList = (params) => request.basic.get('/api/v1/advance', params)
// 新增产品优势 // 获取产品优势详情
export const createAdvance = (data) => request.basic.post('/api/v1/advance', data) export const getAdvance = (id) => request.basic.get(`/api/v1/advance/${id}`)
// 编辑产品优势 // 编辑产品优势
export const updateAdvance = (id, data) => request.basic.put(`/api/v1/advance/${id}`, data) export const updateAdvance = (id, data) => request.basic.put(`/api/v1/advance/${id}`, data)
//获取单个banner // 删除产品优势
export const getBanner = (id) => request.basic.get(`/api/v1/banners/${id}`) export const deleteActive = (id) => request.basic.delete(`/api/v1/advance/${id}`)
//创建banner
export const createBanner = (data) => request.basic.post('/api/v1/banners', data) // 新增产品优势
//更新banner export const createAdvance = (data) => request.basic.post('/api/v1/advance', data)
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}`)

View File

@ -73,13 +73,13 @@
</a-tag> </a-tag>
</template> </template>
<template v-if="'is_recommend' === column.key"> <template v-if="'status' === column.key">
<!--状态--> <!--状态-->
<a-tag v-if="record.banner_type == true" color="processing"> <a-tag v-if="record.status == 'ENABLED'" color="processing">
启用 启用
</a-tag> </a-tag>
<!--状态--> <!--状态-->
<a-tag v-else color="processing"> <a-tag v-else color="red">
禁用 禁用
</a-tag> </a-tag>
</template> </template>
@ -92,10 +92,18 @@
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<!-- <x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <!-- <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.role.edit') }}</template> <template #title> 下架算力卡</template>
<edit-outlined /> <edit-outlined />
</a-tooltip> </a-tooltip>
</x-action-button> --> </x-action-button> -->
<x-action-button @click="handelEdit(record)" :disabled="record.status === 'DISABLED'">
<a-tooltip>
<template #title>
{{ record.status === 'DISABLED' ? '已下架' : '下架算力卡' }}
</template>
<edit-outlined />
</a-tooltip>
</x-action-button>
<x-action-button @click="handleRemove(record)"> <x-action-button @click="handleRemove(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.delete') }}</template> <template #title> {{ $t('pages.system.delete') }}</template>
@ -150,7 +158,7 @@ const columns = [
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
width: 150, width: 150,
customRender: ({ text }) => disabledDict.getLabel(text) || text, // customRender: ({ text }) => disabledDict.getLabel(text) || text,
}, },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 120 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 120 },
]; ];
@ -194,14 +202,14 @@ async function getPageList() {
*/ */
function handleRemove({ id }) { function handleRemove({ id }) {
Modal.confirm({ Modal.confirm({
title: t('pages.system.role.delTip'), title: '提示',
content: t('button.confirm'), content: '是否删除该算力卡?',
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
; (async () => { ; (async () => {
try { try {
const { success } = await apis.role.delRole(id).catch(() => { const { success } = await apis.computing.deleteCard(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
@ -218,6 +226,37 @@ function handleRemove({ id }) {
}) })
} }
//
function handelEdit({ id, status }) {
if (status === 'DISABLED') {
message.warning('该算力卡已下架,无法重复操作');
return;
}
Modal.confirm({
title: '提示',
content: '是否下架该算力卡?',
okText: t('button.confirm'),
onOk: () => {
return new Promise((resolve, reject) => {
; (async () => {
try {
const { success } = await apis.computing.editCard(id).catch(() => {
throw new Error()
})
if (config('http.code.success') === success) {
resolve()
message.success('下架成功')
await getPageList()
}
} catch (error) {
reject()
}
})()
})
},
})
}
/** /**
* 分页 * 分页
*/ */

View File

@ -5,34 +5,35 @@
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.name')" name="name"> <a-form-item :label="'算力中心名称'" name="name">
<a-input v-model:value="formData.name"></a-input> <a-input v-model:value="formData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.sequence')" name="sequence"> <a-form-item :label="'区域编码'" name="code">
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input> <a-input v-model:value="formData.code"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'排序'" name="sort">
<a-input :defaultValue="0" type="number" v-model:value="formData.sort"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.status')" name="status"> <a-form-item :label="$t('pages.system.role.form.status')" name="status">
<a-radio-group v-model:value="formData.status" :options="[ <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.enabled'), value: 'ENABLED' },
{ label: $t('pages.system.role.form.status.disabled'), value: 'disabled' }, { label: $t('pages.system.role.form.status.disabled'), value: 'DISABLED' },
]"></a-radio-group> ]"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="'描述'"> <a-form-item :label="'描述'" name="description">
<a-textarea v-model:value="formData.description"></a-textarea> <a-textarea v-model:value="formData.description"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24">
<a-form-item :label="'上传图片'" name="permissions">
<GxUpload :fileNumber="1" />
</a-form-item>
</a-col>
</a-row> </a-row>
</a-card> </a-card>
</a-form> </a-form>
@ -80,19 +81,12 @@ async function handleEdit(record = {}) {
title: t('pages.system.role.edit'), title: t('pages.system.role.edit'),
}) })
const { data, success } = await apis.role.getRole(record.id).catch() const { data, success } = await apis.computing.editCeCenter(record.id).catch()
if (!success) { if (!success) {
message.error(t('component.message.error.save')) message.error(t('component.message.error.save'))
hideModal() hideModal()
return return
} }
let menus = []
if (data.menus) {
for (let item of data.menus) {
menus.push(item.menu_id)
}
}
checkedKeys.value = menus
formRecord.value = data formRecord.value = data
formData.value = cloneDeep(data) formData.value = cloneDeep(data)
} }
@ -106,16 +100,18 @@ function handleOk() {
.then(async (values) => { .then(async (values) => {
try { try {
showLoading() showLoading()
console.log("===",values)
values.sort = parseInt(values.sort)
const params = {...values} const params = {...values}
let result = null let result = null
switch (modal.value.type) { switch (modal.value.type) {
case 'create': case 'create':
result = await apis.banner.createBanner(params).catch(() => { result = await apis.computing.addCenter(params).catch(() => {
throw new Error() throw new Error()
}) })
break break
case 'edit': case 'edit':
result = await apis.banner.updateBanner(formData.value.id, params).catch(() => { result = await apis.computing.updateCenter(formData.value.id, params).catch(() => {
throw new Error() throw new Error()
}) })
break break

View File

@ -35,31 +35,20 @@
<a-row :gutter="8" :wrap="false"> <a-row :gutter="8" :wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<!-- <x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()"> <a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
添加图片 增加算力中心
</a-button> </a-button>
</x-action-bar> --> </x-action-bar>
<a-table :columns="columns" :data-source="listData" :loading="loading" :pagination="paginationState" <a-table :columns="columns" :data-source="listData" :loading="loading" :pagination="paginationState"
:scroll="{ x: 1000 }" @change="onTableChange"> :scroll="{ x: 1000 }" @change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'banner_type' === column.key"> <template v-if="'status' === column.key">
<!--状态--> <!--状态-->
<a-tag v-if="record.banner_type == 1" color="processing"> <a-tag v-if="record.status == 'ENABLED'" color="processing">
首页轮播图
</a-tag>
<!--状态-->
<a-tag v-else color="processing">
营销活动图
</a-tag>
</template>
<template v-if="'is_recommend' === column.key">
<!--状态-->
<a-tag v-if="record.banner_type == true" color="processing">
启用 启用
</a-tag> </a-tag>
<!--状态--> <!--状态-->
@ -74,12 +63,12 @@
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<!-- <x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.role.edit') }}</template> <template #title> {{ $t('pages.system.role.edit') }}</template>
<edit-outlined /> <edit-outlined />
</a-tooltip> </a-tooltip>
</x-action-button> --> </x-action-button>
<x-action-button @click="handleRemove(record)"> <x-action-button @click="handleRemove(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.delete') }}</template> <template #title> {{ $t('pages.system.delete') }}</template>
@ -104,7 +93,7 @@ import { formatUtcDateTime } from '@/utils/util'
import { config } from '@/config' import { config } from '@/config'
import { usePagination, useForm } from '@/hooks' import { usePagination, useForm } from '@/hooks'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
import { DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { disabledDict } from '@/enums/dict' import { disabledDict } from '@/enums/dict'
@ -115,7 +104,8 @@ const { t } = useI18n() // 解构出t方法
const columns = [ const columns = [
{ title: '算力中心名称', dataIndex: 'name', width: 200 }, { title: '算力中心名称', dataIndex: 'name', width: 200 },
{ title: '区域编码', dataIndex: 'code', width: 150 }, { title: '区域编码', dataIndex: 'code', width: 150 },
{ title: '描述', dataIndex: 'descript', width: 150 }, { title: '描述', dataIndex: 'description', width: 150 },
{ title: '排序', dataIndex: 'sort', width: 150 },
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
@ -165,14 +155,14 @@ async function getPageList() {
*/ */
function handleRemove({ id }) { function handleRemove({ id }) {
Modal.confirm({ Modal.confirm({
title: t('pages.system.role.delTip'), title: '提示',
content: t('button.confirm'), content: '是否删除该算力中心?',
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
; (async () => { ; (async () => {
try { try {
const { success } = await apis.role.delRole(id).catch(() => { const { success } = await apis.computing.deleteCenter(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -1,158 +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="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.host.getHostDetail(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.host.updateHost(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>

View File

@ -75,16 +75,20 @@
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<!-- <x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="handelEdit(record)" :disabled="record.status === 'DISABLED'">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.role.edit') }}</template> <template #title>
<edit-outlined /> {{ record.status === 'DISABLED' ? '已下架' : '下架主机' }}
</a-tooltip> </template>
</x-action-button> --> <edit-outlined />
</a-tooltip>
</x-action-button>
<x-action-button @click="handleRemove(record)"> <x-action-button @click="handleRemove(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.delete') }}</template> <template #title>
<delete-outlined style="color: #ff4d4f" /> {{ $t('pages.system.delete') }}
</template>
<delete-outlined style="color: red;" />
</a-tooltip> </a-tooltip>
</x-action-button> </x-action-button>
</template> </template>
@ -94,7 +98,6 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -105,7 +108,6 @@ import { formatUtcDateTime } from '@/utils/util'
import { config } from '@/config' import { config } from '@/config'
import { statusTypeEnum } from '@/enums/system' import { statusTypeEnum } from '@/enums/system'
import { usePagination, useForm } from '@/hooks' import { usePagination, useForm } from '@/hooks'
import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { disabledDict } from '@/enums/dict' import { disabledDict } from '@/enums/dict'
@ -172,7 +174,6 @@ const columns = [
const { listData, loading, showLoading, hideLoading, paginationState, searchFormData, resetPagination } = const { listData, loading, showLoading, hideLoading, paginationState, searchFormData, resetPagination } =
usePagination() usePagination()
const { resetForm } = useForm() const { resetForm } = useForm()
const editDialogRef = ref()
getPageList() getPageList()
@ -184,7 +185,7 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { data, total } = await apis.computing const { data, total } = await apis.host
.getHostList({ .getHostList({
pageSize, pageSize,
current: current, current: current,
@ -208,8 +209,8 @@ async function getPageList() {
*/ */
function handleRemove({ id }) { function handleRemove({ id }) {
Modal.confirm({ Modal.confirm({
title: t('pages.system.role.delTip'), title: '提示',
content: t('button.confirm'), content: '是否删除该主机?',
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -232,6 +233,37 @@ function handleRemove({ id }) {
}) })
} }
//
function handelEdit({ id, status }) {
if (status === 'DISABLED') {
message.warning('该主机已下架,无法重复操作');
return;
}
Modal.confirm({
title: '提示',
content: '是否下架该主机?',
okText: t('button.confirm'),
onOk: () => {
return new Promise((resolve, reject) => {
; (async () => {
try {
const { success } = await apis.host.updateHost(id).catch(() => {
throw new Error()
})
if (config('http.code.success') === success) {
resolve()
message.success('下架成功')
await getPageList()
}
} catch (error) {
reject()
}
})()
})
},
})
}
/** /**
* 分页 * 分页
*/ */

View File

@ -99,7 +99,6 @@ async function handleEdit(record = {}) {
formRecord.value = data formRecord.value = data
formData.value = cloneDeep(data) formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */

View File

@ -5,31 +5,31 @@
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="'标题'" name="name"> <a-form-item :label="'标题'" name="title">
<a-input v-model:value="formData.name"></a-input> <a-input v-model:value="formData.title"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.sequence')" name="sequence"> <a-form-item :label="$t('pages.system.role.form.sequence')" name="order">
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input> <a-input :defaultValue="0" type="number" v-model:value="formData.order"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.status')" name="status"> <a-form-item :label="'推荐首页'" name="is_recommend">
<a-radio-group v-model:value="formData.status" :options="[ <a-radio-group v-model:value="formData.is_recommend" :options="[
{ label: $t('pages.system.role.form.status.enabled'), value: 'enabled' }, { label:'是', value: true },
{ label: $t('pages.system.role.form.status.disabled'), value: 'disabled' }, { label: '否', value: false },
]"></a-radio-group> ]"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="'描述'"> <a-form-item :label="'描述'" name="description">
<a-textarea v-model:value="formData.description"></a-textarea> <a-textarea v-model:value="formData.description"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="'上传图片'" name="permissions"> <a-form-item :label="'上传图片'" name="imgUrl">
<GxUpload :fileNumber="1" /> <GxUpload :fileNumber="1" />
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -49,6 +49,7 @@ import { useForm, useModal } from '@/hooks'
import GxUpload from '@/components/GxUpload/index.vue' import GxUpload from '@/components/GxUpload/index.vue'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { FacialCleanser } from '@icon-park/vue-next'
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formRecord, formData, formRef, formRules, resetForm } = useForm() const { formRecord, formData, formRef, formRules, resetForm } = useForm()
const { t } = useI18n() // t const { t } = useI18n() // t
@ -81,19 +82,13 @@ async function handleEdit(record = {}) {
title: '编辑产品优势', title: '编辑产品优势',
}) })
const { data, success } = await apis.banner.getBanner(record.id).catch() const { data, success } = await apis.platform.getAdvance(record.id).catch()
if (!success) { if (!success) {
message.error(t('component.message.error.save')) message.error(t('component.message.error.save'))
hideModal() hideModal()
return return
} }
let menus = []
if (data.menus) {
for (let item of data.menus) {
menus.push(item.menu_id)
}
}
checkedKeys.value = menus
formRecord.value = data formRecord.value = data
formData.value = cloneDeep(data) formData.value = cloneDeep(data)
} }

View File

@ -40,25 +40,14 @@
<a-table :columns="columns" :data-source="listData" :loading="loading" :pagination="paginationState" <a-table :columns="columns" :data-source="listData" :loading="loading" :pagination="paginationState"
:scroll="{ x: 1000 }" @change="onTableChange"> :scroll="{ x: 1000 }" @change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'banner_type' === column.key">
<!--状态-->
<a-tag v-if="record.banner_type == 1" color="processing">
首页轮播图
</a-tag>
<!--状态-->
<a-tag v-else color="processing">
营销活动图
</a-tag>
</template>
<template v-if="'is_recommend' === column.key"> <template v-if="'is_recommend' === column.key">
<!--状态--> <!--状态-->
<a-tag v-if="record.banner_type == true" color="processing"> <a-tag v-if="record.is_recommend == true" color="processing">
启用
</a-tag> </a-tag>
<!--状态--> <!--状态-->
<a-tag v-else color="processing"> <a-tag v-else color="processing">
禁用
</a-tag> </a-tag>
</template> </template>
@ -111,11 +100,11 @@ const columns = [
{ title: '标题', dataIndex: 'title', width: 200 }, { title: '标题', dataIndex: 'title', width: 200 },
{ title: '描述', dataIndex: 'description', width: 150 }, { title: '描述', dataIndex: 'description', width: 150 },
{ {
title: '是否启用', title: '是否推荐',
dataIndex: 'is_recommend', dataIndex: 'is_recommend',
key: 'is_recommend', key: 'is_recommend',
width: 150, width: 150,
customRender: ({ text }) => (text ? '启用' : '禁用'), customRender: ({ text }) => (text ? '是' : '否'),
}, },
{ title: '图片地址', key: 'imgUrl', dataIndex: 'imgUrl', width: 160 }, { title: '图片地址', key: 'imgUrl', dataIndex: 'imgUrl', width: 160 },
{ title: '页面地址', key: 'pageUrl', dataIndex: 'pageUrl', width: 160 }, { title: '页面地址', key: 'pageUrl', dataIndex: 'pageUrl', width: 160 },
@ -161,14 +150,14 @@ async function getPageList() {
*/ */
function handleRemove({ id }) { function handleRemove({ id }) {
Modal.confirm({ Modal.confirm({
title: t('pages.system.role.delTip'), title: '是否删除该产品优势?',
content: t('button.confirm'), content: t('button.confirm'),
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
; (async () => { ; (async () => {
try { try {
const { success } = await apis.role.delRole(id).catch(() => { const { success } = await apis.platform.deleteActive(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -5,21 +5,21 @@
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="'标题'" name="name"> <a-form-item :label="'标题'" name="title">
<a-input v-model:value="formData.name"></a-input> <a-input v-model:value="formData.title"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.sequence')" name="sequence"> <a-form-item :label="$t('pages.system.role.form.sequence')" name="order">
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input> <a-input :defaultValue="0" type="number" v-model:value="formData.order"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="$t('pages.system.role.form.status')" name="status"> <a-form-item :label="$t('pages.system.role.form.status')" name="is_recommend">
<a-radio-group v-model:value="formData.status" :options="[ <a-radio-group v-model:value="formData.is_recommend" :options="[
{ label: $t('pages.system.role.form.status.enabled'), value: 'enabled' }, { label: '推荐', value: true },
{ label: $t('pages.system.role.form.status.disabled'), value: 'disabled' }, { label: '不推荐', value: false },
]"></a-radio-group> ]"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -29,7 +29,12 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label="'上传图片'" name="permissions"> <a-form-item :label="'页面路径'" name="pageUrl">
<a-input v-model:value="formData.pageUrl"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'上传图片'" name="imgUrl">
<GxUpload :fileNumber="1" /> <GxUpload :fileNumber="1" />
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -81,19 +86,12 @@ async function handleEdit(record = {}) {
title: '编辑标签', title: '编辑标签',
}) })
const { data, success } = await apis.platform.updateTag(record.id).catch() const { data, success } = await apis.platform.getTag(record.id).catch()
if (!success) { if (!success) {
message.error(t('component.message.error.save')) message.error(t('component.message.error.save'))
hideModal() hideModal()
return return
} }
let menus = []
if (data.menus) {
for (let item of data.menus) {
menus.push(item.menu_id)
}
}
checkedKeys.value = menus
formRecord.value = data formRecord.value = data
formData.value = cloneDeep(data) formData.value = cloneDeep(data)
} }

View File

@ -99,14 +99,14 @@ const columns = [
{ title: '标题', dataIndex: 'title', width: 200 }, { title: '标题', dataIndex: 'title', width: 200 },
{ title: '描述', dataIndex: 'description', width: 150 }, { title: '描述', dataIndex: 'description', width: 150 },
{ {
title: '是否推荐', title: '是否推荐首页',
key: 'is_recommend', key: 'is_recommend',
dataIndex: 'is_recommend', dataIndex: 'is_recommend',
width: 120, width: 120,
customRender: ({ text }) => (text ? '推荐' : '不推荐'), customRender: ({ text }) => (text ? '推荐' : '不推荐'),
}, },
{ title: '图片地址', key: 'image_url', dataIndex: 'image_url', width: 160 }, { title: '图片地址', key: 'imgUrl', dataIndex: 'imgUrl', width: 160 },
{ title: '页面地址', key: 'link_url', dataIndex: 'link_url', width: 160 }, { title: '页面地址', key: 'pageUrl', dataIndex: 'pageUrl', width: 160 },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 120 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 120 },
] ]
@ -149,7 +149,7 @@ async function getPageList() {
*/ */
function handleRemove({ id }) { function handleRemove({ id }) {
Modal.confirm({ Modal.confirm({
title: t('pages.system.role.delTip'), title: '确认删除该标签?',
content: t('button.confirm'), content: t('button.confirm'),
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {