chenhaozhe
2025-08-14 66be6d37c3f66c6861abc3f6a87258e2199e006c
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!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">
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/layui/layui.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>
    <style>
        .main-btn { /*头部主按钮*/
            padding: 0 2px; /*调整按钮左右空隙大小*/
            height: 30px;
            line-height: 30px;
        }
 
        .btn-title {
            font-size: 16px;
        }
        /* 防止下拉框的下拉列表被隐藏---必须设置--- */
        .layui-table-cell {
            overflow: visible !important;
        }
        /* 使得下拉框与单元格刚好合适 */
        td .layui-form-select {
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
 
        .layui-form-item .layui-inline {
            margin-top: 5px;
            margin-bottom: 5px;
            margin-right: 0px;
        }
 
        .layui-form-label {
            width: 25%;
        }
    </style>
 
</head>
<body>
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-card" style="padding: 2px;background-color: #efefef;">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                    <div style="padding: 10px; ">
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnEdit" id="btnEdit">退出</button>
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--基本信息-->
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">角色名</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="GroupName" lay-verify="GroupName" id="GroupName" value="">
                                                <input type="hidden" class="layui-input" name="HGroupID" lay-verify="HGroupID" id="HGroupID" value="0">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">级别</label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                                <select name="HLev" id="HLev" lay-verify="HLev">
                                                    <option value="总经理级">总经理</option>
                                                    <option value="副总级">副总经理</option>
                                                    <option value="质量总监">质量总监</option>
                                                    <option value="部长级">部长级</option>
                                                    <option value="主管级">主管级</option>
                                                    <option value="工程师">工程师</option>
                                                    <option value="班组长级">班组长级</option>
                                                    <option value="组员级">组员级</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">对应组织</label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                                <input type="hidden" class="layui-input" lay-verify="HCREATEORGID" name="HCREATEORGID" id="HCREATEORGID">
                                                <select name="HUSEORGID" id="HUSEORGID" lay-verify="HUSEORGID">
                                                    <!--动态渲染组织-->
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="width: 45%;">
                                            <label class="layui-form-label" style="width: 85px;">说明</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="Explain" id="Explain" lay-verify="Explain" placeholder="请输入内容" onmouseover="this.title=this.value">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
 
                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                </form>
            </div>
        </div>
    </div>
    <script>
 
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element', 'laydate'], function () {
 
            //#region 公共变量
 
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , element = layui.element
                , laydate = layui.laydate
            var option = [];
            //#endregion
 
            //#region 进入页面即加载
 
            //初始化
            set_ClearBill();
            Organ();
 
            var params = getUrlVars();
            var OperationType = params[params[0]]; //从参数中获取 数据类型  1添加 保存  2复制  3 编辑
            var linterid = params[params[1]]; //从参数中获取 单据内码
 
            var linterid_copy = params[params[1]];      //如果为复制操作,记录 被复制单据 的内码
 
            if (linterid == null || linterid == 0) {
                OperationType = 1;
                linterid = 0;
            } else if (OperationType == 2) {        //复制
                RoadBillMain(linterid);
                linterid = 0;
            }
            else {//如果修改则走下面
                RoadBillMain(linterid);
            }
 
            //#endregion
 
            //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
 
 
            //选择销售订单号按钮
 
            //退出
            form.on('submit(btnEdit)', function (data) {
                if (OperationType == 1 && linterid != "") {
                    Pub_Close(2);
                } else {
                    Pub_Close(1);
                }
            });
 
            //保存提交
            form.on('submit(btnSave)', function (data) {//提交
                if (AllowLoadData(data)) {
                    set_AddNew(data);
                }
            });
 
            //#endregion
 
            //#region 此页面所有的方法
 
            // 初始化界面
            function set_ClearBill() {
                set_InitGrid();
                get_Display();
            }
 
            function set_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , height: 600
                    , cellMinWidth: 90
                    , limit: 500
                    , cols: [[
                        { type: 'checkbox', fixed: 'left' }
                        , { field: 'hmainid', title: '单据ID', hide: true }
                        , { field: '用户编码', title: '用户编码' }
                        , { field: '用户名称', title: '用户名称' }
                        , { field: '对应职员', title: '对应职员' }
                        , { field: '对应保管', title: '对应保管' }
                        , { field: '对应验收', title: '对应验收' }
                        , { field: '对应业务员', title: '对应业务员' }
                        , { field: '对应部门', title: '对应部门' }
                        , { field: '对应仓库', title: '对应仓库' }
                        , { field: '对应调入仓库', title: '对应调入仓库' }
                        , { field: '对应供应商', title: '对应供应商' }
                        , { field: '对应CLOUD账号', title: '对应CLOUD账号' }
                        , { field: '对应CLOUD组织', title: '对应CLOUD组织' }
                    ]]
                }
            }
 
            //加载数据到网格
            function get_Display() {
                var wait = layer.load();//遮罩
                $.ajax({
                    url: GetWEBURL() + '/Xt_User/list',
                    type: "GET",
                    data: { "sWhere": "", user: sessionStorage["HUserName"] },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(wait);
                            get_DisplayUserGroupInfoList();
                        } else {
                            layer.close(wait);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(wait);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
 
            //加载绑定角色数据
            function get_DisplayUserGroupInfoList() {
                var sWhere = "and GroupId=" + linterid;
                var wait = layer.load();//遮罩
                $.ajax({
                    url: GetWEBURL() + '/Xt_UserGroup/UserGroupInfoList',
                    type: "GET",
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        layer.close(wait);
                        if (data1.count == 1) {
                            if (data1.data.length > 0) {
                                for (var i = 0; i < data1.data.length; i++) {
                                    for (var j = 0; j < option.data.length; j++) {
                                        if (data1.data[i].UserId == option.data[j]["用户编码"]) {
                                            option.data[j]["LAY_CHECKED"] = true;
                                            break;
                                        }
                                    }
                                }
                                table.render(option);
                            }
                        } else {
                            layer.close(wait);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(wait);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
 
            //保存HMaker
            function set_AddNew(data) {
 
                if (OperationType == 2) {
                    data.field.Explain = data.field.Explain + "#复制原角色ID:" + linterid_copy;
                }
 
                var num = [];
                for (var i = 0; i < table.checkStatus('mainTable').data.length; i++) {
                    num.push(table.checkStatus('mainTable').data[i]["用户编码"]);
                }
 
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = num.toString() == "" ? "-1" : num.toString();
                var sMainSub = sMainStr + ';' + sSubStr + ';' + OperationType + ";" + sessionStorage["HUserName"];
 
                var index = layer.load();
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "/Xt_UserGroup/UserGroupInfoEdit",
                    async: true,
                    data: { "sMainSub": sMainSub },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) {
                            $('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);
                            layer.close(index);
                            layer.msg("提交成功");
                        }
                        else {
                            layer.close(index);
                            layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        }
                    },
                    error: function (err) {
                        layer.close(index);
                        layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                });
            }
 
            //编辑 页面赋值
            function RoadBillMain(linterid)//加载表头
            {
                var sWhere = " and HGroupID=" + linterid ;
                $.ajax({
                    url: GetWEBURL() + "/Xt_UserGroup/list",
                    type: "GET",
                    async: false,
                    data: { "sWhere": sWhere},
                    success: function (d) {
                        //主表
                        form.val("formData", {
                            "HGroupID": linterid
                            , "GroupName": d.data[0].角色
                            , "HLev": d.data[0].级别
                            , "Explain": d.data[0].说明
                            , "HUSEORGID": d.data[0].HUSEORGID
                            , "HCREATEORGID": d.data[0].HCREATEORGID
                        });
                        form.render('select');
                    }
                })
            }
 
            //非空验证
            function AllowLoadData(data) {
 
                if ($("#GroupName").val() == "") {
                    layer.msg("角色名不能为空!");
                    return false;
                }
 
                return true;
            }
 
            //获取参数
            function getUrlVars() {
                var vars = [], hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                for (var i = 0; i < hashes.length; i++) {
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            }
 
 
            //获取组织
            function Organ() {
                //获取登录页组织列
                var Organization = '';
                $.ajax({
                    type: "get",
                    url: GetWEBURL() + "/Web/GetOrganizations",
                    async: false,
                    success: function (result) {
                        if (result.count == 1) { // 说明验证成功了,
                            var data = result.data;
                            for (var i = 0; i < data.length; i++) {
                                Organization += '<option  style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
                            }
                            $("#HUSEORGID").append(Organization);
                            $("#HUSEORGID").val(sessionStorage["OrganizationID"])
                            $("#HCREATEORGID").val(sessionStorage["OrganizationID"])
                            form.render('select');
                        }
                        layer.closeAll("loading");
                    }
                })
            }
 
 
            //#endregion
 
        });
 
 
    </script>
</body>
</html>