opt:新增excel 导出

This commit is contained in:
2025-11-20 16:20:14 +08:00
parent c32665d1be
commit f79a077703
15 changed files with 597 additions and 85 deletions

View File

@@ -3,23 +3,23 @@
<!-- 顶部导航栏 -->
<el-header class="header">
<div class="header-left">
<i class="el-icon-truck"></i>
<i class="el-icon-truck" />
<span class="header-title">库位状态看板</span>
</div>
<div class="header-right">
<el-button
type="primary"
icon="el-icon-refresh"
@click="refreshData"
:loading="isRefreshing"
@click="refreshData"
>
手动刷新
</el-button>
<el-button
type="text"
icon="el-icon-pause"
@click="toggleRefresh"
class="refresh-toggle"
@click="toggleRefresh"
>
{{ isAutoRefresh ? '暂停刷新' : '开启刷新' }}
</el-button>
@@ -85,15 +85,15 @@
class="floor-select"
@change="handleFloorChange"
>
<el-option label="全部楼层" value="all"></el-option>
<el-option label="一层" value="1"></el-option>
<el-option label="二层" value="2"></el-option>
<el-option label="三层" value="3"></el-option>
<el-option label="全部楼层" value="all" />
<el-option label="一层" value="1" />
<el-option label="二层" value="2" />
<el-option label="三层" value="3" />
</el-select>
</div>
<div class="chart-container">
<div id="floorPieChart" class="chart"></div>
<div id="floorBarChart" class="chart"></div>
<div id="floorPieChart" class="chart" />
<div id="floorBarChart" class="chart" />
</div>
</el-card>
</div>
@@ -118,7 +118,7 @@ export default {
name: 'AGVDashboard',
data() {
return {
storCode : 'FJ',
storCode: 'FJ',
// 概览数据
overview: {
totalLocations: 0,
@@ -158,6 +158,18 @@ export default {
}
},
watch: {
// 监听搜索条件变化
searchCode(val) {
this.filterLocations()
},
// 监听选中楼层变化
selectedFloor(val) {
this.updateCharts()
}
},
created() {
// 初始化数据
this.fetchData()
@@ -172,18 +184,6 @@ export default {
}
},
watch: {
// 监听搜索条件变化
searchCode(val) {
this.filterLocations()
},
// 监听选中楼层变化
selectedFloor(val) {
this.updateCharts()
}
},
methods: {
// 获取数据
fetchData() {
@@ -253,7 +253,6 @@ export default {
{ name: '三层', value: this.calculateFloorCount(3) }
]
barData = this.prepareBarData([1, 2, 3])
} else {
// 特定楼层数据
@@ -351,7 +350,7 @@ export default {
// 准备特定楼层的状态数据
prepareFloorStatusData(floor) {
const statuses = ['空闲', '占用', '入库中', '出库中', '移入中', '移出中','其他占用']
const statuses = ['空闲', '占用', '入库中', '出库中', '移入中', '移出中', '其他占用']
const floorLocations = this.locations.filter(location => location.floor === floor)
return statuses.map(status => {
return {

View File

@@ -3,23 +3,23 @@
<!-- 顶部导航栏 -->
<el-header class="header">
<div class="header-left">
<i class="el-icon-s-tools"></i>
<i class="el-icon-s-tools" />
<span class="header-title">任务完成情况看板</span>
</div>
<div class="header-right">
<el-button
type="primary"
icon="el-icon-refresh"
@click="refreshData"
:loading="isRefreshing"
@click="refreshData"
>
手动刷新
</el-button>
<el-button
type="text"
icon="el-icon-pause"
@click="toggleRefresh"
class="refresh-toggle"
@click="toggleRefresh"
>
{{ isAutoRefresh ? '暂停刷新' : '开启刷新' }}
</el-button>
@@ -43,9 +43,9 @@
<div class="stat-value">{{ stats.todayTasks }}</div>
<div class="stat-change">
<span :class="weeklyComparison.growthRate >= 0 ? 'positive' : 'negative'">
<i :class="weeklyComparison.growthRate >= 0 ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
{{ stats.dayOnDay }}%
</span>
<i :class="weeklyComparison.growthRate >= 0 ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" />
{{ stats.dayOnDay }}%
</span>
<span class="compared">较昨日</span>
</div>
</el-card>
@@ -63,7 +63,7 @@
<!-- 数据概览卡片 - 第二行 -->
<div class="overview-cards">
<!-- <el-card class="stat-card" shadow="hover">
<!-- <el-card class="stat-card" shadow="hover">
<div class="stat-title">月均任务数</div>
<div class="stat-value">{{ stats.monthlyAvg }}</div>
</el-card>-->
@@ -97,19 +97,19 @@
class="view-type-select"
@change="handleViewTypeChange"
>
<el-option label="每日任务完成情况" value="daily"></el-option>
<el-option label="周任务数据对比" value="weekly"></el-option>
<el-option label="每日任务完成情况" value="daily" />
<el-option label="周任务数据对比" value="weekly" />
</el-select>
<div class="growth-rate" v-if="viewType === 'weekly' && weeklyComparison.growthRate !== 0">
<div v-if="viewType === 'weekly' && weeklyComparison.growthRate !== 0" class="growth-rate">
<span :class="weeklyComparison.growthRate >= 0 ? 'positive' : 'negative'">
<i :class="weeklyComparison.growthRate >= 0 ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
<i :class="weeklyComparison.growthRate >= 0 ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" />
{{ weeklyComparison.growthRate }}%
</span>
<span class="compared">较上周</span>
</div>
</div>
<div class="chart-container">
<div id="taskChart" class="chart"></div>
<div id="taskChart" class="chart" />
</div>
</el-card>
</div>
@@ -327,8 +327,7 @@ export default {
}
this.updateTaskChart()
}
}
,
},
toggleRefresh() {
this.isAutoRefresh = !this.isAutoRefresh
this.setupAutoRefresh()
@@ -377,15 +376,15 @@ export default {
const otherData = this.historyList.map(item => item.other)
const option = {
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }},
legend: { data: ['入库任务', '出库任务', '其他搬运'], top: 10 },
grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true },
xAxis: { type: 'category', data: xAxisData },
yAxis: { type: 'value' },
series: [
{ name: '入库任务', type: 'bar', data: inboundData, itemStyle: { color: '#1890ff' } },
{ name: '出库任务', type: 'bar', data: outboundData, itemStyle: { color: '#52c41a' } },
{ name: '其他搬运', type: 'bar', data: otherData, itemStyle: { color: '#fa8c16' } }
{ name: '入库任务', type: 'bar', data: inboundData, itemStyle: { color: '#1890ff' }},
{ name: '出库任务', type: 'bar', data: outboundData, itemStyle: { color: '#52c41a' }},
{ name: '其他搬运', type: 'bar', data: otherData, itemStyle: { color: '#fa8c16' }}
]
}
myChart.setOption(option)
@@ -408,9 +407,9 @@ export default {
type: 'value'
},
series: [
{ name: '入库任务', type: 'bar', data: this.threeWeeksData.inboundData, itemStyle: { color: '#1890ff' } },
{ name: '出库任务', type: 'bar', data: this.threeWeeksData.outboundData, itemStyle: { color: '#52c41a' } },
{ name: '其他搬运', type: 'bar', data: this.threeWeeksData.otherData, itemStyle: { color: '#fa8c16' } }
{ name: '入库任务', type: 'bar', data: this.threeWeeksData.inboundData, itemStyle: { color: '#1890ff' }},
{ name: '出库任务', type: 'bar', data: this.threeWeeksData.outboundData, itemStyle: { color: '#52c41a' }},
{ name: '其他搬运', type: 'bar', data: this.threeWeeksData.otherData, itemStyle: { color: '#fa8c16' }}
]
}
@@ -487,8 +486,7 @@ export default {
}
return weeks
}
,
},
// 更新周对比图表
updateWeeklyChart(myChart) {
@@ -551,24 +549,22 @@ export default {
const otherData = this.historyList.map(item => item.other)
const option = {
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }},
legend: { data: ['入库任务', '出库任务', '其他搬运'], top: 10 },
grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true },
xAxis: { type: 'category', data: xAxisData },
yAxis: { type: 'value' },
series: [
{ name: '入库任务', type: 'bar', data: inboundData, itemStyle: { color: '#1890ff' } },
{ name: '出库任务', type: 'bar', data: outboundData, itemStyle: { color: '#52c41a' } },
{ name: '其他搬运', type: 'bar', data: otherData, itemStyle: { color: '#fa8c16' } }
{ name: '入库任务', type: 'bar', data: inboundData, itemStyle: { color: '#1890ff' }},
{ name: '出库任务', type: 'bar', data: outboundData, itemStyle: { color: '#52c41a' }},
{ name: '其他搬运', type: 'bar', data: otherData, itemStyle: { color: '#fa8c16' }}
]
}
myChart.setOption(option)
}
,
},
handleSizeChange(val) {
this.pageSize = val
}
,
},
handleCurrentChange(val) {
this.currentPage = val
}

View File

@@ -92,8 +92,14 @@
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission">
<el-button slot="right"
class="filter-item"
type="primary"
size="mini" @click="exportExcel"
>导出excel
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
@@ -297,7 +303,7 @@
</template>
<script>
import crudStructattr from '@/views/wms/basedata/structattr/structattr'
import crudStructattr, { exportFile } from '@/views/wms/basedata/structattr/structattr'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
@@ -432,6 +438,35 @@ export default {
})
},
methods: {
// 导出Excel功能
exportExcel() {
// 构建文件名称仓位管理导出yyyymmdd.xlsx
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 fileName = `仓位管理导出${year}${month}${day}.xlsx`
// 使用导入的exportFile方法调用后端接口
exportFile(this.query).then(res => {
// 创建Blob对象
const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
// 创建下载链接
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = fileName
// 触发下载
document.body.appendChild(link)
link.click()
// 清理
document.body.removeChild(link)
URL.revokeObjectURL(link.href)
this.crud.notify('导出成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
}).catch(() => {
this.crud.notify('导出失败', CRUD.NOTIFICATION_TYPE.ERROR)
})
},
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true

View File

@@ -48,4 +48,14 @@ export function blurQuery(data) {
})
}
export default { add, edit, del, changeActive, oneCreate, blurQuery }
export function exportFile(query) {
return request({
url: 'api/structattr/exportFile',
method: 'post',
data: query,
responseType: 'blob'
})
}
export default { add, edit, del, changeActive, oneCreate, blurQuery, exportFile }

View File

@@ -179,6 +179,8 @@
<el-table-column prop="stor_name" :label="$t('wms.st.inbill.warehouse')" width="100px;" />
<el-table-column prop="struct_code" :label="$t('wms.st.inbill.warehouse_location')" width="100px;" />
<el-table-column prop="vehicle_code" :label="$t('wms.st.inbill.vehicle_code')" width="100px;" />
<el-table-column prop="material_code" :label="$t('wms.st.inbill.material_code')" width="100px;" />
<el-table-column prop="material_name" :label="$t('wms.st.inbill.material_name')" width="100px;" />
<el-table-column show-overflow-tooltip prop="bill_type" min-width="120" :formatter="bill_typeFormat" :label="$t('wms.st.inbill.bill_type')" />
<el-table-column show-overflow-tooltip min-width="120" prop="biz_date" :label="$t('wms.st.inbill.business_date')" />
<el-table-column show-overflow-tooltip prop="create_mode" :formatter="create_modeFormat" :label="$t('wms.st.inbill.create_mode')" />

View File

@@ -185,6 +185,8 @@
<el-table-column show-overflow-tooltip width="100" prop="biz_date" :label="$t('wms.st.outbill.business_date')" />
<el-table-column show-overflow-tooltip :label="$t('wms.st.outbill.detail_count')" align="center" prop="detail_count" width="60" />
<el-table-column show-overflow-tooltip :label="$t('wms.st.outbill.plan_weight')" align="center" prop="total_qty" width="100" :formatter="crud.formatNum3" />
<el-table-column show-overflow-tooltip prop="material_code" :label="$t('wms.st.inbill.material_code')" width="100px;" />
<el-table-column show-overflow-tooltip prop="material_name" :label="$t('wms.st.inbill.material_name')" width="100px;" />
<!-- <el-table-column show-overflow-tooltip label="实际重量" align="center" prop="plan_qty" width="100" :formatter="crud.formatNum3" />-->
<el-table-column show-overflow-tooltip :label="$t('wms.st.outbill.is_upload')" align="center" prop="is_upload" width="80" :formatter="formatIsUpload" />
<el-table-column show-overflow-tooltip :formatter="create_modeFormat" prop="create_mode" :label="$t('wms.st.outbill.create_mode')" width="100" />