8 changed files with 501 additions and 172 deletions
@ -1,40 +1,148 @@ |
|||||
<template> |
<template> |
||||
<div> |
<custom-base-table |
||||
<el-table :data="data" class="customer-no-border-table"> |
:data="data" |
||||
<el-table-column |
:columns="columns" |
||||
v-for="i in secondLogColumns" |
thead-classes="text-primary" |
||||
:label="i.name" |
> |
||||
:prop="i.prop" |
<template slot="LogType" slot-scope="item"> |
||||
:key="i.prop" |
{{ typeRender(item.row.item.LogType) }} |
||||
> |
</template> |
||||
<template slot-scope="scope"> |
</custom-base-table> |
||||
<div v-if="i.customSlot == 'OrderType'"></div> |
|
||||
<div v-else> |
|
||||
<p>{{ scope.row[i.prop] }}</p> |
|
||||
</div> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
</el-table> |
|
||||
</div> |
|
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import { secondLogColumns } from "../prePages/js/columns"; |
import Bus from "../../common/bus"; |
||||
|
import CustomBaseTable from "../../components/CustomBaseTable"; |
||||
|
import moment from "moment"; |
||||
export default { |
export default { |
||||
props: { |
props: { |
||||
robotId: { type: String, default: "" } |
RobotId: { type: String, default: "60521323-28C3-AC14-0076-48B075584510" } |
||||
}, |
}, |
||||
|
components: { CustomBaseTable }, |
||||
data() { |
data() { |
||||
return { |
return { |
||||
secondLogColumns, |
columns: [ |
||||
data: [] |
{ name: "RobotId", prop: "RobotId" }, |
||||
|
{ name: "内容", prop: "Content" }, |
||||
|
{ |
||||
|
name: "日志类型", |
||||
|
prop: "LogType", |
||||
|
|
||||
|
customSlot: "LogType" |
||||
|
}, |
||||
|
{ |
||||
|
name: "订单Id", |
||||
|
prop: "SpotGoodsOrderId" |
||||
|
}, |
||||
|
{ name: "创建时间", prop: "CreateTime" } |
||||
|
], |
||||
|
data: [], |
||||
|
noMoreData: false, |
||||
|
endTime: null, |
||||
|
scrollInstance: null, |
||||
|
nullPlusTime: 0 |
||||
}; |
}; |
||||
}, |
}, |
||||
|
created() { |
||||
|
let endTime = moment(); |
||||
|
this.endTime = endTime; |
||||
|
this.getLatestLog(endTime); |
||||
|
}, |
||||
|
|
||||
mounted() { |
mounted() { |
||||
this.init(); |
Bus.$on("tradeLog", data => { |
||||
|
console.log(data, "received from ws Bus"); |
||||
|
this.data.unshift(data); |
||||
|
}); |
||||
|
this.initScroller(); |
||||
|
}, |
||||
|
|
||||
|
destroyed() { |
||||
|
if (this.scrollInstance) |
||||
|
this.scrollInstance.removeEventListener("scroll", this.scrollerListener); |
||||
}, |
}, |
||||
methods: { |
methods: { |
||||
init() {} |
initScroller() { |
||||
|
let target = document.getElementById("tradeLog"); |
||||
|
this.scrollInstance = target; |
||||
|
this.scrollInstance.addEventListener( |
||||
|
"scroll", |
||||
|
this.scrollerListener, |
||||
|
false |
||||
|
); |
||||
|
}, |
||||
|
|
||||
|
getPreday() {}, |
||||
|
|
||||
|
scrollerListener() { |
||||
|
// console.log( |
||||
|
// this.scrollInstance.scrollTop, |
||||
|
// this.scrollInstance.scrollHeight, |
||||
|
// this.scrollInstance.clientHeight |
||||
|
// ); |
||||
|
if ( |
||||
|
this.scrollInstance.scrollTop + this.scrollInstance.clientHeight == |
||||
|
this.scrollInstance.scrollHeight |
||||
|
) { |
||||
|
if (!this.spinning && !this.noMoreData) this.getLatestLog(this.endTime); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
typeRender(logType) { |
||||
|
switch (logType) { |
||||
|
case 0: |
||||
|
return "买入"; |
||||
|
case 1: |
||||
|
return "卖出"; |
||||
|
case 2: |
||||
|
return "做多"; |
||||
|
case 3: |
||||
|
return "做空"; |
||||
|
case 4: |
||||
|
return "大趋势看多"; |
||||
|
case 5: |
||||
|
return "大趋势看空"; |
||||
|
case 10: |
||||
|
return "自动卖出"; |
||||
|
} |
||||
|
}, |
||||
|
getLatestLog(endTime) { |
||||
|
this.spinning = true; |
||||
|
let _endTime = endTime.format("YYYY-MM-DD HH:mm:ss"); |
||||
|
|
||||
|
this.$http |
||||
|
.get( |
||||
|
`/Api/ExecutionLog/GetList?robotId=${this.RobotId}&endTime=${_endTime}` |
||||
|
) |
||||
|
.then(res => { |
||||
|
this.spinning = false; |
||||
|
if (res.Code == 200) { |
||||
|
if (res.Data.length > 0) { |
||||
|
if (this.data.length > 0) { |
||||
|
res.Data.forEach(item => this.data.push(item)); |
||||
|
this.endTime = moment( |
||||
|
this.data[this.data.length - 1].CreateTime |
||||
|
); |
||||
|
} else { |
||||
|
this.data = res.Data; |
||||
|
} |
||||
|
} else { |
||||
|
this.noMoreData = true; |
||||
|
this.sMessage("danger", "已经没有更多日志了"); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}, |
||||
|
// 封装showNotification |
||||
|
sMessage(type, message) { |
||||
|
this.$notify({ |
||||
|
type: type, |
||||
|
message, |
||||
|
timeout: 1800 |
||||
|
}); |
||||
|
} |
||||
} |
} |
||||
}; |
}; |
||||
</script> |
</script> |
||||
|
|
||||
|
<style scoped></style> |
||||
|
Loading…
Reference in new issue