3 files added
13 files modified
| | |
| | | return new FebsResponse().success().data(mallVipBenefitsService.findVipBenefitsById(id)); |
| | | } |
| | | |
| | | @PostMapping("/addBenefits") |
| | | public FebsResponse addBenefits(@RequestBody MallVipBenefits mallVipBenefits) { |
| | | @PostMapping("/addOrEditBenefits") |
| | | public FebsResponse addOrEditBenefits(@RequestBody MallVipBenefits mallVipBenefits) { |
| | | if (mallVipBenefits.getId() == null) { |
| | | this.mallVipBenefitsService.addVipBenefits(mallVipBenefits); |
| | | } else { |
| | | this.mallVipBenefitsService.editVipBenefits(mallVipBenefits); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("/delBenefites/{id}") |
| | | @GetMapping("/delBenefits/{id}") |
| | | public FebsResponse delBenefits(@PathVariable("id") Long id) { |
| | | this.mallVipBenefitsService.delVipBenefits(id); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("/findAllBenefits") |
| | | public FebsResponse findAllBenefits() { |
| | | return new FebsResponse().success().data(mallVipBenefitsService.list()); |
| | | } |
| | | } |
| | |
| | | package cc.mrbird.febs.vip.controller; |
| | | |
| | | 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.vip.entity.MallVipConfig; |
| | | import cc.mrbird.febs.vip.service.IMallVipConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping(value = "/admin/vip/config") |
| | | public class AdminMallVipConfigController { |
| | | public class AdminMallVipConfigController extends BaseController { |
| | | |
| | | private final IMallVipConfigService mallVipConfigService; |
| | | |
| | | @GetMapping(value = "/list") |
| | | public FebsResponse list(QueryRequest request) { |
| | | return new FebsResponse().success().data(getDataTable(mallVipConfigService.vipConfigList(request))); |
| | | } |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsConstant; |
| | | import cc.mrbird.febs.common.utils.FebsUtil; |
| | | import cc.mrbird.febs.mall.entity.MallGoods; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCoupon; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsCouponMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallGoodsService; |
| | | import cc.mrbird.febs.vip.entity.MallVipBenefits; |
| | | import cc.mrbird.febs.vip.service.IMallVipBenefitsService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Controller("mallVipConfig") |
| | | @RequestMapping(FebsConstant.VIEW_PREFIX + "modules/vip/config") |
| | | @RequiredArgsConstructor |
| | | public class ViewVipConfigController { |
| | | |
| | | private final IMallVipBenefitsService mallVipBenefitsService; |
| | | private final IApiMallGoodsService apiMallGoodsService; |
| | | private final MallGoodsCouponMapper mallGoodsCouponMapper; |
| | | |
| | | @GetMapping(value = "/benefitsList") |
| | | public String benefitsList() { |
| | |
| | | model.addAttribute("tableIndex", index); |
| | | return FebsUtil.view("modules/vip/coupon-select"); |
| | | } |
| | | |
| | | @GetMapping("/editBenefits/{id}") |
| | | public String editBenefits(@PathVariable("id") Long id, Model model) { |
| | | MallVipBenefits vipBenefits = mallVipBenefitsService.findVipBenefitsById(id); |
| | | |
| | | List<Long> goodsIds = new ArrayList<>(); |
| | | List<Long> couponIds = new ArrayList<>(); |
| | | vipBenefits.getDetails().forEach(item -> { |
| | | if (item.getIsClick() == 2) { |
| | | return; |
| | | } |
| | | |
| | | if (item.getLinkType() == 2) { |
| | | goodsIds.add(Long.parseLong(item.getContent())); |
| | | } |
| | | |
| | | if (item.getLinkType() == 3) { |
| | | couponIds.add(Long.parseLong(item.getContent())); |
| | | } |
| | | }); |
| | | |
| | | List<MallGoods> goodsList = new ArrayList<>(); |
| | | if (CollUtil.isNotEmpty(goodsIds)) { |
| | | goodsList = apiMallGoodsService.listByIds(goodsIds); |
| | | } |
| | | |
| | | List<MallGoodsCoupon> coupons = new ArrayList<>(); |
| | | if (CollUtil.isNotEmpty(couponIds)) { |
| | | coupons = mallGoodsCouponMapper.selectBatchIds(couponIds); |
| | | } |
| | | |
| | | Map<Long, MallGoods> goodsMap = goodsList.stream().collect(Collectors.toMap(MallGoods::getId, MallGoods -> MallGoods)); |
| | | Map<Long, MallGoodsCoupon> couponMap = coupons.stream().collect(Collectors.toMap(MallGoodsCoupon::getId, MallGoodsCoupon -> MallGoodsCoupon)); |
| | | |
| | | vipBenefits.getDetails().forEach(item -> { |
| | | if (item.getIsClick() == 2) { |
| | | return; |
| | | } |
| | | |
| | | if (item.getLinkType() == 2) { |
| | | MallGoods mallGoods = goodsMap.get(Long.parseLong(item.getContent())); |
| | | if (mallGoods != null) { |
| | | item.setContentName(mallGoods.getGoodsName()); |
| | | } |
| | | } |
| | | |
| | | if (item.getLinkType() == 3) { |
| | | MallGoodsCoupon coupon = couponMap.get(Long.parseLong(item.getContent())); |
| | | if (coupon != null) { |
| | | item.setContentName(coupon.getName()); |
| | | } |
| | | } |
| | | }); |
| | | model.addAttribute("benefitsData", vipBenefits); |
| | | return FebsUtil.view("modules/vip/vipBenefits-edit"); |
| | | } |
| | | |
| | | @GetMapping(value = "/levelList") |
| | | public String levelList() { |
| | | return FebsUtil.view("modules/vip/vipConfig-list"); |
| | | } |
| | | |
| | | @GetMapping(value = "/levelAdd") |
| | | public String levelAdd() { |
| | | return FebsUtil.view("modules/vip/vipConfig-add"); |
| | | } |
| | | |
| | | @GetMapping(value = "/levelEdit") |
| | | public String levelEdit() { |
| | | return FebsUtil.view("modules/vip/vipLevel-list"); |
| | | } |
| | | } |
| | |
| | | package cc.mrbird.febs.vip.entity; |
| | | |
| | | import cc.mrbird.febs.common.entity.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | |
| | | * 权益ID |
| | | */ |
| | | private Long benefitsId; |
| | | |
| | | @TableField(exist = false) |
| | | private String contentName; |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.vip.entity.MallVipConfig; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | public interface MallVipConfigMapper extends BaseMapper<MallVipConfig> { |
| | | |
| | | IPage<MallVipConfig> findVipConfigListInPage(IPage<MallVipConfig> page); |
| | | } |
| | |
| | | void addVipBenefits(MallVipBenefits mallVipBenefits); |
| | | |
| | | void delVipBenefits(Long id); |
| | | |
| | | void editVipBenefits(MallVipBenefits mallVipBenefits); |
| | | } |
| | |
| | | package cc.mrbird.febs.vip.service; |
| | | |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.vip.entity.MallVipConfig; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | public interface IMallVipConfigService extends IService<MallVipConfig> { |
| | | |
| | | IPage<MallVipConfig> vipConfigList(QueryRequest request); |
| | | } |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void addVipBenefits(MallVipBenefits mallVipBenefits) { |
| | | if (mallVipBenefits == null) { |
| | | return; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void delVipBenefits(Long id) { |
| | | this.baseMapper.deleteById(id); |
| | | |
| | |
| | | this.mallVipBenefitsDetailsService.remove(delQuery); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void editVipBenefits(MallVipBenefits mallVipBenefits) { |
| | | if (mallVipBenefits.getId() == null) { |
| | | throw new FebsException("缺少重要参数"); |
| | | } |
| | | |
| | | this.baseMapper.updateById(mallVipBenefits); |
| | | |
| | | LambdaQueryWrapper<MallVipBenefitsDetails> delQuery = new LambdaQueryWrapper<>(); |
| | | delQuery.eq(MallVipBenefitsDetails::getBenefitsId, mallVipBenefits.getId()); |
| | | this.mallVipBenefitsDetailsService.remove(delQuery); |
| | | |
| | | mallVipBenefits.getDetails().forEach(item -> { |
| | | item.setBenefitsId(mallVipBenefits.getId()); |
| | | }); |
| | | this.mallVipBenefitsDetailsService.saveBatch(mallVipBenefits.getDetails()); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package cc.mrbird.febs.vip.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.vip.entity.MallVipConfig; |
| | | import cc.mrbird.febs.vip.mapper.MallVipConfigMapper; |
| | | import cc.mrbird.febs.vip.service.IMallVipConfigService; |
| | | 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; |
| | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MallVipConfigServiceImpl extends ServiceImpl<MallVipConfigMapper, MallVipConfig> implements IMallVipConfigService { |
| | | |
| | | @Override |
| | | public IPage<MallVipConfig> vipConfigList(QueryRequest request) { |
| | | Page<MallVipConfig> page = new Page<>(request.getPageNum(), request.getPageNum()); |
| | | return this.baseMapper.findVipConfigListInPage(page); |
| | | } |
| | | } |
| | |
| | | <id property="id" column="id" /> |
| | | <result property="name" column="name" /> |
| | | <result property="type" column="type" /> |
| | | <result property="gainType" column="gain_type" /> |
| | | <result property="icon" column="icon" /> |
| | | <result property="multiple" column="multiple" /> |
| | | <result property="scoreMultiple" column="score_multiple" /> |
| | | <result property="remark" column="remark" /> |
| | | |
| | | <collection property="details" ofType="cc.mrbird.febs.vip.entity.MallVipBenefitsDetails"> |
| | |
| | | <result property="isClick" column="is_click" /> |
| | | <result property="linkType" column="link_type" /> |
| | | <result property="content" column="content" /> |
| | | <result property="benefitsId" column="benefits_id" /> |
| | | <result property="seq" column="seq" /> |
| | | </collection> |
| | | </resultMap> |
| | |
| | | ,benefitsDetail.content |
| | | ,benefitsDetail.seq |
| | | from mall_vip_benefits benefits |
| | | inner join mall_vip_benefits_details benefitsDetail on benefits.id=benefitsDetail.benefitsId |
| | | inner join mall_vip_benefits_details benefitsDetail on benefits.id=benefitsDetail.benefits_id |
| | | where benefits.id=#{id} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cc.mrbird.febs.vip.mapper.MallVipConfigMapper"> |
| | | |
| | | <resultMap id="VipBenefitsMap" type="cc.mrbird.febs.vip.entity.MallVipConfig"> |
| | | <!-- <id property="id" column="id" />--> |
| | | <!-- <result property="name" column="name" />--> |
| | | <!-- <result property="type" column="type" />--> |
| | | <!-- <result property="gainType" column="gain_type" />--> |
| | | <!-- <result property="icon" column="icon" />--> |
| | | <!-- <result property="scoreMultiple" column="score_multiple" />--> |
| | | <!-- <result property="remark" column="remark" />--> |
| | | |
| | | <!-- <collection property="details" ofType="cc.mrbird.febs.vip.entity.MallVipBenefitsDetails">--> |
| | | <!-- <id property="id" column="c_id" />--> |
| | | <!-- <result property="image" column="image" />--> |
| | | <!-- <result property="isClick" column="is_click" />--> |
| | | <!-- <result property="linkType" column="link_type" />--> |
| | | <!-- <result property="content" column="content" />--> |
| | | <!-- <result property="benefitsId" column="benefits_id" />--> |
| | | <!-- <result property="seq" column="seq" />--> |
| | | <!-- </collection>--> |
| | | </resultMap> |
| | | |
| | | <select id="findVipConfigListInPage" resultType="cc.mrbird.febs.vip.entity.MallVipBenefits"> |
| | | select * from mall_vip_config |
| | | </select> |
| | | |
| | | <select id="selectVipBenefitsById" resultMap="VipBenefitsMap"> |
| | | select |
| | | benefits.*, |
| | | benefitsDetail.id c_id |
| | | ,benefitsDetail.image |
| | | ,benefitsDetail.is_click |
| | | ,benefitsDetail.link_type |
| | | ,benefitsDetail.content |
| | | ,benefitsDetail.seq |
| | | from mall_vip_benefits benefits |
| | | inner join mall_vip_benefits_details benefitsDetail on benefits.id=benefitsDetail.benefits_id |
| | | where benefits.id=#{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | $(".linkContent").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | var $this = $(this); |
| | | $(this).off('blur') |
| | | $(this).on('blur', function() { |
| | | var data = $this.val(); |
| | | hasData[dataIndex - 1].content = data; |
| | |
| | | |
| | | $(".goodsSelect").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | $(this).off('click') |
| | | $(this).on('click', function() { |
| | | febs.modal.open('选择商品', 'modules/vip/config/goodsSelect/' + dataIndex, { |
| | | btn: ['提交', '取消'], |
| | |
| | | function listenerCouponSelect() { |
| | | $(".couponSelect").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | |
| | | $(this).off('click') |
| | | $(this).on('click', function() { |
| | | febs.modal.open('选择优惠券', 'modules/vip/config/couponSelect/' + dataIndex, { |
| | | btn: ['提交', '取消'], |
| | |
| | | |
| | | |
| | | var data = {}; |
| | | |
| | | if (isClickVal == 1) { |
| | | data.linkType = linkTypeVal; |
| | | } |
| | | data.isClick = isClickVal; |
| | | addTableDate(data); |
| | | |
| | |
| | | form.on('submit(vipBenefits-add-form-submit)', function (data) { |
| | | data.field.details = tableBenefitsItemsData; |
| | | $.ajax({ |
| | | 'url':ctx + 'admin/vip/benefits/addBenefits', |
| | | 'url':ctx + 'admin/vip/benefits/addOrEditBenefits', |
| | | 'type':'post', |
| | | 'dataType':'json', |
| | | 'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式 |
| | |
| | | <input type="text" id="awardImage{{d.index}}" name="awardImage{{d.index}}" autocomplete="off" value="{{d.image}}" class="layui-input febs-hide"> |
| | | </div> |
| | | </script> |
| | | |
| | | <!--<script type="text/html" id="seqInput">--> |
| | | <!-- <input type="text" name="seq" autocomplete="off" class="layui-input">--> |
| | | <!--</script>--> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="javascript"> |
| | | layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','dropdown', 'laydate', 'layedit', 'upload', 'element', 'table', 'xmSelect'], function () { |
| | |
| | | benefitsData = [[${benefitsData}]], |
| | | element = layui.element; |
| | | |
| | | var tableBenefitsItemsData=[]; |
| | | form.render(); |
| | | formSelects.render(); |
| | | |
| | | function initValue() { |
| | | form.val("goods-detail-form", { |
| | | "id": benefitsData.id, |
| | | "goodsNo": mailGoodsDetail.name, |
| | | "categoryId": mailGoodsDetail.categoryId, |
| | | "mailGoodsSkuDetailVo": mailGoodsDetail.mailGoodsSkuDetailVo, |
| | | "unit": mailGoodsDetail.unit, |
| | | "originalPrice": mailGoodsDetail.originalPrice, |
| | | "presentPrice": mailGoodsDetail.presentPrice, |
| | | "goodsIntrodution": mailGoodsDetail.goodsIntrodution, |
| | | "thumb": mailGoodsDetail.thumb, |
| | | "goodsDetails": mailGoodsDetail.goodsDetails, |
| | | "isHot": mailGoodsDetail.isHot, |
| | | "goodsName": mailGoodsDetail.goodsName |
| | | }); |
| | | } |
| | | |
| | | //图片上传 |
| | | upload.render({ |
| | |
| | | } |
| | | }); |
| | | |
| | | var tableBenefitsItemsData=[]; |
| | | var tableIns = table.render({ |
| | | elem: '#benefitsDetailsItem' |
| | | ,limit:999 |
| | |
| | | $(".linkContent").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | var $this = $(this); |
| | | $(this).off('blur') |
| | | $(this).on('blur', function() { |
| | | var data = $this.val(); |
| | | hasData[dataIndex - 1].content = data; |
| | |
| | | |
| | | $(".goodsSelect").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | $(this).off('click') |
| | | $(this).on('click', function() { |
| | | febs.modal.open('选择商品', 'modules/vip/config/goodsSelect/' + dataIndex, { |
| | | btn: ['提交', '取消'], |
| | |
| | | function listenerCouponSelect() { |
| | | $(".couponSelect").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | $(this).off('click') |
| | | $(this).on('click', function() { |
| | | febs.modal.open('选择优惠券', 'modules/vip/config/couponSelect/' + dataIndex, { |
| | | btn: ['提交', '取消'], |
| | |
| | | |
| | | |
| | | var data = {}; |
| | | if (isClickVal == 1) { |
| | | data.linkType = linkTypeVal; |
| | | } |
| | | data.isClick = isClickVal; |
| | | addTableDate(data); |
| | | |
| | |
| | | form.on('submit(vipBenefits-edit-form-submit)', function (data) { |
| | | data.field.details = tableBenefitsItemsData; |
| | | $.ajax({ |
| | | 'url':ctx + 'admin/vip/benefits/addBenefits', |
| | | 'url':ctx + 'admin/vip/benefits/addOrEditBenefits', |
| | | 'type':'post', |
| | | 'dataType':'json', |
| | | 'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式 |
| | |
| | | } |
| | | |
| | | tableBenefitsItemsData = hasData; |
| | | console.log(tableBenefitsItemsData) |
| | | $(".couponSelect").each(function(index, elem) { |
| | | var dataIndex = $(this).attr('data-index'); |
| | | if (dataIndex == tableIndex) { |
| | |
| | | }); |
| | | } |
| | | |
| | | initValue(); |
| | | function initValue() { |
| | | form.val("vipBenefits-edit-form", { |
| | | "id": benefitsData.id, |
| | | "name": benefitsData.name, |
| | | "gainType": benefitsData.gainType, |
| | | "type": benefitsData.type, |
| | | "scoreMultiple": benefitsData.scoreMultiple, |
| | | "remark": benefitsData.remark, |
| | | "icon":benefitsData.icon, |
| | | }); |
| | | |
| | | $('#demo2').attr('src', benefitsData.icon); |
| | | |
| | | var details = benefitsData.details; |
| | | for(var i = 0; i < details.length; i++) { |
| | | details[i].index = i + 1; |
| | | } |
| | | reloadTable(details); |
| | | |
| | | |
| | | tableBenefitsItemsData = details; |
| | | } |
| | | |
| | | }); |
| | | </script> |
| | | |
| | |
| | | table.on('tool(vipBenefitsTable)', function (obj) { |
| | | var data = obj.data, |
| | | layEvent = obj.event; |
| | | if (layEvent === 'newsInfoUpdate') { |
| | | febs.modal.open('编辑', 'modules/news/newsInfoUpdate/' + data.id, { |
| | | if (layEvent === 'benefitsUpdate') { |
| | | febs.modal.open('编辑', 'modules/vip/config/editBenefits/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#newsInfo-update').find('#submit').trigger('click'); |
| | | $('#febs-vipBenefits-edit').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'delNewsInfo') { |
| | | if (layEvent === 'delBenefits') { |
| | | febs.modal.confirm('删除', '确认删除?', function () { |
| | | delNewsInfo(data.id); |
| | | delBenefits(data.id); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | function delNewsInfo(id) { |
| | | febs.get(ctx + 'admin/news/delNewsInfo/' + id, null, function () { |
| | | function delBenefits(id) { |
| | | febs.get(ctx + 'admin/vip/benefits/delBenefits/' + id, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | }); |
| | |
| | | { |
| | | title: '操作', |
| | | templet: function (d) { |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="newsInfoUpdate" shiro:hasPermission="user:update">编辑</button>' |
| | | + '<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delNewsInfo" shiro:hasPermission="user:update">删除</button>' |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="benefitsUpdate" shiro:hasPermission="user:update">编辑</button>' |
| | | + '<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delBenefits" shiro:hasPermission="user:update">删除</button>' |
| | | }, minWidth: 300, align: 'center' |
| | | } |
| | | ]] |
New file |
| | |
| | | <style> |
| | | #vipConfig-add { |
| | | padding: 20px 25px 25px 0; |
| | | } |
| | | |
| | | #vipConfig-add .layui-treeSelect .ztree li a, .ztree li span { |
| | | margin: 0 0 2px 3px !important; |
| | | } |
| | | #vipConfig-add #data-permission-tree-block { |
| | | border: 1px solid #eee; |
| | | border-radius: 2px; |
| | | padding: 3px 0; |
| | | } |
| | | #vipConfig-add .layui-treeSelect .ztree li span.button.switch { |
| | | top: 1px; |
| | | left: 3px; |
| | | } |
| | | #vipConfig-add img{ |
| | | max-width:100px |
| | | } |
| | | |
| | | </style> |
| | | <div class="layui-fluid" id="febs-vipConfig-add"> |
| | | <form class="layui-form" action="" lay-filter="vipConfig-add-form"> |
| | | <div class="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="name" lay-verify="required" 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="number" name="level" lay-verify="required" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">主图:</label> |
| | | <div class="layui-input-block"> |
| | | <button type="button" class="layui-btn" id="imageUpload" style="background-color: #009688; margin-bottom: 2px">图片上传</button> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> |
| | | <div class=" layui-upload-list view-images" id="thumbImage"> |
| | | </div> |
| | | </blockquote> |
| | | <div class="febs-hide"> |
| | | <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <div class="layui-col-lg4"> |
| | | <label class="layui-form-label febs-form-item-require">有效期:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="number" name="validTime" lay-verify="required" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-lg2"> |
| | | <select name="validType" class="valid-type" lay-filter="valid-type-select"> |
| | | <option value="day">日</option> |
| | | <option value="month">月</option> |
| | | <option value="year">年</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | <div id="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="type" class="valid-type" lay-filter="type-select"> |
| | | <option value="1">指定商品</option> |
| | | <option value="2">时间区间内消费金额</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-col-lg6" id="targetGoods"> |
| | | <label class="layui-form-label febs-form-item-require">指定商品:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" name="targetName" placeholder="点击选择商品" autocomplete="off" class="layui-input" > |
| | | <input type="text" name="targetId" placeholder="点击选择商品" autocomplete="off" class="layui-input febs-hide" > |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-col-lg6 febs-hide" id="targetShopping"> |
| | | <div class="layui-input-inline"> |
| | | <input type="text" name="times" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | <div class="layui-form-mid">月内,消费</div> |
| | | <div class="layui-input-inline"> |
| | | <input type="text" name="times" autocomplete="off" class="layui-input" > |
| | | </div> |
| | | <div class="layui-form-mid">金额</div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label febs-form-item-require">选择会员权益:</label> |
| | | <div class="layui-input-block"> |
| | | <select name="benefitsIds" class="vip-benefits-list" id="vip-benefits-list"> |
| | | <option value="">请选择</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item febs-hide"> |
| | | <button class="layui-btn" lay-submit="" lay-filter="vipConfig-add-form-submit" id="submit"></button> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | <script data-th-inline="javascript"> |
| | | layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','layedit', 'laydate', 'upload'], function () { |
| | | var $ = layui.$, |
| | | febs = layui.febs, |
| | | layer = layui.layer, |
| | | upload = layui.upload, |
| | | formSelects = layui.formSelects, |
| | | form = layui.form, |
| | | laydate = layui.laydate, |
| | | layedit = layui.layedit, |
| | | $view = $('#vipConfig-add'), |
| | | validate = layui.validate; |
| | | |
| | | //(下拉框) |
| | | $.get(ctx + 'admin/vip/benefits/findAllBenefits', function (data) { |
| | | var arr = data.data; |
| | | for (let i = 0; i < arr.length; i++) { |
| | | $(".vip-benefits-list").append("<option value='" + arr[i].id + "'>" + arr[i].name + "</option>"); |
| | | } |
| | | layui.use('form', function () { |
| | | var form = layui.form; |
| | | form.render(); |
| | | }); |
| | | }); |
| | | |
| | | form.render(); |
| | | |
| | | formSelects.render(); |
| | | form.on('submit(vipConfig-add-form-submit)', function (data) { |
| | | febs.post(ctx + 'admin/news/addNewsInfo', data.field, function () { |
| | | layer.closeAll(); |
| | | febs.alert.success('操作成功'); |
| | | $('#febs-newInfo').find('#reset').click(); |
| | | }); |
| | | return false; |
| | | }); |
| | | |
| | | form.on('select(type-select)', function(data) { |
| | | if (data.value == 1) { |
| | | $("#targetGoods").show(); |
| | | $("#targetShopping").hide(); |
| | | } else { |
| | | $("#targetGoods").hide(); |
| | | $("#targetShopping").show(); |
| | | } |
| | | }) |
| | | |
| | | upload.render({ |
| | | elem: '#imageUpload' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,multiple: false |
| | | ,before: function(obj){ |
| | | //预读本地文件示例,不支持ie8 |
| | | obj.preview(function(index, file, result){ |
| | | $('#thumbImage').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') |
| | | }); |
| | | } |
| | | ,done: function(res){ |
| | | $("#thumb").val(res.data.src); |
| | | } |
| | | }); |
| | | |
| | | |
| | | bindUpload(); |
| | | function bindUpload() { |
| | | upload.render({ |
| | | elem: '.upload' |
| | | ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 |
| | | ,accept: 'file' |
| | | ,before: function(obj){ |
| | | layer.msg('上传中', {icon: 16, time: 0}); |
| | | } |
| | | ,done: function(res){ |
| | | var item = this.item; |
| | | //如果上传失败 |
| | | if(res.code !== 0){ |
| | | return layer.msg('上传失败'); |
| | | } |
| | | |
| | | // $(item).parent().prev().find('input').val(res.data[0]); |
| | | $("#videoUrl").val(res.data.src); |
| | | layer.msg('上传完毕', {icon: 1}); |
| | | } |
| | | ,error: function(err){ |
| | | return layer.msg('上传失败'); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | </script> |
New file |
| | |
| | | <div class="layui-fluid layui-anim febs-anim" id="febs-vip-level" 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="vip-benefits-level-table-form"> |
| | | <div class="layui-row"> |
| | | <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="vipBenefitsLevelTable" lay-data="{id: 'vipBenefitsLevelTable'}"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <style> |
| | | .layui-table-cell { |
| | | height: auto; |
| | | } |
| | | .layui-form-onswitch { |
| | | background-color: #5FB878 !important; |
| | | } |
| | | </style> |
| | | <!-- 表格操作栏 start --> |
| | | <script type="text/html" id="user-option"> |
| | | <span shiro:lacksPermission="vipConfig:view,vipConfig:update,vipConfig:delete"> |
| | | <span class="layui-badge-dot febs-bg-orange"></span> 无权限 |
| | | </span> |
| | | <a lay-event="edit" shiro:hasPermission="vipConfig: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-vip-level'), |
| | | $query = $view.find('#query'), |
| | | $add = $view.find('#add'), |
| | | $reset = $view.find('#reset'), |
| | | $searchForm = $view.find('form'), |
| | | sortObject = {field: 'phone', type: null}, |
| | | tableIns; |
| | | |
| | | form.render(); |
| | | |
| | | // 表格初始化 |
| | | initTable(); |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('tool(vipBenefitsLevelTable)', function (obj) { |
| | | var data = obj.data, |
| | | layEvent = obj.event; |
| | | if (layEvent === 'benefitsUpdate') { |
| | | febs.modal.open('编辑', 'modules/vip/config/editBenefits/' + data.id, { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#febs-vipConfig-edit').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | } |
| | | if (layEvent === 'delBenefits') { |
| | | febs.modal.confirm('删除', '确认删除?', function () { |
| | | delBenefits(data.id); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | function delBenefits(id) { |
| | | febs.get(ctx + 'admin/vip/benefits/delBenefits/' + 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/vip/config/levelAdd/', { |
| | | btn: ['提交', '取消'], |
| | | yes: function (index, layero) { |
| | | $('#febs-vipConfig-add').find('#submit').trigger('click'); |
| | | }, |
| | | btn2: function () { |
| | | layer.closeAll(); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | function initTable() { |
| | | tableIns = febs.table.init({ |
| | | elem: $view.find('table'), |
| | | id: 'vipBenefitsLevelTable', |
| | | url: ctx + 'admin/vip/config/list', |
| | | cols: [[ |
| | | {field: 'name', title: '会员名称', minWidth: 120, align: 'center'}, |
| | | { |
| | | field: 'icon', title: '主图', |
| | | templet: function (d) { |
| | | return ''; |
| | | }, minWidth: 150, align: 'center' |
| | | }, |
| | | {field: 'level', title: '等级', minWidth: 120, align: 'center'}, |
| | | {field: 'validType', title: '有效类型', minWidth: 120, align: 'center'}, |
| | | {field: 'type', title: '成为会员条件', minWidth: 120, align: 'center'}, |
| | | { |
| | | title: '操作', |
| | | templet: function (d) { |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="benefitsUpdate" shiro:hasPermission="user:update">编辑</button>' |
| | | + '<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delBenefits" shiro:hasPermission="user:update">删除</button>' |
| | | }, minWidth: 300, align: 'center' |
| | | } |
| | | ]] |
| | | }); |
| | | } |
| | | |
| | | // 获取查询参数 |
| | | function getQueryParams() { |
| | | return { |
| | | }; |
| | | } |
| | | }) |
| | | </script> |