文章管理优化

main
zhc077 1 year ago
parent 35805f42f6
commit 1422736b7e
  1. 2
      jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts
  2. 148
      jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue

@ -23,10 +23,8 @@ export const getExportUrl = Api.exportXls;
*/ */
export const getImportUrl = Api.importExcel; export const getImportUrl = Api.importExcel;
export const updateStatus = (params) => defHttp.post({url: Api.operationStatus, params}); export const updateStatus = (params) => defHttp.post({url: Api.operationStatus, params});
/** /**
* *
* @param params * @param params

@ -8,11 +8,53 @@
</a-button> </a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出 <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出
</a-button> </a-button>
<!-- <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>-->
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
<!-- <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>--> <!-- <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>-->
<TableAction :actions="getTableAction(record)"/> <TableAction :actions="getTableAction(record)"/>
<!--<TableAction
:stopButtonPropagation="true"
:actions="[
{
label: '1',
// type: 'link',
size: 'small',
icon: 'ant-design:plus-circle-outlined',
onClick: add.bind(null, record),
},
{
label: '2',
// type: 'link',
size: 'small',
icon: 'fa6-regular:pen-to-square',
onClick: editor.bind(null, record),
},
{
label: '3',
// color: 'error',
icon: 'ic:outline-delete-outline',
popConfirm: {
title: '确定删除该数据吗?',
confirm: del.bind(null, record),
},
},
]"
/>-->
</template> </template>
<!--字段回显插槽--> <!--字段回显插槽-->
<template #htmlSlot="{text}"> <template #htmlSlot="{text}">
@ -35,24 +77,28 @@
</template> </template>
<script lang="ts" name="cms-cmsArticle" setup> <script lang="ts" name="cms-cmsArticle" setup>
import {ref} from 'vue'; import {ref} from 'vue';
import {useModal} from '/@/components/Modal'; import {BasicTable, TableAction} from '/@/components/Table';
import {useListPage} from '/@/hooks/system/useListPage' import {useModal} from '/@/components/Modal';
import {columns, searchFormSchema} from './CmsArticle.data'; import {useListPage} from '/@/hooks/system/useListPage'
import { import CmsArticleModal from './components/CmsArticleModal.vue'
import {columns, searchFormSchema} from './CmsArticle.data';
import {
batchDelete, batchDelete,
deleteOne, deleteOne,
getExportUrl, getExportUrl,
getImportUrl, getImportUrl,
list, list,
updateStatus updateStatus
} from './CmsArticle.api'; } from './CmsArticle.api';
// import { downloadFile } from '/@/utils/common/renderUtils'; // import {updateStatus} from './CmsArticle.api';
const checkedKeys = ref<Array<string | number>>([]); import {Update} from "/@/views/topic/Topic.api";
//model // import { downloadFile } from '/@/utils/common/renderUtils';
const [registerModal, {openModal}] = useModal(); const checkedKeys = ref<Array<string | number>>([]);
//table //model
const {prefixCls, tableContext, onExportXls, onImportXls} = useListPage({ const [registerModal, {openModal}] = useModal();
//table
const {prefixCls, tableContext, onExportXls, onImportXls} = useListPage({
tableProps: { tableProps: {
title: '文章', title: '文章',
api: list, api: list,
@ -67,7 +113,7 @@
fieldMapToTime: [], fieldMapToTime: [],
}, },
actionColumn: { actionColumn: {
width: 120, width: 180,
fixed: 'right' fixed: 'right'
}, },
}, },
@ -79,73 +125,73 @@
url: getImportUrl, url: getImportUrl,
success: handleSuccess success: handleSuccess
}, },
}) })
const [registerTable, {reload}, {rowSelection, selectedRowKeys}] = tableContext const [registerTable, {reload}, {rowSelection, selectedRowKeys}] = tableContext
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** function update2(record: Recordable, isopen) {
record.isopen = isopen;
updateStatus(record)
reload()
}
/**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
function operationStatus(record: Recordable, isopen) { /**
record.isopen = isopen;
updateStatus(record)
reload()
}
/**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess); await deleteOne({id: record.id}, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess); await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
const actions = [ const actions = [
{ {
label: '编辑', label: '编辑',
@ -159,25 +205,25 @@
} }
} }
]; ];
if (record.status == "0") { if (record.status == "1") {
actions.unshift({ actions.unshift({
label: '发布', label: '取消发布',
onClick: operationStatus.bind(null, record, "1"), onClick: update2.bind(null, record, "0"),
}); });
} }
if (record.status == "1") { if (record.status == "0") {
actions.unshift({ actions.unshift({
label: '取消发布', label: '发布',
onClick: operationStatus.bind(null, record, "0"), onClick: update2.bind("1", record, "1"),
}); });
} }
return actions; return actions;
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record) { function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
@ -190,7 +236,7 @@
} }
} }
] ]
} }
</script> </script>

Loading…
Cancel
Save