yusijie
2023-02-02 04ee1e66aa1e13d786bc6b89e866b659f235d8f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
 
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>消息中心</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>
 
    <div class="layui-fluid" id="LAY-app-message">
        <div class="layui-card">
            <div class="layui-tab layui-tab-brief" lay-filter="demo">
                <ul class="layui-tab-title">
                    <li>通知<span class="layui-badge"></span></li>
                    <li>已阅</li>
                </ul>
                <div class="layui-tab-content">
 
                    <div class="layui-tab-item layui-show">
                        <table class="" id="mainTable" lay-filter="mainTable"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
 
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../../../Scripts/webConfig.js"></script>
 
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['tree', 'index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , element = layui.element
                , laypage = layui.laypage
                , laydate = layui.laydate
                , util = layui.util
                , tree = layui.tree
            var sWhere1 = " and B.HReceiveMan='" + sessionStorage["HUserName"]+"' and B.HReadFlag='0'";
 
            var option = {
                elem: '#mainTable'
                //, toolbar: '#toolbarDemo'
                , height: 'full-120'
                , page: true
                , cellMinWidth: 90
                , cols: [[
                    { type: 'radio', fixed: 'left' }
                    , { field: 'HInterID', title: '主内码', hide: true  }
                    , { field: 'HEntryID', title: '子内码', hide: true }
                    , { field: 'HContext', title: '主题' }
                    , { field: 'HDeptName', title: '发送部门' }
                    , { field: 'HSendMan', title: '发送人' }
                    , { field: 'HReceiveMan', title: '接收人' }
                    , { field: 'HLevel', title: '紧急程度' }
                    , { field: 'HDescription', title: '详细内容' }
                    , { field: 'HDate', title: '发布时间', templet: "<div>{{d.HDate ==null ?'':layui.util.toDateString(d.HDate, 'yyyy-MM-dd')}}</div>"}
                ]]
            };
            Load(sWhere1,0);
           
 
            //一些事件监听
            element.on('tab(demo)', function (data) {
                // console.log(data.index); //得到当前Tab的所在下标
                if (data.index == 0) {
                    console.log('通知');
                    sWhere1 = " and B.HReceiveMan='" + sessionStorage["HUserName"]+"' and B.HReadFlag='0'";
                    Load(sWhere1, data.index)
                   
                } else if (data.index == 1) {
                    console.log('已阅');
                    sWhere1 = " and B.HReceiveMan='" + sessionStorage["HUserName"]+"' and B.HReadFlag='1'";
                    Load(sWhere1, data.index)
                }
            });
 
            //数据加载
            function Load(sWhere1,flag)
            {
                var index = layer.load(0, { shade: false });
                //进入页面显示的缓存列表
                $.ajax({
                    url: GetWEBURL() + 'MsgData',
                    type: "GET",
                    data: { "sWhere": sWhere1 },
                    success: function (data1) {
                        if (data1.data.OA_InformBillMain.length == 1) {
                            if (flag == 0) {
                                $(".layui-badge").html(data1.data.OA_InformBillMain.length);
                            }
                            option.data = data1.data.OA_InformBillMain;
                            table.render(option);
                            layer.close(index);
                        } else {
                            option.data = data1.data.OA_InformBillMain;
                            table.render(option);
                            layer.close(index);
                        }
                    }, error: function () {
                        layer.close(index);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
 
            //点击表格数据
            table.on('row(mainTable)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
                var datas = obj.data; //获得当前行数据
                console.log(datas);
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '阅读明细 ',
                    closeBtn: false,
                    shift: 2,
                    area: ['100%', '100%'],
                    maxmin: true,
                    content: 'MessageDetail.html',
                    end: function () {
                        //刷新页面,
                        location.reload();
                    },
                    success: function (dom) {
                        var a = $(dom[0]).find("iframe").eq(0).contents();
                        a.find("h1").html(datas.HContext);
                        a.find("span").html(datas.HDate);
                        a.find(".layadmin-text").html(datas.HDescription);
                        UpdateMessage(sessionStorage["HUserName"],datas.HInterID, datas.HEntryID);
                    },
                });
            });
 
            //更新公告状态
            function UpdateMessage(UserName,HInterID, HEntryID)
            {
                $.ajax({
                    url: GetWEBURL() + 'UpdateMessage',
                    type: "GET",
                    data: { "UserName": UserName, "HInterID": HInterID, "HEntryID": HEntryID},
                    success: function (data1) {
                        if (data1.count == 1) {
 
                        } else {
 
                        }
                    }, error: function () {
                        layer.close(index);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            } 
 
        });
    </script>
</body>
</html>