13 files added
11 files modified
| | |
| | | <swagger.ui>2.9.2</swagger.ui> |
| | | <tomcat.version>9.0.31</tomcat.version> |
| | | <hutool.version>5.3.1</hutool.version> |
| | | <aliyun-oss.version>3.8.0</aliyun-oss.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.aliyun.oss</groupId> |
| | | <artifactId>aliyun-sdk-oss</artifactId> |
| | | <version>${aliyun-oss.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>${hutool.version}</version> |
New file |
| | |
| | | package cc.mrbird.febs.common.utils; |
| | | |
| | | import com.aliyun.oss.OSS; |
| | | import com.aliyun.oss.OSSClientBuilder; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import sun.misc.BASE64Decoder; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | |
| | | @Slf4j |
| | | public class OssUtils { |
| | | |
| | | private static String END_POINT = "https://oss-cn-hangzhou.aliyuncs.com"; |
| | | private static String ACCESS_KEY_ID = "LTAI4GBuydqbJ5bTsDP97Lpd"; |
| | | private static String ACCESS_KEY_SECRET = "vbCjQtPxABWjqtUlQfzjlA0qAY96fh"; |
| | | private static String bucket_name = "https://excoin.oss-cn-hangzhou.aliyuncs.com"; |
| | | |
| | | public static boolean uploadFileWithBase64(String base64, String pathName) { |
| | | ByteArrayInputStream stream = null; |
| | | try { |
| | | OSS ossClient = new OSSClientBuilder().build(END_POINT, ACCESS_KEY_ID,ACCESS_KEY_SECRET); |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | byte[] bytes = decoder.decodeBuffer(base64); |
| | | stream = new ByteArrayInputStream(bytes); |
| | | ossClient.putObject("excoin", pathName, stream); |
| | | return true; |
| | | } catch (Exception e) { |
| | | log.error("#上传失败:{}#", e); |
| | | return false; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.controller; |
| | | |
| | | |
| | | import cc.mrbird.febs.common.annotation.ControllerEndpoint; |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.utils.OssUtils; |
| | | import cc.mrbird.febs.mall.dto.AddMallGoodsDto; |
| | | import cc.mrbird.febs.mall.entity.MallGoods; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsService; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Validated |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping(value = "/admin/goods") |
| | | public class AdminMallGoodsController extends BaseController { |
| | | |
| | | private final IAdminMallGoodsService adminMallGoodsService; |
| | | |
| | | /** |
| | | * 图片上传 |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/uploadFileBase64") |
| | | @ControllerEndpoint(operation = "图片上传", exceptionMessage = "上传失败") |
| | | public Map<String,Object> uploadFileBase64(@RequestBody @Validated MultipartFile file) { |
| | | if (file.isEmpty()) { |
| | | new FebsResponse().message("上传文件为空"); |
| | | } |
| | | |
| | | //文件加密 |
| | | BASE64Encoder base64Encoder =new BASE64Encoder(); |
| | | String base64EncoderImg = null; |
| | | try { |
| | | base64EncoderImg = base64Encoder.encode(file.getBytes()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String imageFuffix = ".png"; |
| | | String imageNames = System.currentTimeMillis() + IdUtil.simpleUUID() + imageFuffix; |
| | | String imageName = "uploadeFile/" + imageNames; |
| | | OssUtils.uploadFileWithBase64(base64EncoderImg, imageName); |
| | | String bucket_name ="https://excoin.oss-cn-hangzhou.aliyuncs.com"; |
| | | String url = bucket_name + "/" + imageName; |
| | | |
| | | Map<String,Object> map = new HashMap<String,Object>(); |
| | | Map<String,Object> map2 = new HashMap<String,Object>(); |
| | | map.put("code",0);//0表示成功,1失败 |
| | | map.put("msg","上传成功");//提示消息 |
| | | map.put("data",map2); |
| | | map2.put("src",url);//图片url |
| | | map2.put("title",imageNames);//图片名称,这个会显示在输入框里 |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 商品列表 |
| | | * @param mallGoods |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("goodsList") |
| | | public FebsResponse getGoodsList(MallGoods mallGoods, QueryRequest request) { |
| | | Map<String, Object> data = getDataTable(adminMallGoodsService.getCategoryListInPage(mallGoods, request)); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | | /** |
| | | * 商品-新增 |
| | | */ |
| | | @PostMapping("addMallGoods") |
| | | @ControllerEndpoint(operation = " 商品-新增", exceptionMessage = "新增失败") |
| | | public FebsResponse addMallGoods(@RequestBody @Valid AddMallGoodsDto addMallGoodsDto) { |
| | | return adminMallGoodsService.addMallGoods(addMallGoodsDto); |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsConstant; |
| | | import cc.mrbird.febs.common.utils.FebsUtil; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsCategoryService; |
| | | import cc.mrbird.febs.mall.service.IAdminMallMemberService; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsCategoryVo; |
| | | import cc.mrbird.febs.mall.vo.MallGoodsCategoryVo; |
| | | import cc.mrbird.febs.mall.vo.MallMemberVo; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | @Controller("categoryView") |
| | | @RequestMapping(FebsConstant.VIEW_PREFIX + "modules/product") |
| | | @RequiredArgsConstructor |
| | | public class ViewMallGoodsCategoryController extends BaseController { |
| | | |
| | | private final IAdminMallGoodsCategoryService mallGoodsCategoryService; |
| | | |
| | | /** |
| | | * 商品分类列表 |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 商品分类-新增 |
| | | * @return |
| | | */ |
| | | @GetMapping("categoryAdd") |
| | | @RequiresPermissions("categoryAdd:add") |
| | | public String helpCenterAdd() { |
| | | return FebsUtil.view("modules/product/categoryAdd"); |
| | | } |
| | | |
| | | /** |
| | | * 商品分类-详情 |
| | | * @param id |
| | | * @param model |
| | | * @return |
| | | */ |
| | | @GetMapping("categoryUpdate/{id}") |
| | | @RequiresPermissions("categoryUpdate:update") |
| | | public String detail(@PathVariable long id, Model model) { |
| | | AdminMallGoodsCategoryVo data = mallGoodsCategoryService.getMallGoodsCategoryInfoById(id); |
| | | model.addAttribute("member", data); |
| | | return FebsUtil.view("modules/product/categoryUpdate"); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.controller; |
| | | |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsConstant; |
| | | import cc.mrbird.febs.common.utils.FebsUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | @Controller("goodsView") |
| | | @RequestMapping(FebsConstant.VIEW_PREFIX + "modules/goods") |
| | | @RequiredArgsConstructor |
| | | public class ViewMallGoodsController extends BaseController { |
| | | |
| | | /** |
| | | * 商品列表 |
| | | * @return |
| | | */ |
| | | @GetMapping("goodsList") |
| | | @RequiresPermissions("goodsList:view") |
| | | public String categoryList() { |
| | | return FebsUtil.view("modules/goods/goodsList"); |
| | | } |
| | | |
| | | /** |
| | | * 商品-新增 |
| | | * @return |
| | | */ |
| | | @GetMapping("goodsAdd") |
| | | @RequiresPermissions("goodsAdd:add") |
| | | public String helpCenterAdd() { |
| | | return FebsUtil.view("modules/goods/goodsAddNew"); |
| | | } |
| | | |
| | | /** |
| | | * 商品-新增 |
| | | * @return |
| | | */ |
| | | @GetMapping("goodsAddNew") |
| | | @RequiresPermissions("goodsAddNew:add") |
| | | public String goodsAddNew() { |
| | | return FebsUtil.view("modules/goods/goodsAddNew"); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel(value = "AddMallGoodsDto", description = "参数接收类") |
| | | public class AddMallGoodsDto { |
| | | |
| | | private String goodsNo; |
| | | |
| | | private String goodsName; |
| | | |
| | | private List<AddMallGoodsSkuDto> addMallGoodsSkuDtos; |
| | | |
| | | private String goodsIntrodution; |
| | | |
| | | private String unit; |
| | | |
| | | private String thumb; |
| | | |
| | | private String goodsDetails; |
| | | |
| | | private Integer isSale; |
| | | |
| | | private String originalPrice; |
| | | |
| | | private String presentPrice; |
| | | |
| | | private Long categoryId; |
| | | |
| | | private Integer isHot; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @ApiModel(value = "AddMallGoodsSkuDto", description = "参数接收类") |
| | | public class AddMallGoodsSkuDto { |
| | | |
| | | private String skuName; |
| | | |
| | | private String skuImage; |
| | | |
| | | private Integer stock; |
| | | |
| | | private Integer skuVolume; |
| | | |
| | | private String originalPrice; |
| | | |
| | | private String presentPrice; |
| | | |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.mapper; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsCategoryVo; |
| | | import cc.mrbird.febs.mall.vo.MallGoodsCategoryVo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | List<MallGoodsCategory> selectCategoryListByParentId(@Param("id") Long id); |
| | | |
| | | List<MallGoodsCategory> selectRecommendCategoryList(); |
| | | |
| | | AdminMallGoodsCategoryVo getMallGoodsCategoryInfoById(@Param("id")long id); |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.mall.dto.MallGoodsQueryDto; |
| | | import cc.mrbird.febs.mall.entity.MallGoods; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsVo; |
| | | import cc.mrbird.febs.mall.vo.MallGoodsListVo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface MallGoodsMapper extends BaseMapper<MallGoods> { |
| | | |
| | | IPage<MallGoodsListVo> selectMallGoodsListQueryInPage(@Param("record") MallGoodsQueryDto queryDto, Page<MallGoodsListVo> page); |
| | | |
| | | IPage<AdminMallGoodsVo> selectMallGoodsInPage(Page<AdminMallGoodsVo> page, @Param("record")MallGoods mallGoods); |
| | | |
| | | Integer selectMallGoodsCountByGoodsName(@Param("goodsName")String goodsName); |
| | | |
| | | Integer selectMallGoodsCountByGoodsNo(@Param("goodsNo")String goodsNo); |
| | | } |
| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsCategoryVo; |
| | | import cc.mrbird.febs.system.entity.Role; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | |
| | | FebsResponse addCategory(MallGoodsCategory mallGoodsCategory); |
| | | |
| | | List<MallGoodsCategory> getCategorys(MallGoodsCategory mallGoodsCategory); |
| | | |
| | | AdminMallGoodsCategoryVo getMallGoodsCategoryInfoById(long id); |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.dto.AddMallGoodsDto; |
| | | import cc.mrbird.febs.mall.entity.MallGoods; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsVo; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | public interface IAdminMallGoodsService extends IService<MallGoods> { |
| | | |
| | | IPage<AdminMallGoodsVo> getCategoryListInPage(MallGoods mallGoods, QueryRequest request); |
| | | |
| | | FebsResponse addMallGoods(AddMallGoodsDto addMallGoodsDto); |
| | | } |
| | |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsCategoryMapper; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsCategoryService; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsCategoryVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | return mallGoodsCategorys; |
| | | } |
| | | |
| | | @Override |
| | | public AdminMallGoodsCategoryVo getMallGoodsCategoryInfoById(long id) { |
| | | return mallGoodsCategoryMapper.getMallGoodsCategoryInfoById(id); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.mall.dto.AddMallGoodsDto; |
| | | import cc.mrbird.febs.mall.dto.AddMallGoodsSkuDto; |
| | | import cc.mrbird.febs.mall.entity.MallGoods; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsSku; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsStyle; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsCategoryMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsSkuMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsStyleMapper; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsService; |
| | | import cc.mrbird.febs.mall.vo.AdminMallGoodsVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AdminMallGoodsService extends ServiceImpl<MallGoodsMapper, MallGoods> implements IAdminMallGoodsService { |
| | | |
| | | private final MallGoodsCategoryMapper mallGoodsCategoryMapper; |
| | | private final MallGoodsMapper mallGoodsMapper; |
| | | private final MallGoodsSkuMapper mallGoodsSkuMapper; |
| | | private final MallGoodsStyleMapper mallGoodsStyleMapper; |
| | | |
| | | @Override |
| | | public IPage<AdminMallGoodsVo> getCategoryListInPage(MallGoods mallGoods, QueryRequest request) { |
| | | Page<AdminMallGoodsVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<AdminMallGoodsVo> adminMallGoodsVos = this.baseMapper.selectMallGoodsInPage(page, mallGoods); |
| | | return adminMallGoodsVos; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse addMallGoods(AddMallGoodsDto addMallGoodsDto) { |
| | | String goodsName = addMallGoodsDto.getGoodsName(); |
| | | if(StrUtil.isEmpty(goodsName)){ |
| | | return new FebsResponse().fail().message("商品名称不能为空"); |
| | | } |
| | | Integer mallGoodsByGoodsName = mallGoodsMapper.selectMallGoodsCountByGoodsName(goodsName); |
| | | if(mallGoodsByGoodsName > 0){ |
| | | return new FebsResponse().fail().message("商品名称不能重复"); |
| | | } |
| | | String goodsNo = addMallGoodsDto.getGoodsNo(); |
| | | if(StrUtil.isEmpty(goodsNo)){ |
| | | return new FebsResponse().fail().message("商品编号不能为空"); |
| | | } |
| | | Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNo(goodsNo); |
| | | if(mallGoodsByGoodsNo > 0){ |
| | | return new FebsResponse().fail().message("商品编号不能重复"); |
| | | } |
| | | Long categoryId = addMallGoodsDto.getCategoryId(); |
| | | if(ObjectUtil.isEmpty(categoryId)){ |
| | | return new FebsResponse().fail().message("商品分类不能为空"); |
| | | } |
| | | //新增商品 |
| | | MallGoods mallGoods = new MallGoods(); |
| | | mallGoods.setGoodsNo(addMallGoodsDto.getGoodsNo()); |
| | | mallGoods.setGoodsName(addMallGoodsDto.getGoodsName()); |
| | | mallGoods.setGoodsIntrodution(addMallGoodsDto.getGoodsIntrodution()); |
| | | mallGoods.setUnit(addMallGoodsDto.getUnit()); |
| | | mallGoods.setThumb(addMallGoodsDto.getThumb()); |
| | | mallGoods.setGoodsDetails(addMallGoodsDto.getGoodsDetails()); |
| | | mallGoods.setOriginalPrice(addMallGoodsDto.getOriginalPrice()); |
| | | mallGoods.setCategoryId(addMallGoodsDto.getCategoryId()); |
| | | mallGoods.setPresentPrice(addMallGoodsDto.getPresentPrice()); |
| | | mallGoods.setIsHot(addMallGoodsDto.getIsHot()); |
| | | mallGoods.setIsSale(2); |
| | | mallGoodsMapper.insert(mallGoods); |
| | | |
| | | List<AddMallGoodsSkuDto> addMallGoodsSkuDtos = addMallGoodsDto.getAddMallGoodsSkuDtos(); |
| | | if(CollUtil.isNotEmpty(addMallGoodsSkuDtos)){ |
| | | for(AddMallGoodsSkuDto addMallGoodsSkuDto : addMallGoodsSkuDtos){ |
| | | //新增样式 |
| | | MallGoodsStyle mallGoodsStyle = new MallGoodsStyle(); |
| | | mallGoodsStyle.setName(addMallGoodsSkuDto.getSkuName()); |
| | | mallGoodsStyle.setGoodsId(mallGoods.getId()); |
| | | mallGoodsStyleMapper.insert(mallGoodsStyle); |
| | | |
| | | //新增商品规格 |
| | | MallGoodsSku mallGoodsSku = new MallGoodsSku(); |
| | | mallGoodsSku.setSkuName(addMallGoodsSkuDto.getSkuName()); |
| | | mallGoodsSku.setSkuImage(addMallGoodsSkuDto.getSkuImage()); |
| | | mallGoodsSku.setStock(addMallGoodsSkuDto.getStock()); |
| | | mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume()); |
| | | mallGoodsSku.setOriginalPrice(new BigDecimal(addMallGoodsSkuDto.getOriginalPrice())); |
| | | mallGoodsSku.setPresentPrice(new BigDecimal(addMallGoodsSkuDto.getPresentPrice())); |
| | | mallGoodsSku.setStyleId(mallGoodsStyle.getId()); |
| | | mallGoodsSku.setGoodsId(mallGoods.getId()); |
| | | mallGoodsSkuMapper.insert(mallGoodsSku); |
| | | } |
| | | } |
| | | |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "AdminMallGoodsCategoryVo", description = "信息返回类") |
| | | public class AdminMallGoodsCategoryVo { |
| | | |
| | | private Long id; |
| | | |
| | | private String name; |
| | | |
| | | private Long parentId; |
| | | |
| | | private Integer isRecommend; |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "AdminMallGoodsVo", description = "信息返回类") |
| | | public class AdminMallGoodsVo { |
| | | |
| | | private Long id; |
| | | |
| | | private String goodsName; |
| | | |
| | | private String goodsNo; |
| | | |
| | | private String goodsIntrodution; |
| | | |
| | | private String unit; |
| | | |
| | | private String thumb; |
| | | |
| | | private String goodsDetails; |
| | | |
| | | private Integer isSale; |
| | | |
| | | private String originalPrice; |
| | | |
| | | private String presentPrice; |
| | | |
| | | private Long categoryId; |
| | | |
| | | private Integer isHot; |
| | | |
| | | private Integer saleVolume; |
| | | } |
| | |
| | | <mapper namespace="cc.mrbird.febs.mall.mapper.MallGoodsCategoryMapper"> |
| | | |
| | | <select id="selectCategoryListInPage" resultType="cc.mrbird.febs.mall.entity.MallGoodsCategory"> |
| | | SELECT m.name,b.name parentName,m.is_comand isComand |
| | | SELECT m.id,m.name,b.name parentName,m.is_recommend isComand |
| | | FROM mall_goods_category m |
| | | left join mall_goods_category b on m.parent_id = b.id |
| | | <where> |
| | |
| | | select * from mall_goods_category |
| | | where parent_id=0 and is_recommend = 1 |
| | | </select> |
| | | |
| | | <select id="getMallGoodsCategoryInfoById" resultType="cc.mrbird.febs.mall.vo.AdminMallGoodsCategoryVo"> |
| | | select * from mall_goods_category |
| | | where id=#{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | </where> |
| | | order by a.created_time desc |
| | | </select> |
| | | |
| | | <select id="selectMallGoodsInPage" resultType="cc.mrbird.febs.mall.vo.AdminMallGoodsVo"> |
| | | select |
| | | a.id, |
| | | a.goods_name, |
| | | a.goods_no, |
| | | a.goods_introdution, |
| | | a.unit, |
| | | a.thumb, |
| | | a.goods_details, |
| | | a.is_sale, |
| | | a.original_price, |
| | | a.present_price, |
| | | a.is_hot |
| | | from mall_goods a |
| | | <where> |
| | | <if test="record != null"> |
| | | <if test="record.goodsName != null and record.goodsName != ''"> |
| | | and a.goods_name like CONCAT('%', CONCAT(#{record.goodsName}, '%')) |
| | | </if> |
| | | </if> |
| | | </where> |
| | | order by a.created_time desc |
| | | </select> |
| | | |
| | | <select id="selectMallGoodsCountByGoodsName" resultType="java.lang.Integer"> |
| | | select count(id) from mall_goods a where a.goods_name = #{goodsName} |
| | | </select> |
| | | |
| | | <select id="selectMallGoodsCountByGoodsNo" resultType="java.lang.Integer"> |
| | | select count(id) from mall_goods a where a.goods_no = #{goodsNo} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <style> |
| | | #goods-add { |
| | | padding: 20px 25px 25px 0; |
| | | } |
| | | |
| | | #goods-add .layui-treeSelect .ztree li a, .ztree li span { |
| | | margin: 0 0 2px 3px !important; |
| | | } |
| | | #goods-add #data-permission-tree-block { |
| | | border: 1px solid #eee; |
| | | border-radius: 2px; |
| | | padding: 3px 0; |
| | | } |
| | | #goods-add .layui-treeSelect .ztree li span.button.switch { |
| | | top: 1px; |
| | | left: 3px; |
| | | } |
| | | .layui-upload-img{ |
| | | max-width: 300px; |
| | | } |
| | | |
| | | </style> |
| | | <div class="layui-fluid" id="goods-add"> |
| | | <form class="layui-form" action="" lay-filter="user-add-form"> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">商品名称:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsName" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">商品编号:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsNo" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">所属分类:</label> |
| | | <div class="layui-input-block"> |
| | | <select name="categoryId" |
| | | xm-select-direction="down" |
| | | xm-select="user-add-goods" |
| | | xm-select-skin="default"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">单位:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="unit" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label">原价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="originalPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">现价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="presentPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">商品介绍:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label">规格:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" id="attrName"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <button type="button" class="layui-btn" id="test3" >添加</button> |
| | | </div> |
| | | </div> |
| | | <div id="attrWrap"></div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label febs-form-item-require">缩略图:</label> |
| | | <div class="layui-input-block"> |
| | | <div class="layui-upload"> |
| | | <button type="button" class="layui-btn" id="test2">上传</button> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> |
| | | <div class="layui-upload-list" id="demo2"></div> |
| | | </blockquote> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item febs-hide"> |
| | | <label class="layui-form-label febs-form-item-require">缩略图链接:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label febs-form-item-require">商品详情:</label> |
| | | <div class="layui-input-block"> |
| | | <textarea id="lay_edit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea> |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">是否热卖:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="radio" name="isHot" value="1" title="是" > |
| | | <input type="radio" name="isHot" value="2" title="否" checked=""> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item febs-hide"> |
| | | <button class="layui-btn" lay-submit="" lay-filter="goods-add-form-submit" id="submit"></button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | <script data-th-inline="javascript"> |
| | | layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate','layedit','upload'], function () { |
| | | var $ = layui.jquery, |
| | | febs = layui.febs, |
| | | layer = layui.layer, |
| | | formSelects = layui.formSelects, |
| | | treeSelect = layui.treeSelect, |
| | | form = layui.form, |
| | | laydate = layui.laydate, |
| | | eleTree = layui.eleTree, |
| | | member = [[${member}]], |
| | | $view = $('#goods-add'), |
| | | layedit = layui.layedit, |
| | | upload = layui.upload, |
| | | validate = layui.validate; |
| | | |
| | | form.render(); |
| | | laydate.render({ |
| | | elem: '#febs-form-group-date' |
| | | }); |
| | | |
| | | formSelects.render(); |
| | | |
| | | formSelects.config('user-add-goods', { |
| | | searchUrl: ctx + 'admin/goodsCategory/categorys', |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | beforeSuccess: function (id, url, searchVal, result) { |
| | | var data = result.data; |
| | | var tranData = []; |
| | | for (var i = 0; i < data.length; i++) { |
| | | tranData.push({ |
| | | name: data[i].name, |
| | | value: data[i].id |
| | | }) |
| | | } |
| | | result.data = tranData; |
| | | return result; |
| | | }, |
| | | success: function () { |
| | | // formSelects.value('user-add-goods', result.id); |
| | | }, |
| | | error: function (id, url, searchVal, err) { |
| | | console.error(err); |
| | | febs.alert.error('获取分类列表失败'); |
| | | } |
| | | }); |
| | | |
| | | //普通图片上传 |
| | | upload.render({ |
| | | elem: '#skuImg' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,before: function(obj){ |
| | | //预读本地文件示例,不支持ie8 |
| | | obj.preview(function(index, file, result){ |
| | | $('#skuImgs').attr('src', result); //图片链接(base64) |
| | | }); |
| | | } |
| | | ,done: function(res){ |
| | | febs.alert.success(res.data.src); |
| | | $("#skuImage").val(res.data.src); |
| | | } |
| | | }); |
| | | |
| | | //多图片上传 |
| | | upload.render({ |
| | | elem: '#test2' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,multiple: true |
| | | ,before: function(obj){ |
| | | //预读本地文件示例,不支持ie8 |
| | | obj.preview(function(index, file, result){ |
| | | $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">') |
| | | }); |
| | | } |
| | | ,done: function(res){ |
| | | var thumbs = $("#thumb").val(); |
| | | if(thumbs == ''){ |
| | | $("#thumb").val(res.data.src); |
| | | }else{ |
| | | $("#thumb").val(thumbs + ',' + res.data.src); |
| | | } |
| | | // alert($("#thumb").val()); |
| | | } |
| | | }); |
| | | |
| | | layedit.set({ //设置图片接口 |
| | | uploadImage: { |
| | | url: 'admin/goods/uploadFileBase64', //接口url |
| | | type: 'post', |
| | | } |
| | | }); |
| | | //创建一个编辑器 |
| | | var index = layedit.build('lay_edit',{ |
| | | height: 300 |
| | | }); |
| | | //提交时把值同步到文本域中 |
| | | form.verify({ |
| | | //content富文本域中的lay-verify值 |
| | | goodsDetails: function(value) { |
| | | return layedit.sync(index); |
| | | } |
| | | }); |
| | | |
| | | form.on('submit(goods-add-form-submit)', function (data) { |
| | | febs.post(ctx + 'admin/goodsCategory/addCategory', data.field, function () { |
| | | layer.closeAll(); |
| | | febs.alert.success('新增成功'); |
| | | $('#febs-user').find('#reset').click(); |
| | | }); |
| | | return false; |
| | | }); |
| | | $('#test3').on('click', function (){ |
| | | var index = $("#attrWrap").children().length; |
| | | $('#attrWrap').append(` |
| | | <div class="layui-row layui-col-space10 layui-form-item item"> |
| | | <div class="layui-col-lg2"> |
| | | <label class="layui-form-label">` + $('#attrName').val() + `:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-lg2"> |
| | | <label class="layui-form-label">图片:</label> |
| | | <div class="layui-input-block"> |
| | | <div class="layui-upload"> |
| | | <button type="button" class="layui-btn" id="skuImg">上传</button> |
| | | <input type="text" id="skuImage" name="skuImage" autocomplete="off" class="layui-input" readonly> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg2"> |
| | | <label class="layui-form-label">库存:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg2"> |
| | | <label class="layui-form-label">销售数量:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg2"> |
| | | <label class="layui-form-label">原价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg2"> |
| | | <label class="layui-form-label">现价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg2"> |
| | | <button type="button" class="layui-btn del-attr-btn" data-index="` + index +`">删除</button> |
| | | </div> |
| | | </div> |
| | | `) |
| | | }) |
| | | $("#attrWrap").on("click",".del-attr-btn",function(){ |
| | | console.log(this) |
| | | console.log($(this).index()) |
| | | console.log($(this).attr('data-index')) |
| | | var index = $(this).attr('data-index') |
| | | $($("#attrWrap").find(".item")[index].remove()); |
| | | }); |
| | | |
| | | }); |
| | | </script> |
New file |
| | |
| | | <div class="layui-fluid layui-anim febs-anim" id="febs-goods" lay-title="新增商品"> |
| | | <div class="layui-row febs-container"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body febs-table-full"> |
| | | <div class="layui-fluid" id="goods-add"> |
| | | <form class="layui-form" action="" lay-filter="goods-add-form"> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">商品名称:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsName" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">商品编号:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsNo" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">所属分类:</label> |
| | | <div class="layui-input-block"> |
| | | <select name="categoryId" |
| | | lay-verify="required" |
| | | xm-select-direction="down" |
| | | xm-select="user-add-goods" |
| | | xm-select-skin="default"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">单位:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="unit" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">原价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="originalPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label febs-form-item-require">现价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="presentPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">商品介绍:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label">规格:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="addMallGoodsSkuDtos" autocomplete="off" class="layui-input" id="attrName"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg6"> |
| | | <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" id="test3" >添加</button> |
| | | </div> |
| | | </div> |
| | | <div id="attrWrap"></div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">缩略图:</label> |
| | | <div class="layui-input-block"> |
| | | <div class="layui-upload"> |
| | | <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" id="test2">上传</button> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> |
| | | <div class="layui-upload-list" id="demo2"></div> |
| | | </blockquote> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item febs-hide"> |
| | | <label class="layui-form-label">缩略图链接:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">商品详情:</label> |
| | | <div class="layui-input-block"> |
| | | <textarea id="lay_edit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea> |
| | | </div> |
| | | </div> |
| | | <div class="layui-row layui-col-space10 layui-form-item"> |
| | | <div class="layui-col-lg6"> |
| | | <label class="layui-form-label">是否热卖:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="radio" name="isHot" value="1" title="是" > |
| | | <input type="radio" name="isHot" value="2" title="否" checked=""> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item" style="text-align:center"> |
| | | <button class="layui-btn" lay-submit="" lay-filter="goods-add-form-submit" id="submit">保存</button> |
| | | <button class="layui-btn" lay-submit="" lay-filter="goods-add-form-cancel" id="cancel">取消</button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="javascript"> |
| | | layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate','layedit','upload'], function () { |
| | | var $ = layui.jquery, |
| | | febs = layui.febs, |
| | | layer = layui.layer, |
| | | formSelects = layui.formSelects, |
| | | treeSelect = layui.treeSelect, |
| | | form = layui.form, |
| | | laydate = layui.laydate, |
| | | eleTree = layui.eleTree, |
| | | member = [[${member}]], |
| | | $view = $('#goods-add'), |
| | | layedit = layui.layedit, |
| | | upload = layui.upload, |
| | | validate = layui.validate; |
| | | |
| | | form.render(); |
| | | laydate.render({ |
| | | elem: '#febs-form-group-date' |
| | | }); |
| | | |
| | | formSelects.render(); |
| | | |
| | | formSelects.config('user-add-goods', { |
| | | searchUrl: ctx + 'admin/goodsCategory/categorys', |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | beforeSuccess: function (id, url, searchVal, result) { |
| | | var data = result.data; |
| | | var tranData = []; |
| | | for (var i = 0; i < data.length; i++) { |
| | | tranData.push({ |
| | | name: data[i].name, |
| | | value: data[i].id |
| | | }) |
| | | } |
| | | result.data = tranData; |
| | | return result; |
| | | }, |
| | | success: function () { |
| | | // formSelects.value('user-add-goods', result.id); |
| | | }, |
| | | error: function (id, url, searchVal, err) { |
| | | console.error(err); |
| | | febs.alert.error('获取分类列表失败'); |
| | | } |
| | | }); |
| | | //多图片上传 |
| | | upload.render({ |
| | | elem: '#test2' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,multiple: true |
| | | ,before: function(obj){ |
| | | //预读本地文件示例,不支持ie8 |
| | | obj.preview(function(index, file, result){ |
| | | $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">') |
| | | }); |
| | | } |
| | | ,done: function(res){ |
| | | var thumbs = $("#thumb").val(); |
| | | if(thumbs == ''){ |
| | | $("#thumb").val(res.data.src); |
| | | }else{ |
| | | $("#thumb").val(thumbs + ',' + res.data.src); |
| | | } |
| | | // alert($("#thumb").val()); |
| | | } |
| | | }); |
| | | |
| | | layedit.set({ //设置图片接口 |
| | | uploadImage: { |
| | | url: 'admin/goods/uploadFileBase64', //接口url |
| | | type: 'post', |
| | | } |
| | | }); |
| | | //创建一个编辑器 |
| | | var index = layedit.build('lay_edit',{ |
| | | height: 300 |
| | | }); |
| | | //提交时把值同步到文本域中 |
| | | form.verify({ |
| | | //content富文本域中的lay-verify值 |
| | | goodsDetails: function(value) { |
| | | return layedit.sync(index); |
| | | } |
| | | }); |
| | | |
| | | $('#test3').on('click', function (){ |
| | | var index = $("#attrWrap").children().length; |
| | | $('#attrWrap').append(` |
| | | <div class="layui-form-item item"> |
| | | <div style="float:left" > |
| | | <input type="text" name="skuName` + index + `" autocomplete="off" class="layui-input" value="` + $('#attrName').val() + `" readonly > |
| | | </div> |
| | | <div style="float:left" > |
| | | <label class="layui-form-label">图片:</label> |
| | | <div class="layui-input-block"> |
| | | <div class="layui-upload"> |
| | | <button type="button" class="layui-btn layui-btn-normal layui-btn-xs sku-img" id="` + index + `">上传</button> |
| | | <input type="text" id="skuImage` + index +`" name="skuImage` + index + `" autocomplete="off" |
| | | class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="float:left" > |
| | | <label class="layui-form-label">库存:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="stock` + index +`" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div style="float:left" > |
| | | <label class="layui-form-label">销售数量:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="skuVolume` + index +`" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div style="float:left" > |
| | | <label class="layui-form-label">原价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="originalPrice` + index +`" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div style="float:left" > |
| | | <label class="layui-form-label">现价:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="presentPrice` + index + `" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div style="float:left" > |
| | | <button type="button" class="layui-btn del-attr-btn" data-index="` + index +`">删除</button> |
| | | </div> |
| | | </div> |
| | | `) |
| | | //普通图片上传 |
| | | upload.render({ |
| | | elem: '.sku-img' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,done: function(res){ |
| | | febs.alert.success(res.data.src); |
| | | var cid = this.item.attr('id'); |
| | | $('#skuImgPreview' + cid).attr('src', res.data.src); |
| | | $('#skuImage'+cid).val(res.data.src); |
| | | } |
| | | }); |
| | | }); |
| | | upload.render({ |
| | | elem: '.sku-img' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,done: function(res){ |
| | | febs.alert.success(res.data.src); |
| | | var cid = this.item.attr('id'); |
| | | $('#skuImgPreview' + cid).attr('src', res.data.src); |
| | | $('#skuImage'+cid).val(res.data.src); |
| | | } |
| | | }); |
| | | $("#attrWrap").on("click",".del-attr-btn",function(){ |
| | | // console.log(this) |
| | | // console.log($(this).index()) |
| | | // console.log($(this).attr('data-index')) |
| | | var index = $(this).attr('data-index') |
| | | $($("#attrWrap").find(".item")[index].remove()); |
| | | }); |
| | | form.on('submit(goods-add-form-submit)', function (data) { |
| | | let skuArrs = []; |
| | | var skuArr = $("#attrWrap").find(".item"); |
| | | for(var i = 0;i < skuArr.length;i++){ |
| | | skuArrs.push({ |
| | | skuName: $("input[name='skuName" + i + "']").val(), |
| | | skuImage: $("input[name='skuImage" + i + "']").val(), |
| | | stock: $("input[name='stock" + i + "']").val(), |
| | | skuVolume: $("input[name='skuVolume" + i + "']").val(), |
| | | originalPrice:$("input[name='originalPrice" + i + "']").val(), |
| | | presentPrice: $("input[name='presentPrice" + i + "']").val() |
| | | }) |
| | | } |
| | | // console.log(skuArrs) |
| | | data.field.addMallGoodsSkuDtos = skuArrs; |
| | | // console.log(data.field) |
| | | $.ajax({ |
| | | 'url':ctx + 'admin/goods/addMallGoods', |
| | | 'type':'post', |
| | | 'dataType':'json', |
| | | 'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式 |
| | | 'traditional': true,//ajax传递数组必须添加属性 |
| | | 'data':JSON.stringify(data.field), |
| | | 'success':function (data) { |
| | | if(data.code==0){ |
| | | febs.alert.success(data.message); |
| | | var index = parent.layer.getFrameIndex(window.name); |
| | | parent.layer.close(index); |
| | | }else{ |
| | | febs.alert.warn(data.message); |
| | | } |
| | | }, |
| | | 'error':function () { |
| | | febs.alert.warn('服务器繁忙'); |
| | | } |
| | | }) |
| | | return false; |
| | | }); |
| | | |
| | | // $('cancel').on('click', function () { |
| | | // var currentUrl = window.location.hash.replace('#', ''); |
| | | // febs.view.tab.del(currentUrl); |
| | | // febs.view.tab.change("/modules/goods/goodsList/"); |
| | | // }); |
| | | |
| | | }); |
| | | </script> |
New file |
| | |
| | | <div class="layui-fluid layui-anim febs-anim" id="febs-goods" lay-title="商品列表"> |
| | | <div class="layui-row febs-container"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body febs-table-full"> |
| | | <form class="layui-form layui-table-form" lay-filter="user-table-form"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md10"> |
| | | <div class="layui-form-item"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input type="text" placeholder="名称" name="goodsName" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add"> |
| | | 新增 |
| | | </div> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> |
| | | <i class="layui-icon"></i> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | <table lay-filter="userTable" lay-data="{id: 'userTable'}"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 表格操作栏 start --> |
| | | <script type="text/html" id="user-option"> |
| | | <span shiro:lacksPermission="user:view,user:update,user:delete"> |
| | | <span class="layui-badge-dot febs-bg-orange"></span> 无权限 |
| | | </span> |
| | | <a lay-event="edit" shiro:hasPermission="user:update"><i |
| | | class="layui-icon febs-edit-area febs-blue"></i></a> |
| | | </script> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | | // 引入组件并初始化 |
| | | layui.use([ 'jquery', 'form', 'table', 'febs'], function () { |
| | | var $ = layui.jquery, |
| | | febs = layui.febs, |
| | | form = layui.form, |
| | | table = layui.table, |
| | | $view = $('#febs-goods'), |
| | | $query = $view.find('#query'), |
| | | $reset = $view.find('#reset'), |
| | | $searchForm = $view.find('form'), |
| | | $add = $view.find('#add'), |
| | | sortObject = {field: 'phone', type: null}, |
| | | tableIns; |
| | | |
| | | form.render(); |
| | | |
| | | // 表格初始化 |
| | | initTable(); |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('tool(userTable)', function (obj) { |
| | | var data = obj.data, |
| | | layEvent = obj.event; |
| | | if (layEvent === 'close') { |
| | | febs.modal.confirm('禁用', '确认禁用该账号?', function () { |
| | | closeAccount(data.id); |
| | | }); |
| | | } |
| | | if (layEvent === 'open') { |
| | | febs.modal.confirm('开启', '确认开启该账号?', function () { |
| | | openAccount(data.id); |
| | | }); |
| | | } |
| | | if (layEvent === 'see') { |
| | | febs.modal.open( '个人信息', 'modules/mallMember/detail/' + data.id, { |
| | | maxmin: true, |
| | | }); |
| | | } |
| | | }); |
| | | function closeAccount(id) { |
| | | febs.get(ctx + 'admin/mallMember/closeAccount/' + id, null, function () { |
| | | febs.alert.success('禁用成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | function openAccount(id) { |
| | | febs.get(ctx + 'admin/mallMember/openAccount/' + id, null, function () { |
| | | febs.alert.success('开启成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 查询按钮 |
| | | $query.on('click', function () { |
| | | var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); |
| | | tableIns.reload({where: params, page: {curr: 1}}); |
| | | }); |
| | | |
| | | // 刷新按钮 |
| | | $reset.on('click', function () { |
| | | $searchForm[0].reset(); |
| | | sortObject.type = 'null'; |
| | | tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); |
| | | }); |
| | | |
| | | // $add.on('click', function () { |
| | | // febs.modal.open('新增', 'modules/goods/goodsAdd/', { |
| | | // btn: ['提交', '取消'], |
| | | // yes: function (index, layero) { |
| | | // $('#goods-add').find('#submit').trigger('click'); |
| | | // }, |
| | | // btn2: function () { |
| | | // layer.closeAll(); |
| | | // } |
| | | // }); |
| | | // }); |
| | | $add.on('click', function () { |
| | | febs.view.tab.change("/modules/goods/goodsAddNew/"); |
| | | }); |
| | | |
| | | function initTable() { |
| | | tableIns = febs.table.init({ |
| | | elem: $view.find('table'), |
| | | id: 'userTable', |
| | | url: ctx + 'admin/goods/goodsList', |
| | | cols: [[ |
| | | {field: 'goodsName', title: '商品名称', minWidth: 150,align:'left'}, |
| | | // {field: 'accountType', title: '账号类型', |
| | | // templet: function (d) { |
| | | // if (d.accountType === 2) { |
| | | // return '<span style="color:red;">测试账号</span>' |
| | | // } else if (d.accountType === 1) { |
| | | // return '<span style="color:green;">正常账号</span>' |
| | | // }else{ |
| | | // return '' |
| | | // } |
| | | // }, minWidth: 80,align:'center'}, |
| | | // {field: 'accountStatus', title: '账号状态', |
| | | // templet: function (d) { |
| | | // if (d.accountStatus === 1) { |
| | | // return '<span style="color:green;">正常</span>' |
| | | // } else if (d.accountStatus === 2) { |
| | | // return '<span style="color:red;">禁用</span>' |
| | | // }else{ |
| | | // return '' |
| | | // } |
| | | // }, minWidth: 80,align:'center'}, |
| | | // {field: 'createdTime', title: '注册时间', minWidth: 180,align:'center'}, |
| | | // {title: '操作', |
| | | // templet: function (d) { |
| | | // if (d.accountStatus === 1) { |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">详情</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="close" shiro:hasPermission="user:update">禁用</button>' |
| | | // |
| | | // }else{ |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">详情</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="open" shiro:hasPermission="user:update">启用</button>' |
| | | // |
| | | // } |
| | | // },minWidth: 300,align:'center'} |
| | | ]] |
| | | }); |
| | | } |
| | | |
| | | // 获取查询参数 |
| | | function getQueryParams() { |
| | | return { |
| | | name: $searchForm.find('input[name="goodsName"]').val().trim(), |
| | | }; |
| | | } |
| | | |
| | | }) |
| | | </script> |
| | |
| | | openAccount(data.id); |
| | | }); |
| | | } |
| | | |
| | | if (layEvent === 'edit') { |
| | | febs.modal.open('身份认证', 'modules/member/memberDetail/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#user-update').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'see') { |
| | | febs.modal.open( '个人信息', 'modules/mallMember/detail/' + data.id, { |
| | | maxmin: true, |
| | | }); |
| | | } |
| | | if (layEvent === 'addCoin') { |
| | | febs.modal.open( '拨币', 'modules/member/addCoin/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#user-update').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'examine') { |
| | | febs.modal.open( '个人数据详情', 'modules/member/memberDetailInfo/' + data.inviteId, { |
| | | maxmin: true, |
| | | }); |
| | | } |
| | |
| | | return result; |
| | | }, |
| | | success: function () { |
| | | formSelects.value('user-update-category', user.id.split(',')); |
| | | formSelects.value('user-update-category', member.id.split(',')); |
| | | }, |
| | | error: function (id, url, searchVal, err) { |
| | | console.error(err); |
| | |
| | | }); |
| | | } |
| | | |
| | | if (layEvent === 'edit') { |
| | | febs.modal.open('身份认证', 'modules/member/memberDetail/' + data.id, { |
| | | if (layEvent === 'see') { |
| | | febs.modal.open('编辑', 'modules/product/categoryUpdate/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#user-update').find('#submit').trigger('click'); |
| | |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'see') { |
| | | febs.modal.open( '个人信息', 'modules/mallMember/detail/' + data.id, { |
| | | maxmin: true, |
| | | }); |
| | | } |
| | | }); |
| | |
| | | cols: [[ |
| | | {field: 'name', title: '名称', minWidth: 150,align:'left'}, |
| | | {field: 'parentName', title: '父级名称', minWidth: 150,align:'left'}, |
| | | // {title: '操作', |
| | | // templet: function (d) { |
| | | // if (d.accountStatus === 1) { |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">详情</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="close" shiro:hasPermission="user:update">禁用</button>' |
| | | // |
| | | // }else{ |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">详情</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="open" shiro:hasPermission="user:update">启用</button>' |
| | | // |
| | | // } |
| | | // },minWidth: 300,align:'center'} |
| | | {title: '操作', |
| | | templet: function (d) { |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="see" shiro:hasPermission="user:update">编辑</button>' |
| | | },minWidth: 300,align:'center'} |
| | | ]] |
| | | }); |
| | | } |
New file |
| | |
| | | <style> |
| | | #user-add { |
| | | padding: 20px 25px 25px 0; |
| | | } |
| | | |
| | | #user-add .layui-treeSelect .ztree li a, .ztree li span { |
| | | margin: 0 0 2px 3px !important; |
| | | } |
| | | #user-add #data-permission-tree-block { |
| | | border: 1px solid #eee; |
| | | border-radius: 2px; |
| | | padding: 3px 0; |
| | | } |
| | | #user-add .layui-treeSelect .ztree li span.button.switch { |
| | | top: 1px; |
| | | left: 3px; |
| | | } |
| | | |
| | | </style> |
| | | <div class="layui-fluid" id="user-add"> |
| | | <form class="layui-form" action="" lay-filter="categary-update-form"> |
| | | <div class="layui-form-item febs-hide"> |
| | | <label class="layui-form-label febs-form-item-require">用户id:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="id" data-th-value="${member.id}"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label febs-form-item-require">名称:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="name" |
| | | lay-verify="name" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label ">父类:</label> |
| | | <div class="layui-input-block"> |
| | | <select name="parentId" |
| | | xm-select-direction="down" |
| | | xm-select="user-update-category" |
| | | xm-select-skin="default"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label febs-form-item-require">是否推荐:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="radio" name="isRecommend" value="1" title="是" > |
| | | <input type="radio" name="isRecommend" value="2" title="否" checked=""> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item febs-hide"> |
| | | <button class="layui-btn" lay-submit="" lay-filter="categary-update-form-submit" id="submit"></button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | <script data-th-inline="javascript"> |
| | | layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate'], function () { |
| | | var $ = layui.$, |
| | | febs = layui.febs, |
| | | layer = layui.layer, |
| | | formSelects = layui.formSelects, |
| | | treeSelect = layui.treeSelect, |
| | | form = layui.form, |
| | | laydate = layui.laydate, |
| | | eleTree = layui.eleTree, |
| | | member = [[${member}]], |
| | | $view = $('#user-add'), |
| | | validate = layui.validate; |
| | | |
| | | form.render(); |
| | | laydate.render({ |
| | | elem: '#febs-form-group-date' |
| | | }); |
| | | |
| | | formSelects.render(); |
| | | |
| | | formSelects.config('user-update-category', { |
| | | searchUrl: ctx + 'admin/goodsCategory/categorys', |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | beforeSuccess: function (id, url, searchVal, result) { |
| | | var data = result.data; |
| | | var tranData = []; |
| | | for (var i = 0; i < data.length; i++) { |
| | | tranData.push({ |
| | | name: data[i].name, |
| | | value: data[i].id |
| | | }) |
| | | } |
| | | result.data = tranData; |
| | | return result; |
| | | }, |
| | | success: function () { |
| | | formSelects.value('user-update-category', member.parentId); |
| | | }, |
| | | error: function (id, url, searchVal, err) { |
| | | console.error(err); |
| | | febs.alert.error('获取分类列表失败'); |
| | | } |
| | | }); |
| | | initUserValue(); |
| | | |
| | | function initUserValue() { |
| | | form.val("categary-update-form", { |
| | | "id": member.id, |
| | | "name": member.name, |
| | | "parentId": member.parentId, |
| | | "isRecommend": member.isRecommend |
| | | }); |
| | | } |
| | | |
| | | form.on('submit(categary-update-form-submit)', function (data) { |
| | | febs.post(ctx + 'admin/goodsCategory/addCategory', data.field, function () { |
| | | layer.closeAll(); |
| | | febs.alert.success('新增成功'); |
| | | $('#febs-user').find('#reset').click(); |
| | | }); |
| | | return false; |
| | | }); |
| | | }); |
| | | </script> |