|
|
@@ -29,6 +29,32 @@
|
|
|
<el-icon><Document /></el-icon>
|
|
|
导出 Excel
|
|
|
</el-button>
|
|
|
+ <el-button-group>
|
|
|
+ <el-button
|
|
|
+ :type="dateFilterType === 'all' ? 'primary' : 'default'"
|
|
|
+ @click="setDateFilter('all')"
|
|
|
+ >
|
|
|
+ 全部
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ :type="dateFilterType === 'today' ? 'primary' : 'default'"
|
|
|
+ @click="setDateFilter('today')"
|
|
|
+ >
|
|
|
+ 今日
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ :type="dateFilterType === 'yesterday' ? 'primary' : 'default'"
|
|
|
+ @click="setDateFilter('yesterday')"
|
|
|
+ >
|
|
|
+ 昨日
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ :type="dateFilterType === 'week' ? 'primary' : 'default'"
|
|
|
+ @click="setDateFilter('week')"
|
|
|
+ >
|
|
|
+ 本周
|
|
|
+ </el-button>
|
|
|
+ </el-button-group>
|
|
|
</div>
|
|
|
|
|
|
<art-table
|
|
|
@@ -47,7 +73,7 @@
|
|
|
{{ row.inventoryDate || (row.grossWeightTime ? row.grossWeightTime.split(' ')[0] : (row.createdAt ? row.createdAt.split(' ')[0] : '')) }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="planNo" label="计划单号" min-width="120" />
|
|
|
+ <el-table-column prop="planNo" label="计划单号" min-width="200" />
|
|
|
<el-table-column prop="batchNo" label="出入库单号" min-width="140" />
|
|
|
<el-table-column prop="vehicleNo" label="车牌号" min-width="120" />
|
|
|
<el-table-column prop="cargoName" label="货物名称" min-width="150" />
|
|
|
@@ -79,7 +105,7 @@
|
|
|
{{ row.deduction || 0 }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="280" fixed="right">
|
|
|
+ <el-table-column label="操作" width="220" fixed="right">
|
|
|
<template #default="{ row }">
|
|
|
<el-button link type="primary" @click="handleView(row)">
|
|
|
<el-icon><View /></el-icon>
|
|
|
@@ -98,10 +124,6 @@
|
|
|
<el-icon><Close /></el-icon>
|
|
|
作废
|
|
|
</el-button>
|
|
|
- <el-button link type="danger" @click="handleDelete(row.id)">
|
|
|
- <el-icon><Delete /></el-icon>
|
|
|
- 删除
|
|
|
- </el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</art-table>
|
|
|
@@ -394,6 +416,7 @@
|
|
|
const currentPage = ref(1)
|
|
|
const pageSize = ref(10)
|
|
|
const searchKeyword = ref('')
|
|
|
+ const dateFilterType = ref<'all' | 'today' | 'yesterday' | 'week'>('all')
|
|
|
const companies = ref<Company[]>([])
|
|
|
const cargos = ref<Cargo[]>([])
|
|
|
const route = useRoute()
|
|
|
@@ -491,6 +514,36 @@
|
|
|
return allData.value.slice(start, end)
|
|
|
})
|
|
|
|
|
|
+ const dateRange = computed(() => {
|
|
|
+ const today = dayjs().format('YYYY-MM-DD')
|
|
|
+
|
|
|
+ if (dateFilterType.value === 'today') {
|
|
|
+ return { dateFrom: today, dateTo: today }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dateFilterType.value === 'yesterday') {
|
|
|
+ const y = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
|
|
|
+ return { dateFrom: y, dateTo: y }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dateFilterType.value === 'week') {
|
|
|
+ // 本周:周一到周日
|
|
|
+ const today = dayjs()
|
|
|
+ const weekday = today.day() === 0 ? 7 : today.day() // 1-7,周一=1,周日=7
|
|
|
+ const monday = today.subtract(weekday - 1, 'day').format('YYYY-MM-DD')
|
|
|
+ const sunday = today.add(7 - weekday, 'day').format('YYYY-MM-DD')
|
|
|
+ return { dateFrom: monday, dateTo: sunday }
|
|
|
+ }
|
|
|
+
|
|
|
+ return { dateFrom: undefined, dateTo: undefined }
|
|
|
+ })
|
|
|
+
|
|
|
+ const setDateFilter = (type: 'today' | 'yesterday' | 'week') => {
|
|
|
+ dateFilterType.value = type
|
|
|
+ currentPage.value = 1
|
|
|
+ loadData()
|
|
|
+ }
|
|
|
+
|
|
|
const loadData = async () => {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
@@ -498,6 +551,12 @@
|
|
|
if (searchKeyword.value) {
|
|
|
params.vehicleNo = searchKeyword.value
|
|
|
}
|
|
|
+ if (dateRange.value.dateFrom) {
|
|
|
+ params.dateFrom = dateRange.value.dateFrom
|
|
|
+ }
|
|
|
+ if (dateRange.value.dateTo) {
|
|
|
+ params.dateTo = dateRange.value.dateTo
|
|
|
+ }
|
|
|
const records = await weighingApi.list(params)
|
|
|
allData.value = records
|
|
|
total.value = records.length
|
|
|
@@ -694,7 +753,17 @@
|
|
|
|
|
|
const handleExport = async () => {
|
|
|
try {
|
|
|
- const records = await weighingApi.list({})
|
|
|
+ const params: any = {}
|
|
|
+ if (searchKeyword.value) {
|
|
|
+ params.vehicleNo = searchKeyword.value
|
|
|
+ }
|
|
|
+ if (dateRange.value.dateFrom) {
|
|
|
+ params.dateFrom = dateRange.value.dateFrom
|
|
|
+ }
|
|
|
+ if (dateRange.value.dateTo) {
|
|
|
+ params.dateTo = dateRange.value.dateTo
|
|
|
+ }
|
|
|
+ const records = await weighingApi.list(params)
|
|
|
if (records.length === 0) {
|
|
|
ElMessage.warning('没有数据可导出')
|
|
|
return
|