mindoc/views/manager/team_book_list.tpl

191 lines
8.4 KiB
Smarty

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>团队项目 - Powered by MinDoc</title>
<!-- Bootstrap -->
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet" type="text/css">
<link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet" type="text/css">
<link href="{{cdncss "/static/select2/4.0.5/css/select2.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/css/main.css" "version"}}" rel="stylesheet">
</head>
<body>
<div class="manual-reader">
{{template "widgets/header.tpl" .}}
<div class="container manual-body">
<div class="row">
{{template "manager/widgets.tpl" "team"}}
<div class="page-right">
<div class="m-box">
<div class="box-head">
<strong class="box-title">{{.Model.TeamName}} - 团队项目</strong>
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#addTeamBookDialogModal"><i class="fa fa-book" aria-hidden="true"></i> 添加项目</button>
</div>
</div>
<div class="box-body">
<div class="attach-list" id="teamBookList">
<table class="table">
<thead>
<tr>
<th>项目名称</th>
<th>项目作者</th>
<th>加入时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<template v-if="lists.length <= 0">
<tr class="text-center"><td colspan="4">暂无数据</td></tr>
</template>
<template v-else>
<tr v-for="item in lists">
<td>${item.book_name}</td>
<td>${item.book_member_name}</td>
<td>${(new Date(item.create_time)).format("yyyy-MM-dd hh:mm:ss")}</td>
<td>
<button type="button" data-method="delete" class="btn btn-danger btn-sm" @click="deleteTeamBook(item.team_relationship_id)" data-loading-text="删除中...">删除</button>
</td>
</tr>
</template>
</tbody>
</table>
<nav class="pagination-container">
{{.PageHtml}}
</nav>
</div>
</div>
</div>
</div>
</div>
{{template "widgets/footer.tpl" .}}
</div>
<!-- Modal -->
<div class="modal fade" id="addTeamBookDialogModal" tabindex="-1" role="dialog" aria-labelledby="addTeamBookDialogModalLabel">
<div class="modal-dialog modal-sm" role="document" style="width: 450px;">
<form method="post" autocomplete="off" class="form-horizontal" action="{{urlfor "ManagerController.TeamBookAdd"}}" id="addTeamBookDialogForm">
<input type="hidden" name="teamId" value="{{.Model.TeamId}}">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">加入项目</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-sm-3 control-label">项目名称</label>
<div class="col-sm-9">
<select class="js-data-example-ajax form-control" multiple="multiple" name="bookId" id="bookId"></select>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="modal-footer">
<span id="form-error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-success" data-loading-text="保存中..." id="btnAddBook">保存</button>
</div>
</div>
</form>
</div>
</div><!--END Modal-->
<script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}"></script>
<script src="{{cdnjs "/static/vuejs/vue.min.js"}}"></script>
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/layer/layer.js" }}" type="text/javascript"></script>
<script src="{{cdnjs "/static/select2/4.0.5/js/select2.full.min.js"}}"></script>
<script src="{{cdnjs "/static/select2/4.0.5/js/i18n/zh-CN.js"}}"></script>
<script src="{{cdnjs "/static/js/main.js"}}" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var modalCache = $("#addTeamBookDialogModal form").html();
$("#addTeamBookDialogForm").ajaxForm({
beforeSubmit : function () {
var memberId = $.trim($("#bookId").val());
if(memberId === ""){
return showError("项目不能为空");
}
$("#btnAddBook").button("loading");
},
success : function (res) {
if(res.errcode === 0){
app.lists.splice(0,0,res.data);
$("#addTeamBookDialogModal").modal("hide");
}else{
showError(res.message);
}
$("#btnAddBook").button("reset");
}
});
$("#addTeamBookDialogModal").on("hidden.bs.modal",function () {
$(this).find("form").html(modalCache);
}).on("show.bs.modal",function () {
$('.js-data-example-ajax').select2({
language: "zh-CN",
minimumInputLength : 1,
minimumResultsForSearch: Infinity,
maximumSelectionLength:1,
width : "100%",
ajax: {
url: '{{urlfor "ManagerController.TeamSearchBook" "teamId" .Model.TeamId}}',
dataType: 'json',
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
processResults: function (data, params) {
return {
results : data.data.results
}
}
}
});
});
var app = new Vue({
el: "#teamBookList",
data: {
lists: {{.Result}}
},
delimiters: ['${', '}'],
methods: {
deleteTeamBook: function ($id, $e) {
var $this = this;
$.ajax({
url : "{{urlfor "ManagerController.TeamBookDelete"}}",
data : { "teamRelId" : $id },
type : "post",
dataType : "json",
success : function ($res) {
if($res.errcode === 0){
for (var index in $this.lists) {
var item = $this.lists[index];
if (item.team_relationship_id == $id) {
$this.lists.splice(index,1);
break;
}
}
}else {
layer.msg(res.message);
}
},
error : function () {
layer.msg("服务器异常");
}
});
}
}
});
});
</script>
</body>
</html>