给商品库存调用统计导出接口
This commit is contained in:
@@ -6,7 +6,8 @@ const api = {
|
|||||||
role: '/api/role',
|
role: '/api/role',
|
||||||
service: '/api/service',
|
service: '/api/service',
|
||||||
permission: '/api/permission',
|
permission: '/api/permission',
|
||||||
permissionNoPager: '/api/permission/no-pager'
|
permissionNoPager: '/api/permission/no-pager',
|
||||||
|
exportExcelByParam: '/systemConfig/exportExcelByParam'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
@@ -108,37 +109,23 @@ export function downFile(url,parameter){
|
|||||||
return axios({
|
return axios({
|
||||||
url: url,
|
url: url,
|
||||||
params: parameter,
|
params: parameter,
|
||||||
method:'get' ,
|
method: 'get',
|
||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载文件
|
* 下载文件 用于excel导出
|
||||||
* @param url 文件路径
|
* @param url
|
||||||
* @param fileName 文件名
|
|
||||||
* @param parameter
|
* @param parameter
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export function downloadFile(url, fileName, parameter) {
|
export function downFilePost(parameter){
|
||||||
return downFile(url, parameter).then((data) => {
|
return axios({
|
||||||
if (!data || data.size === 0) {
|
url: api.exportExcelByParam,
|
||||||
Vue.prototype['$message'].warning('文件下载失败')
|
data: parameter,
|
||||||
return
|
method: 'post',
|
||||||
}
|
responseType: 'blob'
|
||||||
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对象
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
|
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
|
||||||
*/
|
*/
|
||||||
import { filterObj,getNowFormatStr } from '@/utils/util';
|
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 Vue from 'vue'
|
||||||
import VueDraggableResizable from 'vue-draggable-resizable'
|
import VueDraggableResizable from 'vue-draggable-resizable'
|
||||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
||||||
@@ -293,6 +293,7 @@ export const JeecgListMixin = {
|
|||||||
let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
|
let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
},
|
},
|
||||||
|
//通过get方式导出Excel
|
||||||
handleExportXls(fileName){
|
handleExportXls(fileName){
|
||||||
if(!fileName || typeof fileName != "string"){
|
if(!fileName || typeof fileName != "string"){
|
||||||
fileName = "导出文件"
|
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){
|
handleImportExcel(info){
|
||||||
this.confirmLoading = true
|
this.confirmLoading = true
|
||||||
|
|||||||
@@ -130,7 +130,7 @@
|
|||||||
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
||||||
import { getAction, getFileAccessHttpUrl } from '@/api/manage'
|
import { getAction, getFileAccessHttpUrl } from '@/api/manage'
|
||||||
import {queryMaterialCategoryTreeList} from '@/api/api'
|
import {queryMaterialCategoryTreeList} from '@/api/api'
|
||||||
import { getMpListShort, openDownloadDialog, sheet2blob} from "@/utils/util"
|
import { getMpListShort } from "@/utils/util"
|
||||||
import JEllipsis from '@/components/jeecg/JEllipsis'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
@@ -287,14 +287,17 @@
|
|||||||
this.$refs.materialInOutList.disableSubmit = false;
|
this.$refs.materialInOutList.disableSubmit = false;
|
||||||
},
|
},
|
||||||
exportExcel() {
|
exportExcel() {
|
||||||
let aoa = [['条码', '名称', '规格', '型号', '颜色', '类别', '单位', '单价', '初始库存', '库存', '库存金额', '重量']]
|
let list = []
|
||||||
|
let head = '条码, 名称, 规格, 型号, 颜色, 类别, 单位, 单价, 初始库存, 库存, 库存金额, 重量'
|
||||||
for (let i = 0; i < this.dataSource.length; i++) {
|
for (let i = 0; i < this.dataSource.length; i++) {
|
||||||
|
let item = []
|
||||||
let ds = this.dataSource[i]
|
let ds = this.dataSource[i]
|
||||||
let item = [ds.mBarCode, ds.name, ds.standard, ds.model, ds.color, ds.categoryName, ds.unitName,
|
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]
|
ds.purchaseDecimal, ds.initialStock, ds.currentStock, ds.currentStockPrice, ds.currentWeight)
|
||||||
aoa.push(item)
|
list.push(item)
|
||||||
}
|
}
|
||||||
openDownloadDialog(sheet2blob(aoa), '商品库存')
|
let tip = '商品库存查询'
|
||||||
|
this.handleExportXlsPost('商品库存', '商品库存', head, tip, list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user