| | |
| | | <el-image |
| | | style="width: 95%; height: 90%" |
| | | :src="invoicepdfimg" |
| | | :preview-src-list="invoicepdfimgsrcList" |
| | | @click="invoicehandleImageClick(initialIndex)" |
| | | > |
| | | <!-- <div slot="error" class="image-slot"> |
| | | <i class="el-icon-picture-outline"></i> |
| | | </div> --> |
| | | </el-image> |
| | | <custom-image-viewer |
| | | :url-list="invoicepdfimgsrcList" |
| | | :initial-index="invoicecurrentIndex" |
| | | :visible="invoiceviewerVisible" |
| | | @update:visible="invoiceviewerVisible = $event" |
| | | @close="invoicehandleViewerClose" |
| | | /> |
| | | </div> |
| | | <div v-else class="pdfimgmins">{{ hintitle }}</div> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | import pdf from "vue-pdf"; |
| | | import Decimal from 'decimal.js'; |
| | | import Treeselect from "@riophae/vue-treeselect"; |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| | | import { listDonatebaseinfo } from "@/api/project/donatebaseinfo"; |
| | |
| | | invoicepdfimg: "", |
| | | invoicepdfimgsrcList: [], |
| | | currentIndex: 0, // 初始索引 |
| | | invoicecurrentIndex: 0, // 初始索引 |
| | | initialIndex: 0, // 初始索引 |
| | | viewerVisible: false, // 控制预览组件显示 |
| | | invoiceviewerVisible: false, // 控制预览组件显示 |
| | | |
| | | //人员类别 |
| | | persontype: null, |
| | | //到达地 |
| | |
| | | this.currentIndex = index; |
| | | this.viewerVisible = true; |
| | | }, |
| | | invoicehandleImageClick(index) { |
| | | this.invoicecurrentIndex = index; |
| | | this.invoiceviewerVisible = true; |
| | | }, |
| | | handleViewerClose() { |
| | | this.viewerVisible = false; |
| | | }, |
| | | invoicehandleViewerClose() { |
| | | this.invoiceviewerVisible = false; |
| | | }, |
| | | handleImageError() { |
| | | console.error("图片加载失败"); |
| | |
| | | const index = this.getIndexInArray(this.fileListto, row); |
| | | this.fileListto.splice(index, 1); |
| | | console.log(this.rbDetails[this.atpresent].annexfilesList); |
| | | indexvalue = this.rbDetails[this.atpresent].annexfilesList.find( |
| | | (item, index) => { |
| | | return item.name == row.name; |
| | | } |
| | | ); |
| | | console.log(indexvalue, "删除索引"); |
| | | this.rbDetails[this.atpresent].annexfilesList.splice(indexvalue, 1); |
| | | // indexvalue = this.rbDetails[this.atpresent].annexfilesList.find( |
| | | // (item, index) => { |
| | | // return item.name == row.name; |
| | | // } |
| | | // ); |
| | | // console.log(indexvalue, "删除索引"); |
| | | // this.rbDetails[this.atpresent].annexfilesList.splice(indexvalue, 1); |
| | | const targetIndex = this.rbDetails[ |
| | | this.atpresent |
| | | ].annexfilesList.findIndex(item => { |
| | | return item.name === row.name; // 建议使用严格相等 === |
| | | }); |
| | | console.log(targetIndex, "删除索引"); // 现在打印的是索引号,例如 0, 1, 2... |
| | | |
| | | if (targetIndex > -1) { |
| | | // 确保找到了元素 |
| | | this.rbDetails[this.atpresent].annexfilesList.splice(targetIndex, 1); |
| | | console.log("删除成功"); |
| | | } else { |
| | | console.log("未找到对应项目,无法删除"); |
| | | } |
| | | } else { |
| | | const indexlist = this.getIndexInArray( |
| | | this.invoicepdfimgsrcList, |
| | |
| | | const index = this.getIndexInArray(this.invoicefileListto, row); |
| | | this.invoicefileListto.splice(index, 1); |
| | | console.log(this.rbDetails[this.atpresent].invoicefilesList); |
| | | indexvalue = this.rbDetails[this.atpresent].invoicefilesList.find( |
| | | (item, index) => { |
| | | return item.name == row.name; |
| | | } |
| | | ); |
| | | console.log(indexvalue, "删除索引"); |
| | | this.rbDetails[this.atpresent].invoicefilesList.splice(indexvalue, 1); |
| | | const targetIndex = this.rbDetails[ |
| | | this.atpresent |
| | | ].invoicefilesList.findIndex(item => { |
| | | return item.name === row.name; // 建议使用严格相等 === |
| | | }); |
| | | console.log(targetIndex, "删除索引"); // 现在打印的是索引号,例如 0, 1, 2... |
| | | |
| | | if (targetIndex > -1) { |
| | | // 确保找到了元素 |
| | | this.rbDetails[this.atpresent].invoicefilesList.splice( |
| | | targetIndex, |
| | | 1 |
| | | ); |
| | | console.log("删除成功"); |
| | | } else { |
| | | console.log("未找到对应项目,无法删除"); |
| | | } |
| | | } |
| | | }, |
| | | // 点击上移 |
| | |
| | | this.$refs["form"].validate(valid => { |
| | | if (valid) { |
| | | //票据文件处理 |
| | | const addnumber = this.rbPayees.reduce( |
| | | (amount, item) => amount + Number(item.amount), |
| | | 0 |
| | | ); |
| | | // const addnumber = new Decimal(this.rbPayees.reduce((amount, item) => amount + Number(item.amount), 0 )); |
| | | // console.log(this.form.amountrequested,addnumber); |
| | | // //校验请款金额合计是否等于报销单金额 |
| | | // if (this.form.amountrequested != addnumber) { |
| | | // this.$message({ |
| | | // message: |
| | | // "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!!", |
| | | // type: "warning" |
| | | // }); |
| | | // return; |
| | | // } |
| | | |
| | | // 1. 在 reduce 累加时,直接传入字符串给 Decimal,并使用 .plus() 方法进行累加 |
| | | // 初始值设为 new Decimal(0),确保全程高精度运算 |
| | | const addnumber = this.rbPayees.reduce((amount, item) => { |
| | | return amount.plus(new Decimal(item.amount.toString())); |
| | | }, new Decimal(0)); |
| | | |
| | | //校验请款金额合计是否等于报销单金额 |
| | | if (this.form.amountrequested != addnumber) { |
| | | console.log(this.form.amountrequested, addnumber.toString()); |
| | | |
| | | // 2. 使用 Decimal 的 .eq() 方法进行严格相等比较 |
| | | // 这样既解决了精度问题,也解决了类型转换比较的问题 |
| | | if (!addnumber.eq(this.form.amountrequested)) { |
| | | this.$message({ |
| | | message: |
| | | "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!", |
| | | message: "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!!", |
| | | type: "warning" |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | |
| | | const rbDetails = [...this.rbDetails]; |
| | | const rbPayees = [...this.rbPayees]; |
| | |
| | | (amount, item) => amount + Number(item.amount), |
| | | 0 |
| | | ); |
| | | console.log(addnumber, "addnumber"); |
| | | this.$refs["form"].validate(valid => { |
| | | if (valid) { |
| | | //票据文件处理 |
| | |
| | | if (this.form.amountrequested != addnumber) { |
| | | this.$message({ |
| | | message: |
| | | "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!", |
| | | "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!!!", |
| | | type: "warning" |
| | | }); |
| | | return; |