/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2022-02-28 14:47
 * 描  述：信号通知表
 */
var refreshGirdData;
var ProjectId = request('ProjectId');

var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGird();
            page.bind();
        },
        bind: function () {
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 已阅
            $('#lr_read').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('WireGroupNoticeID');
                if (learun.checkrow(keyValue)) {
                    learun.httpPost(top.$.rootUrl + '/ZZDT_EC/ec_WireGroupNotice/Read', {
                        ProjectId: ProjectId,
                        keyValue: keyValue,
                    }, function (res) {
                        refreshGirdData();
                    });
                }
            });
            // 全部已阅
            $('#lr_reads').on('click', function () {
                var rows = $('#gridtable').jfGridGet('rowdatas');
                if (rows.length == 0) {
                    return false;
                }
                var ids = [];
                $.each(rows, function (id, item) {
                    ids.push(item.WireGroupNoticeID);
                });
                debugger;
                learun.layerConfirm('是否确认全部已阅！', function (res) {
                    learun.httpPost(top.$.rootUrl + '/ZZDT_EC/ec_WireGroupNotice/Reads', {
                        ProjectId: ProjectId,
                        NoticeIds: ids,
                    }, function (res) {
                        refreshGirdData();
                    });
                })
            });
        },
        initGird: function () {
            $('#gridtable').jfGrid({
                url: top.$.rootUrl + '/ZZDT_EC/ec_WireGroupNotice/GetList',
                headData: [
                    { label: 'CH.NO', name: 'Group_Name', width: 80, align: "center", sort: false },
                    { label: '中文描述', name: 'Group_Desc', width: 220, align: "center", sort: false },
                    { label: '英文描述', name: 'Group_Desc_EN', width: 220, align: "center", sort: false },
                    { label: 'IO类型', name: 'IO_Type', width: 80, align: "center", sort: false },
                    { label: '操作', name: 'Action', width: 80, align: "center", sort: false },
                    { label: '发布者', name: 'CreateUserName', width: 80, align: "center", sort: false },
                    { label: '操作时间', name: 'CreateTime', width: 130, align: "center", sort: false },
                    { label: '操作信息', name: 'Message', width: 500, align: "center", sort: false },
                    { name: "", width: 1, sort: false }
                ],
                mainId: 'WireGroupNoticeID',
            });
            page.search();
        },
        search: function (param) {
            param = param || {};
            param.ProjectId = ProjectId;
            $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
        }
    };
    refreshGirdData = function () {
        $('#gridtable').jfGridSet('reload');
    };
    page.init();
}
