123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
- <template>
- <template-page
- ref="pageRef"
- :getList="getList"
- :exportList="exportList"
- :operation="operation()"
- :optionsEvensGroup="optionsEvensGroup"
- :columnParsing="columnParsing"
- :tableAttributes="tableAttributes"
- :tableEvents="tableEvents"
- :replaceOrNotMap="false"
- >
- <Popu v-if="showPage !== 1">
- <ReceivableListAdd v-if="showPage == 2" @close="handleClose" />
- <ReceivableListApproval :approvalId="approvalId" v-if="showPage == 3" @close="handleClose" />
- <ReceivableListDetail :approvalId="approvalId" :czType="czType" v-if="showPage == 4" @close="handleClose" />
- </Popu>
- <print-preview ref="preView" @initPrint="handleInitPrint" @refreshList="handleRefreshList" :addPrint="addPrint"/>
- </template-page>
- </template>
- <script>
- import TemplatePage from '@/components/template/template-page-1.vue'
- import import_mixin from '@/components/template/import_mixin.js'
- import add_callback_mixin from '@/components/template/add_callback_mixin.js'
- import Popu from '@/components/template/popu.vue'
- import { getCustomerList } from '@/api/finance/wallet'
- import {
- getFinanceOtherReceList,
- getFinanceOtherReceListV2,
- exportFinanceOtherReceListV2,
- getFinanceOtherReceDelete,
- getFinanceOtherReceDetail,
- getFinanceOtherReceApply,
- getFinanceOtherReceAbandon
- } from '@/api/finance/receivable_list'
- import ReceivableListAdd from './components/receivable_list-add'
- import ReceivableListApproval from './components/receivable_list-approval'
- import ReceivableListDetail from './components/receivable_list-detail'
- import { disAutoConnect, hiprint } from 'vue-plugin-hiprint'
- disAutoConnect()
- import printPreview from './components/design/preview.vue'
- import { getCompanyList } from '@/api/user'
- import { numToFixed } from '@/filters'
- import { changeNumberMoneyToChinese } from '@/utils/util'
- export default {
- components: { TemplatePage, Popu, ReceivableListAdd, ReceivableListApproval, ReceivableListDetail, printPreview },
- mixins: [import_mixin, add_callback_mixin],
- data() {
- return {
- visible: false,
- // 事件组合
- optionsEvensGroup: [
- [
- [
- {
- name: '打印发货单',
- click: () => {
- if (!this.recordSelected.length) {
- this.$message.info('请选择数据!')
- return
- }
- this.toPrint()
- },
- isRole: this.$checkBtnRole('print', this.$route.meta.roles)
- }
- ]
- ],
- [
- [
- {
- name: '新增',
- click: this.addOn(() => {
- this.addFn()
- }),
- isRole: this.$checkBtnRole('add', this.$route.meta.roles)
- }
- ]
- ],
- [
- [
- {
- name: '批量删除',
- click: async () => {
- if (this.recordSelected.length === 0) {
- this.$message.error('请选择需要删除的数据')
- return
- }
- let ids = this.recordSelected.map(v => {
- return v.itemId
- })
- let params = { ids: ids.toString() }
- await getFinanceOtherReceDelete(params)
- this.$refs.pageRef.refreshList()
- this.$message.success('批量删除成功')
- },
- isRole: this.$checkBtnRole('del', this.$route.meta.roles)
- }
- ]
- ]
- ],
- // 表格属性
- tableAttributes: {
- // 启用勾选列
- selectColumn: true
- }, // 关闭新增弹窗
- // 表格事件
- tableEvents: {
- 'selection-change': this.selectionChange
- },
- recordSelected: [],
- customerList: [],
- currentPage: 1, // 当前页码
- pageSize: 10, // 每页数量
- listTotal: 0, // 列表总数
- dataList: [], // 列表数据
- searchForm: {
- source: '',
- code: '',
- userName: '',
- startTime: '',
- endTime: '',
- examineBy: ''
- }, //搜索表单
- listLoading: false, // 列表加载loading
- examine: '',
- showPage: 1,
- approvalId: null,
- czType: '',
- isCollapse: true,
- deleList: [],
- hiprintTemplate: '',
- company: '',
- tableSelection: []
- }
- },
- methods: {
- // 列表请求函数
- getList(...p) {
- this.recordSelected = []
- return getFinanceOtherReceListV2(...p)
- },
- // 列表导出函数
- exportList: exportFinanceOtherReceListV2,
- // 表格列解析渲染数据更改
- columnParsing(item, defaultData) {
- return defaultData
- },
- // 监听勾选变化
- selectionChange(data) {
- this.recordSelected = data
- },
- operation() {
- return (h, { row, index, column }) => {
- return (
- <div class="operation-btns">
- {this.$checkBtnRole('print', this.$route.meta.roles) ? (
- <el-button type="text" class="textColor" onClick={() => this.toPrint(row, 2)}>
- 打印
- </el-button>
- ) : null}
- {row.examineStatus == 'WAIT' ||
- (row.examineStatus == 'FAIL' && this.$checkBtnRole('examine', this.$route.meta.roles)) ? (
- <el-button type="text" onClick={() => this.approvalFn(row.id)}>
- 审批
- </el-button>
- ) : null}
- {row.examineStatus == 'SAVE' ? (
- <el-button type="text" onClick={() => this.bringFn(row.id)}>
- 提审
- </el-button>
- ) : null}
- {row.examineStatus == 'OK' || row.examineStatus == 'FAIL' ? (
- <el-button type="text" onClick={() => this.unApprovalFn(row.id)}>
- 弃审
- </el-button>
- ) : null}
- {row.examineStatus == 'SAVE' ? (
- <el-button type="text" onClick={() => this.detailFn(row.id, 'edit')}>
- 编辑
- </el-button>
- ) : null}
- {
- <el-button type="text" onClick={() => this.detailFn(row.id, 'detail')}>
- 详情
- </el-button>
- }
- </div>
- )
- }
- },
- handleClose() {
- this.addOff(() => {
- this.showPage = 1
- })()
- this.$refs.pageRef.refreshList()
- },
- //获取经销商列表
- async getCustomerDataList() {
- let res = await getCustomerList({
- pageNum: 1,
- pageSize: -1
- })
- this.customerList = res.data.records
- },
- //提审
- async bringFn(id) {
- await getFinanceOtherReceApply({ id })
- this.$message.success('提审成功')
- this.getDataList({
- pageNum: this.currentPage,
- pageSize: this.pageSize,
- examineStatus: this.examine
- })
- },
- //弃审
- async unApprovalFn(id) {
- await getFinanceOtherReceAbandon({ id })
- this.$message.success('弃审成功')
- this.getDataList({
- pageNum: this.currentPage,
- pageSize: this.pageSize,
- examineStatus: this.examine
- })
- },
- handleSelectAll(selection) {
- this.tableSelection = this.$refs.table.selection
- },
- //radio切换'
- changeRadioGroupFn(v) {
- this.getDataList({
- pageSize: this.pageSize,
- pageNum: this.currentPage,
- examineStatus: v
- })
- },
- // 更改每页数量
- handleSizeChange(val) {
- this.pageSize = val
- this.currentPage = 1
- this.getDataList({
- pageNum: 1,
- pageSize: this.pageSize,
- examineStatus: this.examine
- })
- },
- // 更改当前页
- handleCurrentChange(val) {
- this.currentPage = val
- this.getDataList({
- pageNum: val,
- pageSize: 10,
- examineStatus: this.examine
- })
- },
- //清除
- async clearFn() {
- await this.$refs.searchForm.resetFields()
- this.examine = ''
- },
- //搜索
- searchFn() {
- this.getDataList({
- ...this.searchForm,
- // examineStatus: this.examine,
- pageSize: this.pageSize,
- pageNum: this.currentPage
- })
- },
- //删除
- async deleFn() {
- let res = this.deleList.toString()
- console.log(res)
- await getFinanceOtherReceDelete({ ids: res })
- this.getDataList({ pageSize: this.pageSize, pageNum: this.currentPage })
- this.$message.success('删除成功')
- this.deleList = []
- },
- selectionChangeFn(value) {
- // console.log(value);
- const res = value.map(v => v.itemId)
- // console.log(res);
- this.deleList = res
- },
- //新建后更新列表
- updateList() {
- this.getDataList({ pageSize: this.pageSize, pageNum: this.currentPage })
- },
- //获取来列表数据
- async getDataList(data) {
- let res = await getFinanceOtherReceList(data)
- // console.log(res);
- res.data.records.forEach(item => {
- item.sums2 = ['itemAmount']
- item.sums1 = ['itemAmount']
- })
- this.dataList = res.data.records
- this.listTotal = res.data.total
- },
- //详情
- detailFn(id, type) {
- this.czType = type
- this.approvalId = id
- this.showPage = 4
- },
- //审批
- approvalFn(id) {
- this.approvalId = id
- this.showPage = 3
- },
- //新建
- addFn() {
- this.showPage = 2
- },
- // 点击打印
- async toPrint(row, type) {
- // 初始化模板,否则生成的模板叠加
- hiprint.init()
- this.hiprintTemplate = new hiprint.PrintTemplate()
- // 兼容批量打印
- let params = !type ? this.recordSelected : [row.id]
- let len = params.length
- let loadingLen = len
- // 使用 i-- 提升for效率
- this.$startLoading()
- for (let i = len; i > 0; i--) {
- try {
- const { data } = await getFinanceOtherReceDetail({
- id: params[i - 1].id || params[i - 1]
- })
- // 模板基础配置
- this.panel = this.hiprintTemplate.addPrintPanel({
- height: 140,
- width: 241,
- fontFamily: '黑体',
- fontSize: 13,
- paperFooter: 340,
- paperHeader: 10,
- paperNumberDisabled: true
- })
- // 获取收款单模板和基础配置
- this.panel.addPrintHtml({
- options: {
- width: 633,
- top: 30,
- left: 20,
- fontFamily: '黑体',
- fontSize: 13,
- content: this.setTableDom(data)
- }
- })
- loadingLen--
- } catch (error) {
- console.log(999)
- this.$endLoading()
- return
- }
- }
- if (loadingLen === 0) {
- this.$endLoading()
- }
- console.log(333)
- // 预览打印内容
- this.$refs.preView.show(this.hiprintTemplate, this.panel)
- },
- getCompanyList() {
- getCompanyList().then(res => {
- this.company = res.data ? res.data[0].companyName : ''
- })
- },
- // 收款单打印模板
- setTableDom(data) {
- console.log(this.company, this.nowDate())
- return `
- <div style="font-family:'黑体';">
- <h1 style="text-align:center">${this.company}其他应收单</h1>
- <div >
- <table border=".5" cellspacing="0" width="856" height="250"
- style="border-color: rgb(0,0,0);
- border-collapse: collapse;
- border-style: none;
- border: 1px solid rgb(0,0,0);
- font-weight: normal;
- direction: ltr;
- padding-bottom: 0pt;
- padding-left: 4pt;
- padding-right: 4pt;
- padding-top: 0pt;
- text-decoration: none;
- vertical-align: middle;
- box-sizing: border-box;
- word-wrap: break-word;
- word-break: break-all;">
- <tr>
- <td>单据编号</td>
- <td>${data.code}</td>
- <td>业务日期</td>
- <td>${data.createTime}</td>
- <td>打印日期</td>
- <td>${this.nowDate()}</td>
- </tr>
- <tr>
- <td>付款单位</td>
- <td colspan="5">${data.items[0].customerName}</td>
- </tr>
- <tr>
- <td>钱包</td>
- <td>${data.items[0].customerWalletName}</td>
- <td>实收金额</td>
- <td style="text-align:right">${numToFixed(data.totalAmount)}</td>
- <td colspan="2">${changeNumberMoneyToChinese(data.totalAmount)}</td>
- </tr>
- <tr>
- <td>备注</td>
- <td colspan="5">${data.remark}</td>
- </tr>
- </table>
- </div>
- <div style="margin:100px 0 0 0">
- <div></div>
- </div>
- </div>
- `
- },
- // 获取当前时间
- nowDate() {
- var date = new Date()
- var seperator1 = '-'
- var year = date.getFullYear()
- var month = date.getMonth() + 1
- var strDate = date.getDate()
- if (month >= 1 && month <= 9) {
- month = '0' + month
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = '0' + strDate
- }
- var currentdate = year + seperator1 + month + seperator1 + strDate
- console.log(currentdate)
- return currentdate
- } ,
- handleRefreshList(){
- this.recordSelected = []
- this.$refs.pageRef.refreshList()
- },
- handleInitPrint(){
- this.$nextTick(() => {
- this.initPrint()
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .selectStyle {
- width: 100%;
- }
- .dateStyle {
- width: 100%;
- }
- .delClass {
- margin-left: 10px;
- }
- </style>
|