hwork-master
齐慧慧 2025-11-10 10:12:00 +08:00
parent 1f43402454
commit 0ad90ebf0e
2 changed files with 56 additions and 103 deletions

View File

@ -269,6 +269,7 @@
import {
useStore
} from 'vuex';
import { message } from '@hwork/ant-design-vue';
import {
defineComponent,
onMounted,
@ -643,20 +644,23 @@
const handleSearch = async (selectedKeys, confirm, dataIndex) => {
confirm();
state.loading = true;
/// :
const pageInfo = await getPageInfo(undefined);
let searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param)
console.log("查询条件", searchParams)
const {
total,
data
} = await props.fetch(searchParams);
//
if (state.pagination != false) {
state.pagination.total = total;
try {
//
const pageInfo = await getPageInfo(undefined);
let searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param)
console.log("查询条件", searchParams)
const { total, data } = await props.fetch(searchParams);
if (state.pagination != false) {
state.pagination.total = total || 0;
}
state.datasource = data || [];
} catch (error) {
console.error('列搜索请求失败:', error);
if (state.pagination != false) state.pagination.total = 0;
state.datasource = [];
} finally {
state.loading = false;
}
state.datasource = data;
state.loading = false;
};
/**
@ -740,31 +744,32 @@
}
}
}
//queryTypequeryType = 'like'使
// queryTypequeryType = 'like'使
const pageInfo = await getPageInfo(pagination);
state.loading = true;
var sortFeild = null
if (sorter && sorter.columnKey && sorter.order) {
sortFeild = {
sortColumn: toUnderline(sorter.columnKey),
sortType: sorter.order ? (sorter.order === "ascend" ? "ASC" : sorter.order === "descend" ?
"DESC" : "") : ""
try {
let sortFeild = null
if (sorter && sorter.columnKey && sorter.order) {
sortFeild = {
sortColumn: toUnderline(sorter.columnKey),
sortType: sorter.order ? (sorter.order === 'ascend' ? 'ASC' : sorter.order === 'descend' ? 'DESC' : '') : ''
}
console.log('sortFeild 列排序条件', sortFeild)
}
console.log("sortFeild 列排序条件", sortFeild)
const searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param, sortFeild)
console.log('查询条件', searchParams)
const { total, data } = await props.fetch(searchParams)
if (state.pagination != false) state.pagination.total = total || 0
state.datasource = data || []
} catch (error) {
console.error('表格加载失败:', error)
if (state.pagination != false) state.pagination.total = 0
state.datasource = []
//
// message.error('')
} finally {
state.loading = false
}
let searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param, sortFeild)
console.log("查询条件", searchParams)
///
const {
total,
data
} = await props.fetch(searchParams);
///
if (state.pagination != false) {
state.pagination.total = total;
}
state.datasource = data;
state.loading = false;
};
///
@ -844,26 +849,24 @@
let activeKey = store.getters.activeKey;
var exportFileName = panes.filter(item => item.path == activeKey)[0].title+new Date().toLocaleString().replace(/[/]/g, '_').replace(/[:]/g, '');
console.log("ExportExcel tablename", exportFileName)
state.exportExcelPagination.pageNum = 1;
state.exportExcelPagination.pageSize = state.pagination.total;
let searchParams = Object.assign({}, state.exportExcelPagination, state.columnSearchParams, props.param)
console.log("导出数据条件", searchParams)
const { total, data} = await props.fetch(searchParams);
if (data) {
//
state.datasourceExport = data;
//excelExportRef.value.excelExport()
nextTick(() => {
//table
exportDataMethod(props.tableId,exportFileName);
})
// nextTick(() => {
//
// exportExcelWithData(exportFileName,data);
// })
try {
state.exportExcelPagination.pageNum = 1;
state.exportExcelPagination.pageSize = state.pagination.total;
let searchParams = Object.assign({}, state.exportExcelPagination, state.columnSearchParams, props.param)
console.log('导出数据条件', searchParams)
const { total, data } = await props.fetch(searchParams)
if (data) {
state.datasourceExport = data;
nextTick(() => {
exportDataMethod(props.tableId, exportFileName);
})
}
} catch (error) {
console.error('导出失败:', error)
message.error('导出失败')
} finally {
state.loading = false
}
state.loading = false;
};
const exportDataMethod = function(elementId ,fileName) {

View File

@ -26,8 +26,6 @@
</template>
<script>
import { message, Modal as modal } from '@hwork/ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { message, Modal as modal } from "@hwork/ant-design-vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import { page, clean } from "@/api/module/log";
@ -40,7 +38,6 @@ export default {
const text = ref("");
const visible = ref(false);
///
const converFormat = [{ label: "成功", value: true }, { label: "失败", value: false }];
const converFormat = [
{ label: "成功", value: true },
{ label: "失败", value: false },
@ -49,20 +46,6 @@ export default {
///
const columns = [
{ dataIndex: "index", key: "index", title: "序号", width: 60, fixed: 'left', align: 'center' },
{ dataIndex: "title", key: "title", title: "标题", width: 120, showSearch: true },
{ dataIndex: "describe", key: "describe", title: "描述", width: 120, showSearch: true },
{ dataIndex: "action", key: "action", title: "动作", width: 100 },
{ dataIndex: "type", key: "type", title: "方式", width: 120 },
{ dataIndex: "browser", key: "browser", title: "浏览器", width: 120, ellipsis: true },
{ dataIndex: "system", key: "system", title: "系统", width: 120, ellipsis: true },
{ dataIndex: "address", key: "address", title: "操作地", width: 120, showSearch: true, ellipsis: true },
{ dataIndex: "createBy", key: "createBy", title: "创建人", width: 120, ellipsis: true, showSearch: true },
{ dataIndex: "createUsername", key: "createUsername", title: "创建人", width: 120, ellipsis: true, showSearch: true },
{ dataIndex: "createNickname", key: "createNickname", title: "创建人昵称", width: 120, ellipsis: true },
{ dataIndex: "createTime", key: "createTime", title: "操作时间", width: 180, ellipsis: true },
{ dataIndex: "state", key: "state", title: "状态", conver: converFormat, width: 120, ellipsis: true },
{ dataIndex: "params", key: "params", title: "参数", showSearch: true, width: 300, ellipsis: true },
{ dataIndex: "result", key: "result", title: "返回结果", showSearch: true, width: 300, ellipsis: true },
{
dataIndex: "title",
key: "title",
@ -158,7 +141,6 @@ export default {
];
const operate = [
{ label: "查看", event: function (record) { alert("查看详情:" + JSON.stringify(record)) } },
{
label: "查看",
event: function (record) {
@ -186,11 +168,6 @@ export default {
cancelText: "取消",
onOk() {
message.loading({ content: "提交中...", key: cleanKey });
clean({ "isAuth": true }).then((response) => {
if (response.success) {
message.success({ content: "清空成功", key: cleanKey, duration: 1 })
} else {
message.error({ content: "清空失败", key: cleanKey, duration: 1 })
clean({ isAuth: true }).then((response) => {
if (response.success) {
message.success({
@ -214,24 +191,11 @@ export default {
const toolbar = [
{ label: "备份", icon: 'SnippetsOutlined', event: function () { } },
{ label: "清空", icon: 'ClearOutlined', danger: true, event: function () { cleanMethod(); } },
{ label: "备份", event: function () {} },
{
label: "清空",
event: function () {
cleanMethod();
},
},
];
///
const pagination = {
pageNum: 1,
pageSize: 20,
showSizeChanger: true, //
pageSizeOptions: ["10", "20", "50", "100"], //
showTotal: total => `${total} 条记录`, //
showSizeChange: (current, pageSize) => (this.pageSize = pageSize) //
}
pageSize: 10,
};
@ -243,16 +207,6 @@ export default {
///
const searchParam = [
{ key: "title", type: "input", label: "标题" },
{
key: "state", type: "select", label: "状态", value: "",
options: [
{ text: "全部", value: "" },
{ text: "成功", value: true },
{ text: "失败", value: false }
]
}
]
{ key: "title", type: "input", label: "标题" },
{
key: "state",
@ -267,10 +221,6 @@ export default {
},
];
///
const search = function (value) {
state.param.title = value.title
state.param.state = value.state
}
const search = function (value) {
state.param.title = value.title;
state.param.state = value.state;