123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- @using WeApp.Authorization
- @using WeApp.Configuration
- @using WeApp.Views.Shared.SearchForm
- @using WeApp.Views.Shared.Table
- @{
- ViewBag.ActiveMenu = PermissionNames.Pages; //The menu item will be active for this page.
- ViewBag.Title = L("NotificationTitle");
- List<SelectListItem> states = new List<SelectListItem>
- {
- new SelectListItem() {Text = L("NoRead"), Value = "0"},
- new SelectListItem() {Text = L("HasRead"), Value = "1"}
- },
- names= IwbNotificationName.GetNameList() ;
- var table = new TableViewModel(IwbConsts.ApiAppUrl + "Notification/GetAll", ViewBag.ActiveMenu, new SearchFormViewModel(new List<SearchItem>()
- {
- new SearchItem("state", L("notificationState"),FieldType.I).SetSelectItem(states),
- new SearchItem("date", L("notificationDate"),FieldType.Dn)
- })).SetFields(new List<FieldItem>()
- {
- new FieldItem("name", L("notificationName"),"NameFormatter",isSort:false),
- new FieldItem("text", L("notificationText"),isSort:false),
- new FieldItem("time", L("notificationDate"),isSort:false),
- new FieldItem("notificationState",L("notificationState"),"StateFormatter",isSort:false),
- new FieldItem("",L("Actions"),"ActionFormatter"),
- });
- }
- @Html.Partial("Table/_Table", table)
- @section scripts{
- <script type="text/javascript">
- $(function () {
- LoadTable({
- table: 'table',
- responseHandler: function (res) {
- if (res.success) {
- if (res.result.items.length > 0) {
- var notifications = [];
- $.each(res.result.items, function (index, item) {
- notifications.push(NotificationFormat(item));
- });
- var data = JSON.parse('{"total":' + res.result.totalCount + ',"rows":' + JSON.stringify(notifications) + '}');
- console.log(data);
- return data;
- }
- } else {
- console.log('Table load failed');
- if (res.error) {
- if (res.error.details) {
- return abp.message.error(res.error.details, res.error.message);
- } else {
- if (res.error.message && res.error.message.indexOf('登陆超时') >= 0) {
- return abp.message.error(res.error.message).done(function () {
- window.top.location.reload();
- });
- } else {
- return abp.message.error(res.error.message || abp.ajax.defaultError.message);
- }
- }
- }
- }
- return JSON.parse('{"total":0,"rows":[]}');
- }
- });
- //var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
- //funs["btnUpdate"] = function () { BtnUpdate({ disabled: "codeValue,tableName,columnName" }); };
- });
- function NotificationFormat(userNotification) {
- var f = {
- id: userNotification.id,
- userNotificationId: userNotification.id,
- name: userNotification.notification.notificationName,
- text: abp.notifications.getFormattedMessageFromUserNotification(userNotification),
- time: moment(userNotification.notification.creationTime).format("YYYY-MM-DD HH:mm:ss"),
- icon: abp.userNotificationHelper.getUiIconBySeverity(userNotification.notification.severity),
- //notificationState: abp.notifications.getUserNotificationStateAsString(userNotification.state),
- notificationState: userNotification.state,
- data: userNotification.notification.data,
- url: abp.userNotificationHelper.getUrl(userNotification),
- isUnread: userNotification.state === abp.notifications.userNotificationState.UNREAD,
- timeAgo: moment(userNotification.notification.creationTime).fromNow()
- };
- return f;
- }
- function SetRead(id) {
- $.iwbAjax1({
- url:abp.appUrl+ 'Notification/SetNotificationAsRead',
- data:{id: id},
- success: function() {
- abp.event.trigger('app.notifications.refresh', id);
- RefreshTable();
- }
- });
- }
- function Delete(id) {
- $.iwbAjax1({
- url:abp.appUrl+ 'Notification/DeleteNotification',
- data:{id: id},
- success: function() {
- abp.event.trigger('app.notifications.refresh', id);
- RefreshTable();
- }
- });
- }
-
- </script>
- <script id="formatter-script">
- function ActionFormatter(v,r) {
- var icon = '<i class="fa fa-angle-double-right"></i>',
- readStr = '<span class="table-action" onclick="SetRead(\''+r.id+'\')">' + icon + '@(L("SetAsRead"))</span>',
- deleteStr = '<span class="table-action" onclick="Delete(\''+r.id+'\')">' + icon + '@(L("DeleteNotification"))</span>';
- var str = '';
- if (r.notificationState === 0) {
- str += readStr;
- }
- str += deleteStr;
- return str;
- }
- function StateFormatter(v) {
- var name = $('#hid-state option[value="' + v + '"]').text();
- if (v === 1) {
- return '<span class="label label-success">' + name + '</span>';
- } else
- return '<span class="label label-danger">' + name + '</span>';
- }
- function NameFormatter(v) {
- var name = $('#hid-name option[value="' + v + '"]').text();
- return '<span class=" text-p">' + name + '</span>';
- }
- </script>
- }
- <section style="display:none">
- @Html.DropDownList("hid-state", states)
- @Html.DropDownList("hid-name", names)
- </section>
- @section css{
- }
|