ttk-app-core
Version:
enterprise develop framework
1,101 lines (1,042 loc) • 43.4 kB
JavaScript
import React from 'react'
import { action as MetaAction, AppLoader } from 'edf-meta-engine'
import { List, fromJS } from 'immutable'
import moment from 'moment'
import config from './config'
import { consts } from 'edf-consts'
import utils from 'edf-utils'
import pzjc from './images/pzjc.png'
import syjz from './images/syjz.png'
import qqye from './images/qqye.png'
import kmye from './images/kmye.png'
import cwbb from './images/cwbb.png'
import zcqk from './images/zcqk.png'
import * as data from './data'
import InventoryCosting from './components/InventoryCosting'
import { FormDecorator ,Timeline,Select, Collapse, Icon} from 'edf-component'
class action {
constructor(option) {
this.metaAction = option.metaAction
this.voucherAction = option.voucherAction
this.config = config.current
this.webapi = this.config.webapi
}
onInit = ({ component, injections }) => {
this.voucherAction.onInit({ component, injections })
this.component = component
this.injections = injections
if (this.component.props.setOkListener) {
this.component.props.setOkListener(this.onOk)
}
injections.reduce('init', {
isPop: this.component.props.isPop
})
// this.isMonthEndingClosing=false
this.load()
let addEventListener = this.component.props.addEventListener
if (addEventListener) {
addEventListener('onTabFocus', :: this.onTabFocus)
}
}
onTabFocus = (data) => {
// let oldList = this.metaAction.gf('data.list')
this.metaAction.sfs({
'data.other.isMonthEndingClosing': false,
'data.other.checkAll': false,
'data.oldList': this.metaAction.gf('data.list')
})
this.refresh()
}
refresh = async () => {
this.injections.reduce('btnState',{
isBtnShow:true,
isAgainShow:false,
isAccountShow:false}
)
await this.load()
if(this.metaAction.gf('data.isExpand')){
await this.accountCheck()
}
}
setTabState = () => {
//控制折叠面板
if(this.metaAction.gf('data.isExpand')){
let activeKeys = ['item1', 'item2', 'item3', 'item4', 'item5', 'item6']
this.metaAction.sf('data.activeKey',activeKeys)
this.metaAction.sf('data.activeBtn',true)
}else{
this.metaAction.sf('data.activeKey',[])
this.metaAction.sf('data.activeBtn',false)
}
}
load = async (year) => {
this.metaAction.sf('data.loading',true)
//期末凭证所需接口
let org = this.metaAction.context.get('currentOrg'),
defaultPeriod = await this.webapi.getDisplayPeriod(),
periodDate = org.periodDate.split("-"),
cerficateData = await this.webapi.queryAllCertificate({year: periodDate[0], month: periodDate[1]}),
getGenarateMode = await this.webapi.getGenarateMode(),
oldList = this.metaAction.gf('data.oldList')?this.metaAction.gf('data.oldList').toJS():[]
// oldList.map(o => {
// cerficateData.map(v => {
// v.checked = o.checked
// })
// })
this.metaAction.sfs({
'data.other.disabledDate': `${org.enabledYear}-${org.enabledMonth}`,
'data.other.comparePeriod': `${defaultPeriod.year}-${defaultPeriod.period}`,//结账需比较的期间,并非默认期间
'data.other.period': `${periodDate[0]}-${periodDate[1]}`,
'data.other.defaultPeriod': org.periodDate,
'data.generateMode':getGenarateMode
})
await this.comparePeriod(org.periodDate)
this.metaAction.sf('data.activeKey',[])
let currentYear = moment().format('YYYY'),//当前年份
enabledYear = this.metaAction.context.get("currentOrg").enabledYear, //启用年份
enabledMonth = this.metaAction.context.get("currentOrg").enabledMonth, //启用月份
response
if(year){
response = await this.webapi.query({year: year})
}else{
response = await this.webapi.query({year: currentYear})
}
if(response.finalRecord.month){
this.metaAction.sf('data.initialBalanceShow', false)
}else {
this.metaAction.sf('data.initialBalanceShow', true)
}
response.cerficateData = cerficateData
this.metaAction.sf('data.loading',false)
this.injections.reduce('load',response)
}
getPhoto = (type) => {
if(type == 'initialBalance'){
return qqye
}else if(type == 'voucherAudit'){
return pzjc
}else if(type == 'accountBalanceCheck'){
return kmye
}else if(type == 'profitLoss'){
return syjz
}else if(type == 'reportCheck'){
return cwbb
}else {
return zcqk
}
}
//月份渲染
monthCellCustom = (date) => {
let currentOrg = this.metaAction.context.get("currentOrg"),
enableTime = currentOrg.enabledYear + '-' + currentOrg.enabledMonth,
maxClosingPeriod = currentOrg.maxClosingPeriod
return <DateCellCustom enableTime={enableTime} maxClosingPeriod={maxClosingPeriod} nowTime={date.format('YYYY-MM')}></DateCellCustom>
}
accountCheck = async () => {//结账检查
this.metaAction.sfs({
'data.loading': true,
'data.other.rotation': true,
'data.other.checkBtn': false
})
// this.metaAction.sf('data.loading',true)
let {year, month} = await this.getCurrentAccount(),
currentOrg = this.metaAction.context.get("currentOrg")
if(this.metaAction.gf('data.other.isMonthEndingClosing')==true){
this.metaAction.toast('warning', '正在检查,请勿重复点击检查按钮')
return
}
if(Math.floor(moment(currentOrg.enabledYear + '-' + currentOrg.enabledMonth).format('YYYYMM'))==Math.floor(moment(`${year}-${month}`).format('YYYYMM'))){
this.metaAction.sf('data.initialBalanceShow', true)
}else{
this.metaAction.sf('data.initialBalanceShow', false)
}
this.metaAction.sf('data.other.isMonthEndingClosing', true)
let response = await this.webapi.check({year, month})
await this.injections.reduce('account',response)
let item1 = response.mecBalanceDto.mecDtoList.find(o => {
return o.accountBalance < 0
})
let item2 = response.mecBalanceDto.mecBalanceDiffDtoList.find(o => {
return o.diffVal < 0
})
if(!item1){//除固定无形资产一级科目
this.metaAction.sf('data.firstSubject', true)
}else{
this.metaAction.sf('data.firstSubject', false)
}
if(item2){//资产一级科目
this.metaAction.sf('data.firstSubjectAsset', true)
}else{
this.metaAction.sf('data.firstSubjectAsset', false)
}
if(JSON.stringify(response.initialBalance) == "{}"){//不存在期初余额时
//可以结账的条件
if(response.profitLoss!=0 &&
response.voucherAudit.docExistence &&
response.reportCheck.balanceSheetPass &&
response.reportCheck.balanceAndCashFlowPass
){//新加两个字段分别代表 资产负债表 例如表是否需要重算 &&
// !response.reportCheck.isNeedBalanceRecalculation &&
// !response.reportCheck.isNeedProfitStatementRecalculation
//不能结账的条件
if(!item1 &&
!item2 &&
response.documentNumber.docCodeIsSeries &&
response.assetCheck.state &&
response.documentNumber.docCodeIsSequence &&
response.reportCheck.balanceAndProfitStatementPass&&
!response.reportCheck.isNeedBalanceRecalculation &&
!response.reportCheck.isNeedProfitStatementRecalculation
){
await this.injections.reduce('btnState',{
isBtnShow:false,//检查按钮
isAgainShow:false,//重新检查按钮
isAccountShow:true, //结账按钮,
immediatelyAccountBtn: true
})
}
else {
await this.injections.reduce('btnState',{
isBtnShow:false,
isAgainShow:true,
isAccountShow:true,
immediatelyAccountBtn: true
})
}
}else{
await this.injections.reduce('btnState',{
isBtnShow:false,
isAgainShow:true,
isAccountShow:false,
immediatelyAccountBtn: false
})
}
}else{//存在期初余额时
if(response.profitLoss!=0 &&
response.initialBalance.checkPeriodBegin &&
response.initialBalance.checkYearBegin &&
response.voucherAudit.docExistence &&
response.reportCheck.balanceSheetPass &&
response.reportCheck.balanceAndCashFlowPass
){//新加两个字段分别代表 资产负债表 例如表是否需要重算 &&
// !response.reportCheck.isNeedBalanceRecalculation &&
// !response.reportCheck.isNeedProfitStatementRecalculation
//可以结账的条件
if(!item1 &&
!item2 &&
response.initialBalance &&
response.assetCheck.state &&
response.documentNumber.docCodeIsSeries &&
response.documentNumber.docCodeIsSequence &&
response.reportCheck.balanceAndProfitStatementPass &&
!response.reportCheck.isNeedBalanceRecalculation &&
!response.reportCheck.isNeedProfitStatementRecalculation
){
//不可以结账的条件
await this.injections.reduce('btnState',{
isBtnShow:false,
isAgainShow:false,
isAccountShow:true,
immediatelyAccountBtn: true
})
}
else {
await this.injections.reduce('btnState',{
isBtnShow:false,
isAgainShow:true,
isAccountShow:true,
immediatelyAccountBtn: true
})
}
}else{
await this.injections.reduce('btnState',{
isBtnShow:false,
isAgainShow:true,
isAccountShow:false,
immediatelyAccountBtn: false
})
}
}
this.metaAction.sf('data.isExpand',true)//是否展开
await this.setTabState()
this.metaAction.sfs({
'data.loading': false,
'data.other.rotation': false,
'data.other.isMonthEndingClosing': false
})
}
accountCheckAgain = async () => {
await this.accountCheck()
}
isShowLinkBtn = (type, data) => {
if(type == 'initialBalance') {
if(data.initialBalance&&data.initialBalance.checkPeriodBegin&&data.initialBalance.checkYearBegin&&data.initialBalance.checkLossProfit){
return true
}else {
return false
}
}
}
comparePeriod = async (value) => {
let choosePeriod
if(value){
choosePeriod = new Date(value)
}else{
choosePeriod = utils.moment.stringToMoment(this.metaAction.gf('data.other.period'))
}
let defaultPeriod = utils.moment.stringToMoment(this.metaAction.gf('data.other.comparePeriod')),
period = await this.getCurrentAccount(),
diff = choosePeriod - defaultPeriod
let result = await this.isFinalAccounted()
if(diff <0 ){
if(result){//已经结账并且是最后一个已结账期间,显示反结账
this.metaAction.sfs({
'data.other.unMonthEndingClosingBtn': true,
'data.other.isEdit': false
})
}else{//已经结账但不是最后一个已结账期间,不显示反结账,结账按钮置灰
this.metaAction.sfs({
'data.other.unMonthEndingClosingBtn': false,
'data.other.isEdit': false
})
}
this.metaAction.sf('data.other.isAccountedMonth',true)
}else {//所选期间存在未结账,则可编辑
this.metaAction.sfs({
'data.other.unMonthEndingClosingBtn': false,
'data.other.isEdit': true,
'data.other.isAccountedMonth': false
})
// this.metaAction.sf('data.other.unMonthEndingClosingBtn',false)
}
return diff
}
monthEndingClosing = async () => {//结账
let diff = await this.comparePeriod(),
period = this.metaAction.gf('data.other.comparePeriod').split('-')
if(diff<0){//所选期间是结账期间,则不可编辑
return
}else if(diff>0){//所选期间之前存在未结账期间
this.metaAction.toast('warning', `${period[0]}年${period[1]}月未结账,请按照会计期间顺序结账`)
return
}
if(this.metaAction.gf('data.other.isMonthEndingClosing')==true){
this.metaAction.toast('warning', '正在结账,请勿重复点击结账按钮')
return
}
this.metaAction.sf('data.other.isMonthEndingClosing', true)
// this.isMonthEndingClosing = true
let {year, month} = await this.getCurrentAccount(),
response = await this.webapi.monthEndingClosing({year, month})
if(response){
this.metaAction.toast('success', '结账成功')
this.component.props.onPortalReload && this.component.props.onPortalReload()
this.metaAction.sfs({
// 'data.other.unMonthEndingClosingBtn': true,
isBtnShow:true,
isAgainShow:false,
isAccountShow:false,
immediatelyAccountBtn: false,
initialBalanceShow: false
})
await this.refresh()
await this.setCurrentAccount()
}
this.metaAction.sf('data.other.isMonthEndingClosing', false)
}
undoMonthEndingClosing = async () => {//反结账
if(this.metaAction.gf('data.other.isMonthEndingClosing')==true){
this.metaAction.toast('warning', '正在反结账,请勿重复点击反结账按钮')
return
}
this.metaAction.sf('data.other.isMonthEndingClosing', true)
this.metaAction.sf('data.disabledUndoMonthEndingClosing',true)
let finalRecord = this.metaAction.gf('data.finalRecord').toJS(),
res = await this.webapi.undoMonthEndingClosing({id: finalRecord.id}) ,
period = this.metaAction.gf('data.other.period').split('-')
if(res){
this.metaAction.sf('data.disabledUndoMonthEndingClosing',false)
this.component.props.onPortalReload && this.component.props.onPortalReload()
this.metaAction.toast('success', '反结账成功')
}
this.metaAction.sfs({
'data.other.unMonthEndingClosingBtn': false,
'data.other.isEdit': true
})
await this.setCurrentAccount()
this.metaAction.sfs({
'data.immediatelyAccountBtn': false,
'data.other.isMonthEndingClosing': false
})
}
isAccountedMonth = async () => {//判断是否已结账
let defaultPeriod = utils.moment.stringToMoment(this.metaAction.gf('data.other.comparePeriod')),
period = utils.moment.stringToMoment(this.metaAction.gf('data.other.period'))
if(period < defaultPeriod){
this.metaAction.sf('data.other.isAccountedMonth', true)
}else{
this.metaAction.sf('data.other.isAccountedMonth', false)
}
}
isFinalAccounted = async() => {//判断是否是最后一个结账期间
// debugger
let defaultPeriod = this.metaAction.gf('data.other.comparePeriod')
let period = this.metaAction.gf('data.other.period'),
isFinalAccountedYear ,
year= Number(defaultPeriod.split('-')[0]),
isFinalAccountedMonth ,
month= Number(defaultPeriod.split('-')[1]),
isFinalAccountedPeriod
if(month == 1){
isFinalAccountedMonth = 12
isFinalAccountedYear = year -1
}else{
isFinalAccountedMonth = month -1
isFinalAccountedYear = year
}
isFinalAccountedPeriod = `${isFinalAccountedYear}-${isFinalAccountedMonth}`
let date1 = period.replace(/\-\d{1}$/, function(m) {
return '-0' + m.charAt(1)
}),
date2 = isFinalAccountedPeriod.replace(/\-\d{1}$/, function(m) {
return '-0' + m.charAt(1)
})
if(date1 == date2){
return true
}else{
return false
}
}
getCurrentAccount = async () => {
let period = this.metaAction.gf('data.other.period').split('-')
let year = period[0],
month = period[1]
return {year, month}
}
setCurrentAccount = async () => {
let period = await this.webapi.getDisplayPeriod(),
currentOrg = this.metaAction.context.get("currentOrg")
// let data = await this.webapi.query({year: period.year})
if(Math.floor(moment(currentOrg.enabledYear + '-' + currentOrg.enabledMonth).format('YYYYMM')) == Math.floor(moment(`${period.year}-${period.month}`).format('YYYYMM'))){
this.metaAction.sf('data.initialBalanceShow', true)
}else{
this.metaAction.sf('data.initialBalanceShow', false)
}
this.metaAction.sfs({
'data.other.comparePeriod': `${period.year}-${period.month}`,
'data.other.period': `${period.year}-${period.month}`,
'data.other.checkBtn': true
})
await this.getData()
this.metaAction.sf('data.isExpand',false)
await this.setTabState()
// await this.injections.reduce('load', {
// finalRecord: data.finalRecord,
// dataList: data.dataList,
// currentAccount: this.metaAction.gf('data.other.period')
// })
}
collapseExpand = async (key) => {
if(this.metaAction.gf('data.isBtnShow') == true){
this.metaAction.sf('data.activeKey',[])
this.metaAction.sf('data.activeBtn',false)
}else{
this.metaAction.sf('data.activeKey',key)
this.metaAction.sf('data.activeBtn',true)
}
}
goBeginBalance =async () => {//跳转到期初余额
this.component.props.setPortalContent &&
this.component.props.setPortalContent(
'期初余额',
'app-account-beginbalance',
)
}
goBalanceAccount = async (code1,code2) => {//跳转到余额表
let {year, month} = await this.getCurrentAccount(),
date_end = `${year}-${month}`,
date_start = `${year}-${month}`
this.component.props.setPortalContent &&
this.component.props.setPortalContent('余额表', 'app-balancesum-rpt',{
accessType: 1,
initSearchValue: {
date_end: this.metaAction.stringToMoment(date_end),
date_start: this.metaAction.stringToMoment(date_start),
beginAccountCode: code1,
endAccountCode: code2,
currencyId: "0"
}
})
}
//
goVoucherAudit = async () => {//跳转到凭证管理
let {year, month} = await this.getCurrentAccount(),
date_end = `${year}-${month}`,
date_start = `${year}-01`
this.component.props.setPortalContent &&
this.component.props.setPortalContent(
'凭证管理',
'app-proof-of-list',
{
accessType: 1,
initSearchValue: {
date_end: utils.date.transformMomentDate(date_end),
date_start: utils.date.transformMomentDate(date_end)
}
}
)
}
goDetailAccount = async (accountCode) => {//跳转到明细账
let {year, month} = await this.getCurrentAccount(),
date_end = `${year}-${month}`,
date_start = `${year}-${month}`
this.component.props.setPortalContent &&
this.component.props.setPortalContent('明细账', 'app-detailaccount-rpt', {
accessType: 1,
initSearchValue: {
accountCode: accountCode,
currencyId: "0",
// noDataNoDisplay: searchValue.nodatanodisplay,
date_end:utils.date.transformMomentDate(date_end),
date_start: utils.date.transformMomentDate(date_start),
noDataNoDisplay: ["1"]
},
})
}
goAssetCheck = async () => {//跳转到资产折旧摊销
let {year, month} = await this.getCurrentAccount()
// if(parseInt(month)<10 && `{month}`.indexOf('0')==-1){
// month = `0${month}`
// }
this.component.props.setPortalContent &&
this.component.props.setPortalContent('折旧摊销', 'app-asset-depreciation',{
accessType: 1,
initSearchValue: {
date: `${year}-${month}`
}}
)
}
goProfitLoss = async () => {//跳转到填制凭证
let {year, month} = await this.getCurrentAccount(),
res = await this.webapi.createLossProfitDoc({"year":year,"period": month})
this.component.props.setPortalContent &&
this.component.props.setPortalContent('填制凭证', 'app-proof-of-charge', {
accessType: 1,
initData: { id: res } })
}
goBalanceSheetPass = async () => {//跳转到资产负债表
let {year, month} = await this.getCurrentAccount()
// if(parseInt(month)<10&&`{month}`.indexOf('0')==-1){
// month = `0${month}`
// }
let params = {
period: {
type: 'month',
year: year,
period: month,
name:`${year}年${month}月`
},
resetArApAccount: true
}
this.component.props.setPortalContent &&
this.component.props.setPortalContent(
'资产负债表',
'app-balancesheet-rpt',{
accessType: 1,
initSearchValue: params
}
)
}
goBalanceAndProfitStatementPass = async () => {//跳转到利润表
let {year, month} = await this.getCurrentAccount()
// if(parseInt(month)<10&&`{month}`.indexOf('0')==-1){
// month = `0${month}`
// }
let params = {
period: {
type: 'month',
year: year,
period: month,
name:`${year}年${month}月`
}
}
this.component.props.setPortalContent &&
this.component.props.setPortalContent(
'利润表',
'app-profitstatement-rpt', {
accessType: 1,
initSearchValue: params
}
)
}
goBalanceAndCashFlowPass = async () => {//跳转到现金流量表
let {year, month} = await this.getCurrentAccount()
// if(parseInt(month)<10&&`{month}`.indexOf('0')==-1){
// month = `0${month}`
// }
let params = {
period: {
type: 'month',
year: year,
period: month,
name:`${year}年${month}月`
}
}
this.component.props.setPortalContent &&
this.component.props.setPortalContent(
'现金流量表',
'app-cashflowstatement-rpt',{
accessType: 1,
initSearchValue: params
}
)
}
getSubContentDisplay = (data,accountCheck) => {
let ret
if(accountCheck.grade == 1){
if(accountCheck.isEndNode==true){
ret = "flex"
}else {
if(accountCheck.firstSubject==false){
ret = "none"
}else{
ret = "flex"
}
}
}else if(accountCheck.grade !=1){
if(accountCheck.accountBalance<0){
ret = "flex"
}else{
ret = "none"
}
}
return ret
}
getSubContent3Display = (accountCheck) => {
let ret
if(accountCheck.accountCode1.length!=4){
if(accountCheck.diffVal<0){
ret = "flex"
}else{
ret = "none"
}
}else{
ret = "flex"
}
return ret
}
getSubContentChildren1 = (accountCheck) => {
let ret
if(accountCheck.accountCode1.length == 4){
if(accountCheck.accountCode1.slice(0,4)=="1601"){
ret = "固定资产"
}else if(accountCheck.accountCode1.slice(0,4)=="1701"){
ret = "无形资产"
}
}else{
ret = ""
}
return ret
}
getSubContentChildren2 = (accountCheck) =>{
let ret
if(accountCheck.accountCode1.length >4){
if(accountCheck.accountCode1.slice(0,4)=="1601"){
ret = "折旧"
}else if(accountCheck.accountCode1.slice(0,4)=="1701"){
ret = "摊销"
}
}else{
ret = ""
}
return ret
}
clickMenu = (type) => {
switch (type) {
case 'cerficate':
this.metaAction.sf('data.other.currentMenu', 'cerficate')
break;
case 'account':
this.metaAction.sf('data.other.currentMenu', 'account')
break;
}
}
mouseMenu = (type) => {
switch (type) {
case 'cerficate':
this.metaAction.sf('data.other.currentMenuLine', 'cerficate')
break;
case 'account':
this.metaAction.sf('data.other.currentMenuLine', 'account')
break;
}
}
mouseOutMenu = () => {
this.metaAction.sf('data.other.currentMenuLine', this.metaAction.gf('data.other.currentMenu'))
}
setField = async (path, value) => {
let currentOrg = this.metaAction.context.get("currentOrg")
if(path=='data.other.period'){
this.metaAction.sf('data.other.period',value)
let diff = await this.comparePeriod(value)
}
if(Math.floor(moment(currentOrg.enabledYear + '-' + currentOrg.enabledMonth).format('YYYYMM'))==Math.floor(moment(value).format('YYYYMM'))){
this.metaAction.sf('data.initialBalanceShow', true)
}else{
this.metaAction.sf('data.initialBalanceShow', false)
}
this.metaAction.sfs({
'data.activeKey': [],
'data.other.checkBtn': true,
'data.immediatelyAccountBtn': false
})
if(path=='data.generateMode'){
let period = this.metaAction.gf('data.other.period').split('-')
let hasCarryForwardDocByPeriod = await this.webapi.hasCarryForwardDocByPeriod({year: period[0],month: period[1]})
if(hasCarryForwardDocByPeriod){//
if(value==0){//自动切手工
const ret = await this.metaAction.modal('confirm', {
title: '删除',
content: '切换后将会删除系统自动生成的凭证(包含已审核),请确认是否切换?',
})
if(ret){
this.metaAction.sf('data.generateMode',value)
let data = await this.webapi.updateGenarateMode({generateMode: value,year:period[0],month:period[1]})
}
}else if(value==1){//手工切自动
const ret = await this.metaAction.modal('confirm', {
title: '删除',
content: '系统将会跟随损益科目及税金科目时时调整期末凭证,请确认是否切换?',
})
if(ret){
this.metaAction.sf('data.generateMode',value)
let data = await this.webapi.updateGenarateMode({generateMode: value,year:period[0],month:period[1]})
}
}
}else{
this.metaAction.sf('data.generateMode',value)
let data = await this.webapi.updateGenarateMode({generateMode: value,year:period[0],month:period[1]})
}
}else{
await this.getData()
}
}
checkboxItem = async (item,index)=> {
if(item.amount==0){
return
}
let list = this.metaAction.gf('data.list')
list = list.update(index, item => item.set('checked', !list.get(index).get('checked')))
this.metaAction.sf('data.list',list)
}
checkItem = (item,index) => {//手工选择
if(item.amount==0){
return
}
let list = this.metaAction.gf('data.list')
list = list.update(index, item => item.set('checked', !list.get(index).get('checked')))
this.metaAction.sf('data.list',list)
}
checkAll = () => {
let list = this.metaAction.gf('data.list'),
checkAll = this.metaAction.gf('data.other.checkAll')
list = list.map(item=> {
let i
if(item.get('amount')!=0&&!item.get('docId')){
i = item.update('checked', ()=>!checkAll)
}else{
i = item.update('checked', ()=>false)
}
return i
})
this.metaAction.sfs({
'data.list': list,
'data.other.checkAll': !checkAll
})
// this.metaAction.sf('data.list',list)
}
batchGenerate = async () => {//一键生成
let period = this.metaAction.gf('data.other.period').split('-'),
list = this.metaAction.gf('data.list').toJS(),
businessTypeDefinedList = [],//自定义模板列表
businessTypePresetList = [],
businessTypeList = []
list.map(item => {
if(item.checked){
if(item.templateId){
businessTypeDefinedList.push(item.businessType)
}else{
businessTypePresetList.push(item.businessType)
}
}
})
if(businessTypePresetList.length==0){
this.metaAction.toast('warning', '请选择您要一键生成的数据')
return
}
let res = await this.webapi.generateDoc({
businessTypeList: [...businessTypeDefinedList,...businessTypePresetList],
year: period[0],
month: period[1]
})
if(res){
this.metaAction.toast('success', '凭证生成成功')
this.metaAction.sf('data.other.checkAll', false)
await this.getData()
}
}
generateProof = async (item, index) => {//生成凭证
let period = this.metaAction.gf('data.other.period').split('-'),
res = await this.webapi.generateDoc({
businessTypeList: [item.businessType],
year: period[0],
month: period[1]
})
if(res==true){
this.metaAction.toast('success', '凭证生成成功')
await this.getData()
}
}
getData = async () => {
let period = await this.getCurrentAccount()
let cerficateData = await this.webapi.queryAllCertificate(period),
res = await this.webapi.query(period)
res.cerficateData = cerficateData
this.injections.reduce('load', res)
// return res
}
refresh = async () => {//刷新
this.metaAction.sf('data.loading',true)
let period = this.metaAction.gf('data.other.period').split('-'),
cerficateData = await this.webapi.queryAllCertificate({year: period[0], month: period[1]})
if(cerficateData){
this.metaAction.sfs({
'data.list': fromJS(cerficateData),
'data.loading': false
})
}
}
delTemplate = async (item) => {//删除模板
const _this = this
if(item.isAudited!=undefined){
if(item.isAudited == false){
const ret = await this.metaAction.modal('confirm', {
title: '删除',
content: '此操作将删除模板对应已生成凭证,是否确认删除?',
onOk() {
_this.deleteItem(item)
},
onCancel() { }
})
}else{
this.metaAction.toast('warning', '当期对应自定义凭证已经审核,请弃审后处理')
return
}
}else{
const ret = await this.metaAction.modal('confirm', {
title: '删除',
content: '确认删除?'
});
if(ret){
this.deleteItem(item)
}
}
}
deleteItem = async (item) => {
let period = this.metaAction.gf('data.other.period').split('-')
let res = await this.webapi.del({templateId: item.templateId,year: period[0], month: period[1]})
if(res){
this.metaAction.toast('success', '删除成功')
await this.getData()
}
}
setting = async (e,item) => {//编辑模板
e.stopPropagation()
e.preventDefault()
let periodDate = this.metaAction.gf('data.other.period'),
period = {year:periodDate.split('-')[0],month:periodDate.split('-')[1]},
getAmountAndProportion = await this.webapi.getAmountAndProportion(period),
isAccountedMonth = this.metaAction.gf('data.other.isAccountedMonth'),
hasSaleCostCarryForwardDoc = await this.webapi.hasSaleCostCarryForwardDoc(period),
interfacePath = {
getAmountAndProportion: this.webapi.getAmountAndProportion,
updateCarryForwardModeAndProportion: this.webapi.updateCarryForwardModeAndProportion
},
_this = this
if(item.businessType == 5000040005){//结转销售成本设置弹框
this.metaAction.modal('show', {
title: '结转销售成本设置',
width: 420,
footer: null,
iconType: null,
okText: '保存',
className: 'inventoryCosting-modal-container',
children: <InventoryCosting
// height={height}
// maxLineNum={maxLineNum}
// printAuxAccCalc={printAuxAccCalc}
// type={type}
// width={width}
period={period}
initData={getAmountAndProportion}
isAccountedMonth = {isAccountedMonth||hasSaleCostCarryForwardDoc}
callBack={ _this.saveOption }
interfacePath={interfacePath}
/>
})
}else if(item.businessType == 5000040018){//计提附加税费
const result = await this.metaAction.modal('show', {
title: '附加税设置',
height: 400,
width:700,
okText: '保存',
bodyStyle:{paddingTop:'0px'},
children: this.metaAction.loadApp('ttk-gl-app-withdrawing', {
store: this.component.props.store,
initData:{
period: period,
isAccountedMonth: isAccountedMonth
}
})
})
}else{
let isHasProfitAndLossDoc = await this.webapi.isHasProfitAndLossDoc(period)
if(isHasProfitAndLossDoc){
this.metaAction.toast('warning', '当前期间结转损益凭证已经审核,不可编辑自定义模板')
return
}
if(item.isAudited == true){//凭证已经审核
const ret = await this.metaAction.modal('confirm', {
title: '修改',
content: '当期对应自定义凭证将会跟随变动,是否确认修改自定义模板?',
onOk() {
_this.updateItem(item)
},
onCancel() { }
})
}else{
this.updateItem(item)
}
}
}
saveOption = async (form) => {
const {amount,period,proportion,carryForwardMode} = form.state
if(proportion==''&&carryForwardMode == 5000090001){
this.metaAction.toast('warning', '比例不能为空')
return
}
let res = await this.webapi.updateCarryForwardModeAndProportion({
carryForwardMode,proportion
})
if(res){
await this.getData()
}
}
updateItem = async (item) => {
let period = this.metaAction.gf('data.other.period')
if(item.templateId){
const result = await this.metaAction.modal('show', {
title: '自定义模板',
// height: 500,
width:860,
okText: '保存',
children: this.metaAction.loadApp('app-account-cerficate-add', {
store: this.component.props.store,
initData:{
item:item,
isEdit:this.metaAction.gf('data.other.isEdit'),
period: period
} ,
type: 'update',
// isEdit: this.metaAction.gf('data.other.isEdit')
})
})
if(result){
await this.getData()
}
}
}
addModal = async () => {//新增模板
let period = this.metaAction.gf('data.other.period'),
isHasProfitAndLossDoc = await this.webapi.isHasProfitAndLossDoc({year: period.split('-')[0],month: period.split('-')[1]})
if(isHasProfitAndLossDoc){
this.metaAction.toast('warning', '当前期间结转损益凭证已经审核,不可新增自定义模板')
return
}
const result = await this.metaAction.modal('show', {
title: '自定义模板',
// height: 500,
width:860,
okText: '保存',
children: this.metaAction.loadApp('app-account-cerficate-add', {
store: this.component.props.store,
initData: {
period: period
},
type: 'add'
})
})
if(result){
await this.getData()
}
}
linkProofList = (docId) => {
let period = this.metaAction.gf('data.other.period')
this.component.props.setPortalContent &&
this.component.props.setPortalContent(
'填制凭证',
'app-proof-of-charge',
{
accessType: 1,
initData: {
id: docId
}
}
)
}
examine = () => {
}
formatAmount = (param) => {
return utils.number.format(param, 2)
}
}
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
}
class DateCellCustom extends React.Component {
constructor(props) {
super(props)
}
render() {
if (this.props.maxClosingPeriod == '') {
return (
<div >
{Number(moment(this.props.nowTime).format('MM'))}月
</div>
)
} else {
if ((moment(this.props.nowTime) <= moment(this.props.maxClosingPeriod)) && (moment(this.props.nowTime) >= moment(this.props.enableTime))) {
return (
<div style={{ position: 'relative' }}>
{Number(moment(this.props.nowTime).format('MM'))}月
<Icon type="duigou"
fontFamily='edficon'
className='iconCustom'
style={{ fontSize: '17px', float: 'right', position: 'absolute', top: '-4px', right: '-12px' }} />
</div>
)
} else {
return (
<div >
{Number(moment(this.props.nowTime).format('MM'))}月
</div>
)
}
}
}
}