Files
WMS/HHWMS.Web/Areas/Configs/Views/Print/Index.cshtml
T
2024-03-07 22:59:43 +08:00

107 lines
3.0 KiB
Plaintext

<div id="app">
<a-button @@click="handleClick">
@* <template #icon>
<icon-plus />
</template> *@
{{ message }}
</a-button>
{{ result }}
<a-table :columns="columns" :data="datat" />
</div>
<script src="/front/signalr.min.js"></script>
<script>
const { createApp, reactive } = Vue
const app = createApp({
data() {
return {
message: 'Hello Vue!',
result: 'Hello Vue!',
columns: [
{
title: '地址',
dataIndex: 'Key',
},
{
title: '值',
dataIndex: 'Value',
}
],
datat: reactive([])
}
},
methods: {
handleClick() {
var _this = this;
axios.post("/configs/Print/Test", {})
.then(function (json) {
_this.result = json.data.Data;
_this.datat = [];
_this.result.forEach((item) => {
_this.datat.push(item);
})
// _this.datat.forEach((item,index) => {
// if (item.Key == "DB4.24") {
// _this.datat[index].Value = "3";
// }
// })
})
.catch(function (error) {
console.log(error);
});
},
handleSubmit(data) {
console.log(data);
this.$message.info('This is an info message')
}
}
});
app
.use(ArcoVue)
.use(ArcoVueIcon)
.mount('#app');
console.log(app._instance.data);
let connection = new signalR.HubConnectionBuilder()
.withAutomaticReconnect()
.withUrl("/stocks")
.build();
connection.start().then(function () {
connection.invoke("GetAllStocks").then(function (stocks) {
for (let i = 0; i < stocks.length; i++) {
app._instance.data.datat.push({ Key: stocks[i].dbName, Value: stocks[i].dbValue });
}
});
connection.invoke("GetMarketState").then(function (state) {
console.log(state);
// if (state === 'Open') {
startStreaming();
// }
});
connection.invoke("OpenMarket");
});
function startStreaming() {
connection.stream("StreamStocks").subscribe({
close: false,
next: displayStock,
error: function (err) {
logger.log(err);
}
});
}
function displayStock(stock) {
app._instance.data.datat.forEach((item,index) => {
if (item.Key == stock.dbName) {
app._instance.data.datat[index].Value = stock.dbValue;
}
})
}
</script>