Ldc
2024-04-07 0652600959e5e3b5796fb6e8da129704ca95347a
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
/**
 * 年度生产计划页面
 * @author weidy
 * @date 2022-03-19
 */
layui.define(['layer','element','form','table','dynamicCondition' ],function(exports){
        var webUtil = $webUtil;
    var Class = function(){
        this.MODELNAME = "mes/wrj/PmYearPlan";
        this.moduleKey = "PmYearPlan";
        this.backPath =  configData.compatibility? path:configData.mesWrjService;
        this.url = {
            controller:'yearMakePlanController/',
            dataGrid:'gridPmYearPlan',
            addSave:'addSave',
            editSave:'editSave',
            deleteUrl:'deleteData',
            getObjectByOid:'getObjectByOid'
        };
        this.getContent=function(){
            var that = this;
            return '<div id="UIContent_' + that.id + '" style="overflow: auto;padding:0 5px"></div>';
        };
        this.showContent=function (){
            var that = this;
            var html = "";
            html = [
                        '<div class="layui-layout easyui-layout UIContentLayout"  id="easyuiLayout_',that.id,'" data-options="fit:true" style="display:block;overflow-y: hidden;margin:0 5px">',
                            '<div data-options="region:\'center\'" style="padding-left: 10px;padding-right: 10px;" id="border_',that.id,'">',
                                '<div class="layui-center" style="overflow-y:auto;">',
                                    that.getToolbarHtml(),
                                    '<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',
                                '</div>',
                            '</div>',
                        '</div>'
            ].join("");
            $("#UIContent_"+that.id).html(html);
        };
        this.getToolbarHtml =function(){
            var that = this;
            var html = [
                '<div layui-filter="toolbar_',that.id,'" class="layui-btn-container layui-buttons">',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_ADD"><i class="layui-icon layui-icon-add-1"></i>添加</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_ADVQUERY"><i class="layui-icon layui-icon-search"></i>查询</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_DEL"><i class="layui-icon layui-icon-delete"></i>删除</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EDIT"><i class="layui-icon layui-icon-edit"></i>修改</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
                '</div>'
            ].join("");
            return html;
        };
        this.createSearchHtml = function () {
            var that = this;
            webUtil.bindDefultButtonLisenter(that, that.id);
            webUtil.createSearchHtml({id:"编号",name:"名称"} ,$("[layui-filter='toolbar_" + that.id + "']"), "table_" + that.id);
        };
        this.defaultAttrList = [
        'actualenddate',
        'actualstartdate',
        'adjustenddate',
        'adjuststartdate',
        'bodydelivertime',
        'currentpercent',
        'pdmmodel',
        'plandelivertime',
        'planstartdate',
        'pmplaneplan',
        'pmplaneplanname',
        'pmsaleplantarget',
        'pmsaleplantargetname',
        'targetusetype',
        'vcsno',
            'id',
            'name',
            'description',
            'oid',
            'nameoid',
            'revisionoid',
            'btmname',
            'islastr',
            'isfirstr',
            'islastv',
            'isfirstv',
            'creator',
            'createtime',
            'lastmodifier',
            'lastmodifytime',
            'revisionrule',
            'revisionseq',
            'revisionvalue',
            'versionrule',
            'versionseq',
            'versionvalue',
            'lctid',
            'lcstatus',
            'ts',
            'owner',
            'checkinby',
            'checkintime',
            'checkoutby',
            'checkouttime',
            'copyfromversion',
            'secretgrade'
        ];
        this.init = function(){
            var that = this;
            webUtil.copyConfig(that,that.moduleKey);
            //需要加在定时中,否则样式不能正确展示,不知道原因 wangting
            setTimeout(function (){
                that.showContent();
                var easyuiLayout= $('#easyuiLayout_'+that.id)
                easyuiLayout.css({height:$('#portal_body').height()-43,width:$('#portal_body').width()-15})
                easyuiLayout.layout();
 
                that.initMainTable();
                that.createSearchHtml();
 
            },1)
        };
        this.initMainTable = function (parentFieldName) {
            var that = this;
            var table = layui.table;
            that.checkColumns();
            var tableWidth = $("#border_" + that.id).width();
            var options = {
                elem: '#table_' + that.id,
                id: 'table_' + that.id,
                backPath:that.backPath,
                url: that.url.controller + that.url.dataGrid,
                page: {
                    limit: 20,
                    page: 1
                },
                width:tableWidth,
                selectMode:table.selectMode.muti,
                cols: [that.columns],
                method:'get',
                done:function(res,cur,total){
                    if(!that.fristMainLoad ){
                        table.on('tool(' + that.id + ')',function(obj){
                            var data = obj.data;//当前选择行的数据
                            var layEvent = obj.event;//点的是什么按钮
                            if(layEvent == 'EDIT'){
                                that.addOrEdit(false,data.oid);
                            }
                        });
                    }else{
                        if(total>0) {
                            table.selectRecord('table_' + that.id, {index:0});
                        }
                    }
                    that.fristMainLoad = true;
                }
            };
            if(parentFieldName){
                options.treeConfig = {
                    treepid:parentFieldName,
                    treeid:'id',
                    showField:'name'
                };
            }
            table.render(options);
        };
        this.checkColumns = function(){
            var that = this;
            var table = layui.table;
            if(that.columns==null || that.columns.length==0){
                that.columns = [table.getIndexColumn(),table.getCheckColumn(),
                    {
                        title: '实际结束时间',
                        field: 'actualenddate',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.actualenddate);
                        }
                    },
                    {
                        title: '实际开始时间',
                        field: 'actualstartdate',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.actualstartdate);
                        }
                    },
                    {
                        title: '调整结束时间',
                        field: 'adjustenddate',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.adjustenddate);
                        }
                    },
                    {
                        title: '调整后开始时间',
                        field: 'adjuststartdate',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.adjuststartdate);
                        }
                    },
                    {
                        title: 'bodyDeliverTime',
                        field: 'bodydelivertime',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.bodydelivertime);
                        }
                    },
                    {
                        title: '当前进度',
                        field: 'currentpercent',
                        type:'number',
                        width: 100
                    },
                    {
                        title: '机型',
                        field: 'pdmmodelName',
                        sort:true,
                        sortField:'pdmmodel',
                        type:'refer',
                        referConfig: {
                            type:'default',
                            referBo:'workcontext'
                        },
                        width: 150
                    },
                    {
                        title: '交付节点',
                        field: 'plandelivertime',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.plandelivertime);
                        }
                    },
                    {
                        title: '计划开始时间',
                        field: 'planstartdate',
                        width: 130,
                        type:'datetime',
                        templet: function (d) {
                            return webUtil.formateDateTimeNoSecond(d.planstartdate);
                        }
                    },
                    {
                        title: '机体计划',
                        field: 'pmplaneplanName',
                        sort:true,
                        sortField:'pmplaneplan',
                        type:'refer',
                        referConfig: {
                            type:'default',
                            referBo:'pmplaneplan'
                        },
                        width: 150
                    },
                    {
                        title: 'pmPlanePlanName',
                        field: 'pmplaneplanname',
                        sort:true,
                        width: 150
                    },
                    {
                        title: '科研生产项目主键',
                        field: 'pmsaleplantarget',
                        sort:true,
                        width: 150
                    },
                    {
                        title: '科研生产项目编号',
                        field: 'pmsaleplantargetname',
                        sort:true,
                        width: 150
                    },
                    {
                        title: '用途类型',
                        field: 'targetusetypeText',
                        sort:true,
                        sortField:'targetusetype',
                        type:'combox',
                        comboxKey:"saleTargetUseType",
                        width: 150
                    },
                    {
                        title: '风投号',
                        field: 'vcsno',
                        sort:true,
                        width: 150
                    },
                    {
                        field:'options',
                        title:'操作',
                        width:150,
                        templet:function(d){
                            return '<a class="layui-btn layui-btn-intable" lay-event="EDIT">编辑</a>';
                        }
                    }];
            }
        };
 
        this.getFormItems = function(onlyShow) {
            var that = this;
            var table = layui.table;
            return [
                {
                    field: 'actualenddate',
                    title: '实际结束时间',
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'actualstartdate',
                    title: '实际开始时间',
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'adjustenddate',
                    title: '调整结束时间',
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'adjuststartdate',
                    title: '调整后开始时间',
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'bodydelivertime',
                    title: 'bodyDeliverTime',
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'currentpercent',
                    title: '当前进度',
                    verify: 'number',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'pdmmodel',
                    title: '机型',
                    required: true,
                    type: 'refer',
                    showField: 'pdmmodelName',
                    referConfig: {
                        type:'default',
                        referBo:'workcontext'
                    },
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'plandelivertime',
                    title: '交付节点',
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'planstartdate',
                    title: '计划开始时间',
                    required: true,
                    type: 'datetime',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'pmplaneplan',
                    title: '机体计划',
                    required: true,
                    type: 'refer',
                    showField: 'pmplaneplanName',
                    referConfig: {
                        type:'default',
                        referBo:'pmplaneplan'
                    },
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'pmplaneplanname',
                    title: 'pmPlanePlanName',
                    type: 'text',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'pmsaleplantarget',
                    title: '科研生产项目主键',
                    required: true,
                    type: 'text',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'pmsaleplantargetname',
                    title: '科研生产项目编号',
                    type: 'text',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'targetusetype',
                    title: '用途类型',
                    type: 'combox',
                    comboxKey: 'saleTargetUseType',
                    defaultValue:"",
                    readOnly:onlyShow
                } ,                {
                    field: 'vcsno',
                    title: '风投号',
                    type: 'text',
                    defaultValue:"",
                    readOnly:onlyShow
                }             ];
        };
        this.ADD = function () {
            var that = this;
            that.addOrEdit(true);
        };
        this.EDIT = function(){
            var that = this;
            var oid = webUtil.getOidFromGrid("table_" + that.id,true,true);
            if(!oid){
                return false;
            }
            that.addOrEdit(false,oid);
        };
        this.addOrEdit = function(add,oid) {
            var that = this;
            var form = layui.form;
            var filter ="form_" + that.id;
            var addSaveIndex =webUtil.dialog({
                title:add?'添加年度生产计划':'修改年度生产计划',
                btn:['保存','取消'],
                content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                resizing:function(layero){
                    form.doResize(filter);
                },
                success:function(layero) {
                    form.addItems(filter,that.getFormItems(false),
                        function () {
                            if(!add){
                                form.load(filter,{
                                    backPath:that.backPath,
                                    url:that.url.controller + that.url.getObjectByOid,
                                    method:'get',
                                    params:{
                                        oid:oid
                                    }
                                });
                            }else{
                                var defaultValues = {};
                                //可以手动在此处添加默认值
                                form.setValues(defaultValues,filter);
                            }
                        }, {}, {defaultColumnOneRow: 2});
                },
                yes:function(layero){
                    if(form.validata(filter)){
                        var values = form.getValues(filter,true);
                        var url = that.url.controller + (add?that.url.addSave:that.url.editSave);
                        webUtil.manualAjax(add?'post':'put',url,JSON.stringify(values),function(result){
                            if(result.success){
                                webUtil.showMsgFromResult(result,(add ? "添加成功" : "修改成功"));
                                layer.close(addSaveIndex);
                                that.refresh();
                            }else{
                                webUtil.showErrorMsg(result.msg);
                            }
                        },function(xhr,err){
                            webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
                        },that.backPath);
                    }
                },
                btn2:function(layero){
                    layer.close(addSaveIndex);
                }
            });
        };
        this.DEL = function(){
            var that = this;
            var oid = webUtil.getOidFromGrid("table_" +that.id,true,true);
            if(!oid){
                return false;
            }
            var ts= webUtil.getOidFromGrid("table_" +that.id,false,false,"ts");
            webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!",function () {
                webUtil.deleteRequest(that.url.controller + that.url.deleteUrl,{oid:oid,ts:ts},function(result){
                    if(result.success){
                        webUtil.showMsgFromResult(result,"删除成功");
                        that.refresh();
                    }else{
                        webUtil.showErrorMsg(result.msg);
                    }
                },function(xhr,err){
                    webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
                },that.backPath);
            });
        };
        this.refresh = function () {
            var that = this;
            layui.table.reload("table_" + that.id);
        };
        this.ADVQUERY = function () {
            var that = this;
            if(!that.serinorQueryInstance) {
                var dynamicCondition = layui.dynamicCondition;
                $('[layui-filter="toolbar_' + that.id + '"]').append('<div  id="toolbar' + that.id + '" class="layui-inline"></div>');
                that.checkColumns();
                var dataFields = [];
                for(var i = 0 ; i < that.columns.length ; i ++){
                    dataFields[i] = that.columns[i];
                }
                that.serinorQueryInstance = dynamicCondition.create({
                    fields: dataFields//查询字段
                    , tableId: "table_" + that.id//需要查询的表格
                    , type: "complex"  //type:"simple"/"complex"  查询的方法  暂时写死为 complex
                    , queryCallBack: function (requestData) {//查询之后的callback
 
                    }
                });
            }
            that.serinorQueryInstance.open();
        };
    };
    var cs = new Class();
    exports(cs.MODELNAME,cs);
});