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

View File

@ -26,8 +26,6 @@
</template> </template>
<script> <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 { message, Modal as modal } from "@hwork/ant-design-vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue"; import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import { page, clean } from "@/api/module/log"; import { page, clean } from "@/api/module/log";
@ -40,7 +38,6 @@ export default {
const text = ref(""); const text = ref("");
const visible = ref(false); const visible = ref(false);
/// ///
const converFormat = [{ label: "成功", value: true }, { label: "失败", value: false }];
const converFormat = [ const converFormat = [
{ label: "成功", value: true }, { label: "成功", value: true },
{ label: "失败", value: false }, { label: "失败", value: false },
@ -49,20 +46,6 @@ export default {
/// ///
const columns = [ const columns = [
{ dataIndex: "index", key: "index", title: "序号", width: 60, fixed: 'left', align: 'center' }, { 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", dataIndex: "title",
key: "title", key: "title",
@ -158,7 +141,6 @@ export default {
]; ];
const operate = [ const operate = [
{ label: "查看", event: function (record) { alert("查看详情:" + JSON.stringify(record)) } },
{ {
label: "查看", label: "查看",
event: function (record) { event: function (record) {
@ -186,11 +168,6 @@ export default {
cancelText: "取消", cancelText: "取消",
onOk() { onOk() {
message.loading({ content: "提交中...", key: cleanKey }); 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) => { clean({ isAuth: true }).then((response) => {
if (response.success) { if (response.success) {
message.success({ message.success({
@ -214,24 +191,11 @@ export default {
const toolbar = [ const toolbar = [
{ label: "备份", icon: 'SnippetsOutlined', event: function () { } }, { label: "备份", icon: 'SnippetsOutlined', event: function () { } },
{ label: "清空", icon: 'ClearOutlined', danger: true, event: function () { cleanMethod(); } }, { label: "清空", icon: 'ClearOutlined', danger: true, event: function () { cleanMethod(); } },
{ label: "备份", event: function () {} },
{
label: "清空",
event: function () {
cleanMethod();
},
},
]; ];
/// ///
const pagination = { const pagination = {
pageNum: 1, pageNum: 1,
pageSize: 20,
showSizeChanger: true, //
pageSizeOptions: ["10", "20", "50", "100"], //
showTotal: total => `${total} 条记录`, //
showSizeChange: (current, pageSize) => (this.pageSize = pageSize) //
}
pageSize: 10, pageSize: 10,
}; };
@ -243,16 +207,6 @@ export default {
/// ///
const searchParam = [ 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: "title", type: "input", label: "标题" },
{ {
key: "state", 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) { const search = function (value) {
state.param.title = value.title; state.param.title = value.title;
state.param.state = value.state; state.param.state = value.state;