日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringBoot+MyBatisPlus+DataTables实现退货管理的添加和编辑时控制checkbox的回显选中

發布時間:2025/3/19 javascript 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot+MyBatisPlus+DataTables实现退货管理的添加和编辑时控制checkbox的回显选中 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

場景

SpringBoot+My BatisPlus+DataTables實現企業車間退貨管理(學習企業級開發思想):

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/93190690

在上面實現退貨管理的基礎上,詳解編輯時的邏輯控制和編輯時的回顯checkbox選中。

效果

實現

實體類的擴展類新增IsSelected屬性,標識不良品貨位是否被選中。

package com.ws.bus.sys.vo.BusGoodsLocationVO;import com.ws.bus.sys.entity.BusGoodsLocation; import lombok.Data;import java.util.Date;@Data public class BusGoodsLocationVO extends BusGoodsLocation {private String locationTypeName;private String shelveName;private String materielStatus;private String materielStatusName;private Integer materielNum;//是否是編輯操作private Integer editFlag;//選中要查詢的車間倉庫private String selected;private Integer tdNum;private Integer trNum;//當前不良品貨位是否被選中private Integer isSelected = 0;private Date productDate;private String trayNumber;private Integer maxTrayAmount;private Integer refundOrderFlag; }

分析編輯時的mapper.xml文件

<select id="getPageRejectsLocations" resultMap="busGoodsLocationVOMap"parameterType="com.ws.bus.sys.vo.BusGoodsLocationVO.BusGoodsLocationVO">SELECT location.id,location.goods_location_number, code.code_name location_type_name,shelve.shelves_nameshelve_name,tm.materiel_name save_material_type_name ,sc.code_name materiel_status_name,lt.refund_order_flagFROM bus_location_tray ltLEFT JOIN bus_goods_location location on location.id = lt.location_idLEFT JOIN sys_code code on code.code_type = 'location_type' and code.code_value = location.goods_location_typeLEFT JOIN bus_goods_shelves shelve on shelve.id = location.wh_shelves_idLEFT JOIN sys_code sc on sc.code_type = 'materielCheckStatus' and sc.code_value = lt.materiel_check_statusLEFT JOIN (SELECT DISTINCT tray_id,materiel_nameFROM bus_tray_materielWHERE deleted_flag = '0') tm on tm.tray_id = lt.tray_idWHERE lt.materiel_check_status = 3 and lt.deleted_flag = 0<if test="locationVO != null and locationVO.editFlag == 0">and lt.refund_order_flag = 0</if><if test="locationVO != null and locationVO.selected != null">and location.goods_location_number like? CONCAT(#{locationVO.selected},'%')</if></select>

注:

1.層級關系為:

倉庫--庫區--貨架--貨位--托盤--物料

2.bus_goods_location
貨位表? 的id等于 bus_location_tray 的location_id? 關聯碼表 貨位表類型分為正常貨位和不良品貨位

3.bus_location_tray
貨位-托盤綁定關系表

4.bus_goods_shelves
貨架表

貨架表的Id 等于 貨位表的 wh_shelves_id 歸屬貨架字段

關聯碼表 貨位表的物料檢驗狀態 為1正常 2不良品暫估 3不良品4待檢
查詢物料檢驗狀態為3即不良品的

5.關聯
bus_tray_materiel
托盤-物料綁定關系表,去重查一條

托盤的id 等于貨位表的tray_id

6.條件
貨位表的編號是不是以傳遞過來的A B C D 開頭

如果是新增則 貨位-托盤綁定關系表 的 refund_order_flag 是否已生成退貨單(1-是 0 -否) 為0

?

新增與編輯判斷邏輯

1.新增時要查詢相應倉庫的下的所有不良品貨位,且沒有生成出庫單的。

所以在mapper中

?

<if test="locationVO != null and locationVO.editFlag == 0">and lt.refund_order_flag = 0</if>

來控制實現。

2.編輯時需要查詢相應倉庫的所有不良品貨位下的,當前退貨單對應的不良品以及 當前倉庫下對應的不良品貨位。目的是

為了實現修改退貨單的不良品貨位。

?

后臺判斷邏輯實現

?//當編輯操作id存在時,表明是編輯操作if (vo.getEditActionId() != null && vo.getEditActionId() != 0) {page = locationService.pageRejectsLocations(refundOrderPage, vo, 1,wareNum);//查詢出當前退貨單下的所有明細QueryWrapper<WmsRefundOrderDetails> refundOrderDetailsQueryWrapper = new QueryWrapper<>();refundOrderDetailsQueryWrapper.eq("refund_id", vo.getEditActionId()).eq("deleted_flag", "0");List<WmsRefundOrderDetails> refundOrderDetails = refundOrderDetailsService.list(refundOrderDetailsQueryWrapper);for (BusGoodsLocationVO locationVO : page.getRecords()) {for (WmsRefundOrderDetails details : refundOrderDetails) {if (details.getGoodsLocationId().equals(locationVO.getId())) {locationVO.setIsSelected(1);break;}}}//刪除非此退貨單對應的貨位Iterator<BusGoodsLocationVO> iterator = page.getRecords().iterator();while(iterator.hasNext()){BusGoodsLocationVO locationVO = iterator.next();if (locationVO.getRefundOrderFlag() == 1 && locationVO.getIsSelected() == 0) {iterator.remove();}}} else {page = locationService.pageRejectsLocations(refundOrderPage, vo, 0,wareNum);}

注:

1.在編輯時根據選中的退貨單的id,查詢到當前退貨單對應的不良品貨位,然后將其IsSelected屬性設置為1。

2.然后通過上面的mapper語句在編輯時查詢出所有的退貨單的不良品,然后通過下面的迭代器刪除已經生成出庫單且isSelected屬性為0的(即其它退貨單對應的不良品貨位刪除掉),這樣就能保證將當前退貨單對應的選中的不良品以及當前倉庫下的不良品在編輯時都能查詢出來。

JS中控制DataTables選中回顯

columns: [{ data: 'id' ,"orderable" : false},{ data: 'goodsLocationNumber' },{ data: 'locationTypeName' ,"orderable" : false},{ data: 'saveMaterialTypeName' ,"orderable" : false},{ data: 'materielStatusName',"orderable" : false},{ data: 'shelveName' ,"orderable" : false},{ data: 'remark',"orderable" : false }],columnDefs: [{//?? 指定第1列,從0開始,0表示第一列,1表示第二列……"targets": 0,"bSortable": false,"render": function(data, type, row, meta) {if (row.isSelected == 1){return '<input type="checkbox" class="checkchild" onclick="childClick(this)" checked="checked" value="' + row.id + '" />'}return '<input type="checkbox" class="checkchild" onclick="childClick(this)" value="' + row.id + '" />'}}],

?

總結

以上是生活随笔為你收集整理的SpringBoot+MyBatisPlus+DataTables实现退货管理的添加和编辑时控制checkbox的回显选中的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。