Browse Source

发票详情数据调整;

pdf样式更改;
wr_2024_invoice
wurong 6 months ago
parent
commit
634d1cc10d
  1. 6
      lib/order/invoices_manage/invoices_detail_page.dart
  2. 39
      lib/order/invoices_manage/pdf_screen.dart

6
lib/order/invoices_manage/invoices_detail_page.dart

@ -53,7 +53,7 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
context: context, context: context,
token: value.getString('token'), token: value.getString('token'),
), ),
queryInvoices("1797587255380934656"), queryInvoices(widget?.arguments["id"] ??""),
}); });
} }
@ -104,7 +104,7 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
Completer<File> completer = Completer(); Completer<File> completer = Completer();
print("Start download file from internet!"); print("Start download file from internet!");
try { try {
final url = "https://file.oa.yixinhuixiang.com/2024/08/06/e716b61ed0c4444db4e8e33bf2712432.pdf"; final url = invoicesDetailInfo?.ossUrl ?? "";
final filename = url.substring(url.lastIndexOf("/") + 1); final filename = url.substring(url.lastIndexOf("/") + 1);
var request = await HttpClient().getUrl(Uri.parse(url)); var request = await HttpClient().getUrl(Uri.parse(url));
var response = await request.close(); var response = await request.close();
@ -478,7 +478,7 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
); );
} }
/// ///
launchBrowser() async { launchBrowser() async {
String url = invoicesDetailInfo?.ossUrl ?? ""; String url = invoicesDetailInfo?.ossUrl ?? "";
if (await canLaunch(url)) { if (await canLaunch(url)) {

39
lib/order/invoices_manage/pdf_screen.dart

@ -14,16 +14,18 @@ class PDFScreen extends StatefulWidget {
} }
class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver { class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
final Completer<PDFViewController> _controller = Completer<PDFViewController>(); final Completer<PDFViewController> _controller =
Completer<PDFViewController>();
int pages = 0; int pages = 0;
int currentPage = 0; int currentPage = 0;
int pageTotal =1; int pageTotal = 0;
bool isReady = false; bool isReady = false;
String errorMessage = ''; String errorMessage = '';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return widget.inlet == 1 ?Material( return widget.inlet == 1
? Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
@ -42,8 +44,8 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
pageSnap: true, pageSnap: true,
defaultPage: currentPage, defaultPage: currentPage,
fitPolicy: FitPolicy.BOTH, fitPolicy: FitPolicy.BOTH,
preventLinkNavigation: preventLinkNavigation: false,
false, // if set to true the link is handled in flutter // if set to true the link is handled in flutter
onRender: (_pages) { onRender: (_pages) {
setState(() { setState(() {
pages = _pages; pages = _pages;
@ -96,12 +98,14 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
bottom: 45, bottom: 45,
child: Center( child: Center(
child: Text("${currentPage}/${pageTotal}",style: TextStyle(color: Colors.white,fontSize: 16)), child: Text("${currentPage}/${pageTotal}",
style: TextStyle(color: Colors.white, fontSize: 16)),
), ),
), ),
], ],
), ),
):Scaffold( )
: Scaffold(
body: Stack( body: Stack(
children: <Widget>[ children: <Widget>[
PDFView( PDFView(
@ -113,8 +117,8 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
pageSnap: true, pageSnap: true,
defaultPage: currentPage, defaultPage: currentPage,
fitPolicy: FitPolicy.BOTH, fitPolicy: FitPolicy.BOTH,
preventLinkNavigation: preventLinkNavigation: false,
false, // if set to true the link is handled in flutter // if set to true the link is handled in flutter
onRender: (_pages) { onRender: (_pages) {
setState(() { setState(() {
pages = _pages; pages = _pages;
@ -139,7 +143,8 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
onLinkHandler: (String uri) { onLinkHandler: (String uri) {
print('goto uri: $uri'); print('goto uri: $uri');
}, },
onPageChanged: (int page, int total) { if(total >0){ onPageChanged: (int page, int total) {
if (total > 0) {
print('page change: $page/$total'); print('page change: $page/$total');
setState(() { setState(() {
currentPage = page + 1; currentPage = page + 1;
@ -164,14 +169,20 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
bottom: 45, bottom: 45,
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Center( child: Center(
child: Text("${currentPage+1}/${pageTotal}",style: TextStyle(color: Colors.black,fontSize: 16)), child: Text("${currentPage}/${pageTotal}",
style: TextStyle(color: Colors.black, fontSize: 16)),
), ),
), ),
Positioned(// Positioned(
//
right: 10, right: 10,
top: MediaQuery.of(context).padding.top, top: MediaQuery.of(context).padding.top,
child: IconButton( child: IconButton(
icon: Icon(Icons.close,size: 30,color: Colors.black,), icon: Icon(
Icons.close,
size: 30,
color: Colors.black,
),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
@ -179,8 +190,6 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
), ),
], ],
), ),
); );
} }
} }
Loading…
Cancel
Save