yangle
2023-08-03 cba0ef063a24b5b965bfa943cf1c8d2c8acba84a
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>审批用户权限设置</title>
    <link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../../layuiadmin/layui/layui1.js"></script>
    <script src="../../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../../layuiadmin/PubCustom.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-col-md12">
            <div class="layui-card" style="padding: 1px">
                <div class="layui-card-body" style="padding: 1px;">
                    <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-collapse">
                            <div class="layui-colla-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 85px;">审批流</label>
                                    <div class="layui-input-block" style="margin-left: 67px;">
                                        <input type="text" class="layui-input" name="HCheckFlowName" lay-verify="HCheckFlowName" id="HCheckFlowName" style="background-color:#efefef4d;width: 55%;margin-left:7px;display: inline-block;" readonly>
                                        <input type="hidden" class="layui-input" name="HCheckFlowID" lay-verify="HCheckFlowID" id="HCheckFlowID" value="0">
                                        <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHCheckFlowID" id="btnHCheckFlowID" style="padding: 0 10px;float: right;margin-right: 3px;">
                                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="layui-form-item" style="border-top: solid 1px #F6F6F6;">
                                    <div class="layui-row" style="padding:10px 0">
                                        <div class="layui-col-xs3 layui-inline">
                                            <div id="TreeTable" class="demo-tree demo-tree-box"></div>
                                        </div>
                                        <div class="layui-col-xs3 layui-inline">
                                            <div>
                                                <table class="" id="mainTable" lay-filter="mainTable"></table>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs2 layui-inline" style="text-align: center;">
                                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnLeft" id="btnLeft">左 </button>
                                            <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnRight" id="btnRight"> 右</button>
                                        </div>
                                        <div class="layui-col-xs3 layui-inline">
                                            <div>
                                                <table class="" id="mainTable1" lay-filter="mainTable1"></table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    layui.config({
        base: '../../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form', 'table', 'element', 'laypage', 'laydate',"tree"], function () {
        //#region 公用变量
        var $ = layui.$
            , admin = layui.admin
            , layer = layui.layer
            , table = layui.table
            , form = layui.form
            , element = layui.element
            , laypage = layui.laypage
            , laydate = layui.laydate
            , tree = layui.tree
        var sWhere = "";
        var userID = "";
 
        var option1 = [];
        var option2 = [];
        var cols = [
            { type: 'radio' },
            { field: "HInterID", title: "HInterID", width: 100, hide: true },
            { field: "czybm", title: "用户编号", width: 110 },
            { field: "用户名称", title: "用户名称", width: 100 },
            { field: "hcheckitemid", title: "hcheckitemid", width: 100, hide: true },
            { field: "审批项目", title: "审批项目", width: 110 }
        ];
 
        //#endregion
 
        //#region 进入页面即加载
        set_ClearBill();
 
        //#endregion
 
        //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
 
        //选择审批流按钮
        form.on('submit(btnHCheckFlowID)', function () {
            get_btnHCheckFlowID();
        });
 
        //左按钮
        form.on('submit(btnLeft)', function () {
            if (table.checkStatus('mainTable1').data.length == 0) {
                return layer.msg("点击此按钮,需要右边表格选择数据!")
            }
            get_btnLeft();
        });
 
        //右按钮
        form.on('submit(btnRight)', function () {
            if (table.checkStatus('mainTable').data.length == 0) {
                return layer.msg("点击此按钮,需要左边表格选择数据!")
            }
            get_btnRight();
        });
 
        //#endregion
 
        //#region 本页面被调用的所有方法
 
        // 初始化界面
        function set_ClearBill() {
            set_InitGrid();
            //查询
            get_Display(sWhere);
        }
 
        // 初始化表格方法
        function set_InitGrid() {
            option1 = {
                elem: '#mainTable'
                , height: 500
                , cols: [cols]
                , limit: 50
                , data: []
            };
 
            option2 = {
                elem: '#mainTable1'
                , height: 500
                , cols: [cols]
                , limit: 50
                , data: []
            };
            table.render(option1);
            table.render(option2);
        }
 
        // 树状图查询
        function get_Display(sWhere) {
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Xt_CheckFlowBill/Xt_CheckUserRight',
                type: "GET",
                success: function (data1) {
                    if (data1.count == 1) {
                        layer.close(ajaxLoad);
                        tree.render({
                            elem: '#TreeTable' //默认是点击节点可进行收缩
                            , data: data1.data
                            , click: function (obj) {
                                var data = obj.data;  //获取当前点击的节点数据
                                if (data.id != "1") {
                                    userID = data.id;
                                    get_Display1();
                                    get_Display2();
                                }
                            }
                        });
                    } else {
                        layer.close(ajaxLoad);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
        }
 
        //表格1 查询
        function get_Display1() {
            if ($("#HCheckFlowID").val() != 0) {
                sWhere = " and czybm='" + userID + "' and HInterID='" + $("#HCheckFlowID").val() + "'";
            }
            else {
                return layer.msg("请选择审批流!");
            }
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Xt_CheckFlowBill/Xt_CheckUserRightListMainSource',
                type: "GET",
                data: { "sWhere": sWhere },
                success: function (data1) {
                    if (data1.count == 1) {
                        option1.data = data1.data;
                        table.render(option1);
                    } else {
                        layer.close(ajaxLoad);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
        }
 
        //表格2 查询
        function get_Display2() {
            if ($("#HCheckFlowID").val() != 0) {
                sWhere = " and czybm='" + userID + "' and HInterID='" + $("#HCheckFlowID").val() + "'";
            }
            else {
                return layer.msg("请选择审批流!");
            }
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Xt_CheckFlowBill/Xt_CheckUserRightListMain',
                type: "GET",
                data: { "sWhere": sWhere },
                success: function (data1) {
                    if (data1.count == 1) {
                        option2.data = data1.data;
                        layer.close(ajaxLoad);
                        table.render(option2);
                    } else {
                        layer.close(ajaxLoad);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
        }
 
         //选择审批流
        function get_btnHCheckFlowID() {
            //打开部门小窗体
            layer.open({
                type: 2
                , skin: "layui-layer-rim" //加上边框
                , title: "审批流程列表"  //标题
                , closeBtn: 1  //窗体右上角关闭 的 样式
                , shift: 2 //弹出动画
                , area: ["90%", "90%"] //窗体大小
                , maxmin: true //设置最大最小按钮是否显示
                , content: ["../审核流程单/Xt_CheckFlowList.html", "yes"]
                , btn: ["确定", "取消"]
                , btn1: function (index, laero) {
                    //按钮一  的回调
                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
 
                    if (checkStatus.data.length != 1) {
                        return layer.msg("请选择一条数据");
                    }
                    //更新表格缓存的数据
                    $("#HCheckFlowID").val(checkStatus.data[0].Hmainid);
                    $("#HCheckFlowName").val(checkStatus.data[0].流程名称);
                    layer.close(index);//关闭弹窗
                }
            })
        }
 
        function get_btnLeft() {
            var checkStatus = table.checkStatus('mainTable1').data;
            var tables = [];
            for (var i = 0; i < option2.data.length; i++) {
                if (option2.data[i]["HInterID"] == checkStatus[0]["HInterID"] && option2.data[i]["hcheckitemid"] == checkStatus[0]["hcheckitemid"]) {
                    option1.data.push(option2.data[i]);
                } else {
                    tables.push(option2.data[i]);
                }
            }
           
            option2.data = tables;
            table.render(option1);
            table.render(option2);
            save()
        }
 
        function get_btnRight() {
            var checkStatus = table.checkStatus('mainTable').data;
            var tables = [];
 
            for (var i = 0; i < option1.data.length; i++) {
                if (option1.data[i]["HInterID"] == checkStatus[0]["HInterID"] && option1.data[i]["hcheckitemid"] == checkStatus[0]["hcheckitemid"]) {
                    option2.data.push(option1.data[i]);
                } else {
                    tables.push(option1.data[i]);
                }
            }
           
            option1.data = tables;
            table.render(option1);
            table.render(option2);
            save();
        }
 
        //保存
        function save() {
            var sMainStr = JSON.stringify(table.cache["mainTable1"]);
            $.ajax(
                {
                    type: "POST",
                    url: GetWEBURL() + "/Xt_CheckFlowBill/Xt_CheckUserRightEdit", //方法所在页面和方法名
                    async: true,
                    data: { "msg": sMainStr + ';' + userID + ';' + $("#HCheckFlowID").val()+ ';' + sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // 说明验证成功了,
                            layer.msg(data.Message, { icon: 1 });
                            get_Display1();
                            get_Display2();
                        }
                        else {
                            layer.msg(data.Message);
                        }
                        layer.closeAll("loading");
                    },
                    error: function (err) {
 
                        layer.msg(data.Message);
                    }
                })
        }
 
         //#endregion
});
 
</script>