ttk-app-core
Version:
enterprise develop framework
910 lines (831 loc) • 34.7 kB
JavaScript
import React from 'react'
import { action as MetaAction, AppLoader } from 'edf-meta-engine'
import { fromJS, toJS } from 'immutable'
import config from './config'
import { TableOperate, Select, Button, Modal, Checkbox, PrintOption2 } from 'edf-component'
import sortSearchOption from './utils/sortSearchOption'
import moment from 'moment'
import { FormDecorator } from 'edf-component'
import changeToOption from './utils/changeToOption'
import { consts } from 'edf-consts'
import utils from 'edf-utils'
import { LoadingMask } from 'edf-component'
import renderColumns from './utils/renderColumns'
const Option = Select.Option
class action {
constructor(option) {
this.metaAction = option.metaAction
this.config = config.current
this.webapi = this.config.webapi
this.voucherAction = option.voucherAction
this.selectedOption = []
}
onInit = ({ component, injections }) => {
this.component = component
this.injections = injections
injections.reduce('init')
let addEventListener = this.component.props.addEventListener
if (addEventListener) {
addEventListener('onTabFocus', :: this.onTabFocus)
addEventListener('enlargeClick', () => this.onResize({}))
}
this.load()
}
onTabFocus = async (params) => {
params = params.toJS()
if( params.initSearchValue && params.accessType ==1 ) {
const searchValue = this.metaAction.gf('data.searchValue').toJS()
const initValue = params.initSearchValue
const linkInAccountName = params.linkInAccountName
this.searchValueChange({...searchValue, ...initValue}, initValue.accountCode, params.showOption, linkInAccountName)
}else{
const result = await this.webapi.person.getDisplayDate()
const { DisplayDate, EnableDate } = result
this.injections.reduce('updateArr',[
{
path: 'data.enableDate',
value: utils.date.transformMomentDate(EnableDate)
}
])
const searchValue = this.metaAction.gf('data.searchValue').toJS()
this.searchValueChange(searchValue)
}
}
load = async () => {
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
}
await this.getEnableDate()
this.initDate()
this.getInitOption()
}
linkInTab = async() => {
const searchValue = this.metaAction.gf('data.searchValue').toJS()
const initValue = this.component.props.initSearchValue
const linkInAccountName = this.component.props.linkInAccountName
if( initValue.currencyId != undefined ){
initValue.currencyId = initValue.currencyId.toString()
}
const showOption = this.component.props.showOption
this.searchValueChange({...searchValue, ...initValue}, initValue.accountCode, showOption, linkInAccountName)
}
initDate = () => {
if( this.component.props.initData && this.component.props.initData.date ) {
const str = this.component.props.initData.date
this.injections.reduce('updateArr',[{
path: 'data.searchValue.date_start',
value: utils.date.transformMomentDate(str)
},{
path: 'data.searchValue.date_end',
value: utils.date.transformMomentDate(str)
}])
}
}
getEnableDate = async() => {
const result = await this.webapi.person.getDisplayDate()
const { DisplayDate, EnableDate } = result
this.injections.reduce('updateArr',[
{
path: 'data.searchValue.date_start',
value: utils.date.transformMomentDate(DisplayDate)
},
{
path: 'data.searchValue.date_end',
value: utils.date.transformMomentDate(DisplayDate)
},
{
path: 'data.enableDate',
value: utils.date.transformMomentDate(EnableDate)
}
])
return
}
componentWillReceiveProps = ({ keydown }) => {
if (keydown && keydown.event) {
let e = keydown.event
if( e.keyCode == 39 || e.keyCode == 40 ) {
this.accountlistBtn('right')
}else if ( e.keyCode == 37 || e.keyCode == 38 ) {
this.accountlistBtn('left')
}
}
}
componentDidMount = () => {
if (window.addEventListener) {
window.addEventListener('resize', this.onResize, false)
} else if (window.attachEvent) {
window.attachEvent('onresize', this.onResize)
} else {
window.onresize = this.onResize
}
}
componentWillUnmount = () => {
if (window.removeEventListener) {
window.removeEventListener('resize', this.onResize, false)
} else if (window.detachEvent) {
window.detachEvent('onresize', this.onResize)
} else {
window.onresize = undefined
}
}
// 点击刷新按钮
refreshBtnClick = () => {
this.sortParmas()
}
// 初始化基础信息选项
getInitOption = async () => {
if( this.component.props.initSearchValue ){
await this.linkInTab()
}else{
const params = this.sortParmas(null, null, 'get')
const res = await this.webapi.person.queryForCurrency(
sortSearchOption(params, null, ['accountCode', 'currencyId'])
)
this.injections.reduce('tableLoading', false)
const accountList = res.accountList
this.injections.reduce('normalSearchChange', {
path: 'data.searchValue.accountCode',
value: accountList[0] ? accountList[0].code : ''
})
const currencyList = changeToOption(res.currencyList, 'name', 'id')
this.injections.reduce('initOption', { ...res, currencyList })
if( accountList.length > 0 ){
this.accountlistChange(accountList[0].code, true)
}
}
setTimeout(()=>{
this.onResize()
},20)
}
//获取时间选项
getNormalDateValue = () => {
const data = this.metaAction.gf('data.searchValue').toJS()
const arr = []
arr.push(data.date_start)
arr.push(data.date_end)
return arr
}
// 简单搜索条件发生改变
accountlistBtn = (type) => {
const accountlist = this.metaAction.gf('data.other.accountlist').toJS()
const accountCode = this.metaAction.gf('data.searchValue.accountCode')
if( !accountCode ) {
this.accountlistChange(accountlist[0] ? accountlist[0].code : null)
return
}
let index = accountlist.findIndex(item => item.code == accountCode)
let code
switch (type){
case 'right':
code = accountlist[index+1]&& accountlist[index+1].code ? accountlist[index+1].code : accountCode
break
case 'left':
code = accountlist[index - 1] && accountlist[index - 1].code ? accountlist[index - 1].code : accountCode
break
default:
code = accountCode
break
}
this.accountlistChange(code)
}
accountlistChange = (value, noSend, showOption) => {
const accountlist = this.metaAction.gf('data.other.accountlist').toJS()
const item = accountlist.find(index => {
return index.code == value
})
let { num, currency } = showOption ? showOption : {}
const currency1 = this.metaAction.gf('data.searchValue.currencyId')
this.injections.reduce('update', {
path: 'data.showCheckbox',
value: {
quantity: item == -1 || !item ? false : item.isCalcQuantity,
multi: currency1 == '0' || currency1 == '1' ? false : (item == -1 || !item ? false : item.isCalcMulti)
}
})
this.injections.reduce('update', {
path: 'data.showOption',
value: {
num: num != undefined ? num : item == -1 || !item ? false : item.isCalcQuantity,
currency: currency != undefined ? currency : (currency1 == '0' || currency1 == '1' ? false : (item == -1 || !item ? false : item.isCalcMulti))
}
})
this.injections.reduce('normalSearchChange', { path: 'data.searchValue.accountCode', value })
if( noSend != true ){
this.sortParmas()
}
}
onPanelChange = (value) => {
let date = {
date_end: value[1],
date_start: value[0]
}
const searchValue = this.metaAction.gf('data.searchValue').toJS()
// 修改逻辑简单搜索也需要重新
this.searchValueChange({ ...searchValue, ...date })
}
getNormalSearchValue = () => {
const data = this.metaAction.gf('data.searchValue').toJS()
let date = [ data.date_start, data.date_end ]
return { date, query: data.query }
}
transformDateToNum=(date)=>{
try{
if( !date ){
return 0
}
let time = date
if( typeof date == 'string' ){
time = utils.date.transformMomentDate(date)
}
return parseInt(`${time.year()}${time.month() < 10 ? `0${time.month()}` : `${time.month()}`}`)
}catch(err){
console.log(err)
return 0
}
}
/**
* current 每个月份
* pointTime 指定比较的时间
* type 'pre' 前 'next' 后
* return 返回 true 代表禁用
*/
disabledDate = (current, pointTime, type) => {
const enableddate = this.metaAction.gf('data.enableDate')
const enableddateNum = this.transformDateToNum(enableddate)
if( type == 'pre' ) {
let currentMonth = this.transformDateToNum(current)
return currentMonth < enableddateNum
}else{
let currentMonth = this.transformDateToNum(current)
let pointTimeMonth = this.transformDateToNum(pointTime)
return currentMonth < pointTimeMonth || currentMonth < enableddateNum
}
}
renderCheckBox = () => {
return (
<Checkbox.Group className="app-proof-of-list-accountQuery-search-checkbox">
<Checkbox value="1">科目无发生不显示本月合计、本年累计</Checkbox>
</Checkbox.Group>
)
}
searchValueChange = (value, accountCode, showCheckbox, linkInAccountName) => {
let prevValue = this.metaAction.gf('data.searchValue').toJS()
this.injections.reduce('searchUpdate', { ...prevValue , ...value})
let page = this.metaAction.gf('data.pagination').toJS()
if(prevValue){
if (prevValue.noDataNoDisplay && prevValue.noDataNoDisplay.length>0){
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '高级查询选择科目无发生不显示本月合计、本年累计'])
}
if (prevValue.currencyId == '0' || prevValue.currencyId == '1') {
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '高级查询选择综合本位币或人民币'])
} else {
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '高级查询选择外币'])
}
}
this.sortParmas(
{ ...prevValue , ...value},
{ currentPage: 1, pageSize: page.pageSize },
null,
'moreSearch',
accountCode,
showCheckbox,
linkInAccountName
)
}
sortParmas = (search, pages, type, from, accountCode, showCheckbox, linkInAccountName) => {
// 处理搜索参数
if (!search) {
search = this.metaAction.gf('data.searchValue').toJS()
}
if (!pages) {
pages = this.metaAction.gf('data.pagination').toJS()
}
const changeData = {
'date_start': {
'beginDate': (data) => data ? data.format('YYYY-MM') : null,
},
'date_end': {
'endDate': (data) => data ? data.format('YYYY-MM') : null,
}
}
const searchValue = sortSearchOption(search, changeData)
searchValue.noDataNoDisplay = searchValue.noDataNoDisplay&& searchValue.noDataNoDisplay.length > 0 ? '1' : '0'
const page = sortSearchOption(pages, null, ['total', 'totalCount', 'totalPage'])
if ( type == 'get' ){
return { ...searchValue, page }
}
this.requestData({ ...searchValue, page}, from, accountCode, showCheckbox, linkInAccountName)
}
//分页发生变化
pageChanged = (current, pageSize) => {
let page = this.metaAction.gf('data.pagination').toJS()
page = {
...page,
'currentPage': current,
'pageSize': pageSize ? pageSize : page.pageSize
}
this.sortParmas(null, page)
}
// 针对没有的科目做处理
checkAccountCode = (accountCode) => {
if( !accountCode ){
return { accountCode: null }
}
const accountList = this.metaAction.gf('data.other.accountlist').toJS()
const item = accountList.find(item => {
return item.code == accountCode
})
if( item ){
return { accountCode }
}
const arr = accountCode.split(' ')
if( arr.length == 1 ){
return { accountCode }
}else{
return {
accountCode: arr[0],
linkInAccountName: arr[1]
}
}
}
requestData = async (params, from, accountCode, showCheckbox, linkInAccountName) => {
if( from == 'moreSearch' ) {
const params = this.sortParmas(null, null, 'get')
const preAccountCode = this.metaAction.gf('data.searchValue.accountCode')
params.accountCode = accountCode ? accountCode : (preAccountCode ? preAccountCode : null)
let loading = this.metaAction.gf('data.loading')
if(!loading){
this.injections.reduce('tableLoading', true)
}
let res
if( accountCode || showCheckbox || linkInAccountName){
res = await this.webapi.person.queryForCurrency( params )
if( res.currencyList ){
const currencyList = changeToOption(res.currencyList, 'name', 'id')
this.injections.reduce('update', {
path: 'data.other.currencylist',
value: currencyList
})
}
}else{
const obj = this.checkAccountCode(params.accountCode)
params.accountCode = obj.accountCode
if( obj.linkInAccountName ){
accountCode = obj.accountCode
linkInAccountName = obj.linkInAccountName
}
res = await this.webapi.person.queryForAccount( params )
}
this.injections.reduce('tableLoading', false)
const accountList = res.accountList
accountCode = this.initAccountCode(accountList, accountCode, linkInAccountName)
this.injections.reduce('normalSearchChange', {
path: 'data.searchValue.accountCode',
value: accountCode
})
this.injections.reduce('update', {
path: 'data.other.accountlist',
value: res.accountList
})
this.accountlistChange(accountCode, true, showCheckbox)
if( res && res.currencyList ){
const currencyList = changeToOption(res.currencyList, 'name', 'id')
this.injections.reduce('initOption', { ...res, currencyList })
}
if( res.dataList && res.dataList.data ){
this.injections.reduce('load', res.dataList)
}else{
const page = this.metaAction.gf('data.pagination').toJS()
this.injections.reduce('load', {
data: [],
page: {
...page,
currentPage: 1,
totalCount: 0,
totalPage: 1
}
})
}
// 针对科目和李彪显示不同一的情况做处理
if( accountCode != preAccountCode ) {
this.sortParmas()
}
}else{
// 针对accountCode不存在情况下不发送请求
if( !params.accountCode ) {
return
}
// 如果科目不存在的话不发送请求
const accountlist = this.metaAction.gf('data.other.accountlist').toJS()
let loading = this.metaAction.gf('data.loading')
if(!loading){
this.injections.reduce('tableLoading', true)
}
const obj = this.checkAccountCode(params.accountCode)
params.accountCode = obj.accountCode
const res = await this.webapi.person.getList(params)
this.injections.reduce('tableLoading', false)
this.injections.reduce('load', res)
}
setTimeout(()=>{
this.onResize()
},20)
}
// 增加一条逻辑在新请求到的accountList中如果原来的accountCode 存在的情况下保持原有的accountCode
// 第二个参数表示总账跳转过来就已经携带科目
initAccountCode = (accountList, accountCode, linkInAccountName) => {
if( typeof accountCode == 'string' && !linkInAccountName ){
return accountCode
}
const preAccountCode = this.metaAction.gf('data.searchValue.accountCode')
const item = accountList.find(index=>{
return index.code == preAccountCode
})
if( item ){
return preAccountCode
}else if(linkInAccountName){
return `${accountCode} ${linkInAccountName} `
}else{
return accountList&&accountList[0] ? accountList[0].code : ''
}
}
shareClick = (e) => {
switch (e.key) {
case 'weixinShare':
this.weixinShare()
break;
case 'mailShare':
this.mailShare()
break;
}
}
weixinShare = async () => {
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
return
}
if(this.metaAction.gf('data.list').toJS().length == 0){
this.metaAction.toast('warning', '当前暂无数据可分享')
return
}
let data = await this.sortParmas(null, null, 'get')
const { currency, num } = this.metaAction.gf('data.showOption').toJS()
let newData = {
accountCode: data.accountCode,
beginDate: data.beginDate,
currencyId: data.currencyId,
endDate: data.endDate,
noDataNoDisplay: data.noDataNoDisplay,
isCalcMulti:currency,
isCalcQuantity: num
}
const ret = this.metaAction.modal('show', {
title: '微信/QQ分享',
width: 300,
footer: null,
children: this.metaAction.loadApp('app-weixin-share', {
store: this.component.props.store,
initData: '/v1/gl/report/gldetailrpt/share',
params: newData
})
})
_hmt && _hmt.push(['_trackEvent', '财务', '总账', '分享微信/QQ'])
}
mailShare = async () => {
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
return
}
if(this.metaAction.gf('data.list').toJS().length == 0){
this.metaAction.toast('warning', '当前暂无数据可分享')
return
}
let data = await this.sortParmas(null, null, 'get')
const { currency, num } = this.metaAction.gf('data.showOption').toJS()
let newData = {
accountCode: data.accountCode,
beginDate: data.beginDate,
currencyId: data.currencyId,
endDate: data.endDate,
noDataNoDisplay: data.noDataNoDisplay,
isCalcMulti: currency,
isCalcQuantity: num,
printAll: false
}
const ret = this.metaAction.modal('show', {
title: '邮件分享',
width: 400,
children: this.metaAction.loadApp('app-mail-share', {
store: this.component.props.store,
shareUrl: '/v1/gl/report/gldetailrpt/share',
period: `${newData.beginDate.replace('-','.')}-${newData.endDate.replace('-','.')}`,
params: newData,
mailShareUrl: '/v1/gl/report/gldetailrpt/sendShareMail',
printShareUrl: '/v1/gl/report/gldetailrpt/print',
})
})
_hmt && _hmt.push(['_trackEvent', '明细账', '总账', '邮件分享'])
}
moreActionOpeate = (e) => {
this[e.key] && this[e.key]()
}
rowSpan = (text, row, index) => {
const obj = {
children: <span>{text}</span>,
props: {
rowSpan: this.calcRowSpan(row.docId, 'docId', index),
},
}
return obj
}
normalSearchChange = (path, value) => {
if( path == 'date' ){
this.onPanelChange(value)
}
}
export = async() => {
let tempWindow = window.open()
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
tempWindow.close()
return
}else{
const params = this.sortParmas(null, null, 'get')
if( !params.accountCode ){
this.metaAction.toast('warn', '当前没有可导出数据')
tempWindow.close()
return
}
const { currency, num } = this.metaAction.gf('data.showOption').toJS()
params.isCalcMulti = currency
params.isCalcQuantity = num
params.exportAll = false
params.tempWindow = tempWindow
await this.webapi.person.export(params)
}
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '导出当前科目'])
}
print = async() => {
let tempWindow = window.open()
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
tempWindow.close()
return
}else{
const params = this.sortParmas(null, null, 'get')
if( !params.accountCode ){
this.metaAction.toast('warn', '当前没有可打印数据')
tempWindow.close()
return
}
const { currency, num } = this.metaAction.gf('data.showOption').toJS()
params.isCalcMulti = currency
params.isCalcQuantity = num
params.printAll = false
params.tempWindow = tempWindow
await this.webapi.person.print(params)
}
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '打印当前科目'])
}
showOptionsChange = (key, value) => {
this.injections.reduce('showOptionsChange', {
path: `data.showOption.${key}`,
value: value
})
}
isTotalData = (record) => {
return record.summary == '本月合计' || record.summary == '本年累计' ? 'total_data_weight' : ''
}
rowSpan2 = (text, row, index) => {
const num = this.calcRowSpan(row.accountDate, 'accountDate', index)
const obj = {
children: <span>
<span className={this.isTotalData(row)}>{text}</span>
</span>,
props: {
rowSpan: num,
},
}
return obj
}
calcRowSpan(text, columnKey, currentRowIndex) {
const list = this.metaAction.gf('data.list')
if (!list) return
const rowCount = list.size
if (rowCount == 0 || rowCount == 1) return 1
if (currentRowIndex > 0
&& currentRowIndex <= rowCount
&& text == list.getIn([currentRowIndex - 1, columnKey])) {
return 0
}
var rowSpan = 1
for (let i = currentRowIndex + 1; i < rowCount; i++) {
if (text == list.getIn([i, columnKey]))
rowSpan++
else
break
}
return rowSpan
}
tableColumns = () => {
let arr
const showOption = this.metaAction.gf('data.showOption').toJS()
const { multi } = this.metaAction.gf('data.showCheckbox').toJS()
const currencyId = this.metaAction.gf('data.searchValue.currencyId')
let type;
if ( showOption.num && showOption.currency) {
arr = renderColumns(4, this.openMoreContent)
if( currencyId == -1 ) {
const index = arr.findIndex(item => item.key == 'balance')
if( index > -1 ){
arr[index].children = arr[index].children.filter(item => item.dataIndex != 'balanceOrigAmount')
}
}
}else if( showOption.num && !showOption.currency ) {
arr = renderColumns(3, this.openMoreContent)
}else if( !showOption.num && showOption.currency ) {
arr = renderColumns(2, this.openMoreContent)
if( currencyId == -1 ) {
const index = arr.findIndex(item => item.key == 'balance')
if( index > -1 ){
arr[index].children = arr[index].children.filter(item => item.dataIndex != 'balanceOrigAmount')
}
}
}else {
arr = renderColumns(1, this.openMoreContent)
}
arr[0].render = this.rowSpan2
return arr
}
getRenderType = () => {
let type
const showOption = this.metaAction.gf('data.showOption').toJS()
const { multi } = this.metaAction.gf('data.showCheckbox').toJS()
const currencyId = this.metaAction.gf('data.searchValue.currencyId')
if( !showOption.num && !showOption.currency ){
type = 0
}else if ( showOption.num && !showOption.currency ){
type = 1
}else if( !showOption.num && showOption.currency ){
type = 4
}else if( showOption.num && showOption.currency ){
type = 5
}
if( type == 4 && currencyId == -1 ){
type = 2
}else if( type == 5 && currencyId == -1 ){
type = 3
}
return type
}
// 计算不可选中的时间
calDisableDate = (current) => {
const enableDate = this.metaAction.gf('data.enableDate')
return false
}
openMoreContent = async (docId) => {
this.component.props.setPortalContent &&
this.component.props.setPortalContent('填制凭证', 'app-proof-of-charge', { accessType: 1,initData: { id: docId } })
}
onResize = (e) => {
let keyRandomTab = Math.floor(Math.random() * 10000)
this.keyRandomTab = keyRandomTab
setTimeout(()=>{
if( keyRandomTab == this.keyRandomTab ){
this.getTableScroll('app-detailaccount-rpt-Body', 'ant-table-thead', 0 , 'ant-table-body', 'data.tableOption', e)
}
},200)
}
getTableScroll = (contaienr, head, num, target, path, e) => {
const tableCon = document.getElementsByClassName(contaienr)[0]
if( !tableCon ){
if( e ){
return
}
setTimeout(()=>{
this.getTableScroll(contaienr, head, num, target, path)
}, 500)
return
}
const header = tableCon.getElementsByClassName(head)[0]
const body = tableCon.getElementsByClassName(target)[0].getElementsByTagName('table')[0]
const pre = this.metaAction.gf(path).toJS()
const y = tableCon.offsetHeight - header.offsetHeight - num
const bodyHeight = body.offsetHeight
if( bodyHeight > y && y != pre.y ){
this.metaAction.sf(path, fromJS({...pre, y}))
}else if( bodyHeight < y && pre.y != null ){
this.metaAction.sf(path, fromJS({...pre, y: null}))
}else {
return false
}
}
filterOptionSummary = (input, option) => {
if (option && option.props && option.props.children) {
return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
return true
}
checkBoxisShow = (key) => {
const showCheckbox = this.metaAction.gf('data.showCheckbox').toJS()
return { display: showCheckbox[key] ? 'inline-block' : 'none'}
}
printAllAccount = async () => {
const _this = this
const currency = this.metaAction.gf('data.other.currencylist').toJS()
this.metaAction.modal('show', {
title: '选择格式',
width: 500,
footer: null,
iconType: null,
children: <PrintOption2 currency={currency} type="打印" callBack={ _this.submitPrintOption } />
})
}
submitPrintOption = async (form) => {
let tempWindow = window.open()
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
tempWindow.close()
return
}else{
let { num, currency, currencyId } = form.getValue()
if( currencyId == '0' ){
currency = false
}else{
currency = true
}
const params = this.sortParmas(null, null, 'get')
params.currencyId = currencyId
if( !params.accountCode ){
this.metaAction.toast('warn', '当前没有可打印数据')
tempWindow.close()
return
}
params.tempWindow = tempWindow
params.isCalcMulti = currency
params.isCalcQuantity = num
params.printAll = true
await this.webapi.person.print(params)
}
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '打印所有科目'])
}
exportAllAccount = async () => {
// let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
// if(forwardingFlag){
// this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
// return
// }
const _this = this
const currency = this.metaAction.gf('data.other.currencylist').toJS()
this.metaAction.modal('show', {
title: '选择格式',
width: 500,
footer: null,
iconType: null,
children: <PrintOption2 currency={currency} type="导出" callBack={ _this.submitExportOption } />
})
}
submitExportOption = async (form) => {
let tempWindow = window.open()
let forwardingFlag = await this.webapi.person.getCarryForwardingFlag()
if(forwardingFlag){
this.metaAction.toast('warning', '您修改了数据,系统正在重新计算,请稍后')
tempWindow.close()
return
}else{
let { num, currency, currencyId } = form.getValue()
if( currencyId == '0' ){
currency = false
}else{
currency = true
}
const params = this.sortParmas(null, null, 'get')
params.currencyId = currencyId
if( !params.accountCode ){
this.metaAction.toast('warn', '没有可导出数据')
tempWindow.close()
return
}
params.isCalcMulti = currency
params.isCalcQuantity = num
params.exportAll = true
params.tempWindow = tempWindow
await this.webapi.person.export(params)
}
_hmt && _hmt.push(['_trackEvent', '财务', '明细账', '导出所有科目'])
}
}
export default function creator(option) {
const metaAction = new MetaAction(option),
voucherAction = FormDecorator.actionCreator({ ...option, metaAction }),
o = new action({ ...option, metaAction, voucherAction }),
ret = { ...metaAction, ...voucherAction, ...o }
metaAction.config({ metaHandlers: ret })
return ret
}