zhangyanpeng
2024-05-29 1f227a1cf627526701c652ba84bae3e430bba8d3
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
<!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 = [
                    {id: "css_m1", type: "css", url: "root/css/tree.css"},
                    {id: "css_m2", type: "css", url: "root/module/config/css/approval_img.css"},
                ];
                window.top.initJsCss(document, jscss_urls, callback);
            };
            
            function initVue() {
                new TreeVue({
                    el: "#vbody",
                    data: {
                        dataname: "md_product_category",
                        title: "节点人员",
                        tree_title: "审批类型",
                        treeTxtFormatter: "{name}",
                        isTreeReadonly: true,
                        dataRequest: [],
                        selectednode: {},
                        initTreeData_d: [
                            {id: "C0", name: "商业审批",
                                children: [
                                    {id: "C1", name: "商业创建审批", dataname: "md_org_data", filtertxt: "state_code='UnderApproval' and state_detail_code='UnderMasterApproval'", orderby: "update_time desc", pageurl: "module/md/page/customer/page/customer_edit.html"},
                                    {id: "C2", name: "商业开户商务审批", dataname: "md_org_account", filtertxt: "state_code='WaitOpen' and state_detail_code in ('BusinessApproval')", orderby: "update_time desc", pageurl: "module/md/page/customer/page/customer_acct.html"},
                                    {id: "C4", name: "商业开户财务审批", dataname: "md_org_account", filtertxt: "state_code='WaitOpen' and state_detail_code='FinancialApproval'", orderby: "update_time desc", pageurl: "module/md/page/customer/page/customer_acct.html"},
                                    {id: "C5", name: "商业开户QA审批", dataname: "md_org_account", filtertxt: "state_code='WaitOpen' and state_detail_code='QualityAssuranceApproval'", orderby: "update_time desc", pageurl: "module/md/page/customer/page/customer_acct.html"},
                                    {id: "C8", name: "商业开户审批", dataname: "md_org_account", filtertxt: "state_code='UnderApproval' and state_detail_code='UnderOpenApproval'", orderby: "update_time desc", pageurl: "module/md/page/customer/page/customer_acct.html"},
                                    {id: "C3", name: "商业变更审批", dataname: "md_org_account", filtertxt: "state_code='UnderApproval' and state_detail_code='UnderChangeApproval'", orderby: "update_time desc"},
                                    {id: "C7", name: "商业关户审批", dataname: "md_org_account", filtertxt: "state_code='UnderApproval' and state_detail_code='UnderCloseApproval'", orderby: "update_time desc", pageurl: "module/md/page/customer/page/customer_close.html"},
                                ]
                            },
                            {id: "H0", name: "医院审批",
                                children: [
                                    {id: "H2", name: "医院库变更审批", dataname: "md_terminal", filtertxt: "state_code='UnderApproval'", orderby: "update_time desc", pageurl: "module/md/page/terminal/page/hospital_list_warehouse_info.html"},
                                ]
                            },
                            {id: "O0", name: "订单审批",
                                children: [
                                    {id: "O1", name: "普通订单审批", dataname: "general_sales_order", filtertxt: "state_code='UnderApproval' and type_code = '30-01'", orderby: "update_time desc", pageurl: "module/order/page/porder_general_info.html"},
                                    {id: "O2", name: "直销订单审批", dataname: "direct_sales_order", filtertxt: "state_code='UnderApproval' and type_code in ('30-04', '30-Cxx-03')", orderby: "update_time desc", pageurl: "module/order/page/direct_order_list_info.html"},
                                    {id: "O3", name: "折扣订单审批", dataname: "discount_order", filtertxt: "state_code='UnderApproval' and type_code in ('30-Cxx-01', '30-Cxx-02', '30-Cxx-04')", orderby: "update_time desc", pageurl: "module/order/page/discount_order_list_info.html"},
                                ]
                            },
                            {id: "I0", name: "库存审批",
                                children: [
                                    {id: "I1", name: "库存调整审批", dataname: "wm_alter", filtertxt: "state_code='UnderApproval'", orderby: "update_time desc", pageurl: "module/inventory/page/adjustment_edit.html"},
                                ]
                            },
                        ],
                        dataname_p: "md_product",
                        pagesize_p: 10,
                        pagenum_p: 1,
                        total_p: 0,
                        tableData_p: [
                        ],
                        tableFields_p: [
                            {isshow: "T", field: "number", name: "节点顺序", align: "center",width: "100"},
                            {isshow: "T", field: "node_name", name: "节点名称", align: "center", width: "150", isminwidth: true},
                            {isshow: "T", field: "state_name", name: "对应状态名称", align: "center", width: "150", isminwidth: true},
                            {isshow: "T", field: "", name: "动作", children: [
                                {isshow: "T", field: "approve_node", name: "通过后节点", width: "120", isminwidth: true},
                                {isshow: "T", field: "reject_node", name: "拒绝后节点", width: "120", isminwidth: true},
                            ]},
                        ],
                        isRefresh_p: true,
                        tableHeight_p: 100,
                        
                        tableFields_s_p: [
                            {isshow: "T", field: "writer_name", name: "审批人", align: "center",width: "150", isminwidth: true},
                            {isshow: "T", field: "position_code", name: "岗位编码", align: "center", width: "150", isminwidth: true},
                            {isshow: "T", field: "position_name", name: "职位名称", align: "center", width: "150", isminwidth: true},
                        ],
                        tableData_s_p: [],
                        tablefieldClick: {},
                        isTreeRefresh: true,
                        isshowflow: false,
                    },
                    created() {
                        let clientHeight = document.documentElement.clientHeight;
                        this.treeHeight = clientHeight - 120;
                        var dataRequest_ = {
                            name: "md_approval",
                            paramsobj: {
                                filter: "rolecode like '%|" + window.top.vue.userinfo.currentactor.code + "|%'"
                            },
                            url: "root/workflow/getOutline",
                            isnotoption: true,
                        }
                        this.tableHeight_p = this.treeHeight / 2 - 10;
                        this.dataRequest.push(dataRequest_);
                    },
                    
                    mounted() {
                        var me = this;
                        //预加载数据
                        if (this.dataRequest && this.dataRequest.length) {
                            var result = {};
                            this.loadRequestData(this.dataRequest, result, function(data) {
                                // console.log("预加载数据:", data);
                                me.dataRequestObj = data;
                                let md_approval_ = ArrayToTree(clone(data.md_approval.data), "name", "parent_id");
                                me.initTreeData_d = md_approval_;
                                
                                var medataRequest_ = []
                                me.initData();
                                // 以服务的方式调用的 Loading 需要异步关闭
                                me.$nextTick(() => { 
                                    hideLoading();
                                });
                            });
                        }
                        else {
                            this.initData(); // 以服务的方式调用的 Loading 需要异步关闭
                            this.$nextTick(() => { 
                                hideLoading();
                            });
                        }
                    },
                    
                    methods:{
                        initData() {
                            var me = this;
                            me.treeData = me.initTreeData_d;
                        },
                        
                        onNodeClick(obj) {
                            this.tableData_p = [];
                            this.isshowflow = true;
                            var data = obj.data, node = obj.node, el = obj.el;
                            var val = data.name;
                            if (data.children && data.children.length) {
                                val = "";
                                data.children.map(r=>{
                                    if (val == "") {
                                        val = r.name;
                                    }
                                    else {
                                        val += "','" + r.name;
                                    }
                                })
                            }
                            
                            this.selectednode = data;
                            this.pagenum_p = 1;
                            if (this.selectednode.dataname) {
                                this.getDataByStep(this.selectednode.machine_id);
                            }
                        },
                        
                        getDataByStep(dname) {
                            var me = this;
                            if (!this.selectednode.id) {
                                return
                            }
                            var param_ = {
                                dataname: "sys_state_machine_step",
                                parent_id: this.selectednode.machine_id,
                            }
                            Server.call("root/data/getEntitySet", param_, function(result) {
                                if (result) {
                                    let i = 1;
                                    var tableData_p_ = clone(me.tableData_p)
                                    result.data.entityset.map(e=>{
                                        var obj = {
                                            number : i,
                                            node_name : e.name,
                                            id: e.id,
                                        }
                                        tableData_p_.push(obj);
                                        i++;
                                    })
                                    me.tableData_p = tableData_p_;
                                    if(result.data.entityset[0] && result.data.entityset[0].state_id){
                                        me.getDataByState(result.data.entityset,dname);
                                    }
                                }
                            })
                        },
                        
                        getDataByState(stateIdarr,dname){
                            var me = this;
                            stateIdarr.map((e,index)=>{
                                var param_ = {
                                    dataname: "sys_state_machine_state",
                                    id: e.state_id,
                                }
                                Server.call("root/data/getEntitySet", param_, function(result) {
                                    if (result) {
                                        let tableData_p_ = clone(me.tableData_p)
                                        tableData_p_[index].state_name = result.data.entityset[0].name;
                                        me.tableData_p = clone(tableData_p_);
                                        
                                        if(result.data.entityset[0] && result.data.entityset[0].detail_code){
                                            me.getDataByDetail(result.data.entityset[0].detail_code,dname,"d",index);
                                        }else {
                                            me.getDataByDetail(result.data.entityset[0].code,dname,"c");
                                        }
                                        // if(result.data.entityset[index] && result.data.entityset[index].code){
                                        // }
                                    }
                                })
                            })
                        },
                        
                        getDataByDetail(code,dname,flag,index){
                            var me = this;
                            if(flag == "c"){
                                var param_ = {
                                    dataname: "sys_state_machine_detail",
                                    filter: " from_code='"+code+"' and parent_id='"+ dname +"'",
                                }
                                Server.call("root/data/getEntitySet", param_, function(result) {
                                    if (result) {
                                        var tableData_p_ = clone(me.tableData_p)
                                        if(result.data.entityset[0] && result.data.entityset[0].to_code){
                                            tableData_p_[0].approve_node = result.data.entityset[0].to_code;
                                            tableData_p_[0].reject_node = result.data.entityset[1].to_code;
                                        }
                                        me.tableData_p = tableData_p_;
                                        me.getDataByDetailName(result.data.entityset,"c");
                                    }
                                })
                            }
                            
                            if(flag == "d"){
                                var param_ = {
                                    dataname: "sys_state_machine_detail",
                                    filter: " from_detail_code='"+code+"' and parent_id='"+ dname +"'",
                                }
                                Server.call("root/data/getEntitySet", param_, function(result) {
                                    if (result) {
                                        var tableData_p_ = clone(me.tableData_p)
                                        
                                        if(result.data.entityset[0] && result.data.entityset[0].to_code){
                                            tableData_p_[index].approve_node = result.data.entityset[0].to_code;
                                            tableData_p_[index].reject_node = result.data.entityset[1].to_code;
                                        }
                                        
                                        me.tableData_p = tableData_p_;
                                        me.getDataByDetailName(tableData_p_[index],"d",index);
                                    }
                                })
                            }
                            
                        },
                        
                        getDataByDetailName(data,flag,index){
                            var me = this;
                            if(flag=="d"){
                                var param_ = {
                                    dataname: "sys_state_machine_state",
                                    filter: " code='"+data.approve_node+"' ",
                                }
                                Server.call("root/data/getEntitySet", param_, function(result) {
                                    if (result) {
                                        var tableData_p_ = clone(me.tableData_p)
                                        tableData_p_[index].approve_node = result.data.entityset[0].name;
                                        me.tableData_p = tableData_p_;
                                    }
                                })
                                
                                var param_1 = {
                                    dataname: "sys_state_machine_state",
                                    filter: " code='"+data.reject_node+"' ",
                                }
                                Server.call("root/data/getEntitySet", param_1, function(result) {
                                    if (result) {
                                        var tableData_p_ = clone(me.tableData_p)
                                        tableData_p_[index].reject_node = result.data.entityset[0].name;
                                        me.tableData_p = tableData_p_;
                                    }
                                })
                            }
                            if(flag=="c"){
                                var tableData_p_ = clone(me.tableData_p)
                                var param_ = {
                                    dataname: "sys_state_machine_state",
                                    filter: " code='"+me.tableData_p[0].approve_node+"' ",
                                }
                                Server.call("root/data/getEntitySet", param_, function(result) {
                                    if (result) {
                                        tableData_p_[0].approve_node = result.data.entityset[0].name;
                                    }
                                })
                                
                                var param_1 = {
                                    dataname: "sys_state_machine_state",
                                    filter: " code='"+me.tableData_p[0].reject_node+"' ",
                                }
                                Server.call("root/data/getEntitySet", param_1, function(result) {
                                    if (result) {
                                        
                                        tableData_p_[0].reject_node = result.data.entityset[0].name;
                                        
                                    }
                                })
                                me.tableData_p = tableData_p_;
                            }
                            
                        },
                        
                        onTableDataAfter() {
                            
                        },
                        
                        tableFieldClick() {
                            var me = this;
                            
                            //表格字段事件设置
                            this.tablefieldClick = {
                                
                            };
                        },
                        
                        onQueryAfter() {
                            this.pagenum_p = 1;
                            this.tableData_p = [];
                            this.total_p = 0;
                        },
                        
                        getData_p(page) {
                            this.pagesize_p = page.pagesize;
                            this.pagenum_p = page.pagenum;
                            
                            this.getDataByNode();
                        },
                        
                        rowClick(obj){
                            var me = this;
                            this.selectedrow = obj.row;
                            var param_ = {
                                dataname: "sys_state_machine_user",
                                filter: " step_id='"+this.selectedrow.id+"' ",
                            }
                            Server.call("root/data/getEntitySet", param_, function(result) {
                                if (result) {
                                    var tableData_s_p_ = clone(me.tableData_s_p);
                                    tableData_s_p_ = result.data.entityset;
                                    me.tableData_s_p = tableData_s_p_;
                                }
                            })
                        },
                        
                    }
                });
            };
            
            loadJsCss(function () {
                initVue();
            });
        </script>
        <style>
            /*  在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
            [v-cloak] {
                display: none !important;
            }
            .el-tabs__nav-scroll {
                overflow: hidden;
                position: relative;
                padding-left: 20px;
            }
            
            .nodeLabel {
                max-width: 200px !important;
            }
        </style>
        
    </head>
    
    <body style="margin: 0px;">
        <div v-cloak id="vbody">
            <div id="page_root">
                <div class="topbar">
                    <span>{{title}}</span>
                    
                    <div style="float: right; margin-right: 18px;">
                        <el-button-group style="margin-left: 3px;">
                        </el-button-group>
                    </div>
                </div>
                
                <div class="h_dialog__body">
                    <div style="position: absolute;left: 10px; top:45px;width: 320px; bottom: 10px;border: 1px solid #ccc;">
                        <div style="height: 32px;line-height: 32px;border-bottom: 1px solid #ccc ;">
                            <span style="font-size: 14px;margin-left: 20px;">{{tree_title}}</span>
                        </div>
                        <div :style="{padding: '10px 0', height: treeHeight + 'px', overflow: 'auto'}">
                            <h-tree v-if="isTreeRefresh"
                                :tree-data="treeData"
                                :tree-txt-formatter="treeTxtFormatter"
                                :is-readonly="isTreeReadonly"
                                :default-expanded-keys="defaultexpandedkeys"
                                :currentnodekey="currentnodekey"
                                :default-expand-all="true"
                                
                                @node-click="onNodeClick"
                                >
                            </h-tree>
                            
                        </div>
                    </div>
                    <div style="position: absolute;left: 340px; top:45px; right: 10px; bottom: 10px;border: 1px solid #ccc;">
                        <div>
                            <div style="height: 32px; border-bottom: 1px solid #ccc;">
                                <div class="table_title" style="float: left;">
                                    <span>步骤详情</span>
                                </div>
                            </div>
                            <h-table 
                                v-if="isshowflow"
                                ref="table_p"
                                :table-fields="tableFields_p" 
                                :table-data="tableData_p" 
                                :pagesize="pagesize_p"
                                :pagenum="pagenum_p"
                                :total="total_p"
                                :table-height="tableHeight_p - 52"
                                :is-highlight-row="true"
                                :table-field-click="tablefieldClick"
                                :is-pagination="false"
                                
                                v-on:get-data="getData_p"
                                v-on:row-click="rowClick"
                            >
                            </h-table>
                            <div style="height: 32px; margin-top: 20px;" v-if="isshowflow">
                                <div class="table_title" style="float: left;">
                                    <span> <span v-if="selectedrow && selectedrow.node_name">【{{selectedrow.node_name}}】</span>对应审批人</span>
                                </div>
                            </div>
                            <div :style="{height: (tableHeight_p) + 'px'}">
                                <h-table
                                    v-if="isshowflow"
                                    ref="table_p"
                                    :table-fields="tableFields_s_p" 
                                    :table-data="tableData_s_p" 
                                    :table-height="tableHeight_p"
                                    :is-highlight-row="true"
                                    :table-field-click="tablefieldClick"
                                    :is-pagination="false"
                                >
                                </h-table>
                            </div>
                        </div>
                    </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>