给商品库存调用统计导出接口
This commit is contained in:
@@ -6,7 +6,8 @@ const api = {
|
||||
role: '/api/role',
|
||||
service: '/api/service',
|
||||
permission: '/api/permission',
|
||||
permissionNoPager: '/api/permission/no-pager'
|
||||
permissionNoPager: '/api/permission/no-pager',
|
||||
exportExcelByParam: '/systemConfig/exportExcelByParam'
|
||||
}
|
||||
|
||||
export default api
|
||||
@@ -114,31 +115,17 @@ export function downFile(url,parameter){
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @param url 文件路径
|
||||
* @param fileName 文件名
|
||||
* 下载文件 用于excel导出
|
||||
* @param url
|
||||
* @param parameter
|
||||
* @returns {*}
|
||||
*/
|
||||
export function downloadFile(url, fileName, parameter) {
|
||||
return downFile(url, parameter).then((data) => {
|
||||
if (!data || data.size === 0) {
|
||||
Vue.prototype['$message'].warning('文件下载失败')
|
||||
return
|
||||
}
|
||||
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
||||
window.navigator.msSaveBlob(new Blob([data]), fileName)
|
||||
} else {
|
||||
let url = window.URL.createObjectURL(new Blob([data]))
|
||||
let link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = url
|
||||
link.setAttribute('download', fileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link) //下载完成移除元素
|
||||
window.URL.revokeObjectURL(url) //释放掉blob对象
|
||||
}
|
||||
export function downFilePost(parameter){
|
||||
return axios({
|
||||
url: api.exportExcelByParam,
|
||||
data: parameter,
|
||||
method: 'post',
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
|
||||
*/
|
||||
import { filterObj,getNowFormatStr } from '@/utils/util';
|
||||
import { deleteAction, getAction, postAction, downFile, getFileAccessHttpUrl } from '@/api/manage'
|
||||
import { deleteAction, getAction, postAction, downFile, downFilePost, getFileAccessHttpUrl } from '@/api/manage'
|
||||
import Vue from 'vue'
|
||||
import VueDraggableResizable from 'vue-draggable-resizable'
|
||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
||||
@@ -293,6 +293,7 @@ export const JeecgListMixin = {
|
||||
let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
|
||||
window.location.href = url;
|
||||
},
|
||||
//通过get方式导出Excel
|
||||
handleExportXls(fileName){
|
||||
if(!fileName || typeof fileName != "string"){
|
||||
fileName = "导出文件"
|
||||
@@ -322,6 +323,33 @@ export const JeecgListMixin = {
|
||||
}
|
||||
})
|
||||
},
|
||||
//通过post方式导出Excel
|
||||
handleExportXlsPost(fileName, title, head, tip, list) {
|
||||
if(!fileName || typeof fileName != "string"){
|
||||
fileName = "导出文件"
|
||||
}
|
||||
let paramObj = {'title': title, 'head': head, 'tip': tip, 'list': list}
|
||||
console.log("导出参数", paramObj)
|
||||
downFilePost(paramObj).then((data)=>{
|
||||
if (!data) {
|
||||
this.$message.warning("文件下载失败")
|
||||
return
|
||||
}
|
||||
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
||||
window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
|
||||
}else{
|
||||
let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
|
||||
let link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = url
|
||||
link.setAttribute('download', fileName + '_' + getNowFormatStr()+'.xls')
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link); //下载完成移除元素
|
||||
window.URL.revokeObjectURL(url); //释放掉blob对象
|
||||
}
|
||||
})
|
||||
},
|
||||
/* 导入 */
|
||||
handleImportExcel(info){
|
||||
this.confirmLoading = true
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
||||
import { getAction, getFileAccessHttpUrl } from '@/api/manage'
|
||||
import {queryMaterialCategoryTreeList} from '@/api/api'
|
||||
import { getMpListShort, openDownloadDialog, sheet2blob} from "@/utils/util"
|
||||
import { getMpListShort } from "@/utils/util"
|
||||
import JEllipsis from '@/components/jeecg/JEllipsis'
|
||||
import moment from 'moment'
|
||||
import Vue from 'vue'
|
||||
@@ -287,14 +287,17 @@
|
||||
this.$refs.materialInOutList.disableSubmit = false;
|
||||
},
|
||||
exportExcel() {
|
||||
let aoa = [['条码', '名称', '规格', '型号', '颜色', '类别', '单位', '单价', '初始库存', '库存', '库存金额', '重量']]
|
||||
let list = []
|
||||
let head = '条码, 名称, 规格, 型号, 颜色, 类别, 单位, 单价, 初始库存, 库存, 库存金额, 重量'
|
||||
for (let i = 0; i < this.dataSource.length; i++) {
|
||||
let item = []
|
||||
let ds = this.dataSource[i]
|
||||
let item = [ds.mBarCode, ds.name, ds.standard, ds.model, ds.color, ds.categoryName, ds.unitName,
|
||||
ds.purchaseDecimal, ds.initialStock, ds.currentStock, ds.currentStockPrice, ds.currentWeight]
|
||||
aoa.push(item)
|
||||
item.push(ds.mBarCode, ds.name, ds.standard, ds.model, ds.color, ds.categoryName, ds.unitName,
|
||||
ds.purchaseDecimal, ds.initialStock, ds.currentStock, ds.currentStockPrice, ds.currentWeight)
|
||||
list.push(item)
|
||||
}
|
||||
openDownloadDialog(sheet2blob(aoa), '商品库存')
|
||||
let tip = '商品库存查询'
|
||||
this.handleExportXlsPost('商品库存', '商品库存', head, tip, list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user