Browse Source

[feat]

采购订单前端页面新增导出按钮,新增导出全部和导出选择的前端方法
新增 以供应商和物料为主要数据展示导出的采购订单Vo用于采购订单的导出
采购Controller层新增 导出采购订单子表列表和导出全部采购订单子表列表后端接口
采购订单新增 查询所有可用的采购订单数据后端方法;新增 通过采购订单号数组查询采购订单集合后端方法;新增处理需要导出的采购订单数据后端方法,实现通过使用map,处理采购订单号,绑定采购订单和采购订单子表的关系,然后填充生成 ExportPurchaseOrderVo 列表
采购订单子表新增 通过采购订单号集合查询采购订单子表列表后端方法
dev
liuxiaoxu 6 days ago
parent
commit
760a771670
  1. 36
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 23
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java
  3. 12
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java
  4. 90
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchaseOrderVo.java
  5. 11
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java
  6. 15
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java
  7. 23
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  8. 78
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  9. 8
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml
  10. 14
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml
  11. 69
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

36
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java

@ -11,6 +11,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.purchase.domain.*; import com.ruoyi.purchase.domain.*;
import com.ruoyi.purchase.domain.Vo.*; import com.ruoyi.purchase.domain.Vo.*;
@ -98,6 +99,41 @@ public class PurchaseOrderController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 导出全部采购订单子表列表
*/
@RequiresPermissions("purchase:purchaseOrderChild:export")
@Log(title = "采购订单子表", businessType = BusinessType.EXPORT)
@PostMapping("/exportAll")
@ResponseBody
public AjaxResult exportAll(PurchaseOrder purchaseOrder)
{
List<PurchaseOrder> list = purchaseOrderService.selectAllPurchaseOrderList(purchaseOrder);
List<ExportPurchaseOrderVo> exportPurchaseOrderVos = purchaseOrderService.getExportPurchaseOrderList(list);
ExcelUtil<ExportPurchaseOrderVo> util = new ExcelUtil<ExportPurchaseOrderVo>(ExportPurchaseOrderVo.class);
return util.exportExcel(exportPurchaseOrderVos, "采购订单数据");
}
/**
* 导出采购订单子表列表
*/
@RequiresPermissions("purchase:purchaseOrderChild:export")
@Log(title = "采购订单子表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(@RequestBody String[] purchaseOrderCodes)
{
List<PurchaseOrder> list = purchaseOrderService.selectPurchaseOrderChildListByCodes(purchaseOrderCodes);
List<ExportPurchaseOrderVo> exportPurchaseOrderVos = purchaseOrderService.getExportPurchaseOrderList(list);
ExcelUtil<ExportPurchaseOrderVo> util = new ExcelUtil<ExportPurchaseOrderVo>(ExportPurchaseOrderVo.class);
return util.exportExcel(exportPurchaseOrderVos, "采购订单数据");
}
/** /**
* *
* 导出采购订单合同 * 导出采购订单合同

23
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java

@ -2,6 +2,8 @@ package com.ruoyi.purchase.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -78,39 +80,30 @@ public class PurchaseOrder extends BaseEntity
/** 到货时间 */ /** 到货时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "到货时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date arrivedTime; private Date arrivedTime;
/** 仓库ID */ /** 仓库ID */
@Excel(name = "仓库ID")
private String stockNo; private String stockNo;
/** 仓库名称 */ /** 仓库名称 */
@Excel(name = "仓库名称")
private String stockName; private String stockName;
/** 收货人 */ /** 收货人 */
@Excel(name = "收货人")
private String receivePerson; private String receivePerson;
/** 收货电话 */ /** 收货电话 */
@Excel(name = "收货电话")
private String receivePersonPhone; private String receivePersonPhone;
/** 收货地址 */ /** 收货地址 */
@Excel(name = "收货地址")
private String receiveAddress; private String receiveAddress;
/** 采购员 */ /** 采购员 */
@Excel(name = "采购员")
private String purchaseBuyer; private String purchaseBuyer;
/** 使用状态 (0未使用,1使用,2已作废) */ /** 使用状态 (0未使用,1使用,2已作废) */
@Excel(name = "使用状态",dictType = "useStatus")
private String useStatus; private String useStatus;
/** 审核状态(0待审核、1审核通过、2审核拒绝) */ /** 审核状态(0待审核、1审核通过、2审核拒绝) */
@Excel(name = "审核状态",dictType = "auditStatus")
private String auditStatus; private String auditStatus;
/** 删除标志 */ /** 删除标志 */
@ -140,6 +133,9 @@ public class PurchaseOrder extends BaseEntity
/** 申请时间 */ /** 申请时间 */
private Date applyTime; private Date applyTime;
private List<PurchaseOrderChild> purchaseOrderChildList;
public void setPurchaseOrderId(Long purchaseOrderId) public void setPurchaseOrderId(Long purchaseOrderId)
{ {
this.purchaseOrderId = purchaseOrderId; this.purchaseOrderId = purchaseOrderId;
@ -438,6 +434,14 @@ public class PurchaseOrder extends BaseEntity
return applyTime; return applyTime;
} }
public List<PurchaseOrderChild> getPurchaseOrderChildList() {
return purchaseOrderChildList;
}
public void setPurchaseOrderChildList(List<PurchaseOrderChild> purchaseOrderChildList) {
this.purchaseOrderChildList = purchaseOrderChildList;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -478,6 +482,7 @@ public class PurchaseOrder extends BaseEntity
.append("applyTitle", getApplyTitle()) .append("applyTitle", getApplyTitle())
.append("applyUser", getApplyUser()) .append("applyUser", getApplyUser())
.append("applyTime", getApplyTime()) .append("applyTime", getApplyTime())
.append("purchaseOrderChildList", getPurchaseOrderChildList())
.toString(); .toString();
} }
} }

12
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java

@ -22,7 +22,6 @@ public class PurchaseOrderChild extends BaseEntity
private Long purchaseOrderChildId; private Long purchaseOrderChildId;
/** 采购订单号 */ /** 采购订单号 */
@Excel(name = "采购订单号")
private String purchaseOrderCode; private String purchaseOrderCode;
/** 料号 */ /** 料号 */
@ -34,11 +33,9 @@ public class PurchaseOrderChild extends BaseEntity
private String materialName; private String materialName;
/** 物料类型 */ /** 物料类型 */
@Excel(name = "物料类型")
private String materialType; private String materialType;
/** 物料图片地址 */ /** 物料图片地址 */
@Excel(name = "物料图片地址")
private String materialPhotourl; private String materialPhotourl;
/** 物料品牌 */ /** 物料品牌 */
@ -46,7 +43,7 @@ public class PurchaseOrderChild extends BaseEntity
private String materialBrand; private String materialBrand;
/** 物料单位 */ /** 物料单位 */
@Excel(name = "物料单位") @Excel(name = "物料单位", dictType = "sys_unit_class")
private String materialUnit; private String materialUnit;
/** 物料描述 */ /** 物料描述 */
@ -54,7 +51,7 @@ public class PurchaseOrderChild extends BaseEntity
private String materialDescribe; private String materialDescribe;
/** 物料加工方式 */ /** 物料加工方式 */
@Excel(name = "物料加工方式") @Excel(name = "物料加工方式", dictType = "processMethod")
private String materialProcessMethod; private String materialProcessMethod;
/** 物料型号 */ /** 物料型号 */
@ -62,15 +59,14 @@ public class PurchaseOrderChild extends BaseEntity
private String materialModel; private String materialModel;
/** 入库部门(0仓库、1采购) */ /** 入库部门(0仓库、1采购) */
@Excel(name = "入库部门(0仓库、1采购)")
private String warehouseDept; private String warehouseDept;
/** 物料不含税总价(RMB) */ /** 物料不含税总价(RMB) */
@Excel(name = "物料不含税总价(RMB)") @Excel(name = "物料不含税总价")
private BigDecimal materialNormbSum; private BigDecimal materialNormbSum;
/** 物料含税总价(RMB) */ /** 物料含税总价(RMB) */
@Excel(name = "物料含税总价(RMB)") @Excel(name = "物料含税总价")
private BigDecimal materialRmbSum; private BigDecimal materialRmbSum;
/** 计划采购数 */ /** 计划采购数 */

90
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchaseOrderVo.java

@ -0,0 +1,90 @@
package com.ruoyi.purchase.domain.Vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 以供应商和物料为主要数据展示导出的采购订单Vo
* */
@Data
public class ExportPurchaseOrderVo{
/** 采购订购单号 */
@Excel(name = "采购订购单号")
private String purchaseOrderCode;
/** 供应商ID */
@Excel(name = "供应商ID")
private String supplierCode;
/** 供应商名称 */
@Excel(name = "供应商名称")
private String supplierName;
/** 不含税总价(RMB) */
@Excel(name = "不含税总价(RMB)")
private BigDecimal noRmbSum;
/** 含税总价(RMB) */
@Excel(name = "含税总价(RMB)")
private BigDecimal rmbSum;
/** 料号 */
@Excel(name = "料号")
private String materialNo;
/** 物料名称 */
@Excel(name = "物料名称")
private String materialName;
/** 物料品牌 */
@Excel(name = "物料品牌")
private String materialBrand;
/** 物料单位 */
@Excel(name = "物料单位", dictType = "sys_unit_class")
private String materialUnit;
/** 物料描述 */
@Excel(name = "物料描述")
private String materialDescribe;
/** 物料加工方式 */
@Excel(name = "物料加工方式", dictType = "processMethod")
private String materialProcessMethod;
/** 物料型号 */
@Excel(name = "物料型号")
private String materialModel;
/** 物料不含税总价(RMB) */
@Excel(name = "物料不含税总价")
private BigDecimal materialNormbSum;
/** 物料含税总价(RMB) */
@Excel(name = "物料含税总价")
private BigDecimal materialRmbSum;
/** 计划采购数 */
@Excel(name = "计划采购数")
private Integer planPurchaseNum;
/** 实际采购数 */
@Excel(name = "实际采购数")
private Integer actualPurchaseNum;
/** 共享库存占用数 */
@Excel(name = "共享库存占用数")
private Integer sharedInventoryOccupancyNum;
/** 计划交付时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计划交付时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date planDeliveryTime;
}

11
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java

@ -29,6 +29,15 @@ public interface PurchaseOrderChildMapper
*/ */
public List<PurchaseOrderChild> selectPurchaseOrderChildList(PurchaseOrderChild purchaseOrderChild); public List<PurchaseOrderChild> selectPurchaseOrderChildList(PurchaseOrderChild purchaseOrderChild);
/**
* 通过采购订单号集合查询采购订单子表列表
*
* @param purchaseOrderCodes 采购订单号集合
* @return 采购订单子表集合
*/
List<PurchaseOrderChild> selectPurchaseOrderChildListByCodes(List<String> purchaseOrderCodes);
/** /**
* 新增采购订单子表 * 新增采购订单子表
* *
@ -120,4 +129,6 @@ public interface PurchaseOrderChildMapper
* 批量新增采购订单子表数据 * 批量新增采购订单子表数据
* */ * */
int batchInsertPurchaseOrderChild(List<PurchaseOrderChild> purchaseOrderChildren); int batchInsertPurchaseOrderChild(List<PurchaseOrderChild> purchaseOrderChildren);
} }

15
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java

@ -29,6 +29,20 @@ public interface PurchaseOrderMapper
*/ */
public List<PurchaseOrderVo> selectPurchaseOrderList(PurchaseOrder purchaseOrder); public List<PurchaseOrderVo> selectPurchaseOrderList(PurchaseOrder purchaseOrder);
/**
* 查询所有可用的采购订单数据
* */
List<PurchaseOrder> selectAllPurchaseOrderList(PurchaseOrder purchaseOrder);
/**
* 通过采购订单号数组查询采购订单集合
* */
List<PurchaseOrder> selectPurchaseOrderChildListByCodes(String[] purchaseOrderCodes);
/** /**
* 新增采购订单 * 新增采购订单
* *
@ -68,4 +82,5 @@ public interface PurchaseOrderMapper
PurchaseOrder selectPurchaseOrderByOrderCode(String purchaseOrderCode); PurchaseOrder selectPurchaseOrderByOrderCode(String purchaseOrderCode);
//校验采购订单编号是否唯一 //校验采购订单编号是否唯一
public Integer checkPurchaseOrderCodeUnique(String purchaseOrderCode); public Integer checkPurchaseOrderCodeUnique(String purchaseOrderCode);
} }

23
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java

@ -5,6 +5,7 @@ import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.domain.PurchaseOrderVo; import com.ruoyi.purchase.domain.PurchaseOrderVo;
import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.PurchasePlan;
import com.ruoyi.purchase.domain.Vo.AddPurchaseOrder; import com.ruoyi.purchase.domain.Vo.AddPurchaseOrder;
import com.ruoyi.purchase.domain.Vo.ExportPurchaseOrderVo;
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrder;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -37,6 +38,26 @@ public interface IPurchaseOrderService
*/ */
public List<PurchaseOrderVo> selectPurchaseOrderList(PurchaseOrder purchaseOrder); public List<PurchaseOrderVo> selectPurchaseOrderList(PurchaseOrder purchaseOrder);
/**
* 查询所有可用的采购订单数据
* */
List<PurchaseOrder> selectAllPurchaseOrderList(PurchaseOrder purchaseOrder);
/**
* 通过采购订单号数组查询采购订单集合
* */
List<PurchaseOrder> selectPurchaseOrderChildListByCodes(String[] purchaseOrderCodes);
/**
* 处理需要导出的采购订单数据
* */
List<ExportPurchaseOrderVo> getExportPurchaseOrderList(List<PurchaseOrder> list);
/** /**
* 新增采购订单 * 新增采购订单
* *
@ -105,4 +126,6 @@ public interface IPurchaseOrderService
* 采购计划添加采购订单 * 采购计划添加采购订单
* */ * */
int addPurchasePlanToPurchaseOrder(AddPurchaseOrder addPurchaseOrder); int addPurchasePlanToPurchaseOrder(AddPurchaseOrder addPurchaseOrder);
} }

78
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -228,6 +228,84 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
return returnList; return returnList;
} }
/**
* 查询所有可用的采购订单数据
* */
@Override
public List<PurchaseOrder> selectAllPurchaseOrderList(PurchaseOrder purchaseOrder) {
List<PurchaseOrder> purchaseOrderList = purchaseOrderMapper.selectAllPurchaseOrderList(purchaseOrder);
return purchaseOrderList;
}
/**
* 通过采购订单号数组查询采购订单集合
* */
@Override
public List<PurchaseOrder> selectPurchaseOrderChildListByCodes(String[] purchaseOrderCodes) {
List<PurchaseOrder> purchaseOrderList = purchaseOrderMapper.selectPurchaseOrderChildListByCodes(purchaseOrderCodes);
return purchaseOrderList;
}
/**
* 处理需要导出的采购订单数据
* */
@Override
public List<ExportPurchaseOrderVo> getExportPurchaseOrderList(List<PurchaseOrder> list) {
if (!CollectionUtils.isEmpty(list)){
List<String> purchaseOrderCodes = list.stream().map(PurchaseOrder::getPurchaseOrderCode).collect(Collectors.toList());
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildMapper.selectPurchaseOrderChildListByCodes(purchaseOrderCodes);
// 创建一个 map 用于快速查找主表数据
Map<String, PurchaseOrder> purchaseOrderMap = list.stream()
.collect(Collectors.toMap(PurchaseOrder::getPurchaseOrderCode, Function.identity()));
// 创建一个 map 用于快速查找子表数据
Map<String, List<PurchaseOrderChild>> purchaseOrderChildMap = purchaseOrderChildList.stream()
.collect(Collectors.groupingBy(PurchaseOrderChild::getPurchaseOrderCode));
// 生成 ExportPurchaseOrderVo 列表
List<ExportPurchaseOrderVo> exportPurchaseOrderVoList = new ArrayList<>();
for (String purchaseOrderCode : purchaseOrderCodes) {
PurchaseOrder purchaseOrder = purchaseOrderMap.get(purchaseOrderCode);
List<PurchaseOrderChild> children = purchaseOrderChildMap.getOrDefault(purchaseOrderCode, Collections.emptyList());
for (PurchaseOrderChild child : children) {
ExportPurchaseOrderVo exportPurchaseOrderVo = new ExportPurchaseOrderVo();
exportPurchaseOrderVo.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
exportPurchaseOrderVo.setSupplierName(purchaseOrder.getSupplierName());
exportPurchaseOrderVo.setSupplierCode(purchaseOrder.getSupplierCode());
exportPurchaseOrderVo.setNoRmbSum(purchaseOrder.getNoRmbSum());
exportPurchaseOrderVo.setRmbSum(purchaseOrder.getRmbSum());
// 填充子表数据
exportPurchaseOrderVo.setMaterialNo(child.getMaterialNo());
exportPurchaseOrderVo.setMaterialName(child.getMaterialName());
exportPurchaseOrderVo.setMaterialBrand(child.getMaterialBrand());
exportPurchaseOrderVo.setMaterialDescribe(child.getMaterialDescribe());
exportPurchaseOrderVo.setMaterialModel(child.getMaterialModel());
exportPurchaseOrderVo.setMaterialProcessMethod(child.getMaterialProcessMethod());
exportPurchaseOrderVo.setMaterialUnit(child.getMaterialUnit());
exportPurchaseOrderVo.setMaterialNormbSum(child.getMaterialNormbSum());
exportPurchaseOrderVo.setMaterialRmbSum(child.getMaterialRmbSum());
exportPurchaseOrderVo.setPlanPurchaseNum(child.getPlanPurchaseNum());
exportPurchaseOrderVo.setActualPurchaseNum(child.getActualPurchaseNum());
exportPurchaseOrderVo.setSharedInventoryOccupancyNum(child.getSharedInventoryOccupancyNum());
exportPurchaseOrderVo.setPlanDeliveryTime(child.getPlanDeliveryTime());
exportPurchaseOrderVoList.add(exportPurchaseOrderVo);
}
}
return exportPurchaseOrderVoList;
}
return Collections.emptyList();
}
/** /**
* 新增采购订单 * 新增采购订单
* *

8
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml

@ -45,6 +45,14 @@
where purchase_order_child_id = #{purchaseOrderChildId} where purchase_order_child_id = #{purchaseOrderChildId}
</select> </select>
<select id="selectPurchaseOrderChildListByCodes" parameterType="String" resultMap="PurchaseOrderChildResult">
<include refid="selectPurchaseOrderChildVo"/>
where purchase_order_code in
<foreach collection="list" item="purchaseOrderCode" open="(" separator="," close=")">
#{purchaseOrderCode}
</foreach>
</select>
<insert id="insertPurchaseOrderChild" parameterType="PurchaseOrderChild" useGeneratedKeys="true" keyProperty="purchaseOrderChildId"> <insert id="insertPurchaseOrderChild" parameterType="PurchaseOrderChild" useGeneratedKeys="true" keyProperty="purchaseOrderChildId">
insert into purchase_order_child insert into purchase_order_child
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

14
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml

@ -66,6 +66,20 @@
where purchase_order_id = #{purchaseOrderId} where purchase_order_id = #{purchaseOrderId}
</select> </select>
<select id="selectAllPurchaseOrderList" parameterType="PurchaseOrder" resultMap="PurchaseOrderResult">
<include refid="selectPurchaseOrderVo"/>
where audit_status = '1' and use_status = '1'
</select>
<select id="selectPurchaseOrderChildListByCodes" parameterType="String" resultMap="PurchaseOrderResult">
<include refid="selectPurchaseOrderVo"/>
where purchase_order_code in
<foreach collection="array" item="purchaseOrderCode" open="(" separator="," close=")">
#{purchaseOrderCode}
</foreach>
</select>
<insert id="insertPurchaseOrder" parameterType="PurchaseOrder" useGeneratedKeys="true" keyProperty="purchaseOrderId"> <insert id="insertPurchaseOrder" parameterType="PurchaseOrder" useGeneratedKeys="true" keyProperty="purchaseOrderId">
insert into purchase_order insert into purchase_order
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

69
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

@ -56,16 +56,7 @@
</div> </div>
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="purchase:purchaseOrder:add"> <a class="btn btn-success" onclick="exportExcel()" shiro:hasPermission="purchase:purchaseOrder:export">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="purchase:purchaseOrder:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="purchase:purchaseOrder:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="purchase:purchaseOrder:export">
<i class="fa fa-download"></i> 导出 <i class="fa fa-download"></i> 导出
</a> </a>
</div> </div>
@ -214,6 +205,64 @@
}; };
$.table.init(options); $.table.init(options);
}); });
// 导出
function exportExcel(formId) {
// $.table.set();
var purchaseOrderCodeData = [];
var selections = $("#bootstrap-table").bootstrapTable("getSelections");
if(selections.length === 0){
$.modal.confirm("确定导出所有采购订单吗?", function() {
var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
var params = $("#bootstrap-table").bootstrapTable('getOptions');
var dataParam = $("#" + currentId).serializeArray();
dataParam.push({ "name": "orderByColumn", "value": params.sortName });
dataParam.push({ "name": "isAsc", "value": params.sortOrder });
$.modal.loading("正在导出数据,请稍后...");
$.post(prefix + '/exportAll', dataParam, function(result) {
if (result.code == web_status.SUCCESS) {
window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
} else if (result.code == web_status.WARNING) {
$.modal.alertWarning(result.msg)
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
});
});
}else {
$.modal.confirm("确定导出选中的所有采购订单吗?", function () {
//·拼接单号
for(let i=0;i<selections.length;i++){
purchaseOrderCodeData.push(selections[i].purchaseOrderCode);
}
var purchaseOrderCodes = JSON.stringify(purchaseOrderCodeData);
// console.log(bomNos);
$.modal.loading("正在导出数据,请稍后...");
var config = {
url: prefix + '/export',
type: "post",
dataType: "json",
contentType: "application/json;charset=utf-8",
data: purchaseOrderCodes,
success: function(result) {
window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
$.modal.alertSuccess("导出成功!")
$.modal.closeLoading();
},
error: function (result){
$.modal.alertError(result.msg);
}
};
$.ajax(config)
});
}
};
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save