zhangyanpeng
2024-08-20 f9d42f7a3929dacb96446e873ab992f9560ac9c9
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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
<!doctype html>
<html>
    <head>
        <meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
        <title>执行单信息</title>
        
        <script type="text/javascript">
            var pageVue = null;
            function loadJsCss(callback) {
                var jscss_urls = [];
                window.top.initJsCss(document, jscss_urls, callback);
            };
            
            function initVue() {
                new FormVue({
                    el: "#vbody",
                    data: {
                        dataname: "fee_guide_settle_execute",
                        table_dataname: "fee_working_out_base_execute",
                        title: "执行单信息",
                        dataRequest: [
                            {
                                name: "fee_working_out_base_execute", // 业务负责人字段
                                dataname: "fee_working_out_base_execute",
                                url: "root/data/getEntitySet",
                                paramsobj: {dataname: "fee_working_out_base_execute", attachMeta: true, filter: "1<>1"},
                                isnotoption: true, //true:不是选项
                            }
                        ],
                        meta_fee_working_out_base_execute: [],
                        
                        options_md_org_master: [],
                        md_bu_org_obj: {},
                        options_md_bu: [],
                        productobj_map: {},
                        md_bu_product_obj: {},
                        md_bu_product_bu_obj: {},
                        md_prod_sku_obj: {},
                        
                        formAttr: {
                            istitle: false,
                            title: "表单名称",
                            columnnumber: 3,
                            labelwidth: "100px",
                            labelposition: "left",//"left",// right//top
                            size: "mini",
                            border: "10px solid #c6c6c600",
                            borderleft: "0px"
                        },
                        
                        formFields: [],
                        
                        newformData: {
                            state_code: "Input",
                            state_name: "录入",
                            is_active: true,
                            source: "手动录入",
                            type_code: "Customer", // Standard标准价目表、Customer经销商价目表
                        },
                        formData: {},
                        
                        isRefresh: true,
                        tableFields: [],
                        tableData: [],
                        //字段设置
                        tablefieldClick: {},
                        pagesize: 10,
                        pagenum: 1,
                        total: 0,
                        tableHeight: 200,
                        tableloading: false,
                        
                        
                        //按键权限设置
                        isedit: false,//提交前编辑,保存/提交
                        isrefuseedit: false,//拒绝后编辑,保存/再次提交
                        isapproval: false,//审批,同意/拒绝/转办/退回
                        
                        iscommit: false,//提交标记
                        
                        //弹窗参数
                        popupParames: {},
                        
                        formfieldClick: {},
                        dheight: null,
                        
                        agreementdata: {},
                        options_product: [],
                        
                        //审批相关变量
                        reasonvisible:false,//审批通过或拒绝填写原因
                        approveremark: '',//填写理由
                        passOrRefuse:false,
                        loading_pass: false,
                    },
                    created() {
                        this.popupParames = clone(Root.popupParames);
                        // this.title = this.popupParames.title || this.popupParames.text
                        if (this.popupParames.data) {
                            if (this.popupParames.data._datano) {
                                this.title = this.title + this.popupParames.data._datano;
                            }
                            this.formData = clone(this.popupParames.data);
                        }
                        if (this.popupParames.delta && this.popupParames.delta.dataname) {
                            this.dataname = clone(this.popupParames.delta.dataname);
                        }
                        
                        if (this.popupParames.delta && this.popupParames.delta.agreementdata) {
                            this.agreementdata = clone(this.popupParames.delta.agreementdata);
                        }
                        if (this.popupParames.delta && this.popupParames.delta.options_product) {
                            this.options_product = clone(this.popupParames.delta.options_product);
                        }
                        
                        if (this.popupParames.sceneCode) {
                            if (this.popupParames.sceneCode == "add") {//新增
                                var newEntity_ = {
                                    name: "newEntity",
                                    url: "root/data/newEntity",
                                    paramsobj: {dataname: this.dataname},
                                    isnotoption: true, //true:不是选项
                                }
                                this.dataRequest.push(newEntity_);
                                for (var k in this.popupParames.data) {
                                    this.newformData[k] = this.popupParames.data[k]
                                }
                                this.isedit = true;
                            }
                            else if (this.popupParames.sceneCode == "browse") {//只读
                                this.formAttr.disabled = true;
                            }
                            else if (this.popupParames.sceneCode == "edit" || this.popupParames.sceneCode == "editbyagreement") {//编辑
                                this.isedit = true;
                            }
                            else if (this.popupParames.sceneCode == "approval") {//审批
                                this.formAttr.disabled = true;
                                this.isapproval = true;
                                
                                if (this.formData.current_step_name && this.formData.current_step_name == "运营部门复核") {
                                    this.isedit = true;
                                }
                                
                            }
                            else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
                                this.isrefuseedit = true;
                            }
                        }
                    },
                    
                    mounted() {
                        var me = this;
                        var title_h = 0;
                        if (me.popupParames.totab) {
                            title_h = 42;
                        }
                        me.dheight = document.documentElement.clientHeight - 50 - title_h;
                        //预加载数据
                        if (this.dataRequest && this.dataRequest.length) {
                            var result = {};
                            this.loadRequestData(this.dataRequest, result, function(data) {
                                me.dataRequestObj = data;
                                //预加载数据后给哪些字段设置options或formatterjson
                                if (me.dataRequestObj.newEntity) {
                                    var formData = clone(me.dataRequestObj.newEntity.data[me.dataname]);
                                    if (me.newformData) {
                                        let formData_ = clone(formData);
                                        
                                        for (var k in me.newformData) {
                                            if (!formData_[k]) {
                                                formData_[k] = me.newformData[k];
                                            }
                                        }
                                
                                        me.formData = formData_;
                                    }
                                }
                                // 获取变更的字段
                                if (me.dataRequestObj.fee_working_out_base_execute) {
                                    let meta_ = me.dataRequestObj.fee_working_out_base_execute.meta.fee_working_out_base_execute.fields;
                                    meta_.map(f=>{
                                        f.isshow = "T";
                                        if (f.field == "_qty_trans" || f.field == "_qty_cal" || f.field == "_qty_final" || f.field == "_amt_final") {
                                            f.isfixed = "right";
                                        }
                                    })
                                    me.meta_fee_working_out_base_execute = clone(meta_)
                                }
                                me.initData();
                            });
                        }
                        else {
                            this.initData();
                        }
                        
                        // 以服务的方式调用的 Loading 需要异步关闭
                        this.$nextTick(() => { 
                            hideLoading();
                        });
                    },
                    
                    methods:{
                        //关闭弹窗
                        closeDialog() {
                            var me = this;
                            if (me.popupParames.totab){
                                Root.tab.removeItem(Root.tab.selected);
                                Root.tab.open(me.popupParames.parentOption, false); 
                            }
                            else {
                                Root.hidePopup();
                            }
                        },
                        //关闭前调回调
                        saveAfter() {
                            var me = this;
                            if(this.popupParames.callback) {
                                let obj = {
                                    //row: this.formData
                                }
                                this.popupParames.callback(obj, function() {
                                    me.closeDialog();
                                });
                            }
                            else {
                                me.closeDialog();
                            }
                        },
                        
                        initData() {
                            let me = this;
                            var id_ = null;
                            if (this.formData.id) {
                                id_ = this.formData.id;
                            }
                            this.getRowDataById(id_, function(result) { //查询后的回调,用于获取字段的
                                if (result.meta && result.meta[me.dataname] && result.meta[me.dataname].fields) {
                                    var metas = clone(result.meta[me.dataname].fields);
                                    var formFields_ = [];
                                    
                                    metas.map(f=>{
                                        f.isshow = "T";
                                        if (f.field == "company_id") {
                                            // f.isshow = "F";
                                            f.options = me.options_md_org_master
                                        }
                                        
                                        if (f.field == "product_id") {
                                            f.props = {label: "value", value: "code", multiple: false};
                                            if (me.options_product.length) {
                                                f.options = clone(me.options_product);
                                            }
                                            else if (me.formData.bu_id && me.md_bu_product_obj[me.formData.bu_id]) {
                                                f.options = clone(me.md_bu_product_obj[me.formData.bu_id].children);
                                            }
                                            else {
                                                f.options = [];
                                            }
                                        }
                                        
                                        // if (f.field == "customer_name" && (me.popupParames.sceneCode == "addbyagreement" || me.popupParames.sceneCode == "editbyagreement")) {
                                        //     f.disabled = true;
                                        // }
                                        // if ((f.field == "date_from" || f.field == "date_to") && (me.popupParames.sceneCode == "addbyagreement" || me.popupParames.sceneCode == "editbyagreement")) {
                                        //     f.isshow = false;
                                        // }
                                        
                                        formFields_.push(clone(f));
                                    })
                                    if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
                                        me.formFields = clone(formFields_);
                                        me.tableFields = clone(me.meta_fee_working_out_base_execute);
                                        
                                        //设置字段事件
                                        me.tableFieldClick();
                                    }
                                    
                                    if (me.formData.company_id) {
                                        var formFields_ = clone(me.formFields);
                                        formFields_.map(f=>{
                                            if (f.field == "bu_id") {
                                                if (me.md_bu_org_obj[me.formData.company_id] && me.md_bu_org_obj[me.formData.company_id].length) {
                                                    f.options = clone(me.md_bu_org_obj[me.formData.company_id])
                                                }    
                                            }
                                        })
                                        me.formFields = clone(formFields_);
                                    }
                                    
                                    if (me.formData.product_id) {
                                        var select_p_ = [me.formData.product_id];
                                        me.formData.product_id = clone(select_p_);
                                        
                                        var formFields_ = clone(me.formFields);
                                        formFields_.map(f=>{
                                            if (f.field == "spec") {
                                                if (me.formData.product_id) {
                                                    f.options = clone(me.md_prod_sku_obj[me.formData.product_id[0]]);
                                                }
                                                else {
                                                    f.options = [];    
                                                }
                                            }
                                        })
                                        me.formFields = clone(formFields_);
                                    }
                                    me.onTableQuery();
                                }
                            })
                        },
                        
                        tableFieldClick() {
                            var me = this;
                            //表单字段事件设置
                            this.formfieldClick = {
                                type_code: {
                                    select: {
                                        onchange: function(obj,refreshCallback) {//下拉展开事件
                                            obj.data.type_name = obj.selectoption.value || "";
                                            var formFields_ = clone(me.formFields);
                                            formFields_.map(f=>{
                                                if (f.field == "account_name") { // f.field == "company_id" || f.field == "bu_id" ||
                                                    if (obj.data.type_code == "Onsite") { // 优惠价格
                                                        f.required = false
                                                    }
                                                    else {
                                                        f.required = true
                                                    }
                                                }
                                            })
                                            me.formFields = clone(formFields_);
                                        },
                                    },
                                },
                                _qty_trans: {
                                    val: {
                                        onchange: function(obj) {
                                            var formData_ = clone(me.formData);
                                            formData_._qty_trans = formData_._qty_trans * 1;
                                            if (formData_._qty_cal) {
                                                formData_._qty_final = (formData_._qty_cal * 1) - (formData_._qty_trans * 1)
                                                formData_._amt_final = formData_._qty_final  * formData_._taxunitprice
                                            }
                                            me.formData = clone(formData_);
                                        }
                                    },
                                    input: {
                                        onchange: function(obj) {
                                            var formData_ = clone(me.formData);
                                            formData_._qty_trans = formData_._qty_trans * 1;
                                            if (formData_._qty_cal) {
                                                formData_._qty_final = (formData_._qty_cal * 1) - (formData_._qty_trans * 1)
                                                formData_._amt_final = formData_._qty_final  * formData_._taxunitprice
                                            }
                                            me.formData = clone(formData_);
                                        }
                                    }
                                },
                                
                            };
                            
                            this.tablefieldClick = {
                                _qty_trans: {
                                    input: {
                                        onchange: function(obj) {
                                            obj.row._qty_trans = obj.row._qty_trans * 1;
                                            if (obj.row._qty_cal) {
                                                obj.row._qty_final = (obj.row._qty_cal * 1) - (obj.row._qty_trans * 1)
                                                obj.row._amt_final = obj.row._qty_final  * obj.row._taxunitprice
                                            }
                                            
                                            me.saveTableRow(obj.row);
                                        }
                                    }
                                },
                            }
                        },
                        
                        saveTableRow(row) {
                            var me = this;
                            var entity_ = clone(row);
                            var entity = {
                                _qty_trans: entity_._qty_trans,
                                _qty_final: entity_._qty_final,
                                _amt_final: entity_._amt_final,
                                id: entity_.id
                            };
                            
                            let param = {
                                dataname: me.table_dataname,
                                data: {},
                            }
                            if (entity.id) {
                                param.id = entity.id
                            }
                            param.data[me.table_dataname] = entity;
                            Server.call("root/data/saveEntity", param, function(result) {
                                
                            }, function(errorresult) {
                                console.log("错误信息", errorresult);
                                if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
                                    if (errorresult.messages.list) {
                                        var config = {
                                            totab: false,
                                            icon: "icon-product",
                                            text: "错误信息",
                                            url: "module/tool/page/popup_error_messages.html",
                                            data: {},
                                            delta: errorresult.messages.list,
                                            callback: function(obj, callback) {
                                                if (callback) {
                                                    callback();
                                                }
                                            }
                                        };
                                        me.doPopupByPublic(config);
                                    }
                                }
                                else if (errorresult.exists_errors && errorresult.exists_errors.length) {
                                    var messages_list = []
                                    var index_ = 0;
                                    errorresult.exists_errors.map(r=>{
                                        index_ ++;
                                        var messages_ = {
                                            step: index_,
                                            level: "Error",
                                            message: r.title + "【" + r.errors[0].record_no +  r.errors[0].record_name?r.errors[0].record_name: '' + "】"
                                        }
                                        messages_list.push(messages_)
                                    })
                                    var config = {
                                        totab: false,
                                        // width: "1200px",
                                        // height: 800,
                                        icon: "icon-product",
                                        text: "错误信息",
                                        url: "module/tool/page/popup_error_messages.html",
                                        data: {},
                                        delta: messages_list,
                                        callback: function(obj, callback) {
                                            if (callback) {
                                                callback();
                                            }
                                        }
                                    };
                                    me.doPopupByPublic(config);
                                }
                                else {
                                    Root.message({
                                        type: 'error',
                                        message: '调整失败'
                                    });
                                }
                            });
                        },
                        
                        openAccount(sceneCode, obj, callback) {
                            var me = this;
                            var data_ = {};
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "800px",
                                height: "520px",
                                icon: "icon-product",
                                text: "经销商选择",
                                id: "popup_account",//totab: true时需设置,用于判断是否已打开此页面
                                url: "module/md/page/popup/page/popup_account.html",
                                data: data_,
                                delta: {},
                                // filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
                                filter: "md_org_account.state_code='Open'",
                                sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(popupobj, popupcallback) {
                                    callback(popupobj);
                                    if (popupcallback) {
                                        popupcallback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
                        openOrg(sceneCode, obj, callback) {
                            var me = this;
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "800px",
                                height: "520px",
                                icon: "icon-product",
                                text: "选择配送商",
                                id: "popup_customer",//totab: true时需设置,用于判断是否已打开此页面
                                url: "module/md/page/popup/page/popup_customer.html",
                                data: {},
                                delta: "",
                                // filter: "category_code='"+ me.positiondata.org_id + "' and bu_id='" + me.positiondata.bu_id + "'",
                                filter: "is_distributor='T'",
                                sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(popupobj, popupcallback) {
                                    callback(popupobj);
                                    if (popupcallback) {
                                        popupcallback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
                        openHospital(sceneCode, obj, callback) {
                            var me = this;
                            var data_ = {};
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "800px",
                                height: "520px",
                                icon: "icon-product",
                                text: "医院选择",
                                id: "popup_hospital",//totab: true时需设置,用于判断是否已打开此页面
                                url: "module/md/page/popup/page/popup_hospital.html",
                                data: data_,
                                delta: {},
                                // filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
                                filter: "",
                                sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(popupobj, popupcallback) {
                                    callback(popupobj);
                                    if (popupcallback) {
                                        popupcallback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
                        
                        open_productlist(obj) {
                            var me = this;
                            Root.showPopup({
                                url: "../md/product/popup/sku_list.html",
                                width: 800,
                                height: 550,
                                callback: function(obj, callback) {
                                    let formData_ = clone(me.formData);
                                    
                                    formData_.product_id = obj.row.id;
                                    formData_.product_code = obj.row.md_code;
                                    formData_.product_name = obj.row.md_description;
                                    //formData_.spec = obj.row.pack_specification;
                                    
                                    me.formData = formData_;
                                    if (callback) {
                                        callback();
                                    }
                                }
                            });
                        },
                        
                        getData: function(page) {
                            this.pagesize = page.pagesize;
                            this.pagenum = page.pagenum;
                            // if (page.filtersobj) {
                            //     this.filterObj = page.filtersobj;
                            // }
                            // this.selectedrow = {};
                            this.onTableQuery();
                        },
                        onTableQuery() {
                            var me = this
                            let filter_ = "task_id='" + this.formData.id + "'";
                            
                            let param_ = {
                                dataname: this.table_dataname,
                                filter: filter_,
                                orderby: "_dataNo",
                                page: {
                                    pageno: this.pagenum,
                                    pagesize: this.pagesize
                                },
                                attachMeta: false
                            }
                            
                            me.tableData = [];
                            me.tableloading = true;
                            Server.call("root/data/getEntitySet", param_, function(result) {
                                me.tableloading = false;
                                if (result && result.data && result.data.entityset) {
                                    var data_ = result.data.entityset;
                                    me.tableData = data_;
                                    me.total = result.data.page ? result.data.page.recordcount : 0;
                                }
                                else {
                                    me.total = 0;
                                }
                            }, function(){
                                me.tableloading = false;
                            });
                        },
                        
                        //提交
                        submitRowTable() {
                            var me = this;
                            var bo_ = this.$refs.form1.checkForm();
                            
                            if (!bo_) {
                                bo_ = false;
                                Root.message({
                                    type: 'error',
                                    message: '请填写必填项'
                                });
                                return
                            }
                            this.iscommit = true;
                            this.saveRowTable();
                        },
                        
                        //保存
                        saveRowTable(callback) {
                            var me = this;
                            var operator_ = "saveEntity";//保存
                            // if(me.iscommit) {
                            //     operator_ = "commit";//提交
                            // }
                            
                            var entity_ = clone(this.formData);
                            var entity = {
                                _qty_trans: entity_._qty_trans,
                                _qty_final: entity_._qty_final,
                                _amt_final: entity_._amt_final,
                                id: entity_.id
                            };
                            
                            let param = {
                                dataname: me.dataname,
                                data: {},
                            }
                            if (me.formData.id) {
                                param.id = me.formData.id
                            }
                            param.data[me.dataname] = entity;
                            
                            Server.call("root/data/" + operator_, param, function(result) {
                                console.log(result);
                                if (result.success) {
                                    if (callback) {
                                        callback()
                                    }
                                    else {
                                        if(me.iscommit){
                                            me.iscommit = false;
                                            Root.message({
                                                type: 'success',
                                                message: '提交成功'
                                            }); 
                                            me.saveAfter();
                                        }
                                        else {
                                            Root.message({
                                                type: 'success',
                                                message: '保存成功'
                                            }); 
                                            me.saveAfter();
                                        }
                                    }
                                }
                            }, function(errorresult) {
                                console.log("错误信息", errorresult);
                                if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
                                    if (errorresult.messages.list) {
                                        me.iscommit = false;
                                        var config = {
                                            totab: false,
                                            // width: "1200px",
                                            // height: 800,
                                            icon: "icon-product",
                                            text: "错误信息",
                                            url: "module/tool/page/popup_error_messages.html",
                                            data: {},
                                            delta: errorresult.messages.list,
                                            callback: function(obj, callback) {
                                                if (callback) {
                                                    callback();
                                                }
                                            }
                                        };
                                        me.doPopupByPublic(config);
                                    }
                                }
                                else if (errorresult.exists_errors && errorresult.exists_errors.length) {
                                    var messages_list = []
                                    var index_ = 0;
                                    errorresult.exists_errors.map(r=>{
                                        index_ ++;
                                        var messages_ = {
                                            step: index_,
                                            level: "Error",
                                            message: r.title + "【" + r.errors[0].record_no +  r.errors[0].record_name?r.errors[0].record_name: '' + "】"
                                        }
                                        messages_list.push(messages_)
                                    })
                                    me.iscommit = false;
                                    var config = {
                                        totab: false,
                                        // width: "1200px",
                                        // height: 800,
                                        icon: "icon-product",
                                        text: "错误信息",
                                        url: "module/tool/page/popup_error_messages.html",
                                        data: {},
                                        delta: messages_list,
                                        callback: function(obj, callback) {
                                            if (callback) {
                                                callback();
                                            }
                                        }
                                    };
                                    me.doPopupByPublic(config);
                                }
                                else {
                                    me.iscommit = false;
                                    Root.message({
                                        type: 'error',
                                        message: '提交失败'
                                    });
                                }
                            });
                        },
                        
                        // 通过或拒绝
                        onShowApproval(passOrRefuse) {
                            this.approveremark = "";
                            this.reasonvisible = true;//审批备注填写弹窗
                            this.passOrRefuse = passOrRefuse;// commit下一个状态;approve通过;gohome;//拒绝 goback;//回退
                        },
                        saveReason() {
                            this.loading_pass = true;
                            if(this.passOrRefuse == "commit" || this.passOrRefuse == "approve"){
                                this.doApproval();
                            }
                            else{
                                if(this.approveremark != ""){
                                    this.doApproval();
                                }
                                else{
                                    Root.message({
                                        type: 'warning',
                                        message: '请填写原因'
                                    });
                                    this.loading_pass = false;
                                }
                            }
                        },
                        doApproval(bo) {
                            var me = this;
                            // if (this.isedit) {
                            //     this.saveRowTable(function() {
                            //         me.doRunApproval();
                            //     });
                            // }
                            // else {
                                me.doRunApproval();
                            // }
                            
                        },
                        
                        getMachine(callback) {
                            var me = this;
                            let param = {
                                dataname: me.dataname,
                            }
                            Server.call("root/state/getMachine", param, function(result) {
                                var next_step = {}; // 向下流程
                                var up_step = {}; // 向上流程
                                
                                if (result && result.machine && result.machine.detail) {
                                    result.machine.detail.map(md=>{
                                        next_step[md.from_code] = md.to_code;
                                        up_step[md.to_code] = md.from_code;
                                    })
                                    
                                    callback(next_step, up_step);
                                }
                            })
                        },
                        
                        doRunApproval() {
                            var me = this;
                            
                            let param = {
                                dataname: me.dataname,
                                id: me.formData.id,
                                // to_state: to_state_,
                                remark: this.approveremark
                            }
                            //
                            // return
                            Server.call("root/data/" + this.passOrRefuse, param, function(result) {
                                me.loading_pass = false;
                                console.log(result);
                                if (me.passOrRefuse == "commit" || me.passOrRefuse == "approve") {
                                    Root.message({
                                        type: 'success',
                                        message: '审批成功'
                                    }); 
                                }
                                else if (me.passOrRefuse == "goback") {
                                    Root.message({
                                        type: 'success',
                                        message: '已退回'
                                    }); 
                                }
                                else if (me.passOrRefuse == "gohome") {
                                    Root.message({
                                        type: 'success',
                                        message: '已拒绝'
                                    }); 
                                }
                                me.saveAfter();
                            }, function(errorresult) {
                                console.log("错误信息", errorresult);
                                me.loading_pass = false;
                                if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
                                    if (errorresult.messages.list) {
                                        var config = {
                                            totab: false,
                                            // width: "1200px",
                                            // height: 800,
                                            icon: "icon-product",
                                            text: "错误信息",
                                            url: "module/tool/page/popup_error_messages.html",
                                            data: {},
                                            delta: errorresult.messages.list,
                                            callback: function(obj, callback) {
                                                if (callback) {
                                                    callback();
                                                }
                                            }
                                        };
                                        me.doPopupByPublic(config);
                                        
                                    }
                                }
                                else {
                                    Root.message({
                                        type: 'error',
                                        message: '审批失败'
                                    }); 
                                }
                            });
                        },
                        
                    }
                });
            };
            
            loadJsCss(function () {
                initVue();
            });
        </script>
        <style>
            /*  在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
            [v-cloak] {
                display: none !important;
            }
        </style>
        
    </head>
    
    <body style="margin: 0px;">
        <div v-cloak id="vbody">
            <div id="page_root">
                <div ref="popup_body" style="padding: 0 20px;">
                    <div v-if="popupParames.totab" class="el-dialog__header">
                        <div class="dialog-title">
                          <i class="iconfont icon-customermanagement"></i>
                          <span> {{title}}</span>
                        </div>
                    </div>
                    <div :style="{height: dheight + 'px', 'overflow-y': 'auto'}">
                        <div class="el-dialog__body">
                            <h-form
                                ref="form1"
                                :form-attr="formAttr"
                                :table-fields="formFields"
                                :form-data="formData"
                                :table-field-click="formfieldClick"
                            >
                            </h-form>
                        </div>
                        
                        <div class="h_BU">
                            <div style="padding: 0px;">
                                <h-table
                                    v-if="isRefresh"
                                    ref="table1"
                                    :table-fields="tableFields" 
                                    :table-data="tableData" 
                                    :is-within-edit-table-data="isedit"
                                    :table-field-click="tablefieldClick"
                                    :pagesize="pagesize"
                                    :pagenum="pagenum"
                                    :total="total"
                                    :table-height="dheight - 252 - 64"
                                    :is-highlight-row="true"
                                    :isdraggableorder="false"
                                    :isshowtool="false"
                                    :isshow-shoppingcart="false"
                                    
                                    v-on:get-data="getData"
                                >
                                </h-table>
                                <!-- 
                                 :is-edit-table-data="isWithinEditTableData"
                                 -->
                            </div>
                        </div>
                    </div>
                    <el-dialog title="填写原因" :visible.sync="reasonvisible" height="50%">
                        <el-input
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 10}"
                        placeholder="请输入原因"
                        v-model="approveremark">
                        </el-input>
                        
                        <div slot="footer" class="dialog-footer" >
                        <el-button type="default" @click="reasonvisible = false">取 消</el-button>
                        <el-button type="primary" :loading="loading_pass" @click="saveReason">确 定</el-button>
                        </div>
                    </el-dialog>
                    <div class="el-dialog__footer">
                        <el-button-group style="margin-right: 80px;" >        
                            <el-button  size="small" v-if="isapproval" type="warning" plain @click="onShowApproval('gohome')">退回到申请人</el-button>
                            <el-button  size="small" v-if="isapproval" type="danger" plain @click="onShowApproval('goback')">退回到上一步</el-button>
                        </el-button-group>
                        <el-button size="small" type="default" @click="closeDialog">取 消</el-button>
                        <!-- <el-button size="small" v-if="isedit || isrefuseedit" type="primary" :loading="loading_save" @click="saveRowTable()":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
                        <el-button size="small" v-if="isedit && !formData.agreement_id" type="success" :loading="loading_submit" @click="submitRowTable":icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</el-button>
                         -->
                        <el-button size="small" v-if="isrefuseedit" type="success" @click="">再次提交</el-button>
                        
                        <el-button size="small" v-if="isapproval" type="success" @click="onShowApproval('approve')">通 过</el-button>
                        <!-- <el-button size="small" v-if="isapproval" type="primary" @click="">转 办</el-button> -->
                    </div>
                </div>
            </div>
        </div>
        
        <div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
            <div class="spinner">
              <div class="cube1"></div>
              <div class="cube2"></div>
            </div>
        </div>
    </body>
</html>