Commit edf2b27d authored by liuchao's avatar liuchao

no message

parent 8b7f5357
......@@ -238,10 +238,26 @@ public class RainbowPlanController extends BaseController<Object> {
RainbowPlanUser user = userDao.findByOpenid(openid);
if (user != null){
if (!info.getFile().isEmpty()){
String originalFileName = info.getFile().getOriginalFilename();
//String originalFileName = info.getFile().getOriginalFilename();
//String rootPath = rb.getString("file_path");
//File destFile = new File(rootPath + uploadAvatarPath,originalFileName);
//FileUtils.writeByteArrayToFile(destFile,info.getFile().getBytes());
String[] originalFileName = info.getFile().getOriginalFilename().split("\\.");
String fileName = info.getUid() + "." + originalFileName[originalFileName.length-1];
String rootPath = rb.getString("file_path");
File destFile = new File(rootPath + uploadAvatarPath,originalFileName);
if (StringUtils.isNotBlank(user.getAvatar())) {
File oldFile = new File(rootPath + user.getAvatar());
FileUtils.forceDelete(oldFile);
}
File destFile = new File(rootPath + uploadWishImagePath,fileName);
FileUtils.writeByteArrayToFile(destFile,info.getFile().getBytes());
user.setAvatar(uploadAvatarPath + File.separator + fileName);
user.setPhone(info.getPhone());
user.setName(info.getName());
user.setNickName(info.getNickName());
......@@ -251,7 +267,6 @@ public class RainbowPlanController extends BaseController<Object> {
user.setReceiveName(info.getReceiveName());
user.setConnectTel(info.getConnectTel());
user.setReceiveAddress(info.getReceiveAddress());
user.setAvatar(uploadAvatarPath + File.separator + originalFileName);
user.setDisease(info.getDisease());
userDao.update(user);
}else {
......
package com.qiankun.controller.rainbowplan;
import java.io.File;
import java.util.List;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.qiankun.controller.base.BaseController;
......@@ -109,4 +114,73 @@ public class RainbowPlanWebController extends BaseController<Object>{
return view;
}
@RequestMapping(value = "/rainbow/wish/save",method = RequestMethod.POST)
public ModelAndView saveWish(@RequestParam(value = "file", required = false) MultipartFile file, WishVo vo, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
String uploadWishImagePath = File.separator + "rainbowplan" + File.separator + "wishUploadImage";
ResourceBundle rb = ResourceBundle.getBundle("system");
Wish wish = new Wish();
if (StringUtils.isBlank(vo.getId())) {
if (file == null) {
view.getModelMap().addAttribute("message", "nopic");
return view;
}
wish.setRainbowPlanUserId(vo.getRainbowPlanUserId());
wish.setActivityId(vo.getActivityId());
wish.setChildren(userDao.find(vo.getRainbowPlanUserId()));
wish.setActivity(activityService.findById(vo.getActivityId()));
wish.setVolunteer(null);
view.getModelMap().addAttribute("status", 1);
} else {
wish = wishDao.find(vo.getId());
view.getModelMap().addAttribute("status", 2);
}
if (file != null) {
String fileFullName = file.getOriginalFilename();
String[] originalFileName = fileFullName.split("\\.");
String fileName = vo.getCode() + "." + originalFileName[originalFileName.length-1];
String rootPath = rb.getString("file_path");
if (StringUtils.isNotBlank(wish.getUploadImage())) {
File oldFile = new File(rootPath + wish.getUploadImage());
if (oldFile.isFile())
FileUtils.forceDelete(oldFile);
}
File destFile = new File(rootPath + uploadWishImagePath,fileName);
FileUtils.writeByteArrayToFile(destFile,file.getBytes());
wish.setUploadImage(uploadWishImagePath + File.separator + fileName);
}
wish.setStatus(vo.getStatus());
wish.setCode(vo.getCode());
wish.setTitle(vo.getTitle());
wish.setContent(vo.getContent());
if (vo.getReset() != null && vo.getReset()) {
wish.setVolunteer(null);
wish.setExpressCode(null);
wish.setExpressCompany(null);
wish.setHelpType(0);
}
wishDao.save(wish);
return view;
}
}
......@@ -38,7 +38,12 @@ public class WishDaoImpl extends AbsDao<Wish,String> implements WishDao {
@Override
public IPageList<Wish> findPages(String searchStr, String activityId, Integer status, String order, String sort, Hints hints) {
if (order == null){
order = " createTime ";
}
if (sort == null){
sort=" desc ";
}
String hql = "";
if (StringUtils.isNotBlank(searchStr)) {
if (StringUtils.isBlank(hql)) {
......
......@@ -2,11 +2,14 @@ package com.qiankun.vo;
import java.util.Date;
import org.springframework.web.multipart.MultipartFile;
import com.qiankun.entity.RainbowPlanUser;
public class WishVo {
private String id; //愿望ID
private String code; //愿望编号
private String title;//愿望标题
private String content;//愿望内容
private String uploadImage; //上传的图片
......@@ -26,6 +29,8 @@ public class WishVo {
private String order;
private String sort;
private Boolean reset = false;
public Date getCreateTime() {
return createTime;
}
......@@ -161,6 +166,22 @@ public class WishVo {
public void setSort(String sort) {
this.sort = sort;
}
public Boolean getReset() {
return reset;
}
public void setReset(Boolean reset) {
this.reset = reset;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
......
#file_path=D:/file/
file_path=D:/file/
#file_path=/Users/liuyang/work/argus_work/tjmdp/udata
file_path=/var/tjmdp/udata
#file_path=/var/tjmdp/udata
account=admin
......
......@@ -181,4 +181,4 @@
activityHTML += '</select><button class="btn-xs" onclick="user.validateWish()">确定</button></div>';
</script>
<script src="<webpath:path/>/resources/js/rainbow/rainbowuser.js" type="text/javascript"></script>
\ No newline at end of file
<script src="<webpath:path/>/resources/js/rainbow/rainbowuser.js?v=window.number" type="text/javascript"></script>
\ No newline at end of file
......@@ -47,7 +47,7 @@
</div>
<div class="pull-right">
<select class="" id="activityId" name="activityId">
<select class="" id="activity" name="activity">
<option value="">请选择活动</option>
<c:forEach var="list" items="${activitylist}">
<option value="${list.id}" <c:if test="${wishVo.activityId==list.id}">selected</c:if>>${list.name}</option>
......@@ -76,7 +76,7 @@
<span class="lbl"></span>
</label>
</th>
<th width="">图片</th>
<th width="70">图片</th>
<th width="">小朋友</th>
<th width="10%">愿望</th>
<th width="20%">内容</th>
......@@ -86,7 +86,7 @@
<th width="">所属活动</th>
<th width="">状态</th>
<th width="5%">发布时间</th>
<!-- <th width="5%">操作</th> -->
<th width="2%">操作</th>
</tr>
</thead>
......@@ -101,11 +101,13 @@
</td>
<td title="" valign="middle"><a href="#"><img alt="" src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${wish.uploadImage}" width="60" height="60"/></a></td>
<td title="">姓名:${wish.children.name}&nbsp; 楼层床号:${wish.children.bedNum}<br/>
联系方式:${wish.children.phone}<br/>
收件人:${wish.children.receiveName} &nbsp;联系方式:${wish.children.connectTel}<br/>
收件地址:${wish.children.receiveAddress};
</td>
<td title="" valign="middle">${wish.title}</td>
<td title="" valign="middle">
编号:${wish.code}<br>
愿望:${wish.title}</td>
<td title="" valign="middle"><div class="slim-scroll" style="overflow: hidden; width: auto; height: 65px;">${wish.content}</div></td>
<td title="" valign="middle">
<c:if test="${wish.volunteer != null}">姓名:${wish.volunteer.name}<br/>
......@@ -127,23 +129,23 @@
<td title="" valign="middle"><fmt:formatDate value='${wish.createTime}' pattern='yyyy-MM-dd HH:mm' /></td>
<%-- <td>
<td>
<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/rainbow/user/add?id=${user.id}'">
<i class="icon-credit-card bigger-120"></i>
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/rainbow/wish/view?id=${wish.id}'">
<i class="icon-edit bigger-120"></i>
</button>
&nbsp;
<a class="btn btn-xs btn-link" title="详细信息" href="<webpath:path/>/rainbow/wish/view?id=${wish.id}">
<%-- <a class="btn btn-xs btn-link" title="详细信息" href="<webpath:path/>/rainbow/wish/view?id=${wish.id}">
<i class="icon-list-alt bigger-120"></i>
</a>
</a> --%>
</div>
</td> --%>
</td>
</tr>
</c:forEach>
</tbody>
......
......@@ -33,7 +33,10 @@
<div class="col-xs-12">
<form action="#" id="" name="" method="post" onsubmit="return false" class="form-horizontal" role="form">
<form action="#" id="wish_form" name="wish_form" method="post" onsubmit="return false" class="form-horizontal" role="form">
<input class="col-xs-10 col-sm-10" id="id" name="id" type="hidden" value="${wish.id}"/>
<input class="col-xs-10 col-sm-10" id="activityId" name="activityId" type="hidden" value="${wish.activityId}"/>
<input class="col-xs-10 col-sm-10" id="rainbowPlanUserId" name="rainbowPlanUserId" type="hidden" value="${wish.rainbowPlanUserId}"/>
<div class="row">
<div class="col-xs-12">
......@@ -42,284 +45,85 @@
<div class="row">
<div class="col-xs-4">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">愿望</label>
<div class="col-sm-9">
${wish.title}
</div>
</div>
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 内容 </label>
<div class="col-sm-9">
<textarea rows="4" class="col-xs-10 col-sm-10" >${wish.content}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 图片 </label>
<div class="col-sm-9">
<img src="<webpath:path/>/loadResource?imageName=${wish.uploadImage}" />
</div>
</div>
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 状态 </label>
<div class="col-sm-9">
${wish.status}
</div>
</div>
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 出生日期 </label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="birthday" name="birthday" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.birthday}"/>
</div>
</div>
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 楼层床号 </label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="bedNum" name="bedNum" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.bedNum}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 收件人姓名 </label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="receiveName" name="receiveName" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.receiveName}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 联系方式</label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="connectTel" name="connectTel" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.connectTel}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 收件地址</label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="receiveAddress" name="receiveAddress" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.receiveAddress}"/>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 户籍所在地 </label>
<div class="col-sm-9">
<input type="text" id="domicilePlace" name="domicilePlace" value="${user.domicilePlace}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 经常居住地</label>
<div class="col-sm-9">
<input type="text" id="addr" name="addr" value="${user.addr}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 学历</label>
<div class="col-sm-9">
<select class="col-xs-10 col-sm-10" id="education" name="education">
<option value="">请选择</option>
<c:forEach var="value" items="${dict.education}">
<option value="${value}" <c:if test="${user.education==value}">selected</c:if>>${value}</option>
</c:forEach>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 工作单位/学校 </label>
<div class="col-sm-9">
<input type="text" id="unit" name="unit" value="${user.unit}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 职业 </label>
<div class="col-sm-9">
<select class="col-xs-10 col-sm-10" id="profession" name="profession">
<option value="">请选择</option>
<c:forEach var="value" items="${dict.profession}">
<option value="${value}" <c:if test="${user.profession==value}">selected</c:if>>${value}</option>
</c:forEach>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 单位/学校地址 </label>
<div class="col-sm-9">
<input type="text" id="unitAddr" name="unitAddr" value="${user.unitAddr}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 单位/学校电话 </label>
<div class="col-sm-9">
<input type="text" id="unitTel" name="unitTel" value="${user.unitTel}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 本人手机 </label>
<div class="col-sm-9">
<input type="text" id="mobile" name="mobile" value="${user.mobile}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 固定电话 </label>
<div class="col-sm-9">
<input type="text" id="tel" name="tel" value="${user.tel}" class="col-xs-10 col-sm-10" />
</div>
</div>
</div>
<div class="col-xs-4">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 邮箱 </label>
<div class="col-sm-9">
<input type="text" id="email" name="email" value="${user.email}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font>QQ号码 </label>
<div class="col-sm-9">
<input type="text" id="qq" name="qq" value="${user.qq}" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 微信号 </label>
<div class="col-sm-9">
<input type="text" id="weixin" name="weixin" value="${user.weixin}" class="col-xs-10 col-sm-10" />
<div class="col-xs-4">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">编号</label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="code" name="code" type="text" value="${wish.code}"/>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 无偿献血次数 </label>
<div class="col-sm-9">
<input type="text" id="donateBloodCount" name="donateBloodCount" value="${user.donateBloodCount}" class="col-xs-10 col-sm-10" />
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">愿望</label>
<div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="title" name="title" type="text" value="${wish.title}"/>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 血型 </label>
<div class="col-sm-9">
<select class="col-xs-10 col-sm-10" id="bloodType" name="bloodType">
<option value="">请选择</option>
<c:forEach var="value" items="${dict.bloodType}">
<option value="${value}" <c:if test="${user.bloodType==value}">selected</c:if>>${value}</option>
</c:forEach>
</select>
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">内容 </label>
<div class="col-sm-9">
<textarea rows="4" class="col-xs-10 col-sm-10" id="content" name="content">${wish.content}</textarea>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 身高 </label>
<div class="col-sm-9">
<input type="text" id="height" name="height" value="${user.height}" class="col-xs-10 col-sm-10" />
<span class="help-inline col-xs-12 col-sm-2">
<span class="middle">cm</span>
</span>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"><font color="red">*</font>图片</label>
<div class="col-sm-9">
<c:if test="${wish.uploadImage!=null}">
<img src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${wish.uploadImage}" /><br></c:if>
<input type="file" id="input_file" name="file" accept="image/gif,image/jpeg,image/jpg,image/png" >
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 体重 </label>
<div class="col-sm-9">
<input type="text" id="weight" name="weight" value="${user.weight}" class="col-xs-10 col-sm-10" />
<span class="help-inline col-xs-12 col-sm-2">
<span class="middle">kg</span>
</span>
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 状态 </label>
<div class="col-sm-9">
<select class="" id="status" name="status">
<option value="0" <c:if test="${wish.status==0}">selected</c:if>>发布</option>
<option value="1" <c:if test="${wish.status==1}">selected</c:if>>认领</option>
<option value="2" <c:if test="${wish.status==2}">selected</c:if>>寄送中</option>
<option value="3" <c:if test="${wish.status==3}">selected</c:if>>红会代收</option>
<option value="4" <c:if test="${wish.status==4}">selected</c:if>>完成</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 备注 </label>
<div class="col-sm-9">
<textarea rows="4" class="col-xs-10 col-sm-10" id="remark" name="remark">${user.remark}</textarea>
<c:if test="${wish.id!=null}">
<div class="form-group children">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 重新认领 </label>
<div class="col-sm-9">
<select class="" id="reset" name="reset">
<option value="false">否</option>
<option value="true" >是</option>
</select>
</div>
</div>
</c:if>
</div>
</div>
</div>
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-sm btn-success" type="submit" onclick="wish.save()">
<i class="icon-save bigger-110"></i>
保存
</button>
<a class="btn btn-sm btn-success" href="javascript:history.go(-1)">
<i class="icon-reply bigger-110"></i>
返回
......@@ -338,11 +142,14 @@
</div>
</div>
</div>
<script src="<webpath:path/>/resources/js/user/cityData.js" type="text/javascript"></script>
<script src="<webpath:path/>/resources/js/user/user.js" type="text/javascript"></script>
\ No newline at end of file
<script src="<webpath:path/>/resources/js/rainbow/wish.js?v=window.number" type="text/javascript"></script>
......@@ -41,6 +41,10 @@ var user = {
userId:"",
validateWish:function(){
var activityId = $("#activityId").val()
if (activityId == ""){
$("#message").html("请选择活动!");
return;
}
$.ajax({
type: 'POST',
url: '/rainbow/wish/validate',
......
var isSubmit = true;
$(document).ready(function(){
$("#activityId").select2({
$("#activity").select2({
placeholder : "请选择",
allowClear : true
});
......@@ -11,13 +12,48 @@ $(document).ready(function(){
railVisible:true
});
});
/*if ($('#wish_form').length>0){
$('#wish_form').validate({
rules : {
"title" : {
required : true
},
"content" : {
required : true
}
},
messages:{
"title" : {
required : "不能为空"
},
"content" : {
required : "不能为空"
}
},
submitHandler: function(form){
wish.save();
}
});
}*/
})
var wish = {
search : function(){
var activityId = $("#activityId").val();
var activityId = $("#activity").val();
var searchStr = $("#searchStr").val();
var status = $("#status").val();
var url = webPath + "/rainbow/wish/list";
......@@ -137,6 +173,94 @@ var wish = {
});
}
})
},
save : function(form){
if (isSubmit){
isSubmit = false;
var formData = new FormData();
formData.append('file', $('#input_file')[0].files[0]);
formData.append('id', $('#id').val());
formData.append('code', $('#code').val());
formData.append('activityId', $('#activityId').val());
formData.append('rainbowPlanUserId', $('#rainbowPlanUserId').val());
formData.append('title', $('#title').val());
formData.append('content', $('#content').val());
formData.append('status', $('#status').val());
//console.info($('#reset'));
//alert(typeof($('#reset').val()) != "undefined");
if (typeof($('#reset').val()) != "undefined" ){
formData.append('reset', $('#reset').val());
}
$.ajax({
url: webPath + "/rainbow/wish/save",
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false,
dataType:"json",
beforeSend: function(){
},
success : function(data) {
isSubmit = true;
var status = data.status;
var message = data.message;
if (message == "nopic"){
bootbox.dialog({
message:"请上传图片",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
}
}
}
});
}
if (status == 1){
bootbox.dialog({
message:"保存成功",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
history.go(-1);
}
}
}
});
}
if (status == 2){
bootbox.dialog({
message:"修改成功",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.reload();
}
}
}
});
}
}
})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment