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
<!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"},
                ];
                window.top.initJsCss(document, jscss_urls, callback);
            };
            
            function initVue() {
                new TreeVue({
                    el: "#vbody",
                    data: {
                        dataname: "sys_page_report", // "md_prod_category",
                        title: "报表管理",
                        tree_title: "报表菜单",
                        treeTxtFormatter: "{title}",
                        isTreeReadonly: true,
                        
                        currentnodekey: "",
                        filter_node_val: "1<>1",
                        
                        edition_data_page: "./report_iframe.html",
                    },
                    created() {
                        
                    },
                    
                    mounted() {
                        var me = this;
                        //获取数据
                        me.initData();
                        me.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
                            hideLoading();
                        });
                    },
                    
                    methods:{
                        initData() {
                            var me = this;
                            this.onQuery(function(result, callback) {//查询后的回调,用于获取字段的
                                var treeData_ = [];
                                var buobj_ = {};
                                me.treeData = clone(me.initTreeData);
                                // let initTreeData_ = ArrayToTree(clone(me.initTreeData), "name", "parent_id", null, null, null);
                                // me.treeData = initTreeData_;
                                
                                if (callback) {
                                    callback();
                                }
                                
                                if(me.treeData[0]) {
                                    const leafNode = me.findLeafNode(me.treeData[0]);
                                    let objInit = {
                                        data: leafNode,
                                        node: {},
                                        el: {},
                                    };
                                    me.currentnodekey = leafNode.id;
                                    me.onNodeClick(objInit);
                                }
                            });
                        },
 
                        findLeafNode(node) {
                            if (!node.children || node.children.length === 0) {
                                return node;
                            }
                            for (let i = 0; i < node.children.length; i++) {
                                const child = node.children[i];
                                const leafNode = this.findLeafNode(child);
                                if (leafNode) {
                                    return leafNode;
                                }
                            }
                            return null;
                        },
                        
                        onAddNode(obj) {
                            var data = obj.data, node = obj.node;
                            let me = this;
                            var config = {
                                totab: false, //true: 以Tab导航的方式打开
                                width: "500px",
                                height: "300px",
                                icon: "icon-product",
                                text: "产品类型信息",
                                id: "product_type_edit",//totab: true时需设置,用于判断是否已打开此页面
                                url: "module/md/page/product/page/product_type_edit.html",
                                data: {},
                                delta: {},
                                sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
                                callback: function(obj, callback) {
                                    me.type_treedata = obj.options
                                    if (callback) {
                                        callback();
                                    }
                                }
                            };
                            me.doPopupByPublic(config);
                        },
                        
                        onEditNode(obj) {
                            var data = obj.data, node = obj.node;
                            var me = this;
                            Root.showPopup({
                                url: "module/md/page/product/page/product_type_edit.html",
                                width: 800,
                                height: 230,
                                data: data,
                                sceneCode: "edit",
                                callback: function(options_obj, callback) {
                                    me.type_treedata = options_obj.options
                                    if (callback) {
                                        callback();
                                    }
                                }
                            });
                        },
                        
                        onDelNode(obj) {
                            var data = obj.data, node = obj.node;
                            let me = this;
                            Root.confirm('确定删除-' + data.name + '-吗?', '删除提示', {
                              confirmButtonText: '删除',
                              cancelButtonText: '取消',
                              type: 'warning'
                            }).then(() => {
                                me.dodeldata(data, node, "agm_category");
                            }).catch(() => {
                                Root.message({
                                    type: 'info',
                                    message: '已取消删除'
                                });
                            });
                        },
                        
                        dodeldata(row, node, tablename) {
                            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) {
                                        const parent = node.parent;
                                        const children = parent.data.children || parent.data;
                                        const index = children.findIndex(d => d.id === row.id);
                                        children.splice(index, 1);
                                        
                                        Root.message({
                                            type: 'success',
                                            message: '删除成功!'
                                        });
                                    }
                                });
                            }
                        },
                        
                        node_isShow(data, isShow) {
                            if (this.$refs[data.id]) {
                                this.$refs[data.id].style.display = isShow ? '' : 'none';
                            }
                        },
                        
                        onNodeClick(obj) {
                            console.log(obj);
                            var data = obj.data, node = obj.node, el = obj.el;
                            var pageUrl = window.top.config.url_page;
                            this.edition_data_page = pageUrl + data.url;
                        },
                    }
                });
            };
            
            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: 220px !important;
            }
        </style>
        
    </head>
    
    <body style="margin: 0px;">
        <div v-cloak id="vbody">
            <div id="page_root">
                <div class="h_dialog__body">
                    <div :style="{position: 'absolute', left: '5px', width: '205px', top: '5px', bottom: '5px', 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: '16px 0', height: treeHeight - 155 + 'px', overflow: 'auto'}">
                            <h-tree
                            v-if="isRefresh"
                            :tree-data="treeData"
                            :tree-txt-formatter="treeTxtFormatter"
                            :currentnodekey="currentnodekey"
                            :is-readonly="isTreeReadonly"
                            
                            @node-click="onNodeClick"
                            @add-node="onAddNode"
                            @edit-node="onEditNode"
                            @del-node="onDelNode"
                            >
                            </h-tree>
                        </div>
                    </div>
                    <div :style="{position: 'absolute', left: '220px', right: '5px', top: '5px', bottom: '5px', border: '1px solid #ccc'}">
                        <div style="height: 100%; width: 100%;">
                            <iframe ref="edition_data_iframe" style="height: 100%; width: 100%;" frameborder="0" :src="edition_data_page"></iframe>
                        </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>