123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- @using WePlatform.Configuration
- @using WePlatform.Authorization
- @using WePlatform.Views.Shared.Modals
- @using WePlatform.Views.Shared.SearchForm
- @using WePlatform.Views.Shared.Table
- @{
- ViewBag.Title = "行为角色管理";
- string activeMenu = PermissionNames.PagesResourceMgBasicMgBehaviorRoleMg;
- string role = "<option value=\"NEW\">新建角色</option>" + ViewBag.Role, category = ViewBag.Category;
- ViewBag.ActiveMenu = activeMenu;
- var searchForm = new SearchFormViewModel(new List<SearchItem>()
- {
- new SearchItem("roleName","行为角色"),
- //new SearchItem("sceneCategory","场景类别").SetSelectItem(category,isTree:true),
- }, "search-form", false);
- var table = new TableViewModel(IwbConsts.ApiAppUrl + "BehaviorRole/GetAll", activeMenu, searchForm)
- .SetFields(new List<FieldItem>()
- {
- new FieldItem("id", "编码"),
- new FieldItem("roleName", "行为角色"),
- new FieldItem("sceneCategoryName", "场景类别",isSort:false),
- });
- }
- @section css{
- }
- @Html.Partial("Table/_Table", table)
- @section modal{
- <!--Main Modal-->
- @{
- var modal = new ModalViewModel("角色", new ModalBodyViewModel(new List<Input>()
- {
- new InputHide("id"),
- new InputHide("roleName"),
- new InputHide("relateNo"),
- new Input("role", "行为角色",other:"onchange=RoleChange(this,1)").SetSelectOptions(role),
- new Input("role2", "新建角色",other:"onchange=RoleChange(this)" ).SetNotRequired(),
- new Input("sceneCategory", "场景类别").SetSelectOptions(category,isAddBlank:false),
- new InputTextarea("description", "角色详情").SetNotRequired(),
- }));
- }
- @Html.Partial("Modals/_Modal", modal)
- }
- @section scripts
- {
- <script src="~/Content/Libs/select2/js/select2tree.js"></script>
- <script type="text/javascript">
- var $table = $('#table');
- $(function () {
- $('#role2').closest('.form-group').hide();
- var $exTool = $table.closest('.table-box').find('.tableTool #Tool1');
- $exTool.append(
- '<div class="ml-3"><div class="form-group row " style="margin-bottom:0;"><label class=" iwb-label iwb-label-sm mr-1 pt-1" style="color:#007bff" for="tool-sceneCategory">场景类别</label><div><div class="input-group input-group-sm"><select class="form-control" id="tool-sceneCategory" name="tool-sceneCategory" type="text" style="width:250px">@(Html.Raw(category))</select></div></div></div></div>');
- var root = $('#tool-sceneCategory option[parent="0"]').eq(0).attr('value');
- var defaultCategory = $('#tool-sceneCategory option[parent="'+root+'"]').eq(0).attr('value');
- //console.log(defaultCategory);
- $('#tool-sceneCategory').val(defaultCategory).select2tree();
- //$('#tool-sceneCategory').val('').select2tree();
- $table = LoadTable({ searchFun: CustomSearchList });
- var funs = window.iwbfuns || { none: function() { console.log("No type"); } };
- funs["btnCreate"] = function() {
- BtnCreate({
- data: { id: "" },
- select2tree: "sceneCategory",
- shownAfter: function() {
- $.iwbAjax4({
- url: abp.appUrl + "Query/GetBehaviorRoleSelectStr",
- success: function(res) {
- var str = "<option value=\"NEW\">新建角色</option>"
- if (res) {
- str += res;
- }
- $('#role').html(str);
- }
- });
- }
- });
- }
- funs["btnUpdate"] = function() {
- var row = $table.bootstrapTable("getSelections")[0];
- if (row) {
- BtnUpdate(
- {
- disabled: "",
- select2tree: "sceneCategory",
- shownAfter: function() {
- $.iwbAjax4({
- url: abp.appUrl + "Query/GetBehaviorRoleSelectStr",
- success: function (res) {
- var str = "<option value=\"NEW\">新建角色</option>"
- if (res) {
- str += res;
- }
- $('#role').html(str);
- if (res) {
- $('#role option').each(function() {
- if ($(this).text() == row.roleName) {
- $('#role').val($(this).attr('value'));
- return;
- }
- });
- }
- }
- });
- }
- },row);
- }
- };
- funs["btnDelete"] = function () {
- var row = $table.bootstrapTable("getSelections")[0];
- if (row) {
- MsgConfirm(abp.localization.iwbZero('DeleteConfirmContent'),
- abp.localization.iwbZero('DeleteConfirm'),
- function() {
- $.iwbAjax1({
- url: abp.appUrl + "BehaviorRole/DeleteRole?id=" + row.id + "&relateNo=" + row.relateNo,
- success: function () {
- RefreshTable();
- }
- });
- });
- }
- };
- $('#tool-sceneCategory').on('change.reTable', function() { RefreshTable("table", true); });
- $('#sceneCategory').on('change.reTable',
- function(e) {
- $('#tool-sceneCategory').off('change.reTable');
- $('#tool-sceneCategory').val($(this).val()).select2tree();
- $('#tool-sceneCategory').on('change.reTable', function() { RefreshTable("table", true); });
- });
- });
- function RoleChange(that,type) {
- if (type) {
- if ($(that).val() == "NEW") {
- $('#role2').closest('.form-group').show();
- } else {
- $('#role2').closest('.form-group').hide();
- $('#roleName').val($(that).find('option:selected').text());
- }
- } else {
- $('#roleName').val($(that).val());
- }
- }
- function CustomSearchList(searchList) {
- var keyWord = $('#tool-sceneCategory').val();
- if (keyWord) {
- searchList.push({
- KeyWords: keyWord,
- KeyField: "CategoryNo",
- FieldType: 0,
- ExpType: 0
- });
- }
- }
- </script>
- <!--格式化-->
- <script id="formatter-script" type="text/javascript">
- function TypeFormatter(v) {
- var name = $('#hid-type option[value="' + v + '"]').text();
- switch (v) {
- case 0:
- return '<span class="label label-danger">' + name + '</span>';
- default:
- return '<span class="label label-info">' + name + '</span>';
- }
- }
- </script>
- }
- <section style="display: none">
- <select id="hid-type">
- <option value=""></option>
- </select>
- @*@Html.DropDownList("hid-type", type)*@
- </section>
|