pull/530/head
江世峰 8 years ago
parent 0dec647116
commit fd52a85dbb

@ -5,18 +5,11 @@
{% block custom_head_css_js %} {% block custom_head_css_js %}
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet"> <link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script> <script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
<link href="{% static 'css/plugins/dataTables/datatables.min.css' %}" rel="stylesheet">
<script src="{% static 'js/plugins/dataTables/datatables.min.js' %}"></script>
<style> <style>
div.dataTables_wrapper div.dataTables_filter,
<!--table.dataTable tbody tr.selected {--> .dataTables_length {
<!--background-color: white;--> float: left;
<!--color:#676a6c;--> }
<!--//background-color: transparent;-->
<!--}-->
<!--table.dataTable tbody tr.selected td.text-center{-->
<!--background-color: #B0BED9;-->
<!--}-->
</style> </style>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -50,7 +43,7 @@
{{ form.name|bootstrap_horizontal }} {{ form.name|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }} {{ form.comment|bootstrap_horizontal }}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<h3 class="widget-head-color-box">资产数量</h3> <h3 class="widget-head-color-box">用户选择的资产</h3>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">已选</label> <label class="col-sm-2 control-label">已选</label>
<div class="col-sm-9" id="asset_sed"> <div class="col-sm-9" id="asset_sed">

@ -9,7 +9,7 @@
<thead> <thead>
<tr> <tr>
<th class="text-center" style="background-color:white"> <th class="text-center" style="background-color:white">
<input type="checkbox" id="check_all" onclick="checkAll('check_all', 'checked')"> <input type="checkbox" id="check_all" onclick="checkAll()">
</th> </th>
<th id="th_no">id</th> <th id="th_no">id</th>
<th>资产名称</th> <th>资产名称</th>
@ -21,10 +21,11 @@
</thead> </thead>
<tbody> <tbody>
{% for asset in asset_modal_list %} {% for asset in asset_modal_list %}
<tr>
{% if asset.id in group_assets %} {% if asset.id in group_assets %}
<tr name="oAssets" class="odd selected">
<td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" checked="checked" ></td> <td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" checked="checked" ></td>
{% else %} {% else %}
<tr name="oAssets">
<td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" ></td> <td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" ></td>
{% endif %} {% endif %}
<td>{{ asset.id }}</td> <td>{{ asset.id }}</td>
@ -54,6 +55,9 @@ $(document).ready(function(){
"aaSorting": [[2, "asc"]], "aaSorting": [[2, "asc"]],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0 ] }], "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0 ] }],
"bAutoWidth": false, "bAutoWidth": false,
"language": {
"url": "/static/js/plugins/dataTables/i18n/zh-hans.json"
},
columns: [ columns: [
{data: "checkbox"}, {data: "checkbox"},
{data: "id"}, {data: "id"},
@ -64,9 +68,18 @@ $(document).ready(function(){
{data: "dp"} {data: "dp"}
] ]
}); });
//讲ID列隐藏
table.column('1').visible(false); table.column('1').visible(false);
$('#editable tbody').on( 'click', 'tr', function () { $('#editable tbody').on( 'click', 'tr', function () {
$(this).toggleClass('selected'); //alert($(this).hasClass('selected'));
if($(this).hasClass('selected')){
$(this).removeClass('selected');
this.children[0].children[0].checked=0;
}else{
$(this).addClass('selected');
this.children[0].children[0].checked=1;
};
}); });
$('#save-btn').on('click',function(){ $('#save-btn').on('click',function(){
@ -77,23 +90,34 @@ $(document).ready(function(){
var column2 = table.rows('.selected').data(); var column2 = table.rows('.selected').data();
$("#asset_sed").find("input[name='assets']").remove(); $("#asset_sed").find("input[name='assets']").remove();
for(var i=0;i<column2.length;i++){ for(var i=0;i<column2.length;i++){
column2[i].checkbox='<input name="checked" value="1" checked="" type="checkbox">';
var value = column2[i].id; var value = column2[i].id;
$("#asset_sed").append("<input type='hidden' name='assets' value='"+value+"'>"); $("#asset_sed").append("<input type='hidden' name='assets' value='"+value+"'>");
} }
$('#modal').modal('hide'); $('#modal').modal('hide');
}); });
}); //$(document).ready
var bCheck = 1;
function checkAll(){
if(bCheck){
$("tr[name='oAssets']").each(function(){
oCheckbox = this.children[0].children[0];
$(this).toggleClass('selected',true);
oCheckbox.checked=1;
}); });
$('#close-btn').on('click',function(){ document.getElementById('check_all').checked=1;
//alert('点击关闭按钮时触发;') bCheck = 0;
$('#modal').modal('hide'); }else{
$("tr[name='oAssets']").each(function(){
oCheckbox = this.children[0].children[0];
$(this).toggleClass('selected',false);
oCheckbox.checked=0;
}); });
document.getElementById('check_all').checked=0;
bCheck = 1;
};
};
</script> </script>

@ -1,15 +1,15 @@
{% load static %} {% load static %}
<!-- css file --> <!-- css file -->
<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static "css/font-awesome.css" %}" rel="stylesheet"> <link href="{% static 'css/font-awesome.css' %}" rel="stylesheet">
<link href="{% static "css/plugins/toastr/toastr.min.css" %}" rel="stylesheet"> <link href="{% static 'css/plugins/toastr/toastr.min.css' %}" rel="stylesheet">
<link href="{% static "css/plugins/sweetalert/sweetalert.css" %}" rel="stylesheet"> <link href="{% static 'css/plugins/sweetalert/sweetalert.css' %}" rel="stylesheet">
<link href="{% static "css/style.css" %}" rel="stylesheet"> <link href="{% static 'css/style.css' %}" rel="stylesheet">
<link href="{% static "css/plugins/vaildator/jquery.validator.css" %}" rel="stylesheet"> <link href="{% static 'css/plugins/vaildator/jquery.validator.css' %}" rel="stylesheet">
<link href="{% static 'css/plugins/dataTables/datatables.min.css' %}" rel="stylesheet">
<!-- scripts --> <!-- scripts -->
<script src="{% static 'js/jquery-2.1.1.js' %}"></script> <script src="{% static 'js/jquery-2.1.1.js' %}"></script>
<!-- Sweet alert -->
<script src="{% static 'js/plugins/sweetalert/sweetalert.min.js' %}"></script> <script src="{% static 'js/plugins/sweetalert/sweetalert.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script> <script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/plugins/dataTables/datatables.min.js' %}"></script>

@ -8,10 +8,10 @@
<title>Jumpserver</title> <title>Jumpserver</title>
<link rel="shortcut icon" href={% static "img/facio.ico" %} type="image/x-icon"> <link rel="shortcut icon" href="{% static 'img/facio.ico' %}" type="image/x-icon">
{% include '_head_css_js.html' %} {% include '_head_css_js.html' %}
<link href="{% static 'css/jumpserver.css' %}" rel="stylesheet">
{% block custom_head_css_js %} {% endblock %} {% block custom_head_css_js %} {% endblock %}
<link href="{% static "css/jumpserver.css" %}" rel="stylesheet">
</head> </head>
<body> <body>

Loading…
Cancel
Save