tom
2023-12-06 9e968679ed2e6937aeb7b50a6c450d5d19251f42
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
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
<!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 src="../../../jsnew/elementDefault.js?v=20220425"></script>
        <script src="../../../jsnew/vue/vue.js"></script>
        <script src="../../../jsnew/vue/element-ui/element-ui_15/index.js"></script>
        <script src="../../../jsnew/myelement.js?v=20220425"></script>
        <script src="../../../jsnew/page.js?v=20220425"></script>
        <!-- <script src="../../../setting.js"></script> -->
        
        <link href="../../../jsnew/vue/element-ui/element-ui_15/theme-chalk/index.css" rel="stylesheet">
        <link href="../../../jsnew/myelement.css?v=20220426" rel="stylesheet">
        <link href="../../../jsnew/theme.css?v=20220426" rel="stylesheet">
        <link href="../../../css/iconfont.css" rel="stylesheet">
        <link href="../../../jsnew/page.css?v=20220425" rel="stylesheet">
        <link href="//at.alicdn.com/t/font_2374495_13ltsxm2eor.css" rel="stylesheet">
    </head>
 
    <style>
        /*  在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
        [v-cloak] {
            display: none !important;
        }
    </style>
 
    <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=" text-align: right; padding: 5px 30px 0px 0px;"  v-if="!isedit">
                        <el-button size="small" type="primary" @click="">导 出</el-button>
                        <el-button-group>
                            <el-button size="small" v-if="isapproval" type="primary" @click="">批 准</el-button>
                            <el-button size="small" v-if="isapproval" type="primary" @click="">退 回</el-button>
                            <el-button size="small" v-if="isapproval" type="primary" @click="">拒 绝</el-button>
                            <el-button size="small" v-if="isapproval" type="primary" @click="">转 发</el-button>
                            <el-button size="small" v-if="isapproval" type="primary" @click="">转 办</el-button>
                        </el-button-group>
                        <!-- <el-button size="small" type="primary" v-if="isapproval" @click="">征询意见</el-button> -->
                        <el-button size="small" type="primary" @click="">打 印</el-button>
                        <el-button size="small" type="default" @click="closeDialog">取 消</el-button>
                    </div>
 
                    <div :style="{height: t_height +'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">
                                <!-- <el-alert
                                    v-if="!isend && !ischange"
                                    title="必须完整填写赠药明细,否则开票时无法关联赠药数量"
                                    type="warning"
                                    show-icon
                                    >
                                </el-alert> -->
 
                                <div v-if="isedit || isrefuseedit" style=" text-align: right; padding-top: 30px;">
                                    <!-- 工具栏 -->
                                    <div  style=" display: inline-block; width: 215px;">
                                        <el-button-group style="display: flex;">
                                            <el-button @click="selectData">新增明细</el-button>
                                            <el-button @click="">模板下载</el-button>
                                            <el-button @click="">导 入</el-button>
                                        </el-button-group>
                                    </div>
                                </div>
 
                                <h-table
                                    v-if="isRefresh && tableFields.length"
                                    ref="table1"
                                    :table-fields="tableFields" 
                                    :table-data="tableData" 
                                    :is-edit-table-data="isedit || isrefuseedit"
                                    :is-within-edit-table-data="isedit || isrefuseedit"
                                    :is-pagination="false"
                                    :table-field-click="tablefieldClick"
                                    :is-show-index="tableData.length ? true : false"
                                    :edit-table-button="editTableButton"
                                    :table-height="tableHeight"
                                    :isdraggableorder="false"
                                    
                                    v-on:get-data="getData"
                                    v-on:del-data="delData"
                                >
                                </h-table>
                            </div>
 
                            <div class="h_dialog__body"  style="padding-top: 30px;">
                                <h-form
                                    ref="form2"
                                    :form-attr="formAttr2"
                                    :table-fields="formFields2"
                                    :form-data="formData2"
                                    :table-field-click="formfieldClick"
                                    :is-end-colspan = "false"
                                >
                                </h-form>
                            </div>
 
                            <div v-if="!isedit" style="height: 150px; border-top: 15px;">
                                <!-- <iframe :src="'../../approval/ApprovalList_page.html?flow_id=' + flow_id" style="width: 100%; height: 100%; border: 0px;"></iframe> -->
                                <div style="width: 100%; height: 100%; border: 0px;">
                                    <div class="topbar">
                                        <span>审批记录</span>
                                        
                                        <div style="float: right; margin-right: 20px;">
                                            <el-button-group>
                                                <!-- <el-button :disabled="isexport_pdf" @click="" :loading="export_loading">导出</el-button> -->
                                                <el-button @click="">查看流程图</el-button>
                                                <!-- <el-button type="default" @click="closeDialog">关 闭</el-button> -->
                                            </el-button-group>
                                        </div>
                                    </div>
                                    <div class="versionNo">
                                        <h-table
                                            v-if="isRefresh"
                                            ref="table3"
                                            :table-fields="tableFields3" 
                                            :table-data="tableData3" 
                                            :table-height="tableHeight"
                                            :is-pagination="false"
                                        >
                                        </h-table>
                                        
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="el-dialog__footer" v-if="isedit">
                        <el-button size="small" type="default" @click="closeDialog">取 消</el-button>
                        <el-button size="small" v-if="(isedit || isrefuseedit) && !isend" type="primary" @click="saveRowTable">保 存</el-button>
                        <el-button size="small" v-if="isedit && !isend" type="success" @click="">提 交</el-button>
                        <el-button size="small" v-if="isend" type="primary" @click="">提交申请</el-button>
                        <el-button size="small" v-if="isrefuseedit" type="success" @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>
        
        <script type="text/javascript">
            function initVue() {
                new FormVue({
                    el: "#vbody",
                    data: {
                        dataname: "md_product_line",
                        table_dataname: "md_product_line.aaa_detail",
                        title: "表单+明细模板1",
 
                        formAttr: {
                            istitle: false,
                            title: "表单名称",
                            columnnumber: 3,
                            labelwidth: "140px",
                            labelposition: "left",//"left",// right//top
                            size: "mini",
                            border: "3px solid #c6c6c600"
                        },
                        default_formFields: [
                            {isshow: "T", field: "process_no", name: "流程号", type:"span", colspan: 3, required: true},
                            {isshow: "T", field: "apply_date", name: "申请日期", type:"span", type: "date", required: true},
                            {isshow: "T", field: "employee_code", name: "员工编号", required: true },
                            {isshow: "T", field: "apply_name", name: "申请人", type:"span", required: true},
                            {isshow: "T", field: "department", name: "所在部门", type:"span", required: true},
                            {isshow: "T", field: "apply_province", name: "申请省份", type:"select", required: true},
                            {isshow: "T", field: "remark", name: "备注", type:"textarea", required: false, colspan: 2},
                            // {isshow: "T", field: "process_type", name: "流程类型",},
                        ],
                        formFields: [],
                        newformData: {
                            biz_date: createDate(),
                            creator_code: window.top.vue.userinfo.employee.code,
                            creator_name: window.top.vue.userinfo.employee.name,
                            creator_depart_name: window.top.vue.userinfo.employee.hierarchyNodesStr,
                            type: 'ZYSQ',
                            status: 'input'
                        },
                        dataRequest: [
                            {
                                name: "md_province",
                                url: "rootjemin/data/getEntitySet",
                                paramsobj: {dataname: "md_division", filter: "level = '1'"},
                                isnotoption: false, //true:不是选项
                            }
                        ],
                        formData: {},
 
                        formAttr2: {
                            istitle: false,
                            title: "表单名称",
                            columnnumber: 2,
                            labelwidth: "140px",
                            labelposition: "left",//"left",// right//top
                            size: "mini",
                            border: "3px solid #c6c6c600"
                        },
                        default_formFields2: [
                            {isshow: "T", field: "summary", name: "折扣金额汇总", type: "span", colspan: 2},
                            {isshow: "T", field: "attachment_name", name: "附件", type: "uploadfilelist", colspan: 2},
                        ],
                        formFields2: [],
                        formData2: {
                            oa_code: "test123",
                        },
 
                        default_tableFields: [
                            {isshow: "T", field: "end_date", name: "结束时间", width: "100", type:"date", formatter: "formatter_date"},
                            {isshow: "T", field: "delivery_name", name: "发货主体", width: "200", type:"span",},
                            {isshow: "T", field: "customer_code", name: "商业编码", width: "150", type: "select",},
                            {isshow: "T", field: "customer_name", name: "商业名称", width: "200", type:"span",},
                            {isshow: "T", field: "product_code", name: "品种编码", width: "150", type:"select",},
                            {isshow: "T", field: "spec", name: "规格", width: "100", type: "span",},
                            {isshow: "T", field: "qty", name: "赠药数量", width: "100", type: "span",},
                            {isshow: "T", field: "price", name: "供货价", width: "100", type: "input", formatter: "formatter_money", align: "right"},
                            {isshow: "T", field: "discount", name: "折扣金额", width: "100", type: "input", formatter: "formatter_money", align: "right"},
                            {isshow: "T", field: "unit", name: "赠药单位", width: "100", type: "span",},
                            {isshow: "T", field: "second_price", name: "二级商业供货价", width: "150", type: "input", formatter: "formatter_money", align: "right"},
                            {isshow: "T", field: "store", name: "赠药药店", width: "100", type: "span",},
                            {isshow: "T", field: "store_price", name: "药店供货价", width: "100", type: "input", formatter: "formatter_money", align: "right"},
                            {isshow: "T", field: "hospital_code", name: "医院编码", width: "150", type: "select",},
                            {isshow: "T", field: "hospital_name", name: "医院名称", width: "200", type:"span",},
                            {isshow: "T", field: "pay_type", name: "支付方式", width: "100", type: "span"},
                            {isshow: "T", field: "policy", name: "赠药政策", width: "100", type: "span"},
                            {isshow: "T", field: "remark", name: "明细备注", type: "input", width: "150"}, 
                        ],
                        tableFields: [],
                        newTableData: {},
                        tableData: [],
 
                        default_tableFields3: [
                            {isshow: "T", field: "field1", name: "当前节点", width: "150", type:"span", required: true},
                            {isshow: "T", field: "field2", name: "申请/审批时间", width: "100", type:"span", formatter: "formatter_date", required: true, isminwidth: true,},
                            {isshow: "T", field: "field3", name: "审批情况", width: "150", type:"span", formatter: "formatter_date", required: true, isminwidth: true,},
                            {isshow: "T", field: "field4", name: "原因", width: "150", type: "span", required: true, isminwidth: true,},
                            {isshow: "T", field: "field5", name: "申请/审批人", width: "150", type:"span", required: true, isminwidth: true,}, 
                            {isshow: "T", field: "field6", name: "附件", width: "200", type:"span", required: true, isminwidth: true,}, 
                        ],
                        tableFields3: [],
                        tableData3: [],
                        
                        //字段设置
                        tablefieldClick: {},
                        formfieldClick: {},
 
                        //按键权限设置
                        isedit: false,//提交前编辑,保存/提交
                        isrefuseedit: false,//拒绝后编辑,保存/再次提交
                        isapproval: false,//审批,同意/拒绝/转办/退回
                        isend: false,
                        
                        iscommit: false,//提交标记
                        
                        //弹窗参数
                        popupParames: {},
 
                        flow_id: "c1355b3fd4b049f28135548d17f2071f",
                        t_height:null,
                        isRefresh: true,
                    },
                    created() {
                        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_;
                                }
                                
                                this.isedit = true;
                                
                                //动态获取默认数据
                                var newEntity_ = {
                                    name: "newEntity",
                                    url: "rootjemin/data/newEntity",
                                    paramsobj: {dataname: "pkg_grant_order"},
                                    isnotoption: true, //true:不是选项
                                }
                                this.dataRequest.push(newEntity_);
                            }
                            else if (this.popupParames.sceneCode == "browse") {//只读
                                this.formAttr.disabled = true;
                                this.formAttr2.disabled = true;
                            }
                            else if (this.popupParames.sceneCode == "edit") {//编辑
                                this.isedit = true;
                            }
                            else if (this.popupParames.sceneCode == "approval") {//审批
                                this.formAttr.disabled = true;
                                this.formAttr2.disabled = true;
                                this.isapproval = true;
                            }
                            else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
                                this.isrefuseedit = true;
                            }
                        }
                    },
                    
                    mounted() {
                        var me = this;
                        me.t_height = document.documentElement.clientHeight*1 - 91;
 
                        //预加载数据
                        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["grant_order"]);
                                    // formData.product_category_name = [];
                                    if (me.newformData) {
                                        let formData_ = clone(formData);
                                        
                                        for (var k in me.newformData) {
                                            if (!formData_[k]) {
                                                formData_[k] = me.newformData[k];
                                            }
                                        }
                                
                                        me.formData = formData_;
                                    }
                                }
                                
                                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
                        
                            if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
                                me.formFields2 = clone(me.default_formFields2);
                            }
                        
                            let param = {
                                dataname: "pkg_grant_order",
                            };
                            if (this.formData.id) {
                                param.id = this.formData.id;
                            }
                            Server.call("rootjemin/data/getEntity", param, function(result) {
                                if (result.success) {
                                    let formData_ = result.data['grant_order']
                                    let tableData_ = result.data['grant_order_detail']
                                    if (formData_) me.formData = formData_
                                    
                                    var metas = clone(result.meta['grant_order'].fields);
                                    var table_dataname_ = "grant_order_detail";
                                    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 == 'province_name') {
                                            me.dataRequestObj.md_province.data.entityset.map(e => {
                                                e.value = e.name
                                            })
                                            f.options = me.dataRequestObj.md_province.data.entityset
                                        }
                                        formFields_.push(clone(f));
                                    })
                                    table_metas.map(f=>{
                                        f.isshow = "T";
                                        if (me.popupParames.sceneCode == "add" && f.field == 'detail_code') {
                                            f.isshow = "F"
                                        }
                                        if (!f.appendix) {
                                            tableFields_.push(clone(f));
                                        }
                                    })
                        
                                    me.formFields = clone(formFields_);
                                    me.tableFields = clone(tableFields_);
                                    //字段数组转字段obj
                                    me.fieldsToFieldsObj();
                                
                                    //设置字段事件
                                    me.tableFieldClick();
                                }
                            });
                        },
 
                        selectData() {
                            var me = this;
                            
                            if (!this.formData.province_code) {
                                Root.message({
                                    type: 'warning',
                                    message: '请先选择省份'
                                })
                                return
                            }
                            
                            let filter = " type = 'zyzc' and status = 'open' and freeze <> 'T' and province_code = '" + this.formData.province_code + "'"
                            if (me.tableData.length > 0) {
                                let str = ''
                                me.tableData.map(s => {
                                    if (!str) {
                                        str = "'" + s.old_id + "'"
                                    }
                                    else {
                                        str += ",'" + s.old_id + "'"
                                    }
                                })
                                
                                if (str) {
                                    filter += " and ar.id not in (" + str + ")"
                                }
                            }
                            
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "900px",
                                height: "900px",
                                icon: "icon-product",
                                text: "请选择赠药政策明细数据",
                                id: "popup_medicine_policy_info_list",//totab: true时需设置,用于判断是否已打开此页面
                                url: "../agreement/policy/popup_policy_info_list.html",
                                dataname: "agm_record_zyzc",
                                filter: filter,
                                data: {},
                                delta: {},
                                sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(data, callback) {
                                    let tableData_ = clone(me.tableData)
                                    data.map(e => {
                                        e.termination_operate_code = window.top.vue.userinfo.employee.code
                                        e.termination_operate_name = window.top.vue.userinfo.employee.name
                                        e.old_id = JSON.parse(JSON.stringify(e.id))
                                        e.id = null
                                        e.parent_id = me.formData.id
                                        
                                        tableData_.push(e)
                                    })
                                    me.tableData = tableData_
                                    
                                    if (callback) {
                                        callback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
 
                        newEndDeatil() {
                            var me = this;
                            
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "900px",
                                height: "900px",
                                icon: "icon-product",
                                text: "请选择要终止的赠药申请明细数据",
                                id: "popup_terminal_policy_info_list",//totab: true时需设置,用于判断是否已打开此页面
                                url: "../agreement/policy/popup_terminal_policy_info_list.html",
                                data: {},
                                delta: {},
                                sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(obj, callback) {
                                    if (callback) {
                                        callback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
                        
                        tableFieldClick() {
                            var me = this;
                            //表单字段事件设置
                            this.formfieldClick = {
                                attachment_name: {
                                    buttonarray: {
                                        onclick: function(obj) {
                                            var filenamefield = obj.obj.field;
                                            var fileidfield = "attachment_name";
                                            if(obj.buttonobj && obj.buttonobj.code == "showfilebyfile"){
                                                me.showFileImgByFileId(obj.buttonobj.fileobj);
                                            }else if (obj.buttonobj && obj.buttonobj.code == "uploadlist"){
                                                me.onPopupByUploadFile(filenamefield, fileidfield, me.dataname);
                                            }else if (obj.buttonobj && obj.buttonobj.code == "delfilebyfile"){
                                                me.deleteByFileId(filenamefield, obj.buttonobj.fileobj);
                                            }
                                        }
                                    }
                                },
                                province_name: {
                                    select: {
                                        onchange: function(obj) {//下拉展开事件
                                            if (me.formData.province_code && me.tableData.length > 0) {
                                                Root.confirm('切换省份将清空明细,请确认', '提示', {
                                                  confirmButtonText: '确认',
                                                  cancelButtonText: '取消',
                                                  type: 'warning'
                                                }).then(() => {
                                                    obj.data.province_code = obj.selectoption.code
                                                    obj.data.province_name = obj.selectoption.name
                                                    
                                                    me.tableData = []
                                                }).catch(() => {
                                                    let formData = clone(me.formData)
                                                    formData.province_code = me.province_code_old
                                                    formData.province_name = me.province_name_old
                                                    me.formData = formData
                                                });
                                            }
                                            else {
                                                obj.data.province_code = obj.selectoption.code
                                                obj.data.province_name = obj.selectoption.name
                                                me.province_code_old = obj.selectoption.code
                                                me.province_name_old = obj.selectoption.name
                                            }
                                        }
                                    },
                                }
                            };
                            
                            //表格字段事件设置
                            this.tablefieldClick = {
                                delivery_part_name: {
                                    select: {
                                        onchange: function(obj) {
                                            let tableData = clone(me.tableData)
                                            tableData[obj.$index]['delivery_part_code'] = obj.selectoption.code
                                            tableData[obj.$index]['delivery_part_name'] = obj.selectoption.label
                                            me.tableData = tableData
                                        }
                                    }
                                },
                                terminal_price: {
                                    visible: {
                                        onchange: function(fieldObj, callback, scope) {//下拉展开事件
                                            let row = scope.row
                                            
                                            if (!row.delivery_part_code) {
                                                callback([])
                                                return
                                            }
                                            
                                            let param_ = {
                                                dataname: "agm_record_syzc",
                                                filter: " type = 'syzc' and status = 'open' and freeze <> 'T' and delivery_part_code = '" + row.delivery_part_code + "' and customer_code = '" + row.customer_code + "' and product_code = '" + row.product_code + "' "
                                            }
                                            Server.call("rootjemin/data/getEntitySet", param_, function(result) {
                                                if (result && result.data) {
                                                    var options_ = result.data.entityset;
                                                    for(var i=0; i<options_.length;i++) {
                                                        options_[i].code = options_[i].supply_price;
                                                        options_[i].value = options_[i].supply_price;
                                                    }
                                                    
                                                    callback({options: options_})
                                                }
                                            });
                                        }
                                    },
                                    select: {
                                        onchange: function(obj) {
                                            let tableData = clone(me.tableData)
                                            if (tableData[obj.$index]['cnt'])
                                            tableData[obj.$index]['amt'] = parseFloat(obj.selectoption.code) * parseFloat(tableData[obj.$index]['cnt'])
                                            me.tableData = tableData
                                        }
                                    }
                                },
                                cnt: {
                                    input: {
                                        onchange: function(obj) {
                                            let tableData = clone(me.tableData)
                                            if (tableData[obj.$index]['terminal_price'])
                                            tableData[obj.$index]['amt'] = parseFloat(obj.row.cnt) * parseFloat(tableData[obj.$index]['terminal_price'])
                                            me.tableData = tableData
                                        }
                                    }
                                },
                                grant_target: {
                                    select: {
                                        onchange: function(obj) {
                                            if (obj.selectoption.code && obj.selectoption.code == "business") {
                                                
                                            }
                                            else if (obj.selectoption.code && obj.selectoption.code == "terminal") {
                                                let tableData = clone(me.tableData)
                                                tableData[obj.$index]['grant_customer_name'] = null
                                                tableData[obj.$index]['business_price'] = null
                                                me.tableData = tableData
                                            }
                                        }
                                    }
                                },
                                grant_customer_name: {
                                    cssname: function(row,  callback) {
                                        var classname_ = "h_business"
                                        if (row.grant_target == "terminal") {
                                            classname_ = "h_terminal";
                                        }
                                        callback(classname_)
                                    }
                                },
                                business_price: {
                                    cssname: function(row,  callback) {
                                        var classname_ = "h_business"
                                        if (row.grant_target == "terminal") {
                                            classname_ = "h_terminal";
                                        }
                                        callback(classname_)
                                    }
                                },
                                network_name: {
                                    popup: {
                                        onclick: function(obj) {//弹窗点击事件
                                            let filter = " type = 'zyzc' and status = 'open' and freeze <> 'T' and province_code = '" + me.formData.province_code + "'"
                                            var config = {
                                                totab: false, //true: 以Tab导航的方式打开
                                                width: "900px",
                                                height: "900px",
                                                icon: "icon-product",
                                                text: "选择网点",
                                                id: "popup_medicine_policy_info_list",//totab: true时需设置,用于判断是否已打开此页面
                                                url: "../agreement/policy/popup_policy_info_list.html",
                                                dataname: "agm_record_zyzc",
                                                filter: filter,
                                                data: {},
                                                delta: {isSelects: "F"},
                                                sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
                                                callback: function(data, callback) {
                                                    let tableData = clone(me.tableData)
                                                    
                                                    let policyId = clone(data.row.id)
                                                    data.row.id = null
                                                    tableData[obj.$index] = data.row
                                                    tableData[obj.$index]['agreement_id'] = policyId
                                                    
                                                    me.tableData = tableData
                                                    
                                                    if (callback) {
                                                        callback();
                                                    }
                                                }
                                            };
                                            me.doPopupByPublic(config);
                                        }
                                    },
                                },
                            };
                        
                        },
 
                        onPopupByUploadFile(filenamefield, fileidfield,dataname) {
                            var me = this;
                            var analysistype_ = "";
                            var formData_ = clone(me.formData);
                            var delta_ = {filetypelist: []}//".png", ".jpg", ".pdf"
                            var config = {
                                totab: false,
                                width: "500px",
                                icon: "icon-product",
                                text: "附件上传",
                                id: "popupByUploadFile",
                                url: "../tool/popup_uploadFile.html",
                                data: {
                                    dataName: dataname,
                                    fileidfieldName: fileidfield,
                                    id: me.formData.id,
                                    fileNamefieldName: filenamefield,
                                    max_size: "100MB",
                                },
                                delta: delta_,
                                callback: function(obj, callback) {
                                    me.$message({
                                        showClose: true,
                                        message: '上传成功!',
                                        type: 'success'
                                    });
                                    
                                    var file_ = {
                                        id: obj.row[0].id,
                                        file_name: decodeURI(obj.row[0].name)
                                    }
                                    if (!formData_[filenamefield]) {
                                        formData_[filenamefield] = []
                                    }
                                    formData_[filenamefield].push(file_);
                                    
                                    me.formData = formData_;
                                    if (callback) {
                                        callback();
                                    }
                                }
                            };
                            this.doPopupByPublic(config);
                        },
 
                        deleteByFileId(filenamefield, fileobj){
                            var me = this;
                            var formData_ = clone(me.formData);
                            Root.confirm('确定删除附件【' + fileobj.file_name + '】吗?', '删除提示', {
                              confirmButtonText: '删除',
                              cancelButtonText: '取消',
                              type: 'warning'
                            }).then(() => {
                                if (fileobj.id) {
                                    let param = {
                                        dataname: "file_index",
                                        id: fileobj.id
                                    }
                                    
                                    Server.call("root/data/deleteEntity", param, function(result) {
                                        console.log(result);
                                        if (result && result.data) {
                                            me.formData[filenamefield].remove(fileobj);
                                            // me.formData = formData_;
                                            Root.message({
                                                type: 'success',
                                                message: '删除成功!'
                                            });
                                        }
                                    });
                                }
                            }).catch(() => {
                                Root.message({
                                    type: 'info',
                                    message: '已取消删除'
                                });          
                            });
                            
                        },
                        
                        showFileImgByFileId(fileobj) {
                            let me = this;
                            var file_id = fileobj.id;
                            var file_name = fileobj.file_name;
                            
                            this.zzimg = {};
                            this.zzimgList = [];
                            this.file_txt = false;
                            if(file_id) {
                                var fileid = file_id;
                                let fileName = clone(file_name);
                                let index1 = fileName.lastIndexOf(".");
                                let index2 = fileName.length;
                                let suffix = fileName.substring(index1, index2).toLowerCase(); //后缀名
                                if (suffix == ".png" || suffix == ".jpg" || suffix == ".pdf") {
                                    var row = {
                                        fileid: fileid,
                                        filename: fileName
                                    }
                        
                                    var config = {
                                        totab: false,
                                        width: "1200px",
                                        height: 800,
                                        icon: "icon-product",
                                        text: "附件预览",
                                        id: "pdf_" + fileid,
                                        url: "module/tool/page/popup_file_pdf.html",
                                        data: row,
                                        delta: {},
                                        callback: function(obj, callback) {
                                            if (callback) {
                                                callback();
                                            }
                                        }
                                    };
                                    this.doPopupByPublic(config);
                        
                                }
                                else {//只可下载,不可预览
                                    // handleDownloadUrl(fileid,false);
                                    handleDownload(fileid);
                                }
                            }
                        },
                        
                        
                        
                        addTableData() {
                            var table_row = clone(this.newTableData);
                            this.rowChange(table_row, "add", this.table_dataname);
                        },
                        
                        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(() => {
                                
                            });
                        },
                        
                        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() {
                            this.iscommit = true;
                            this.saveRowTable();
                        },
                        
                        //保存
                        saveRowTable() {
                            var me = this;
                            
                            if(me.iscommit) {
                                var bo = me.$refs.form1.checkForm();
                                
                                if(!bo) {
                                    Root.message({
                                        type: 'warning',
                                        message: '请填写必填项'
                                    });
                                    return;
                                }
                                
                                this.formData.readed = "F"
                            }
                            
                            var operator_ = "save";//保存
                            if(me.iscommit) {
                                operator_ = "commit";//提交
                            }
                            
                            var entity_ = clone(this.formData);
                            var entity = {};
                            for (var r in entity_) {
                                if (entity_[r]) {
                                    entity[r] = entity_[r];
                                }
                            }
                            entity.update_time = ''
                            
                            var tableData_ = [];
                            this.tableData.map(r=>{
                                var row_ = {};
                                for (var k in r) {
                                    if (r[k]) {
                                        row_[k] = r[k];
                                    }
                                }
                                tableData_.push(row_);
                            })
                            
                            let fileList = []
                            if (me.formData2.attachment_name && me.formData2.attachment_name.length > 0) {
                                me.formData2.attachment_name.map(s => {
                                    fileList.push({
                                        type: "grant_order",
                                        file_id: s.id,
                                        file_name: s.file_name
                                    })
                                })
                            }
                            
                            if (tableData_.length == 0) {
                                Root.message({
                                    type: 'warning',
                                    message: '请先添加明细数据'
                                });
                                return
                            }
                            
                            let param = {
                                dataName: 'pkg_grant_order',
                                data: {
                                    grant_order: entity,
                                    grant_order_detail: tableData_,
                                    grant_order_file: fileList
                                },
                            }
                            Server.call("rootjemin/data/saveEntity", param, function(result) {
                                console.log(result);
                                if (result.success) {
                                    if(me.iscommit){
                                        me.iscommit = false;
                                        me.doSubmit(param.data.grant_order.id);
                                    }
                                    else {
                                        Root.message({
                                            type: 'success',
                                            message: '保存成功'
                                        }); 
                                        me.saveAfter();
                                    }
                                }
                            });
                        },
                        doSubmit(id) {
                            let me = this;
                            let pa = {
                                dataName: "grant_order",
                                id: id,
                                flow_id: this.formData.flow_id || "",
                                business_type: "grandOrder"
                            }
                            Server.call("rootjemin/data/Commit", pa, function(result) {
                                if (result.success) {
                                    Root.message({
                                        type: 'success',
                                        message: '提交成功'
                                    }); 
                                    window.top.vue.setMenuBadgeByMenuid('A10-22', 'grandOrder');
                                    me.saveAfter();
                                }
                            }, function(result) {
                                if (result.messages && result.messages.list && result.messages.list.length > 0){
                                    let str = ''
                                    result.messages.list.map(e => {
                                        if (!str) str += "<div style='max-height:200px; width: 340px; overflow: auto;'>" + e.message
                                        else {
                                            str += "</br></br> " + e.message
                                        }
                                    })
                                    
                                    Root.message({
                                        dangerouslyUseHTMLString: true,
                                        type: 'error',
                                        message: str
                                    }); 
                                }
                            });
                        }
                        
                    }
                });
            };
 
            initVue();
        </script>
        
        <style>
            .a:hover{
                background-color: #FFFFFF;
            }
            .el-input__inner{
                padding: 0 2px;
            }
            .header {
                height: 21px;
            }
            .el-dialog_header {
                padding: 10px 20px;
                border-bottom: 1px solid #ccc;
                right: 10px;
                left: 10px;
                top: 0px;
                position: fixed;
            }
            .el-dialog_body{
                padding: 20px;
                
                overflow-y: auto;
                right: 10px;
                left: 10px;
                top: 42px;
                bottom: 50px;    
                position: fixed;
            }
            .el-dialog_footer {
                padding: 10px 20px;
                border-top: 1px solid #ccc;
                right: 10px;
                left: 10px;
                bottom: 0px;
                position: fixed;
                background-color: #fff;
                z-index: 10;
                text-align: right;
            }
            html{
                overflow-y: hidden;
            }
            .h_terminal .el-input__inner {
                pointer-events: none;
                border: 1px solid #DDD;
                background-color: #F5F5F5;
                color: #ACA899;
            }
 
            /* .el-button--mini {
                color: #FFF;
                background-color: #2984e2;
                border-color: #409EFF;
            } */
        </style>
        
    </body>
</html>