UNPKG

ttk-app-core

Version:
1,361 lines (1,217 loc) 57.3 kB
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 { FormDecorator } from 'edf-component' import { trimLeft, trimRight, trim } from '../../../utils/string/index' import utils from 'edf-utils' class action { constructor(option) { this.metaAction = option.metaAction this.voucherAction = option.voucherAction this.config = config.current this.webapi = this.config.webapi this.menuList = {} } 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) }*/ if (this.component.props.setCancelLister) { this.component.props.setCancelLister(this.onCancel) } let option = { status: this.component.props.status, isGuide: this.component.props.isGuide, menuKey: this.component.props.isMenuCode } this.menuList = option injections.reduce('init', option) this.load() } load = async () => { let res = {}, assetPropertyId = this.metaAction.gf('data.form.assetPropertyId'), statusObj = this.metaAction.gf('data.other.statusObj').toJS() if (this.component.props.id) { let option = { id: this.component.props.id } if (this.component.props.cardId) option.cardId = this.component.props.cardId res = await this.webapi.asset.getById(option) } else { let initData = await this.webapi.asset.query(assetPropertyId) if (initData) res.initEnum = initData } if (res) { if (!res.act) { res.status = this.component.props.status } else { res.status = res.act } res.status = this.component.props.status if (res.initEnum && res.initEnum.beginUseTime1 && res.initEnum.beginUseTime2) { if (res.status == statusObj.new || res.status == statusObj.edit) { let sysDate = res.initEnum.systemDate let assetCardIsEnable = this.getAssetCardIsEnable(assetPropertyId, res.initEnum.beginUseTime1, res.initEnum.beginUseTime2, sysDate, res.initEnum) //卡片初始化时当前属性下是否可新增修改 this.metaAction.sf('data.other.assetCardIsEnable', assetCardIsEnable) } } //isDeprEnd 资产是否全部计提完成 //usesId 用途的初始值 //res.status == statusObj.change 状态为变动时 if (res.asset && res.asset.isDeprEnd != undefined && res.asset.usesId && res.status == statusObj.change) { this.metaAction.sf('data.other.isDeprEnd', res.asset.isDeprEnd) this.metaAction.sf('data.other.usesId', res.asset.usesId) } this.injections.reduce('load', res) } } //资产属性修改 assetPropertyChange = (v) => { let assetCardIsEnable = this.getAssetCardIsEnable(v) this.injections.reduce('openTip', false, true) this.metaAction.sf('data.other.isLineDepreciation', true) this.metaAction.sf('data.other.assetCardIsEnable', assetCardIsEnable) this.getAssetPropertyData(v) } getAssetPropertyData = async (v) => { let id = '', assetTypeList = this.metaAction.gf('data.other.assetProperty').toJS() assetTypeList.map(item => { if (item.id == v) id = item.id }) if (id) { let res = await this.webapi.asset.assetPropertyChange(id) if (res) { this.injections.reduce('assetPropertyChange', v, res) } } } //资产类别修改 assetClass = () => (v) => { let data = { "data.other.assetClassTip": false } this.injections.reduce('openTip', data) let assetClass = this.metaAction.gf('data.other.assetClass') if (assetClass) { let assetClassItem = assetClass.toJS().filter(o => o.id == v)[0] this.fieldChange('data.form.assetClass', assetClassItem) let assetPropertyId = this.metaAction.gf('data.form.assetPropertyId') let option = { assetProperty: assetPropertyId, assetClass: assetClassItem.id + "" } this.assetClassChange(option, assetClassItem) } } assetClassChange = async (option, assetClassItem) => { let response = await this.webapi.asset.getCode(option), useDate, assetPropertyId = this.metaAction.gf('data.form.assetPropertyId'), consts = this.metaAction.gf('data.consts').toJS() if (response) { //固定资产使用月份默认值 if (assetClassItem.id == 35 || assetClassItem.id == 46) useDate = 20 if (assetClassItem.id == 36 || assetClassItem.id == 47) useDate = 10 if (assetClassItem.id == 37 || assetClassItem.id == 48) useDate = 5 if (assetClassItem.id == 38 || assetClassItem.id == 49) useDate = 4 if (assetClassItem.id == 39 || assetClassItem.id == 50) useDate = 3 //无形资产使用月份默认值 if (assetPropertyId == consts.ASSETTYPE_immaterialAssets) useDate = 10 //长期待摊使用月份默认值 if (assetPropertyId == consts.ASSETTYPE_longtermPrepaidExpenses) useDate = 3 this.metaAction.sf('data.form.deprMonth', fromJS(useDate * 12)) this.metaAction.sf('data.other.smallMonth', fromJS(useDate * 12)) this.getDepreciationValue('deprMonth', useDate * 12) this.metaAction.sf('data.other.lineDepreciationTip', true) this.metaAction.sf('data.other.codeTip', true) this.metaAction.sf('data.other.deprMonthTip', true) this.injections.reduce('assetClass', response, assetClassItem) } } //开始使用日期修改带出开始折旧月份 useDateChange = (d) => { let currentOrg = this.metaAction.context.get("currentOrg"), date = this.metaAction.momentToString(d, 'YYYY-MM-DD'), form = this.metaAction.gf('data.form').toJS(), consts = this.metaAction.gf('data.consts').toJS(), beginUseTime1 = this.metaAction.gf('data.other.beginUseTime1'), beginUseTime2 = this.metaAction.gf('data.other.beginUseTime2'), initMounth, systemDate = this.metaAction.gf('data.other.currentDate'), data = { "data.other.buyDateTip": false } this.injections.reduce('openTip', data) //控制期初是否勾选 beginUseTime1 = this.getBeginUseTime(beginUseTime1) beginUseTime2 = this.getBeginUseTime(beginUseTime2) //计算期初已折旧期数和期初累计折旧,红色提示去掉 this.metaAction.sf('data.other.initDeprMonthsTip', true) this.metaAction.sf('data.other.initAccuDepreciationTip', true) let beginUseTime = beginUseTime1 if (form.assetPropertyId == consts.ASSETTYPE_fixedAssets) beginUseTime = beginUseTime2 if (moment(date) < moment(beginUseTime)) { this.metaAction.sf('data.form.isHasInit', true) this.metaAction.sf('data.other.isDisableHasInit', false) this.metaAction.sf('data.other.isDisableLineDepreciation', false) this.metaAction.sf('data.other.useDateBefore', true) } else { this.metaAction.sf('data.form.isHasInit', false) this.metaAction.sf('data.other.isDisableHasInit', true) this.metaAction.sf('data.other.useDateBefore', false) } initMounth = this.getBeginDepr(date) //控制开始折旧月份 if (date && currentOrg && currentOrg.enabledMonth && currentOrg.enabledYear) { let startDate = this.metaAction.momentToString(date, 'YYYY-MM'), enabledDate = this.getDate(currentOrg) if (moment(enabledDate) > moment(date)) startDate = enabledDate if (moment(initMounth) < moment(startDate)) initMounth = utils.moment.stringToMoment(systemDate).format('YYYY-MM') } //一次性加速,期初已折旧期数为1,期初累计折旧为原值*(1-残值率),置灰不可修改 if (form.deprMethod.id == consts.DEPRMETHOD_0004) { let initAccuDepreciation, origValue = this.metaAction.gf('data.form.origValue'), salvageRate = this.metaAction.gf('data.form.salvageRate') salvageRate = salvageRate ? salvageRate : 0 initAccuDepreciation = origValue ? origValue * (1 - salvageRate / 100) : '' this.metaAction.sf('data.form.initDeprMonths', 1) this.metaAction.sf('data.form.initAccuDepreciation', initAccuDepreciation) this.metaAction.sf('data.other.initDepr', true) this.metaAction.sf('data.other.disableBeginDeprPeriod', true) //不提折旧,期初已折旧期数为空,期初已累计折旧为空,置灰不可修改 } else if (form.deprMethod.id == consts.DEPRMETHOD_0005) { this.metaAction.sf('data.form.initDeprMonths', '') this.metaAction.sf('data.form.initAccuDepreciation', '') this.metaAction.sf('data.other.initDepr', true) this.metaAction.sf('data.other.disableBeginDeprPeriod', true) //其他折旧方法 } else { let initDeprMonths = this.getDiffInitDeprMonths(initMounth, this.metaAction.momentToString(d, 'YYYY-MM')), lineDepreciation = this.metaAction.gf('data.form.lineDepreciation'), initAccuDepreciation = initDeprMonths * (lineDepreciation ? lineDepreciation : 0) this.metaAction.sf('data.form.initDeprMonths', initDeprMonths) this.metaAction.sf('data.form.initAccuDepreciation', initAccuDepreciation) if (form.deprMethod.id != consts.DEPRMETHOD_0001) this.getDepreciationValue('buyDate', d) } this.fieldChange('data.form.buyDate', date) this.injections.reduce('useDateChange', initMounth) } //新增计量单位/核算项目 addUnitProject = async (name, path, title) => { if (title == '计量单位') { _hmt && _hmt.push(['_trackEvent', '资产', '资产卡片弹框', '计量单位新增']) } else if (title == '项目') { _hmt && _hmt.push(['_trackEvent', '资产', '资产卡片弹框', '核算项目新增']) } else if (title == '部门') { _hmt && _hmt.push(['_trackEvent', '资产', '资产卡片弹框', '使用部门新增']) } const ret = await this.metaAction.modal('show', { title: title, width: 400, children: this.metaAction.loadApp(name, { store: this.component.props.store }), }) if (ret) { this.injections.reduce("addUnitProject", path, ret) } } //折旧方法控制 deprMethod = (option) => { _hmt && _hmt.push(['_trackEvent', '资产', '资产卡片弹框', '折旧/摊销方法']) let form = this.metaAction.gf('data.form').toJS(), consts = this.metaAction.gf('data.consts').toJS(), isHasInit = this.metaAction.gf('data.form.isHasInit'), data = { "data.other.deprMethodTip": false } this.injections.reduce('openTip', data) if (option.id == consts.DEPRMETHOD_0001) { this.metaAction.sf('data.other.isLineDepreciation', true) } else { this.metaAction.sf('data.other.isLineDepreciation', false) } let beginDeprPeriod = this.getBeginDepr(form.buyDate, option) this.metaAction.sf('data.form.beginDeprPeriod', beginDeprPeriod) //一次性加速和不提折旧开始折旧月份置灰不可选 if (isHasInit && (option.id == consts.DEPRMETHOD_0004 || option.id == consts.DEPRMETHOD_0005)) { this.metaAction.sf('data.form.beginDeprPeriod', '') this.metaAction.sf('data.other.disableBeginDeprPeriod', true) } else { this.metaAction.sf('data.other.disableBeginDeprPeriod', false) } //一次性加速,期初已折旧期数为1,期初累计折旧为原值*(1-残值率),置灰不可修改 if (isHasInit && option.id == consts.DEPRMETHOD_0004) { let initAccuDepreciation, origValue = this.metaAction.gf('data.form.origValue'), salvageRate = this.metaAction.gf('data.form.salvageRate') salvageRate = salvageRate ? salvageRate : 0 initAccuDepreciation = origValue ? origValue * (1 - salvageRate / 100) : '' this.metaAction.sf('data.form.initDeprMonths', 1) this.metaAction.sf('data.form.initAccuDepreciation', initAccuDepreciation) this.metaAction.sf('data.other.initDepr', true) //不提折旧,期初已折旧期数为空,期初已累计折旧为空,置灰不可修改 } else if (isHasInit && option.id == consts.DEPRMETHOD_0005) { this.metaAction.sf('data.form.initDeprMonths', '') this.metaAction.sf('data.form.initAccuDepreciation', '') this.metaAction.sf('data.other.initDepr', true) } else { let buyDate = form.buyDate, initDeprMonths = this.getDiffInitDeprMonths(beginDeprPeriod, buyDate) this.metaAction.sf('data.form.initDeprMonths', initDeprMonths) this.metaAction.sf('data.other.initDepr', false) } this.getDepreciationValue("deprMethod", option) this.injections.reduce("deprMethod", option) } //计算税率 getTax = (name, value) => { const form = this.metaAction.gf('data.form').toJS() let origValue = form.origValue, inputTaxRate = form.inputTaxRate origValue = origValue ? origValue : 0 inputTaxRate = inputTaxRate ? inputTaxRate : 0 if (name == 'origValue') { origValue = value } else if (name == 'inputTaxRate') { inputTaxRate = value } if (inputTaxRate) { inputTaxRate = inputTaxRate.taxRate } this.metaAction.sf('data.form.inputTax', origValue * inputTaxRate) } //开始变动日期控制 disabledChangeDate = (current) => { let isDeprEnd = this.metaAction.gf('data.other.isDeprEnd'), deprEndTime = this.metaAction.gf('data.other.deprEndTime'), usesId = this.metaAction.gf('data.other.usesId'), //uses = this.metaAction.gf('data.form.uses'), systemDate = this.metaAction.gf('data.other.currentDate') let form = this.metaAction.gf('data.form').toJS(), assetProperty = this.metaAction.gf('data.other.assetProperty').toJS(), currentEndTime = this.metaAction.momentToString(utils.moment.stringToMoment(systemDate).endOf('day'), "YYYY-MM-DD") let beginUseTime = this.getBeginUseDate() //资产全部计提完成 if (isDeprEnd) { deprEndTime = this.getBeginUseTime(deprEndTime) deprEndTime = this.getNextMonth(deprEndTime) //审核月份(beginUseTime)和最后一期计提折旧月份(deprEndTime) //审核月份大于最后一期计提折旧月份变动时间不能早于最后一期计提折旧月份 //审核月份小于最后一期计提折旧月份变动时间不能早于审核月份 if (moment(deprEndTime) < moment(beginUseTime)) { return current && current < moment(deprEndTime) } else { return current && current < moment(beginUseTime) } } //资产没有全部计提完成 else { let endTime = moment(this.getNextMonth(currentEndTime)).startOf('month').format("YYYY-MM-DD") return current && (current > moment(endTime) || current < moment(beginUseTime)) } } //用途修改时,变动日期不是当前日期应改为当前日期 usesChange = (path, value) => { let systemDate = this.metaAction.gf('data.other.currentDate'), currentDate = utils.moment.stringToMoment(systemDate).format('YYYY-MM-DD'), usesId = this.metaAction.gf('data.other.usesId'), statusObj = this.metaAction.gf('data.other.statusObj').toJS(), isEnable = this.metaAction.gf('data.other.isEnable'), changeDate = this.metaAction.gf('data.form.changeDate'), currentEndTime = this.metaAction.momentToString(utils.moment.stringToMoment(systemDate).endOf('day'), "YYYY-MM-DD"), data = { "data.other.usesTip": false } this.injections.reduce('openTip', data) if (this.component.props.status == statusObj.change && value.id != usesId && !isEnable) { let beginUseTime = this.getBeginUseDate() if (moment(beginUseTime) > moment(changeDate)) { this.metaAction.sf('data.form.changeDate', fromJS(currentDate)) } if (moment(beginUseTime) > moment(currentEndTime)) { this.metaAction.sf('data.other.isEnable', true) } } if (this.component.props.status == statusObj.change && value.id == usesId && isEnable) { this.metaAction.sf('data.other.isEnable', false) } this.fieldChange(path, value) } //变动日期切换和用途切换时获取最小限制时间 getBeginUseDate = () => { let beginUseTime2 = this.metaAction.gf('data.other.beginUseTime2'), beginUseTime, isYj = this.metaAction.gf('data.other.isYj') beginUseTime = this.getBeginUseTime(beginUseTime2) if (!isYj) beginUseTime = this.getNextMonth(beginUseTime) return beginUseTime } //开始使用日期控制 disabledUseDate = (current) => { let systemDate = this.metaAction.gf('data.other.currentDate') return current && current > utils.moment.stringToMoment(systemDate).endOf('month') } // 检验导入的开始使用日期是否大于当前会计期间 checkBuyDate = (option) => { if (!option.value) return '请选择购置日期' let systemDate = this.metaAction.gf('data.other.currentDate'), endDate = this.metaAction.momentToString(utils.moment.stringToMoment(systemDate).endOf('month'), 'YYYY-MM') if (String(option.value).substring(0, 7) > endDate) { return '不能大于当前会计期间' } else { return '' } } //开始折旧/摊销日期控制 disabledBeginDate = (current) => { const form = this.metaAction.gf('data.form').toJS(), currentOrg = this.metaAction.context.get("currentOrg"), systemDate = this.metaAction.gf('data.other.currentDate') if (form.buyDate && currentOrg && currentOrg.enabledMonth && currentOrg.enabledYear) { let startDate = this.metaAction.momentToString(form.buyDate, 'YYYY-MM'), enabledDate = this.getDate(currentOrg), endDate = this.metaAction.momentToString(utils.moment.stringToMoment(systemDate).endOf('month'), 'YYYY-MM') if (moment(enabledDate) > moment(form.buyDate)) startDate = enabledDate endDate = this.getNextMonth(this.getNextMonth(endDate)) return current && (current > moment(endDate) || moment(startDate) > current) } else { return false } } //是否有原始期初值切换 hasInitChange = (path, value) => { _hmt && _hmt.push(['_trackEvent', '资产', '资产卡片弹框', '原始期初值']) this.fieldChange(path, value) let systemDate = this.metaAction.gf('data.other.currentDate'), contextDate = this.metaAction.gf('data.other.contextDate'), current = this.metaAction.momentToString(utils.moment.stringToMoment(systemDate).endOf('month'), 'YYYY-MM') current = this.getBeginDepr(current) if (!value) { this.metaAction.sf('data.form.buyDate', fromJS(utils.moment.stringToMoment(contextDate && moment(contextDate)<=moment(systemDate) ? contextDate : systemDate).format('YYYY-MM-DD'))) this.metaAction.sf('data.other.isDisableLineDepreciation', true) this.metaAction.sf('data.other.isDisableHasInit', true) } else { this.metaAction.sf('data.other.isDisableLineDepreciation', false) } this.metaAction.sf('data.form.beginDeprPeriod', current) } //获取开始折旧月份 getBeginDepr = (date, initDeprMethod) => { let assetPropertyId = this.metaAction.gf('data.form.assetPropertyId'), consts = this.metaAction.gf('data.consts').toJS(), thisMounth = this.metaAction.momentToString(date, 'YYYY-MM'), nextMounth = this.getNextMonth(date), isHasInit = this.metaAction.gf('data.form.isHasInit'), deprMethod = this.metaAction.gf('data.form.deprMethod') deprMethod = (deprMethod && deprMethod.size) ? deprMethod.toJS() : deprMethod if (initDeprMethod) deprMethod = initDeprMethod let initMounth = (assetPropertyId == consts.ASSETTYPE_fixedAssets && deprMethod.id != consts.DEPRMETHOD_0004) ? nextMounth : thisMounth if (isHasInit) initMounth = this.metaAction.gf('data.other.currentDate') if (isHasInit && deprMethod.id == consts.DEPRMETHOD_0004) initMounth = '' if (deprMethod.id == consts.DEPRMETHOD_0005) initMounth = '' return initMounth } //获取卡片新增是否可用,自然月会计期间已经结账 不可新增资产 getAssetCardIsEnable = (v, time1, time2, sysDate, initData) => { let beginUseTime1 = this.metaAction.gf('data.other.beginUseTime1'), beginUseTime2 = this.metaAction.gf('data.other.beginUseTime2'), statusObj = this.metaAction.gf('data.other.statusObj').toJS(), currentOrg = this.metaAction.context.get("currentOrg"), enabledDate = this.getDate(currentOrg), systemDate = this.metaAction.gf('data.other.currentDate') if (time1 && time2) { beginUseTime1 = time1 beginUseTime2 = time2 } beginUseTime1 = this.getBeginUseTime(beginUseTime1) beginUseTime2 = this.getBeginUseTime(beginUseTime2) let consts = this.metaAction.gf('data.consts').toJS(), beginUseTime = beginUseTime1, assetCardIsEnable = true if (v == consts.ASSETTYPE_fixedAssets) beginUseTime = beginUseTime2 if (sysDate) { systemDate = sysDate } if (moment(beginUseTime) > moment(utils.moment.stringToMoment(systemDate).format('YYYY-MM-DD'))) { let status = this.component.props.status, isYj = this.metaAction.gf('data.other.isYj'), name = '审核' if (initData) isYj = initData.isYj if (isYj) { name = '月末结账' beginUseTime2 = this.getPrevMonth(beginUseTime2) } let year = Number(beginUseTime2.split('-')[0]), mounth = Number(beginUseTime2.split('-')[1]), tip = `${year}年${mounth}月资产计提折旧摊销凭证已经${name},不可新增资产` if (enabledDate == beginUseTime.substring(0, 7)) { tip = `本账套启用日期为${currentOrg.enabledYear}年${currentOrg.enabledMonth}月,本月不可新增资产` } if (status == statusObj.edit) tip = `${year}年${mounth}月资产计提折旧摊销凭证已经${name},不可编辑资产` if (status == statusObj.new || status == statusObj.edit) { //变动时初始化时 assetCardIsEnable = false this.metaAction.toast('warning', tip) } } return assetCardIsEnable } getBeginUseTime = (beginUseTime) => { let year = beginUseTime.substring(0, 4), mounth = beginUseTime.substring(4, 6) return `${year}-${mounth}-01` } addThousandsPosition = (inputs, name) => { let input, num, origValues if (name == 'origValue') { origValues = this.metaAction.gf('data.form.origValues') } else if (name == 'lineDepreciation') { origValues = this.metaAction.gf('data.form.lineDepreciation') } else if (name == 'initAccuDepreciation') { origValues = this.metaAction.gf('data.form.initAccuDepreciation') } if (origValues == 0) { return parseFloat(0).toFixed(2) } if (inputs) { input = inputs } else if (origValues && origValues < 9999999999.99) { input = origValues } if (origValues && origValues > 9999999999.99) return input = undefined if (isNaN(input) || input == '') return '' if (input != '') { num = parseFloat(input).toFixed(2) } else { num = input.toString() } return this.addThouPos(num) } //原值修改 getOrigValue = (path, value) => { let data = { "data.other.origValueTip": false } this.injections.reduce('openTip', data) this.metaAction.sf('data.form.origValues', value) let newValue = value.toString().replace(/,/g, '') if (newValue > 9999999999.99) { this.metaAction.sf('data.form.origValue', undefined) return this.metaAction.toast('warning', '原值不能大于9,999,999,999.99,请调整') } this.metaAction.sf('data.form.origValue', newValue) this.metaAction.sf('data.other.lineDepreciationTip', true) this.fieldChange(path, newValue) this.getTax('origValue', newValue) this.getDepreciationValue('origValue', newValue) this.getInitAccDep('origValue', newValue) } //期初累计折旧修改 getInitAccuDepreciation = (path, value) => { let data = { "data.other.initAccuDepreciationTip": false } this.injections.reduce('openTip', data) this.metaAction.sf('data.form.initAccuDepreciation', value) let newValue = value.toString().replace(/,/g, '') if (newValue > 9999999999.99) { this.metaAction.sf('data.form.initAccuDepreciation', undefined) return this.metaAction.toast('warning', '期初累计折旧不能大于9,999,999,999.99,请调整') } this.metaAction.sf('data.form.initAccuDepreciation', newValue) this.fieldChange(path, newValue) } changeDepreciation = (value) => { if (value == '') { this.fieldChange('data.form.initAccuDepreciation', value) } } //备注修改 memoChange = () => { let data = { "data.other.memoTip": false } this.injections.reduce('openTip', data) } //净残值率 salvageRateChange = (path, value) => { let salvageRate = this.metaAction.gf('data.form.salvageRate') if(value && Number(salvageRate)==Number(value)){ this.fieldChange(path, value+'1') } let data = { "data.other.salvageRateTip": false } this.injections.reduce('openTip', data) this.metaAction.sf('data.other.initAccuDepreciationTip', true) this.fieldChange(path, value) this.getDepreciationValue('salvageRate', value) this.getInitAccDep('salvageRate', value) } //计算期初累计折旧 getInitAccDep = (name, value) => { let origValue = this.metaAction.gf('data.form.origValue'), consts = this.metaAction.gf('data.consts').toJS(), salvageRate = this.metaAction.gf('data.form.salvageRate') ? this.metaAction.gf('data.form.salvageRate') : 0, isHasInit = this.metaAction.gf('data.form.isHasInit'), deprMethod = this.metaAction.gf('data.form.deprMethod').size ? this.metaAction.gf('data.form.deprMethod').toJS() : this.metaAction.gf('data.form.deprMethod') if (isHasInit && deprMethod.id == consts.DEPRMETHOD_0004) { if (name == 'origValue') origValue = value if (name == 'salvageRate') salvageRate = value let initAccuDepreciation = origValue ? origValue * (1 - salvageRate / 100) : '' this.metaAction.sf('data.form.initDeprMonths', 1) this.metaAction.sf('data.form.initAccuDepreciation', initAccuDepreciation) this.metaAction.sf('data.other.initDepr', true) } } //月折旧额值改变 getLineDepreciation = (path, value) => { let data = { "data.other.lineDepreciationTip": false } this.injections.reduce('openTip', data) this.metaAction.sf('data.form.lineDepreciation', value) let newValue = value.toString().replace(/,/g, '') if (newValue > 9999999999.99) { this.metaAction.sf('data.form.lineDepreciation', undefined) return this.metaAction.toast('warning', '月折旧额不能大于9,999,999,999.99,请调整') } this.metaAction.sf('data.form.lineDepreciation', newValue) this.fieldChange(path, value) setTimeout(() => { this.getDepreciationValue('lineDepreciation', newValue) }, 1000) } //预计使用月值改变 getDeprMonths = (path, value) => { let data = { "data.other.deprMonthTip": false } this.injections.reduce('openTip', data) let form = this.metaAction.gf('data.form').toJS() if (form.deprMethod.name == "双倍余额递减法") { let option = {} option.name = form.deprMethod.name this.injections.reduce("deprMethod", option) } if (value <= 0) value = '' this.fieldChange(path, value) this.getDepreciationValue('deprMonth', value) } //期初已折旧期数修改 changeInitDeprMonths = (value) => { if (value == '') { this.fieldChange('data.form.initDeprMonths', value) } } getInitDeprMonths = (path, value) => { let data = { "data.other.initDeprMonthsTip": false } this.injections.reduce('openTip', data) this.fieldChange(path, value) this.getDepreciationValue('initDeprMonths', value) } //开始折旧月份修改 beginDeprPeriodChange = (path, value) => { _hmt && _hmt.push(['_trackEvent', '资产', '资产卡片弹框', '在本产品折旧开始月份']) let data = { "data.other.beginDeprPeriodTip": false } this.injections.reduce('openTip', data) this.fieldChange(path, value) this.getDepreciationValue('beginDeprPeriod', value) } //资产数量 getQuantity = (path, value) => { this.fieldChange(path, value) if (!this.checkIsNumber(value)) value = 1 this.fieldChange(path, value) } //计算月折旧额,期初已折旧期数和期初累计折旧 getDepreciationValue = async (name, value) => { let form = this.metaAction.gf('data.form').toJS(), consts = this.metaAction.gf('data.consts').toJS(), origValue = form.origValue, salvageRate = form.salvageRate, deprMonth = form.deprMonth, buyDate = form.buyDate, beginDeprPeriod = form.beginDeprPeriod ? form.beginDeprPeriod : this.getBeginDepr(buyDate), isHasInit = form.isHasInit, deprMethod = form.deprMethod, initDeprMonths = form.initDeprMonths if (name == 'buyDate') buyDate = this.metaAction.momentToString(value, 'YYYY-MM-DD') if (name == 'origValue') origValue = value if (name == 'deprMonth') deprMonth = value if (name == 'salvageRate' && form.assetPropertyId == consts.ASSETTYPE_fixedAssets) salvageRate = value if (form.assetPropertyId != consts.ASSETTYPE_fixedAssets) salvageRate = 0 if (name == 'deprMethod') deprMethod = value if (name == 'beginDeprPeriod') beginDeprPeriod = value if (name == 'beginDeprPeriod') { initDeprMonths = this.getDiffInitDeprMonths(beginDeprPeriod, buyDate) } //debugger if (name == 'initDeprMonths') initDeprMonths = value //debugger //其他的值改变时,期初折旧期数和期初累计折旧额红色提示去掉 if (name != 'lineDepreciation' && name != 'initDeprMonths' && name != 'salvageRate') { this.metaAction.sf('data.other.initDeprMonthsTip', true) this.metaAction.sf('data.other.initAccuDepreciationTip', true) } //期初折旧期数和期初累计折旧额改变时,期初折旧期数和期初累计折旧额红色提示去掉 if (name == 'lineDepreciation' || name == 'initDeprMonths') { this.metaAction.sf('data.other.initAccuDepreciationTip', true) } //净残值率改变时月折旧额计算,月折旧额红色提示去掉 if (name == 'salvageRate' || name == 'deprMethod') { this.metaAction.sf('data.other.lineDepreciationTip', true) } if (deprMethod.id == consts.DEPRMETHOD_0001) { origValue = origValue ? origValue : 0 deprMonth = deprMonth ? deprMonth : 0 salvageRate = salvageRate ? salvageRate : 0 let salvageValue = origValue * (salvageRate / 100), lineDepreciation = deprMonth ? (origValue - salvageValue) / deprMonth : 0 if (name == 'lineDepreciation') { if (value > lineDepreciation - 1 && value < lineDepreciation + 1) lineDepreciation = value this.fieldChange('data.form.lineDepreciation', lineDepreciation) } //debugger let initAccuDepreciation = initDeprMonths * lineDepreciation this.injections.reduce("getDepreciationValue", { lineDepreciation, initDeprMonths, initAccuDepreciation }, name) } else if (isHasInit && (deprMethod.id == consts.DEPRMETHOD_0002 || deprMethod.id == consts.DEPRMETHOD_0003)) { if (origValue && initDeprMonths && deprMonth) { let option = { salvageRate: salvageRate ? salvageRate : 0, //净残值率 initDeprMonths: initDeprMonths, //期初已折旧期数 origValue: origValue, //原值 deprMethodId: deprMethod.id, //折旧方法 deprMonth: deprMonth, //预计使用月 isHasInit: 1, //是否有期初值 beginDeprPeriod: beginDeprPeriod //开始折旧月份 } let response = await this.webapi.asset.checkQCDreption(option) if (response) { this.metaAction.sf('data.form.initAccuDepreciation', response.accuDepreciation) this.metaAction.sf('data.form.initDeprMonths', initDeprMonths) } } else { this.metaAction.sf('data.form.initAccuDepreciation', 0) this.metaAction.sf('data.form.initDeprMonths', initDeprMonths) } } } //获取已折旧期数(已折旧期数与期初已折旧期数之和) geHasDeprMonths = (form) => { let hasDeprMonths = form.hasDeprMonths, initDeprMonths = form.initDeprMonths if (hasDeprMonths !== undefined && initDeprMonths !== undefined) { return Number(hasDeprMonths) + Number(initDeprMonths) } else if (hasDeprMonths !== undefined) { return Number(hasDeprMonths) } else if (initDeprMonths !== undefined) { return Number(initDeprMonths) } else { return '' } } //获取累积折旧的值(累积折旧与期初累积折旧之和) getaccuDepreciation = (form) => { let accuDepreciation = form.accuDepreciation, initAccuDepreciation = form.initAccuDepreciation if (accuDepreciation !== undefined && initAccuDepreciation !== undefined) { return this.addThouPos((Number(accuDepreciation) + Number(initAccuDepreciation)).toFixed(2)) } else if (accuDepreciation !== undefined) { return this.addThouPos((Number(accuDepreciation)).toFixed(2)) } else if (initAccuDepreciation !== undefined) { return this.addThouPos((Number(initAccuDepreciation)).toFixed(2)) } else { return '' } } //获取净值 getNetValue = () => { let form = this.metaAction.gf('data.form').toJS() if (!form.origValue) return '' if (!form.accuDepreciation && !form.initAccuDepreciation) { return this.addThouPos(Number(form.origValue).toFixed(2)) } else if (form.accuDepreciation && form.initAccuDepreciation) { return this.addThouPos(Number(form.origValue - form.accuDepreciation - form.initAccuDepreciation).toFixed(2)) } else if (form.accuDepreciation) { return this.addThouPos(Number(form.origValue - form.accuDepreciation).toFixed(2)) } else if (form.initAccuDepreciation) { return this.addThouPos(Number(form.origValue - form.initAccuDepreciation).toFixed(2)) } return '' } onSave = (name) => { this.onOk(name) } onOk = async (name) => { const adding = this.metaAction.gf('data.other.adding') if (adding) return false let saveOption = await this.save(name) if (saveOption !== false) this.injections.reduce('setIsSaveAndNew', name) if (saveOption !== false && name == 'save') { if (saveOption === undefined) saveOption = true this.component.props.closeModal(saveOption) } } onCancel = () => { let adding = this.metaAction.gf('data.other.adding'), isSaveAndNew = this.metaAction.gf('data.other.isSaveAndNew'), option = false if (adding) return false if (isSaveAndNew) option = isSaveAndNew this.component.props.closeModal(option) } save = async (name) => { this.injections.reduce('openTip', false, false) const form = this.metaAction.gf('data.form').toJS(), other = this.metaAction.gf('data.other').toJS(), consts = this.metaAction.gf('data.consts').toJS() if (other.status == other.statusObj.query) { return { isQuery: true } } let checkArr = [{ path: 'data.form.code', value: form.code }, { path: 'data.form.name', value: form.name }, { path: 'data.form.assetClass', value: form.assetClass }, { path: 'data.form.buyDate', value: form.buyDate }, { path: 'data.form.origValue', value: form.origValue }, { path: 'data.form.deprMonth', value: form.deprMonth }, { path: 'data.form.uses', value: form.uses }, { path: 'data.form.deprMethod', value: form.deprMethod }, { path: 'data.form.salvageRate', value: form.salvageRate }] //有原始期初值必填校验 if (form.isHasInit) { if (form.deprMethod.id == consts.DEPRMETHOD_0004 || form.deprMethod.id == consts.DEPRMETHOD_0005) { checkArr = checkArr } else { checkArr.push({ path: 'data.form.initAccuDepreciation', value: form.initAccuDepreciation }, { path: 'data.form.initDeprMonths', value: form.initDeprMonths }, { path: 'data.form.beginDeprPeriod', value: form.beginDeprPeriod }) } } //资产变动必填校验 if (other.status == other.statusObj.change) checkArr.push({ path: 'data.form.changeDate', value: form.changeDate }) let isLineDepreciation = this.metaAction.gf('data.other.isLineDepreciation') //debugger //月折旧额必填校验 if (isLineDepreciation) checkArr.push({ path: 'data.form.lineDepreciation', value: Number(form.lineDepreciation) > 0 ? (Number(form.lineDepreciation)).toFixed(2) : 0 }) const ok = await this.voucherAction.check(checkArr, this.check) if (!ok) { this.metaAction.toast('warning', '请按页面提示修改信息后才可提交') return false } //变动时间控制时,计提折旧摊销审核时间大于当前日期 let beginUseTime2 = this.metaAction.gf('data.other.beginUseTime2'), isEnable = this.metaAction.gf('data.other.isEnable') if (this.component.props.status == other.statusObj.change && isEnable) { beginUseTime2 = this.getBeginUseTime(beginUseTime2) let isYj = this.metaAction.gf('data.other.isYj'), name = '审核' if (isYj) { name = '月末结账' beginUseTime2 = this.getPrevMonth(beginUseTime2) } let year = Number(beginUseTime2.split('-')[0]), mounth = Number(beginUseTime2.split('-')[1]), tip = `${year}年${mounth}月资产计提折旧摊销凭证已经${name},资产不可变动` this.metaAction.toast('warning', tip) return false } let option = { assetPropertyId: form.assetPropertyId, code: form.code, name: form.name, assetClassId: form.assetClass.id, buyDate: form.buyDate, origValue: Number(form.origValue).toFixed(2), usesId: form.uses.id, deprMethodId: form.deprMethod.id, deprMonth: form.deprMonth, isHasInit: form.isHasInit ? 1 : 0 } if (this.getBeginDepr(option.buyDate)) option.beginDeprPeriod = this.getBeginDepr(option.buyDate) /*if(form.isHasInit && form.deprMethod.id == consts.DEPRMETHOD_0004){ let currentDate = this.metaAction.gf('data.other.currentDate') option.beginDeprPeriod = this.metaAction.momentToString(currentDate, 'YYYY-MM') }*/ option.initDeprMonths = 0 option.initAccuDepreciation = 0 option.salvageRate = 0 if (form.beginDeprPeriod) option.beginDeprPeriod = this.metaAction.momentToString(form.beginDeprPeriod, 'YYYY-MM') if (form.isHasInit && form.initDeprMonths) option.initDeprMonths = form.initDeprMonths if (form.isHasInit && form.initAccuDepreciation) option.initAccuDepreciation = Number(form.initAccuDepreciation).toFixed(2) if (this.component.props.status == other.statusObj.change && form.changeDate) option.changeDate = form.changeDate if (form.specification) option.specification = form.specification if (form.salvageRate && option.assetPropertyId == consts.ASSETTYPE_fixedAssets) option.salvageRate = form.salvageRate if (form.hasDeprMonths) option.hasDeprMonths = form.hasDeprMonths if (form.accuDepreciation) option.accuDepreciation = form.accuDepreciation if (form.addType) option.addTypeId = form.addType.id if (form.quantity) option.quantity = form.quantity if (form.unit) option.unitId = form.unit.id if (form.department) option.departmentId = form.department.id if (form.inputTaxRate) option.inputTaxRate = form.inputTaxRate.id if (form.inputTax) option.inputTax = Number(form.inputTax).toFixed(2) if (form.project) option.projectId = form.project.id if (isLineDepreciation && form.lineDepreciation) option.lineDepreciation = Number(form.lineDepreciation).toFixed(2) //if(form.invoiceType) option.invoiceTypeId = form.invoiceType.id //if(form.isRent) option.isRent = form.isRent if (form.memo) option.memo = form.memo let response, smallMonth = this.metaAction.gf('data.other.smallMonth'), ret if (option.deprMonth < smallMonth) { ret = await this.metaAction.modal('confirm', { title: '预计使用月', content: '您输入的预计使用月份小于税法规定最小使用月份,请确认已备案' }) } else { ret = true } if (option.origValue < 1000) { ret = await this.metaAction.modal('confirm', { title: '原值', content: '原值小于1000元,是否保存卡片?' }) if (!ret) { return false } } if (!other.ok) return false this.metaAction.sf('data.other.ok', false) option.isReturnValue = true //开始使用日期为比较早时,loading提示 if (form.buyDate) { let systemDate = this.metaAction.gf('data.other.currentDate'), monthDiff = this.getMonthDifference(systemDate, form.buyDate) if (monthDiff > 5) { this.metaAction.sf('data.other.longLoading', true) } } if (ret && other.status == other.statusObj.new) { //console.log(3) option = await this.getCheckQCDreption(option) if (!option) return false //console.log(option) this.metaAction.sf('data.other.loading', true) this.metaAction.sf('data.other.adding', true) response = await this.webapi.asset.create(option) this.metaAction.sf('data.other.loading', false) this.metaAction.sf('data.other.adding', false) this.metaAction.sf('data.other.ok', true) this.metaAction.sf('data.other.longLoading', false) if (response && response.result == false) { this.metaAction.toast('error', response.error.message) return false } else { this.metaAction.toast('success', '保存成功') if (name == 'saveAndNew') this.injections.reduce('saveAndNew', option) } } else if (ret && other.status == other.statusObj.edit) { option.id = this.component.props.id if (form.cardId) option.cardId = form.cardId if (form.ts) option.ts = form.ts //if(form.lineDepreciation !== undefined) option.lineDepreciation = form.lineDepreciation //console.log(2) option = await this.getCheckQCDreption(option) if (!option) return false //console.log(option) this.metaAction.sf('data.other.loading', true) this.metaAction.sf('data.other.adding', true) response = await this.webapi.asset.update(option) this.metaAction.sf('data.other.loading', false) this.metaAction.sf('data.other.adding', false) this.metaAction.sf('data.other.ok', true) this.metaAction.sf('data.other.longLoading', false) if (response && response.result == false) { this.metaAction.toast('error', response.error.message) return false } else { this.metaAction.toast('success', '更新成功') } } else if (ret && other.status == other.statusObj.change) { option.id = this.component.props.id if (form.cardId) option.cardId = form.cardId if (form.ts) option.ts = form.ts //if(form.lineDepreciation !== undefined) option.lineDepreciation = form.lineDepreciation this.metaAction.sf('data.other.loading', true) this.metaAction.sf('data.other.adding', true) response = await this.webapi.asset.change(option) this.metaAction.sf('data.other.loading', false) this.metaAction.sf('data.other.adding', false) this.metaAction.sf('data.other.ok', true) this.metaAction.sf('data.other.longLoading', false) if (response && response.result == false) { this.metaAction.toast('error', response.error.message) return false } else { this.metaAction.toast('success', '变动成功') } } else { this.metaAction.sf('data.other.ok', true) this.metaAction.sf('data.other.longLoading', false) return false } } //期初数据与对应开始使用日期及折旧方法校验 getCheckQCDreption = async (option) => { let isHasInit = this.metaAction.gf('data.form.isHasInit') if (!isHasInit) return option let response = await this.webapi.asset.checkQCDreption(option) //console.log(response) this.metaAction.sf('data.other.ok', true) if (response && response.result == false) { this.metaAction.toast('error', response.error.message) return false } else { if (response.state && response.accuDepreciation !== undefined) { const ret = await this.metaAction.modal('confirm', { title: '确认', content: '期初数据与对应开始使用日期及折旧方法不相符,是否要自动生成调整资产凭证?' }) if (!ret) return option option.origAccuDepreciation = option.initAccuDepreciation option.initAccuDepreciation = response.accuDepreciation option.isTidyToDoc = true return option } return option } } check = async (option) => { if (!option || !option.path) return if (option.path == 'data.form.code') { return { errorPath: 'data.other.error.code', message: !option.value ? '请录入资产编码' : (option.value.length > 50 ? '资产编码不能超过50个字' : '') } } else if (option.path == 'data.form.name') { return { errorPath: 'data.other.error.name', message: !option.value ? '请录入资产名称' : (option.value.length > 100 ? '资产名称不能超过100个字' : '') } } else if (option.path == 'data.form.assetClass') { return { errorPath: 'data.other.error.assetClass', message: option.value ? '' : '请选择资产分类' } } else if (option.path == 'data.form.buyDate') { return { errorPath: 'data.other.error.buyDate', message: this.checkBuyDate(option) } } else if (option.path == 'data.form.changeDate') { return { errorPath: 'data.other.error.changeDate', message: option.value ? '' : '请选择变动日期' } } else if (option.path == 'data.form.origValue') { return { errorPath: 'data.other.error.origValue', message: this.checkOrigValue(option) } } else if (option.path == 'data.form.deprMonth') { return { errorPath: 'data.other.error.deprMonth', message: this.checkDeprMonth(option) } } else if (option.path == 'data.form.uses') { return { errorPath: 'data.other.error.uses', message: option.value ? '' : '请选择用途' } } else if (option.path == 'data.form.initDeprMonths') { return { errorPath: 'data.other.error.initDeprMonths', message: this.checkInitDeprMonths(option) } } else if (option.path == 'data.form.initAccuDepreciation') { return { errorPath: 'data.other.error.initAccuDepreciation', message: this.checkInitAccuDepreciation(option) } } else if (option.path == 'data.form.beginDeprPeriod') { return { errorPath: 'data.other.error.beginDeprPeriod', message: this.getBeginDeprPeriod(option) } } else if (option.path == 'data.form.deprMethod') { return { errorPath: 'data.other.error.deprMethod', message: option.value ? '' : '请选择折旧方法' } } else if (option.path == 'data.form.salvageRate') { return { errorPath: 'data.other.error.salvageRate', message: this.checkSalvageRate(option) } } else if (option.path == 'data.form.specification') { return { errorPath: 'data.other.error.specification', message: option.value.length > 50 ? '规格型号不能超过50个字' : '' } } else if (option.path == 'data.form.memo') { return { errorPath: 'data.other.error.memo', message: option.value.length > 200 ? '备注不能超过200个字' : '' } } else if (option.path == 'data.form.lineDepreciation') { return { errorPath: 'data.other.error.lineDepreciation', message: this.checkLineDepreciation(option) } } } checkOrigValue = (option) => { if (!this.checkIsNumber(option.value)) { return '请输入数字' } if (!option.value) return '请录入原值' if (option.value <= 0) { return '原值必须大于0' } else { return '' } } checkSalvageRate = (option) => { if (!this.checkIsNumber(option.value)) { return '请输入数字' } if ((option.value && Number(option.value) >= 100) || (option.value && Number(option.value) < 0)) { return '净残值率必须大于等于0小于100' } else { return '' } } getBeginDeprPeriod = (option) => { if (!option.value) return '请选择开始折旧月份' const form = this.metaAction.gf('data.form').toJS(), currentOrg = this.metaAction.context.get("currentOrg"), systemDate = this.metaAction.gf('data.other.currentDate'), value = this.metaAction.momentToString(option.value, 'YYYY-MM') if (form.buyDate && currentOrg && currentOrg.enabledMonth && currentOrg.enabledYear) { let startDate = this.metaAction.momentToString(form.buyDate, 'YYYY-MM'), enabledDate = this.getDate(currentOrg), endDate = this.metaAction.momentToString(utils.moment.stringToMoment(systemDate).endOf('month'), 'YYYY-MM') if (moment(enabledDate) > moment(form.buyDate)) startDate = enabledDate endDate = this.getNextMonth(this.getNextMonth(endDate)) if (value && (moment(value) > moment(endDate) || moment(startDate) > moment(value))) { return '会计期间错误' } return '' } return '' } checkLineDepreciation = (option) => { if (!this.checkIsNumber(option.value)) { return '请输入数字' } let lineDepreciation = this.metaAction.gf('data.other.lineDepreciation') if (!option.value) return '月折旧额必须大于0' if (option.value >= lineDepreciation + 1 || option.value <= lineDepreciation - 1) { return '月折旧额容差为1以内' } return '' } checkDeprMonth = (option) => { if (!this.checkIsNumber(option.value)) { return '请输入数字' } let form = this.metaAction.gf('data.form').toJS(), consts = this.metaAction.gf('data.consts').toJS() if (!option.value) { return '请录入预计使用月' } else if (option.value && (form.deprMethod.id == consts.DEPRMETHOD_0002 || form.deprMethod.id == consts.DEPRMETHOD_0003) && option.value % 12 != 0) { if (form.deprMethod.id == consts.DEPRMETHOD_0002) { return '双倍余额递减法预计使用月为整年' } else if (form.deprMethod.id == consts.DEPRMETHOD_0003) { return '年数总和法预计使用月为整年' } } else { return '' } } checkInitDeprMonths = (option) => { if (!this.checkIsNumber(option.value)) { return '请输入数字' } let form = this.metaAction.gf('data.form').toJS() let assetProperty = this.metaAction.gf('data.other.assetProperty').toJS() if (option.value === undefined || option.value === '') { if (form.assetPropertyId == assetProperty[0].id) { return '请录入期初已折旧期数' } else { return '请录入期初已摊销期数' } } else if (option.value) { let beginDeprPeriod = form.beginDeprPeriod, buyDate = form.buyDate, initDeprMonths if (beginDeprPeriod) { initDeprMonths = this.getDiffInitDeprMonths(beginDeprPeriod, buyDate) } if (option.value < 0) { if (form.assetPropertyId == assetProperty[0].id) { return '期初已折旧期数必须大于等于0' } else { return '期初已摊销期数必须大于等于0' } } if (form.deprMonth && initDeprMonths > form.deprMonth) { initDeprMonths = form.deprMonth if (option.value > initDeprMonths) { return '不能超过预计使用月最大值' } } else { if (option.value > initDeprMonths) { return '不能超过开始使用与折旧日期差' } } } else { return '' } } checkInitAccuDepreciation = (option) => { if (!this.checkIsNumber(option.value)) { return '请输入数字' } let form = this.metaAction.gf('data.form').toJS() let assetProperty = this.metaAction.gf('data.other.assetProperty').toJS() if (option.value === undefined || option.value === '') { if (form.assetPropertyId == assetProperty[0].id) { return '请录入期初累计折旧' } else { return '请录入期初累计摊销' } } else if (option.value && form.origValue) { let salvageRate = form.salvageRate ? form.salvageRate : 0, value = form.origValue * (1 - form.salvageRate / 100) if (option.value < 0) { if (form.assetPropertyId == assetProperty[0].id) { return '期初累计折旧必须大于等于0' } else { return '期初累计摊销必须大于等于0' } } if (option.value > value) { if (form.assetPropertyId == assetProperty[0].id) { return '不能大于原值*(1-残值率)' } else { return '不能大于原值*(1-残值率)' } } } else { return '' } } //获取上一个月 getPrevMonth = (date) => { var arr = date.split('-') var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var year2 = year; var month2 = parseInt(month) - 1; if (month2 == 0) { year2 = parseInt(year2) - 1; month2 = 12; } if (month2 < 10) { month2 = '0' + month2 } var t2 = year2 + '-' + month2 return t2; } //获取下一个月 getNextMonth = (date) => { var arr = date.split('-') var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var year2 = year; var month2 = parseInt(month) + 1 if (month2 == 13) { year2 = parseInt(year2) + 1 month2 = 1 } if (month2 < 10) { month2 = '0' + month2 } var t2 = year2 + '-' + month2 return t2; } //获取期初已折旧期数 getDiffInitDeprMonths = (date1, date2) => { let form = this.metaAction.gf('data.form').toJS() let initDeprMonths = this.getMonthDifference(date1, date2), consts = this.metaAction.gf('data.consts').toJS() //固定资产除一次性加速外期初已折旧期数为开始折旧月份和开始使用时间之差 if (form.assetPropertyId == consts.ASSETTYPE_fixedAssets && form.deprMethod != consts.DEPRMETHOD_0004) { initDeprMonths = initDeprMonths - 1 } return initDeprMonths } //获取两个日期的月份差 getMonthDifference = (