87 lines
2.8 KiB
Python
87 lines
2.8 KiB
Python
# coding:utf-8
|
|
# @Time : 2024/9/5 上午11:15
|
|
# @Author : ouyangyouzhang
|
|
# @FileName : Dialog.py
|
|
# @Describe :
|
|
|
|
import sys
|
|
from PyQt5.QtWidgets import QApplication, QDialog, QVBoxLayout, QLineEdit, QPushButton, QLabel, QHBoxLayout, QDateEdit, \
|
|
QMessageBox
|
|
from PyQt5.QtCore import QDate
|
|
|
|
from main import export_by_conversation_id, export_by_data
|
|
|
|
|
|
class ExportDialog(QDialog):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("导出对话框")
|
|
self.setFixedSize(400, 150)
|
|
# self.setGeometry(100, 100, 400, 100)
|
|
|
|
layout = QVBoxLayout()
|
|
|
|
# 添加新的布局
|
|
self.appid_layout = QHBoxLayout()
|
|
|
|
# 添加标签
|
|
self.appid_label = QLabel("AppID:")
|
|
self.appid_layout.addWidget(self.appid_label)
|
|
|
|
# 添加编辑框
|
|
self.appid_input = QLineEdit(self)
|
|
self.appid_layout.addWidget(self.appid_input)
|
|
|
|
# 将新布局添加到主布局
|
|
layout.addLayout(self.appid_layout)
|
|
|
|
# 通过会话ID导出部分
|
|
self.id_label = QLabel("通过会话ID导出")
|
|
self.id_input = QLineEdit(self)
|
|
self.id_export_button = QPushButton("导出", self)
|
|
self.id_export_button.clicked.connect(self.export_by_id)
|
|
|
|
id_layout = QHBoxLayout()
|
|
id_layout.addWidget(self.id_input)
|
|
id_layout.addWidget(self.id_export_button)
|
|
|
|
layout.addWidget(self.id_label)
|
|
layout.addLayout(id_layout)
|
|
|
|
# 通过日期导出部分
|
|
self.date_label = QLabel("通过日期导出")
|
|
self.date_input = QDateEdit(self)
|
|
self.date_input.setCalendarPopup(True)
|
|
self.date_input.setDate(QDate.currentDate()) # 设置为当前日期
|
|
self.date_export_button = QPushButton("导出", self)
|
|
self.date_export_button.clicked.connect(self.export_by_date)
|
|
|
|
date_layout = QHBoxLayout()
|
|
date_layout.addWidget(self.date_input)
|
|
date_layout.addWidget(self.date_export_button)
|
|
|
|
layout.addWidget(self.date_label)
|
|
layout.addLayout(date_layout)
|
|
|
|
self.setLayout(layout)
|
|
|
|
def export_by_id(self):
|
|
session_id = self.id_input.text()
|
|
session_id = session_id.strip()
|
|
if session_id:
|
|
export_by_conversation_id(session_id, self.appid_input.text().strip())
|
|
QMessageBox.information(self, "完成", "导出成功!")
|
|
else:
|
|
print("请输入会话ID")
|
|
|
|
def export_by_date(self):
|
|
selected_date = self.date_input.date().toString("yyyy-MM-dd")
|
|
export_by_data(selected_date, self.appid_input.text().strip())
|
|
QMessageBox.information(self, "完成", "导出成功!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication(sys.argv)
|
|
dialog = ExportDialog()
|
|
dialog.show()
|
|
sys.exit(app.exec_()) |