generated from Leo_Ding/web-template
算力中心
This commit is contained in:
parent
6c2042ccee
commit
7cd0f0fb05
@ -6,12 +6,14 @@ export const getCardsList = (params) => request.basic.get('/api/v1/cards', param
|
|||||||
//获取算力中心列表
|
//获取算力中心列表
|
||||||
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}`)
|
||||||
|
|
||||||
//获取单个banner
|
// 更新算力中心
|
||||||
export const getBanner = (id) => request.basic.get(`/api/v1/banners/${id}`)
|
export const updateCenter = (id, data) => request.basic.put(`/api/v1/centers/${id}`, data)
|
||||||
//创建banner
|
|
||||||
export const createBanner = (data) => request.basic.post('/api/v1/banners', data)
|
// 新增算力中心
|
||||||
//更新banner
|
export const addCenter = (data) => request.basic.post('/api/v1/centers', 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}`)
|
export const deleteCenter = (id) => request.basic.delete(`/api/v1/centers/${id}`)
|
||||||
@ -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
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user