zj
2024-06-03 89d48809779ae41f8712539584798d5900b64b78
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
<template>
    <div>
        <div class="zixuancontainer">
            <Newheader></Newheader>
            <div>
                <el-table :data="zixuanlist" :highlight-current-row="false" border style="width: 100%"
                    v-loading="loading" element-loading-spinner="el-icon-loading" @row-contextmenu="rightClick"
                    element-loading-background="rgba(37,38,42, 0.8)" :height="tableHeight" @row-click="handleTableRow"
                    :header-cell-style="{ 'padding': '2px 0', 'background': 'rgb(37,38,42)', 'color': '#9d9d9d', 'font-size': '12px' }">
                    <el-table-column prop="date" label="排序">
                        <template slot-scope="scope">
                            <span>
                                {{ scope.$index + 1 }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="name" label="名称">
                        <template slot-scope="scope">
                            <span class="contents">
                                {{ scope.row.name ? scope.row.name : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="code" label="代码">
                        <template slot-scope="scope">
                            <span class="contents">
                                {{ scope.row.code ? scope.row.code : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="hcrate" label="涨幅%">
                        <template slot-scope="scope">
                            <span class="contents" :class="scope.row.hcrate < 0 ? 'greens' : 'reds'">
                                {{ scope.row.hcrate ? scope.row.hcrate + '%' : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="nowPrice" label="现价">
                        <template slot-scope="scope">
                            <span class="contents" :class="scope.row.hcrate < 0 ? 'greens' : 'reds'">
                                {{ scope.row.nowPrice ? scope.row.nowPrice : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="today_max" label="最高">
                        <template slot-scope="scope">
                            <span class="contents" :class="scope.row.hcrate < 0 ? 'greens' : 'reds'">
                                {{ scope.row.today_max ? scope.row.today_max : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="today_min" label="最低">
                        <template slot-scope="scope">
                            <span class="contents" :class="scope.row.hcrate < 0 ? 'greens' : 'reds'">
                                {{ scope.row.today_min ? scope.row.today_min : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="open_px" label="开盘">
                        <template slot-scope="scope">
                            <span class="contents" :class="scope.row.hcrate < 0 ? 'greens' : 'reds'">
                                {{ scope.row.open_px ? scope.row.open_px : '--' }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="preclose_px" label="昨收">
                    </el-table-column>
                </el-table>
                <div id="menu">
                    <ul>
                        <li @click="getaddzixuan"><span>添加自选</span></li>
                        <li @click="getdelzixuan"><span>删除自选</span></li>
                        <li @click="handleTableRow(currentRow)"><span>交易</span></li>
                    </ul>
                </div>
            </div>
            <Newfooter></Newfooter>
            <div class="zhezhao" v-if="iszhezhao" @click="getmenuclose"></div>
        </div>
    </div>
</template>
<script>
import * as api from "../../axios/api";
import Newheader from '@/components/newheader';
import Newfooter from '@/components/newfooters';
export default {
    components: {
        Newheader,
        Newfooter
    },
    data() {
        return {
            windowWidth: document.documentElement.clientWidth,  //实时屏幕宽度
            windowHeight: document.documentElement.clientHeight,   //实时屏幕高
            tableHeight: (document.documentElement.clientHeight - 74) + 'px',
            keyWords: '',
            pageNum: 1,
            pageSize: 15,
            zixuanlist: [],
            loading: true,
            isshow: true,
            currentRow: '',
            iszhezhao: false,
        }
    },
    computed: {
    },
    watch: {
        windowHeight(val) {
            let that = this;
            console.log("实时屏幕高度:", val, that.windowHeight);
        },
        windowWidth(val) {
            let that = this;
            console.log("实时屏幕宽度:", val, that.windowHeight);
        }
    },
    mounted() {
        var that = this;
        window.onresize = () => {
            return (() => {
                window.fullHeight = document.documentElement.clientHeight;
                window.fullWidth = document.documentElement.clientWidth;
                that.windowHeight = window.fullHeight;  // 高
                that.windowWidth = window.fullWidth; // 宽
                that.$nextTick(() => {
                    that.tableHeight = (that.windowHeight - 70) + 'px'
                })
            })()
        };
        this.getzixuan()
    },
    beforeDestroy() {
        window.onresize = null;
        this.isshow = false
    },
    methods: {
        getmenuclose() {
            this.iszhezhao = false
            var menu = document.querySelector("#menu");
            menu.style.display = "none";
        },
        getaddzixuan() {
            api.addOption({ code: this.currentRow.code }).then(res => {
                if (res.status == 0) {
                    this.$message({
                        message: '添加自选成功',
                        type: 'success'
                    });
                } else {
                    this.$message({
                        message: '添加自选失败',
                        type: 'error'
                    });
                }
                this.getmenuclose()
            })
        },
        getdelzixuan() {
            api.delOption({ code: this.currentRow.code }).then(res => {
                if (res.status == 0) {
                    this.$message({
                        message: '删除自选成功',
                        type: 'success'
                    });
                } else {
                    this.$message({
                        message: '删除自选失败',
                        type: 'error'
                    });
                }
                this.getmenuclose()
            })
 
        },
        rightClick(row, column, event) {
            this.currentRow = row;
            var menu = document.querySelector("#menu");
            event.preventDefault();
            //获取我们自定义的右键菜单
 
            // 根据事件对象中鼠标点击的位置,进行定位
            menu.style.left = event.clientX + "px";
            menu.style.top = event.clientY + "px";
            // 改变自定义菜单的隐藏与显示
            menu.style.display = "block";
            this.iszhezhao = true
        },
        async getzixuan() {
            var that = this;
            var opt = {
                keyWords: this.keyWords,
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                stockPlate: '',
                stockType: 'hk'
            };
            var data = await api.getStock(opt);
            if (data.data.list.length > 0) {
                for (const i in data.data.list) {
                    this.zixuanlist.push(data.data.list[i])
                }
                if (that.isshow) {
                    setTimeout(() => {
                        that.pageNum++
                        that.getzixuan()
                    }, 100);
                }
                if (this.loading == true && this.pageNum >= 2) {
                    this.loading = false;
                }
            }
        },
        handleTableRow(row, event, column) {
            console.log(row, event, column)
            this.$router.push({
                path: '/hqchartdetail',
                query: {
                    code: row.code,
                    stock_type: row.stock_type,
                    is_zhishu: 0,
                    sok: row.type ? row.type : 1
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
/deep/ .el-table__body td {
    color: #fff !important;
}
 
/deep/ .el-table tbody tr:hover>td,
.el-table tbody tr:hover>tr,
.el-table tbody tr:hover .el-table tbody tr td {
    background-color: rgb(33, 59, 76) !important;
    background: rgb(33, 59, 76) !important;
}
 
// /deep/.el-table--enable-row-hover .el-table__body tr:hover > td {
//   background-color: rgb(19, 75, 132) !important; //颜色必须是rgb
// }
/deep/ .el-table__body-wrapper {
    background-color: rgb(37, 38, 42) !important;
}
 
/deep/ .el-table__body-wrapper::-webkit-scrollbar-corner {
    width: 8px;
    height: 8px;
    display: none;
}
 
/deep/ .el-table--border::after,
.el-table--group::after,
.el-table::before {
    background-color: rgb(37, 38, 42);
}
 
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background: rgb(37, 38, 42);
    /*滚动条里面小方块*/
}
 
/deep/ .el-table__body-wrapper::-webkit-scrollbar-track {
    // -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    border-radius: unset;
    /*滚动条的背景区域的圆角*/
    background-color: rgb(37, 38, 42);
    /*滚动条的背景颜色*/
}
 
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
    border-radius: unset;
    /*滚动条的圆角*/
    // -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    background-color: rgb(50, 51, 55);
    /*滚动条的背景颜色*/
}
 
.greens {
    color: rgb(22, 135, 64) !important;
}
 
.blues {
    color: rgb(3, 182, 191) !important;
}
 
.reds {
    color: rgb(237, 58, 59) !important;
}
 
.zixuancontainer {
    background: #25262a;
    height: calc(100vh - 34px);
    overflow: unset;
 
    #menu {
        position: absolute;
        display: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
        background: #323337;
        cursor: pointer;
        color: #c9c9c9;
        width: 200px;
        border: 1px solid #19a0ff;
        font-size: 13px;
        z-index: 12;
 
        ul {
            list-style: none;
            margin: 0px;
            padding: 0px;
 
            li {
                padding: 0px 10px;
                height: 30px;
                line-height: 30px;
                position: relative;
                box-sizing: border-box;
                text-indent: 8px;
 
                &:hover {
                    border-top: 1px solid #19a0ff;
                    border-bottom: 1px solid #19a0ff;
                    background: #213b4c;
                }
 
            }
        }
    }
 
    .zhezhao {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 8;
    }
}
</style>