| | |
| | | |
| | | private int total = 0; |
| | | private Long userId; |
| | | private Long hostId; |
| | | |
| | | public MatExcelListener() { |
| | | } |
| | | |
| | | public MatExcelListener(Long userId) { |
| | | public MatExcelListener(Long userId, Long hostId) { |
| | | this.userId = userId; |
| | | this.hostId = hostId; |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!Cools.isEmpty(excel.getPriClass()) && !Cools.isEmpty(excel.getSecClass())) { |
| | | Tag priTag = tagService.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getName, excel.getPriClass()).eq(Tag::getLevel, 2)); |
| | | if (priTag == null) { |
| | | Tag top = tagService.getTop(); |
| | | Tag top = tagService.getTop(hostId); |
| | | NodeUtils nodeUtils = new NodeUtils(); |
| | | nodeUtils.executePath(top.getId()); |
| | | priTag = new Tag( |
| | |
| | | } |
| | | tagId = secTag.getId(); |
| | | } else { |
| | | tagId = tagService.getTop().getId(); |
| | | tagId = tagService.getTop(hostId).getId(); |
| | | } |
| | | // 商品 |
| | | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, excel.getMatnr())); |
| | |
| | | /** |
| | | * 获取树图数据结构 |
| | | */ |
| | | @Cacheable(cacheNames="tagTree",key="#id") |
| | | public ArrayList<Map> getTree(String id){ |
| | | @Cacheable(cacheNames = "tagTree", key = "#id") |
| | | public ArrayList<Map> getTree(Long id, Long hostId) { |
| | | ArrayList<Map> result = new ArrayList<>(); |
| | | Tag tag = tagService.getById(id); |
| | | Tag tag = tagService.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getId, id).eq(Tag::getHostId, hostId)); |
| | | // 主节点 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("title", tag.getName()); |
| | |
| | | List<Tag> tags = tagService.list( |
| | | new LambdaQueryWrapper<Tag>() |
| | | .eq(Tag::getParentId, parent.getId()) |
| | | .eq(Tag::getStatus, "1")); |
| | | .eq(Tag::getStatus, 1)); |
| | | for (Tag tag : tags) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("title", tag.getName()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 递归获取节点以及子节点数据 |
| | | */ |
| | | public void getTagIdList(Long id, List<Long> nodes) { |
| | | if (!nodes.contains(id)) { |
| | | nodes.add(id); |
| | | } |
| | | List<Tag> tags = tagService.list(new LambdaQueryWrapper<Tag>().eq(Tag::getParentId, id).eq(Tag::getStatus, 1)); |
| | | for (Tag tag : tags) { |
| | | if (!nodes.contains(tag.getId())) { |
| | | nodes.add(tag.getId()); |
| | | } |
| | | getTagIdList(tag.getId(), nodes); |
| | | } |
| | | } |
| | | |
| | | |
| | | // ------------------------------------------------------------------------------------------------------- |
| | | |
| | |
| | | } |
| | | |
| | | protected Tag getOriginTag(){ |
| | | return tagService.getTop(); |
| | | return tagService.getTop(getHostId()); |
| | | } |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | /** |
| | | * 仓库ID |
| | | */ |
| | | @ApiModelProperty(value= "仓库ID") |
| | | private Long hostId; |
| | | |
| | | public Mat() {} |
| | | |
| | | public Mat(String uuid, Long tagId, String matnr, String maktx, String name, String specs, String model, String color, String brand, String unit, Double price, String sku, Double units, String barcode, String origin, String manu, String manuDate, String itemNum, Double safeQty, Double weight, Double length, Double volume, String threeCode, String supp, String suppCode, Integer beBatch, String deadTime, Integer deadWarn, Integer source, Integer inspect, Integer danger, Integer status, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo) { |
| | |
| | | TagService tagService = SpringUtils.getBean(TagService.class); |
| | | Tag tag = tagService.getById(this.tagId); |
| | | if (!Cools.isEmpty(tag)){ |
| | | return String.valueOf(tag.getId()); |
| | | return String.valueOf(tag.getName()); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | /** |
| | | * 仓库ID |
| | | */ |
| | | @ApiModelProperty(value= "仓库ID") |
| | | private Long hostId; |
| | | |
| | | public Tag() {} |
| | | |
| | | public Tag(String uuid, String name, Long parentId, String parentName, String path, String pathName, Integer type, String leading, String img, String brief, Integer count, Integer level, Integer sort, Integer status, Date createTime, Long createBy, Date updateTime, Long updateBy, String memo) { |
| | |
| | | |
| | | public interface TagService extends IService<Tag> { |
| | | |
| | | Tag getTop(); |
| | | Tag getTop(Long hostId); |
| | | |
| | | } |
| | |
| | | public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements TagService { |
| | | |
| | | @Override |
| | | public synchronized Tag getTop() { |
| | | Tag top = this.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getLevel, 1)); |
| | | public synchronized Tag getTop(Long hostId) { |
| | | Tag top = this.getOne(new LambdaQueryWrapper<Tag>().eq(Tag::getLevel, 1).eq(Tag::getHostId, hostId)); |
| | | if (top == null) { |
| | | top = new Tag(); |
| | | top.setName("全部"); |
| | |
| | | top.setLevel(1); |
| | | top.setStatus(1); |
| | | top.setSort(0); |
| | | top.setHostId(hostId); |
| | | Integer insert = this.baseMapper.insert(top); |
| | | if (insert == 0) { |
| | | throw new CoolException("服务器异常"); |
| | |
| | | package com.zy.asrs.wms.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.common.utils.TreeUtils; |
| | | import com.zy.asrs.common.wms.entity.Mat; |
| | | import com.zy.asrs.common.wms.service.MatService; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | |
| | | import com.zy.asrs.framework.domain.KeyValueVo; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private TreeUtils treeUtils; |
| | | |
| | | @RequestMapping(value = "/mat/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | public R page(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam(required = false) String timeRange) { |
| | | @RequestParam(required = false) String timeRange, |
| | | @RequestParam Map<String, Object> param) { |
| | | LambdaQueryWrapper<Mat> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Mat::getHostId, getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(Mat::getId, condition); |
| | | } |
| | |
| | | wrapper.ge(Mat::getCreateTime, DateUtils.convert(range[0])); |
| | | wrapper.le(Mat::getCreateTime, DateUtils.convert(range[1])); |
| | | } |
| | | Object tagId = param.get("tag_id"); |
| | | ArrayList<Long> nodes = new ArrayList<>(); |
| | | if (Cools.isEmpty(tagId)) { |
| | | tagId = getOriginTag().getId(); |
| | | } |
| | | treeUtils.getTagIdList(Long.parseLong(tagId.toString()), nodes); |
| | | wrapper.in(Mat::getTagId, nodes); |
| | | if (!Cools.isEmpty(param.get("matnr"))) { |
| | | wrapper.eq(Mat::getMatnr, param.get("matnr")); |
| | | } |
| | | if (!Cools.isEmpty(param.get("maktx"))) { |
| | | wrapper.eq(Mat::getMaktx, param.get("maktx")); |
| | | } |
| | | return R.ok(matService.page(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/mat/add/auth") |
| | | @ManagerAuth |
| | | public R add(Mat mat) { |
| | | mat.setHostId(getHostId()); |
| | | matService.save(mat); |
| | | return R.ok(); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/mat/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | matService.removeById(id); |
| | | public R delete(@RequestParam String param){ |
| | | List<Mat> list = JSONArray.parseArray(param, Mat.class); |
| | | if (Cools.isEmpty(list)){ |
| | | return R.error(); |
| | | } |
| | | for (Mat entity : list){ |
| | | if (!matService.remove(new LambdaQueryWrapper<>(entity))) { |
| | | throw new CoolException("删除失败,请联系管理员"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | public R query(String condition) { |
| | | LambdaQueryWrapper<Mat> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.like(Mat::getId, condition); |
| | | wrapper.eq(Mat::getHostId, getHostId()); |
| | | Page<Mat> page = matService.page(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Mat mat : page.getRecords()){ |
| | |
| | | public R getDataKV(@RequestParam(required = false) String condition) { |
| | | List<KeyValueVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<Mat> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Mat::getHostId, getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(Mat::getId, condition); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/tag/page/auth") |
| | | @ManagerAuth |
| | | public R page(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam(required = false) String timeRange) { |
| | | public R page(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | Long hostId = getHostId(); |
| | | LambdaQueryWrapper<Tag> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(Tag::getId, condition); |
| | | } |
| | | if (!Cools.isEmpty(timeRange)) { |
| | | String[] range = timeRange.split(RANGE_TIME_LINK); |
| | | wrapper.ge(Tag::getCreateTime, DateUtils.convert(range[0])); |
| | | wrapper.le(Tag::getCreateTime, DateUtils.convert(range[1])); |
| | | } |
| | | return R.ok(tagService.page(new Page<>(curr, limit), wrapper)); |
| | | wrapper.eq(Tag::getHostId, hostId); |
| | | excludeTrash(param); |
| | | return R.parse("0-操作成功").add(tagService.list(wrapper)); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/tag/add/auth") |
| | | @ManagerAuth |
| | | public R add(Tag tag) { |
| | | tag.setHostId(getHostId()); |
| | | tag.setStatus(1); |
| | | tagService.save(tag); |
| | | return R.ok(); |
| | | } |
| | |
| | | @PostMapping(value = "/tag/tree/auth") |
| | | @ManagerAuth |
| | | public R tree(@RequestParam(required = false, defaultValue = "") String condition) throws IOException, ClassNotFoundException { |
| | | ArrayList<Map> tree = treeUtils.getTree(String.valueOf(getOriginTag().getId())); |
| | | ArrayList<Map> tree = treeUtils.getTree(getOriginTag().getId(), getHostId()); |
| | | // 深拷贝 |
| | | List<Map> result = ListUtils.deepCopy(tree); |
| | | if (!Cools.isEmpty(condition)) { |
| | |
| | | @ManagerAuth(memo = "商品档案数据导入") |
| | | @Transactional |
| | | public R matExcelImport(MultipartFile file) throws IOException { |
| | | MatExcelListener listener = new MatExcelListener(getUserId()); |
| | | MatExcelListener listener = new MatExcelListener(getUserId(), getHostId()); |
| | | EasyExcel.read(file.getInputStream(), MatExcel.class, listener).sheet().doRead(); |
| | | return R.ok("成功同步"+listener.getTotal()+"条商品数据"); |
| | | } |
| | |
| | | var pageCount = 0; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['table','laydate', 'form', 'admin', 'xmSelect'], function(){ |
| | | var table = layui.table; |
| | | }).use(['treeTable','laydate', 'form', 'admin', 'xmSelect'], function(){ |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | var xmSelect = layui.xmSelect; |
| | | var table = layui.treeTable; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | |
| | | height: 'full-120', |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | ,{field: 'id', align: 'center',title: 'ID'} |
| | | ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'name', align: 'center',title: '名称'} |
| | | ,{field: 'parentId', align: 'center',title: '父级'} |
| | | ,{field: 'parentName', align: 'center',title: '父级名称'} |
| | | ,{field: 'path', align: 'center',title: '关联路径'} |
| | | ,{field: 'pathName', align: 'center',title: '关联路径名'} |
| | | ,{type: 'numbers'} |
| | | ,{field: 'name', align: 'left',title: '名称', minWidth: 150} |
| | | // ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'type$', align: 'center',title: '类型'} |
| | | ,{field: 'leading', align: 'center',title: '负责人'} |
| | | ,{field: 'img', align: 'center',title: '图片'} |
| | | ,{field: 'brief', align: 'center',title: '简要描述'} |
| | | ,{field: 'count', align: 'center',title: '数量'} |
| | | ,{field: 'level', align: 'center',title: '等级'} |
| | | ,{field: 'img', align: 'center',title: '图片', hide: true} |
| | | // ,{field: 'brief', align: 'center',title: '简要描述'} |
| | | // ,{field: 'count', align: 'center',title: '数量'} |
| | | ,{field: 'sort', align: 'center',title: '排序'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'createTime$', align: 'center',title: '添加时间'} |
| | | ,{field: 'createBy$', align: 'center',title: '添加人员'} |
| | | ,{field: 'updateTime$', align: 'center',title: '修改时间'} |
| | | ,{field: 'updateBy$', align: 'center',title: '修改人员'} |
| | | ,{field: 'memo', align: 'center',title: '备注'} |
| | | ,{field: 'updateBy$', align: 'center',title: '修改人员', hide: true} |
| | | ,{field: 'memo', align: 'center',title: '备注', hide: true} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | |
| | | form.val('detail', mData); |
| | | layDateRender(mData); |
| | | form.on('submit(editSubmit)', function (data) { |
| | | data.field.parentId = insXmSel.getValue('valueStr'); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/tag/"+(mData?'update':'add')+"/auth", |
| | |
| | | }) |
| | | return false; |
| | | }); |
| | | // 渲染下拉树 |
| | | var insXmSel = xmSelect.render({ |
| | | el: '#tagParentSel', |
| | | height: '250px', |
| | | data: tableIns.options.data, |
| | | initValue: mData ? [mData.parentId] : [], |
| | | model: {label: {type: 'text'}}, |
| | | prop: { |
| | | name: 'name', |
| | | value: 'id' |
| | | }, |
| | | radio: true, |
| | | clickClose: true, |
| | | tree: { |
| | | show: true, |
| | | indent: 15, |
| | | strict: false, |
| | | expandedKeys: false |
| | | } |
| | | }); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <style> |
| | | #detail { |
| | | padding: 25px 30px 0 0; |
| | | } |
| | | .ew-tree-table-box { |
| | | height: 100%; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | | |
| | | <!-- 正文开始 --> |
| | | <div class="layui-fluid"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <div class="layui-form toolbar" id="search-box"> |
| | | <div class="layui-form-item"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline" style="width: 300px"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input layui-laydate-range" name="timeRange" type="text" placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline">  |
| | | <button class="layui-btn icon-btn" lay-filter="search" lay-submit> |
| | | <i class="layui-icon"></i>搜索 |
| | | </button> |
| | | <button class="layui-btn icon-btn" lay-filter="reset" lay-submit> |
| | | <i class="layui-icon"></i>重置 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <table class="layui-hide" id="tag" lay-filter="tag"></table> |
| | | <!-- 数据表格 --> |
| | | <table id="tag"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">新增</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">删除</button> |
| | | <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right">导出</button> |
| | | </div> |
| | | </script> |
| | | |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-del" lay-event="del">删除</a> |
| | | </script> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <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/tag/tag.js" charset="utf-8"></script> |
| | | </body> |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="editDialog"> |
| | | <div id="detail" lay-filter="detail" class="layui-form admin-form model-form"> |
| | | <form id="detail" lay-filter="detail" class="layui-form"> |
| | | <input name="id" type="hidden"> |
| | | <input name="uuid" type="hidden"> |
| | | <input name="path" type="hidden"> |
| | | <input name="pathName" type="hidden"> |
| | | <input name="img" type="hidden"> |
| | | <input name="brief" type="hidden"> |
| | | <input name="level" type="hidden"> |
| | | <input name="count" type="hidden"> |
| | | <input name="createTime$" type="hidden"> |
| | | <input name="createBy" type="hidden"> |
| | | <input name="updateTime$" type="hidden"> |
| | | <input name="updateBy" type="hidden"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md12"> |
| | | |
| | | <div class="layui-col-md6"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">编号: </label> |
| | | <label class="layui-form-label">上级菜单</label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="uuid" placeholder="请输入编号"> |
| | | <div id="tagParentSel" class="ew-xmselect-tree"></div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">名称: </label> |
| | | <label class="layui-form-label">类型</label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="name" placeholder="请输入名称"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">父级: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="parentId" placeholder="请输入父级"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">父级名称: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="parentName" placeholder="请输入父级名称"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">关联路径: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="path" placeholder="请输入关联路径"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">关联路径名: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="pathName" placeholder="请输入关联路径名"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">类型: </label> |
| | | <div class="layui-input-block"> |
| | | <select name="type"> |
| | | <select name="type" lay-vertype="tips"> |
| | | <option value="">请选择类型</option> |
| | | <option value="1">盒装</option> |
| | | <option value="2">袋装</option> |
| | | <option value="0">其他</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">负责人: </label> |
| | | <label class="layui-form-label">负责人</label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="leading" placeholder="请输入负责人"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">图片: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="img" placeholder="请输入图片"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">简要描述: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="brief" placeholder="请输入简要描述"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">数量: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="count" placeholder="请输入数量"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">等级: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="level" placeholder="请输入等级"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">排序: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="sort" placeholder="请输入排序"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">状态: </label> |
| | | <div class="layui-input-block"> |
| | | <select name="status"> |
| | | <option value="">请选择状态</option> |
| | | <option value="1">正常</option> |
| | | <option value="0">禁用</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">添加时间: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="createTime" id="createTime$" placeholder="请输入添加时间"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">添加人员: </label> |
| | | <div class="layui-input-block cool-auto-complete"> |
| | | <input class="layui-input" name="createBy" placeholder="请输入添加人员" style="display: none"> |
| | | <input id="createBy$" name="createBy$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="请输入添加人员" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="userQueryBycreateBy" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="userQueryBycreateBySelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">修改时间: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="updateTime" id="updateTime$" placeholder="请输入修改时间"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">修改人员: </label> |
| | | <div class="layui-input-block cool-auto-complete"> |
| | | <input class="layui-input" name="updateBy" placeholder="请输入修改人员" style="display: none"> |
| | | <input id="updateBy$" name="updateBy$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="请输入修改人员" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="userQueryByupdateBy" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="userQueryByupdateBySelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">备注: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="memo" placeholder="请输入备注"> |
| | | <input name="leading" placeholder="请输入负责人" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-col-md6"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">归类名称</label> |
| | | <div class="layui-input-block"> |
| | | <input name="name" placeholder="请输入归类名称" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">排序</label> |
| | | <div class="layui-input-block"> |
| | | <input name="sort" placeholder="请输入排序" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">备注</label> |
| | | <div class="layui-input-block"> |
| | | <input name="memo" placeholder="请输入备注" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | </script> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <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> |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['form','treeTable', 'admin', 'xmSelect'], function() { |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | var treeTable = layui.treeTable; |
| | | var xmSelect = layui.xmSelect; |
| | | var tbDataList = []; |
| | | |
| | | var insTb = treeTable.render({ |
| | | elem: '#tag', |
| | | url: baseUrl+'/tag/page/auth', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | height: 'full-200', |
| | | toolbar: ['<p>', |
| | | '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon"></i>添加</button> ', |
| | | '<button lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon"></i>删除</button>', |
| | | '</p>'].join(''), |
| | | tree: { |
| | | iconIndex: 2, // 折叠图标显示在第几列 |
| | | isPidData: true, // 是否是id、pid形式数据 |
| | | idName: 'id', // id字段名称 |
| | | pidName: 'parentId' // pid字段名称 |
| | | }, |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | ,{type: 'numbers'} |
| | | ,{field: 'name', align: 'left',title: '名称', minWidth: 150} |
| | | // ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'type$', align: 'center',title: '类型'} |
| | | ,{field: 'leading', align: 'center',title: '负责人'} |
| | | ,{field: 'img', align: 'center',title: '图片', hide: true} |
| | | // ,{field: 'brief', align: 'center',title: '简要描述'} |
| | | // ,{field: 'count', align: 'center',title: '数量'} |
| | | ,{field: 'sort', align: 'center',title: '排序'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'updateTime$', align: 'center',title: '修改时间'} |
| | | ,{field: 'updateBy$', align: 'center',title: '修改人员', hide: true} |
| | | ,{field: 'memo', align: 'center',title: '备注', hide: true} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | done: function (data) { |
| | | $('.ew-tree-table-box').css('height', '100%'); |
| | | insTb.expandAll(); |
| | | tbDataList = data; |
| | | } |
| | | }); |
| | | |
| | | /* 表格头工具栏点击事件 */ |
| | | treeTable.on('toolbar(tag)', function (obj) { |
| | | if (obj.event === 'add') { // 添加 |
| | | showEditModel(); |
| | | } else if (obj.event === 'del') { // 删除 |
| | | var checkRows = insTb.checkStatus(); |
| | | if (checkRows.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | var ids = checkRows.map(function (d) { |
| | | if (!d.LAY_INDETERMINATE) { |
| | | return d.id; |
| | | } else { |
| | | return null; |
| | | } |
| | | }); |
| | | doDel({ids: ids}); |
| | | } |
| | | }); |
| | | |
| | | /* 表格操作列点击事件 */ |
| | | treeTable.on('tool(tag)', function (obj) { |
| | | if (obj.event === 'edit') { // 修改 |
| | | showEditModel(obj.data); |
| | | } else if (obj.event === 'del') { // 删除 |
| | | doDel(obj); |
| | | } |
| | | }); |
| | | |
| | | /* 显示表单弹窗 */ |
| | | function showEditModel(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '600px', |
| | | title: (mData ? '修改' : '添加') + '归类', |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | // 回显表单数据 |
| | | form.val('detail', mData); |
| | | // 表单提交事件 |
| | | form.on('submit(editSubmit)', function (data) { |
| | | data.field.parentId = insXmSel.getValue('valueStr'); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/tag/"+(mData?'update':'add')+"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.refresh(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | return false; |
| | | }); |
| | | // 渲染下拉树 |
| | | console.log(mData) |
| | | var insXmSel = xmSelect.render({ |
| | | el: '#tagParentSel', |
| | | height: '250px', |
| | | data: insTb.options.data, |
| | | initValue: mData ? [mData.parentId] : [], |
| | | model: {label: {type: 'text'}}, |
| | | prop: { |
| | | name: 'name', |
| | | value: 'id' |
| | | }, |
| | | radio: true, |
| | | clickClose: true, |
| | | tree: { |
| | | show: true, |
| | | indent: 15, |
| | | strict: false, |
| | | expandedKeys: false |
| | | } |
| | | }); |
| | | // 弹窗不出现滚动条 |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /* 删除 */ |
| | | function doDel(obj) { |
| | | layer.confirm('确定要删除选中数据吗?', { |
| | | skin: 'layui-layer-admin', |
| | | shade: .1 |
| | | }, function (i) { |
| | | layer.close(i); |
| | | var loadIndex = layer.load(2); |
| | | var ids; |
| | | if (obj.data) { |
| | | ids = []; |
| | | ids[0] = obj.data.id; |
| | | } else { |
| | | ids = obj.ids; |
| | | } |
| | | $.ajax({ |
| | | url: baseUrl+"/tag/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: ids}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.refresh(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | </script> |
| | | </body> |
| | | </html> |
| | | |