任务功能开发完成;v1.0版本产生
This commit is contained in:
parent
cfbdf809f9
commit
cf527d9087
|
@ -1,7 +1,13 @@
|
|||
class MissionsController < ApplicationController
|
||||
|
||||
before_action :authenticate
|
||||
|
||||
skip_before_action :verify_authenticity_token, :only => [
|
||||
:create,
|
||||
:getlist,
|
||||
:detail,
|
||||
:update,
|
||||
:commentPublish
|
||||
]
|
||||
#======================================>获取当前项目某状态的任务列表
|
||||
|
||||
def getlist
|
||||
|
@ -82,24 +88,24 @@ class MissionsController < ApplicationController
|
|||
#Todo
|
||||
params_mission = {name: params[:name],project_id: params[:project_id],content: params[:content],deadline: params[:deadline],priority: params[:priority],status: params[:status]}
|
||||
mission = Mission.new(params_mission)
|
||||
mission.save
|
||||
#puts mission.inspect
|
||||
#puts mission.id
|
||||
usernames = params[:users]
|
||||
usernames.each do |name|
|
||||
|
||||
user_enties = User.find_by(name: name)
|
||||
if mission.save
|
||||
render :json => {:code => 0}
|
||||
else
|
||||
render json: mission.errors, status: :unprocessable_entity
|
||||
end
|
||||
userids = params[:users]
|
||||
userids.each do |id|
|
||||
user_enties = User.find_by(id: id)
|
||||
#puts user_enties.inspect
|
||||
params_mu = {mission_id: mission.id,user_id: user_enties.id}
|
||||
missions_user = Missions_user.new(params_mu)
|
||||
missions_user.save
|
||||
content = "有新任务:"+mission.name
|
||||
content = "有新任务 <a>"+mission.name+"</a>"
|
||||
|
||||
params_note = {content: content,user_id: user_enties.id,category: 3,project_id: mission.project_id}
|
||||
note = Note.new(params_note)
|
||||
note.save
|
||||
end
|
||||
render :json => {:code => 0}
|
||||
end
|
||||
|
||||
#======================================>修改任务信息
|
||||
|
@ -110,18 +116,18 @@ class MissionsController < ApplicationController
|
|||
id = params[:id]
|
||||
#now = Datetime.now
|
||||
mission = Mission.find_by(id: id)
|
||||
params_mission = {name: params[:name],content: params[:content],deadline: params[:deadline],priority: params[:priority],status: params[:status]}
|
||||
params_mission = {name: params[:name],content: params[:content],deadline: params[:deadline],priority: params[:priority]}
|
||||
#puts params_mission
|
||||
mission.update(params_mission)
|
||||
mission.save
|
||||
Missions_user.delete_all(["mission_id = ?",id])
|
||||
usernames = params[:users]
|
||||
usernames.each do |name|
|
||||
user_enties = User.find_by(name: name)
|
||||
userids = params[:users]
|
||||
userids.each do |name|
|
||||
user_enties = User.find_by(id: id)
|
||||
params = {mission_id: id,user_id: user_enties.id}
|
||||
missions_user = Missions_user.new(params)
|
||||
missions_user.save
|
||||
content = mission.name + "——任务信息发生了变化"
|
||||
content = "<a>"+mission.name + "</a> 任务信息发生了变化"
|
||||
|
||||
params_note = {content: content,user_id: user_enties.id,category: 3,project_id: mission.project_id}
|
||||
note = Note.new(params_note)
|
||||
|
@ -139,10 +145,10 @@ class MissionsController < ApplicationController
|
|||
user_id = session[:user_id]
|
||||
params = {content: content, mission_id: mission_id, user_id: user_id}
|
||||
comment = Comment.new(params)
|
||||
comment.save
|
||||
render :json => {:code => 0}
|
||||
if comment.save
|
||||
render :json => {:code => 0}
|
||||
else
|
||||
render json: mission.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -75,10 +75,10 @@ Rails.application.routes.draw do
|
|||
|
||||
get 'notes/list' => 'notes#getNotesList'
|
||||
|
||||
get 'missions/project/status' => 'missions#getlist'
|
||||
get 'missions' => 'missions#getlist'
|
||||
get 'missions/detail' => 'missions#detail'
|
||||
post 'missions/comments' => 'missions#commentPublish'
|
||||
post 'missions/create' => 'missions#create'
|
||||
post 'missions' => 'missions#create'
|
||||
patch 'missions/detail' => 'missions#update'
|
||||
|
||||
end
|
||||
|
|
|
@ -81,9 +81,9 @@
|
|||
for(var j=0;j<informs.length;j++){
|
||||
var inform_label='\
|
||||
<li>\
|
||||
<i class="'+icon_class[informs[j].type]+'"></i>\
|
||||
<i class="'+icon_class[informs[j].type-1]+'"></i>\
|
||||
<div class="timeline-item">\
|
||||
<span class="time"><i class="fa fa-clock-o"></i>'+informs[j].time.substring(0,5)+'</span>\
|
||||
<span class="time"><i class="fa fa-clock-o"></i> '+informs[j].time.substring(0,5)+'</span>\
|
||||
<h3 class="timeline-header">'+informs[j].content+'</h3>\
|
||||
</div>\
|
||||
</li>';
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
<div class="box-header with-border">
|
||||
<h3 class="box-title">未开始</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button class="btn btn-box-tool" data-toggle="modal" data-target="#myModal2"><i class="fa fa-plus"></i></button>
|
||||
<button class="btn btn-box-tool" onclick="mission_create(1)"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
|
@ -103,7 +103,7 @@
|
|||
<div class="box-header with-border">
|
||||
<h3 class="box-title">进行中</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button class="btn btn-box-tool"><i class="fa fa-plus"></i></button>
|
||||
<button class="btn btn-box-tool" onclick="mission_create(2)"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
|
@ -119,7 +119,7 @@
|
|||
<div class="box-header with-border">
|
||||
<h3 class="box-title">已完成</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button class="btn btn-box-tool"><i class="fa fa-plus"></i></button>
|
||||
<button class="btn btn-box-tool" onclick="mission_create(3)"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
|
@ -135,7 +135,7 @@
|
|||
<div class="box-header with-border">
|
||||
<h3 class="box-title">已测试</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button class="btn btn-box-tool"><i class="fa fa-plus"></i></button>
|
||||
<button class="btn btn-box-tool" onclick="mission_create(4)"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
|
@ -157,6 +157,7 @@
|
|||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
|
||||
×
|
||||
</button>
|
||||
<input id="mission_id" style="display:none;">
|
||||
<h4 class="modal-title" id="myModalLabel">
|
||||
|
||||
</h4>
|
||||
|
@ -171,21 +172,19 @@
|
|||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<strong><i class="fa fa-book margin-r-5"></i>任务名称</strong>
|
||||
<p class="text-muted" id="cy_task_name">
|
||||
前端原型开发
|
||||
<p class="text-muted" id="mission_task_name">
|
||||
</p>
|
||||
<hr>
|
||||
<strong><i class="fa fa-tasks margin-r-5"></i>任务内容</strong>
|
||||
<p class="text-muted" id="cy_task_content">开发出项目的前端原型。</p>
|
||||
<p class="text-muted" id="mission_task_content"></p>
|
||||
<hr>
|
||||
<strong><i class="fa fa-calendar margin-r-5"></i>截止时间</strong> <span id="cy_task_deadline">2016年12月8日</span>
|
||||
<strong><i class="fa fa-calendar margin-r-5"></i>截止时间</strong> <span id="mission_task_deadline"></span>
|
||||
<hr>
|
||||
<strong><i class="fa fa-clock-o margin-r-5"></i>优先级</strong>
|
||||
<div class="label label-danger" style="font-size:15px;font-weight:0 !important;" id="cy_task_priority">紧急</div>
|
||||
<div class="label label-danger" style="font-size:15px;font-weight:0 !important;" id="mission_task_priority"></div>
|
||||
<hr>
|
||||
<strong><i class="fa fa-file-text-o margin-r-5"></i>参与人员</strong>
|
||||
<p id="cy_task_users">
|
||||
杨诏 陈翊
|
||||
<p id="mission_task_users">
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
|
@ -200,53 +199,17 @@
|
|||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<!-- Conversations are loaded here -->
|
||||
<div class="direct-chat-messages">
|
||||
<!-- Message. Default to the left -->
|
||||
<div class="direct-chat-msg" id="cy_comments_template" style="display:none;">
|
||||
<div class="direct-chat-info clearfix">
|
||||
<span class="direct-chat-name pull-left" id="cy_comment_name">杨诏</span>
|
||||
<span class="direct-chat-timestamp pull-right" id="cy_comment_time">2016-12-7 2:00 pm</span>
|
||||
</div>
|
||||
<!-- /.direct-chat-info -->
|
||||
<img class="direct-chat-img" src="../dist/img/avatar5.png" alt="message user image">
|
||||
<!-- /.direct-chat-img -->
|
||||
<div class="direct-chat-text" id="cy_comment_content">
|
||||
这个任务相当好!
|
||||
</div>
|
||||
<!-- /.direct-chat-text -->
|
||||
</div>
|
||||
<!-- Contacts are loaded here -->
|
||||
<div class="direct-chat-contacts">
|
||||
<ul class="contacts-list">
|
||||
<li>
|
||||
<a href="#">
|
||||
<img class="contacts-list-img" src="../dist/img/avatar5.png">
|
||||
<div class="contacts-list-info">
|
||||
<span class="contacts-list-name">
|
||||
Count Dracula
|
||||
<small class="contacts-list-date pull-right">2/28/2015</small>
|
||||
</span>
|
||||
<span class="contacts-list-msg">How have you been? I was...</span>
|
||||
</div>
|
||||
<!-- /.contacts-list-info -->
|
||||
</a>
|
||||
</li>
|
||||
<!-- End Contact Item -->
|
||||
</ul>
|
||||
<!-- /.contatcts-list -->
|
||||
<div class="direct-chat-messages" id="mission_comments_container">
|
||||
</div>
|
||||
<!-- /.direct-chat-pane -->
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<form action="#" method="post">
|
||||
<div class="input-group">
|
||||
<input type="text" name="message" placeholder="输入评论内容" class="form-control">
|
||||
<input type="text" name="message" id="mission_comments_content" placeholder="输入评论内容" class="form-control">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-primary btn-flat">提交评论</button>
|
||||
<button type="button" class="btn btn-primary btn-flat" onclick="publish_comment()">提交评论</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /.box-footer-->
|
||||
</div>
|
||||
|
@ -256,7 +219,7 @@
|
|||
<!-- row -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal2">
|
||||
<button type="button" class="btn btn-primary" onclick="mission_update()">
|
||||
修改
|
||||
</button>
|
||||
</div>
|
||||
|
@ -266,15 +229,20 @@
|
|||
<!-- /.modal -->
|
||||
</div>
|
||||
<!-- 模态框(Modal) -->
|
||||
</div>
|
||||
<!-- 更新和创建共用模态框 -->
|
||||
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content modal-detail">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
|
||||
×
|
||||
</button>
|
||||
</button>
|
||||
<!-- 用来记录动作是要更新还是创建:1:创建,2:更新 -->
|
||||
<input id="mission_edit_type" style="display:none;">
|
||||
<!-- 用来记录任务所在的状态 -->
|
||||
<input id="mission_edit_status" style="display:none;">
|
||||
<h4 class="modal-title" id="myModalLabel">
|
||||
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
@ -291,20 +259,20 @@
|
|||
<div class="form-group row has-feedback">
|
||||
<label for="inputPassword3" class="col-sm-2 col-md-push-2 control-label">任务名称</label>
|
||||
<div class="col-sm-6 col-md-push-2">
|
||||
<input type="text" id="cy_modify_taskname" class="form-control" value="11" id="address" name="address" placeholder="任务名称">
|
||||
<input type="text" class="form-control" value="" id="mission_edit_name" placeholder="输入任务名称">
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./form-group -->
|
||||
<div class="form-group row has-feedback">
|
||||
<label for="inputPassword3" class="col-sm-2 col-md-push-2 control-label">任务内容</label>
|
||||
<div class="col-sm-6 col-md-push-2">
|
||||
<textarea class="form-control" rows="3" placeholder="Enter ..." id="cy_modify_taskcontent"></textarea> </div>
|
||||
<textarea class="form-control" rows="3" placeholder="输入任务内容" id="mission_edit_content"></textarea> </div>
|
||||
</div>
|
||||
<!-- ./form-group -->
|
||||
<div class="form-group row has-feedback">
|
||||
<label for="inputPassword3" class="col-sm-2 col-md-push-2 control-label">截止时间</label>
|
||||
<div class="col-sm-6 col-md-push-2">
|
||||
<input type="text" class="form-control" value="11" id="cy_modify_taskdeadline" name="address" placeholder="截止时间">
|
||||
<input type="text" class="form-control" value="" id="mission_edit_deadline" placeholder="输入截止时间">
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./form-group -->
|
||||
|
@ -313,35 +281,28 @@
|
|||
<div class="col-sm-6 col-md-push-2">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked="">
|
||||
<input type="radio" name="mission_edit_priority" value="1" checked="">
|
||||
普通
|
||||
</label>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
|
||||
紧急
|
||||
</label>
|
||||
<input type="radio" name="mission_edit_priority" value="2">
|
||||
紧急
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3">
|
||||
非常紧急
|
||||
</label>
|
||||
<input type="radio" name="mission_edit_priority" value="3">
|
||||
非常紧急
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./form-group -->
|
||||
<div class="form-group row has-feedback">
|
||||
<label for="inputPassword3" class="col-sm-2 col-md-push-2 control-label">参与人员</label>
|
||||
<div class="col-sm-6 col-md-push-2">
|
||||
<select multiple="" class="form-control" id="cy_modify_select">
|
||||
<option>杨诏</option>
|
||||
<option>陈翊</option>
|
||||
<option>崔承旭</option>
|
||||
<option>胡家煊</option>
|
||||
<option>马旭桐</option>
|
||||
</select>
|
||||
<div class="col-sm-6 col-md-push-2" id="mission_edit_users_options">
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./form-group -->
|
||||
|
@ -359,7 +320,7 @@
|
|||
<!-- row -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="cy_submit_modify">
|
||||
<button type="button" class="btn btn-primary" id="mission_edit_submit">
|
||||
提交
|
||||
</button>
|
||||
</div>
|
||||
|
@ -367,7 +328,6 @@
|
|||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
|
||||
</section>
|
||||
<!-- content section -->
|
||||
|
@ -377,7 +337,8 @@
|
|||
<!-- ./wrapper -->
|
||||
<center><strong>Copyright © 2016 <a href="#">Ambition Inc.</a>.</strong> All rights reserved.</center>
|
||||
|
||||
<a id="cy_show_modal" style="display:none" data-toggle="modal" data-target="#myModal"></a>
|
||||
<a id="show_modal" style="display:none" data-toggle="modal" data-target="#myModal"></a>
|
||||
<a id="show_modal2" style="display:none" data-toggle="modal" data-target="#myModal2"></a>
|
||||
|
||||
<!-- jQuery 2.1.4 -->
|
||||
<script src="../plugins/jQuery/jQuery-2.1.4.min.js"></script>
|
||||
|
@ -390,6 +351,152 @@
|
|||
<!-- date select and query -->
|
||||
<!-- Custom Scripts -->
|
||||
<script>
|
||||
function mission_create(status){
|
||||
$("#mission_edit_type").val('1');// 表示创建操作
|
||||
$("#show_modal2").click();
|
||||
// 初始化表单
|
||||
$("#mission_edit_content").val("");
|
||||
$("#mission_edit_deadline").val("");
|
||||
$("#mission_edit_name").val("");
|
||||
$('input:radio[name="mission_edit_priority"][value="1"]').attr('checked','checked');
|
||||
$("#mission_edit_status").val(status);
|
||||
$("#mission_edit_users_options").html("");
|
||||
// 初始化可选用户
|
||||
$.ajax({
|
||||
type:"get",
|
||||
dataType:"json",
|
||||
url:"/projects/detail.json",
|
||||
async:false,// 强制同步
|
||||
data:{
|
||||
"id":parent.LoginUserInfo.selectProject
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var data=rpstr.data;
|
||||
if(rpstr.code=="0"){
|
||||
var users = data.users;
|
||||
for(var i = 0; i < users.length; ++i){
|
||||
var user='<label class="checkbox-inline"><input type="checkbox" name="mission_edit_users" value="'+users[i].id+'">'+users[i].name+'</label>';
|
||||
$("#mission_edit_users_options").append(user);
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert("服务器内部出错啦!");
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
});
|
||||
$("[name='mission_edit_users']:checkbox").attr("checked", false);
|
||||
}
|
||||
function mission_update(){
|
||||
$("#mission_edit_type").val('2');// 表示创建操作
|
||||
// 初始化表单
|
||||
$("#mission_edit_users_options").html("");
|
||||
$("#show_modal2").click();
|
||||
// 初始化可选用户
|
||||
$.ajax({
|
||||
type:"get",
|
||||
dataType:"json",
|
||||
url:"/projects/detail.json",
|
||||
async:false,// 强制同步
|
||||
data:{
|
||||
"id":parent.LoginUserInfo.selectProject
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var data=rpstr.data;
|
||||
if(rpstr.code=="0"){
|
||||
var users = data.users;
|
||||
for(var i = 0; i < users.length; ++i){
|
||||
var user='<label class="checkbox-inline"><input type="checkbox" name="mission_edit_users" value="'+users[i].id+'">'+users[i].name+'</label>';
|
||||
$("#mission_edit_users_options").append(user);
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert("服务器内部出错啦!");
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
});
|
||||
$("[name='mission_edit_users']:checkbox").attr("checked", false);
|
||||
}
|
||||
$("#mission_edit_submit").click(function (){
|
||||
var mission_edit_name=$("#mission_edit_name").val();
|
||||
var mission_edit_content=$("#mission_edit_content").val();
|
||||
var mission_edit_deadline=$("#mission_edit_deadline").val();
|
||||
var mission_edit_priority=$('input:radio[name="mission_edit_priority"]:checked').val();
|
||||
var mission_edit_status=$("#mission_edit_status").val();
|
||||
var mission_edit_users=[];
|
||||
$("input[name='mission_edit_users']:checkbox:checked").each(function(){
|
||||
mission_edit_users.push($(this).val());
|
||||
});
|
||||
//alert(mission_edit_users.length);
|
||||
if( mission_edit_name.length>0 && mission_edit_content.length>0 && mission_edit_deadline.length>0 && mission_edit_priority>0 && mission_edit_users.length>0){
|
||||
if( $("#mission_edit_type").val()==1 ){// 创建
|
||||
$.ajax({
|
||||
type:"post",
|
||||
dataType:"json",
|
||||
url:"/missions.json",
|
||||
data:{
|
||||
"project_id":parent.LoginUserInfo.selectProject,
|
||||
"name":mission_edit_name,
|
||||
"content":mission_edit_content,
|
||||
"deadline":mission_edit_deadline,
|
||||
"priority":mission_edit_priority,
|
||||
"users":mission_edit_users,
|
||||
"status":mission_edit_status
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = rpstr;
|
||||
if(robj["code"]==0){
|
||||
alert("创建成功!");
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
422:function(){
|
||||
alert("输入不符合要求,请重新输入!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if($("#mission_edit_type").val()==2){// 更新
|
||||
$.ajax({
|
||||
type:"patch",
|
||||
dataType:"json",
|
||||
url:"/missions/detail.json",
|
||||
data:{
|
||||
"id":parent.LoginUserInfo.selectProject,
|
||||
"name":mission_edit_name,
|
||||
"content":mission_edit_content,
|
||||
"deadline":mission_edit_deadline,
|
||||
"priority":mission_edit_priority,
|
||||
"users":mission_edit_users
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = rpstr;
|
||||
if(robj["code"]==0){
|
||||
alert("修改成功!");
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
422:function(){
|
||||
alert("输入不符合要求,请重新输入!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}else{
|
||||
alert("请输入完整!");
|
||||
}
|
||||
});
|
||||
$(document).ready(function(){
|
||||
//获取某状态的任务列表
|
||||
getTaskList(1,"container_1");
|
||||
|
@ -397,10 +504,11 @@
|
|||
getTaskList(3,"container_3");
|
||||
getTaskList(4,"container_4");
|
||||
function getTaskList(type,container_id){
|
||||
//alert("11");
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
dataType:"json",
|
||||
url:"/missions/project/status.json",
|
||||
url:"/missions.json",
|
||||
data:{
|
||||
"project_id":parent.LoginUserInfo.selectProject,
|
||||
"status_type":type
|
||||
|
@ -438,11 +546,13 @@
|
|||
});
|
||||
//获取任务详情(修改模态框)
|
||||
function showTaskDetail(mission_id){
|
||||
$("#mission_id").val(mission_id);// 保存在页面,以便评论使用
|
||||
//修改模态框
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
dataType:"json",
|
||||
url:"/missions/detail.json",
|
||||
async:false,
|
||||
data:{
|
||||
"id":mission_id
|
||||
},
|
||||
|
@ -450,28 +560,47 @@
|
|||
200: function(rpstr) {// 请求成功
|
||||
if(rpstr.code=="0"){
|
||||
var data=rpstr.data;
|
||||
$("#cy_task_name").html(data.name);
|
||||
$("#cy_task_content").html(data.content);
|
||||
$("#cy_task_deadline").html(data.deadline);
|
||||
$("#mission_task_name").html(data.name);
|
||||
$("#mission_task_content").html(data.content);
|
||||
$("#mission_task_deadline").html(data.deadline.substring(0,10)+" "+data.deadline.substring(11,16));
|
||||
if(data.priority==1){
|
||||
$("#mission_task_priority").html("普通");
|
||||
$("#mission_task_priority").attr("class","label label-info");
|
||||
}
|
||||
if(data.priority==2){
|
||||
$("#mission_task_priority").html("紧急");
|
||||
$("#mission_task_priority").attr("class","label label-danger");
|
||||
}
|
||||
if(data.priority==3){
|
||||
$("#mission_task_priority").html("非常紧急");
|
||||
$("#mission_task_priority").attr("class","label label-danger");
|
||||
}
|
||||
var name_list_str = "";
|
||||
for(var i=0; i < data.username.length; ++i){
|
||||
for(var i=0; i < data.users.length; ++i){
|
||||
if(i != 0){
|
||||
name_list_str+='、'
|
||||
name_list_str+=','
|
||||
}
|
||||
name_list_str += data.username[i];
|
||||
name_list_str += data.users[i];
|
||||
}
|
||||
$("#cy_task_users").html(name_list_str);
|
||||
if(data.priority==1){$("#cy_task_priority").html("普通");}
|
||||
if(data.priority==2){$("#cy_task_priority").html("紧急");}
|
||||
if(data.priority==3){$("#cy_task_priority").html("非常紧急");}
|
||||
|
||||
$("#mission_task_users").html(name_list_str);
|
||||
$("#mission_comments_container").html("");
|
||||
for(var i=0; i < data.comments.length; ++i){
|
||||
var template = $("#cy_comments_template");
|
||||
var tp=template.clone("true");
|
||||
tp.find("#cy_comment_name").html(data.comments[i].nickname);
|
||||
tp.find("#cy_comment_time").html(data.comments[i].time);
|
||||
tp.find("#cy_comment_content").html(data.comments[i].content);
|
||||
var comment='\
|
||||
<div class="direct-chat-msg">\
|
||||
<div class="direct-chat-info clearfix">\
|
||||
<span class="direct-chat-name pull-left">'+data.comments[i].nickname+'</span>\
|
||||
<span class="direct-chat-timestamp pull-right">'+data.comments[i].time.substring(0,5)+' '+data.comments[i].time.substring(6,11)+'</span>\
|
||||
</div>\
|
||||
<img class="direct-chat-img" src="../dist/img/avatar5.png" alt="message user image">\
|
||||
<div class="direct-chat-text">'+data.comments[i].content+'</div>\
|
||||
</div>';
|
||||
$("#mission_comments_container").append(comment);
|
||||
}
|
||||
// 初始化修改页面
|
||||
$("#mission_edit_content").val(data.content);
|
||||
$("#mission_edit_deadline").val(data.deadline.substring(0,10)+" "+data.deadline.substring(11,16));
|
||||
$("#mission_edit_name").val(data.name);
|
||||
$('input:radio[name="mission_edit_priority"][value='+data.priority+']').attr('checked','checked');
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
|
@ -483,50 +612,43 @@
|
|||
}
|
||||
});
|
||||
//显示模态框
|
||||
$("#cy_show_modal").click();
|
||||
$("#show_modal").click();
|
||||
}
|
||||
|
||||
$("#cy_submit_modify").click(function cy_update_mission(){
|
||||
var modify_name=$("#cy_modify_taskname").val();
|
||||
var modify_content=$("#cy_modify_taskcontent").val();
|
||||
var modify_deadline=$("#cy_modify_taskdeadline").val();
|
||||
var modify_priority=1;
|
||||
var modify_select=$("#cy_modify_select").find("option:selected").text();
|
||||
for(var i = 1; i <= 3; ++i){
|
||||
if($("#optionsRadios"+i).is(":checked")){
|
||||
modify_priority = i;
|
||||
}
|
||||
}
|
||||
if( modify_name.length>0 && modify_content.length>0 && modify_deadline.length>0){
|
||||
$.ajax({
|
||||
type:"patch",
|
||||
dataType:"json",
|
||||
url:"/missions/detail.json",
|
||||
data:{
|
||||
"id":parent.LoginUserInfo.selectProject,
|
||||
"mission[name]":modify_name,
|
||||
"mission[content]":modify_content,
|
||||
"mission[deadline]":modify_deadline,
|
||||
"mission[priority]":modify_priority,
|
||||
"mission[users]":modify_select
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = rpstr;
|
||||
if(robj["code"]==0){
|
||||
alert("修改成功!");
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
422:function(){
|
||||
alert("输入不符合要求,请重新输入!");
|
||||
function publish_comment(){
|
||||
var mission_id=$("#mission_id").val();
|
||||
var comment_content=$("#mission_comments_content").val();
|
||||
if( comment_content.length>0 ){
|
||||
$.ajax({
|
||||
type:"post",
|
||||
dataType:"json",
|
||||
url:"/missions/comments.json",
|
||||
data:{
|
||||
"mission_id":mission_id,
|
||||
"content":comment_content
|
||||
},
|
||||
async:false,// 强制同步
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var data=rpstr.data;
|
||||
if(rpstr.code=="0"){
|
||||
alert("评论成功!");
|
||||
$('#myModal').modal('hide');
|
||||
setTimeout("showTaskDetail("+mission_id+")", 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
alert("请输入完整!");
|
||||
}
|
||||
})
|
||||
else{
|
||||
alert("服务器内部出错啦!");
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
alert("请输入完整!");
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
Loading…
Reference in New Issue