role create&update&list

This commit is contained in:
RobbieHan
2018-11-14 13:44:27 +08:00
parent 0f6bd53883
commit 4570252f6d
11 changed files with 425 additions and 116 deletions

189
.idea/workspace.xml generated
View File

@@ -2,11 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="80da5b45-7eca-459a-bbe3-5443bc141768" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/apps/custom.py" afterPath="$PROJECT_DIR$/apps/custom.py" />
<change beforePath="$PROJECT_DIR$/apps/system/urls.py" afterPath="$PROJECT_DIR$/apps/system/urls.py" />
<change beforePath="$PROJECT_DIR$/apps/system/views_menu.py" afterPath="$PROJECT_DIR$/apps/system/views_menu.py" />
<change beforePath="$PROJECT_DIR$/db.sqlite3" afterPath="$PROJECT_DIR$/db.sqlite3" />
<change beforePath="$PROJECT_DIR$/templates/system/menu_list.html" afterPath="$PROJECT_DIR$/templates/system/menu_list.html" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@@ -19,64 +16,7 @@
<option name="myCustomStartScript" value="import sys; print('Python %s on %s' % (sys.version, sys.platform))&#10;import django; print('Django %s' % django.get_version())&#10;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])&#10;if 'setup' in dir(django): django.setup()&#10;import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="urls.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/apps/system/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="30" column="0" lean-forward="true" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="menu_update.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/templates/system/menu_update.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="623">
<caret line="100" column="0" lean-forward="true" selection-start-line="100" selection-start-column="0" selection-end-line="100" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="menu_list.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/templates/system/menu_list.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="606">
<caret line="160" column="11" lean-forward="true" selection-start-line="160" selection-start-column="11" selection-end-line="160" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="views_menu.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="391">
<caret line="23" column="0" lean-forward="true" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="custom.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/apps/custom.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="555">
<caret line="55" column="53" lean-forward="true" selection-start-line="55" selection-start-column="53" selection-end-line="55" selection-end-column="53" />
<folding>
<element signature="e#73#84#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@@ -124,11 +64,15 @@
<option value="$PROJECT_DIR$/apps/system/apps.py" />
<option value="$PROJECT_DIR$/sandboxMP/settings.py" />
<option value="$PROJECT_DIR$/apps/system/views_structure.py" />
<option value="$PROJECT_DIR$/apps/system/urls.py" />
<option value="$PROJECT_DIR$/templates/system/menu_update.html" />
<option value="$PROJECT_DIR$/templates/system/menu_list.html" />
<option value="$PROJECT_DIR$/apps/custom.py" />
<option value="$PROJECT_DIR$/templates/system/role_create.html" />
<option value="$PROJECT_DIR$/apps/system/views_menu.py" />
<option value="$PROJECT_DIR$/templates/system/role_update.html" />
<option value="$PROJECT_DIR$/apps/system/urls.py" />
<option value="$PROJECT_DIR$/apps/system/views_role.py" />
<option value="$PROJECT_DIR$/templates/system/role.html" />
</list>
</option>
</component>
@@ -138,11 +82,11 @@
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="-1379" />
<option name="y" value="113" />
<option name="width" value="1456" />
<option name="height" value="876" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1936" />
<option name="height" value="1056" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
@@ -176,7 +120,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
@@ -192,14 +136,24 @@
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="apps" type="462c0819:PsiDirectoryNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="templates" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sandboxMP" type="b2602c69:ProjectViewProjectNode" />
<item name="sandboxMP" type="462c0819:PsiDirectoryNode" />
<item name="templates" type="462c0819:PsiDirectoryNode" />
<item name="system" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -293,22 +247,21 @@
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24156693" sideWeight="0.5042644" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23068553" sideWeight="0.49573562" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.1936888" sideWeight="0.49573562" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Mongo Explorer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1609808" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.14978679" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="SciView" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.18656716" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.26792964" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.21650879" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297062" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@@ -346,34 +299,6 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/apps/system/views_user.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="20" column="6" lean-forward="false" selection-start-line="20" selection-start-column="6" selection-end-line="20" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="0" lean-forward="true" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sandboxMP/settings.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/bootstrap/js/npm.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="12" column="28" lean-forward="true" selection-start-line="12" selection-start-column="28" selection-end-line="12" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
@@ -712,16 +637,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="30" column="0" lean-forward="true" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/menu_update.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="623">
@@ -740,7 +655,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/apps/custom.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="555">
<state relative-caret-position="691">
<caret line="55" column="53" lean-forward="true" selection-start-line="55" selection-start-column="53" selection-end-line="55" selection-end-column="53" />
<folding>
<element signature="e#73#84#0" expanded="true" />
@@ -748,16 +663,60 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/role_update.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="657">
<caret line="80" column="14" lean-forward="false" selection-start-line="80" selection-start-column="14" selection-end-line="80" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_role.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595">
<caret line="35" column="28" lean-forward="false" selection-start-line="35" selection-start-column="28" selection-end-line="35" selection-end-column="28" />
<folding>
<element signature="e#78#89#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/views_menu.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="391">
<caret line="23" column="0" lean-forward="true" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<state relative-caret-position="136">
<caret line="8" column="16" lean-forward="true" selection-start-line="8" selection-start-column="16" selection-end-line="9" selection-end-column="22" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/role.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="657">
<caret line="145" column="1" lean-forward="true" selection-start-line="145" selection-start-column="1" selection-end-line="145" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/system/role_form.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="504">
<caret line="70" column="11" lean-forward="true" selection-start-line="70" selection-start-column="11" selection-end-line="70" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/apps/system/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="578">
<caret line="34" column="0" lean-forward="true" selection-start-line="34" selection-start-column="0" selection-end-line="34" selection-end-column="0" />
<folding>
<element signature="e#0#28#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

Binary file not shown.

View File

@@ -1,7 +1,7 @@
from django.urls import path
from .views import SystemView
from . import views_structure, views_user, views_menu
from . import views_structure, views_user, views_menu, views_role
app_name = 'system'
@@ -27,4 +27,8 @@ urlpatterns = [
path('rbac/menu/create/', views_menu.MenuCreateView.as_view(), name='rbac-menu-create'),
path('rbac/menu/update/', views_menu.MenuUpdateView.as_view(), name='rbac-menu-update'),
path('rbac/role/', views_role.RoleView.as_view(), name='rbac-role'),
path('rbac/role/create/', views_role.RoleCreateView.as_view(), name='rbac-role-create'),
path('rbac/role/list/', views_role.RoleListView.as_view(), name='rbac-role-list'),
path('rbac/role/update/', views_role.RoleUpdateView.as_view(), name='rbac-role-update'),
]

36
apps/system/views_role.py Normal file
View File

@@ -0,0 +1,36 @@
# @Time : 2018/11/13 23:25
# @Author : RobbieHan
# @File : views_role.py
import json
from django.views.generic.base import View
from django.shortcuts import HttpResponse
from django.views.generic import TemplateView
from .mixin import LoginRequiredMixin
from .models import Role
from custom import SandboxCreateView, SandboxUpdateView
class RoleView(LoginRequiredMixin, TemplateView):
template_name = 'system/role.html'
class RoleCreateView(SandboxCreateView):
model = Role
fields = '__all__'
class RoleListView(LoginRequiredMixin, View):
def get(self, reqeust):
fields = ['id', 'name', 'desc']
ret = dict(data=list(Role.objects.values(*fields)))
return HttpResponse(json.dumps(ret), content_type='application/json')
class RoleUpdateView(SandboxUpdateView):
model = Role
fields = '__all__'
template_name_suffix = '_update'

Binary file not shown.

149
templates/system/role.html Normal file
View File

@@ -0,0 +1,149 @@
{% extends "base-left.html" %}
{% load staticfiles %}
{% block css %}
<link rel="stylesheet" href="{% static 'plugins/datatables/jquery.dataTables.min.css' %}">
<link rel="stylesheet" href="{% static 'js/plugins/layer/skin/layer.css' %}">
{% endblock %}
{% block content %}
<!-- Main content -->
<section class="content">
<div id="devlist">
<div class="box box-primary" id="liebiao">
<div class="box-header">
<div class="btn-group pull-left">
<button type="button" id="btnRefresh" class="btn btn-default">
<i class="glyphicon glyphicon-repeat"></i>刷新
</button>
</div>
<div class="btn-group pull-left">&nbsp</div>
<div class="btn-group pull-left">
<button type="button" id="btnCreate" class="btn btn-default">
<i class="glyphicon glyphicon-plus"></i>新增
</button>
</div>
<div class="btn-group pull-left">&nbsp</div>
<div class="btn-group pull-left">
<button type="button" id="btnDelete" class="btn btn-default">
<i class="glyphicon glyphicon-trash"></i>删除
</button>
</div>
</div>
<div class="box-body">
<table id="dtbList" class="display" cellspacing="0" width="100%">
<thead>
<tr valign="middle">
<th><input type="checkbox" id="checkAll"></th>
<th>ID</th>
<th>名称</th>
<th>说明</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<br> <br>
</div>
</div>
</div>
</section>
<!-- /.content -->
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'plugins/datatables/dataTables.const.js' %}"></script>
<script src="{% static 'js/plugins/layer/layer.js' %}"></script>
<script type="text/javascript">
var oDataTable = null;
$(function () {
oDataTable = initTable();
function initTable() {
var oTable = $('#dtbList').DataTable($.extend(true, {},
DATATABLES_CONSTANT.DATA_TABLES.DEFAULT_OPTION,
{
ajax: {
"url": "{% url 'system:rbac-role-list' %}",
},
columns: [
DATATABLES_CONSTANT.DATA_TABLES.COLUMN.CHECKBOX,
{
data: "id",
width: "5%",
},
{
data: "name",
//width : "20%",
},
{
data: "desc",
//width : "20%",
},
{
data: "id",
width: "16%",
bSortable: "false",
render: function (data, type, row, meta) {
var ret = "";
var ret = "<button title='详情-编辑' onclick='doUpdate("
+ data + ")'><i class='glyphicon glyphicon-pencil'></i></button>";
ret = ret + "<button title='关联用户' onclick='doUpdateUser("
+ data + ")'><i class='glyphicon glyphicon-user'></i></button>";
ret = ret + "<button title='关联菜单' onclick='doUpdateMenu("
+ data + ")'><i class='glyphicon glyphicon-tree-conifer'></i></button>";
ret = ret + "<button title='删除' onclick='doDelete("
+ data + ")'><i class='glyphicon glyphicon-trash'></i></button>";
return ret;
}
}],
}));
return oTable;
}
});
$("#btnCreate").click(function () {
layer.open({
type: 2,
title: '新增',
shadeClose: false,
maxmin: true,
area: ['800px', '300px'],
content: "{% url 'system:rbac-role-create' %}",
end: function () {
//关闭时做的事情
oDataTable.ajax.reload();
}
});
});
$("#btnRefresh").click(function () {
oDataTable.ajax.reload();
});
function doUpdate(id) {
layer.open({
type: 2,
title: '编辑',
shadeClose: false,
maxmin: true,
area: ['800px', '400px'],
content: ["{% url 'system:rbac-role-update' %}" + '?id=' + id, 'no'],
end: function () {
oDataTable.ajax.reload();
}
});
}
</script>
{% endblock %}

View File

@@ -0,0 +1,80 @@
{% extends 'base-layer.html' %}
{% load staticfiles %}
{% block main %}
<div class="box box-danger">
<form class="form-horizontal" id="addForm" method="post">
{% csrf_token %}
<div class="box-body">
<fieldset>
<legend>
<h4>新建角色</h4>
</legend>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-8">
<input class="form-control" name="name" type="text" />
</div>
</div>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">描述</label>
<div class="col-sm-8">
<input class="form-control" name="desc" type="text" />
</div>
</div>
</fieldset>
</div>
<div class="box-footer ">
<div class="row span7 text-center ">
<button type="button" id="btnCancel" class="btn btn-default margin-right ">重置</button>
<button type="button" id="btnSave" class="btn btn-info margin-right ">保存</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/combo-select/jquery.combo.select.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap-datetimepicker.js' %}"></script>
<script type="text/javascript">
$("#btnSave").click(function () {
var data = $("#addForm").serialize();
$.ajax({
type: $("#addForm").attr('method'),
url: "{% url 'system:rbac-role-create' %}",
data: data,
cache: false,
success: function (msg) {
if (msg.result) {
layer.alert('数据保存成功!', {icon: 1}, function (index) {
parent.layer.closeAll(); //关闭所有弹窗
});
} else {
layer.alert('数据保存失败', {icon: 5});
//$('errorMessage').html(msg.message)
}
return;
}
});
});
/*点取消刷新新页面*/
$("#btnCancel").click(function () {
window.location.reload();
});
/*select 支持输入检索*/
$(function () {
$('select').comboSelect();
});
</script>
{% endblock %}

View File

@@ -0,0 +1,81 @@
{% extends 'base-layer.html' %}
{% load staticfiles %}
{% block main %}
<div class="box box-danger">
<form class="form-horizontal" id="addForm" method="post">
{% csrf_token %}
<input type="hidden" name='id' value="{{ role.id }}"/>
<div class="box-body">
<fieldset>
<legend>
<h4>修改角色</h4>
</legend>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-8">
<input class="form-control" name="name" type="text" value="{{ role.name }}"/>
</div>
</div>
<div class="form-group has-feedback">
<label class="col-sm-2 control-label">描述</label>
<div class="col-sm-8">
<input class="form-control" name="desc" type="text" value="{{ role.desc }}"/>
</div>
</div>
</fieldset>
</div>
<div class="box-footer ">
<div class="row span7 text-center ">
<button type="button" id="btnCancel" class="btn btn-default margin-right ">重置</button>
<button type="button" id="btnSave" class="btn btn-info margin-right ">保存</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block javascripts %}
<script src="{% static 'plugins/combo-select/jquery.combo.select.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap-datetimepicker.js' %}"></script>
<script type="text/javascript">
$("#btnSave").click(function () {
var data = $("#addForm").serialize();
$.ajax({
type: $("#addForm").attr('method'),
url: "{% url 'system:rbac-role-update' %}",
data: data,
cache: false,
success: function (msg) {
if (msg.result) {
layer.alert('数据保存成功!', {icon: 1}, function (index) {
parent.layer.closeAll(); //关闭所有弹窗
});
} else {
layer.alert('数据保存失败', {icon: 5});
//$('errorMessage').html(msg.message)
}
return;
}
});
});
/*点取消刷新新页面*/
$("#btnCancel").click(function () {
window.location.reload();
});
/*select 支持输入检索*/
$(function () {
$('select').comboSelect();
});
</script>
{% endblock %}