| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 广告设置控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ITAdvertisementUserService itAdvertisementUserService; |
| | | @Autowired |
| | | private ITAdvertisementInformService itAdvertisementInformService; |
| | | @Autowired |
| | | private ITUserService userService; |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | /** |
| | | * 跳转到广告设置首页 |
| | | */ |
| | |
| | | tAdvertisementService.insert(tAdvertisement); |
| | | return SUCCESS_TIP; |
| | | } |
| | | @RequestMapping(value = "/addInfo1") |
| | | @ResponseBody |
| | | public Object add1(String userId,String driverId,String name,String content) { |
| | | TAdvertisement tAdvertisement = new TAdvertisement(); |
| | | tAdvertisement.setType(4); |
| | | tAdvertisement.setName(name); |
| | | tAdvertisement.setInsertTime(new Date()); |
| | | tAdvertisement.setInsertUser(ShiroKit.getUser().getId()); |
| | | tAdvertisement.setContent(content); |
| | | boolean insert = tAdvertisementService.insert(tAdvertisement); |
| | | if(insert){ |
| | | TAdvertisementInform tAdvertisementUser = new TAdvertisementInform(); |
| | | tAdvertisementUser.setAdvertisementId(tAdvertisement.getId()); |
| | | tAdvertisementUser.setDriverId(driverId); |
| | | tAdvertisementUser.setUserId(userId); |
| | | boolean insert1 = itAdvertisementInformService.insert(tAdvertisementUser); |
| | | // TODO 发送邮件 |
| | | if(insert1){ |
| | | Timer timer = new Timer(); |
| | | timer.schedule(new timerTaskTest(tAdvertisementUser.getId()),30*1000); |
| | | } |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | class timerTaskTest extends TimerTask { |
| | | private Integer id; |
| | | |
| | | public timerTaskTest(Integer id) { |
| | | this.id = id; |
| | | } |
| | | @Override |
| | | public void run() { |
| | | TAdvertisementInform tAdvertisementUser = itAdvertisementInformService.selectById(id); |
| | | // 司机所有 TODO |
| | | if("[]".equals(tAdvertisementUser.getDriverId())){ |
| | | System.out.println(1111111111); |
| | | List<TDriver> list = driverService.selectList(null); |
| | | for (TDriver tDriver : list) { |
| | | String email = tDriver.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | }else { |
| | | JSONArray driverId = JSON.parseArray(tAdvertisementUser.getDriverId()); |
| | | for(int j=0;j<driverId.size();j++){ |
| | | TDriver tDriver = driverService.selectById(driverId.getJSONObject(j).getInteger("userId")); |
| | | String email = tDriver.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | } |
| | | // 用户所有 |
| | | if("[]".equals(tAdvertisementUser.getUserId())){ |
| | | List<TUser> users = userService.selectList(null); |
| | | for (TUser user : users) { |
| | | String email = user.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | }else { |
| | | JSONArray driverId = JSON.parseArray(tAdvertisementUser.getUserId()); |
| | | for(int j=0;j<driverId.size();j++){ |
| | | TUser tUser = userService.selectById(driverId.getJSONObject(j).getInteger("userId")); |
| | | String email = tUser.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/addInfo") |
| | | @ResponseBody |
| | | public Object add(String userId,String driverId,String name,String content) { |
| | | TAdvertisement tAdvertisement = new TAdvertisement(); |
| | | tAdvertisement.setType(3); |
| | | tAdvertisement.setName(name); |
| | | tAdvertisement.setInsertTime(new Date()); |
| | | tAdvertisement.setInsertUser(ShiroKit.getUser().getId()); |
| | | tAdvertisement.setContent(content); |
| | | boolean insert = tAdvertisementService.insert(tAdvertisement); |
| | |
| | | tAdvertisementUser.setAdvertisementId(tAdvertisement.getId()); |
| | | tAdvertisementUser.setDriverId(driverId); |
| | | tAdvertisementUser.setUserId(userId); |
| | | itAdvertisementUserService.insert(tAdvertisementUser); |
| | | boolean insert1 = itAdvertisementUserService.insert(tAdvertisementUser); |
| | | |
| | | // TODO 发送邮件 |
| | | if(insert1){ |
| | | Timer timer = new Timer(); |
| | | timer.schedule(new timerTaskTest1(tAdvertisementUser.getId()),30*1000); |
| | | } |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | class timerTaskTest1 extends TimerTask { |
| | | private Integer id; |
| | | |
| | | public timerTaskTest1(Integer id) { |
| | | this.id = id; |
| | | } |
| | | @Override |
| | | public void run() { |
| | | TAdvertisementUser tAdvertisementUser = itAdvertisementUserService.selectById(id); |
| | | // 司机所有 TODO |
| | | if("[]".equals(tAdvertisementUser.getDriverId())){ |
| | | List<TDriver> list = driverService.selectList(null); |
| | | for (TDriver tDriver : list) { |
| | | String email = tDriver.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | }else { |
| | | JSONArray driverId = JSON.parseArray(tAdvertisementUser.getDriverId()); |
| | | for(int j=0;j<driverId.size();j++){ |
| | | TDriver tDriver = driverService.selectById(driverId.getJSONObject(j).getInteger("userId")); |
| | | String email = tDriver.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | } |
| | | // 用户所有 |
| | | if("[]".equals(tAdvertisementUser.getUserId())){ |
| | | List<TUser> users = userService.selectList(null); |
| | | for (TUser user : users) { |
| | | String email = user.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | }else { |
| | | JSONArray driverId = JSON.parseArray(tAdvertisementUser.getUserId()); |
| | | for(int j=0;j<driverId.size();j++){ |
| | | TUser tUser = userService.selectById(driverId.getJSONObject(j).getInteger("userId")); |
| | | String email = tUser.getEmail(); |
| | | if(ToolUtil.isNotEmpty(email)){ |
| | | // TODO 发送邮件 |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 删除广告设置 |
| | | */ |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.modular.system.model.City; |
| | | import com.stylefeng.guns.modular.system.model.TAdvertisement; |
| | | import com.stylefeng.guns.modular.system.service.ICityService; |
| | | import com.stylefeng.guns.modular.system.service.ITAdvertisementService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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 org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 广告设置控制器 |
| | | * |
| | | * @author fengshuonan |
| | | * @Date 2020-06-02 09:36:03 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/tAdvertisementInform") |
| | | public class TAdvertisementInformController extends BaseController { |
| | | |
| | | private String PREFIX = "/system/tAdvertisement/"; |
| | | |
| | | @Autowired |
| | | private ITAdvertisementService tAdvertisementService; |
| | | |
| | | @Autowired |
| | | private ICityService cityService; |
| | | |
| | | /** |
| | | * 跳转到广告设置首页 |
| | | */ |
| | | @RequestMapping("") |
| | | public String index() { |
| | | return PREFIX + "tAdvertisement_inform.html"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转到添加广告设置 |
| | | */ |
| | | @RequestMapping("/tAdvertisement_add") |
| | | public String tAdvertisementAdd(Model model) { |
| | | List<City> list = cityService.selectList(null); |
| | | model.addAttribute("list",list); |
| | | return PREFIX + "tAdvertisement_inform_add.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到修改广告设置 |
| | | */ |
| | | @RequestMapping("/tAdvertisement_update/{tAdvertisementId}") |
| | | public String tAdvertisementUpdate(@PathVariable Integer tAdvertisementId, Model model) { |
| | | TAdvertisement tAdvertisement = tAdvertisementService.selectById(tAdvertisementId); |
| | | model.addAttribute("item",tAdvertisement); |
| | | LogObjectHolder.me().set(tAdvertisement); |
| | | List<City> list = cityService.selectList(null); |
| | | model.addAttribute("list",list); |
| | | return PREFIX + "tAdvertisement_edit.html"; |
| | | } |
| | | @RequestMapping("user") |
| | | public String user() { |
| | | return PREFIX + "tUser.html"; |
| | | } |
| | | |
| | | @RequestMapping("driver") |
| | | public String driver() { |
| | | return PREFIX + "driver.html"; |
| | | } |
| | | |
| | | /** |
| | | * 获取广告设置列表 |
| | | */ |
| | | @RequestMapping(value = "/list") |
| | | @ResponseBody |
| | | public Object list() { |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | page.setRecords(tAdvertisementService.getAdvertisementList2(page)); |
| | | return super.packForBT(page); |
| | | } |
| | | |
| | | /** |
| | | * 新增广告设置 |
| | | */ |
| | | @RequestMapping(value = "/add") |
| | | @ResponseBody |
| | | public Object add(TAdvertisement tAdvertisement) { |
| | | tAdvertisement.setInsertTime(new Date()); |
| | | tAdvertisement.setInsertUser(ShiroKit.getUser().getId()); |
| | | tAdvertisementService.insert(tAdvertisement); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | /** |
| | | * 删除广告设置 |
| | | */ |
| | | @RequestMapping(value = "/delete") |
| | | @ResponseBody |
| | | public Object delete(@RequestParam Integer tAdvertisementId) { |
| | | tAdvertisementService.deleteById(tAdvertisementId); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | /** |
| | | * 操作广告设置 |
| | | */ |
| | | @RequestMapping(value = "/opt") |
| | | @ResponseBody |
| | | public Object opt(@RequestParam Integer tAdvertisementId,@RequestParam Integer optType) { |
| | | TAdvertisement tAdvertisement = tAdvertisementService.selectById(tAdvertisementId); |
| | | if (SinataUtil.isNotEmpty(tAdvertisement)){ |
| | | if (1 == optType.intValue()){ //上线 |
| | | tAdvertisement.setState(1); |
| | | }else if (2 == optType.intValue()){ //下线 |
| | | tAdvertisement.setState(2); |
| | | } |
| | | tAdvertisement.setUpdateTime(new Date()); |
| | | tAdvertisement.setUpdateUser(ShiroKit.getUser().getId()); |
| | | tAdvertisementService.updateById(tAdvertisement); |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | /** |
| | | * 修改广告设置 |
| | | */ |
| | | @RequestMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update(TAdvertisement tAdvertisement) { |
| | | tAdvertisement.setUpdateTime(new Date()); |
| | | tAdvertisement.setUpdateUser(ShiroKit.getUser().getId()); |
| | | tAdvertisementService.updateById(tAdvertisement); |
| | | return SUCCESS_TIP; |
| | | } |
| | | } |
| | |
| | | |
| | | List<Map<String, Object>> getAdvertisementList1(Page<Map<String, Object>> page); |
| | | |
| | | List<Map<String, Object>> getAdvertisementList2(Page<Map<String, Object>> page); |
| | | |
| | | } |
| | |
| | | |
| | | TAdvertisementUser selectTAdvertisementUser(Integer id); |
| | | |
| | | TAdvertisementUser selectTAdvertisementInform(Integer id); |
| | | } |
| | |
| | | SELECT * FROM (SELECT rr.chineseName as provinceName,aa.* FROM t_advertisement as aa |
| | | LEFT JOIN t_city as rr on rr.id = aa.cityId) as o where o.type=3 order by o.id desc |
| | | </select> |
| | | |
| | | <select id="getAdvertisementList2" resultType="java.util.Map"> |
| | | SELECT * FROM (SELECT rr.chineseName as provinceName,aa.* FROM t_advertisement as aa |
| | | LEFT JOIN t_city as rr on rr.id = aa.cityId) as o where o.type=4 order by o.id desc |
| | | |
| | | </select> |
| | | </mapper> |
| | |
| | | <select id="selectTAdvertisementUser" resultMap="BaseResultMap"> |
| | | select * from t_advertisement_user where advertisementId =#{id} |
| | | </select> |
| | | <select id="selectTAdvertisementInform" resultMap="BaseResultMap"> |
| | | select * from t_advertisement_inform where advertisementId =#{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | List<Map<String, Object>> getAdvertisementList1(@Param("page") Page<Map<String, Object>> page); |
| | | |
| | | |
| | | List<Map<String, Object>> getAdvertisementList2(Page<Map<String, Object>> page); |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | return advertisementList1; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getAdvertisementList2(Page<Map<String, Object>> page) { |
| | | List<Map<String, Object>> advertisementList1 = this.baseMapper.getAdvertisementList2(page); |
| | | for (Map<String, Object> stringObjectMap : advertisementList1) { |
| | | Integer id = (Integer)stringObjectMap.get("id"); |
| | | TAdvertisementUser tAdvertisementUser = tAdvertisementUserMapper.selectTAdvertisementInform(id); |
| | | if("[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | // all |
| | | stringObjectMap.put("sendUser",1); |
| | | }else if("[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | // driver |
| | | stringObjectMap.put("sendUser",2); |
| | | }else if(!"[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | stringObjectMap.put("sendUser",3); |
| | | }else if(!"[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
| | | stringObjectMap.put("sendUser",4); |
| | | } |
| | | } |
| | | return advertisementList1; |
| | | } |
| | | } |
New file |
| | |
| | | @layout("/common/_container.html"){ |
| | | <div class="row"> |
| | | <div class="col-sm-12"> |
| | | <div class="ibox float-e-margins"> |
| | | <div class="ibox-title"> |
| | | <h5>推送广告</h5> |
| | | </div> |
| | | <div class="ibox-content"> |
| | | <div class="row row-lg"> |
| | | <div class="col-sm-12"> |
| | | <div class="row"> |
| | | </div> |
| | | <div class="hidden-xs" id="TAdvertisementTableToolbar" role="group"> |
| | | @if(shiro.hasPermission("/tAdvertisement_defined/add")){ |
| | | <#button name="添加" icon="fa-plus" clickFun="TAdvertisement.openAddTAdvertisement()"/> |
| | | @} |
| | | @if(shiro.hasPermission("/tAdvertisement_defined/update")){ |
| | | <#button name="编辑" icon="fa-edit" clickFun="TAdvertisement.openTAdvertisementDetail()" space="true"/> |
| | | @} |
| | | @if(shiro.hasPermission("/tAdvertisement/delete")){ |
| | | <#button name="删除" icon="fa-remove" clickFun="TAdvertisement.delete()" space="true"/> |
| | | @} |
| | | </div> |
| | | <#table id="TAdvertisementTable"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <script src="${ctxPath}/static/modular/system/tAdvertisement/tAdvertisement_inform.js"></script> |
| | | <script> |
| | | laydate.render({ |
| | | elem: '#insertTime' |
| | | ,range: true |
| | | }); |
| | | </script> |
| | | @} |
New file |
| | |
| | | @layout("/common/_container.html"){ |
| | | <div class="ibox float-e-margins"> |
| | | <div class="ibox-content"> |
| | | <div class="form-horizontal" id="advertisementInfoForm"> |
| | | |
| | | <div class="row"> |
| | | <div class="col-sm-10"> |
| | | <#input id="name" name="通知标题"/> |
| | | <div class="form-group" id="contentDiv"> |
| | | <label class="col-sm-3 control-label">通知内容:</label> |
| | | <div class="col-sm-9"> |
| | | <textarea type="text/plain" id="editor" style="width:100%;height:350px;"></textarea> |
| | | </div> |
| | | </div> |
| | | <div class="form-group"> |
| | | <label class="col-sm-3 control-label">发送对象:</label> |
| | | <div class="col-sm-9" style="display: flex;align-items: center;"> |
| | | <div class="radio radio-info radio-inline"> |
| | | <input type="radio" id="sendType1" value="1" name="sendType" checked="" > |
| | | <label for="sendType1"> 全部用户 </label> |
| | | </div> |
| | | <div class="radio radio-success radio-inline"> |
| | | <input type="radio" id="sendType2" value="2" name="sendType" > |
| | | <label for="sendType2"> 选择用户 </label> |
| | | </div> |
| | | <#button name="选择" icon="fa-plus" clickFun="TAdvertisementInfoDlg.toSelectUserOpt()"/> |
| | | <div class="form-group"> |
| | | <label class="col-sm-3 control-label">已添加用户</label> |
| | | <div class="col-sm-9"> |
| | | <div style="height: 200px; border: 1px solid #e5e6e7;overflow-y: auto;"> |
| | | <table class="table table-striped table-bordered table-hover table-condensed"> |
| | | <thead> |
| | | <tr> |
| | | <th style="width: 300px;">用户昵称</th> |
| | | <th style="width: 300px;">手机号</th> |
| | | <th style="width: 300px;">注册地所属分公司</th> |
| | | <th style="width: 100px;">操作</th> |
| | | </tr> |
| | | </thead> |
| | | <tbody id="coun"> |
| | | |
| | | </tbody> |
| | | </table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="col-sm-9 left:50px" style="display: flex;align-items: center;left: 341px;"> |
| | | <div class="radio radio-info radio-inline"> |
| | | <input type="radio" id="sendType3" value="1" name="sendType1" checked="" > |
| | | <label for="sendType1"> 全部司机 </label> |
| | | </div> |
| | | <div class="radio radio-success radio-inline"> |
| | | <input type="radio" id="sendType4" value="2" name="sendType1" > |
| | | <label for="sendType2"> 选择司机 </label> |
| | | </div> |
| | | <#button name="选择" icon="fa-plus" clickFun="TAdvertisementInfoDlg.toSelectUserOpt1()"/> |
| | | <div class="form-group"> |
| | | <label class="col-sm-3 control-label">已添加司机</label> |
| | | <div class="col-sm-9"> |
| | | <div style="height: 200px; border: 1px solid #e5e6e7;overflow-y: auto;"> |
| | | <table class="table table-striped table-bordered table-hover table-condensed"> |
| | | <thead> |
| | | <tr> |
| | | <th style="width: 300px;">司机昵称</th> |
| | | <th style="width: 300px;">手机号</th> |
| | | <th style="width: 300px;">注册地所属分公司</th> |
| | | <th style="width: 100px;">操作</th> |
| | | </tr> |
| | | </thead> |
| | | <tbody id="coun1"> |
| | | |
| | | </tbody> |
| | | </table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="row btn-group-m-t"> |
| | | <div class="col-sm-10 col-sm-offset-5"> |
| | | <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="TAdvertisementInfoDlg.addSubmit2()"/> |
| | | <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="TAdvertisementInfoDlg.close()"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | <script src="${ctxPath}/static/modular/system/tAdvertisement/tAdvertisement_info.js"></script> |
| | | @} |
| | |
| | | ajax.set("content",editor) |
| | | ajax.start(); |
| | | } |
| | | TAdvertisementInfoDlg.addSubmit2 = function() { |
| | | this.clearData(); |
| | | this.collectData(); |
| | | var name = $("#name").val(); |
| | | var editor = TAdvertisementInfoDlg.editor.getContent(); |
| | | if ("" == name){ |
| | | Feng.info("请输入通知标题"); |
| | | return; |
| | | } |
| | | var subArr=[]; |
| | | $(".timeClass").each(function () { |
| | | subArr.push({ |
| | | userId:$(this).find("input[name*='userId']").val(), |
| | | }) |
| | | }); |
| | | var subArr1=[]; |
| | | $(".timeClass1").each(function () { |
| | | subArr1.push({ |
| | | //companyName,nickName,phone |
| | | userId:$(this).find("input[name*='userId']").val(), |
| | | }) |
| | | }); |
| | | var sendType = $("input[name='sendType']:checked").val(); |
| | | console.log(sendType) |
| | | if(sendType==2 && subArr.length <= 0){ |
| | | Feng.error("请选择用户"); |
| | | return; |
| | | } |
| | | console.log(subArr) |
| | | console.log(subArr1) |
| | | //提交信息 |
| | | var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/addInfo1", function(data){ |
| | | Feng.success("添加成功!"); |
| | | window.parent.TAdvertisement.table.refresh(); |
| | | TAdvertisementInfoDlg.close(); |
| | | },function(data){ |
| | | Feng.error("添加失败!" + data.responseJSON.message + "!"); |
| | | }); |
| | | ajax.set("userId",JSON.stringify(subArr)) |
| | | ajax.set("driverId",JSON.stringify(subArr1)) |
| | | ajax.set("name",name) |
| | | ajax.set("content",editor) |
| | | ajax.start(); |
| | | } |
| | | |
| | | /** |
| | | * 提交修改 |
New file |
| | |
| | | /** |
| | | * 广告设置管理初始化 |
| | | */ |
| | | var TAdvertisement = { |
| | | id: "TAdvertisementTable", //表格id |
| | | seItem: null, //选中的条目 |
| | | table: null, |
| | | layerIndex: -1 |
| | | }; |
| | | |
| | | /** |
| | | * 初始化表格的列 |
| | | */ |
| | | TAdvertisement.initColumn = function () { |
| | | return [ |
| | | {field: 'selectItem', radio: true}, |
| | | {title: '主键ID', field: 'id', visible: false, align: 'center', valign: 'middle'}, |
| | | {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'10%', |
| | | formatter: function (value, row) { |
| | | var btn = ""; |
| | | if(row.insertTime != '' && row.insertTime != null) { |
| | | var time = row.insertTime.replace(" ",'<br>'); |
| | | btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.insertTime + '" onfocus="TUser.tooltip()">' + time + '</p>'] |
| | | } |
| | | return btn; |
| | | } |
| | | }, |
| | | {title: '公告标题', field: 'name', visible: true, align: 'center', valign: 'middle', |
| | | formatter: function (value, row) { |
| | | var btn = ""; |
| | | if(row.name != '' && row.name != null) { |
| | | btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.name + '" onfocus="TUser.tooltip()">' + row.name + '</p>'] |
| | | } |
| | | return btn; |
| | | } |
| | | }, |
| | | {title: '发送对象', field: 'sendUser', visible: true, align: 'center', valign: 'middle', |
| | | formatter:function (data) { |
| | | if(data==1){ |
| | | return '所有用户/所有司机' |
| | | } |
| | | if(data==2){ |
| | | return '部分用户/所有司机' |
| | | } |
| | | if(data==3){ |
| | | return '所有用户/部分司机' |
| | | } |
| | | if(data==4){ |
| | | return '部分用户/部分司机' |
| | | } |
| | | } |
| | | }, |
| | | {title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle', |
| | | formatter:function (data) { |
| | | return "已发送" |
| | | } |
| | | }, |
| | | ]; |
| | | }; |
| | | |
| | | /** |
| | | * 检查是否选中 |
| | | */ |
| | | TAdvertisement.check = function () { |
| | | var selected = $('#' + this.id).bootstrapTable('getSelections'); |
| | | if(selected.length == 0){ |
| | | Feng.info("请先选中表格中的某一记录!"); |
| | | return false; |
| | | }else{ |
| | | TAdvertisement.seItem = selected[0]; |
| | | return true; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 点击添加广告设置 |
| | | */ |
| | | TAdvertisement.openAddTAdvertisement = function () { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '添加通知', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tAdvertisementInform/tAdvertisement_add' |
| | | }); |
| | | this.layerIndex = index; |
| | | }; |
| | | |
| | | /** |
| | | * 打开查看广告设置详情 |
| | | */ |
| | | TAdvertisement.openTAdvertisementDetail = function () { |
| | | if (this.check()) { |
| | | var index = layer.open({ |
| | | type: 2, |
| | | title: '编辑广告图', |
| | | area: ['100%', '100%'], //宽高 |
| | | fix: false, //不固定 |
| | | maxmin: true, |
| | | content: Feng.ctxPath + '/tAdvertisementDefined/tAdvertisement_update/' + TAdvertisement.seItem.id |
| | | }); |
| | | this.layerIndex = index; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 删除广告设置 |
| | | */ |
| | | TAdvertisement.delete = function () { |
| | | if (this.check()) { |
| | | var name = TAdvertisement.seItem.name; |
| | | if (name == "" || name == null || name == undefined) { |
| | | name = "该广告"; |
| | | } else { |
| | | name = "【" + name + "】"; |
| | | } |
| | | swal({ |
| | | title: "您是否确认删除" + name + "?", |
| | | text: "请谨慎操作,删除后不可恢复!", |
| | | type: "warning", |
| | | showCancelButton: true, |
| | | confirmButtonColor: "#DD6B55", |
| | | confirmButtonText: "删除", |
| | | closeOnConfirm: false |
| | | }, function () { |
| | | var ajax = new $ax(Feng.ctxPath + "/tAdvertisementInform/delete", function (data) { |
| | | swal("删除成功", "您已经成功删除了" + name + "。", "success"); |
| | | TAdvertisement.table.refresh(); |
| | | }, function (data) { |
| | | swal("删除失败", "warning"); |
| | | }); |
| | | ajax.set("tAdvertisementId",TAdvertisement.seItem.id); |
| | | ajax.start(); |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 上线 |
| | | */ |
| | | TAdvertisement.up = function(){ |
| | | if (this.check()) { |
| | | var name = TAdvertisement.seItem.name; |
| | | if (name == "" || name == null || name == undefined) { |
| | | name = "该广告"; |
| | | } else { |
| | | name = "【" + name + "】"; |
| | | } |
| | | if (TAdvertisement.seItem.state != 2) { |
| | | swal("上线失败", "【已下线】状态下才能执行此操作", "warning"); |
| | | return; |
| | | } else { |
| | | swal({ |
| | | title: "您是否确认上线" + name + "?", |
| | | text: "请谨慎操作!", |
| | | type: "warning", |
| | | showCancelButton: true, |
| | | confirmButtonColor: "#DD6B55", |
| | | confirmButtonText: "上线", |
| | | closeOnConfirm: false |
| | | }, function () { |
| | | var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/opt", function (data) { |
| | | swal("上线成功", "您已经成功上线了" + name + "。", "success"); |
| | | TAdvertisement.table.refresh(); |
| | | }, function (data) { |
| | | swal("上线失败", data.responseJSON.message + "!", "warning"); |
| | | }); |
| | | ajax.set("tAdvertisementId", TAdvertisement.seItem.id); |
| | | ajax.set("optType", 1); |
| | | ajax.start(); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下线 |
| | | */ |
| | | TAdvertisement.down = function(){ |
| | | if (this.check()) { |
| | | var name = TAdvertisement.seItem.name; |
| | | if (name == "" || name == null || name == undefined) { |
| | | name = "该广告"; |
| | | } else { |
| | | name = "【" + name + "】"; |
| | | } |
| | | if (TAdvertisement.seItem.state != 1) { |
| | | swal("下线失败", "【已上线】状态下才能执行此操作", "warning"); |
| | | return; |
| | | } else { |
| | | swal({ |
| | | title: "您是否确认下线" + name + "?", |
| | | text: "请谨慎操作!", |
| | | type: "warning", |
| | | showCancelButton: true, |
| | | confirmButtonColor: "#DD6B55", |
| | | confirmButtonText: "下线", |
| | | closeOnConfirm: false |
| | | }, function () { |
| | | var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/opt", function (data) { |
| | | swal("下线成功", "您已经成功下线了" + name + "。", "success"); |
| | | TAdvertisement.table.refresh(); |
| | | }, function (data) { |
| | | swal("下线失败", data.responseJSON.message + "!", "warning"); |
| | | }); |
| | | ajax.set("tAdvertisementId", TAdvertisement.seItem.id); |
| | | ajax.set("optType", 2); |
| | | ajax.start(); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询广告设置列表 |
| | | */ |
| | | TAdvertisement.search = function () { |
| | | var queryData = {}; |
| | | TAdvertisement.table.refresh({query: queryData}); |
| | | }; |
| | | TAdvertisement.resetSearch = function () { |
| | | $("#insertTime").val(""); |
| | | $("#name").val(""); |
| | | $("#type").val(""); |
| | | TAdvertisement.search(); |
| | | }; |
| | | |
| | | $(function () { |
| | | var defaultColunms = TAdvertisement.initColumn(); |
| | | var table = new BSTable(TAdvertisement.id, "/tAdvertisementInform/list", defaultColunms); |
| | | table.setPaginationType("server"); |
| | | TAdvertisement.table = table.init(); |
| | | }); |