Commit ac80945a by 罗绍泽

日历功能增删改查的实现

parent 83be002e
......@@ -43,18 +43,20 @@
//在input之后添加一个label标签
var $label;
var input_left = $input.offset().left - $input.parent().offset().left;
var input_top = $input.offset().top - $input.parent().offset().top;
if($input.next('label').length==0){
$label = $('<label></label>');
$label.css({
'position':'absolute',
'top':'0',
'left':$input.css('paddingLeft'),
'top':input_top,
'left':input_left+($input.css('paddingLeft').replace('px','')-0),
'cursor':'text',
'color':defaults.tip.color,
'fontFamily':defaults.tip.fontFamily,
'fontSize':defaults.tip.fontSize,
'height':$input.css('height'),
'lineHeight':$input.css('height'),
'height':$input.outerHeight(true)+'px',
'lineHeight':$input.outerHeight(true)+'px',
'display':'inlineBlock'
});
}
......@@ -62,14 +64,17 @@
$label=$input.next('label');
}
//如果input给了value值时
if($input.val()){
$label.text($input.val());
$input.val('');
if($input.attr('tiptext')){
$label.text($input.attr('tiptext'));
}
else{
$label.text(defaults.tip.text)
}
$input.after($label);
//判断文本框是否有值,有值则隐藏label
if($input.val()!=''){
$label.hide();
}
/*var timeid = setInterval(function(){
if(!$input.val()==""){
......@@ -77,8 +82,8 @@
clearInterval(timeid);
}
},10);*/
$input.siblings('label').click(function(){
$(this).siblings("input").focus();
$input.next('label').click(function(){
$(this).prev("input").focus();
});
$input.bind({
focus:function(){
......@@ -87,9 +92,9 @@
options.focus(this);
return;
}
if (this.value == ""){
/*if (this.value == ""){
$(this).siblings("label").hide();
}
}*/
},
blur:function(){
//如果用户传进来的话就调用用户的
......@@ -98,15 +103,25 @@
return;
}
if (this.value == ""){
$(this).siblings("label").show();
$(this).next("label").show();
}
},
input:function(){
//如果用户传进来的话就调用用户的
if(options!=null && typeof options.input == 'function'){
options.input(this);
return;
}
if (this.value == ""){
$(this).next("label").show();
}
else{
$(this).next("label").hide();
}
}
});
});
}//$.fn
})(jQuery);
\ No newline at end of file
......@@ -655,6 +655,9 @@ a{
color: #999;
margin-bottom:10px;
}
.index_calendar_text>label{
margin-bottom:0px;
}
.index_calendar_text>input{
width: 320px;
height: 26px;
......@@ -672,7 +675,7 @@ a{
margin-bottom:10px;
}
.index_calendar_date>input{
width: 143px;
width: 320px;
height: 26px;
line-height: 20px;
padding: 2px;
......@@ -1643,3 +1646,4 @@ a{
......@@ -1219,9 +1219,9 @@ function init_index_fullCalendar() {
start = moment(date, 'mm.HH.DD.MM.YYYY').format('YYYY-MM-DD HH:mm');
end = moment(date, 'mm.HH.DD.MM.YYYY').add(1, 'hour').format('YYYY-MM-DD HH:mm');
}
var strVar = index_fullCalendar_template('', '新增事件', '记录你将要做的一件事...', date._ambigTime, start, end);
var strVar = index_fullCalendar_template('', '新增事件', '', date._ambigTime, start, end);
$.fancybox.open(strVar);
$("#index_calendarTitle").inputTips();
init_index_color();
},
......@@ -1241,14 +1241,43 @@ function init_index_fullCalendar() {
//颜色
var color = calEvent.color;
if(allDay==1){
start=start.substring(0,10);
end=end.substring(0,10);
}else{
start=start.substring(0,16);
end=end.substring(0,16);
}
var strVar = index_fullCalendar_template(id, '编辑事件', title, allDay, start, end);
$.fancybox.open(strVar);
$("#index_calendarTitle").inputTips();
init_index_color(color);
},
/*editable : true,*/
/*eventLimit : true, // allow "more" link when too many events*/
events : ctx+'/date.json'
//events : ctx+'/date.json'
events : function(start,end,timezone, callback) {
var result=jwAppPortletModel.jwAppsPortletDataAction.listCalendarInfo({
FIELD_START_TIME:start._i,
FIELD_END_TIME:end._i
});
var listData=result.rowSet;
var json=[];
for(var i=0;i<listData.length;i++){
var data=listData[i];
json.push({
"id": data.UUID,
"title": data.TITLE,
"start": data.START_TIME,
"end": data.END_TIME,
"url": null,
"allDay": data.ALLDAY==1,
"color": data.COLOR
});
}
callback(json);
}
});
}
......@@ -1260,7 +1289,7 @@ function index_fullCalendar_template(id, header, title, allDay, start, end) {
strVar += " <div class=\"index_calendar_header\">@{header}<\/div>\n";
strVar += " <div class=\"index_calendar_container\">\n";
strVar += " <div class=\"index_calendar_text\">\n";
strVar += " <label for=\"index_calendarTitle\">日程内容:<\/label><input type=\"text\" id=\"index_calendarTitle\" value=\"@{title}\" />\n";
strVar += " <label for=\"index_calendarTitle\">日程内容:<\/label><input type=\"text\" id=\"index_calendarTitle\" value=\"@{title}\" tiptext=\"记录你将要做的一件事...\"/>\n";
strVar += " <\/div>\n";
strVar += " <div class=\"index_calendar_date\">\n";
strVar += " <label for=\"index_calendarStart\">开始时间:<\/label><input class=\"Wdate\" @{startTime} type=\"text\" id=\"index_calendarStart\" value=\"@{start}\" />\n";
......@@ -1378,13 +1407,13 @@ function index_allDay(handler) {
function index_startAllday() {
WdatePicker({
dateFmt : 'yyyy-MM-dd',
minDate : '%y-%M-%d'
maxDate : '#F{$dp.$D(\'index_calendarEnd\',{d:-1})}'
});
}
function index_start() {
WdatePicker({
dateFmt : 'yyyy-MM-dd HH:mm',
minDate : '%y-%M-%d {%H}:%m'
maxDate : '#F{$dp.$D(\'index_calendarEnd\',{H:-1})}'
})
}
function index_endAllday() {
......@@ -1406,12 +1435,17 @@ function index_removeDay() {
var option = {
title: "删除提示",
onOk: function(){
alert($('#index_calendarId').val())
//删除日历的事件
$('#index_calendar').fullCalendar('removeEvents', $('#index_calendarId').val())
//删除数据库的数据
var result=jwAppPortletModel.jwAppsPortletActAction.removeCalendarInfo({
UUID:$('#index_calendarId').val()
});
if(result.NAME==3){
$.fancybox.close();
}else{
alert(result.VALUE);
}
},
onCancel:function(){
......@@ -1427,13 +1461,13 @@ function index_submitClick() {
return;
}
var jsonDate = {};
jsonDate.id = $('#index_calendarId').val();
jsonDate.title = $('#index_calendarTitle').val();
jsonDate.start = $('#index_calendarStart').val();
jsonDate.end = $('#index_calendarEnd').val();
jsonDate.allDay = $('#index_isAllDay').prop('checked');
jsonDate.color = $('#index_calendarColor').val();
console.log(jsonDate)
jsonDate.FIELD_UUID = $('#index_calendarId').val();
jsonDate.FIELD_TITLE = $('#index_calendarTitle').val();
jsonDate.FIELD_START_TIME = $('#index_calendarStart').val();
jsonDate.FIELD_END_TIME = $('#index_calendarEnd').val();
jsonDate.FIELD_ALLDAY = $('#index_isAllDay').prop('checked')?1:0;
jsonDate.FIELD_COLOR = $('#index_calendarColor').val();
jwAppPortletModel.jwAppsPortletActAction.saveCalendarInfo(jsonDate);
$('#index_calendar').fullCalendar('refetchEvents'); //重新获取所有事件数据
//保存到数据库
......@@ -1450,6 +1484,7 @@ function init_index_color(color) {
color = '#ECC';
}
$("#index_calendarColor").val(color);
console.log($("#index_calendarColor"))
$("#index_calendarColor").spectrum({
/*allowEmpty:true,*/
color : color,
......
......@@ -16,6 +16,12 @@ jwAppPortletModel.prototype.listAllPortletColumns = function(){};
jwAppPortletModel.prototype.listAllPTemplate = function(){};
//保存用户的资源列表
jwAppPortletModel.prototype.saveLayout = function(){};
//获取当前登录人的日历信息
jwAppPortletModel.prototype.listCalendarInfo = function(){};
//保存当前登录人的日历信息
jwAppPortletModel.prototype.saveCalendarInfo = function(){};
//删除当前登录人的日历信息
jwAppPortletModel.prototype.removeCalendarInfo = function(){};
//创建一个数据操作对象,然后再后续使用
jwAppPortletModel.jwAppsPortletActAction = new jwAppPortletModel("json").delegate("jwAppsPortletAct");
......
......@@ -17,4 +17,10 @@ public interface PortletBusiness {
List<Map<String,Object>> list_portlet_columns(Map<String, Object> query) throws BusinessException ;
void saveLayout(String columnsId,List<Map<String, Object>> list) throws BusinessException ;
List<Map<String,Object>> list_calendar_by_user(Map<String, Object> query) throws BusinessException ;
Map<String,Object> save_calendar(Map<String, Object> info) throws BusinessException ;
void delete_calendar(String uuid) throws BusinessException ;
}
......@@ -16,6 +16,7 @@ import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Encipher;
import com.gaowj.business.util.SessionUtil;
import com.jw.app.business.PortletBusiness;
import com.jw.app.business.utils.DateTools;
import com.jw.app.business.utils.QueryParamUtil;
public class PortletBusinessImpl implements PortletBusiness {
......@@ -190,6 +191,58 @@ public class PortletBusinessImpl implements PortletBusiness {
}
}
@Override
public List<Map<String,Object>> list_calendar_by_user(Map<String, Object> query) throws BusinessException{
query.put("START_TIME", new Date(Long.valueOf(query.get("START_TIME").toString())));
query.put("END_TIME", new Date(Long.valueOf(query.get("END_TIME").toString())));
return portletDAO.list_calendar_by_user(query);
}
@Override
public Map<String,Object> save_calendar(Map<String, Object> info) throws BusinessException {
if(info.get("UUID")==null||"".equals(info.get("UUID"))){
//表示新增
info.put("UUID", UUID.randomUUID().toString());
info.put("USER_ID", SessionUtil.getEmid());
info.put("CREATE_USER", SessionUtil.getEmid());
info.put("CREATE_TIME", new Date());
info.put("UPDATE_USER", SessionUtil.getEmid());
info.put("UPDATE_TIME", new Date());
List<Map<String,Object>> listField=new ArrayList<Map<String,Object>>();
for(String k:info.keySet()){
Map<String,Object> field=new HashMap<String, Object>();
field.put("key", k);
field.put("value", info.get(k));
listField.add(field);
}
info.put("list", listField);
portletDAO.insert_calendar(info);
}else{
//表示更新
info.put("UPDATE_USER", SessionUtil.getEmid());
info.put("UPDATE_TIME", new Date());
List<Map<String,Object>> listField=new ArrayList<Map<String,Object>>();
for(String k:info.keySet()){
if("UUID".equals(k)){
continue;
}
Map<String,Object> field=new HashMap<String, Object>();
field.put("key", k);
field.put("value", info.get(k));
listField.add(field);
}
info.put("list", listField);
portletDAO.update_calendar(info);
}
return info;
}
@Override
public void delete_calendar(String uuid) throws BusinessException {
portletDAO.delete_calendar(uuid);
}
private List<Map<String, Object>> mapToList(Map<String, Object> map) {
List<Map<String, Object>> entity = new ArrayList<Map<String, Object>>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
......
......@@ -8,6 +8,8 @@ import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.exception.BusinessException;
public interface PortletDAO {
List<Map<String,Object>> list_calendar_by_user(Map<String,Object> query) throws BusinessException ;
List<Map<String,Object>> list_portlet_template_user(Map<String,Object> query) throws BusinessException ;
List<Map<String,Object>> list_portlet_template(Map<String,Object> query) throws BusinessException ;
......@@ -21,4 +23,10 @@ public interface PortletDAO {
void delete_portlet_template_user(Map<String,Object> query) throws BusinessException ;
void insert_portlet_template_user(List<Map<String,Object>> entity) throws BusinessException ;
void insert_calendar(Map<String,Object> info) throws BusinessException ;
void update_calendar(Map<String,Object> info) throws BusinessException ;
void delete_calendar(String uuid) throws BusinessException ;
}
......@@ -152,4 +152,51 @@
</trim>
<![CDATA[ ) ]]>
</insert>
<select id="list_calendar_by_user" parameterType="map"
resultType="upperCaseKeyMap">
<![CDATA[
select * from b_t_ufp_calendar t
]]>
<trim prefix="WHERE" prefixOverrides="AND |OR">
<if test="USER_ID != null and USER_ID != ''">
and t.USER_ID = #{USER_ID}
</if>
<!-- 开始时间或者结束时间,有一个在用户传进来的时间范围内就给予显示 -->
<![CDATA[
and ((t.START_TIME >= #{START_TIME} and t.START_TIME <= #{END_TIME}) or (t.END_TIME >= #{START_TIME} and t.END_TIME <= #{END_TIME}))
]]>
</trim>
ORDER BY t.create_time DESC
</select>
<insert id="insert_calendar" parameterType="java.util.List">
insert into b_t_ufp_calendar(
<trim prefix="" suffixOverrides=",">
<foreach collection="list" item="field">
${field.key},
</foreach>
</trim>
<![CDATA[ ) values( ]]>
<trim prefix="" suffixOverrides=",">
<foreach collection="list" item="field">
#{field.value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
<update id="update_calendar" parameterType="java.util.List">
update b_t_ufp_calendar set
<trim prefix="" suffixOverrides=",">
<foreach collection="list" item="field">
${field.key}=#{field.value},
</foreach>
</trim>
where UUID=#{UUID}
</update>
<delete id="delete_calendar" parameterType="String">
delete from b_t_ufp_calendar where UUID=#{uuid}
</delete>
</mapper>
\ No newline at end of file
......@@ -10,6 +10,7 @@ import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils;
import com.jw.app.business.PortletBusiness;
import com.jw.app.business.utils.QueryParamUtil;
import com.jw.app.business.utils.Status;
import net.sf.json.JSONArray;
......@@ -53,4 +54,30 @@ public class actAction extends BasicAction {
return "json";
}
public String saveCalendarInfo() throws BusinessException{
Map<String, Object> info = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
PortletBusiness business = BusinessManager.getBusiness(PortletBusiness.class);
try {
info = QueryParamUtil.StringToDate(info);
business.save_calendar(info);
jsonObject.putAll(Status.getStatus(Status.UPDATE_OK));
} catch (Exception e) {
jsonObject.putAll(Status.getStatus(Status.UPDATE_ERR));
}
return "json";
}
public String removeCalendarInfo() throws BusinessException{
PortletBusiness business = BusinessManager.getBusiness(PortletBusiness.class);
try {
business.delete_calendar(RequestUtils.getString(request, "UUID"));
jsonObject.putAll(Status.getStatus(Status.DELETE_OK));
} catch (Exception e) {
jsonObject.putAll(Status.getStatus(Status.DELETE_ERR));
}
return "json";
}
}
......@@ -172,4 +172,46 @@ public class dataAction extends BasicAction {
}
return "json";
}
/**
* 获取当前登录人的日历信息
* @return
* @throws BusinessException
*/
public String listCalendarInfo() throws BusinessException{
PortletBusiness business = BusinessManager
.getBusiness(PortletBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
try {
query = QueryParamUtil.StringToDate(query);
//设置当前登陆人
query.put("USER_ID", SessionUtil.getEmid());
List<Map<String, Object>> listData = business
.list_calendar_by_user(query);
for (Map<String, Object> rm : listData) {
if(rm.get("P_TYPE")==null||!rm.get("P_TYPE").equals("3"))
{
rm.remove("RSS_CONTENT");
rm.remove("TAKE_CONTENT");
}
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateTimeToString(listData));
data.put("pageNo", 1);
data.put("pageSize", listData.size());
data.put("pageCount", listData.size());
data.put("rows", data.get("rowSet"));
data.put("total", listData.size());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
}
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