123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- @using WePlatform
- @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.PagesResourceMgBasicMgSceneCategoryMg; //The menu item will be active for this page.
- ViewBag.ActiveMenu = activeMenu;
- var searchForm = new SearchFormViewModel(new List<SearchItem>()
- {
- new SearchItem("categoryName","类别名称"),
- }, "search-form", false);
- var table = new TableViewModel(IwbConsts.ApiAppUrl + "SceneCategory/GetAll", activeMenu)
- .SetFields(new List<FieldItem>()
- {
- //new FieldItem("parentNo", "父类别"),
- new FieldItem("categoryName", "类别名称",align:"left"),
- new FieldItem("", "操作","ActionsFormatter"),
- })
- .SetPageArray(1000);
- }
- @section css{
- }
- @Html.Partial("Table/_Table", table)
- @section modal{
- <!--Main Modal-->
- @{
- var modal = new ModalViewModel("场景类别", new ModalBodyViewModel(new List<Input>()
- {
- new InputHide("id"),
- new Input("parentNo", "父类别").SetNotRequired().SetSelectOptions(""),
- new Input("categoryName", "类别名称"),
- new InputNumber("sort", "类别排序"),
- new InputTextarea("description", "类别描述").SetNotRequired(),
- }));
- }
- @Html.Partial("Modals/_Modal", modal)
- }
- @section scripts
- {
- <script type="text/javascript">
- var $table = $("#table");
- var actions = [], funs = [];
- $(function () {
- funs= LoadTreeTable({
- rootNo: null,
- table: "table",
- idField: 'id',
- treeShowField: 'categoryName',
- customDataField: ['categoryPath']
- }) || { none: function () { console.log("No type"); } };
- var btnCreate = funs['btnCreate'];
- funs['btnCreate'] = function (url, id) {
- console.log("Add", id);
- var row;
- if (typeof id === "string" && id !== "") {
- row = $table.bootstrapTable("getRowByUniqueId", id);
- }
- if (row) {
- $.iwbAjax4({
- url: abp.appUrl + 'SceneCategory/GetSelectStr',
- success: function (res) {
- $("#parentNo").empty().html(res);
- btnCreate(url, id);
- }
- });
- } else {
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- }
- }
- var btnUpdate = funs['btnUpdate'];
- funs['btnUpdate'] = function (url, id) {
- console.log("Edit", id);
- var row;
- if (typeof id === "string" && id !== "") {
- row = $table.bootstrapTable("getRowByUniqueId", id);
- }
- if (row) {
- $.iwbAjax4({
- url: abp.appUrl + 'SceneCategory/GetSelectStr',
- success: function (res) {
- $("#parentNo").empty().html(res);
- btnUpdate(url, id);
- }
- });
- } else {
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- }
- }
- });
- </script>
- <script>
- //操作按钮
- function ActionsFormatter(v, r) {
- r._parent = null;
- var str = '<div class="btn-tool">';
- for (var i = 0; i < actions.length; i++) {
- //str += '<span class="table-action" onclick="funs[' + actions[i]["type"] + '](\'' + actions[i]["url"] + '\',\'' + r.id + '\',this)"><i class="' + actions[i]["icon"] + '"></i>' + actions[i]["name"] + ' </span>';
- str += '<span class="table-action" onclick="FunctionCall(\'' + actions[i]["type"] + '\',\'' + actions[i]["url"] + '\',\'' + r.id + '\',this)"><i class="' + actions[i]["icon"] + '"></i>' + actions[i]["name"] + ' </span>';
- }
- str += '</div>';
- return str;
- }
- function FunctionCall(type, url, id, that) {
- funs[type] ? funs[type].call(this, url, id, that) : funs["none"].call(this);
- }
- </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>
|