feat: add 'not contains' operator, implement inbound record export, and verify export filter rules

This commit is contained in:
DXC
2026-04-07 17:23:00 +08:00
parent 30ab1c186c
commit 6d80c90b66
7 changed files with 273 additions and 2 deletions

View File

@ -15,4 +15,13 @@ export function getInboundSummaryList(params: InboundSummaryQuery) {
method: 'get',
params
})
}
export function exportInboundSummary(params: any) {
return request({
url: '/v1/inbound/summary/export',
method: 'get',
params,
responseType: 'blob'
})
}

View File

@ -657,6 +657,7 @@ const operatorOptions = ref([
{ value: 'eq', label: '等于' },
{ value: 'ne', label: '不等于' },
{ value: 'contains', label: '包含' },
{ value: 'not_contains', label: '不包含' },
{ value: 'ge', label: '大于等于' },
{ value: 'le', label: '小于等于' }
]);

View File

@ -880,6 +880,7 @@ const operatorOptions = ref([
{ value: 'eq', label: '等于' },
{ value: 'ne', label: '不等于' },
{ value: 'contains', label: '包含' },
{ value: 'not_contains', label: '不包含' },
{ value: 'ge', label: '大于等于' },
{ value: 'le', label: '小于等于' }
])

View File

@ -28,6 +28,10 @@
@change="handleFilter"
/>
<el-button type="primary" class="filter-item" style="margin-left: 10px;" @click="handleFilter">查询</el-button>
<el-button type="success" plain class="filter-item" style="margin-left: 10px;" @click="handleExport" :loading="exportLoading">
导出Excel
</el-button>
</div>
<el-table
@ -100,14 +104,16 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { getInboundSummaryList } from '@/api/inbound/inbound_summary'
import { getInboundSummaryList, exportInboundSummary } from '@/api/inbound/inbound_summary'
import { useUserStore } from '@/stores/user'
import { ElMessage } from 'element-plus'
const userStore = useUserStore()
const list = ref([])
const total = ref(0)
const loading = ref(false)
const exportLoading = ref(false)
const listQuery = reactive({
page: 1,
@ -147,6 +153,48 @@ const handleFilter = () => {
fetchData()
}
// 导出 Excel
const handleExport = () => {
exportLoading.value = true
const params = {
keyword: listQuery.keyword,
source_type: listQuery.source_type,
start_date: listQuery.dateRange ? listQuery.dateRange[0] : null,
end_date: listQuery.dateRange ? listQuery.dateRange[1] : null
}
exportInboundSummary(params)
.then((response: any) => {
const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
const hour = String(now.getHours()).padStart(2, '0')
const minute = String(now.getMinutes()).padStart(2, '0')
const second = String(now.getSeconds()).padStart(2, '0')
const filename = `入库记录_${year}${month}${day}_${hour}${minute}${second}.xlsx`
link.setAttribute('download', filename)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
ElMessage.success('导出成功')
})
.catch((err: any) => {
console.error('导出失败', err)
ElMessage.error('导出失败')
})
.finally(() => {
exportLoading.value = false
})
}
// 来源类型的 Tag 颜色
const getSourceTag = (type: string) => {
if (type === 'buy') return 'success' // 绿色