Browse Source

发票列表

zhaoxiaohai 2 years ago
parent
commit
cdd9a42de7

+ 116 - 0
packageA/invoice/modules/InvoiceList/index.js

@@ -0,0 +1,116 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        disabled: Boolean
+    },
+    data: {
+        show: false,
+        sa_invoiceapplyid: 0,
+        "content": {
+            nocache: true,
+            pageNumber: 1,
+            pageTotal: 1,
+            total: null,
+        },
+        actions: null
+    },
+    methods: {
+        /* 获取发票列表 */
+        getList(id, init) {
+            let content = this.data.content;
+            content.sa_invoiceapplyid = id;
+            if (init) content.pageNumber = 1;
+            _Http.basic({
+                "id": "20221223153403",
+                content
+            }).then(res => {
+                console.log("发票列表", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.msg,
+                    icon: "none"
+                })
+                /* res.data = res.data.map(value => {
+                  if (value.attinfos.length != 0) {
+                    value.attinfos = file.fileList(value.attinfos)
+                    let image = value.attinfos.find(v => v.fileType == "image");
+                    value.cover = image ? image.cover : "";
+                  }
+                  return value;
+                }) */
+                this.setData({
+                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                    "content.pageNumber": res.pageNumber + 1,
+                    "content.pageSize": res.pageSize,
+                    "content.pageTotal": res.pageTotal,
+                    "content.total": res.total,
+                    sa_invoiceapplyid: id
+                })
+            })
+        },
+        previewpdf(e) {
+            let {
+                pdfurl,
+                paperpdfurl
+            } = e.currentTarget.dataset.item;
+            if (!pdfurl && !paperpdfurl) {
+                wx.showToast({
+                    title: '暂无可预览文件',
+                    icon: "none"
+                })
+            } else if (pdfurl && paperpdfurl) {
+                this.setData({
+                    actions: [{
+                            name: '查看发票',
+                            url: pdfurl
+                        },
+                        {
+                            name: '查看纸质发票',
+                            url: paperpdfurl
+                        }
+                    ],
+                    show: true
+                })
+            } else {
+                this.handleOpen(pdfurl || paperpdfurl)
+            }
+        },
+        onClose() {
+            this.setData({
+                show: false
+            });
+        },
+        onSelect(event) {
+            this.handleOpen(event.detail.url)
+        },
+        handleOpen(url) {
+            wx.showLoading({
+                title: '加载中...',
+                mask: true
+            })
+            wx.downloadFile({
+                url,
+                success: function (res) {
+                    const filePath = res.tempFilePath
+                    wx.openDocument({
+                        filePath: filePath,
+                        complete(res) {
+                            console.log("打开文档", res)
+                            wx.hideLoading()
+                            if (res.errMsg != 'openDocument:ok') wx.showToast({
+                                title: '打开失败',
+                                icon: "none"
+                            })
+                        }
+                    })
+                },
+                fail(err) {
+                    wx.hideLoading()
+                    wx.showToast({
+                        title: '打开失败',
+                        icon: "none"
+                    })
+                }
+            })
+        },
+    }
+})

+ 4 - 0
packageA/invoice/modules/InvoiceList/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 41 - 0
packageA/invoice/modules/InvoiceList/index.scss

@@ -0,0 +1,41 @@
+@import "../../../../static/common-head.scss";
+
+.count {
+	font-size: 30rpx !important;
+	font-weight: bold;
+}
+
+.item {
+	width: 100vw;
+	display: flex;
+	background-color: #ffffff;
+	padding: 20rpx 30rpx;
+	box-sizing: border-box;
+	margin-bottom: 20rpx;
+
+	.dec {
+		flex: 1;
+		width: 0;
+		min-height: 128rpx;
+		height: 100%;
+		font-size: 24rpx;
+		font-family: PingFang SC-Regular, PingFang SC;
+		color: #999999;
+
+		.title {
+			display: flex;
+			width: 90%;
+			height: 40rpx;
+			font-size: 28rpx;
+			font-weight: 600;
+			color: #333333;
+		}
+
+		.subfield {
+			display: flex;
+			margin-top: 8rpx;
+			height: 34rpx;
+			line-height: 34rpx;
+		}
+	}
+}

+ 38 - 0
packageA/invoice/modules/InvoiceList/index.wxml

@@ -0,0 +1,38 @@
+<view class="head">
+	<view class="count">发票清单</view>
+</view>
+
+<navigator url="#" class="item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" bindtap="previewpdf">
+	<view class="dec">
+		<view class="title line-1">
+			发票ID:{{item.sa_invoiceapplyid}}
+		</view>
+		<view class="subfield">
+			红蓝字:{{item.rb==1?'蓝':'红'}}
+		</view>
+		<view class="subfield">
+			发票流水号:{{item.invoiceserialnum||" --"}}
+		</view>
+		<view class="subfield">
+			开票金额:{{item.sumtaxincludedamount}}元
+		</view>
+		<view class="subfield">
+			发票代码:{{item.invoicecode||" --"}}
+		</view>
+		<view class="subfield">
+			发票号码:{{item.invoiceno||" --"}}
+		</view>
+		<view class="subfield">
+			发票状态:{{item.status||" --"}}
+		</view>
+		<view class="subfield">
+			备注:{{item.remarks||" --"}}
+		</view>
+	</view>
+</navigator>
+<block wx:if="{{list.length==0}}">
+	<Yl_Empty />
+	<view style="height: 150rpx;" />
+</block>
+
+<van-action-sheet show="{{ show }}" actions="{{ actions }}" z-index="99999999" cancel-text="取消" bind:close="onClose" bind:select="onSelect" bind:click-overlay='onClose' />