This commit is contained in:
oneao committed 2026-03-26 21:43:19 +08:00
1 parent 04d00b5b0b
commit 26721a142e
5 files changed
+350 -23

No files matched your search

-7
View File
@@ -18,7 +18,6 @@ declare module 'vue' {
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
@@ -28,21 +27,15 @@ declare module 'vue' {
ElInput: typeof import('element-plus/es')['ElInput']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElResult: typeof import('element-plus/es')['ElResult']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSplitter: typeof import('element-plus/es')['ElSplitter']
ElSplitterPanel: typeof import('element-plus/es')['ElSplitterPanel']
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElText: typeof import('element-plus/es')['ElText']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree']
G3Column: typeof import('./src/components/g3-table/g3-column.vue')['default']
@@ -13,8 +13,6 @@ const props = defineProps({
const dataList = ref([]);
async function initData() {
console.log(props);
if (!props.viewName) return;
loading.value = true;
@@ -22,7 +22,7 @@
.el-loading-mask {
&.is-fullscreen {
background: "rgba(0, 0, 0, 0.5)";
background: rgba(0, 0, 0, 0.5);
.el-loading-spinner .path {
stroke: #fff !important;
@@ -0,0 +1,283 @@
<script lang="js" setup>
import { loadDataBySqlApi } from "@/request/api";
import { useThrottle } from "@/utils/throttle";
import { ElMessage } from "element-plus";
const visible = defineModel(false);
const searchForm = ref({
startTime: "",
endTime: "",
containerNo: "",
username: "",
mode: "ALL",
});
const sliceModeForm = ref({
startPage: 1,
endPage: 100,
});
const chunkModeForm = ref({
pageSize: 100,
});
const total = ref(0);
const loadingTotal = ref(false);
function handleResetForm() {
searchForm.value.startTime = "";
searchForm.value.endTime = "";
searchForm.value.containerNo = "";
searchForm.value.username = "";
searchForm.value.mode = "ALL";
sliceModeForm.value.startPage = 1;
sliceModeForm.value.endPage = 100;
chunkModeForm.value.pageSize = 100;
}
watch(
() => ({
startTime: searchForm.value.startTime,
endTime: searchForm.value.endTime,
containerNo: searchForm.value.containerNo,
username: searchForm.value.username,
}),
() => {
if (visible.value) {
fetchTotalThrottle();
}
},
{ deep: true },
);
function onOpened() {
fetchTotalThrottle();
}
function onClosed() {
handleResetForm();
}
const fetchTotalThrottle = useThrottle(async () => {
await fetchTotal();
}, 300);
async function fetchTotal() {
if (!visible.value) {
return;
}
loadingTotal.value = true;
let searchCondition = [];
if (searchForm.value.startTime) {
searchCondition.push(`b_inputdatetime >= '${searchForm.value.startTime}'`);
}
if (searchForm.value.endTime) {
searchCondition.push(`b_inputdatetime <= '${searchForm.value.endTime}'`);
}
if (searchForm.value.containerNo) {
searchCondition.push(
`b_container_no LIKE '%${searchForm.value.containerNo}%'`,
);
}
if (searchForm.value.username) {
searchCondition.push(`v_username LIKE '%${searchForm.value.username}%'`);
}
// 拼接 WHERE 条件
const whereClause = searchCondition.length
? "WHERE " + searchCondition.join(" AND ")
: "";
// 构建 SQL 获取总数
const sql = `SELECT COUNT(*) as total FROM v_container ${whereClause}`;
try {
const res = await loadDataBySqlApi(sql);
if (res.success) {
total.value = res.data[0]?.total || 0;
}
} catch (err) {
console.error("获取总数失败", err);
total.value = 0;
} finally {
loadingTotal.value = false;
}
}
function handleExport() {
if (total === 0) {
ElMessage.warning("无有效数据可操作");
return;
}
}
</script>
<template>
<el-dialog
v-bind="$attrs"
title="高级下载"
width="500"
@opened="onOpened"
@closed="onClosed"
v-model="visible"
>
<div class="tip">
<div>请根据筛选条件下载,条件为空则默认全部。</div>
<div class="total">
共
<span class="num" v-loading="loadingTotal">
{{ total }}
</span>
条数据
</div>
</div>
<div class="form-container">
<!-- 上传日期 -->
<div class="form-item">
<div class="label">上传日期</div>
<div class="content">
<el-date-picker
type="datetime"
placeholder="开始日期"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
v-model="searchForm.startTime"
/>
<el-divider direction="vertical" />
<el-date-picker
type="datetime"
placeholder="结束日期"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
v-model="searchForm.endTime"
/>
</div>
</div>
<!-- 箱号 -->
<div class="form-item">
<div class="label">箱号</div>
<div class="content">
<el-input v-model="searchForm.containerNo" placeholder="请输入箱号" />
</div>
</div>
<!-- 操作员 -->
<div class="form-item">
<div class="label">操作员</div>
<div class="content">
<G3Select
v-model="searchForm.username"
v-model:label="searchForm.username"
search-condition="b_id <> 'g3soft'"
view-name="b_user"
value-key="b_name"
label-key="b_name"
keep-input
/>
</div>
</div>
<!-- 操作员 -->
<div class="form-item">
<div class="label">模式</div>
<div class="content">
<el-radio-group v-model="searchForm.mode">
<el-radio label="ALL">全部导出</el-radio>
<el-radio label="SLICE">按页区间导出</el-radio>
<el-radio label="CHUNK">分页拆分导出</el-radio>
</el-radio-group>
</div>
<div
v-if="searchForm.mode === 'SLICE'"
style="margin-top: 8px; display: flex; align-items: center"
>
<el-input placeholder="起始页" />
<el-divider direction="vertical" />
<el-input placeholder="终止页" />
</div>
<div
v-if="searchForm.mode === 'CHUNK'"
style="margin-top: 8px; display: flex; align-items: center"
>
<el-input placeholder="分页大小" />
</div>
</div>
</div>
<template #footer>
<el-button @click="handleResetForm">
<el-icon class="el-icon--left">
<G3Icon icon="lucide:refresh-ccw" />
</el-icon>
重置
</el-button>
<el-button type="primary">
<el-icon class="el-icon--left">
<G3Icon icon="lucide:cloud-download" />
</el-icon>
下载
</el-button>
</template>
</el-dialog>
</template>
<style lang="scss" scoped>
.tip {
font-weight: 600;
margin-bottom: 16px;
display: flex;
align-items: center;
justify-content: space-between;
}
.total {
color: #909399;
.num {
color: #409eff;
font-weight: 500;
padding: 0 4px;
}
}
.form-container {
display: flex;
flex-direction: column;
gap: 12px;
.form-item {
display: flex;
flex-direction: column;
}
.label {
font-size: 14px;
color: #606266;
margin-bottom: 8px;
}
.content {
flex: 1;
display: flex;
align-items: center;
::deep(.el-input) {
flex: 1;
}
}
}
</style>
@@ -15,6 +15,7 @@ import { saveAs } from "file-saver";
import JSZip from "jszip";
import { usePermissionStore } from "@/store/permission";
import { ExportVxeTableExcel, exportExcel } from "@/utils/excel";
import HighDownloadDialog from "./high-download-dialog.vue";
const tableRef = ref();
@@ -28,6 +29,8 @@ const loading = reactive({
table: true,
});
const showHighDownload = ref(false);
const searchForm = ref({
startTime: "",
endTime: "",
@@ -57,7 +60,9 @@ const viewName = "v_container";
const showPreview = ref(false);
const previewIndex = ref(-1);
const previewImageList = computed(() => {
return tableData.value.map((item) => item.b_container_img).filter((img) => img);
return tableData.value
.map((item) => item.b_container_img)
.filter((img) => img);
});
const currentRow = ref({});
@@ -190,9 +195,12 @@ async function deleteRows(rows = []) {
const safeDeleteIds = deleteIds.map((id) => Number(id));
// 使用安全的 SQL 查询
const fileRes = await loadDataApi("bf_file", `father IN (${safeDeleteIds.join(",")})`, "", [
"subid",
]);
const fileRes = await loadDataApi(
"bf_file",
`father IN (${safeDeleteIds.join(",")})`,
"",
["subid"],
);
if (!fileRes.success) {
return;
@@ -268,7 +276,11 @@ async function handleDownloadOne(data) {
});
try {
const fileRes = await loadDataApi("bf_file", `father = ${data.b_id}`, "mx_xh asc");
const fileRes = await loadDataApi(
"bf_file",
`father = ${data.b_id}`,
"mx_xh asc",
);
if (!fileRes.success) {
ElMessage.error("获取附件失败");
@@ -276,7 +288,11 @@ async function handleDownloadOne(data) {
}
const downloadFiles = fileRes.data.map((item, index) => ({
mx_filename: buildFileName(data.b_container_no, index + 1, item.mx_filename),
mx_filename: buildFileName(
data.b_container_no,
index + 1,
item.mx_filename,
),
mx_mapfilename: item.mx_mapfilename,
}));
@@ -338,7 +354,11 @@ async function handleDownloadBatch() {
let finished = 0;
for (const item of records) {
const fileRes = await loadDataApi("bf_file", `father = '${item.b_id}'`, "");
const fileRes = await loadDataApi(
"bf_file",
`father = '${item.b_id}'`,
"",
);
if (fileRes.success) {
total += (fileRes.data || []).length;
}
@@ -349,7 +369,11 @@ async function handleDownloadBatch() {
const folder = zip.folder(folderName);
const fileRes = await loadDataApi("bf_file", `father = '${item.b_id}'`, "mx_xh asc");
const fileRes = await loadDataApi(
"bf_file",
`father = '${item.b_id}'`,
"mx_xh asc",
);
if (!fileRes.success) {
ElMessage.error("获取附件失败");
@@ -365,7 +389,8 @@ async function handleDownloadBatch() {
const blob = getAliyunFileBlob(fileUrl);
const fileName =
buildFileName(item.b_container_no, index + 1, file.mx_filename) || "未命名文件";
buildFileName(item.b_container_no, index + 1, file.mx_filename) ||
"未命名文件";
folder.file(fileName, blob);
} catch (e) {
@@ -401,7 +426,6 @@ function buildFileName(containerNo, index, fileName) {
}
function testExport() {
const options = {
columns: [
{
@@ -575,6 +599,16 @@ function testExport() {
</el-icon>
批量下载
</el-button>
<el-button
type="primary"
:disabled="!permissionStore.hasActionPermission(1)"
@click="showHighDownload = true"
>
<el-icon class="el-icon--left">
<G3Icon icon="lucide:cloud-download" />
</el-icon>
高级下载
</el-button>
<el-button
type="danger"
@click="handleDeleteRows"
@@ -612,7 +646,12 @@ function testExport() {
<el-dropdown-item @click="updateViewTableColumns(tableRef)">
栏位保存
</el-dropdown-item>
<el-dropdown-item @click="ExportVxeTableExcel(tableRef)"> 导出Execl </el-dropdown-item>
<el-dropdown-item @click="ExportVxeTableExcel(tableRef)">
导出Execl
</el-dropdown-item>
<el-dropdown-item @click="ExportVxeTableExcel(tableRef)">
高级导出
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@@ -644,7 +683,14 @@ function testExport() {
show-overflow
show-header-overflow
>
<vxe-column field="seq" type="seq" width="50" align="center" title=" " fixed="left" />
<vxe-column
field="seq"
type="seq"
width="50"
align="center"
title=" "
fixed="left"
/>
<vxe-column type="checkbox" width="50" align="center" fixed="left" />
<vxe-column
v-for="column in columns"
@@ -665,7 +711,12 @@ function testExport() {
/>
</template>
<template v-else>
{{ formatValueByFormat(row[column.col_FieldName], column.col_DisplayFormat) }}
{{
formatValueByFormat(
row[column.col_FieldName],
column.col_DisplayFormat,
)
}}
</template>
</template>
</vxe-column>
@@ -736,6 +787,8 @@ function testExport() {
module-id="b_container"
:categories="fileCategories"
/>
<HighDownloadDialog v-model="showHighDownload" />
</div>
</template>