generated from Leo_Ding/web-template
标签、产品优势
This commit is contained in:
parent
608dee8c32
commit
fbca951282
@ -3,12 +3,23 @@ import request from '@/utils/request'
|
|||||||
//获取标签列表
|
//获取标签列表
|
||||||
export const getTagList = (params) => request.basic.get('/api/v1/home-top-labels', params)
|
export const getTagList = (params) => request.basic.get('/api/v1/home-top-labels', params)
|
||||||
|
|
||||||
//获取算力卡列表
|
// 新增标签
|
||||||
export const getCardsList = (params) => request.basic.get('/api/v1/cards', params)
|
export const createTag = (data) => request.basic.post('/api/v1/home-top-labels', data)
|
||||||
|
|
||||||
//获取算力中心列表
|
// 编辑标签
|
||||||
export const getCentersList = (params) => request.basic.get('/api/v1/centers', params)
|
export const updateTag = (id, data) => request.basic.put(`/api/v1/home-top-labels/${id}`, data)
|
||||||
|
|
||||||
|
// 删除标签
|
||||||
|
export const deleteTag = (id) => request.basic.delete(`/api/v1/home-top-labels/${id}`)
|
||||||
|
|
||||||
|
//获取产品优势列表
|
||||||
|
export const getAdvanceList = (params) => request.basic.get('/api/v1/advance', params)
|
||||||
|
|
||||||
|
// 新增产品优势
|
||||||
|
export const createAdvance = (data) => request.basic.post('/api/v1/advance', data)
|
||||||
|
|
||||||
|
// 编辑产品优势
|
||||||
|
export const updateAdvance = (id, data) => request.basic.put(`/api/v1/advance/${id}`, data)
|
||||||
|
|
||||||
//获取单个banner
|
//获取单个banner
|
||||||
export const getBanner = (id) => request.basic.get(`/api/v1/banners/${id}`)
|
export const getBanner = (id) => request.basic.get(`/api/v1/banners/${id}`)
|
||||||
|
|||||||
@ -1,60 +1,101 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-modal
|
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
|
||||||
:open="modal.open"
|
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
||||||
:title="modal.title"
|
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
:confirm-loading="modal.confirmLoading"
|
<a-card class="mb-8-2">
|
||||||
:after-close="onAfterClose"
|
<a-row :gutter="24">
|
||||||
@ok="handleOk"
|
<a-col :span="24">
|
||||||
@cancel="handleCancel">
|
<a-form-item :label="'标题'" name="name">
|
||||||
<a-form
|
<a-input v-model:value="formData.name"></a-input>
|
||||||
ref="formRef"
|
|
||||||
scroll-to-first-error
|
|
||||||
:model="formData"
|
|
||||||
:rules="formRules"
|
|
||||||
:label-col="{ style: { width: '80px' } }">
|
|
||||||
<a-form-item
|
|
||||||
label="标题"
|
|
||||||
name="title">
|
|
||||||
<a-input v-model:value="formData.title"></a-input>
|
|
||||||
</a-form-item>
|
</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-form>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { cloneDeep } from 'lodash-es'
|
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 apis from '@/apis'
|
||||||
import { useForm, useModal } from '@/hooks'
|
import { useForm, useModal } from '@/hooks'
|
||||||
|
import GxUpload from '@/components/GxUpload/index.vue'
|
||||||
const emit = defineEmits(['ok'])
|
const emit = defineEmits(['ok'])
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
const { formRef, formRules, formRecord, formData, resetForm } = useForm()
|
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 = {
|
formRules.value = {
|
||||||
title: { required: true, message: '请输入标题' },
|
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() {
|
function handleCreate() {
|
||||||
|
console.log('添加handleCreate')
|
||||||
showModal({
|
showModal({
|
||||||
type: 'create',
|
type: 'create',
|
||||||
title: '新建',
|
title: '添加产品优势',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
*/
|
*/
|
||||||
function handleEdit(record = {}) {
|
async function handleEdit(record = {}) {
|
||||||
showModal({
|
showModal({
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
title: '编辑',
|
title: '编辑产品优势',
|
||||||
})
|
})
|
||||||
formRecord.value = record
|
|
||||||
formData.value = cloneDeep(record)
|
const { data, success } = await apis.banner.getBanner(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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,24 +107,22 @@ function handleOk() {
|
|||||||
.then(async (values) => {
|
.then(async (values) => {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const params = {
|
const params = { ...values }
|
||||||
...values,
|
|
||||||
}
|
|
||||||
let result = null
|
let result = null
|
||||||
switch (modal.value.type) {
|
switch (modal.value.type) {
|
||||||
case 'create':
|
case 'create':
|
||||||
result = await apis.common.create(params).catch(() => {
|
result = await apis.platform.createAdvance(params).catch(() => {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'edit':
|
case 'edit':
|
||||||
result = await apis.common.update(formRecord.value.id, params).catch(() => {
|
result = await apis.platform.updateAdvance(formData.value.id, params).catch(() => {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
hideLoading()
|
hideLoading()
|
||||||
if (200 === result?.code) {
|
if (config('http.code.success') === result?.success) {
|
||||||
hideModal()
|
hideModal()
|
||||||
emit('ok')
|
emit('ok')
|
||||||
}
|
}
|
||||||
@ -108,6 +147,7 @@ function handleCancel() {
|
|||||||
*/
|
*/
|
||||||
function onAfterClose() {
|
function onAfterClose() {
|
||||||
resetForm()
|
resetForm()
|
||||||
|
hideLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@ -30,12 +30,12 @@
|
|||||||
<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">
|
||||||
@ -137,8 +137,8 @@ async function getPageList() {
|
|||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const { pageSize, current } = paginationState
|
const { pageSize, current } = paginationState
|
||||||
const { data, total } = await apis.activities
|
const { data, total } = await apis.platform
|
||||||
.getActiveList({
|
.getAdvanceList({
|
||||||
pageSize,
|
pageSize,
|
||||||
current: current,
|
current: current,
|
||||||
...searchFormData.value,
|
...searchFormData.value,
|
||||||
|
|||||||
@ -1,60 +1,101 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-modal
|
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
|
||||||
:open="modal.open"
|
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
||||||
:title="modal.title"
|
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
:confirm-loading="modal.confirmLoading"
|
<a-card class="mb-8-2">
|
||||||
:after-close="onAfterClose"
|
<a-row :gutter="24">
|
||||||
@ok="handleOk"
|
<a-col :span="24">
|
||||||
@cancel="handleCancel">
|
<a-form-item :label="'标题'" name="name">
|
||||||
<a-form
|
<a-input v-model:value="formData.name"></a-input>
|
||||||
ref="formRef"
|
|
||||||
scroll-to-first-error
|
|
||||||
:model="formData"
|
|
||||||
:rules="formRules"
|
|
||||||
:label-col="{ style: { width: '80px' } }">
|
|
||||||
<a-form-item
|
|
||||||
label="标题"
|
|
||||||
name="title">
|
|
||||||
<a-input v-model:value="formData.title"></a-input>
|
|
||||||
</a-form-item>
|
</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-form>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { cloneDeep } from 'lodash-es'
|
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 apis from '@/apis'
|
||||||
import { useForm, useModal } from '@/hooks'
|
import { useForm, useModal } from '@/hooks'
|
||||||
|
import GxUpload from '@/components/GxUpload/index.vue'
|
||||||
const emit = defineEmits(['ok'])
|
const emit = defineEmits(['ok'])
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
const { formRef, formRules, formRecord, formData, resetForm } = useForm()
|
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 = {
|
formRules.value = {
|
||||||
title: { required: true, message: '请输入标题' },
|
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() {
|
function handleCreate() {
|
||||||
|
console.log('添加handleCreate')
|
||||||
showModal({
|
showModal({
|
||||||
type: 'create',
|
type: 'create',
|
||||||
title: '新建',
|
title: '添加标签',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
*/
|
*/
|
||||||
function handleEdit(record = {}) {
|
async function handleEdit(record = {}) {
|
||||||
showModal({
|
showModal({
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
title: '编辑',
|
title: '编辑标签',
|
||||||
})
|
})
|
||||||
formRecord.value = record
|
|
||||||
formData.value = cloneDeep(record)
|
const { data, success } = await apis.platform.updateTag(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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,24 +107,22 @@ function handleOk() {
|
|||||||
.then(async (values) => {
|
.then(async (values) => {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const params = {
|
const params = { ...values }
|
||||||
...values,
|
|
||||||
}
|
|
||||||
let result = null
|
let result = null
|
||||||
switch (modal.value.type) {
|
switch (modal.value.type) {
|
||||||
case 'create':
|
case 'create':
|
||||||
result = await apis.common.create(params).catch(() => {
|
result = await apis.platform.createTag(params).catch(() => {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'edit':
|
case 'edit':
|
||||||
result = await apis.common.update(formRecord.value.id, params).catch(() => {
|
result = await apis.platform.updateTag(formData.value.id, params).catch(() => {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
hideLoading()
|
hideLoading()
|
||||||
if (200 === result?.code) {
|
if (config('http.code.success') === result?.success) {
|
||||||
hideModal()
|
hideModal()
|
||||||
emit('ok')
|
emit('ok')
|
||||||
}
|
}
|
||||||
@ -108,6 +147,7 @@ function handleCancel() {
|
|||||||
*/
|
*/
|
||||||
function onAfterClose() {
|
function onAfterClose() {
|
||||||
resetForm()
|
resetForm()
|
||||||
|
hideLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@ -30,12 +30,12 @@
|
|||||||
<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">
|
||||||
@ -156,7 +156,7 @@ function handleRemove({ id }) {
|
|||||||
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.deleteTag(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