hwork-master
parent
1f43402454
commit
0ad90ebf0e
|
|
@ -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);
|
const pageInfo = await getPageInfo(undefined);
|
||||||
let searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param)
|
let searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param)
|
||||||
console.log("查询条件", searchParams)
|
console.log("查询条件", searchParams)
|
||||||
const {
|
const { total, data } = await props.fetch(searchParams);
|
||||||
total,
|
|
||||||
data
|
|
||||||
} = await props.fetch(searchParams);
|
|
||||||
// 状态重置
|
|
||||||
if (state.pagination != false) {
|
if (state.pagination != false) {
|
||||||
state.pagination.total = total;
|
state.pagination.total = total || 0;
|
||||||
}
|
}
|
||||||
state.datasource = data;
|
state.datasource = data || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('列搜索请求失败:', error);
|
||||||
|
if (state.pagination != false) state.pagination.total = 0;
|
||||||
|
state.datasource = [];
|
||||||
|
} finally {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -740,31 +744,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//分页信息:包含queryType,当queryType = 'like'时,配合后端使用模糊查询
|
// 分页信息:包含queryType,当queryType = 'like'时,配合后端使用模糊查询
|
||||||
const pageInfo = await getPageInfo(pagination);
|
const pageInfo = await getPageInfo(pagination);
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
var sortFeild = null
|
try {
|
||||||
|
let sortFeild = null
|
||||||
if (sorter && sorter.columnKey && sorter.order) {
|
if (sorter && sorter.columnKey && sorter.order) {
|
||||||
sortFeild = {
|
sortFeild = {
|
||||||
sortColumn: toUnderline(sorter.columnKey),
|
sortColumn: toUnderline(sorter.columnKey),
|
||||||
sortType: sorter.order ? (sorter.order === "ascend" ? "ASC" : sorter.order === "descend" ?
|
sortType: sorter.order ? (sorter.order === 'ascend' ? 'ASC' : sorter.order === 'descend' ? 'DESC' : '') : ''
|
||||||
"DESC" : "") : ""
|
|
||||||
}
|
}
|
||||||
console.log("sortFeild 列排序条件", sortFeild)
|
console.log('sortFeild 列排序条件', sortFeild)
|
||||||
}
|
}
|
||||||
let searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param, sortFeild)
|
const searchParams = Object.assign({}, pageInfo, state.columnSearchParams, props.param, sortFeild)
|
||||||
console.log("查询条件", searchParams)
|
console.log('查询条件', searchParams)
|
||||||
///查询后端的数据
|
const { total, data } = await props.fetch(searchParams)
|
||||||
const {
|
if (state.pagination != false) state.pagination.total = total || 0
|
||||||
total,
|
state.datasource = data || []
|
||||||
data
|
} catch (error) {
|
||||||
} = await props.fetch(searchParams);
|
console.error('表格加载失败:', error)
|
||||||
/// 状态重置
|
if (state.pagination != false) state.pagination.total = 0
|
||||||
if (state.pagination != false) {
|
state.datasource = []
|
||||||
state.pagination.total = total;
|
// 可选:给出全局提示
|
||||||
|
// message.error('数据加载失败')
|
||||||
|
} finally {
|
||||||
|
state.loading = false
|
||||||
}
|
}
|
||||||
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)
|
||||||
|
try {
|
||||||
state.exportExcelPagination.pageNum = 1;
|
state.exportExcelPagination.pageNum = 1;
|
||||||
state.exportExcelPagination.pageSize = state.pagination.total;
|
state.exportExcelPagination.pageSize = state.pagination.total;
|
||||||
let searchParams = Object.assign({}, state.exportExcelPagination, state.columnSearchParams, props.param)
|
let searchParams = Object.assign({}, state.exportExcelPagination, state.columnSearchParams, props.param)
|
||||||
console.log("导出数据条件", searchParams)
|
console.log('导出数据条件', searchParams)
|
||||||
const { total, data} = await props.fetch(searchParams);
|
const { total, data } = await props.fetch(searchParams)
|
||||||
if (data) {
|
if (data) {
|
||||||
// 供导出用
|
|
||||||
state.datasourceExport = data;
|
state.datasourceExport = data;
|
||||||
//excelExportRef.value.excelExport()
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
//缺陷:依赖于table才能打印
|
exportDataMethod(props.tableId, exportFileName);
|
||||||
exportDataMethod(props.tableId,exportFileName);
|
|
||||||
})
|
})
|
||||||
// nextTick(() => {
|
|
||||||
//优点:指定数据源就可以完成导出操作 缺点:表头是英文 之后在优化
|
|
||||||
// exportExcelWithData(exportFileName,data);
|
|
||||||
// })
|
|
||||||
|
|
||||||
}
|
}
|
||||||
state.loading = false;
|
} catch (error) {
|
||||||
|
console.error('导出失败:', error)
|
||||||
|
message.error('导出失败')
|
||||||
|
} finally {
|
||||||
|
state.loading = false
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportDataMethod = function(elementId ,fileName) {
|
const exportDataMethod = function(elementId ,fileName) {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue