Blame view

web/WebMvc/wwwroot/productjs/equipment/BaseEquipment.js 11.9 KB
HuXiYu authored
1
2
3
4
5
6
7
8
9
10
11
12
13
let action = null;
layui.config({
    base: "/js/",
    version: 1
}).use(['system'], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        areaName = "equipment",
        controllerName = "BaseEquipment",
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        app = null,
        selectMaintainRuleOpt = {
            selectMaintainRule: {
                SelType: "FromUrl",
                SelFrom: `/${areaName}/BusEquipmentMaintainRuleHead/Load`,
                SelLabel: "equipmentRuleName",
                SelValue: "equipmentRuleCode",
                Where: {},
                Dom: [$("#modifyForm [name='equipmentMaintainRuleCode']")],
            },
            selectData: {

            },
        },
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        selectFactoryOpt = {
            factoryCode: {
                SelType: "FromUrl",
                SelFrom: `/configure/Factory/Load`,
                SelLabel: "factoryName",
                SelValue: "factoryCode",
                Where: {},
                Dom: [$("[name='factoryCode']")],
               /* isFirstSelected: false*/
            },
            selectData: {

            },
        },
42
        sendData = {
43
44
            editMaintainRuleWhere: null,
            selectFactorySelectWhere: null
45
46
        };
HuXiYu authored
47
48

    action = {
HuXiYu authored
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
        addOptions: function () {
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${controllerName}/Ins`,
                //sendDataWhere: null,
                //isAddWhereExtend: "arbitrarily",
                //mainTable: app.data.tableIns,
                submit: "submit(fromAdd)"
            }
            return options;
        },

        editOptions: function () {
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${controllerName}/Upd`,
                submit: "submit(fromUpdate)"
            }
            return options;
        },

        deleteOptions: function () {
            var options = {
                url: `/${areaName}/${controllerName}/DelByIds`,
                keyId: "id"
            }
            return options;
        },
HuXiYu authored
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
        exportOptions: function () {
            var options = {
                fromId: "listForm",
                url: `/${areaName}/${controllerName}/Export`,
                isDefault: false,
                sendDataWhere: {},
                excelCols: {
                    head: app.data.cols,
                    body: app.data.colsDesc
                }
            }
            return options;
        },

        queryOptions: function () {
            var options = {
                resetFrom: "form[lay-filter=listForm]",
                fromId: "listForm",
                urlExport: `/${areaName}/${controllerName}/Export`,
                urlQuery: `/${areaName}/${controllerName}/Load`,
                sendDataWhere: {},
                mainTable: app.data.tableIns
            }
            return options;
        },
        /*rowClickOptions: function () {
            var options = {
                //是否主子表
                isDefault: true,
                targetTableId: app.data.tableElem,
                tabfilter: "tableTabBody",
                tabId: 2,
                customFn: app.methods.initTableDesc
            }
            return options;
        },*/

        uploadOptions: function () {
            var options = {
                url: `/${areaName}/${controllerName}/Import`,
                fromFile: "#excelfile",
                content: $("#ImportData")
            }
            return options;
        },
HuXiYu authored
123
        addBefore: function (callBack) {
124
            sendData.editMaintainRuleWhere = null;
125
126
127
128

            selectMaintainRuleOpt.selectMaintainRule.Dom[0].empty();
            selectFactoryOpt.factoryCode.Dom[0].empty();
            form.render("select");
HuXiYu authored
129
130
131
132
133
134
135
136
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },

        addSaveBefore: function (data, callBack) {
            if (callBack != null) callBack();
        },
        editBefore: function (data, callBack) {
137
138
139
140
141
142
143
            sendData.editMaintainRuleWhere = data;
            selectMaintainRuleOpt.selectMaintainRule.Where["equipmentTypeCode"] = data.equipmentTypeCode;
            var fn = () => {
                callBack();
                form.val("modifyForm", data);
            }
            sysU.initSelect(selectMaintainRuleOpt, fn);
144
145
146
147
148
            selectFactoryOpt.factoryCode.Where["factorySelectWhere"] = data.projectKeys;
            sysU.initSelect(selectFactoryOpt, () => {
                form.val("modifyForm", data);
            });
HuXiYu authored
149
150
        },
        editSaveBefore: function (data, callBack) {
151
            if (typeof data.field.isEnable == "undefined") data.field["isEnable"] = 0;
HuXiYu authored
152
153
            if (callBack != null) callBack();
        },
HuXiYu authored
154
155
156

        checkboxMethod: function (obj) {
            var page = "".GetUrlParam("page"),
HuXiYu authored
157
158
                simNumber = "".GetUrlParam("simNumber");
            if (page == "BaseSim") {
HuXiYu authored
159
                var sendData = {
HuXiYu authored
160
161
162
163
                    simNumber: simNumber,
                    checkeds: obj.checked,
                    equipmentCode: obj.data.equipmentCode,
                    factoryCode: obj.data.factoryCode
HuXiYu authored
164
165
166
                };
                var ajaxConfig = {
                    data: sendData,
HuXiYu authored
167
                    url: "/base/BaseSim/BindEquipment",
HuXiYu authored
168
169
170
                    success: function (result) {
                        if (sysU.successBefore(result)) return false;
                        layer.msg(result.Message);
HuXiYu authored
171
                        sysU.refreshTable(app, sysU, null, "main");
HuXiYu authored
172
173
174
175
176
                    }
                };
                sysU.ajax(ajaxConfig);
            }
        },
HuXiYu authored
177
178
179
180
181
182
183
184
185
186
187
        //所有动作成功之后
        actionSuccess: (flag) => {
            sysU.refreshTable(app, sysU, null, flag);
        },
        closeAfter: function (callBack) {
            if (callBack != null) callBack();
        },

        //设备类型加载保养规则
        equipmentTypeCodeFromEvent: function (data) {
HuXiYu authored
188
189
190
191
192
193
            if (data.value == "") {
                selectMaintainRuleOpt.selectMaintainRule.Dom[0].empty();
                form.render("select");
                return false;
            }
            //对应到实体(筛选条件)中字段属性
赖素文 authored
194
            selectMaintainRuleOpt.selectMaintainRule.Where["equipmentTypeCode"] = data.value;
195
            sysU.initSelect(selectMaintainRuleOpt);
HuXiYu authored
196
197
        },
198
199
200
        //所属项目加载项目厂房
        projectKeysFromEvent: function (data) {
            if (data.value == "") {
201
                selectFactoryOpt.factoryCode.Dom[0].empty();
202
203
204
205
                form.render("select");
                return false;
            }
            //对应到实体(筛选条件)中字段属性
206
207
            selectFactoryOpt.factoryCode.Where["factorySelectWhere"] = data.value;
            sysU.initSelect(selectFactoryOpt);
HuXiYu authored
208
        },
209
        EqDescTableRowEvent: function (sU, toolbarId, obj) {
210
211
            window.open("/equipment/BaseEquipment/ProjectMapEqDescIndex","_self");
        },
212
213
214
215
216
217
218
        EqeqmaintainTableRowEvent: function (sU, toolbarId, obj) {
            window.open("/equipment/BaseEquipment/ProjectMapEqDescIndex", "_self");
        },
        //关联设备链接 
        btnBindEquipment: function (sU, toolbarId, obj) {
            sU.getParentElemId("BaseSim").click();
        },
HuXiYu authored
219
220
221
222
223
224
    }

    app = {
        data: {
            cols: [[
                { field: "id", width: 80, hide: true, title: "Id" },
225
                { field: "projectKeys", width: 150, title: "项目keys", hide: true, },
HuXiYu authored
226
227
                { field: "projectName", width: 150, title: "项目" },
                /*{ field: "factoryCode", width: 150, title: "厂房编码" },*/
HuXiYu authored
228
229
                { field: "equipmentCode", width: 120, title: "设备编码"},
HuXiYu authored
230
                { field: "equipmentName", width: 150, title: "设备名称" },
231
                { field: "equipmentTypeCode", width: 150, title: "设备类型编码", hide: true },
232
                { field: "name", width: 120, title: "设备类型" },
HuXiYu authored
233
                { field: "equipmentMaintainRuleCode", width: 150, title: "维护规则" },
234
235
                { field: "equipmentStatus", width: 150, title: "状态" },
HuXiYu authored
236
                { field: "simNumber", width: 150, title: "SIM卡号" },
HuXiYu authored
237
                { field: "startTime", width: 150, title: "出厂时间" },
HuXiYu authored
238
HuXiYu authored
239
                { field: "imgSrc", width: 150, title: "图片" },
240
241
242
243
                { field: "ip", width: 150, title: "IP", hide: true, },
                { field: "destinationArea", width: 150, title: "区域", hide: true,},
                { field: "remark", width: 150, title: "描述", hide: true, },
                { field: "isEnable", width: 100, title: "启用", templet: '#isSysEnableTemplet' },
HuXiYu authored
244
HuXiYu authored
245
246
                { field: "createTime", width: 150, title: "createTime" },
                { field: "createBy", width: 150, title: "createBy" },
247
248
249

                { field: "updateTime", width: 150, title: "updateTime", hide: true, },
                { field: "updateBy", width: 150, title: "updateBy", hide: true, },
HuXiYu authored
250
251
252
253
254
255
256
257
258
            ]],
            colsDesc: null,
            tableIns: null,
            tableElem: "mainList",
            tableInsDesc: null,
            tableElemDesc: "mainListDesc",

            //下拉框配置
            selectOption: {
HuXiYu authored
259
260
261
262
263
264
                selectEquipmentTypeCode: {
                    SelType: "FromUrl",
                    SelFrom: `/${areaName}/BaseEquipmentType/Load`,
                    //SelModel:"EquipmentTypeName",
                    SelLabel: "name",
                    SelValue: "code",
265
266
                    Dom: [$("[name='equipmentTypeCode']")],
                    isFirstSelected: false
HuXiYu authored
267
                },
HuXiYu authored
268
269
270
271
                projectKeys: {
                    SelType: "FromUrl",
                    SelFrom: `/configure/BaseProject/Load`,
                    SelLabel: "projectName",
272
273
274
                    SelValue: "keys",
                    Dom: [$("[name='projectKeys']")],
                    isFirstSelected: false
HuXiYu authored
275
                },
HuXiYu authored
276
277
278
279
280
281
282
283
284
285
                //返回的数据 用于后续操作
                selectData: {

                }
            },
        },
        methods: {
            initTable: function (opt) {
                var config = {};
                if (opt != undefined) $.extend(config, opt);
286
287
288
289
290
291
292
293
                //项目地图跳转过来的
                var flag = $(".layui-breadcrumb");
                if (flag.length >0) {
                    config["projectKeys"] = localStorage.getItem("projectMapKeys");
                    app.data.cols[0].push({ fixed: 'right', title: '操作', width: 150, toolbar: '#barDemo' });
                } else {
                    app.data.cols[0].unshift({ checkbox: true, fixed: true });
                }
HuXiYu authored
294
295
296
297
298
299
300
301
302
303
304
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${controllerName}/Load`,
                    cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
                    toolbar: '#toolbarTable',
                    where: config,
                    //height: "full-56",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
                    doneExtend: function (res, obj) {

                    }
                }
305
赖素文 authored
306
307
308
                if (flag.length > 0) {
                    options["height"] = "full-25"
                }
HuXiYu authored
309
310
311
312
313
                app.data.tableIns = sysU.initTable(options);
            },


            initFrom() {
HuXiYu authored
314
                sysU.initSelect(app.data.selectOption);
HuXiYu authored
315
316
317
318
319
320
321
322

                //sysU.initSelecteByEnum(app.data.selectOptionEnum);
            }
        },
        registerEvent: function () {

        },
        init: function () {
323
            debugger
HuXiYu authored
324
325
326
327
328
329
330
331
            //var sendDataWhere = form.val("listForm")
            app.methods.initTable();
            app.methods.initFrom();
            app.registerEvent();
        }
    };
    app.init();
});