Browse Source

发票详情数据调整;

pdf样式更改;
wr_2024_invoice
wurong 5 months ago
parent
commit
634d1cc10d
  1. 6
      lib/order/invoices_manage/invoices_detail_page.dart
  2. 329
      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)) {

329
lib/order/invoices_manage/pdf_screen.dart

@ -8,179 +8,188 @@ class PDFScreen extends StatefulWidget {
final String path; final String path;
final int inlet; final int inlet;
PDFScreen({Key key, this.path,this.inlet}) : super(key: key); PDFScreen({Key key, this.path, this.inlet}) : super(key: key);
_PDFScreenState createState() => _PDFScreenState(); _PDFScreenState createState() => _PDFScreenState();
} }
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
type: MaterialType.transparency, ? Material(
child: Stack( type: MaterialType.transparency,
children: <Widget>[ child: Stack(
Center( children: <Widget>[
child: Container( Center(
height:250, child: Container(
decoration: BoxDecoration( height: 250,
color: Colors.white, decoration: BoxDecoration(
), color: Colors.white,
child: PDFView( ),
filePath: widget.path, child: PDFView(
enableSwipe: true, filePath: widget.path,
swipeHorizontal: true, enableSwipe: true,
autoSpacing: false, swipeHorizontal: true,
pageFling: true, autoSpacing: false,
pageSnap: true, pageFling: true,
defaultPage: currentPage, pageSnap: true,
fitPolicy: FitPolicy.BOTH, defaultPage: currentPage,
preventLinkNavigation: fitPolicy: FitPolicy.BOTH,
false, // if set to true the link is handled in flutter preventLinkNavigation: false,
onRender: (_pages) { // if set to true the link is handled in flutter
setState(() { onRender: (_pages) {
pages = _pages; setState(() {
isReady = true; pages = _pages;
}); isReady = true;
}, });
onError: (error) { },
setState(() { onError: (error) {
errorMessage = error.toString(); setState(() {
}); errorMessage = error.toString();
print(error.toString()); });
}, print(error.toString());
onPageError: (page, error) { },
setState(() { onPageError: (page, error) {
errorMessage = '$page: ${error.toString()}'; setState(() {
}); errorMessage = '$page: ${error.toString()}';
print('$page: ${error.toString()}'); });
}, print('$page: ${error.toString()}');
onViewCreated: (PDFViewController pdfViewController) { },
_controller.complete(pdfViewController); onViewCreated: (PDFViewController pdfViewController) {
}, _controller.complete(pdfViewController);
onLinkHandler: (String uri) { },
print('goto uri: $uri'); onLinkHandler: (String uri) {
}, print('goto uri: $uri');
onPageChanged: (int page, int total) { },
if(total >0){ onPageChanged: (int page, int total) {
print('page change: $page/$total'); if (total > 0) {
setState(() { print('page change: $page/$total');
currentPage = page +1; setState(() {
pageTotal = total; currentPage = page + 1;
}); pageTotal = total;
}else{ });
pageTotal = 1; } else {
} pageTotal = 1;
}, }
), },
), ),
), ),
errorMessage.isEmpty ),
? !isReady errorMessage.isEmpty
? Center( ? !isReady
child: CircularProgressIndicator(), ? Center(
) child: CircularProgressIndicator(),
: Container() )
: Center( : Container()
child: Text(errorMessage), : Center(
), child: Text(errorMessage),
//pdfindex显示 ),
Positioned( //pdfindex显示
width: MediaQuery.of(context).size.width, Positioned(
bottom:45, width: MediaQuery.of(context).size.width,
child: Center( bottom: 45,
child: Text("${currentPage}/${pageTotal}",style: TextStyle(color: Colors.white,fontSize: 16)), child: Center(
child: Text("${currentPage}/${pageTotal}",
style: TextStyle(color: Colors.white, fontSize: 16)),
),
),
],
), ),
),
],
),
):Scaffold(
body: Stack(
children: <Widget>[
PDFView(
filePath: widget.path,
enableSwipe: true,
swipeHorizontal: true,
autoSpacing: false,
pageFling: true,
pageSnap: true,
defaultPage: currentPage,
fitPolicy: FitPolicy.BOTH,
preventLinkNavigation:
false, // if set to true the link is handled in flutter
onRender: (_pages) {
setState(() {
pages = _pages;
isReady = true;
});
},
onError: (error) {
setState(() {
errorMessage = error.toString();
});
print(error.toString());
},
onPageError: (page, error) {
setState(() {
errorMessage = '$page: ${error.toString()}';
});
print('$page: ${error.toString()}');
},
onViewCreated: (PDFViewController pdfViewController) {
_controller.complete(pdfViewController);
},
onLinkHandler: (String uri) {
print('goto uri: $uri');
},
onPageChanged: (int page, int total) { if(total >0){
print('page change: $page/$total');
setState(() {
currentPage = page +1;
pageTotal = total;
});
}else{
pageTotal = 1;
}
},
),
errorMessage.isEmpty
? !isReady
? Center(
child: CircularProgressIndicator(),
) )
: Container() : Scaffold(
: Center( body: Stack(
child: Text(errorMessage), children: <Widget>[
), PDFView(
//pdfindex显示 filePath: widget.path,
Positioned( enableSwipe: true,
bottom: 45, swipeHorizontal: true,
width: MediaQuery.of(context).size.width, autoSpacing: false,
child: Center( pageFling: true,
child: Text("${currentPage+1}/${pageTotal}",style: TextStyle(color: Colors.black,fontSize: 16)), pageSnap: true,
), defaultPage: currentPage,
), fitPolicy: FitPolicy.BOTH,
Positioned(// preventLinkNavigation: false,
right: 10, // if set to true the link is handled in flutter
top: MediaQuery.of(context).padding.top, onRender: (_pages) {
child: IconButton( setState(() {
icon: Icon(Icons.close,size: 30,color: Colors.black,), pages = _pages;
onPressed: (){ isReady = true;
Navigator.of(context).pop(); });
}, },
onError: (error) {
setState(() {
errorMessage = error.toString();
});
print(error.toString());
},
onPageError: (page, error) {
setState(() {
errorMessage = '$page: ${error.toString()}';
});
print('$page: ${error.toString()}');
},
onViewCreated: (PDFViewController pdfViewController) {
_controller.complete(pdfViewController);
},
onLinkHandler: (String uri) {
print('goto uri: $uri');
},
onPageChanged: (int page, int total) {
if (total > 0) {
print('page change: $page/$total');
setState(() {
currentPage = page + 1;
pageTotal = total;
});
} else {
pageTotal = 1;
}
},
),
errorMessage.isEmpty
? !isReady
? Center(
child: CircularProgressIndicator(),
)
: Container()
: Center(
child: Text(errorMessage),
),
//pdfindex显示
Positioned(
bottom: 45,
width: MediaQuery.of(context).size.width,
child: Center(
child: Text("${currentPage}/${pageTotal}",
style: TextStyle(color: Colors.black, fontSize: 16)),
),
),
Positioned(
//
right: 10,
top: MediaQuery.of(context).padding.top,
child: IconButton(
icon: Icon(
Icons.close,
size: 30,
color: Colors.black,
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
],
), ),
), );
],
),
);
} }
} }

Loading…
Cancel
Save