opt:导出功能优化
This commit is contained in:
@@ -5,22 +5,29 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.pm_manage.service.IPmFormDataService;
|
||||
import org.nl.wms.pm_manage.service.dao.PmFormData;
|
||||
import org.nl.wms.pm_manage.service.dto.PmFormDataParam;
|
||||
import org.nl.wms.pm_manage.service.dto.FormDataQuery;
|
||||
import org.nl.wms.pm_manage.service.dto.PmFormDataDto;
|
||||
import org.nl.wms.pm_manage.service.dto.PmFormDataParam;
|
||||
import org.nl.wms.system_manage.service.columnInfo.ColumnInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
/**
|
||||
* <p>
|
||||
@@ -33,11 +40,15 @@ import java.util.stream.Collectors;
|
||||
@RestController
|
||||
@RequestMapping("/api/pmFormData")
|
||||
@SaIgnore
|
||||
@Slf4j
|
||||
public class PmFormDataController {
|
||||
|
||||
@Autowired
|
||||
private IPmFormDataService iPmFormDataService;
|
||||
|
||||
@Autowired
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
|
||||
|
||||
@GetMapping()
|
||||
@@ -136,7 +147,33 @@ public class PmFormDataController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/exportFile")
|
||||
public void exportFile(@RequestBody FormDataQuery query, HttpServletResponse response) {
|
||||
PageQuery page = new PageQuery();
|
||||
page.setPage(0);
|
||||
page.setSize(99999);
|
||||
IPage<PmFormDataDto> pmFormDataDtoIPage = iPmFormDataService.queryTree(query, page);
|
||||
List<PmFormDataDto> pmFormDataDtos = pmFormDataDtoIPage.getRecords();
|
||||
|
||||
List<Map> maps = pmFormDataDtos.stream().map(pmFormDataDto -> {
|
||||
try {
|
||||
return BeanUtils.describe(pmFormDataDto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
try {
|
||||
columnInfoService.exportFile("pm_form_data", maps, response,
|
||||
null, MapOf.of(
|
||||
"material_code","物料编号","material_name","物料名称","net_weight","物料净重"
|
||||
)
|
||||
);
|
||||
} catch (IOException e) {
|
||||
log.info("EXCEL 导出异常,异常原因=【{}】",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
package org.nl.wms.warehouse_manage.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.system_manage.service.columnInfo.ColumnInfoService;
|
||||
import org.nl.wms.warehouse_manage.service.IOutBillService;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
@@ -25,6 +35,9 @@ public class OutBillController {
|
||||
@Resource
|
||||
private IOutBillService iOutBillService;
|
||||
|
||||
@Resource
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询出库单")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) {
|
||||
@@ -143,5 +156,32 @@ public class OutBillController {
|
||||
public ResponseEntity<Object> getOutBillTask(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(iOutBillService.getOutBillTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/exportFile")
|
||||
public void exportFile(@RequestBody Map whereJson, PageQuery page,String[] stor_id, String[] bill_status, String[] bill_type, HttpServletResponse response) {
|
||||
page.setPage(0);
|
||||
page.setSize(99999);
|
||||
IPage<IOStorInvDto> ioStorInvIPage = iOutBillService.pageQuery(whereJson, page, stor_id, bill_status, bill_type);
|
||||
List<IOStorInvDto> ioStorInvs = ioStorInvIPage.getRecords();
|
||||
|
||||
List<Map> maps = ioStorInvs.stream().map(ioStorInv -> {
|
||||
try {
|
||||
// BeanUtils.describe() 会把 JavaBean 转成 Map(key 是属性名,value 是属性值)
|
||||
return BeanUtils.describe(ioStorInv);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
try {
|
||||
columnInfoService.exportFile("st_ivt_iostorinv", maps, response,
|
||||
null,
|
||||
MapOf.of(
|
||||
"material_code","物料编号","material_name","物料名称"
|
||||
));
|
||||
} catch (IOException e) {
|
||||
log.info("EXCEL 导出异常,异常原因=【{}】",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
package org.nl.wms.warehouse_manage.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.system_manage.service.columnInfo.ColumnInfoService;
|
||||
import org.nl.wms.warehouse_manage.service.IRawAssistIStorService;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
@@ -27,6 +37,9 @@ public class RawAssistIStorController {
|
||||
@Resource
|
||||
private IRawAssistIStorService iRawAssistIStorService;
|
||||
|
||||
@Resource
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询入库单据")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
@@ -112,4 +125,34 @@ public class RawAssistIStorController {
|
||||
public ResponseEntity<Object> getInBillTaskDtl(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(iRawAssistIStorService.getInBillTaskDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/exportFile")
|
||||
public void exportFile(@RequestBody Map whereJson, HttpServletResponse response) {
|
||||
PageQuery page = new PageQuery();
|
||||
page.setPage(0);
|
||||
page.setSize(99999);
|
||||
IPage<IOStorInvDto> ioStorInvIPage = iRawAssistIStorService.pageQuery(whereJson, page);
|
||||
List<IOStorInvDto> ioStorInvs = ioStorInvIPage.getRecords();
|
||||
|
||||
List<Map> maps = ioStorInvs.stream().map(ioStorInv -> {
|
||||
try {
|
||||
// BeanUtils.describe() 会把 JavaBean 转成 Map(key 是属性名,value 是属性值)
|
||||
return BeanUtils.describe(ioStorInv);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
try {
|
||||
columnInfoService.exportFile("st_ivt_iostorinv", maps, response,
|
||||
null,
|
||||
MapOf.of(
|
||||
"material_code","物料编号","material_name","物料名称"
|
||||
));
|
||||
} catch (IOException e) {
|
||||
log.info("EXCEL 导出异常,异常原因=【{}】",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.warehouse_manage.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDisDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDtlDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,7 +26,7 @@ public interface IOutBillService extends IService<IOStorInv> {
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type);
|
||||
IPage<IOStorInvDto> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type);
|
||||
|
||||
/**
|
||||
* 获取可用库存物料
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.nl.wms.warehouse_manage.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_manage.service.dto.GroupPlateDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDisDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDtlDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,7 +27,7 @@ public interface IRawAssistIStorService extends IService<IOStorInv> {
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page);
|
||||
IPage<IOStorInvDto> pageQuery(Map whereJson, PageQuery page);
|
||||
|
||||
IPage<GroupPlateDto> getBillDtl(Map whereJson, PageQuery page);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.warehouse_manage.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_manage.service.dto.GroupPlateDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDtlDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -18,7 +19,7 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface IOStorInvMapper extends BaseMapper<IOStorInv> {
|
||||
|
||||
IPage<IOStorInv> queryAllByPage (IPage<IOStorInv> page,@Param("params") Map whereJson);
|
||||
IPage<IOStorInvDto> queryAllByPage (IPage<IOStorInv> page, @Param("params") Map whereJson);
|
||||
|
||||
IPage<GroupPlateDto> getGroupPlate (IPage<GroupPlateDto> page, @Param("params") Map whereJson);
|
||||
|
||||
@@ -26,6 +27,6 @@ public interface IOStorInvMapper extends BaseMapper<IOStorInv> {
|
||||
|
||||
List<IOStorInvDtlDto> getIODtl (@Param("params") Map whereJson);
|
||||
|
||||
IPage<IOStorInv> queryOutBillPage (IPage<IOStorInv> page,@Param("params") Map whereJson);
|
||||
IPage<IOStorInvDto> queryOutBillPage (IPage<IOStorInv> page,@Param("params") Map whereJson);
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.nl.wms.warehouse_manage.service.dao.mapper.IOStorInvDtlMapper;
|
||||
import org.nl.wms.warehouse_manage.service.dao.mapper.IOStorInvMapper;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDisDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDtlDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -111,7 +112,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) {
|
||||
public IPage<IOStorInvDto> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) {
|
||||
HashMap<String, String> map = new HashMap<>(whereJson);
|
||||
|
||||
if (StrUtil.isNotEmpty(map.get("bill_code"))) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.nl.wms.warehouse_manage.service.dao.mapper.IOStorInvMapper;
|
||||
import org.nl.wms.warehouse_manage.service.dto.GroupPlateDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDisDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDtlDto;
|
||||
import org.nl.wms.warehouse_manage.service.dto.IOStorInvDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -96,7 +97,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
||||
private IPmFormDataService iPmFormDataService;
|
||||
|
||||
@Override
|
||||
public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page) {
|
||||
public IPage<IOStorInvDto> pageQuery(Map whereJson, PageQuery page) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("stor_id", (String) whereJson.get("stor_id"));
|
||||
map.put("bill_type", (String) whereJson.get("bill_type"));
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user