Ver código fonte

微信模板管理

wujunjie 7 anos atrás
pai
commit
3da3336300

+ 100 - 26
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/notification/WechatTemplateController.java

@ -1,19 +1,9 @@
package com.yihu.wlyy.controller.manager.notification;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.WlyyAuditNotice;
import com.yihu.wlyy.entity.WlyyAuditNoticeScope;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.service.manager.notification.WlyyAuditNoticeScopeService;
import com.yihu.wlyy.service.manager.notification.WlyyAuditNoticeService;
import com.yihu.wlyy.service.manager.wechat.WechatTemplateService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import com.yihu.wlyy.service.wechat.WechatService;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
@ -23,7 +13,6 @@ import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @Description: 微信模板管理
@ -36,18 +25,35 @@ public class WechatTemplateController extends BaseController {
    @Autowired
    private WechatTemplateService wechatTemplateService;
    @Autowired
    private WlyyAuditNoticeScopeService wlyyAuditNoticeScopeService;
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    /**
     * 列表页面初始化数据
     * @param model
     * @return
     */
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationListInitial(Model model) {
    public String listInitial(Model model) {
        System.out.println("initial model"+model);
        return "wechat/wechat_list";
    }
    /**
     * 编辑、查看、新增页面初始化数据
     * @param
     * @return
     */
    @RequestMapping(value = "editInitial", method = RequestMethod.GET)
    @ApiIgnore
    public String editInitial(String templateName,String scene,String mode) {
        request.setAttribute("templateName",templateName);
        request.setAttribute("scene",scene);
        request.setAttribute("mode",mode);
        System.out.println("editInitial mode "+mode);
        System.out.println("editInitial templateName "+templateName);
        System.out.println("editInitial scene "+scene);
        return "wechat/wechat_edit";
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息
     * @param templateName
@ -69,8 +75,9 @@ public class WechatTemplateController extends BaseController {
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int pageSize) {
        try {
            Page<WechatTemplateConfig> templetes = wechatTemplateService.searchList(templateName, scene, page, pageSize);
            return write(200, "操作成功", page, pageSize, templetes);
            List<WechatTemplateConfig> templetes = wechatTemplateService.searchList(templateName, scene, page, pageSize);
            int count = wechatTemplateService.getListCount(templateName, scene);
            return write(200, "操作成功", page, pageSize,count, templetes);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
@ -88,11 +95,11 @@ public class WechatTemplateController extends BaseController {
    @ResponseBody
    public String getTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene) {
            @RequestParam(value = "scene", required = true) String scene) {
        try {
            WechatTemplateConfig templete = wechatTemplateService.getTemplate(templateName, scene);
            List<Map<String,Object>> templete = wechatTemplateService.getTemplate(templateName, scene);
            return write(200, "操作成功", "data",templete);
        } catch (Exception ex) {
            error(ex);
@ -101,7 +108,7 @@ public class WechatTemplateController extends BaseController {
    }
    /**
     * 新增或修改模板详情
     * 修改模板详情
     * @param templateName
     * @param scene
     * @return
@ -111,10 +118,32 @@ public class WechatTemplateController extends BaseController {
    @ResponseBody
    public String updateTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene) {
            @RequestParam(value = "scene", required = true) String scene,
            @ApiParam(name = "sceneDescription", value = "模板场景描述")
            @RequestParam(value = "sceneDescription", required = true) String sceneDescription,
            @ApiParam(name = "first", value = "first")
            @RequestParam(value = "first", required = false) String first,
            @ApiParam(name = "remark", value = "remark")
            @RequestParam(value = "remark", required = false) String remark,
            @ApiParam(name = "value1", value = "value1")
            @RequestParam(value = "value1", required = false) String value1,
            @ApiParam(name = "value2", value = "value2")
            @RequestParam(value = "value2", required = false) String value2,
            @ApiParam(name = "value3", value = "value3")
            @RequestParam(value = "value3", required = false) String value3,
            @ApiParam(name = "value4", value = "value4")
            @RequestParam(value = "value4", required = false) String value4,
            @ApiParam(name = "value5", value = "value5")
            @RequestParam(value = "value5", required = false) String value5,
            @ApiParam(name = "value6", value = "value6")
            @RequestParam(value = "value6", required = false) String value6,
            @ApiParam(name = "value7", value = "value7")
            @RequestParam(value = "value7", required = false) String value7) {
        try {
            wechatTemplateService.updateTemplate(templateName, scene,sceneDescription,first,remark,
                    value1,value2,value3,value4,value5,value6,value7);
            return write(200, "操作成功", "data","");
        } catch (Exception ex) {
            error(ex);
@ -122,5 +151,50 @@ public class WechatTemplateController extends BaseController {
        }
    }
    /**
     * 新增模板详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "saveTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String saveTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = true) String scene,
            @ApiParam(name = "sceneDescription", value = "模板场景描述")
            @RequestParam(value = "sceneDescription", required = true) String sceneDescription,
            @ApiParam(name = "first", value = "first")
            @RequestParam(value = "first", required = false) String first,
            @ApiParam(name = "remark", value = "remark")
            @RequestParam(value = "remark", required = false) String remark,
            @ApiParam(name = "value1", value = "value1")
            @RequestParam(value = "value1", required = false) String value1,
            @ApiParam(name = "value2", value = "value2")
            @RequestParam(value = "value2", required = false) String value2,
            @ApiParam(name = "value3", value = "value3")
            @RequestParam(value = "value3", required = false) String value3,
            @ApiParam(name = "value4", value = "value4")
            @RequestParam(value = "value4", required = false) String value4,
            @ApiParam(name = "value5", value = "value5")
            @RequestParam(value = "value5", required = false) String value5,
            @ApiParam(name = "value6", value = "value6")
            @RequestParam(value = "value6", required = false) String value6,
            @ApiParam(name = "value7", value = "value7")
            @RequestParam(value = "value7", required = false) String value7) {
        try {
            Map<String,Object> result = wechatTemplateService.saveTemplate(templateName, scene,sceneDescription,first,remark,
                    value1,value2,value3,value4,value5,value6,value7);
            int code = Integer.parseInt(result.get("code").toString());
            String msg = result.get("msg").toString();
            return write(code, msg);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 139 - 23
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/wechat/WechatTemplateService.java

@ -3,23 +3,18 @@ package com.yihu.wlyy.service.manager.wechat;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.service.SMSService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyRoleService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SQLQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -31,14 +26,15 @@ import java.util.Map;
@Service
public class WechatTemplateService extends BaseJpaService<WlyyAuditNotice, WlyyAuditNoticeDao> {
    @Autowired
    private WlyyRoleDao wlyyRoleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WechatTemplateConfigDao wechatTemplateConfigDao;
    /**
     * 根据模板自定义名称和场景值查询模板消息
     *
     * @param templateName
     * @param scene
     * @param page
@ -46,47 +42,167 @@ public class WechatTemplateService extends BaseJpaService<WlyyAuditNotice, WlyyA
     * @return
     * @throws Exception
     */
    public Page<WechatTemplateConfig> searchList(String templateName, String scene, int page, int pageSize) throws Exception {
    public List<WechatTemplateConfig> searchList(String templateName, String scene, int page, int pageSize) throws Exception {
        if (page <= 0) {
            page = 1;
        }
        if (pageSize <= 0) {
            pageSize = 15;
        }
        PageRequest pageRequest = new PageRequest(page - 1, pageSize);
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "templateName?" + templateName + ";";
            filters = "and t.template_name= '" + templateName + "' ";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += "scene=" + scene + ";";
            filters += " and t.scene= '" + scene + "' ";
        }
        filters += " order by t.id asc limit " + (page-1)*pageSize +"," +pageSize;
        String sql = "SELECT t.* FROM `weixin_template_config` t WHERE t.`status` = 1 "
                + filters ;
        List<WechatTemplateConfig> WechatTemplateConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(WechatTemplateConfig.class));
        return WechatTemplateConfigs;
    }
        List<WechatTemplateConfig> list = search("", filters, "", page, pageSize);
        return new PageImpl<WechatTemplateConfig>(list, pageRequest, getCount(filters));
    /**
     * 根据模板自定义名称和场景值查询模板消息
     *
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    public int getListCount(String templateName, String scene) throws Exception {
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "and t.template_name= '" + templateName + "' ";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += " and t.scene= '" + scene + "' ";
        }
        filters += " order by t.id asc ";
        String sql = "SELECT t.* FROM `weixin_template_config` t WHERE t.`status` = 1 "
                + filters ;
        List<WechatTemplateConfig> WechatTemplateConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(WechatTemplateConfig.class));
        return WechatTemplateConfigs.size();
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息详情
     *
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    public WechatTemplateConfig getTemplate(String templateName, String scene) throws Exception {
    public List<Map<String,Object>> getTemplate(String templateName, String scene) throws Exception {
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "templateName=" + templateName + ";";
            filters = " AND templateName= '" + templateName + "' ";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += "scene=" + scene + ";";
            filters += " AND scene= '" + scene + "' ";
        }
        String sql = "SELECT t.template_name, t.template_title, t.format, c.`first`, " +
        String sql = "SELECT t.template_name, c.scene, t.format, c.`first`, " +
                " c.keyword1 , c.keyword2, c.keyword3, c.keyword4, c.keyword5, c.keyword6 , c.keyword7, c.remark " +
                " FROM weixin_template t, weixin_template_config c " +
                " WHERE t.template_name = c.template_name AND c.scene = ''";
        return null;
                " WHERE t.template_name = c.template_name " +
                filters;
        List<Map<String,Object>> WechatTemplateConfig = jdbcTemplate.queryForList(sql);
        return WechatTemplateConfig;
    }
    /**
     * 修改模板详细信息
     *
     * @param templateName
     * @param scene
     * @param sceneDescription
     * @param first
     * @param remark
     * @param value1
     * @param value2
     * @param value3
     * @param value4
     * @param value5
     * @param value6
     * @param value7
     * @return
     * @throws Exception
     */
    public void updateTemplate(String templateName, String scene, String sceneDescription, String first, String remark,
                               String value1, String value2, String value3, String value4, String value5, String value6, String value7) throws Exception {
//      保持数据唯一性
        WechatTemplateConfig wechatTemplateConfig = wechatTemplateConfigDao.findByScene(templateName, scene);
        if (wechatTemplateConfig != null) {
            wechatTemplateConfig.setTemplateName(templateName);
            wechatTemplateConfig.setScene(scene);
            wechatTemplateConfig.setSceneDescription(sceneDescription);
            wechatTemplateConfig.setFirst(first);
            wechatTemplateConfig.setRemark(remark);
            wechatTemplateConfig.setKeyword1(value1);
            wechatTemplateConfig.setKeyword2(value2);
            wechatTemplateConfig.setKeyword3(value3);
            wechatTemplateConfig.setKeyword4(value4);
            wechatTemplateConfig.setKeyword5(value5);
            wechatTemplateConfig.setKeyword6(value6);
            wechatTemplateConfig.setKeyword7(value7);
            wechatTemplateConfig.setStatus(1);
            if (StringUtils.isEmpty(first)) {
                wechatTemplateConfig.setFirst("");
            }
            wechatTemplateConfigDao.save(wechatTemplateConfig);
        }
    }
    /**
     * 保存模板详细信息
     *
     * @param templateName
     * @param scene
     * @param sceneDescription
     * @param first
     * @param remark
     * @param value1
     * @param value2
     * @param value3
     * @param value4
     * @param value5
     * @param value6
     * @param value7
     * @return
     * @throws Exception
     */
    public Map<String,Object> saveTemplate(String templateName, String scene, String sceneDescription, String first, String remark,
                               String value1, String value2, String value3, String value4, String value5, String value6, String value7) throws Exception {
        Map<String,Object> result = new HashMap<>();
        result.put("code",200);
        result.put("msg","保持成功!");
        //      保持数据唯一性
        WechatTemplateConfig wechatTemplateConfig = wechatTemplateConfigDao.findByScene(templateName, scene);
        if (wechatTemplateConfig != null) {
            result.put("code",-1);
            result.put("msg","该模板消息场景已存在!");
            return result;
        }
        wechatTemplateConfig.setTemplateName(templateName);
        wechatTemplateConfig.setScene(scene);
        wechatTemplateConfig.setSceneDescription(sceneDescription);
        wechatTemplateConfig.setFirst(first);
        wechatTemplateConfig.setRemark(remark);
        wechatTemplateConfig.setKeyword1(value1);
        wechatTemplateConfig.setKeyword2(value2);
        wechatTemplateConfig.setKeyword3(value3);
        wechatTemplateConfig.setKeyword4(value4);
        wechatTemplateConfig.setKeyword5(value5);
        wechatTemplateConfig.setKeyword6(value6);
        wechatTemplateConfig.setKeyword7(value7);
        wechatTemplateConfig.setStatus(1);
        if (StringUtils.isEmpty(first)) {
            wechatTemplateConfig.setFirst("");
        }
        wechatTemplateConfigDao.save(wechatTemplateConfig);
        return result;
    }
}

+ 67 - 154
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit.jsp

@ -1,184 +1,97 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
	<%@ include file="../head/page_head.jsp"%>
	<title>机构管理</title>
	<title>模板详情</title>
	<style type="text/css">
		.m-form-group label.label_title{width: 100px}
	</style>
</head>
<style>
	.m-form-group label.label_title {
		width: 100px
	}
	.m-form-group p.tip {
		width: auto;
        margin-left: 100px;
        line-height: 20px;
	}
	.m-form-group ul li{
		line-height: 30px;
		margin-left: 100px;
	}
	.m-form-group .inpRadio{
		 vertical-align: bottom;
		 margin: 8px 0 0;
	 }
	.m-form-group .inpChkb{
		vertical-align: sub;
	}
	.m-form-group .l-text-date{
		width: 140px;
	}
	.m-form-group .sendTime{
		width: 138px;
	}
    .m-form-group  span.community{
        width: 50px;
        display: inline-flex;
    }
	.f-pa{
		position: relative;
	}
	.f-pa .m-form-control{
		margin-left: 200px;
		margin-top: 10px;
	}
	.wordwrap{
		float: left;
		display: block;
		margin: 140px 0 0 10px;
	}
	.wordCount .word{
		color: red;
		padding: 0 4px;
	}
	#messageContent .j-text-wrapper{
		float: left;
	}
	#messageContent .l-text-trigger-cancel{
		display: none!important;
	}
</style>
<body>
<div id="div_roles_info_form" class="m-form-inline f-mt20 f-ml30"
	 data-role-form>
	<input type="hidden" id="uuid" value='${UUID}'/>
	<input type="hidden" id="cityAuthority" value='${cityAuthority}'/>
	<input type="hidden" id="areaAuthority" value='${areaAuthority}'/>
	<input type="hidden" id="communityAuthority" value='${communityAuthority}'/>
	<input type="hidden" id="mode" value='${mode}'/>
	<input type="hidden" id="scopeId"/>
	<input type="hidden" id="diseaseTypeId"/>
	<input type="hidden" id="healthSituationId"/>
	<input type="hidden" id="serverTypeId"/>
	<input type="hidden" id="noticeId" value='${id}' data-attr-scan="id" />
<div id="div_template_info_form" data-role-form class="m-form-inline f-mt20 f-ml30" data-role-form>
	<input type="hidden" id="inp_mode" value='${mode}'/>
	<div class="m-form-group" style="padding:10 0 10 0">
		<label class="label_title" style="width:120px">模板名称</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_templateName" readonly class="required useTitle ajax f-w240 validate-special-char"  required-title="模板名称不能为空"  data-attr-scan="templateName" value='${templateName}'/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="">发送范围:</label>
		<div class="u-radio-wrap m-form-control">
			<input type="radio" value="0" name="scope" id="cityScope" class="inpRadio" data-attr-scan=""> 全市
			<input type="radio" value="1" name="scope" id="areaScope" class="inpRadio" data-attr-scan=""> 指定区
			<input type="radio" value="2" name="scope" id="communityScope" class="inpRadio" data-attr-scan=""> 指定社区
		<label class="label_title" style="width:120px">模板场景值</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_scene" readonly class="required useTitle f-w240 validate-special-char"  required-title="模板场景值不能为空"  data-attr-scan="scene" value='${scene}'/>
		</div>
	</div>
	<div class="m-form-group" id="scope_area" style="display: none">
		<label class="label_title" style="">选择区:</label>
		<div class="u-checkbox-wrap m-form-control scope_areaDiv">
			<%--<input type="checkbox" name="scope_area" class="inpChkb" value="1" data-attr-scan>选项一--%>
			<%--<input type="checkbox" name="scope_area" class="inpChkb" value="2" data-attr-scan>选项二--%>
			<%--<input type="checkbox" name="scope_area" class="inpChkb" value="3" data-attr-scan>选项三--%>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">模板场景描述</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_sceneDescription" readonly class="required useTitle f-w240 validate-special-char" required-title="模板场景描述不能为空"  required-title="请输入模板场景描述"  data-attr-scan="sceneDescription"/>
		</div>
	</div>
	<div class="m-form-group" id="scope_community" style="display: none">
		<label class="label_title" style="">选择社区:</label>
		<div class="m-form-control scope_communityDiv" style="margin-top: 5px;">
			<%--<input type="checkbox" name="scope_community" class="inpChkb" value="1" data-attr-scan>选项一--%>
			<%--<input type="checkbox" name="scope_community" class="inpChkb" value="2" data-attr-scan>选项二--%>
			<%--<input type="checkbox" name="scope_community" class="inpChkb" value="3" data-attr-scan>选项三--%>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">first</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_first" readonly class="required useTitle f-w240 validate-special-char" required-title="first不能为空"  required-title="请输入first内容"  data-attr-scan="first"/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">remark</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_remark" readonly class="required useTitle ajax validate-mobile-phone f-w240 validate-special-char"  data-attr-scan="remark"/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">value1</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_value1" readonly class="required useTitle f-w240 validate-special-char"  data-attr-scan="value1"/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="">筛选条件:</label>
		<div class="u-radio-wrap m-form-control">
			<input type="radio" value="0" name="condition_type" class="inpRadio" data-attr-scan=""> 全部居民
			<input type="radio" value="1" name="condition_type" class="inpRadio" data-attr-scan=""> 设置条件
		<label class="label_title" style="width:120px">value2</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_value2" class="required useTitle f-w240 validate-special-char"  data-attr-scan="value2"/>
		</div>
	</div>
	<div class="m-form-group" id="inpCondition" style="display: none;padding-bottom: 0px">
		<label class="label_title" style=""></label>
		<div class="u-checkbox-wrap m-form-control">
			<input type="checkbox" name="condition" class="inpChkb" value="1" data-class=".serverType" data-name="serverType" data-tip="服务类型" data-attr-scan>按服务类型
			<input type="checkbox" name="condition" class="inpChkb" value="2" data-class=".health_situation" data-name="health_situation" data-tip="健康情况" data-attr-scan>按健康情况
			<input type="checkbox" name="condition" class="inpChkb" value="3" data-class=".diease" data-name="diease" data-tip="疾病类型" data-attr-scan>按疾病类型
	<div class="m-form-group">
		<label class="label_title" style="width:120px">value3</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_value3" class="required useTitle f-w240 validate-special-char"  data-attr-scan="value3"/>
		</div>
	</div>
	<div class="m-form-group" style=" ">
		<ul style="display: block; vertical-align: middle;">
			<li>
				<div class="m-form-group serverType" style="display: none;padding-bottom: 0px;">
					<label class="label_title" style="text-align: left;width: auto;line-height: 20px;">服务类型:</label>
					<div class="u-checkbox-wrap m-form-control serverTypeDiv" style="line-height: 20px;">
						<%--<input type="checkbox" name="server" class="inpChkb" value="1" data-attr-scan>按服务类型--%>
						<%--<input type="checkbox" name="server" class="inpChkb" value="2" data-attr-scan>按健康情况--%>
						<%--<input type="checkbox" name="server" class="inpChkb" value="3" data-attr-scan>按疾病类型--%>
					</div>
				</div>
			</li>
			<li>
				<div class="m-form-group health_situation" style="display: none;padding-bottom: 0px;">
					<label class="label_title" style="text-align: left;width: auto;line-height: 20px;">健康情况:</label>
					<div class="u-checkbox-wrap m-form-control health_situationDiv" style="line-height: 20px;">
						<%--<input type="checkbox" name="health_situation" class="inpChkb" value="1" data-attr-scan>按服务类型--%>
						<%--<input type="checkbox" name="health_situation" class="inpChkb" value="2" data-attr-scan>按健康情况--%>
						<%--<input type="checkbox" name="health_situation" class="inpChkb" value="3" data-attr-scan>按疾病类型--%>
					</div>
				</div>
			</li>
			<li>
				<div class="m-form-group diease" style="display: none;padding-bottom: 0px;">
					<label class="label_title" style="text-align: left;width: auto;line-height: 20px;">疾病类型:</label>
					<div class="u-checkbox-wrap m-form-control dieaseDiv" style="line-height: 20px;">
						<%--<input type="checkbox" name="diease" class="inpChkb" value="1" data-attr-scan>按服务类型--%>
						<%--<input type="checkbox" name="diease" class="inpChkb" value="2" data-attr-scan>按健康情况--%>
						<%--<input type="checkbox" name="diease" class="inpChkb" value="3" data-attr-scan>按疾病类型--%>
					</div>
				</div>
			</li>
		</ul>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">value4</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_value4" class="required useTitle f-w240 validate-special-char"  data-attr-scan="value4"/>
		</div>
	</div>
	<div class="m-form-group" style="">
		<label class="label_title" style="">通知标题:</label>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">value5</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text" id="title" class="required useTitle validate-special-char" required-title="请输入通知标题" placeholder="请输入通知标题" data-attr-scan="title" />
			<input type="text"  id="inp_value5" class="required useTitle f-w240 validate-special-char" data-attr-scan="value5"/>
		</div>
	</div>
    <div class="m-form-group">
        <label class="label_title" style="">通知内容:</label>
        <div class="l-text-wrapper m-form-control" id="messageContent">
				<textarea type="text" id="content"  maxlength="120"
                          class="required max-length-120 validate-special-char" placeholder="请输入通知具体内容,最多120字,因每条短信限制70字,若大于70字可能将被分割成两条短信" data-attr-scan="content"></textarea>
				<span class="wordwrap" id="wordwrap"><var class="word">0</var>/120</span>
        </div>
    </div>
	<div class="m-form-group">
		<label class="label_title">发送时间:</label>
		<div class="l-text-wrapper m-form-control useTitle ajax validate-special-char">
			<input id="send_type_combo_select" data-type="text" class="" data-name="text" data-attr-scan="sendType">
		<label class="label_title" style="width:120px">value6</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_value6" class="required useTitle f-w240 validate-special-char"   data-attr-scan="value6"/>
		</div>
		<div class="m-form-control essential send_time" style="margin-left: 10px;">
			<input type="text" id="send_time" class="sendTime required" placeholder="输入发送时间"  required-title="不能为空" data-attr-scan="sendTime"/>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">value7</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_value7" class="required useTitle f-w240 validate-special-char"  data-attr-scan="value7"/>
		</div>
	</div>
	<div class="m-form-group">
		<p class="tip">1、立即发送,则审核通过后立即发送</p>
		<p class="tip">2、定时发送,则审核通过后将在指定时间发送。如在指定时间前未审核通过,则将自动撤回</p>
		<label class="label_title" style="width:120px">fromat</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_format" class="required useTitle f-w240 validate-special-char"  data-attr-scan="format"/>
		</div>
	</div>
	</div>
	<div class="m-form-group f-pa" id="btn_save_close" style="right: 10px;bottom: 0;">
	<div class="m-form-group f-pa" id="btn_save_close"  style="right: 10px;bottom: 10px;display: none">
		<div class="m-form-control">
			<input type="button" value="提    交" id="btn_save" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam" />
			<input type="button" value="保存" id="btn_save" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam" />
			<div id="btn_cancel" class="l-button u-btn u-btn-cancel u-btn-large f-ib f-vam" >
				<span>关闭</span>
			</div>

+ 111 - 532
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit_js.jsp

@ -1,575 +1,154 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<script language="javascript">
    $(function(){
        //先选出 textarea 和 统计字数 dom 节点
        var wordCount = $("#messageContent"),
                textArea = wordCount.find("textarea"),
                word = wordCount.find(".word");
        //调用
        statInputNum(textArea,word);
    });
    /*
     * 剩余字数统计
     * 注意 最大字数只需要在放数字的节点哪里直接写好即可 如:<var class="word">200</var>
     */
    function statInputNum(textArea,numItem) {
        var max = numItem.text(), curLength;
        curLength = textArea.val().length;
        numItem.text(max - curLength);
        textArea.on('input propertychange', function () {
            var _value = $(this).val().replace(/\n/gi,"");
            numItem.text(_value.length);
        });
    }
</script>
<script>
    (function ($, win) {
	(function ($, win) {
		$(function () {
			/* ************************** 变量定义 ******************************** */
			var Util = $.Util;
			var notificationInfo = null;
            var serviceLabelType = 1;
            var healthLabelType = 2;
            var dieaseLabelType = 3;
			var province = 350000;
			var city = 350200;
			var isAuditor = ${isAuditor};
			// 表单校验工具类
			var templateName = $('#inp_templateName').val();
			var scene = $('#inp_scene').val();
			var info = "";
			var jValidation = $.jValidation;
			/* *************************** 函数定义 ******************************* */
			//页面初始化
			function pageInit() {
				notificationInfo.init();
				info.initForm();
			}
			//发送范围事件
            $(":radio[name='scope']").click(function(){
                var scope = $(this).val();
                var scopeId = $("#scopeId").val();//修改时选中值
                if(scope=="0"){
                    $("#scope_area").hide();
                    $("#scope_community").hide();
                }else if(scope=="1"){//展示区
                    $.ajax({
                        url: ctx + "/common/districtAuthority",
                        method: "post",
                        dataType: "json",
                        data: {"type": 3, "code": city},
                        success: function (data) {
                            if(data.status=='200'){
                                var html = "";
                                if(scopeId){
                                    var scopeIds = scopeId.split(",");
                                    for(var i=0;i<data.list.length;i++){
                                        var town = data.list[i];
                                        if(scopeId.indexOf(town.code)<0){
                                            html +="<input type='checkbox' name='scope_area' class='inpChkb' data-name='"+town.name+"' value='"+town.code+"' >"+town.name+"&nbsp;";
                                        }else{
                                            html +="<input type='checkbox' checked='checked' name='scope_area' class='inpChkb' data-name='"+town.name+"' value='"+town.code+"' >"+town.name+"&nbsp;";
                                        }
                                    }
                                }else{
                                    for(var i=0;i<data.list.length;i++){
                                        var town = data.list[i];
                                        html +="<input type='checkbox' name='scope_area' class='inpChkb' data-name='"+town.name+"' value='"+town.code+"' >"+town.name+"&nbsp;";
                                    }
                                }
                                $(".scope_areaDiv").html(html);
                            }else{
                                $.Notice.error(data.msg);
                            }
                        }
                    });
                    $("#scope_area").show();
                    $("#scope_community").hide();
                }else if(scope=="2"){//展示社区
                    $.ajax({
                        url: ctx + "/admin/hos/community",
                        method: "post",
                        dataType: "json",
                        data: {"city": city},
                        success: function (data) {
                            if(data.status=='200'){
                                var communityAuthority = $("#communityAuthority").val();
                                var html = "";
                                var attrTown = "";
                                for(var i=0;i<data.list.length;i++){
                                    var town = data.list[i];
                                    attrTown += town.town+";";
                                    var tn = town.town.split(":");
                                    html +="<div  class='m-form-group u-checkbox-wrap m-form-control' style='height: auto;line-height: 15px;'>";
                                    if("2"==communityAuthority||scopeId.indexOf(tn[0])>=0){
                                        html +="<input type='checkbox' name='"+tn[0]+"' checked='checked' class='inpChkb chkCommunity' data-name='"+town.town+"' data-area='"+tn[1]+"' value='"+tn[0]+"' >"+tn[1]+"&nbsp;";
                                    }else{
                                        html +="<input type='checkbox' name='"+tn[0]+"' class='inpChkb chkCommunity' data-name='"+town.town+"' data-area='"+tn[1]+"' value='"+tn[0]+"' >"+tn[1]+"&nbsp;";
                                    }
                                    for(var j=0;j<town.community.length;j++){
                                        community = town.community[j];
                                        if(j>0&&j%6==0){
                                            html+="<br><span style='display: inline-block;width: 61px;'></span>";
                                        }
                                        var comName = community.name;
                                        comName = comName.substring(3,comName.length);
                                        if("2"==communityAuthority||scopeId.indexOf(community.code)>=0){
                                            html +="<input type='checkbox' name='"+town.town+"' checked='checked' class='inpChkb' data-name='"+comName+"' value='"+community.code+"' ><span class='community'>"+comName+"</span>&nbsp;";
                                        }else{
                                            html +="<input type='checkbox' name='"+town.town+"' class='inpChkb' data-name='"+comName+"' value='"+community.code+"' ><span class='community'>"+comName+"</span>&nbsp;";
                                        }
                                    }
                                    html +="</div>"
                                    html +="<br>";
                                }
                                $(".scope_communityDiv").attr("attr-towns",attrTown);
                                $(".scope_communityDiv").html(html);
                            }else{
                                $.Notice.error(data.msg);
                            }
                        }
                    });
                    $("#scope_area").hide();
                    $("#scope_community").show();
                }
            });
            //选择区 全选/反选 社区
            $(document).on("click",".chkCommunity",function () {
                var name = $(this).attr("data-name");
                $("[name = '"+name+"']:checkbox").prop("checked", $(this).is(':checked'));
            });
            //筛选条件
            $(":radio[name='condition_type']").click(function(){
                var condition_type = $(this).val();
                if(condition_type=="0"){
                    $("#inpCondition").hide();
                    $("[name = 'condition']:checkbox").prop("checked",false);
                    $(".serverType").hide();
                    $(".health_situation").hide();
                    $(".diease").hide();
                }else if(condition_type=="1"){
                    $("#inpCondition").show();
                }
            });
            //标签事件
            $(":checkbox[name='condition']").change(function () {
                var chkValue = $(this).val();
                var selClass = $(this).attr("data-class");
                if($(this).is(':checked')){
                    $.ajax({
                        url: ctx + "/common/label/signPatientLabel",
                        method: "post",
                        dataType: "json",
                        data: {"labelType": chkValue},
                        success: function (data) {
                            if(data.status=='200'){
                                var html = "";
                                var name = selClass.substring(1,selClass.length);
                                for(var i=0;i<data.list.length;i++){
                                    var patiemtLabel = data.list[i];
                                    if(i>0&&i%6==0){
                                        html+="<br>";
                                    }
                                    var selectId = "";
                                    if("1"==chkValue){
                                        selectId = $("#serverTypeId").val();
                                    }
                                    if("2"==chkValue){
                                        selectId = $("#healthSituationId").val();
                                    }
                                    if("3"==chkValue){
                                        selectId = $("#diseaseTypeId").val();
                                    }
                                    if(selectId&&selectId.indexOf(patiemtLabel.code)>=0){
                                        html +="<input type='checkbox' name='"+name+"' checked='checked' class='inpChkb' data-name='"+patiemtLabel.name+"' value='"+patiemtLabel.code+"' >"+patiemtLabel.name+"&nbsp;";
                                    }else{
                                        html +="<input type='checkbox' name='"+name+"' class='inpChkb' data-name='"+patiemtLabel.name+"' value='"+patiemtLabel.code+"' >"+patiemtLabel.name+"&nbsp;";
                                    }
                                }
                                $(selClass+"Div").html(html);
                            }else{
                                $.Notice.error(data.msg);
                            }
                            $(selClass).show();
			info = {
				//变量
				$form: $("#div_template_info_form"),
				$code: $('#inp_code'),
				$name: $('#inp_name'),
				$sex: $('#inp_sex'),
				$idcard: $('#inp_idcard'),
				$mobile: $('#inp_mobile'),
				$hospital: $("#inp_hospital"),
                $hospitalName:$("#inp_hospital_name"),
				init: function () {
				    //input样式
					this.$form.attrScan();
					this.$code.ligerTextBox({width: 240});
					this.$name.ligerTextBox({width: 240});
                    this.$sex.ligerTextBox({width: 240});
                    this.$idcard.ligerTextBox({width: 240});
					this.$mobile.ligerTextBox({width: 240});
					this.$hospital.ligerTextBox({width: 240});
					this.$hospitalName.ligerComboBox({
						width: 240,
						initIsTriggerEvent: false,
						valueField: 'typeId',
                        onSelected: function(id,name){
                            $("#inp_hospital").val(id);
                        }
                    });
                }else{
                    $(selClass).hide();
                }
            });
			/* *************************** 模块初始化 ***************************** */
			notificationInfo = {
				$form: $("#div_roles_info_form"),
				$scope: $("input[name='scope']"),//发送范围
				$scope_area: $("input[name='scope_area']"),//指定区
				$scope_community: $("input[name='scope_community']"),//指定社区
				$condition_type: $("input[name='condition_type']"),//筛选条件
				$condition: $("input[name='condition']"),//筛选条件
				$server: $("input[name='server']"),//服务类型
				$health_situation: $("input[name='health_situation']"),//健康情况
				$diease: $("input[name='diease']"),//疾病类型
				$title: $("#title"),//消息标题
				$content: $("#content"),//消息内容
				$send_type_combo_select: $("#send_type_combo_select"),//发送方式
				$send_time: $("#send_time"),//发送时间
				$btnsave: $("#btn_save"),//保存按钮
				$btncancle: $("#btn_cancel"),//结束按钮
				init: function () {
				},
				initForm: function () {
					_this = this;
                    //范围权限控制
                    var cityAuthority = $("#cityAuthority").val();
                    var areaAuthority = $("#areaAuthority").val();
                    var communityAuthority = $("#communityAuthority").val();
                    if("0"==cityAuthority){
                        $("#cityScope").attr("disabled", false);
                        $("#cityScope").attr("disabled","disabled")
                    }
                    if("0"==areaAuthority){
                        $("#areaScope").attr("disabled", false);
                        $("#areaScope").attr("disabled", "disabled");
                    }
                    if("0"==communityAuthority){
                        $("#communityScope").attr("disabled", false);
                        $("#communityScope").attr("disabled", "disabled");
                    }
//                    if("2"==communityAuthority){
//                        $("#communityScope").attr("checked", true);
//                    }
                    this.bindEvents();
					if (type == "view") {
					    //查看时只读属性不可更新数据
						_this.$form.addClass("m-form-readonly"); //表单只读
						$(".essential").addClass("XXXtest");
						$(".essential").removeClass("essential");
						$("#btn_save_close").css("display", "none");
					} else {
						this.$form.removeClass("m-form-readonly");
						$(".XXXtest").addClass("essential");
						$("#btn_save_close").css("display", "block");
                        if(type == "edit"){
                            $("#new_psw_div").css("display", "block");
                            $("#old_psw_div").css("display", "block");
                        }
					}
					this.$form.show();
				},
					this.$title.ligerTextBox({width: 240, validate: {required: true}});
				//绑定事件
				bindEvents: function () {
					var validator = new jValidation.Validation(this.$form, {
						immediate: true, onSubmit: false,
						onElementValidateForAjax: function (elm) {
                    var sendTypeSelect = this.$send_type_combo_select.ligerComboBox({
                        with:180,
                        data: [
                            { text: "立即发送", id: "0" },
//                            { text: "定时发送", id: "1" }//暂时只做立即发送(有审核权限-新增时立即发送,无权限-审核通过后立即发送)
                        ],
                        valueField: 'id',
                        textField: 'text',
                        cancelable: false,
                        initIsTriggerEvent: false,
                        onSelected: function (newvalue){
                            if(newvalue=="0"){
                                $(".send_time").hide();
                            }else{
                                $(".send_time").show();
                            }
						}
					});
					var self = this;
					$("#btn_save").click(function () {
                        var values = self.$form.Fields.getValues();
                        if (!validator.validate()) {
                            return;
                        }
                        update(values);
                    });
                    sendTypeSelect.setValue("0");
                    this.$content.ligerTextBox({width: 430, height: 150, validate: {required: true}});
					this.$form.attrScan();
					_this = this;
					var noticeId = $("#noticeId").val();
					var mode = $("#mode").val();//模式  (新增/修改/查看)
					if (isNoEmpty(noticeId) && noticeId != 0) {
						//id不为空时 :为修改页面,进行修改操作
						//异步根据id获取消息信息
                    //查看模板信息
                    function get(values) {
                        var dataModel = $.DataModel.init();
                        $.ajax({
                            url: ctx + "/admin/notification/notice",
                            url: ctx + "/admin/wechatTemplate/updateTemplate",
                            async: false,
                            method: "post",
                            dataType: "json",
                            data: {id: noticeId},
                            success: function (result) {
                                if (result.status == '200') {
                                    var notice = result.data;
                                    var scope = notice.scope;
                                    var scopeId = notice.scopeId;
                                    $("#scopeId").val(scopeId);//范围
                                    $(":radio[name='scope'][value='" + scope + "']").click();
                                    var conditionType = notice.condition;//筛选条件
                                    var diseaseTypeId = notice.diseaseTypeId;
                                    var healthSituationId = notice.healthSituationId;
                                    var serverTypeId = notice.serverTypeId;
                                    $("#serverTypeId").val(serverTypeId);
                                    $("#healthSituationId").val(healthSituationId);
                                    $("#diseaseTypeId").val(diseaseTypeId);
                                    $(":radio[name='condition_type'][value='" + conditionType + "']").click();
                                    if(serverTypeId){
                                        $(":checkbox[name='condition'][value='1']").click();
                                    }
                                    if(healthSituationId){
                                        $(":checkbox[name='condition'][value='2']").click();
                                    }
                                    if(diseaseTypeId){
                                        $(":checkbox[name='condition'][value='3']").click();
                                    }
                                    _this.$form.Fields.fillValues({
                                        title: notice.title,
                                        content: notice.content,
                                    });
                                    $(".word").text(notice.content.length);
                                    //发送方式
                                    var sendType = notice.sendType;
                                    if("1"==sendType){
                                        var sendTime = notice.sendTime;
                                        sendTime = sendTime.substring(0,16);
                                        sendTypeSelect.setValue(sendType);
                                        $("#send_time").ligerDateEditor({showTime: true,initValue: sendTime});
                                        $(".send_time").show();
                                    }
                            data: {"templateName": templateName,"scene":scene},
                            success: function (data) {
                                if (data.status == 200) {
                                    alert(data.toString());
                                    parent.window.reloadMasterGrid(data.msg);
                                    parent.window.closeUserInfoDialog();
                                } else {
                                    $.Notice.error(result.msg);
                                    $.Notice.error(data.msg);
                                }
                            },
                            error: function (data) {
                                $.Notice.error("系统异常,请联系管理员!");
                            }
                        });
					}else{
                        this.$send_time.ligerDateEditor({showTime: true});
                    }
					this.$form.show();
					this.bindEvents();
				},
				bindEvents: function () {
					var self = this;
					var flag = false;
					$("#btn_save").click(function () {
						var values = self.$form.Fields.getValues();
						if (values.id == '') {
							values.id = 0;
						}
                        values.city = city+"";
                        var s = self.$send_type_combo_select;
                        values.sendType = self.$send_type_combo_select.ligerComboBox().getValue();
                        values.sendTime = self.$send_time.val();
                        values.communityAuthority = $("#communityAuthority").val();
						if (isEmpty(values.scope)) {
							$.Notice.error("请选择发送范围!");
							return false;
						}
						if(values.scope=="0"){
                            values.conditionDescription = "厦门市 全市";
                        }else if(values.scope=="1"){
                            var area = "";
                            var areaName = "";
                            $("input[name='scope_area']:checked").each(function(){
                                area+=$(this).val()+",";
                                areaName+=$(this).attr("data-name")+",";
                            });
                            if(area==""){
                                $.Notice.error("请至少选择一个区!");
                                return false;
                            }
                            areaName = areaName.substring(0,areaName.length-1);
                            area = area.substring(0,area.length-1);
                            values.town = area;
                            values.scopeId = area;
                            values.scopeContent = areaName;
                            values.conditionDescription = "厦门市 "+areaName;
                        }else if(values.scope=="2"){
                            var attrTowns = $(".scope_communityDiv").attr("attr-towns");
                            if(attrTowns.length==0){
                                $.Notice.error("请至少选择一个社区!");
                                return false;
                            }
                            var towns = attrTowns.split(";");
                            var selctCommunity = "";
                            var townCommunity = "";
                            var conditionDescription = "";
                            for(var i=0;i<towns.length;i++){
                                var townName = towns[i];
                                var strCom = "";
                                var strComName = "";
                                $("input[name='"+townName+"']:checked").each(function(){
                                    strCom+=$(this).val()+",";
                                    strComName+=$(this).attr("data-name")+",";
                                });
                                if(strCom.length>0){
                                    //selctCommunity += strCom.substring(0,strCom.length-1);
                                    selctCommunity += strCom;
                                    townCommunity += townName.split(":")[0] +":"+strCom.substring(0,strCom.length-1)+";";
                                    conditionDescription += townName.split(":")[1] +":"+strComName.substring(0,strComName.length-1)+";\n ";
                                }
                            }
                            if(selctCommunity.length==0){
                                $.Notice.error("请至少选择一个社区!");
                                return false;
                            }
                            values.community = selctCommunity.substring(0,selctCommunity.length-1);
                            //values.townCommunity = townCommunity;
                            values.scopeId = townCommunity.substring(0,townCommunity.length-1);
                            values.scopeContent = conditionDescription;
                            values.conditionDescription = "厦门市 "+ conditionDescription;
                        }
                        if (isEmpty(values.condition_type)) {
                            $.Notice.error("请选择筛选条件!");
                            return false;
                        }
						if (values.condition_type=='0') {//全部居民
							var condition = "0";
							var conditionId = "";
							values.condition = condition;
							values.conditionId = conditionId;
						}
                        if(values.condition_type=='1'){
                            var condition = "";
                            var conditionId = "";
                            $("input[name='condition']:checked").each(function(){
                                condition+=$(this).val()+",";
                                var conDetail = "";
                                var nameDetail = "";
                                var dataName = $(this).attr("data-name");
                                $("input[name='"+dataName+"']:checked").each(function(){
                                    conDetail+=$(this).val()+",";
                                    conditionId+=$(this).val()+",";
                                    nameDetail+=$(this).attr("data-name")+",";
                                });
                                if(conDetail.length==0){
                                    $.Notice.error("请至少选择一个"+$(this).attr("data-tip")+"!");
                                    return false;
                                }
                                if(dataName=="serverType"){
                                    values.serverTypeId = conDetail.substring(0,conDetail.length-1);
                                    values.serverTypeContent = nameDetail.substring(0,nameDetail.length-1);
                                }else if(dataName=="health_situation"){
                                    values.healthSituationId = conDetail.substring(0,conDetail.length-1);
                                    values.healthSituationContent = nameDetail.substring(0,nameDetail.length-1);
                                }else if(dataName=="diease"){
                                    values.diseaseTypeId = conDetail.substring(0,conDetail.length-1);
                                    values.diseaseTypeContent= nameDetail.substring(0,nameDetail.length-1);
                                }
                            });
                            if(condition.length==0){
                                $.Notice.error("请至少选择一个设置条件!");
                                return false;
                            }
                            values.condition = condition;
                            values.conditionId = conditionId;
                        }
                        var validator = new jValidation.Validation(self.$form, {
                            immediate: true, onSubmit: false,
                            onElementValidate: function (result,elm) {
                                if (Util.isStrEquals($(elm).attr("id"), 'title')) {
                                    if (isEmpty(values.title)) {
                                        result.setResult(false);
                                        return result;
                                    }
                                }
                                if (Util.isStrEquals($(elm).attr("id"), 'content')) {
                                    if (isEmpty(values.content)) {
                                        result.setResult(false);
                                        return result;
                                    }
                                }
                                if (Util.isStrEquals($(elm).attr("id"), 'send_time')) {
                                    if (values.sendType=="1"&&isEmpty(values.sendTime)) {
                                        result.setResult(false);
                                        return result;
                                    }
                                }
                            }
                        });
                        validator.validate();
						if (isEmpty(values.title)) {
							$.Notice.error("通知标题不能为空!");
							return false;
						}
                        if (isEmpty(values.content)) {
                            $.Notice.error("通知内容不能为空!");
                            return false;
                        }
                        if(values.sendType=="1"&&isEmpty(values.sendTime)){
                            $.Notice.error("发送时间不能为空!");
                            return false;
                        }
						var ddf = $.ligerDialog.open({
                            height: 100,
                            width: 300,
                            title: "提示",
                            isHidden: true,
                            target: "<div style='margin: 0 auto; width: 200px;' >是否确认提交消息通知?提交后无法变更</div>",
							buttons: [
								{
									text: '立即提交', onclick: function (i, d) {
									d.hide();
									update(values);
								}
								},
                                { text: '我在看看', onclick: function (i, d) { d.hide(); }}
                            ]
                        });
//                        $.ajax({
//                            url: ctx + "/admin/notification/isNoticeAuditor",
//                            async: false,
//                            method: "post",
//                            dataType: "json",
//                            data: {},
//                            success: function (data) {
//                                if (data.status == 200) {
//                                    var authority = data.authority;
//
//                                    $.ligerDialog.open({
//                                        height: 250,
//                                        width: 300,
//                                        title: "tishi",
//                                        isHidden: true,
//                                        target: "是否确认提交消息通知?提交后无法变更",
//                                        buttons: [  { text: '立即提交', onclick: function (i, d) { update(values); }},
//                                            { text: '我在看看', onclick: function (i, d) { d.hide(); }}
//                                        ]
//                                    });
//                                } else {
//                                    $.Notice.error(data.msg);
//                                }
//                            }
//                        });
					});
                    //编辑模板信息
					function update(values) {
						var dataModel = $.DataModel.init();
						var message = "保存中...";
						var url = "update";
						if (values.id == 0) {
							url = "create";
						}
						var wattingDialog = $.Notice.waitting(message);
						dataModel.updateRemote(ctx + "/admin/notification/" + url, {
							data: {jsonData: JSON.stringify(values)},
						$.ajax({
							url: ctx + "/admin/wechatTemplate/updateTemplate",
							async: false,
							method: "post",
							dataType: "json",
							data: {"doc": doc,"oldHospital":hospital,"hospital": $("#inp_hospital").val()},
							success: function (data) {
								wattingDialog.close();
								if (data.status == 200) {
									parent.window.reloadMasterGrid(data.msg);
									parent.window.closeInfoDialog();
									parent.window.closeUserInfoDialog();
								} else {
									$.Notice.error(data.msg);
								}
							},
							error: function (data) {
								wattingDialog.close();
								$.Notice.error("系统异常,请联系管理员!");
							}
						});
					}
                    //新增模板信息
                    function save(values) {
                        var dataModel = $.DataModel.init();
                        $.ajax({
                            url: ctx + "/admin/wechatTemplate/saveTemplate",
                            async: false,
                            method: "post",
                            dataType: "json",
                            data: {"doc": doc,"oldHospital":hospital,"hospital": $("#inp_hospital").val()},
                            success: function (data) {
                                if (data.status == 200) {
                                    parent.window.reloadMasterGrid(data.msg);
                                    parent.window.closeUserInfoDialog();
                                } else {
                                    $.Notice.error(data.msg);
                                }
                            }
                        });
                    }
					$("#btn_cancel").click(function () {
						parent.window.closeInfoDialog();
						parent.window.closeUserInfoDialog();
					});
				}
			};
			/* *************************** 页面初始化 **************************** */
			}
			pageInit();
		})
	})(jQuery, window);
		});
	})(jQuery, window)
</script>

+ 16 - 18
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list.jsp

@ -4,37 +4,35 @@
<html lang="en">
<head>
	<%@ include file="../head/page_head.jsp" %>
	<title>用户管理</title>
	<title>微信模板消息管理</title>
</head>
<style>
</style>
<body>
<div id="div_wrapper">
	<!-- 检索条件 -->
	<div class="m-retrieve-area f-h50 f-dn f-pr m-form-inline" data-role-form style='display: block;'>
		<div class="m-form-group f-mt10">
			<%--<sec:authorize url="/admin/roles/rolesList">--%>
			<div class="m-form-control f-fs12 f-ml10">
				<input type="text" id="inp_searchNm" placeholder="请输入标题/提交人">
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_templateName" placeholder="请输入微信模板名称" class="f-ml10" data-attr-scan="templateName"/>
			</div>
			<div class="m-form-control f-fs12 f-ml10">
				<input id="sel_status" placeholder="选择状态"/>
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_scene" placeholder="请输入模板场景值" class="f-ml10" data-attr-scan="scene"/>
			</div>
			<%--</sec:authorize>--%>
			<%--<sec:authorize url="/admin/roles/create">--%>
			<div class="m-form-control f-mr20" style="float: right">
				<div id="div_new_notice" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam">
					<span>新增消息通知</span>
			<sec:authorize url="/admin/wechatTemplate/list">
			<div id="btn_search" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
				<span>查询</span>
			</div>
			</sec:authorize>
			<sec:authorize url="/admin/wechatTemplate/editInitial">
			<div class="m-form-control m-form-control-fr">
				<div id="btn_add" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam" style="margin-right: 20px;">
					<span>新增</span>
				</div>
			</div>
			<%--</sec:authorize>--%>
			</sec:authorize>
		</div>
	</div>
	<!-- 列表 -->
	<div id="div_notice_list">
	<div id="div_template_list">
	</div>
</div>

+ 69 - 187
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list_js.jsp

@ -9,9 +9,6 @@
			var retrieve = null;
			var master = null;
			var isFirstPage = false;
			var status = '';
			var isAuditor = ${isAuditor};
			/* *************************** 函数定义 ******************************* */
			function pageInit() {
@ -21,144 +18,73 @@
			function reloadGrid(params) {
				if (isFirstPage) {
					master.grid.options.newPage = 1;
					this.grid.options.newPage = 1;
				}
				master.grid.setOptions({parms: params});
				master.grid.loadData(true);
				this.grid.setOptions({parms: params});
				this.grid.loadData(true);
			}
			/* *************************** 模块初始化 ***************************** */
			retrieve = {
				$element: $('.m-retrieve-area'),
				$addBtn: $('#div_new_notice'),
				$searchNm: $("#inp_searchNm"),
				$status: $('#sel_status'),
				$searchBtn: $('#btn_search'),
				$addBtn: $('#btn_add'),
				$templateName: $("#inp_templateName"),
				$scene: $("#inp_scene"),
				init: function () {
					_this = this;
					this.$searchNm.ligerTextBox({
						width: 240, isSearch: true, search: function () {
							master.reloadGrid();//参数:标签/提交人+消息通知状态
						}
					})
					//状态复选框,选择时也刷新列表
					_this.statusBox = _this.$status.ligerComboBox({
						width: 180,
						data: [
							{text: '全部', statusId: ''},
							{text: '待提交', statusId: '1'},
							{text: '待审核', statusId: '2'},
							{text: '待发送', statusId: '3'},
							{text: '已发送', statusId: '4'},
							{text: '已拒绝', statusId: '5'},
							{text: '已撤回', statusId: '6'},
						],
						initIsTriggerEvent: false,
						valueFieldID: 'statusId',
						valueField: 'statusId',
						onSelected: function (newvalue) {
							status = newvalue;
							if (!master || !master.grid) {
								return
							}
							master.reloadGrid();//参数:标签/提交人+消息通知状态
						},
					this.$element.show();
					this.$element.attrScan();
					window.form = this.$element;
					this.$templateName.ligerTextBox({width: 200});
					this.$scene.ligerTextBox({width: 200})
					this.bindEvents();
				},
				bindEvents: function () {
					var self = this;
					self.$searchBtn.click(function () {
						master.grid.options.newPage = 1;
						master.reloadGrid();
					});
                    this.bindEvents();
					if (isAuditor) {
						_this.statusBox.setValue('2');//根据是否是审核者设置默认值,审核者:默认选中待审核
					} else {
						_this.statusBox.setValue('');//根据是否是审核者设置默认值,审核者:待审核;非:默认全部
					}
				},bindEvents: function () {
                    var self = this;
                    self.$addBtn.click(function () {
                        master.infoDialog = $.ligerDialog.open({
                            height: 550,
                            width: 750,
                            title: '新增消息',
                            url: ctx + '/admin/notification/infoInit/' + "0" + "?mode=add"
                        })
                    });
                }
					self.$addBtn.click(function () {
						$.publish("info:create", [''])
					});
				}
			};
			master = {
				infoDialog: null,
				grid: null,
				init: function () {
					this.grid = $("#div_notice_list").ligerGrid($.LigerGridEx.config({
						url: ctx + '/admin/notification/list',
						parms: {status: status},
					var data;
					this.grid = $("#div_template_list").ligerGrid($.LigerGridEx.config({
						url: ctx + '/admin/wechatTemplate/list',
						parms: {},
						ajaxHeader: ajaxHeaderName,
						ajaxHeaderValue: ajaxHeaderValue,
						columns: [
							{display: 'ID', name: 'id', hide: true},
							{display: '标题', name: 'title', width: '14%', align: "left"},
							{display: '状态', name: 'status', hide: true},
                            {display: 'ID', name: 'id', hide: true},
                            {display: '模板名称', name: 'templateName', width: '15%', align: "left"},
                            {display: '场景值', name: 'scene', width: '5%', align: "left"},
                            {display: '场景描述', name: 'sceneDescription', width: '15%', align: "center"},
                            {display: 'first', name: 'first', width: '10%', align: "center"},
                            {display: 'remark', name: 'remark', width: '10%', align: "center"},
                            {display: 'value1', name: 'keyword1', width: '5%', align: "center"},
                            {display: 'value2', name: 'keyword2', width: '5%', align: "center"},
                            {display: 'value3', name: 'keyword3', width: '5%', align: "center"},
                            {display: 'value4', name: 'keyword4', width: '5%', align: "center"},
                            {display: 'value5', name: 'keyword5', width: '5%', align: "center"},
                            {display: 'value6', name: 'keyword6', width: '5%', align: "center"},
                            {display: 'value7', name: 'keyword7', width: '5%', align: "center"},
							{
								display: '状态', name: 'status', width: '6%', align: "center",
								display: '操作', name: 'operator', width: '10%', align: "center", isSort: false,
								render: function (row) {
									var html = '';
									if (row.status == '0') {
										return "创建中"
									}
									;
									if (row.status == '1') {
										return "待提交"
									}
									;
									if (row.status == '2') {
										return "待审核"
									}
									;
									if (row.status == '3') {
										return "待发送"
									}
									;
									if (row.status == '4') {
										return "已发送"
									}
									;
									if (row.status == '5') {
										return "已拒绝"
									html += '<a  href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:view", row.templateName,row.scene) + '">查看</a>';
									<sec:authorize url="/admin/wechatTemplate/editInitial">
									if (!Util.isStrEquals(row.code, "admin")) {
										html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:edit", row.templateName,row.scene) + '">编辑</a>';
									}
									;
									if (row.status == '6') {
										return "已撤回"
									}
									;
								}
							},
							{display: '通知总人数', name: 'totalCount', width: '15%', align: "center"},
//							{display: '定时发送时间', name: 'sendTime', width: '15%', align: "center"},
							{display: '提交人Id', name: 'applyUserId', hide: true},
							{display: '提交人', name: 'applyUserName', width: '10%', align: "center"},
							{display: '提交时间', name: 'applyTime', width: '15%', align: "center"},
							{display: '审核Id', name: 'auditUserId', hide: true},
							{display: '审核人', name: 'auditUserName', width: '10%', align: "center"},
							{display: '审核时间', name: 'auditTime', width: '15%', align: "center"},
							{
								display: '操作', name: 'operator', width: '15%', align: "center", isSort: false,
								render: function (row) {
									var html = '';
									html += '<a  href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:view", row.id) + '">查看</a>';
									if (row.owned == true) {
										if (row.status == 5 || row.status == 6) {
											html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:edit", row.id) + '">编辑</a>';
											html += '<a  style="margin-left:10px;" title="删除" href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:del", row.id) + '">删除</a>';
										}
										if (row.status == 2) {
											html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:revoke", row.id) + '">撤回</a>';
										}
										if (row.status == 1) {
											html += '<a  style="margin-left:10px;" title="删除" href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:del", row.id) + '">删除</a>';
										}
									}
									<%--<sec:authorize url="/admin/user/update">--%>
									if (row.owned == false && row.auditor == true && row.status == 2) {
										html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:edit", row.id) + '">审核</a>';
									}
									<%--</sec:authorize>--%>
									</sec:authorize>
									return html;
								}
							}
@ -174,82 +100,49 @@
						//如果是新增,直接刷新页面
						master.grid.loadData();
					} else {
						debugger
						//如果是查询(获取查询参数)
						var searchNm = retrieve.$searchNm.val() || '';
						var status = retrieve.statusBox.getValue() || '';
						var values = {
							searchNm: searchNm,
							status: status
						}
						//如果是查询
						retrieve.$element.attrScan();
						var values = retrieve.$element.Fields.getValues();
						reloadGrid.call(this, values);
					}
				},
				delRecord: function (id, code) {
					var self = this;
					$.ajax({
						url: ctx + "/admin/notification/delete",
						data: {"id": id},
						method: "post",
						dataType: "json",
						success: function (result) {
							if (result.status == '200') {
								window.reloadMasterGrid(result.msg);
							} else {
								$.Notice.error(result.msg);
							}
						},
						error: function (data) {
							$.Notice.error("系统异常,请联系管理员!");
						}
					})
				},
				bindEvents: function () {
					var self = this;
					$.subscribe('info:view', function (event, id) {
						var title = '消息通知详情';
					$.subscribe('info:view', function (event,templateName,scene) {
						var title = '查看微信模板';
						self.infoDialog = $.ligerDialog.open({
							height: 550,
							width: 750,
							urlParms: {"id": id, "mode": "view"},
							height: 800,
							width: 950,
							urlParms: {"templateName": templateName, "scene": scene, "mode": "view"},
							title: title,
							url: ctx + '/admin/notification/view'
							url: ctx + '/admin/wechatTemplate/editInitial'
						})
					});
                    $.subscribe('info:revoke', function (event, id) {
                        var title = '消息通知撤回';
                        self.infoDialog = $.ligerDialog.open({
                            height: 550,
                            width: 750,
                            urlParms: {"id": id, "mode": "revoke"},
                            title: title,
                            url: ctx + '/admin/notification/view'
                        })
                    });
					$.subscribe('info:edit', function (event, id) {
						var title = '编辑用户信息';
					$.subscribe('info:edit', function (event, templateName,scene) {
						var title = '编辑微信模板';
						self.infoDialog = $.ligerDialog.open({
							height: 550,
							width: 750,
							height: 800,
							width: 950,
							urlParms: {"templateName": templateName,"scene":scene,"mode": "edit"},
							title: title,
                            url: ctx + '/admin/notification/infoInit/' + id + "?mode=edit"
							url: ctx + '/admin/wechatTemplate/editInitial'
						})
					});
					$.subscribe('info:create', function (event, id) {
						var title = '新增消息';
					$.subscribe('info:create', function (event) {
						var title = '新增微信模板';
						self.infoDialog = $.ligerDialog.open({
							height: 460,
							width: 490,
							height: 600,
							width: 950,
							urlParms: {"mode": "new"},
							title: title,
							url: ctx + '/notification/infoInit' + "0" + "?mode=add"
							url: ctx + '/admin/wechatTemplate/editInitial'
						})
					});
					$.subscribe('info:del', function (event, id, code) {
					$.subscribe('info:del', function (event, templateName, scene) {
						$.ligerDialog.confirm('确认删除该行信息?<br>如果是请点击确认按钮,否则请点击取消。', function (yes) {
							if (yes) {
								self.delRecord(id, code);
								self.delRecord(templateName, scene);
							}
						});
					})
@ -266,17 +159,6 @@
			win.closeUserInfoDialog = function () {
				master.infoDialog.close();
			};
            win.closeInfoDialog = function () {
                master.infoDialog.close();
            };
			win.openEditInfoDialog = function (id) {
				master.infoDialog.close();
				$.publish("info:edit", id);
			}
			win.deleteNoticeDialog = function (id) {
				master.delRecord(id);
				master.infoDialog.close();
			}
			/* *************************** 页面初始化 **************************** */
			pageInit();
		});