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
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
| /**
| * 供应商基本信息页面
| * @author renky
| * @date 2020-08-17
| */
| layui.define(['layer','element','form','table','dynamicCondition','upload' ,'tree'],function(exports){
| var webUtil = $webUtil;
| var Class = function(){
| this.MODELNAME = "platform/basedoc/BdSupplier";
| this.moduleKey = "BdSupplier";
| this.backPath = configData.compatibility?path:configData.frameworkPath;
| this.url = {
| controller:'supplierController/',
| dataGrid:'getDataGridSupplier',
| tree:'supplierClassifyController/referTreeSupplierClassify',
| addSave:'insert',
| editSave:'update',
| delSvae:'delete',
| checkIsCanDelete:'checkIsCanDelete',
| referTree:'referTree' ,
| deleteUrl:'delete',
| enableData: 'enable',
| disableData: 'disable',
| downloadImportTemplate:'downloadImportTemplate',
| importData : 'importData',
| exportData : 'exportData',
| getObjectByOid:'getByOid'
| };
| this.getContent=function(){
| var that = this;
| var html = "";
| html = [
| '<div class="layui-layout" style="display:block;overflow-y: hidden">',
| that.getWestToolbarHtml(),
| '<div class="layui-vci-tree" style="width:250px;float: left;background-color:#ffffff;overflow-y: auto;">',
| '<label class="layui-icon layui-icon-tree" style="line-height: 20px;color:red;font-size:20px;">供应商基本信息</label>',
| '<ul layui-filter="tree_',that.id,'"><ul>',
| '</div>',
| '<div class="layui-layout-border" style="display:block;margin-top:0px; margin-left:255px;" 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 id="toolbar_column_',that.id ,'" style="display:none;"></div>',
| '</div>',
| '</div>',
| '</div>'
| ].join("");
| return html;
| };
| this.getWestToolbarHtml = function(){
| var that = this;
| var html = [
| '<div layui-filter="toolbar_west_',that.id,'" class="layui-btn-container layui-buttons">',
| '</div>'
| ].join("");
| return html;
| };
| this.createWestSearchHtml = function () {
| var that = this;
| };
| 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,'_EDIT"><i class="layui-icon layui-icon-edit"></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,'_ENABLE"><i class="layui-icon layui-icon-ok-circle"></i>启用</button>',
| '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_DISABLE"><i class="layui-icon layui-icon-404"></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,'_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.init = function(){
| var that = this;
| webUtil.copyConfig(that,that.moduleKey);
| that.initTree();
| that.initMainTable();
| that.createSearchHtml();
| that.advancedQuery();
| };
| this.initTree = function () {
| var that = this;
| var tree = layui.tree;
| var scrollHeight = window.innerHeight;
| var treeUL = $('[layui-filter="tree_' + that.id + '"]');
| var treeHeight = scrollHeight - 200;
| treeUL.parent().height(treeHeight);
| tree.init("tree_" + that.id, treeUL, {
| url: /*that.url.controller +*/ that.url.tree,
| backPath: that.backPath,
| extraParams: {
| isMuti: false,
| isQueryAllColumn: true
| },
| showSearch:true,
| click: function (item, elem, options) {
| that.currentItemOid = item.oid;
| that.currentItemAttributes = item.attributes;
| layui.table.reload('table_' + that.id,{
| extraParams:{parentSupplier:that.currentItemAttributes.oid}
| });
| }
| });
| };
| this.initMainTable = function (parentFieldName) {
| var that = this;
| var table = layui.table;
| that.checkColumns();
| var tableWidth = $("#border_" + that.id).width()-225;
| 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],
| 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);
| document.getElementById("toolbar_column_" + that.id).innerHTML =
| '<a class="layui-btn layui-btn-intable" lay-event="EDIT">编辑</a>';
| };
| 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: 'id',
| width: 150
| },{
| title: '名称',
| field: 'name',
| width: 150
| },{
| title: '供应商基本分类',
| field: 'pkSupplierClassifyText',
| width: 150
| },{
| title: '供应商类型',
| field: 'supplierTypeText',
| width: 150
| },{
| title: '供应商准入状态',
| field: 'pkSupplierAdmittanceText',
| width: 150
| },{
| title: '地区分类',
| field: 'pkAreaClassifyText',
| width: 150
| },{
| title: '联系地址',
| field: 'address',
| width: 150
| },{
| title: '主要联系人',
| field: 'contactor',
| width: 150
| },{
| title: '主要联系方式',
| field: 'contacts',
| width: 150
| },{
| title: '网址',
| field: 'web',
| width: 150
| },{
| title: '电子信箱',
| field: 'email',
| width: 150
| },{
| title: '法人',
| field: 'legal',
| width: 60
| },{
| title: '税类',
| field: 'tax',
| width: 90
| },{
| title: '传真',
| field: 'fax',
| width: 100
| },{
| title: '注册资金',
| field: 'registermoney',
| width: 90
| },{
| title: '纳税人登记号',
| field: 'taxcode',
| width: 100
| },{
| title: '最新评分总分',
| field: 'rateInfo',
| width: 100
| },{
| title: '供应商品信息',
| field: 'supplierMateriel',
| width: 150
| },{
| title: '所属行业',
| field: 'trade',
| width: 150
| },{
| title: '加工能力描述',
| field: 'workingAbility',
| width: 150
| },{
| title: '描述',
| field: 'description',
| width: 150
| },{
| title: '状态',
| field: 'lcStatusText',
| width: 70
| },{
| title: '密级',
| field: 'secretGradeText',
| width: 60
| }];
| }
| };
|
| this.setFormValues = function () {
| var that = this;
| layui.form.setValues({parentSupplier:that.currentItemAttributes.oid},"form_" + that.id);
| };
| this.getFormItems = function(onlyShow) {
| var that = this;
| var table = layui.table;
| return [
| {
| field: 'id',
| title: '编号',
| required: true,
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'name',
| title: '名称',
| required: true,
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'pkSupplierClassify',
| title: '供应商基本分类',
| required: true,
| type: 'refer',
| showField: 'pkSupplierClassifyText',
| referConfig: {
| textField: 'name',
| valueField: 'oid',
| backPath: that.backPath,//注意这里需要修改参照的对应路径
| isMuti: false,
| type: 'tree',
| url: that.url.tree
| },
| readOnly:onlyShow
| } , {
| field: 'supplierType',
| title: '供应商类型',
| required: true,
| type: 'combox',
| comboxKey: 'supplierType',
| defaultValue:'supplier',
| readOnly:onlyShow
| } , {
| field: 'pkSupplierAdmittance',
| title: '供应商准入状态',
| type: 'refer',
| showField: 'pkSupplierAdmittanceText',
| required: true,
| referConfig: {
| textField: 'name',
| valueField: 'oid',
| backPath: that.backPath,//注意这里需要修改参照的对应路径
| isMuti: false,
| type: 'tree',
| url: 'supplierAdmittanceController/referTreeSupplierAdmittance'
| },
| readOnly:onlyShow
| } , {
| field: 'pkSupplierImporttance',
| title: '供应商重要度',
| type: 'refer',
| required: true,
| showField: 'pkSupplierImporttanceText',
| referConfig: {
| textField: 'name',
| valueField: 'oid',
| backPath: that.backPath,//注意这里需要修改参照的对应路径
| isMuti: false,
| type: 'tree',
| url: 'supplierImporttanceController/referTreeImportance'
| },
| readOnly:onlyShow
| } , {
| field: 'pkAreaClassify',
| title: '地区分类',
| type: 'refer',
| showField: 'pkAreaClassifyText',
| referConfig: {
| textField: 'name',
| valueField: 'oid',
| backPath: that.backPath,//注意这里需要修改参照的对应路径
| isMuti: false,
| type: 'tree',
| url: 'areaClassifyController/referTreeAreaClassify'
| },
| readOnly:onlyShow
| }
| // , {
| // field: 'parentSupplier',
| // title: '上级供应商',
| // type: 'refer',
| // showField: 'parentSupplierText',
| // referConfig: {
| // textField: 'name',
| // valueField: 'oid',
| // backPath: that.backPath,//注意这里需要修改参照的对应路径
| // isMuti: false,
| // type: 'tree',
| // url: ''
| // },
| // readOnly:onlyShow
| // }
| , {
| field: 'address',
| title: '联系地址',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'contactor',
| title: '主要联系人',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'contacts',
| title: '主要联系方式',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'web',
| title: '网址',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'email',
| title: '电子信箱',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'legal',
| title: '法人',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'tax',
| title: '税类',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'fax',
| title: '传真',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'registermoney',
| title: '注册资金',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'taxcode',
| title: '纳税人登记号',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'supplierMateriel',
| title: '供应商品信息',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'trade',
| title: '所属行业',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'workingAbility',
| title: '加工能力描述',
| type: 'text',
| readOnly:onlyShow
| } , {
| field: 'description',
| title: '描述',
| type: 'text',
| readOnly:onlyShow
| }];
| };
| this.ADD = function () {
| var that = this;
| that.addOrEdit(true);
| };
| this.EDIT = function(){
| var that = this;
| var selectData = layui.table.checkStatus("table_" + that.id).data[0];
| if(selectData == undefined){
| webUtil.showErrorMsg("请先选择一条数据!");
| return false;
| }
| that.addOrEdit(false,selectData);
| };
| this.addOrEdit = function(add,selectData) {
| var that = this;
| var form = layui.form;
| var filter ="form_" + that.id;
| var addSaveIndex =webUtil.dialog({
| title:add?'添加供应商基本信息':'修改供应商基本信息',
| btn:['保存','取消'],
| skin:'layui-layer-lan',
| content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
| fullScreen:true,
| resizing:function(layero){
| form.doResize(filter);
| },
| success:function(layero) {
| form.addItems(filter,that.getFormItems(false),
| function () {
| if(!add){
| form.setValues(selectData,filter);
|
| }else{
| var defaultValues = {};
| defaultValues["parentSupplier"] = that.currentItemOid;
| defaultValues["parentSupplier" + "Name"] = that.currentItemAttributes.name;
| //可以手动在此处添加默认值
| form.setValues(defaultValues,filter);
| }
| }, {}, {defaultColumnOneRow: 3});
| },
| yes:function(layero){
| if(form.validata(filter)){
| var values = form.getValues(filter,true);
| values['secretGrade'] = "10"; // 密级
| values.pkSupplierClassifyName = values.pkSupplierClassifyText
| values.pkSupplierAdmittanceName = values.pkSupplierAdmittanceText
| values.pkSupplierImporttanceName = values.pkSupplierImporttanceText
| values.pkAreaClassifyName = values.pkAreaClassifyText
| values.parentSupplierName = values.parentSupplierText
| // return false
| var url = that.url.controller + (add?that.url.addSave:that.url.editSave);
| webUtil.ajax(add?'post':'put',url,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 selectData = layui.table.checkStatus("table_" + that.id).data[0];
| if(selectData == undefined){
| webUtil.showErrorMsg("请先选择一条数据!");
| return false;
| }
| webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!",function () {
| var submitValue = {oid:selectData.oid,ts:selectData.ts};
| webUtil.deleteRequest(that.url.controller + that.url.delSvae,submitValue,function(result){
| if(result.success) {
| if ('true' == result.obj || true == result.obj) {
| webUtil.showConfirmMsg("当前数据包含有下级数据,要删除的话会和下级数据一起删除,你确认继续?", function () {
| that.doDelete(submitValue);
| });
| } else {
| //说明可以删除
| that.doDelete(submitValue);
| }
| }else {
| webUtil.showErrorMsg(result.msg);
| }
| },function (xhr,error) {
| webUtil.showErrorMsg("校验删除出现了错误,可能是服务器未启动")
| },that.backPath);
| });
| };
| this.doDelete = function (submitValue) {
| var that = this;
| webUtil.deleteRequest(that.url.controller + that.url.deleteUrl,submitValue,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 (buttonid,parentNodeOid) {
| var that = this;
| var tree = layui.tree;
| if(webUtil.isNotNull(parentNodeOid)){
| tree.reloadNode("tree_" + that.id,parentNodeOid);
| }else {
| tree.reload("tree_" + that.id);
| }
| };
| this.DISABLE = function () {
| var that = this;
| that.disableOrEnable(false);
| };
| this.ENABLE = function () {
| var that = this;
| that.disableOrEnable(true);
| };
| this.disableOrEnable = function (enable) {
| var that = this;
| var oid ;
| var ts ;
| var selectData = layui.table.checkStatus("table_" + that.id).data[0];
| if(selectData == undefined){
| webUtil.showErrorMsg("请先选择一条数据!");
| return false;
| }
| oid = selectData.oid;
| ts = selectData.ts;
| webUtil.post(that.url.controller + (enable?that.url.enableData:that.url.disableData),{
| oid:oid,
| ts:ts
| },function(result){
| if(result.success){
| webUtil.showMsgFromResult(result,(enable?'启用成功':'停用成功'));
| that.refresh();
| }else{
| webUtil.showErrorMsg(result.msg);
| }
| },function(xhr,err){
| webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
| },that.backPath);
| };
|
| this.EXPORT = function () {
| var that = this;
| var iframeId = MD5("export" +webUtil.getSystemVar(webUtil.systemValueKey.currentDateTimeSSS) +webUtil.getSystemVar(webUtil.systemValueKey.userOid));
| var data = {};
| data[TOKEN_KEY] = webUtil.getToken();
| data['downloadUUID'] = iframeId;
| webUtil.fileDownloadPost(that.backPath + that.url.controller + that.url.exportData,data);
| };
| this.IMPORT = function () {
| var that = this;
| var filter =that.id + "_upload";
| var form = layui.form;
| var uploadIndex = webUtil.dialog({
| title:'导入供应商基本信息',
| btn:['下载导入模板','取消'],
| content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" enctype="multipart/form-data"></form>',
| area: ['300px', '300px'],
| resize:false,
| success:function(layero){
| //如果导入有其他操作,在第二个参数中添加
| form.addItems(filter,[],function(){
| $("#form_" + filter).append('<button type="button" class="layui-btn" id="' + that.id + '_upload_form_file" style="margin-left:100px;margin-top:80px;"><i class="layui-icon"></i>选择文件后自动导入</button> ');
| var upload = layui.upload;
| //执行实例
| var uploadInst = upload.render({
| elem: '#' + that.id + '_upload_form_file' //绑定元素
| ,accept:'file'
| ,acceptMime:'file/*'
| ,exts:'xls|xlsx'
| ,url: that.backPath + that.url.controller + that.url.importData
| ,done: function(result){
| if(result.success){
| layer.close(uploadIndex);
| webUtil.showMsgFromResult(result,"导入成功");
| that.refresh();
| }else{
| webUtil.showErrorMsg(result.msg);
| }
| }
| ,error: function(){
| //请求异常回调
| webUtil.showErrorMsg("上传异常");
| }
| });
| },{},{
| defaultColumnOneRow:1
| });
| },
| yes:function(){
| var iframeId = MD5("downloadImportTemplate" +webUtil.getSystemVar(webUtil.systemValueKey.currentDateTimeSSS) +webUtil.getSystemVar(webUtil.systemValueKey.userOid));
| webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadImportTemplate+ "?" + TOKEN_KEY + "=" + webUtil.getToken() + "&downloadUUID=" + iframeId );
| }
| });
| };
| this.ADVQUERY = function() {
| var that = this;
| that.serinorQueryInstance.open();
| };
| this.advancedQuery = function () {
| var that = this;
| var dynamicCondition = layui.dynamicCondition;
| $('[layui-filter="toolbar_' + that.id + '"]').append('<div id="toolbar'+ that.id+'" class="layui-inline"></div>');
| var smUserTable = JSON.parse(JSON.stringify(that.columns));
| that.serinorQueryInstance = dynamicCondition.create({
| fields : smUserTable//查询字段
| ,tableId:"table_"+that.id//需要查询的表格
| ,type:"complex" //type:"simple"/"complex" 查询的方法 暂时写死为 complex
| // ,conditionTextId:"#toolbar"+that.id//高级查询 按钮所在的div
| // ,popupShowQueryBtn: true//显示高级查询按钮
| ,queryCallBack:function(requestData){//查询之后的callback
| //console.log(JSON.stringify(requestData))
| }
| });
| };
| this.refresh = function(){
| var that = this;
| layui.table.reload("table_" + that.id);
| };
| };
| var cs = new Class();
| exports(cs.MODELNAME,cs);
| });
|
|