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
<!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 id="layout1" class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <form id="form" class="layui-form" lay-filter="component-form-group" action="">
                        <div class="layui-card-header">
                            <div class="layui-btn-group">
 
                                <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                                <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
 
                            </div>
 
                        </div>
                        <div class="layui-card-body">
                            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                             
                                <h1 style="text-align:center;"><b>任务类别</b></h1>
                                <div class="layui-tab-content">
                                    <div class="layui-tab-item layui-show">
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 120px">代码:</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="HNumber" lay-verify="HNumber" id="HNumber" autocomplete="off" >
                                                    <input name="HItemID" id="HItemID" autocomplete="off" type="hidden">
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 120px">名称:</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="HName" id="HName" autocomplete="off">
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 120px">助记码:</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="HHelpCode" id="HHelpCode" autocomplete="off">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label" style="width: 120px">使用组织:</label>
                                            <div class="layui-input-inline">
                                                <select name="HUSEORGID" id="HUSEORGID" lay-verify="HUSEORGID">
                                                </select>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 120px">使用状态:</label>
                                                <div class="layui-input-inline">
                                                    <select name="HUseFlag" id="HUseFlag" lay-verify="HUseFlag">
                                                        <option value="未检测" selected>未检测</option>
                                                        <option value="未使用">未使用</option>
                                                        <option value="已使用">已使用</option>
                                                    </select>
                                                </div>
                                            </div>
                                           
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 120px"> 禁用标志:</label>
                                                <div class="layui-input-inline">
                                                    <input type="checkbox" name="HStopflag" id="HStopflag" lay-skin="primary" title="" value="">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-col-xs11">
                                                <label class="layui-form-label"> 备注:</label>
                                                <div class="layui-input-block">
                                                    <input class="layui-input" name="HRemark" id="HRemark" autocomplete="off">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
 
    <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>
    <script>
        //获取参数
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
        } else {
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSouceBillType = params[params[2]];//源单类型
        }
 
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
            //#region 公共变量
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
            //#endregion
            //#region 进入页面即加载
 
            //初始化界面
            set_ClearBill();
            //判断操作类型
            if (OperationType == 1) {//无源单
                set_AddFNew();
 
              
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid();
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
 
            //#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
            //保存
            form.on('submit(Saver)', function (data) {//保存
 
                var isEndCheck = document.getElementById("HStopflag").checked;
                isEndCheck == true ? data.field.HStopflag = 'true' : data.field.HStopflag = 'false';//将数组合并成字符串
 
                var sMainStr = JSON.stringify(data.field) + ";" + sessionStorage["HUserName"];
                $.ajax(
                    {
                        type: "POST",
                        url: GetWEBURL() + "SaveGy_TaskClassList", //方法所在页面和方法名
                        async: true,
                        data: { "msg": sMainStr },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1) { // 说明验证成功了,
                                layer.msg(data.Message, { icon: 1 });
                                $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                            }
                            else {
                                f_alert(data.Message);
                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
 
                            f_alert("错误:" + err);
                            console.log("Reason" + sMainStr);
                        }
                    });
            });
            //退出
            form.on('submit(Exit)', function (data) {//
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
           
            //监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
                    }
                    //}
                }
            });
            //#endregion
 
 
            //#region 当前页面面所有的方法
 
            //初始化界面
            function set_ClearBill() {
                Organ();
            }
            //无源单新增
            function set_AddFNew() {
                $("#HItemID").val("0");
              
            }
            //编辑
            function set_EditFromGrid() {
                $("#HItemID").val(linterid);
                set_EditForm(linterid);  //编辑获取表头
            }
            //编辑加载表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "GetGy_TaskClassDetail",
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
                        if (result.code == 1) { // 说明验证成功了,
                            var data = result.data.h_v_Gy_TaskClass[0];
                            $("#HItemID").val(data.HItemID);//代码ID
                            $("#HNumber").val(data.任务类别代码);//代码
                            $("#HName").val(data.任务类别名称);//名称
                            $("#HEnglishName").val(data.英文名称);//助记码
                            $("#HHelpCode").val(data.助记码);//助记码
                            $("#HUSEORGID").val(data.创建组织);//使用组织
                            $("#HUseFlag ").val(data.使用状态);//使用状态
                            $("#HRemark").val(data.备注);//备注
                            $("input[name='HStopflag']").attr("checked", data.禁用标志 == "是" ? true : false);//true:选中 false:不选中
                            layui.form.render();//实时渲染选中和不选中的样式,最好添加这句话
 
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            
            //
            function f_alert(sMsg) {
                layer.alert(sMsg, { icon: 5 });
 
            }
             //获取登录页组织列
            function Organ() {
                var Organization = '';
                $.ajax({
                    type: "get",
                    url: GetWEBURL() + "/Web/GetOrganizations",
                    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"])
                            form.render('select');
                        }
                        layer.closeAll("loading");
                    }
                })
            }
            //#endregion
        });
 
    </script>
</body>
</html>