|
@@ -1,5 +1,5 @@
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, watchEffect } from "vue";
|
|
|
+import { ref, watchEffect, shallowRef, nextTick } from "vue";
|
|
|
import { addition } from "/@/utils/calc";
|
|
|
import printStyle from "/@/assets/print-style"
|
|
|
|
|
@@ -11,9 +11,11 @@ const initialInfo = {
|
|
|
supplierName: "",
|
|
|
companyName: "",
|
|
|
totalPrice: 0,
|
|
|
+ totalNum: 0,
|
|
|
payNo:""
|
|
|
}
|
|
|
|
|
|
+const isGoodNum = shallowRef(false);
|
|
|
const cgdlist = ref<Array<Record<string, any>>>([])
|
|
|
const cgdInfo = ref({ ...initialInfo })
|
|
|
|
|
@@ -24,6 +26,8 @@ function handleRecord(data: any) {
|
|
|
|
|
|
_cgdlist.forEach((item, index) => {
|
|
|
cgdInfo.value.totalPrice = addition(cgdInfo.value.totalPrice, item.totalPrice)
|
|
|
+ cgdInfo.value.totalNum = addition(cgdInfo.value.totalNum, item.goodNum)
|
|
|
+
|
|
|
cgdlist.value.push({
|
|
|
index: index + 1,
|
|
|
qrdNo: item.qrdCode,
|
|
@@ -43,18 +47,22 @@ function handleRecord(data: any) {
|
|
|
cgdInfo.value.payNo = payNo;
|
|
|
}
|
|
|
|
|
|
-function print() {
|
|
|
- const printInnerHTML = document.getElementById("print-template")!.innerHTML;
|
|
|
- const iframe = document.createElement('iframe');
|
|
|
- iframe.setAttribute('style', 'position: absolute; width: 0; height: 0;'); document.body.appendChild(iframe);
|
|
|
- const iframeDoc = iframe.contentWindow!.document;
|
|
|
- iframeDoc.write(printStyle);
|
|
|
- iframeDoc.write('<div>' + printInnerHTML + '</div>');
|
|
|
-
|
|
|
- setTimeout(function () {
|
|
|
- iframe.contentWindow!.print();
|
|
|
- document.body.removeChild(iframe);
|
|
|
- }, 50);
|
|
|
+function print(isNum = false) {
|
|
|
+ isGoodNum.value = isNum;
|
|
|
+
|
|
|
+ nextTick(() => {
|
|
|
+ const printInnerHTML = document.getElementById("print-template")!.innerHTML;
|
|
|
+ const iframe = document.createElement('iframe');
|
|
|
+ iframe.setAttribute('style', 'position: absolute; width: 0; height: 0;'); document.body.appendChild(iframe);
|
|
|
+ const iframeDoc = iframe.contentWindow!.document;
|
|
|
+ iframeDoc.write(printStyle);
|
|
|
+ iframeDoc.write('<div>' + printInnerHTML + '</div>');
|
|
|
+
|
|
|
+ setTimeout(function () {
|
|
|
+ iframe.contentWindow!.print();
|
|
|
+ document.body.removeChild(iframe);
|
|
|
+ }, 50);
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
|
|
@@ -73,14 +81,15 @@ defineExpose({ print })
|
|
|
<div id="print-template">
|
|
|
<table>
|
|
|
<div class="header">
|
|
|
- <div class="first">对账单</div>
|
|
|
+ <div class="first">{{isGoodNum ? "出库单" : "对账单"}}</div>
|
|
|
<div class="column">
|
|
|
<div class="supplier">供货商: {{ cgdInfo.supplierName }}</div>
|
|
|
<div class="record">对账单号: {{cgdInfo.payNo}}</div>
|
|
|
</div>
|
|
|
<div class="column">
|
|
|
<div class="company">业务公司: {{ cgdInfo.supplierName }}</div>
|
|
|
- <div class="total">总货款: {{ cgdInfo.totalPrice }}</div>
|
|
|
+ <div class="total" v-if="isGoodNum"> 商品总数量: {{cgdInfo.totalNum}}</div>
|
|
|
+ <div class="total" v-else>总货款: {{ cgdInfo.totalPrice }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -92,9 +101,12 @@ defineExpose({ print })
|
|
|
<th style="text-align: left;">商品名称</th>
|
|
|
<th style="text-align: left;" width="30px">单位</th>
|
|
|
<th style="text-align: left;" width="70px">商品数量</th>
|
|
|
- <th style="text-align: left;" width="100px">商品单价</th>
|
|
|
- <th style="text-align: left;" width="100px">总货款</th>
|
|
|
- <th style="text-align: left;" width="30px">税率</th>
|
|
|
+
|
|
|
+ <template v-if="!isGoodNum">
|
|
|
+ <th style="text-align: left;" width="100px">商品单价</th>
|
|
|
+ <th style="text-align: left;" width="100px">总货款</th>
|
|
|
+ <th style="text-align: left;" width="30px">税率</th>
|
|
|
+ </template>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
@@ -105,9 +117,12 @@ defineExpose({ print })
|
|
|
<td>{{ item.goodName }}</td>
|
|
|
<td>{{ item.goodUnit }}</td>
|
|
|
<td>{{ item.goodNum }}</td>
|
|
|
- <td>{{ item.goodPrice }}</td>
|
|
|
- <td>{{ item.totalPrice }}</td>
|
|
|
- <td>{{ item.tax }}</td>
|
|
|
+
|
|
|
+ <template v-if="!isGoodNum">
|
|
|
+ <td>{{ item.goodPrice }}</td>
|
|
|
+ <td>{{ item.totalPrice }}</td>
|
|
|
+ <td>{{ item.tax }}</td>
|
|
|
+ </template>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|