给欠款详情增加打印和导出excel功能

This commit is contained in:
季圣华
2022-10-18 21:49:37 +08:00
parent 6ad7f157a6
commit b0b1ddf8cb
2 changed files with 29 additions and 29 deletions

View File

@@ -1,4 +1,3 @@
import * as api from '@/api/api'
import { isURL } from '@/utils/validate' import { isURL } from '@/utils/validate'
import XLSX from 'xlsx' import XLSX from 'xlsx'
import Vue from 'vue' import Vue from 'vue'
@@ -527,8 +526,7 @@ export function getNowFormatStr() {
if (strSeconds >= 0 && strSeconds <= 9) { if (strSeconds >= 0 && strSeconds <= 9) {
strSeconds = "0" + strSeconds; strSeconds = "0" + strSeconds;
} }
let currentdate = month + strDate + strHours + strMinutes + strSeconds; return month +''+ strDate +''+ strHours +''+ strMinutes +''+ strSeconds;
return currentdate;
} }
/** /**
@@ -609,7 +607,7 @@ export function sheet2blob (aoa, sheetName) {
workbook.Sheets[sheetName] = sheet workbook.Sheets[sheetName] = sheet
// 生成excel的配置项 // 生成excel的配置项
let wopts = { let wopts = {
bookType: 'xlsx', // 要生成的文件类型 bookType: 'xls', // 要生成的文件类型
bookSST: false, // 是否生成Shared String Table官方解释是如果开启生成速度会下降但在低版本IOS设备上有更好的兼容性 bookSST: false, // 是否生成Shared String Table官方解释是如果开启生成速度会下降但在低版本IOS设备上有更好的兼容性
type: 'binary' type: 'binary'
} }

View File

@@ -28,27 +28,30 @@
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24"> <a-col :md="6" :sm="24">
<a-button type="primary" @click="searchQuery">查询</a-button> <a-button type="primary" @click="searchQuery">查询</a-button>
<a-button style="margin-left: 8px" @click="searchReset">重置</a-button> <a-button style="margin-left: 8px" v-print="'#debtAccountPrint'" icon="printer">打印</a-button>
<a-button style="margin-left: 8px" @click="exportExcel" icon="download">导出</a-button>
</a-col> </a-col>
</span> </span>
</a-row> </a-row>
</a-form> </a-form>
</div> </div>
<!-- table区域-begin --> <!-- table区域-begin -->
<a-table <section ref="debtPrint" id="debtAccountPrint">
bordered <a-table
ref="table" bordered
size="middle" ref="table"
rowKey="id" size="middle"
:columns="columns" rowKey="id"
:dataSource="dataSource" :columns="columns"
:pagination="false" :dataSource="dataSource"
:loading="loading" :pagination="false"
@change="handleTableChange"> :loading="loading"
<span slot="numberCustomRender" slot-scope="text, record"> @change="handleTableChange">
<a @click="myHandleDetail(record)">{{record.number}}</a> <span slot="numberCustomRender" slot-scope="text, record">
</span> <a @click="myHandleDetail(record)">{{record.number}}</a>
</a-table> </span>
</a-table>
</section>
<!-- table区域-end --> <!-- table区域-end -->
<!-- 表单区域 --> <!-- 表单区域 -->
<bill-detail ref="modalDetail"></bill-detail> <bill-detail ref="modalDetail"></bill-detail>
@@ -58,6 +61,7 @@
<script> <script>
import BillDetail from '../../bill/dialog/BillDetail' import BillDetail from '../../bill/dialog/BillDetail'
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { openDownloadDialog, sheet2blob} from "@/utils/util"
import { findBillDetailByNumber } from '@/api/api' import { findBillDetailByNumber } from '@/api/api'
import Vue from 'vue' import Vue from 'vue'
export default { export default {
@@ -168,17 +172,15 @@
onDateOk(value) { onDateOk(value) {
console.log(value); console.log(value);
}, },
searchReset() { exportExcel() {
this.queryParam = { let aoa = [['单据编号', this.columns[2].title, '商品信息', '单据日期', '操作员', '欠款', '已收欠款', '待收欠款']]
organId: this.queryParam.organId, for (let i = 0; i < this.dataSource.length; i++) {
type: this.queryParam.type, let ds = this.dataSource[i]
subType: this.queryParam.subType, let item = [ds.number, ds.organName, ds.materialsList, ds.operTimeStr, ds.userName, ds.needDebt, ds.finishDebt, ds.debt]
beginTime: this.queryParam.beginTime, aoa.push(item)
endTime: this.queryParam.endTime,
roleType: Vue.ls.get('roleType'),
} }
this.loadData(1); openDownloadDialog(sheet2blob(aoa), '欠款详情')
}, }
} }
} }
</script> </script>