|
@@ -55,8 +55,9 @@
|
|
|
</div>
|
|
|
<div class="row justify-content-center mt-5" id="my_li">
|
|
|
<ul>
|
|
|
- <li v-for="item in createdList">{{ convertToBeijingTime(item.created_at) }}
|
|
|
- <button class="deleteBtn" v-on:click="confirmDelete(item.id)">删除</button>
|
|
|
+ <li v-for="(item, index) in createdList">{{ convertToBeijingTime(item.created_at) }}
|
|
|
+ <button class="deleteBtn" v-on:click="confirmDelete(item.id)">删除</button>
|
|
|
+ <button class="eventBtn" v-on:click="addEvent(index)">添加事件</button>
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
@@ -100,6 +101,35 @@
|
|
|
this.getLatestData(); // 获取最新的数据
|
|
|
},
|
|
|
methods: {
|
|
|
+ addEvent(index) {
|
|
|
+ const currentItem = this.createdList[index];
|
|
|
+ const nextItem = this.createdList[index + 1];
|
|
|
+
|
|
|
+ const endTime = currentItem.created_at;
|
|
|
+ const startTime = nextItem ? nextItem.created_at : currentItem.created_at;
|
|
|
+
|
|
|
+ const eventName = prompt("请输入事件名称:");
|
|
|
+
|
|
|
+ if (eventName) {
|
|
|
+ const eventData = {
|
|
|
+ start_time: convertToBeijingTime(startTime),
|
|
|
+ end_time: convertToBeijingTime(endTime),
|
|
|
+ event_name: eventName,
|
|
|
+ created_by: "b90c0cf6997d4cfa987f2bc59583fcaa"
|
|
|
+ };
|
|
|
+
|
|
|
+ // 使用异步请求将 eventData 发送到后台
|
|
|
+ axios.post("https://api.tianyunperfect.cn/location/event", eventData)
|
|
|
+ .then(response => {
|
|
|
+ // 处理请求成功的响应
|
|
|
+ showMsg("成功", 2);
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ // 处理请求失败的错误
|
|
|
+ console.error(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
confirmDelete: function (id) {
|
|
|
if (confirm("确认要删除吗?")) {
|
|
|
// 发送删除请求
|