tom
2024-08-16 a0dadc84e4a819607e1b2b34534bb0b0ae73a7a8
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
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
 
<!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_payment",
                        table_dataname: "fee_qty",
                        title: "单据信息",
                        dataRequest: [
                        ],
                        default_formFields: [
                        { field: "state_name", name: "状态", isshow: "F", width: "80",input_type_filter:"select",filter_field:"state_code",inputtype:"capsuletag",options_pattern:"{^草稿^:^info^,^生效^:^success^,^审批中^:^warning^}"},
                                // { field: "state_name", name: "状态", isshow: "T", width: "80"},
                                { field: "state_code", name: "状态", isshow: "F", width: "80" },
                                { field: "id", name: "费用单编号", isshow: "T", width: "120", },
                                { field: "province", name: "省份", isshow: "T" ,width: "100"},
                                { field: "rate", name: "费率", isshow: "T" ,width: "100"},
                                { field: "amt_rate", name: "付款比例", isshow: "T" ,width: "100"},
                                { field: "customer_code", name: "服务供应商编码", isshow: "T" ,width: "110"},
                                { field: "customer_name", name: "服务供应商", isshow: "T" ,width: "200",align:"left"},
                                { field: "amt", name: "应付金额", isshow: "T" ,width: "100",formatter:'formatter_money'},
                                { field: "other_deduction", name: "其余扣款", isshow: "T", align: "center", width: "100",formatter:'formatter_money' },
                                { field: "after_deduction_amt", name: "扣款后金额", isshow: "T", align: "center", width: "100",formatter:'formatter_money' },
                                { field: "applicant", name: "申请人", isshow: "T", align: "center", width: "100" },
                                { field: "apply_date", name: "申请时间", isshow: "T", align: "center", width: "100" ,formatter:'formatter_date'},
                                { field: "order_state", name: "尾款状态", isshow: "T", align: "center", width: "100" },
                                { field: "order_code", name: "关联首款单号", isshow: "T", align: "center", width: "100",  },
                                { field: "province_order_code", name: "省级费用单号", isshow: "T", align: "center", width: "100",  },
                                { field: "payment", name: "付款金额", isshow: "T", align: "center", width: "100",formatter:'formatter_money' },
                                { field: "payment_date", name: "付款时间", isshow: "T", align: "center", width: "100", formatter:'formatter_date'},
                                { field: "freeze", name: "冻结状态", isshow: "T", align: "center", width: "100" },
                        ],
                        default_tableFields:[
                        { field: "state_name", name: "状态", isshow: "F", width: "80",input_type_filter:"select",filter_field:"state_code",inputtype:"capsuletag",options_pattern:"{^草稿^:^info^,^生效^:^success^,^审批中^:^warning^}"},
                                { field: "state_code", name: "状态", isshow: "F", width: "80" },
                                { field: "parent_id", name: "确认单号", isshow: "T", width: "120",  },
                                { field: "sale_year", name: "销售年份", isshow: "T", align: "center", width: "80" },
                                { field: "sale_month", name: "销售月份", isshow: "T" ,width: "80"},
                                { field: "date", name: "销售日期", isshow: "T",width: "100",type:"date",formatter:"formatter_date"},
                                { field: "commit_year", name: "统计年份", isshow: "T",width: "80" },
                                { field: "commit_month", name: "统计月份", isshow: "T", width: "80" },
                                { field: "type", name: "类型", isshow: "T",},
                                { field: "sale_code", name: "服务联系人编码", isshow: "T", align: "center",width: "110"  },
                                { field: "sale_name", name: "服务联系人", isshow: "T", align: "center", width: "100" },
                                { field: "customer_code", name: "客户编码", isshow: "T", align: "center",width: "100"  },
                                { field: "customer_name", name: "客户名称", isshow: "T", align: "left",width: "150",inputtype:'span'},
                                { field: "product", name: "产品名称", isshow: "T", align: "left" ,width: "200"  },
                                { field: "spec", name: "规格", isshow: "T", align: "center",width: "150"   },
                                { field: "agreement_code", name: "协议编号", isshow: "T",width: "100", align: "center", },
                                { field: "invoince_price", name: "开票价", isshow: "T", align: "center",  },
                                { field: "settlement_price", name: "结算低价", isshow: "T", align: "center",  },
                                { field: "tax", name: "税点", isshow: "T", align: "center",  },
                                { field: "policy", name: "政策", isshow: "T", align: "center",  },
                                { field: "flow_qty", name: "流向数量", isshow: "T", align: "center",  },
                                { field: "comfirm_qyt", name: "确认数量", isshow: "T", align: "center",  },
                                { field: "return_qty", name: "应返金额", isshow: "T", align: "center",formatter:"formatter_money"  },
                                { field: "other_deduction", name: "其余扣款", isshow: "T", align: "center",formatter:"formatter_money"  },
                                { field: "returned_qty", name: "实返金额", isshow: "T", align: "center",formatter:"formatter_money" },
                                { field: "deduction_remark", name: "扣款备注", isshow: "T", align: "left",width:'200'  },
                                { field: "order_code", name: "订单号", isshow: "T", align: "center",  width:'120' },
                                { field: "order_total", name: "订单金额", isshow: "T", align: "center",formatter:"formatter_money",width:'120'  },
                                { field: "order_amt", name: "订单单价", isshow: "T", align: "center",formatter:"formatter_money",width:'120'  },
                                { field: "order_state", name: "订单状态", isshow: "T", align: "center",width:'80'  },
                                { field: "platform_information", name: "平台信息", isshow: "T", align: "center",  },
                                { field: "applicant", name: "申请人", isshow: "T", align: "center",  },
                                { field: "product_group", name: "产品组", isshow: "T", align: "center",  },
                                { field: "apply_date", name: "申请时间", isshow: "T", align: "center",formatter:"formatter_date",width: "100"  },
                                { field: "pre_merger_customer", name: "合并前客户", isshow: "T", align: "center", width: "100" },
                                { field: "last_arrpove_time", name: "最后审批时间", isshow: "T", align: "center",formatter:"formatter_date",width: "100"  },
                                { field: "agency_fee_state", name: "代理费用单状态", isshow: "T", align: "center",width: "110"  },
                                { field: "freeze", name: "冻结状态", isshow: "T", align: "center",  },
                                { field: "ferrze_remark", name: "冻结原因", isshow: "T", align: "left",  },
                        ],
                        options_wm_warehouse: [],
                        
                        formAttr: {
                            istitle: false,
                            title: "表单名称",
                            columnnumber: 2,
                            labelwidth: "120px",
                            labelposition: "left",//"left",// right//top
                            size: "mini",
                            border: "5px solid #c6c6c600"
                        },
                        formFields: [],
                        newformData: {
                            code: createCode("YC"),
                            doc_date: createDate(),
                            create_time: createDatetime(),
                            state_code: "Input",
                            state_name: "草稿",
                            account_id:window.top.vue.userinfo.currentactor.target_id,
                            to_account_id:window.top.vue.userinfo.currentactor.target_id,
                            company_id:window.top.vue.userinfo.currentactor.company_id,
                            bu_name:window.top.vue.userinfo.currentactor.bu_name,
                            bu_id:window.top.vue.userinfo.currentactor.bu_id,
                            org_id:window.top.vue.userinfo.org.id,
                            org_code:window.top.vue.userinfo.org.code,
                            org_name:window.top.vue.userinfo.org.name,
                            creator_name: window.top.vue.userinfo.name,
                        },
                        formData: {},
                        
                        isRefresh: true,
                        tablebuttonClick:[],
                        tableFields: [],
                        newTableData: {
                            create_time: createDatetime(),
                            creator_name: window.top.vue.userinfo.name,
                        },
                        tableData: [],
                        stock_qty:0,
                        //按键权限设置
                        isedit: false,//提交前编辑,保存/提交
                        isrefuseedit: false,//拒绝后编辑,保存/再次提交
                        isapproval: false,//审批,同意/拒绝/转办/退回
                        
                        iscommit: false,//提交标记
                        
                        //弹窗参数
                        popupParames: {},
                        //字段设置
                        tablefieldClick: {},
                        formfieldClick: {},
                        dheight: 0,
                        checkarr:[],
                        delarr:[],
                        iscustomer: false,
                        tableAttr:{}
                    },
                    created() {
                        this.tableButtonClick();    
                        if (window.top.vue.userinfo && window.top.vue.userinfo.org && window.top.vue.userinfo.org.is_account) {
                            this.iscustomer = true;
                        }
                        this.dheight = document.documentElement.clientHeight - 92;
                        this.popupParames = clone(Root.popupParames);
                        this.title = this.popupParames.title || this.popupParames.text
                        if (this.popupParames.data) {
                            this.formData = clone(this.popupParames.data);
                        }
                        
                        if (this.popupParames.sceneCode) {
                            if (this.popupParames.sceneCode == "add") {//新增
                                if (this.newformData) {
                                    let formData_ = clone(this.formData);
                                    
                                    for (var k in this.newformData) {
                                        formData_[k] = this.newformData[k];
                                    }
                                    this.formData = formData_;
                                }
                                
                                // if (this.newTableData) {
                                //     this.tableData.push(clone(this.newTableData));
                                // }
                                
                                this.isedit = true;
                            }
                            else if (this.popupParames.sceneCode == "browse") {//只读
                                this.formAttr.disabled = true;
                                this.isedit = false;
                            }
                            else if (this.popupParames.sceneCode == "edit") {//编辑
                                this.isedit = true;
                            }
                            else if (this.popupParames.sceneCode == "approval") {//审批
                                this.formAttr.disabled = true;
                                this.isapproval = true;
                            }
                            else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
                                this.isrefuseedit = true;
                            }
                        }
                    },
                    
                    mounted() {
                        var me = this;
                        me.tableButtonClick();
 
                        //  this.tableAttr.toolbarobj={};
                        // this.$set(tableAttr , 'toolbarobj', '');
                        //预加载数据
                        if (this.dataRequest && this.dataRequest.length) {
                            var result = {};
                            this.loadRequestData(this.dataRequest, result, function(data) {
                                me.dataRequestObj = data;
                                //预加载数据后给哪些字段设置options或formatterjson
                                if(me.dataRequestObj.wm_warehouse){
                                    me.options_wm_warehouse = me.dataRequestObj.wm_warehouse
                                }
                                me.initData();
 
                            });
                        }
                        else {
                            this.initData();
                        }
                        
                        // 以服务的方式调用的 Loading 需要异步关闭
                        this.$nextTick(() => { 
                            hideLoading();
                            
                            //重新设置弹窗宽高
                            this.$nextTick(function(){
                                //let w_ = this.$refs.popup_body.offsetWidth + "px";
                                let w_ = "900px";
                                let h_ = this.$refs.popup_body.offsetHeight + "px";
                                Root.setPopupWH(w_, h_);
                            })
                        });
                    },
                    
                    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;
                            me.tableButtonClick();
                    
                            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 table_dataname_ = "";
                                    for (var dataname_ in result.meta) {
                                        if (dataname_ != me.dataname && !table_dataname_) {
                                            table_dataname_ = dataname_;
                                        }
                                    }
                                    var table_metas = [];
                                    if (table_dataname_) {
                                        me.table_dataname = table_dataname_;
                                        table_metas = clone(result.meta[table_dataname_].fields);
 
                                    }
                                    
                                    var formFields_ = [];
                                    var tableFields_ = [];
                                    metas.map(f=>{
                                        f.isshow = "T";
                                        // if(f.field == "org_code" || f.field == "org_name"){
                                        //     if(me.iscustomer){
                                        //         f.isshow = "F";
                                        //     }
                                        // }
                                        if (f.field == "from_warehouse_name") {
                                                f.options = me.options_wm_warehouse;
                                            }
                                        if (f.field == "to_warehouse_name") {
                                                f.options = me.options_wm_warehouse;
                                            }    
                                        formFields_.push(clone(f));
                                    })
                                    table_metas.map(f=>{
                                        f.isshow = "T";
                                        
                                        if (f.field == "stock_type") {
                                            f.options = me.dataRequestObj.wm_stock_type
                                            var formatterjson_ = {};
                                            me.dataRequestObj.wm_stock_type.map(r=>{
                                                formatterjson_[r.code] = r.name;
                                            })
                                            f.formatterjson = formatterjson_
                                            
                                        }
                                        if (f.field == "qty") {
                                            
                                            f.inputkeys = "number";//按键正整数
                                            var f_stock_qty = {isshow: "T", field: "stock_qty", name: "可用数量", align: "right",width: "100"}
                                            tableFields_.push(clone(f_stock_qty));
                                        }
                                        tableFields_.push(clone(f));
                                    })
                                    
                                    if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
                                        me.formFields = clone(me.default_formFields);
                                        me.tableFields = clone(me.default_tableFields);
                                        
                                        
                                    }
                                }
                                if (me.rowData[me.dataname]) {
                                    me.formData = me.rowData[me.dataname];
                                }
                                if (me.rowData[me.table_dataname]) {
                                    me.tableData = me.rowData[me.table_dataname];
                                }
                            })
 
                            me.tableButtonClick();
                            
                            //字段数组转字段obj,目的为了筛选时获取字段属性
                            me.fieldsToFieldsObj();
                                    
                            //设置字段事件
                            me.tableFieldClick();
                            
                        },
                        
                        tableFieldClick() {
                            var me = this;
                            //表单字段事件设置
                            this.formfieldClick = {
                                org_name: {
                                    popup: {
                                        onclick: function(obj) {//弹窗点击事件
                                            //打开
                                            me.tablePopup_customerList()
                                        }
                                    },
                                },
                                from_warehouse_name: { 
                                    visible: {
                                            onchange: function(obj) {
                                                // me.formData.from_warehouse_name//这是出仓项
                                                var formFields_ = [];
                                                var options_ = []
                                                formFields_ = clone(me.formFields)
                                                me.options_wm_warehouse.map(f=>{ 
                                                    if(f.name != me.formData.to_warehouse_name && f.account_id == me.formData.account_id) {
                                                        options_.push(clone(f))
                                                    }
                                                })
                                                formFields_.map(f=>{
                                                    if(f.field == "from_warehouse_name") {
                                                        f.options = clone(options_)
                                                    }
                                                })
                                                me.formFields = clone(formFields_)
                                                if(me.formData.from_warehouse_name) {
                                                    Root.confirm('更换移出仓库将会重置明细,是否继续?', '更换提示', { //下拉提示
                                                    confirmButtonText: '确定',
                                                    // cancelButtonText: '取消',
                                                    showCancelButton:false,
                                                    type: 'warning'
                                                    }).then(() => {
                                                        return        
                                                    }).catch(() => {
                                                        return                              
                                                    });
                                                }
                                                
                                            }
                                    },
                                    select: {
                                        onchange: function(obj) {
                                            me.tableData = []
                                            obj.data.from_warehouse_name = obj.selectoption.name//将选中项赋值
                                            obj.data.from_warehouse_id = obj.selectoption.id
                                            obj.data.from_warehouse_code = obj.selectoption.code 
 
                                        }
                                    }
                                    
                                },
                                to_warehouse_name: {
                                    visible: {
                                        onchange: function(obj) {
                                            var formFields_ = [];
                                            var options_ = []
                                            formFields_ = clone(me.formFields)
                                            me.options_wm_warehouse.map(f=>{
                                                if(f.name != me.formData.from_warehouse_name && f.account_id == me.formData.to_account_id) {//这是出仓项
                                                    options_.push(clone(f))
                                                }
 
                                            })
                                            formFields_.map(f=>{
                                                if(f.field == "to_warehouse_name") {
                                                    f.options = clone(options_)
                                                }
                                            })
                                            me.formFields = clone(formFields_)
                                            
                                        }
                                    },
                                    select: {
                                        onchange: function(obj){
                                            obj.data.to_warehouse_name = obj.selectoption.name
                                            obj.data.to_warehouse_id = obj.selectoption.id
                                            obj.data.to_warehouse_code = obj.selectoption.code
                                        }
                                    }
                                },
                            };
                            
                            //表格字段事件设置
                            this.tablefieldClick = {
                                material_name: {
                                    popup: {
                                        onclick: function(obj) {//弹窗点击事件
                                            //打开
                                            me.tablepopup_productlist(obj);
                                        }
                                    },
                                },
                                qty: {
                                    input: {
                                        onchange: function(obj) {//输入更改事件
                                            // if (obj.row.batch_sn) {//有序列号
                                            //     //不能大于1且不能小于0
                                            //     if (obj.row.qty > 1) {
                                            //         Root.message({
                                            //             type: 'warning',
                                            //             message: '存在序列号的数量不可大于1'
                                            //         });
                                            //         me.$set(obj.row, "qty", 1);
                                            //     }
                                            //     else if (obj.row.qty < 0) {
                                            //         Root.message({
                                            //             type: 'warning',
                                            //             message: '存在序列号的数量不可小于0'
                                            //         });
                                            //         me.$set(obj.row, "qty", 0);
                                            //     }
                                            // }
                                            if (obj.row.stock_qty) {//可用数
                                                if (obj.row.qty > obj.row.stock_qty) {
                                                    Root.message({
                                                        type: 'warning',
                                                        message: '数量不可大于可用数'
                                                    });
                                                    me.$set(obj.row, "qty", 0);
                                                }
                                            }
                                            //将类似‘00099’之类的数字,前面的0都删掉
                                            if (obj.row.qty && obj.row.qty.length > 1) {
                                                var p = 0;
                                                for (q = 0; q <= (obj.row.qty.length + p); q++) {
                                                    if (obj.row.qty[0]*1 == 0) {
                                                        obj.row.qty = obj.row.qty.substring(1);
                                                        p ++;
                                                    } else {
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    },
                                },
                            };
                        },
                        // 设置表格工具栏按键事件
                        tableButtonClick() {
                            var me = this;
                            var tablebuttonclick = [];
                            tablebuttonclick = [
                            {    
                                    name:"新增明细",
                                    isbuttonshow: me.isedit, type: "primary",
                                    code: "addDetail", isselected: false, classname:"",
                                
                                    onclick: function(obj) {
                                        // if(!me.formData.from_warehouse_name || !me.formData.to_warehouse_name){
                                        //     Root.message({
                                        //         type: 'warning',
                                        //         message: '请先选择仓库'
                                        //     });
                                        // return;
                                        // }
                                        // me.tablepopup_productlist(obj)
                                        me.tablepopup_feelist("add", obj, function(popupobj){
                                            // let row_ = clone(me.formData)
                                            var tableData_ = clone(me.tableData);
                                            if (popupobj.list && popupobj.list.length) {
                                                popupobj.list.map(row => {
                                                    var newrow = {
                                                        parent_id: row.id,
                                                        sale_year: row.sale_year,
                                                        sale_month: row.sale_month,
                                                        date: row.date,
                                                        commit_year: row.commit_year,
                                                        commit_month: row.commit_month,
                                                        type: row.type,
                                                        sale_code: row.sale_code,
                                                        sale_name: row.sale_name,
                                                        customer_code: row.customer_code,
                                                        customer_name: row.customer_name,
                                                        product: row.product,
                                                        spec: row.spec,
                                                        agreement_code: row.agreement_code,
                                                        invoince_price: row.invoince_price,
                                                        settlement_price: row.settlement_price,
                                                        tax: row.tax,
                                                        policy: row.policy,
                                                        flow_qty: row.flow_qty,
                                                        comfirm_qyt: row.comfirm_qyt,
                                                        return_qty: row.return_qty,
                                                        other_deduction: row.other_deduction,
                                                        returned_qty: row.returned_qty,
                                                        deduction_remark: row.deduction_remark,
                                                        order_code: row.order_code,
                                                        order_total: row.order_total,
                                                        order_amt: row.order_amt,
                                                        order_state: row.order_state,
                                                        platform_information: row.platform_information,
                                                        applicant: row.applicant,
                                                        product_group: row.product_group,
                                                        apply_date: row.apply_date,
                                                        pre_merger_customer: row.pre_merger_customer,
                                                        last_arrpove_time: row.last_arrpove_time,
                                                        agency_fee_state: row.agency_fee_state,
                                                        freeze: row.freeze,
                                                        ferrze_remark: row.ferrze_remark,
                                                    }
 
                                                    tableData_.unshift(clone(newrow));
                                                })
                                            }
                                            me.tableData = clone(tableData_)
                                        })
 
                                    }
                                },
                                {
                                    isbuttonshow: me.isedit, type: "danger",
                                    code: "delete", isselected: true, classname:"",
                                    disabled: function(selectRowList) {
                                        var bo_ = true ;
                                        if (selectRowList[0]) {
                                            bo_ = false
                                        }
                                        return bo_; 
                                    },
                                    onclick: function(obj) {
                                        var row = obj.selectedList[0];
                                        var txt = clone(row.product_name);
                                        me.deleteDataById(row.id, "wm_movement_detail", "【" + txt + "】", function(){
                                            me.tableData.splice(obj.selectRowIndex, 1);
                                        })
                                    }
                                }
                            ]
                            me.tablebuttonClick = tablebuttonclick
                            
                        },
 
                        
                        
                        tablepopup_feelist(sceneCode, obj , callback) {
                            var me = this;
                            var data_ = {};
                            var delta_ = {};
                            console.log(obj);
                            
                            //排除已选物料
                            // me.tableData.map(row=>{
                            //     if (row.batch_sn) {
                            //         var key_ =  me.formData.from_warehouse_id + "_" + row.product_code + "_" + row.batch_no + "_" + row.batch_sn
                            //         delta_[key_] = true
                            //     }
                            //     else if (row.product_code) {
                            //         var key_ = me.formData.from_warehouse_id + "_" + row.product_code + "_" + row.batch_no
                            //         delta_[key_] = true
                            //     }
                            // })
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "800px",
                                height: "520px",
                                icon: "icon-product",
                                text: "明细选择",
                                id: "popup_fee_qty",//totab: true时需设置,用于判断是否已打开此页面
                                url: "module/fee/page/popup/popup_fee_qty.html",
                                data: data_,
                                delta: delta_,
                                // filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
                                filter: "state_code='Input'" , 
                                sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(popupobj, popupcallback) {
                                    callback(popupobj);
                                    if (popupcallback) {
                                        popupcallback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
                        deleteDataById(id, dataname, confirm_txt, callback){
                            var me = this;
                            var formData_ = clone(me.formData);
                            Root.confirm('确定删除该' + confirm_txt + '吗?', '删除提示', {
                              confirmButtonText: '删除',
                              cancelButtonText: '取消',
                              type: 'warning'
                            }).then(() => {
                                if (id) {
                                    let param = {
                                        dataname: dataname,
                                        id: id
                                    }
                                    Server.call("root/data/deleteEntity", param, function(result) {
                                        console.log(result);
                                        if (result && result.data) {
                                            callback();
                                        }
                                    });
                                }
                                else {
                                    callback();
                                }
                                
                            }).catch(() => {
                                Root.message({
                                    type: 'info',
                                    message: '已取消删除'
                                });          
                            });
                            
                        },
                        
                        GFG_Fun() {
                            var suiji = Math.random().toString(36).slice(2);
                            return suiji;
                        },
                        
                        addTableData() {
                            var me = this
                            // if(!this.formData.from_warehouse_name || !this.formData.to_warehouse_name){
                            //     Root.message({
                            //         type: 'warning',
                            //         message: '请先选择仓库'
                            //     });
                            // return;
                            // }                            
                        },
                        
                        delData(scope) {
                            let me = this;
                            let row = scope.row;
                            let index_ = scope.$index;
                            
                            Root.confirm('确定删除该数据吗?', '删除提示', {
                              confirmButtonText: '删除',
                              cancelButtonText: '取消',
                              type: 'warning'
                            }).then(() => {
                                me.rowChange(row, "del", me.table_dataname);
                            }).catch(() => {
                                Root.message({
                                    type: 'info',
                                    message: '已取消删除'
                                });          
                            });
                        },
                        
                        rowChange(row, type, tablename) {
                            var me = this;
                            if (type == "add") {
                                this.tableData.unshift(row);
                            }
                            else if (type == "del") {
                                if (row.id) {
                                    let param = {
                                        dataname: tablename,
                                        id: row.id
                                    }
                                    
                                    Server.call("root/data/deleteEntity", param, function(result) {
                                        console.log(result);
                                        if (result && result.data) {
                                            me.tableData.remove(row);
                                            
                                            Root.message({
                                                type: 'success',
                                                message: '删除成功!'
                                            });
                                        }
                                    });
                                }
                                else {
                                    this.tableData.remove(row);
                                }
                            }
                            else {
                            
                            }
                        },
                        
                        //提交
                        submitRowTable() {
                            var me = this;
                            var bo_ = true;
                            var batch_no_ = true;
                            if (this.iscommit) {
                                return
                            }
                            
                            if (me.tableData.length == 0) {
                                bo_ = false;
                                Root.message({
                                    type: 'warning',
                                    message: '请先添加明细数据'
                                });
                                return
                            }
                            
                            me.tableData.map(r=>{
                                if (r.qty == null || r.qty === "" || isNaN(r.qty) || r.qty == 0) {
                                    bo_ = false;
                                }
                                if (r.batch_no == null || r.batch_no === "") {
                                    batch_no_ = false;
                                }
                            })
                            if (!bo_) {
                                Root.message({
                                    type: 'error',
                                    message: '明细中存在数量为空的数据'
                                });
                                return
                            }
                            
                            // if (!batch_no_) {
                            //     Root.message({
                            //         type: 'error',
                            //         message: '明细中存在批号为空的数据'
                            //     });
                            //     return
                            // }
                            
                            
                            this.iscommit = true;
                            this.saveRowTable();
                        },
                        
                        //保存
                        saveRowTable() {
                            var me = this;
                            var operator_ = "saveEntity";//保存
                            if(me.iscommit) {
                                operator_ = "Commit";//提交
                            }
                            
                            var entity_ = clone(this.formData);
                            var entity = {};
                            for (var r in entity_) {
                                if (entity_[r] || entity_[r] == "" || entity_[r] == false || entity_[r] == 0) {
                                    entity[r] = entity_[r];
                                }
                            }
                            
                            var tableData_ = [];
                            this.tableData.map(r=>{
                                var row_ = {};
                                for (var k in r) {
                                    if (r[k]) {
                                        row_[k] = r[k];
                                    }
                                }
                                tableData_.push(row_);
                            })
                            
                            if (tableData_.length == 0) {
                                Root.message({
                                    type: 'warning',
                                    message: '请先添加明细数据'
                                });
                                return
                            }
                            
                            var bo_ = true;
                            var batch_no_ = true;
                            tableData_.map(r=>{
                                if (r.qty == null || r.qty === "" || isNaN(r.qty) || r.qty == 0) {
                                    bo_ = false;
                                }
                                if (r.batch_no == null || r.batch_no === "") {
                                    batch_no_ = false;
                                }
                            })
                            if (!bo_) {
                                Root.message({
                                    type: 'error',
                                    message: '明细中存在数量为空的数据'
                                });
                                return
                            }
                            
                            let param = {
                                dataname: this.dataname,
                                data: {},
                            }
                            param.data[this.dataname] = entity;
                            param.data[this.table_dataname] = tableData_;
                            
                            if (this.formData.id) {
                                param.id = this.formData.id
                            }
                            
                            Server.call("root/data/" + operator_, param, function(result) {
                                console.log(result);
                                if (result.success) {
                                    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) {
                                    me.iscommit = false;
                                    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 {
                                    if (me.iscommit) {
                                        Root.message({
                                            type: 'error',
                                            message: '提交失败'
                                        }); 
                                        me.iscommit = false;
                                    }
                                    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 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 class="h_dialog__body">
                                <div v-if="isedit || isrefuseedit" style=" text-align: right; margin-top: 20px;">
                                    <!-- 工具栏 -->
                                    <!-- <div style=" display: inline-block; width: 90px;">
                                        <el-button-group style="display: flex;justify-content: center;"> -->
                                            <!-- <el-button>批量导入</el-button>
                                            <el-button type = "danger" @click="delDetail">删 除</el-button>
                                            <el-button>导入模板下载</el-button> -->
                                            <!-- <el-button @click="addTableData">新增明细</el-button> -->
                                        <!-- </el-button-group>
                                    </div> -->
                                </div>
                                <h-table
                                    v-if="isRefresh && tableFields.length"
                                    ref="table1"
                                    :table-fields="tableFields" 
                                    :table-data="tableData" 
                                    :is-within-edit-table-data="isedit || isrefuseedit"
                                    :is-pagination="false"
                                    :is-highlight-row="true"
                                    :isdraggableorder="false"
                                    :isfilterfield="false"                                
                                    :table-field-click="tablefieldClick"
                                    :table-buttons-click="tablebuttonClick"                                
                                    
                                    v-on:get-data="getData"
                                    v-on:del-data="delData"
                                >
                                </h-table>
                            </div>
                            
                            
                        </div>
                    </div>
                    <div class="el-dialog__footer">
                        <el-button size="small" type="default" @click="closeDialog">取 消</el-button>
                        <el-button size="small" v-if="isedit || isrefuseedit" type="primary" @click="":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
                        <el-button size="small" v-if="isedit" type="success" @click="" :icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</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>