页面布局
This commit is contained in:
parent
853e171f54
commit
daa190b7e3
67
src/api/content/layout.ts
Normal file
67
src/api/content/layout.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
/**
|
||||
* @description: 列表
|
||||
*/
|
||||
export function getLayoutList(params?) {
|
||||
return http.request({
|
||||
url: '/layout/page',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
export function getLayoutAllList(params?) {
|
||||
return http.request({
|
||||
url: '/layout/list',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 根据ID获取详情
|
||||
*/
|
||||
export function getLayoutDetail(layoutId) {
|
||||
return http.request({
|
||||
url: '/layout/detail/'+layoutId,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 添加
|
||||
*/
|
||||
export function layoutAdd(data:any) {
|
||||
return http.request({
|
||||
url: '/layout/add',
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 更新
|
||||
*/
|
||||
export function layoutUpdate(data:any) {
|
||||
return http.request({
|
||||
url: '/layout/update',
|
||||
method: 'PUT',
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 删除
|
||||
*/
|
||||
export function layoutDelete(layoutId) {
|
||||
return http.request({
|
||||
url: '/layout/delete/'+layoutId,
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 批量删除
|
||||
*/
|
||||
export function layoutBatchDelete(data:any) {
|
||||
return http.request({
|
||||
url: '/layout/batchDelete',
|
||||
method: 'DELETE',
|
||||
data
|
||||
});
|
||||
}
|
60
src/api/content/layoutItem.ts
Normal file
60
src/api/content/layoutItem.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
/**
|
||||
* @description: 列表
|
||||
*/
|
||||
export function getLayoutList(params?) {
|
||||
return http.request({
|
||||
url: '/layout/item/page',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 根据ID获取详情
|
||||
*/
|
||||
export function getLayoutDetail(layoutId) {
|
||||
return http.request({
|
||||
url: '/layout/item/detail/'+layoutId,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 添加
|
||||
*/
|
||||
export function layoutAdd(data:any) {
|
||||
return http.request({
|
||||
url: '/layout/item/add',
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 更新
|
||||
*/
|
||||
export function layoutUpdate(data:any) {
|
||||
return http.request({
|
||||
url: '/layout/item/update',
|
||||
method: 'PUT',
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 删除
|
||||
*/
|
||||
export function layoutDelete(layoutId) {
|
||||
return http.request({
|
||||
url: '/layout/item/delete/'+layoutId,
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 批量删除
|
||||
*/
|
||||
export function layoutBatchDelete(data:any) {
|
||||
return http.request({
|
||||
url: '/layout/item/batchDelete',
|
||||
method: 'DELETE',
|
||||
data
|
||||
});
|
||||
}
|
28
src/views/content/layout/columns.ts
Normal file
28
src/views/content/layout/columns.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { h } from 'vue';
|
||||
import { ElTag } from 'element-plus';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
type: 'selection',
|
||||
},
|
||||
{
|
||||
label: '位置编号',
|
||||
prop: 'location',
|
||||
},
|
||||
{
|
||||
label: '位置描述',
|
||||
prop: 'description',
|
||||
},
|
||||
{
|
||||
label: '排序',
|
||||
prop: 'sort',
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
prop: 'createUser',
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'createTime',
|
||||
},
|
||||
];
|
105
src/views/content/layout/edit.vue
Normal file
105
src/views/content/layout/edit.vue
Normal file
@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="props.visible"
|
||||
:title="props.layoutId?'编辑':'新增'"
|
||||
width="500"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="dialogClose"
|
||||
>
|
||||
<el-form
|
||||
class="ls-form"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="位置编号" prop="location" :rules="{ required: true, message: '请输入位置编号', trigger: 'blur' }">
|
||||
<number-input v-model="formData.location" type="textarea" placeholder="请输入位置编号"/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="位置描述"
|
||||
prop="description"
|
||||
:rules="{ required: true, message: '请输入页面位置描述', trigger: 'blur' }"
|
||||
>
|
||||
<el-input
|
||||
class="ls-input"
|
||||
v-model="formData.description"
|
||||
placeholder="请输入页面位置描述"
|
||||
clearable
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogClose">取消</el-button>
|
||||
<el-button :loading="subLoading" type="primary" @click="submit">
|
||||
确定
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type {FormInstance} from "element-plus";
|
||||
import {getLayoutDetail,layoutAdd,layoutUpdate} from "@/api/content/layout";
|
||||
import {onMounted, reactive, shallowRef} from "vue";
|
||||
import {message} from "@/utils/auth";
|
||||
import {useLockFn} from "@/utils/useLockFn";
|
||||
|
||||
const emit = defineEmits(["success", "update:visible"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
description: "",
|
||||
location: "",
|
||||
sort: 0
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
},
|
||||
layoutId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
props.layoutId ? await layoutUpdate(formData) : await layoutAdd(formData);
|
||||
message("操作成功");
|
||||
emit("update:visible", false);
|
||||
emit("success");
|
||||
};
|
||||
|
||||
const dialogClose = () => {
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
const { isLock:subLoading,lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
|
||||
const setFormData = async () => {
|
||||
const data = await getLayoutDetail(props.layoutId);
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (props.layoutId) {
|
||||
setFormData();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
156
src/views/content/layout/index.vue
Normal file
156
src/views/content/layout/index.vue
Normal file
@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<PageWrapper>
|
||||
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||
</el-card>
|
||||
<el-card :bordered="false" class="proCard">
|
||||
<BasicTable
|
||||
:columns="columns"
|
||||
:request="loadDataTable"
|
||||
:row-key="(row) => row.id"
|
||||
ref="tableRef"
|
||||
:actionColumn="actionColumn"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<template #tableTitle>
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<PlusOutlined />
|
||||
</el-icon>
|
||||
</template>
|
||||
添加页面布局
|
||||
</el-button>
|
||||
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</template>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</el-card>
|
||||
|
||||
<editDialog
|
||||
v-if="editVisible"
|
||||
:layoutId="layoutId"
|
||||
v-model:visible="editVisible"
|
||||
@success="reloadTable"
|
||||
>
|
||||
</editDialog>
|
||||
</PageWrapper>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||
import { ColProps } from 'element-plus';
|
||||
import { schemas } from './querySchemas';
|
||||
import { useForm } from '@/components/Form/index';
|
||||
import { TableAction } from '@/components/Table';
|
||||
import { getLayoutList,layoutDelete,layoutBatchDelete } from '@/api/content/layout';
|
||||
import { columns } from './columns';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import {message,confirm} from "@/utils/auth";
|
||||
const editDialog = defineAsyncComponent(() =>
|
||||
import('./edit.vue')
|
||||
)
|
||||
const layoutId =ref(0)
|
||||
const editVisible=ref(false)
|
||||
const selectionData = ref([])
|
||||
const tableRef = ref();
|
||||
const formParams = reactive({
|
||||
description:''
|
||||
});
|
||||
const actionColumn = reactive({
|
||||
width: 250,
|
||||
label: '操作',
|
||||
prop: 'action',
|
||||
fixed: 'right',
|
||||
render(record) {
|
||||
return h(TableAction, {
|
||||
style: 'button',
|
||||
actions: [
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'warning',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
ifShow: () => {
|
||||
return true;
|
||||
},
|
||||
// auth: ['sys:user:list'],
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
onClick: handleDelete.bind(null, record),
|
||||
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
||||
ifShow: () => {
|
||||
return true;
|
||||
},
|
||||
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||
// auth: ['basic_list'],
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const loadDataTable = async (res: any) => {
|
||||
const result = await getLayoutList({ ...formParams, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
function reloadTable() {
|
||||
tableRef.value.reload({pageNo:1});
|
||||
}
|
||||
const [register, {}] = useForm({
|
||||
labelWidth: 80,
|
||||
layout: 'horizontal',
|
||||
colProps: { span: 6 } as ColProps,
|
||||
submitOnReset:true,
|
||||
schemas
|
||||
});
|
||||
function handleSubmit(values: Recordable) {
|
||||
for (const key in formParams) {
|
||||
if (values[key] != null && values[key] != undefined) {
|
||||
formParams[key] = values[key];
|
||||
}
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
for (const key in formParams) {
|
||||
formParams[key] ='';
|
||||
}
|
||||
}
|
||||
const handleAdd = async () => {
|
||||
layoutId.value=0
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
const handleEdit = async (record: Recordable) => {
|
||||
layoutId.value=record.row.id
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
let ids = []
|
||||
if(!record){
|
||||
ids = selectionData.value.map(({id}) => id);
|
||||
}
|
||||
await confirm('确定要删除?');
|
||||
record? await layoutDelete(record.row.id):await layoutBatchDelete(ids);
|
||||
message("删除成功");
|
||||
reloadTable()
|
||||
}
|
||||
function onSelectionChange(value){
|
||||
selectionData.value = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
11
src/views/content/layout/querySchemas.ts
Normal file
11
src/views/content/layout/querySchemas.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { FormSchema } from '@/components/Form/index';
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
field: 'description',
|
||||
component: 'Input',
|
||||
label: '页面描述',
|
||||
componentProps: {
|
||||
placeholder: '请输入页面位置描述',
|
||||
},
|
||||
}
|
||||
];
|
28
src/views/content/layoutItem/columns.ts
Normal file
28
src/views/content/layoutItem/columns.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { h } from 'vue';
|
||||
import { ElTag } from 'element-plus';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
type: 'selection',
|
||||
},
|
||||
{
|
||||
label: '位置编号',
|
||||
prop: 'location',
|
||||
},
|
||||
{
|
||||
label: '位置描述',
|
||||
prop: 'description',
|
||||
},
|
||||
{
|
||||
label: '排序',
|
||||
prop: 'sort',
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
prop: 'createUser',
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'createTime',
|
||||
},
|
||||
];
|
145
src/views/content/layoutItem/edit.vue
Normal file
145
src/views/content/layoutItem/edit.vue
Normal file
@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="props.visible"
|
||||
:title="props.layoutId?'编辑':'新增'"
|
||||
width="500"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="dialogClose"
|
||||
>
|
||||
<el-form
|
||||
class="ls-form"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="页面布局" prop="layoutId" class="flex-1" :rules="{ required: true, message: '请选择页面布局', trigger: 'change' }">
|
||||
<el-select v-model="formData.layoutId" class="flex-1" clearable placeholder="请选择页面布局">
|
||||
<el-option v-for="(item, index) in layoutList" :key="index" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="位置编号" prop="location" :rules="{ required: true, message: '请输入位置编号', trigger: 'blur' }">
|
||||
<number-input v-model="formData.location" type="textarea" placeholder="请输入位置编号"/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="位置描述"
|
||||
prop="description"
|
||||
:rules="{ required: true, message: '请输入页面位置描述', trigger: 'blur' }"
|
||||
>
|
||||
<el-input
|
||||
class="ls-input"
|
||||
v-model="formData.description"
|
||||
placeholder="请输入页面位置描述"
|
||||
clearable
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="页面类型" prop="type"
|
||||
:rules="{ required: true, message: '请选择页面类型', trigger: 'change' }">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
placeholder="请选择页面类型"
|
||||
>
|
||||
<el-option label="CMS文章" :value="1"></el-option>
|
||||
<el-option label="通知公告" :value="2"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="页面编号" prop="typeId" :rules="{ required: true, message: '请输入页面编号', trigger: 'blur' }">
|
||||
<number-input v-model="formData.typeId" placeholder="请输入页面编号"/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="图片路径"
|
||||
prop="image"
|
||||
>
|
||||
<UploadImg @changeFileName="(name)=>formData.imgName=name"
|
||||
:fileType=" ['image/jpeg', 'image/png', 'image/jpg', 'image/gif']"
|
||||
name="article"
|
||||
:fileSize="200"
|
||||
v-model:image-url="formData.image">
|
||||
<template v-slot:tip>支持扩展名: jpg png jpeg;文件大小不超过200M</template>
|
||||
</UploadImg>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogClose">取消</el-button>
|
||||
<el-button :loading="subLoading" type="primary" @click="submit">
|
||||
确定
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type {FormInstance} from "element-plus";
|
||||
import {getLayoutDetail,layoutAdd,layoutUpdate} from "@/api/content/layoutItem";
|
||||
import { getLayoutAllList } from '@/api/content/layout';
|
||||
import {onMounted, reactive, shallowRef,ref} from "vue";
|
||||
import {message} from "@/utils/auth";
|
||||
import UploadImg from "@/components/Upload/Image.vue";
|
||||
import {useLockFn} from "@/utils/useLockFn";
|
||||
|
||||
const emit = defineEmits(["success", "update:visible"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
layoutId:'',
|
||||
description: "",
|
||||
type:'',
|
||||
typeId:'',
|
||||
location: "",
|
||||
image:'',
|
||||
sort: 0
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
},
|
||||
layoutId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
const layoutList = ref([])
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
props.layoutId ? await layoutUpdate(formData) : await layoutAdd(formData);
|
||||
message("操作成功");
|
||||
emit("update:visible", false);
|
||||
emit("success");
|
||||
};
|
||||
|
||||
const dialogClose = () => {
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
const { isLock:subLoading,lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
|
||||
const setFormData = async () => {
|
||||
const data = await getLayoutDetail(props.layoutId);
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
const getAllDict = async () => {
|
||||
let list = await getLayoutAllList();
|
||||
layoutList.value = list ? list : [];
|
||||
};
|
||||
onMounted(() => {
|
||||
getAllDict()
|
||||
if (props.layoutId) {
|
||||
setFormData();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
158
src/views/content/layoutItem/index.vue
Normal file
158
src/views/content/layoutItem/index.vue
Normal file
@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<PageWrapper>
|
||||
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||
</el-card>
|
||||
<el-card :bordered="false" class="proCard">
|
||||
<BasicTable
|
||||
:columns="columns"
|
||||
:request="loadDataTable"
|
||||
:row-key="(row) => row.id"
|
||||
ref="tableRef"
|
||||
:actionColumn="actionColumn"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<template #tableTitle>
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<PlusOutlined />
|
||||
</el-icon>
|
||||
</template>
|
||||
添加页面推荐
|
||||
</el-button>
|
||||
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</template>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</el-card>
|
||||
|
||||
<editDialog
|
||||
v-if="editVisible"
|
||||
:layoutId="layoutId"
|
||||
v-model:visible="editVisible"
|
||||
@success="reloadTable"
|
||||
>
|
||||
</editDialog>
|
||||
</PageWrapper>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||
import { ColProps } from 'element-plus';
|
||||
import { schemas } from './querySchemas';
|
||||
import { useForm } from '@/components/Form/index';
|
||||
import { TableAction } from '@/components/Table';
|
||||
import { getLayoutList,layoutDelete,layoutBatchDelete } from '@/api/content/layoutItem';
|
||||
import { getLayoutAllList } from '@/api/content/layout';
|
||||
import { columns } from './columns';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import {message,confirm} from "@/utils/auth";
|
||||
const editDialog = defineAsyncComponent(() =>
|
||||
import('./edit.vue')
|
||||
)
|
||||
const layoutId =ref(0)
|
||||
const editVisible=ref(false)
|
||||
const selectionData = ref([])
|
||||
const tableRef = ref();
|
||||
const formParams = reactive({
|
||||
layoutId:'',
|
||||
type:''
|
||||
});
|
||||
const actionColumn = reactive({
|
||||
width: 250,
|
||||
label: '操作',
|
||||
prop: 'action',
|
||||
fixed: 'right',
|
||||
render(record) {
|
||||
return h(TableAction, {
|
||||
style: 'button',
|
||||
actions: [
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'warning',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
ifShow: () => {
|
||||
return true;
|
||||
},
|
||||
// auth: ['sys:user:list'],
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
onClick: handleDelete.bind(null, record),
|
||||
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
||||
ifShow: () => {
|
||||
return true;
|
||||
},
|
||||
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||
// auth: ['basic_list'],
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const loadDataTable = async (res: any) => {
|
||||
const result = await getLayoutList({ ...formParams, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
function reloadTable() {
|
||||
tableRef.value.reload({pageNo:1});
|
||||
}
|
||||
const [register, {}] = useForm({
|
||||
labelWidth: 80,
|
||||
layout: 'horizontal',
|
||||
colProps: { span: 6 } as ColProps,
|
||||
submitOnReset:true,
|
||||
schemas
|
||||
});
|
||||
function handleSubmit(values: Recordable) {
|
||||
for (const key in formParams) {
|
||||
if (values[key] != null && values[key] != undefined) {
|
||||
formParams[key] = values[key];
|
||||
}
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
for (const key in formParams) {
|
||||
formParams[key] ='';
|
||||
}
|
||||
}
|
||||
const handleAdd = async () => {
|
||||
layoutId.value=0
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
const handleEdit = async (record: Recordable) => {
|
||||
layoutId.value=record.row.id
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
let ids = []
|
||||
if(!record){
|
||||
ids = selectionData.value.map(({id}) => id);
|
||||
}
|
||||
await confirm('确定要删除?');
|
||||
record? await layoutDelete(record.row.id):await layoutBatchDelete(ids);
|
||||
message("删除成功");
|
||||
reloadTable()
|
||||
}
|
||||
function onSelectionChange(value){
|
||||
selectionData.value = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
46
src/views/content/layoutItem/querySchemas.ts
Normal file
46
src/views/content/layoutItem/querySchemas.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { FormSchema } from '@/components/Form/index';
|
||||
import { getLayoutAllList } from '@/api/content/layout';
|
||||
export const loadSelectData = async(res)=> {
|
||||
//这里可以进行数据转换处理
|
||||
return (await getLayoutAllList({ ...res })).map((item, index) => {
|
||||
return {
|
||||
...item,
|
||||
label:item.name,
|
||||
value:item.id,
|
||||
index,
|
||||
};
|
||||
});
|
||||
}
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
field: 'layoutId',
|
||||
component: 'BasicSelect',
|
||||
label: '页面布局',
|
||||
componentProps: {
|
||||
placeholder: '请选择页面布局',
|
||||
block:true,
|
||||
request: loadSelectData,
|
||||
onChange: (e: any) => {
|
||||
console.log(e);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
component: 'Select',
|
||||
label: '页面类型',
|
||||
componentProps: {
|
||||
placeholder: '请选择页面类型',
|
||||
options: [
|
||||
{
|
||||
label: 'CMS文章',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
label: '通知公告',
|
||||
value: '2',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
Loading…
Reference in New Issue
Block a user