opt:导出功能优化

This commit is contained in:
2025-11-21 12:58:04 +08:00
parent 668736639b
commit 85d349eda2
17 changed files with 340 additions and 16 deletions

View File

@@ -247,7 +247,7 @@
</template>
<script>
import crudGroup, { exportFile } from '@/views/wms/basedata/group/group'
import crudGroup, { exportFile } from '@/views/wms/basedata/group/group'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'

View File

@@ -45,4 +45,13 @@ export function getSonFormData(id) {
})
}
export function exportFile(query) {
return request({
url: 'api/pmFormData/exportFile',
method: 'post',
data: query,
responseType: 'blob'
})
}
export default {add, edit, del, getFormType, getParentFormTypes, getSonFormData}

View File

@@ -94,7 +94,16 @@
</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" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="820px">
<el-form ref="form" style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;" :inline="true" :model="form" :rules="rules" size="mini" label-width="135px" label-suffix=":">
@@ -216,7 +225,7 @@
</template>
<script>
import crudFormData from './formData'
import crudFormData, { exportFile } from './formData'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation.vue'
import rrOperation from '@crud/RR.operation.vue'
@@ -316,6 +325,34 @@ export default {
mounted() {
},
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)
})
},
[CRUD.HOOK.beforeRefresh]() {
if (this.query.datepick) {
this.query.start_time = this.query.datepick[0]

View File

@@ -67,4 +67,14 @@ export function dismerge(data) {
data
})
}
export function exportFile(query) {
return request({
url: 'api/pmFormData/exportFile',
method: 'post',
data: query,
responseType: 'blob'
})
}
export default { add, edit, del, getParentFormTypes, getSonFormData, dismerge, tomerge, getdtl }

View File

@@ -109,6 +109,14 @@
>
{{ $t('wms.pm_manage.form_data2.cancel_merge') }}
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
size="mini"
@click="exportExcel"
>导出excel
</el-button>
</crudOperation>
<!--表格渲染-->
<el-table
@@ -147,7 +155,7 @@
</template>
<script>
import crudFormData from './formData'
import crudFormData, { exportFile } from './formData'
import CRUD, { crud, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation.vue'
import rrOperation from '@crud/RR.operation.vue'
@@ -191,6 +199,34 @@ export default {
mounted() {
},
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)
})
},
[CRUD.HOOK.beforeRefresh]() {
if (this.query.datepick) {
this.query.start_time = this.query.datepick[0]

View File

@@ -139,6 +139,14 @@
>
{{ $t('wms.st.inbill.force_confirm') }}
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
size="mini"
@click="exportExcel"
>导出excel
</el-button>
</crudOperation>
<!--表格渲染-->
<el-table
@@ -211,7 +219,7 @@
</template>
<script>
import rawAssist from '@/views/wms/st/inbill/rawassist'
import rawAssist, { exportFile } from '@/views/wms/st/inbill/rawassist'
import crudRawAssist from '@/views/wms/st/inbill/rawassist'
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
@@ -286,6 +294,43 @@ export default {
this.initQuery()
},
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`
if (this.query.createTime) {
this.query.start_time = this.query.createTime[0]
this.query.begin_time= this.query.createTime[0]
if (this.query.createTime.length > 1) {
this.query.end_time = this.query.createTime[1]
}
} else {
this.query.start_time = ''
this.query.end_time = ''
}
// 使用导入的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)
})
},
/* 搜索框创建时间默认最近一周*/
initQuery() {
const end = new Date()

View File

@@ -93,5 +93,14 @@ export function getInBillTaskDtl(data) {
})
}
export function exportFile(query) {
return request({
url: '/api/in/rawAssist/exportFile',
method: 'post',
data: query,
responseType: 'blob'
})
}
export default { add, edit, del, getIODtl, commit,
deleteDisDtl, getDisDtl, divStruct, unDivStruct, divPoint, confirm, getInBillTaskDtl }

View File

@@ -116,4 +116,13 @@ export function outReturn(data) {
})
}
export function exportFile(query) {
return request({
url: '/api/checkoutbill/exportFile',
method: 'post',
data: query,
responseType: 'blob'
})
}
export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, autoCancel, getStructIvt, manualDiv, confirm, allDivOne, getOutBillTask, oneCancel, allSetPoint, outReturn }

View File

@@ -142,6 +142,14 @@
>
{{ $t('wms.st.outbill.force_confirm') }}
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
size="mini"
@click="exportExcel"
>导出excel
</el-button>
</crudOperation>
<!--表格渲染-->
<el-table
@@ -210,7 +218,7 @@
</template>
<script>
import checkoutbill from '@/views/wms/st/outbill/checkoutbill'
import checkoutbill, { exportFile } from '@/views/wms/st/outbill/checkoutbill'
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
@@ -279,6 +287,43 @@ export default {
this.initQuery()
},
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`
if (this.query.createTime) {
this.query.start_time = this.query.createTime[0]
this.query.begin_time= this.query.createTime[0]
if (this.query.createTime.length > 1) {
this.query.end_time = this.query.createTime[1]
}
} else {
this.query.start_time = ''
this.query.end_time = ''
}
// 使用导入的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)
})
},
/* 搜索框创建时间默认最近一周*/
initQuery() {
const end = new Date()