| | |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.service.NodeService; |
| | | import zy.cloud.wms.manager.utils.NodeUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class NodeController extends BaseController { |
| | |
| | | @RequestMapping(value = "/node/add/auth") |
| | | @ManagerAuth |
| | | public R add(Node node) { |
| | | if (node.getType() != 1) { |
| | | Node parentNode = nodeService.selectById(node.getParentId()); |
| | | if (parentNode == null || parentNode.getStatus() == 0) { |
| | | return R.error(node.getType()==2?"所属仓库不存在":"所属库区不存在"); |
| | | } |
| | | node.setParentName(parentNode.getName()); |
| | | node.setLevel(parentNode.getLevel() + 1); |
| | | } |
| | | // path |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(node); |
| | | node.setPath(nodeUtils.path.toString()); |
| | | node.setNamePath(nodeUtils.pathName.toString()); |
| | | |
| | | node.setLevel(node.getType()); |
| | | node.setCreateBy(getUserId()); |
| | | node.setCreateTime(new Date()); |
| | | node.setUpdateBy(getUserId()); |
| | | node.setUpdateTime(new Date()); |
| | | node.setStatus(1); |
| | | nodeService.insert(node); |
| | | return R.ok(); |
| | | } |
| | |
| | | if (Cools.isEmpty(node) || null==node.getId()){ |
| | | return R.error(); |
| | | } |
| | | if (node.getType() != 1) { |
| | | Node parentNode = nodeService.selectById(node.getParentId()); |
| | | if (parentNode == null || parentNode.getStatus() == 0) { |
| | | return R.error(node.getType()==2?"所属仓库不存在":"所属库区不存在"); |
| | | } |
| | | node.setParentName(parentNode.getName()); |
| | | node.setLevel(parentNode.getLevel() + 1); |
| | | } |
| | | // path |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(node); |
| | | node.setPath(nodeUtils.path.toString()); |
| | | node.setNamePath(nodeUtils.pathName.toString()); |
| | | |
| | | node.setUpdateBy(getUserId()); |
| | | node.setUpdateTime(new Date()); |
| | | nodeService.updateById(node); |
| | | return R.ok(); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/parent/node/group") |
| | | public R getParentNodeGroup(@RequestParam(required = false) String condition, |
| | | @RequestParam Integer type) { |
| | | List<Node> nodes = nodeService.selectList(new EntityWrapper<Node>().eq("type", type).eq("status", 1)); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Node node : nodes) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("key", node.getId()); |
| | | map.put("val", node.getName()); |
| | | result.add(map); |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | public interface NodeService extends IService<Node> { |
| | | |
| | | |
| | | String getPathName(Node node); |
| | | |
| | | } |
| | |
| | | @Service("nodeService") |
| | | public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements NodeService { |
| | | |
| | | @Override |
| | | public String getPathName(Node node) { |
| | | if (node.getParentId() != null) { |
| | | Node node1 = selectById(node.getParentId()); |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package zy.cloud.wms.manager.utils; |
| | | |
| | | import com.core.common.SpringUtils; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.service.NodeService; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/1/19 |
| | | */ |
| | | public class NodeUtils { |
| | | |
| | | public StringBuilder path = new StringBuilder(); |
| | | |
| | | public StringBuilder pathName = new StringBuilder(); |
| | | |
| | | public void executePath(Node node) { |
| | | NodeService bean = SpringUtils.getBean(NodeService.class); |
| | | Node parent = bean.selectById(node.getParentId()); |
| | | if (null != parent) { |
| | | path.insert(0, parent.getId()).insert(0,","); |
| | | pathName.insert(0, parent.getName()).insert(0,","); |
| | | if (parent.getParentId() != null) { |
| | | executePath(parent); |
| | | } else { |
| | | path.deleteCharAt(0); |
| | | pathName.deleteCharAt(0); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | var pageCurr; |
| | | |
| | | getParentNode(); |
| | | function getParentNode(el) { |
| | | http.post(baseUrl + "/parent/node/group", {type: 2}, function (res) { |
| | | if (res.data != null) { |
| | | var tpl = $("#parentNodeGroup").html(); |
| | | var template = Handlebars.compile(tpl); |
| | | var html = template(res); |
| | | $('#parentId').append(html); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/node/list/auth', |
| | | page: true, |
| | | where: {type: 2}, |
| | | where: {type: 3}, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | even: true, |
| | |
| | | ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'name', align: 'center',title: '仓库名称'} |
| | | // ,{field: 'parentId', align: 'center',title: '父级'} |
| | | // ,{field: 'parentName', align: 'center',title: '父级名称'} |
| | | ,{field: 'parentName', align: 'center',title: '所属库区'} |
| | | // ,{field: 'type$', align: 'center',title: '类型'} |
| | | // ,{field: 'path', align: 'center',title: '关联路径'} |
| | | // ,{field: 'namePath', align: 'center',title: '关联路径名'} |
| | |
| | | type: 3, |
| | | path: $('#path').val(), |
| | | namePath: $('#namePath').val(), |
| | | level: 3, |
| | | level: $('#level').val(), |
| | | leading: $('#leading').val(), |
| | | sort: $('#sort').val(), |
| | | barcode: $('#barcode').val(), |
| | |
| | | var pageCurr; |
| | | var tableIns; |
| | | |
| | | getParentNode(); |
| | | function getParentNode(el) { |
| | | http.post(baseUrl + "/parent/node/group", {type: 1}, function (res) { |
| | | if (res.data != null) { |
| | | var tpl = $("#parentNodeGroup").html(); |
| | | var template = Handlebars.compile(tpl); |
| | | var html = template(res); |
| | | $('#parentId').append(html); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | {type: 'checkbox'} |
| | | // ,{field: 'id', align: 'center',title: 'ID'} |
| | | ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'name', align: 'center',title: '仓库名称'} |
| | | ,{field: 'name', align: 'center',title: '库区名称'} |
| | | // ,{field: 'parentId', align: 'center',title: '父级'} |
| | | // ,{field: 'parentName', align: 'center',title: '父级名称'} |
| | | ,{field: 'parentName', align: 'center',title: '所属仓库'} |
| | | // ,{field: 'type$', align: 'center',title: '类型'} |
| | | // ,{field: 'path', align: 'center',title: '关联路径'} |
| | | // ,{field: 'namePath', align: 'center',title: '关联路径名'} |
| | |
| | | type: 'datetime' |
| | | }); |
| | | |
| | | |
| | | }); |
| | | |
| | | |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // layui select 默认赋值 |
| | | function setOption(el, value) { |
| | | el.siblings("div.layui-form-select").find('dl').find('dd[lay-value=' + value + ']').click(); |
| | | } |
| | |
| | | <input class="layui-input" type="text" name="name" placeholder="仓库名称" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <select id="parentId" name="parent_id" lay-search=""> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <!-- 待添加 --> |
| | | <div id="data-search-btn" class="layui-btn-container layui-form-item"> |
| | | <button id="search" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">搜索</button> |
| | |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> |
| | | <script type="text/javascript" src="../../static/js/allo/allo.js" charset="utf-8"></script> |
| | | |
| | | <iframe id="detail-iframe" scrolling="auto" style="display:none;"></iframe> |
| | | |
| | | </body> |
| | | <script type="text/template" id="parentNodeGroup"> |
| | | <option value="">选择库区</option> |
| | | {{#each data}} |
| | | <option value="{{this.key}}">{{this.val}}</option> |
| | | {{/each}} |
| | | </script> |
| | | </html> |
| | | |
| | |
| | | <input id="name" class="layui-input" type="text" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline" style="width:31%;;display: none"> |
| | | <label class="layui-form-label">父 级:</label> |
| | | <div class="layui-inline" style="width:85%;"> |
| | | <label class="layui-form-label form-required">所属库区:</label> |
| | | <div class="layui-input-inline"> |
| | | <input id="parentId" class="layui-input" type="text" lay-verify="number" > |
| | | <select id="parentId" lay-verify="required" lay-search=""> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="layui-inline" style="width:31%;;display: none">--> |
| | | <!-- <label class="layui-form-label">父 级:</label>--> |
| | | <!-- <div class="layui-input-inline">--> |
| | | <!-- <input id="parentId" class="layui-input" type="text" lay-verify="number" >--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | <div class="layui-inline" style="width:31%;;display: none"> |
| | | <label class="layui-form-label">父级名称:</label> |
| | | <div class="layui-input-inline"> |
| | |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> |
| | | <script type="text/javascript" src="../../static/js/allo/allo.js" charset="utf-8"></script> |
| | | <script type="text/template" id="parentNodeGroup"> |
| | | <option value="">选择库区</option> |
| | | {{#each data}} |
| | | <option value="{{this.key}}">{{this.val}}</option> |
| | | {{/each}} |
| | | </script> |
| | | </html> |
| | | |
| | |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/common.css" media="all"> |
| | | <style> |
| | | .layui-form-select dl { |
| | | max-height: 200px; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | | |
| | |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="name" placeholder="仓库名称" autocomplete="off"> |
| | | <input class="layui-input" type="text" name="name" placeholder="库区名称" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <select id="parentId" name="parent_id" lay-search=""> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <!-- 待添加 --> |
| | |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> |
| | | <script type="text/javascript" src="../../static/js/area/area.js" charset="utf-8"></script> |
| | | |
| | | <iframe id="detail-iframe" scrolling="auto" style="display:none;"></iframe> |
| | | |
| | | </body> |
| | | <script type="text/template" id="parentNodeGroup"> |
| | | <option value="">选择仓库</option> |
| | | {{#each data}} |
| | | <option value="{{this.key}}">{{this.val}}</option> |
| | | {{/each}} |
| | | </script> |
| | | </html> |
| | | |
| | |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/common.css" media="all"> |
| | | <style> |
| | | .layui-form-select dl { |
| | | max-height: 200px; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | | |
| | |
| | | <div class="layui-inline" style="width:85%;"> |
| | | <label class="layui-form-label form-required">编号:</label> |
| | | <div class="layui-input-inline"> |
| | | <input id="uuid" class="layui-input" type="text" autocomplete="off"> |
| | | <input id="uuid" class="layui-input" type="text" autocomplete="off" lay-verify="required"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline" style="width:85%;"> |
| | | <label class="layui-form-label form-required">名称:</label> |
| | | <div class="layui-input-inline"> |
| | | <input id="name" class="layui-input" type="text" autocomplete="off"> |
| | | <input id="name" class="layui-input" type="text" autocomplete="off" lay-verify="required"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline" style="width:31%;;display: none"> |
| | | <label class="layui-form-label">父 级:</label> |
| | | <div class="layui-inline" style="width:85%;"> |
| | | <label class="layui-form-label form-required">所属仓库:</label> |
| | | <div class="layui-input-inline"> |
| | | <input id="parentId" class="layui-input" type="text" lay-verify="number" > |
| | | <select id="parentId" lay-verify="required" lay-search=""> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="layui-inline" style="width:31%;;display: none">--> |
| | | <!-- <label class="layui-form-label">父 级:</label>--> |
| | | <!-- <div class="layui-input-inline">--> |
| | | <!-- <input id="parentId" class="layui-input" type="text" lay-verify="number" >--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | <div class="layui-inline" style="width:31%;;display: none"> |
| | | <label class="layui-form-label">父级名称:</label> |
| | | <div class="layui-input-inline"> |
| | |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> |
| | | <script type="text/javascript" src="../../static/js/area/area.js" charset="utf-8"></script> |
| | | <script type="text/template" id="parentNodeGroup"> |
| | | <option value="">选择仓库</option> |
| | | {{#each data}} |
| | | <option value="{{this.key}}">{{this.val}}</option> |
| | | {{/each}} |
| | | </script> |
| | | </html> |
| | | |