ttk-app-core
Version:
enterprise develop framework
1,215 lines (1,187 loc) • 117 kB
JavaScript
import React from 'react'
import { Map, fromJS, Set } from 'immutable'
import { action as MetaAction, AppLoader } from 'edf-meta-engine'
import { FormDecorator, LoadingMask, Button, Input, Icon, Upload, Tabs, Radio, Select } from 'edf-component'
import extend from './extend'
import config from './config'
import { areaList } from './city'
import renderColumns from './utils/renderColumns'
import changeToOption from './utils/changeToOption'
import { fetch, number, history } from 'edf-utils'
import { message } from 'antd';
import { debug } from 'util';
import moment from 'moment'
const Option = Select.Option
class action {
constructor(option) {
this.metaAction = option.metaAction
this.extendAction = option.extendAction
this.config = config.current
this.webapi = this.config.webapi
//this.beforeLoad = option.voucherAction.excelbeforeUpload
}
onInit = async ({ component, injections }) => {
/* ********
菜单名 财报转换申报
使用场景: 1、财税助手集成报表转换功能
2、北京、大连等国税局集成报表转换功能 (导入第三方财务软件生成的财务报表,并生成税局统一格式的财务报表。生成成功后,跳转到电局填表页)
3、产品中报税功能 财务三大报表集成报表转换
拼接规则
参数说明
参数 参数名称 类型 必填 描述 范例
gdslxDm 国地税类型代码 String 必填 区分上报的是国税还是地税,国税:1,地税:2
kjzdzzDm(作废) 会计制度准则代码 String 必填 第一阶段暂支持企业会计准则、小企业会计准则两类 企业会计准则=》2000020001,小企业会计准则 =》 2000020002
zlbsxlDm 资料报送小类代码 String 必填 企业会计准则对应的小类目前只支持一般企业//企业 =》 "ZL1001001" , 小企业 =》 "ZL1001003"
bbbsqDm 报表报送期代码 String 必填 01:年报;03:季报;04:月报
sssqQ 所属时期起 String 必填 例 2018-03-01
sssqZ 所属时期止 String 必填 例 2018-03-31
nsrsbh 纳税人识别号 String 必填 北京的第2,3位是11
nsrmc 纳税人名称 String 必填
zgswskfjDm 主管税务所科分局代码 String 必填 纳税人主管税务所科分局代码
djxh 登记序号 10111101000060491228
*******/
this.extendAction.gridAction.onInit({ component, injections })
this.component = component
this.injections = injections
injections.reduce('init')
let addEventListener = this.component.props.addEventListener
if (addEventListener) {
addEventListener('onTabFocus', :: this.onTabFocus)
}
let params, res, reduceArr = [], paramExternalData = this.component.props.param //this.getUrlData()
//申报列表过来
if (this.component.props.financeParam) {
params = this.component.props.financeParam
await this.initData(params.sourceType, params)
}
/**
* (局方版)财报转换申报10001002
(企业版)财报转换申报10001006
(福建集成版)财报转换申报10002001
*/
if (this.component.props.appKey) {
this.initData(this.component.props.appKey, null, paramExternalData)
}
// if (this.component.props.sourceType) {
// this.initData(this.component.props.sourceType, null, paramExternalData)
// }
// //通过url访问
// // sourceType约定: 字段说明 表示来源,如果url里面没有此属性,走oauthAuthentication验证,否则走本地
// // 1. 无值(未传该参数):认为是北京国税产品跳转过来的,调用oauthAuthentication接口
// // 2. B01:同1
// // 3. A01:通过拼接url方式访问,测试人员使用该方式,调用getOrgAndToken接口
// // 4. A02:通过产品内菜单访问,演示报表转换功能使用,在发现企业信息没有设置纳税人识别号时会抛提示,调用getOrg接口
// if (!paramExternalData.sourceType || (paramExternalData.sourceType && paramExternalData.sourceType == 'B01')) {
// res = await this.webapi.tranreport.oauthAuthentication(afferentParamsData)
// } else if (paramExternalData.sourceType == 'A01') {
// //sourceType=A01 通过拼接url方式访问,测试人员使用该方式,调用getOrgAndToken接口
// if (!paramExternalData.nsrsbh || paramExternalData.nsrsbh == "undefined") {
// message.warning('纳税人识别号为空', 5);
// return
// }
// res = await this.webapi.tranreport.getOrgAndToken(paramExternalData)
// }
// if (res) {
// reduceArr.push({
// path: 'data.orgDto',
// value: res.orgDto
// })
// reduceArr.push({
// path: 'data.paramExternalDto',
// value: res.paramExternalDto
// })
// reduceArr.push({
// path: 'data.tokenData',
// value: res.token
// })
// reduceArr.push({
// path: 'data.other.allVisible',
// value: true
// })
// paramExternalData = res.paramExternalDto
// this.injections.reduce('updateArr', reduceArr)
// this.load(paramExternalData)
// }
}
//页面加载
load = async (paramExternalData) => {
let reduceArr = [], rptTitleList = this.metaAction.gf('data.source.rptTitleList')
this.injections.reduce('load', paramExternalData, rptTitleList.toJS())
let showRptStates = this.setShowRptStates(paramExternalData.zgswskfjDm, paramExternalData.bbbsqDm)
if (showRptStates) {
reduceArr = [
...reduceArr,
{
path: 'data.other.balancesheetStatus',
value: showRptStates.balancesheetStatus
}, {
path: 'data.other.profitstatementStatus',
value: showRptStates.profitstatementStatus
}, {
path: 'data.other.cashflowstatementStatus',
value: showRptStates.cashflowstatementStatus
}
]
this.injections.reduce('updateArr', reduceArr)
}
this.isExistHistoryReportData(paramExternalData)
// setTimeout(() => {
// this.onResize()
// }, 20)
}
//渲染radio
renderOption = (value) => {
let taxTimeTypes = this.metaAction.gf('data.enumListForm.taxTimeTypes').toJS()
return taxTimeTypes.map(item => {
return (
<Radio
checked={item.value == value}
onClick={() => this.fieldChange('data.form.taxTimeType', item.value)}
value={item.value}
>
{item.label}
</Radio>
)
})
}
onTabFocus = (params) => {
//申报列表过来
if (this.component.props.financeParam) {
params = this.component.props.financeParam
this.initData(params.sourceType, params)
}
//税务助手、国税局过来
if (this.component.props.appKey) {
const paramExternalData = this.component.props.param//this.getUrlData()
this.initData(this.component.props.appKey, null, paramExternalData)
}
}
//作废
getUrlData = () => {
//以下处理url跳转过来问题
let urlData, urlSearch, urltest = 'http://127.0.0.1:8001/#/edfx-app-root/ttk-access-app-tranreport?zlbsxlDm=ZL1001003&bbbsqDm=01&sssqQ=2018-01-01&sssqZ=2018-12-31&nsrsbh=91199106726456657C&nsrmc=%E8%8D%80%E5%BD%A7%E9%A2%84%E7%BD%AE%E5%8C%97%E4%BA%AC%E5%9C%B0%E5%8C%BA%E4%BC%81%E4%B8%9A%E5%B9%B4%E6%8A%A5&zgswskfjDm=11102270000&djxh=10111101000060491334&sourceType=A02'
urlSearch = (location && location.search.indexOf('?') >= 0) ? location.search : ((location && location.hash.indexOf('?') >= 0) ? location.hash : "?")
//产品走此分支
if (urlSearch.indexOf('&') < 0) {
urlSearch = urltest
}
urlData = this.urlParse(decodeURI(urlSearch))
if (typeof urlData['tmp_code'] != "undefined") {
urlData['code'] = urlData['tmp_code']
}
//三种情况
//第一种,从云财税进来,有token。不需要调接口,直接向下走
//第二种,从国税进来,没有code,调用A接口,返回新的带有code的地址,重定向
//第三种,重定向完毕,有code,调用B接口,获取token 和其他信息,向下走
// if (location.href.indexOf('erp.jchl.com') >= 0
// || location.href.indexOf('erpdemo.jchl.com') >= 0
// || location.href.indexOf('erp-dzsj.jchl.com') >= 0
// || location.href.indexOf('erpdemo-dzsj.jchl.com') >= 0)
return urlData
}
initData = async (appKey, params, paramExternalDto) => {
// (局方版)财报转换申报10001002
// (企业版)财报转换申报10001006
// (福建集成版)财报转换申报10002001
let res, response, reduceArr = []
if (appKey) {
if (appKey == '10001002') { //北京局方
//sourceType=A02 通过产品内菜单访问,演示报表转换功能使用,在发现企业信息没有设置纳税人识别号时会抛提示,调用getOrg接口
let reduceArr = [{
path: 'data.step.step0Visible',
value: false
}, {
path: 'data.step.step1Visible',
value: true
}, {
path: 'data.step.step2Visible',
value: false
}, {
path: 'data.step.iconVisible',
value: false
}, {
path: 'data.other.componyVisible', //财税助手-对应得按钮
value: false
}, {
path: 'data.other.taxVisible', //局端对应得按钮
value: true
}, {
path: 'data.other.taxapplyVisible',//申报功能对应得按钮
value: false
}, {
path: 'data.other.taxapplyTipsVisible',
value: true
}, {
path: 'data.other.isProjectAdjust',
value: true
}]
this.injections.reduce('updateArr', reduceArr)
res = await this.webapi.tranreport.getOrg(paramExternalDto)
if (res) {
reduceArr.push({
path: 'data.orgDto',
value: res.orgDto
})
reduceArr.push({
path: 'data.paramExternalDto',
value: res.paramExternalDto
})
reduceArr.push({
path: 'data.other.allVisible',
value: true
})
paramExternalDto = res.paramExternalDto
this.injections.reduce('updateArr', reduceArr)
}
this.load(paramExternalDto)
} else if (appKey == '10002001') {//(福建集成版)财报转换
let reduceArr = [{
path: 'data.step.step0Visible',
value: false
}, {
path: 'data.step.step1Visible',
value: true
}, {
path: 'data.step.step2Visible',
value: false
}, {
path: 'data.step.iconVisible',
value: false
}, {
path: 'data.other.componyVisible', //财税助手-对应得按钮
value: false
}, {
path: 'data.other.taxVisible', //局端对应得按钮
value: true
}, {
path: 'data.other.taxapplyVisible',//申报功能对应得按钮
value: false
}, {
path: 'data.other.taxapplyTipsVisible',
value: true
}, {
path: 'data.other.isProjectAdjust',
value: true
}]
this.injections.reduce('updateArr', reduceArr)
const resZlBsXlDm = await this.webapi.tranreport.queryAccountingStandards()
let resData = resZlBsXlDm.find(element => element.zlbsxlDm == paramExternalDto.zlbsxlDm)
paramExternalDto.accountingStandards = resData && resData.accountingStandardsId
paramExternalDto.accountingStandardsId = resData && resData.accountingStandardsId
reduceArr.push({
path: 'data.paramExternalDto',
value: paramExternalDto
})
reduceArr.push({
path: 'data.other.allVisible',
value: true
})
this.injections.reduce('updateArr', reduceArr)
this.load(paramExternalDto)
} else if (appKey == '10001006') {//企业版
//财税助手集成 appKey="10001006"
// "entryType": "1000090001" 财税云
// "entryType": "1000090002" 财税助手
const entryType = this.component.props.entryType
//初始化企业版基础信息
let reduceArr = [{
path: 'data.step.step0Visible',
value: true
}, {
path: 'data.step.step1Visible',
value: false
}, {
path: 'data.step.step2Visible',
value: false
}, {
path: 'data.step.iconVisible',
value: true
}, {
path: 'data.other.componyVisible', //财税助手-对应得按钮
value: true
}, {
path: 'data.other.taxVisible', //局端对应得按钮
value: false
}, {
path: 'data.other.taxapplyVisible',//申报功能对应得按钮
value: false
}, {
path: 'data.other.allVisible',
value: true
}, {
path: 'data.other.taxapplyTipsVisible',
value: true
}, {
path: 'data.other.isProjectAdjust',
value: true
}]
this.injections.reduce('updateArr', reduceArr)
//this.injections.reduce('setLoading', 'data.other.step0loading', true)
const taxTimeTypes = this.metaAction.gf('data.taxTimeType').toJS()//await this.webapi.tranreport.findByEnumCode({ "enumCode": "taxTimeType" })
const accountingStandardEnums = this.metaAction.gf('data.accountStandardsForSB').toJS()//await this.webapi.tranreport.getAccountStandardsForSB({ "enumCode": "accountingStandards" })
let querys = [], serverDate, date, curFormData, taxTimes = []
if (entryType == '1000090002') { //财税助手
querys = this.metaAction.gf('data.localForm').toJS()//await this.webapi.tranreport.queryLocal()
curFormData = querys && querys[0]
serverDate = await this.webapi.tranreport.getSystemDate()
curFormData.systemDate = serverDate
date = moment(new Date(serverDate))
} else {
querys = await this.webapi.tranreport.queryServer()
curFormData = querys && querys[0]
serverDate = curFormData.systemDate ? new Date(curFormData.systemDate) : new Date()
date = moment(serverDate)
}
this.injections.reduce('initForm', curFormData)
taxTimeTypes.forEach(element => {
taxTimes.push({ value: element.id, label: element.name })
})
//按照城市区号进行排序
let sortCity = fromJS(changeToOption(areaList, 'n', 'cityNo')).sortBy((val, index, obj) => {
return val.get('key')
}, (a, b) => {
if (a < b) { return -1 }
if (a > b) { return 1 }
if (a === b) { return 0 }
})
let { arraryYear, arraySeason } = this.getEnumYearsAndSeason()
this.injections.reduce('enumDetails', { taxTimeTypes: taxTimes, accountingStandardEnums, areaCode: sortCity, taxYears: arraryYear, taxSeasons: arraySeason })
this.setVisibleDate(curFormData.taxTimeType)
this.getDefaultDate(date.year(), date.month())
//this.injections.reduce('setLoading', 'data.other.step0loading', false)
} else if (appKey == 'A04') {//申报
const appraisalId = params.id
response = await this.webapi.tranreport.querySelectReport({ appraisalId })
if (response && !response.haveSelected) {//是否有选择的报表
let mutilSelect = await this.showRptSelectData(response && response.reportList, appraisalId)
if (!mutilSelect) {
return
}
}
//解决切换页签后,如果数据变更,不重新请求数据
let editStatus = this.metaAction.gf('data.other.editStatus')
if (editStatus) {
return
}
let reduceArr = [{
path: 'data.step.step0Visible',
value: false
}, {
path: 'data.step.step1Visible',
value: false
}, {
path: 'data.step.step2Visible',
value: true
}, {
path: 'data.step.iconVisible',
value: false
}, {
path: 'data.other.componyVisible', //财税助手-对应得按钮
value: false
}, {
path: 'data.other.taxVisible', //局端对应得按钮
value: false
}, {
path: 'data.other.taxapplyVisible',//申报功能对应得按钮
value: true
}, {
path: 'data.other.allVisible',
value: true
}, {
path: 'data.other.taxapplyTipsVisible',
value: false
}]
this.injections.reduce('updateArr', reduceArr)
let bbbsqDm,
month = this.getDiffMonth(params.startPeriod, params.endPeriod),
cityNo = params.cityNo ? params.cityNo : '1100',
writable = params.writable//true:可编辑 false:不可编辑
let paramExternalDto = {
// gdslxDm: '1', //国地税类型代码
// kjzdzzDm: '',
// zlbsxlDm: 'ZL1001003', //资料报送小类代码 String 必填 企业会计准则对应的小类目前只支持一般企业//企业 =》 "ZL1001001" , 小企业 =》 "ZL1001003"
// bbbsqDm: '03', //报表报送期代码 String 必填 01:年报;03:季报;04:月报
sssqQ: params.startPeriod,
sssqZ: params.endPeriod,
startPeriod: params.startPeriod,
endPeriod: params.endPeriod,
nsrsbh: params.nsrsbh, //纳税人识别号 String 必填 北京的第2, 3位是11
nsrmc: params.nsrmc, //纳税人名称
zgswskfjDm: params.zgswskfjDm,//cityNo.padStart('5', '0'),//'11102270000'//主管税务所科分局代码
//djxh: '10111101000060491228', //登记序号
accountingStandardsId: params.accountingStandardsId,
tmpRvState: params.tmpRvState, //申报状态
taxProjectName: params.taxProjectName //申报项目
}
const rptTitleList = this.metaAction.gf('data.source.rptTitleList')
this.injections.reduce('load', paramExternalDto, rptTitleList.toJS())
if (month < 3) {
bbbsqDm = '04' //月报
} else if (month >= 3 && month < 12) {
bbbsqDm = '03' //季报
} else if (month == 12) {
bbbsqDm = '01' //年报
}
if (bbbsqDm == '01') {
//上传附注只有年报才显示
reduceArr.push({
path: 'data.other.yearVisible',
value: true
})
}
let showRptStates = this.setShowRptStates(params.zgswskfjDm, bbbsqDm)
if (showRptStates) {
reduceArr = [
{
path: 'data.other.balancesheetStatus',
value: showRptStates.balancesheetStatus
}, {
path: 'data.other.profitstatementStatus',
value: showRptStates.profitstatementStatus
}, {
path: 'data.other.cashflowstatementStatus',
value: showRptStates.cashflowstatementStatus
}, {
path: 'data.other.appraisalId',
value: params.id
}, {
path: 'data.other.writable',
value: writable
}
]
}
this.injections.reduce('updateArr', reduceArr)
setTimeout(() => {
const tableHeight = this.getTableCurHeigh()
document.querySelector('.ttk-access-app-tranreport-step2content-content').style.height = `${tableHeight}px`
}, 500)
//初始化申报列表
this.initTaxReport(paramExternalDto)
}
}
}
//初始化申报
initTaxReport = async (paramExternalDto) => {
LoadingMask.show()
const res = await this.webapi.tranreport.getData(paramExternalDto)
LoadingMask.hide()
if (res) {
//this.injections.reduce('setLoading', 'data.other.loading', false)
let currentRptName = this.metaAction.gf('data.other.rpttype')
//报表转换--选择转换利润表,成功导入后前端的tab应该切换到利润表页签上。
let reduceArr = [{
path: 'data.other.rpttype',
value: currentRptName
}, {
path: 'data.other.editStatus',
value: false
}, {
path: 'data.other.loading',
value: false
}, {
path: 'data.other.isProjectAdjust',
value: res.isProjectAdjust ? false : true //取反,true 会计自动一致,隐藏调整项目按钮
}]
this.injections.reduce('updateArr', reduceArr)
//初始化第一个报表
const rptTitle = this.metaAction.gf('data.rptTitle')
this.injections.reduce('setSourceRpt', res, currentRptName, rptTitle && rptTitle.toJS()[currentRptName])
let writable = true, params = this.component.props.financeParam
if (params) {
writable = params.writable
}
if (res.needMatching && writable) {
this.nextResponseWarning(this.getMessages(this.metaAction.gf('data.btnState.nextState')))
}
}
}
getDiffMonth = (startTime, endTime) => {
if (!startTime || !endTime) {
this.metaAction.toast('success', '开始结束日期不能为空!')
return
}
let startDate, endDate, differMonth = 0
if (typeof startTime == 'string') {
startDate = moment(new Date(startTime))
}
if (typeof endTime == 'string') {
endDate = moment(new Date(endTime))
}
differMonth = parseInt(endDate.month() - startDate.month())
return differMonth + 1
}
fieldChange = async (fieldPath, value) => {
let cityNo, resJson = {}
if (fieldPath == 'data.form.taxTimeType') {
this.setVisibleDate(value)
}
if (fieldPath == 'data.form.vatTaxpayerNum') {
/*当纳税人识别号15位时,根据前4位确定省市代码,根据代码确定“省市”信息,
自动带入到“省市”中去,如果无法对应则不带入“省市”信息;当纳税人识别号18位时,
根据第3 - 6位对应的省市代码,将对应的省市信息带入到“省市”中去,如果无法对应则不带入“省市”信息;
纳税人识别号20位时,则不自动带入省市信息。
(备注:
15位纳税人识别号第一二位为省级代码、第三四位为市级代码, 第五六位为区县级代码.
18位的纳税人识别号取值规则:第一部分(第1位),为登记管理部门代码。
第二部分(第2位),为企业等纳税人类别代码。第三部分(第3 - 8位),
为登记管理机关行政区划码。第四部分(第9 - 17位),为主体标识码。
第五部分(第18位),为校验码,由系统自动生成。
20位纳税人为个体户,只能开普票)*/
if (value.length == 15) {
cityNo = this.getCurCityNo(value.substr(0, 4))
this.metaAction.sf('data.form.areaCode', cityNo)
resJson['data.error.vatTaxpayerNum'] = ''
resJson['data.error.areaCode'] = ''
} else if (value.length == 18) {
cityNo = this.getCurCityNo(value.substr(2, 4))
this.metaAction.sf('data.form.areaCode', cityNo)
resJson['data.error.vatTaxpayerNum'] = ''
resJson['data.error.areaCode'] = ''
} else if (value.length == 20) {
this.metaAction.sf('data.form.areaCode', cityNo)
} else if (value && value.length < 2) {
resJson['data.error.vatTaxpayerNum'] = ''
}
this.metaAction.sfs(resJson)
}
if (fieldPath == 'data.form.areaCode') {
resJson['data.error.areaCode'] = ''
this.metaAction.sfs(resJson)
}
if (fieldPath == 'data.form.accountingStandards') {
resJson['data.error.accountingStandards'] = ''
this.metaAction.sfs(resJson)
}
this.metaAction.sf(fieldPath, value)
}
/**
* 根据年、月、季选项切换控件
*/
setVisibleDate = (value) => {
let reduceArr = []
if (value == '2000070001') {//月
reduceArr.push(
{
path: 'data.other.seasonVisible',
value: false
}, {
path: 'data.other.yearDateVisible',
value: false
}, {
path: 'data.other.monthDateVisible',
value: true
}
)
} else if (value == '2000070002') {//季度
reduceArr.push(
{
path: 'data.other.seasonVisible',
value: true
}, {
path: 'data.other.yearDateVisible',
value: false
}, {
path: 'data.other.monthDateVisible',
value: false
}
)
} else {
//年
reduceArr.push(
{
path: 'data.other.seasonVisible',
value: false
}, {
path: 'data.other.yearDateVisible',
value: true
}, {
path: 'data.other.monthDateVisible',
value: false
}
)
}
this.injections.reduce('updateArr', reduceArr)
}
/**
* 获取当前日期值
*/
getCurrentDate = (value, nowDate) => {
let taxDate,
reduceArr = [],
month = nowDate.month() + 1,
year = nowDate.year()
if (value == '2000070001') {//月
taxDate = {
sssqQ: nowDate.startOf('month').format("YYYY-MM-DD"),
sssqZ: nowDate.endOf('month').format("YYYY-MM-DD")
}
reduceArr.push(
{
path: 'data.form.monthTaxTime',
value: `${year}-${month < 10 ? `0${month}` : `${month}`}`,
}
)
} else if (value == '2000070002') {//季度
let { season, sssqQ, sssqZ } = this.getSeason(year, month)
//季
taxDate = {
sssqQ: sssqQ,
sssqZ: sssqZ
}
reduceArr.push(
{
path: 'data.form.year',
value: year
}, {
path: 'data.form.season',
value: season
}
)
} else {
//年 2000070003
taxDate = {
sssqQ: `${year}-01-01`,
sssqZ: `${year}-12-31`
}
reduceArr.push(
{
path: 'data.form.yearTaxTime',
value: year
}
)
}
this.metaAction.sf('data.form.sssqQ', fromJS(taxDate.sssqQ))
this.metaAction.sf('data.form.sssqZ', fromJS(taxDate.sssqZ))
this.injections.reduce('updateArr', reduceArr)
}
/**
* 获取日期默认值
*/
getDefaultDate = (year, month) => {
let tmpYear, preSeason,
reduceArr = [],
tempMonth = month + 1
if (tempMonth < 4) {
tmpYear = year - 1
preSeason = 12
} else if (tempMonth >= 4 && tempMonth < 7) {
tmpYear = year
preSeason = 3
} else if (tempMonth >= 7 && tempMonth < 10) {
tmpYear = year
preSeason = 6
} else {
tmpYear = year
preSeason = 9
}
reduceArr.push(
{
path: 'data.form.year',
value: tmpYear
}, {
path: 'data.form.season',
value: preSeason
}, {
path: 'data.form.monthTaxTime',
value: `${year}-${month < 10 ? `0${month}` : `${month}`}`,
}, {
path: 'data.form.yearTaxTime',
value: year - 1
}
)
this.injections.reduce('updateArr', reduceArr)
}
/**
* 获取季度得起始和结束日期间隔段
*/
getSeason = (year, season) => {
let sssqQ, sssqZ
if (season == 3) {
sssqQ = `${year}-01-01`
sssqZ = `${year}-03-31`
} else if (season == 6) {
sssqQ = `${year}-04-01`
sssqZ = `${year}-06-30`
} else if (season == 9) {
sssqQ = `${year}-07-01`
sssqZ = `${year}-09-30`
} else {
sssqQ = `${year}-10-01`
sssqZ = `${year}-12-31`
}
return { season, sssqQ, sssqZ }
}
/**
* 获取基础信息年和季列表
*/
getEnumYearsAndSeason = () => {
let arraryYear = [],
arraySeason = [],
nowDate = moment(new Date()),
minYear = nowDate.year() - 20
for (let index = nowDate.year(); nowDate.year() - 20 <= index; index--) {
arraryYear.push({
id: index,
name: `${index}年`
})
}
arraySeason.push(
{ id: 3, name: '一季度' },
{ id: 6, name: '二季度' },
{ id: 9, name: '三季度' },
{ id: 12, name: '四季度' },
)
return { arraryYear, arraySeason }
}
//判断是否存在历史报表数据
isExistHistoryReportData = async (paramExternalData) => {
let reduceArr = [], res = await this.webapi.tranreport.getReportJson(paramExternalData)
if (res) {
if (!(res.body && (!res.body.zcfzbBody && !res.body.lrbBody && !res.body.xjllbBody))) {
//报表转换--选择转换利润表,成功导入后前端的tab应该切换到利润表页签上。
let currentRptName = this.metaAction.gf('data.other.rpttype')
//初始化第一个报表
const rptTitle = this.metaAction.gf('data.rptTitle')
reduceArr.push({
path: 'data.other.editStatus',
value: false
})
this.injections.reduce('setSourceRpt', res, currentRptName, rptTitle && rptTitle.toJS()[currentRptName])
reduceArr = [
...reduceArr,
{
path: 'data.balancesheetData',
value: undefined
}, {
path: 'data.cashflowstatementData',
value: undefined
}, {
path: 'data.profitstatementData',
value: undefined
}, {
//如果下一步调用接口成功,将updateState 改为false。文件名清空。返回上一步重新选择文件
path: 'data.btnState.updateState',
value: false
}, {
path: 'data.btnState.nextState',
value: false
}
]
this.injections.reduce('updateArr', reduceArr)
}
}
}
/**
* 组件从界面上移除触发
*/
componentWillUnmount = () => {
if (window.removeEventListener) {
window.removeEventListener('resize', this.onResize, false)
document.body.removeEventListener('keydown', this.bodyKeydownEvent, false)
} else if (window.detachEvent) {
window.detachEvent('onresize', this.onResize)
document.body.detachEvent('onkeydown', this.bodyKeydownEvent)
} else {
window.onresize = undefined
}
}
/**
* 在初始化render之后只执行一次
*/
componentDidMount = () => {
if (window.addEventListener) {
window.addEventListener('resize', this.onResize, false)
document.body.addEventListener('keydown', this.bodyKeydownEvent, false)
} else if (window.attachEvent) {
window.attachEvent('onresize', this.onResize)
document.body.attachEvent('onkeydown', this.bodyKeydownEvent)
} else {
window.onresize = this.onResize
}
}
//处理在IE9、IE8按BackSpace 回退页面的问题
bodyKeydownEvent = (e) => {
const projectadjustbody = document.getElementById('ttk-access-app-tranreport-projectadjust')
const tranreportbody = document.getElementById('ttk-access-app-tranreport')
const setInfo = document.getElementById('setInfo')
//IE8不存在document.getElementsByClassName 属性
const inputs = this.getElementsByClassName('ant-input mk-input-number ttk-access-app-tranreport-step2content-tableCellInput')
//获取事件对象 兼容IE8
var eve = e || window
////获取document 对象的引用 兼容IE8
var objEle = eve.target || eve.srcElement
if (!projectadjustbody && !setInfo) {
if (tranreportbody && inputs) {
if (inputs.length < 1 && eve) {
this.bodyhandleKeyDown({ event: eve })
} else {
const index = $(inputs).index(objEle)
if ((inputs[index] != document.activeElement)) {
this.bodyhandleKeyDown({ event: eve })
}
}
}
}
}
bodyhandleKeyDown = (e) => {
//e.keyCode 8:Backspace
if (e && e.event) {
const keydown = e && e.event
if (keydown.type !== 'keydown' || keydown.keyCode == 8) {
//IE
window.event.cancelBubble = true;//停止冒泡
window.event.returnValue = false;//阻止事件的默认行为
//chrome
if (keydown.preventDefault) {
keydown.preventDefault()
}
if (keydown.stopPropagation) {
keydown.stopPropagation()
}
}
}
}
/**
* 获取dom节点值,兼容IE9一下浏览器
*/
getElementsByClassName = (className) => {
if (document.getElementsByClassName) {
// 使用现有方法
return document.getElementsByClassName(className);
} else {
// 循环遍历所有标签,返回带有相应类名的元素
let results = [],
elems = document.getElementsByTagName("input");
for (var i = 0, len = elems.length; i < len; i++) {
if (elems[i].className.indexOf(className) != -1) {
results[results.length] = elems[i];
}
}
return results;
}
}
/**
* 计算table滚动条
*/
onResize = (e) => {
let keyRandomTab = Math.floor(Math.random() * 10000)
this.keyRandomTab = keyRandomTab
setTimeout(() => {
if (keyRandomTab == this.keyRandomTab) {
this.getTableScroll('ttk-access-app-tranreport-step2content-content', 'ant-table-thead', 1, 'ant-table-body', 'data.tableOption', e)
}
}, 200)
}
//获取当前表格的高度
getTableCurHeigh = (num = 109) => {
let curTableHeight
const body = document.body.clientHeight
const header = 148
curTableHeight = body - header - num
return curTableHeight
}
/**
* 计算table滚动条
*/
getTableScroll = (contaienr, head, num, target, path, e) => {
try {
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
}
} catch (err) {
console.log(err)
}
}
/**
* 解析url
*/
urlParse = (url) => {
let arr = [], obj = {};
if (url.indexOf('?') != -1) {
const parseStr = url.split("?")[1];
if (parseStr.indexOf("&") != -1) {
arr = parseStr.split("&");
for (let i = 0; i < arr.length; i++) {
obj[arr[i].split("=")[0]] = arr[i].split("=")[1];
}
} else {
obj[parseStr.split("=")[0]] = parseStr.split("=")[1];
}
}
return obj;
}
/**
* 基础信息设置
*/
taxSettingClick = async () => {
//更新保存设置ts
let querys, appKey = this.component.props && this.component.props.appKey
if (!appKey) {
querys = await this.webapi.tranreport.queryServer()
}
let reduceArr = [{
path: 'data.step.step0Visible',
value: true
}, {
path: 'data.step.step1Visible',
value: false
}, {
path: 'data.step.step2Visible',
value: false
}, {
path: 'data.form.ts',
value: querys && querys[0].ts //更新保存设置ts
}, {
path: 'data.btnState.nextState',
value: true
}]
this.injections.reduce('updateArr', reduceArr)
}
getAccessToken = () => {
let token = fetch.getAccessToken()
return { token }
}
//基础信息保存
formSaveClick = async () => {
let form = this.metaAction.gf('data.form').toJS()
//const error = this.metaAction.gf('data.error').toJS()
const checkInfo = await this.preSaveCheck(
[{
path: 'data.form.vatTaxpayerNum', value: form.vatTaxpayerNum
}, {
path: 'data.form.accountingStandards', value: form.accountingStandards
}, {
path: 'data.form.areaCode', value: form.areaCode
}])
if (checkInfo) {
return
}
//处理日期
let nowDate
if (form.taxTimeType == '2000070001') {//月
nowDate = new moment(new Date(form.monthTaxTime))
} else if (form.taxTimeType == '2000070002') {//季
nowDate = new moment(new Date(form.year + `-${form.season < 10 ? `0${form.season}` : form.season}`))
} else {
nowDate = new moment(new Date(form.yearTaxTime + '-12'))
}
this.getCurrentDate(form.taxTimeType, nowDate)
//this.injections.reduce('setLoading', 'data.other.step0loading', true)
let response,
areaCode = form.areaCode.length < 4 ? form.areaCode.padEnd('4', '0') : form.areaCode,
registerNum,
appKey = this.component.props && this.component.props.appKey,
resZlBsXlDm = await this.webapi.tranreport.queryAccountingStandards()
// 1000090001 菜单
// 1000090002 url
const entryType = this.component.props.entryType
if (appKey && entryType=='1000090002') {
//appKey: "10001006"
form.name = "<空>"
form.vatTaxpayer = "2000010002"
const date = new moment(new Date(form.systemDate))
form.enabledMonth = `${date.month() + 1 < 10 ? `0${date.month() + 1}` : date.month() + 1}`
form.enabledYear = date.year()
form.appKey = appKey
form.registerNum = (areaCode || '1100').padStart('5', '0')
LoadingMask.show()
response = await this.webapi.tranreport.accessLogin({ ...form })
LoadingMask.hide()
sessionStorage['_accessToken'] = response && response.token
} else {
LoadingMask.show()
response = await this.webapi.tranreport.updateEDFOrgInfo(form)
LoadingMask.hide()
}
if (response) {
const sssqQ = this.metaAction.gf('data.form.sssqQ')
const sssqZ = this.metaAction.gf('data.form.sssqZ')
//this.injections.reduce('setLoading', 'data.other.step0loading', false)
let zlbsxlDmData = resZlBsXlDm.find(element => element.accountingStandardsId == form.accountingStandards)
let paramExternalDto = {
gdslxDm: '1', //国地税类型代码
kjzdzzDm: form.accountingStandards,
zlbsxlDm: zlbsxlDmData.zlbsxlDm, //资料报送小类代码 String 必填 企业会计准则对应的小类目前只支持一般企业//企业 =》 "ZL1001001" , 小企业 =》 "ZL1001003"
bbbsqDm: form.taxTimeType == '2000070001' ? '04' : form.taxTimeType == '2000070002' ? '03' : '01', //报表报送期代码 String 必填 01:年报;03:季报;04:月报
sssqQ: sssqQ, //所属时期起 String 必填 例 2018-03 - 01
sssqZ: sssqZ, //所属时期止 String 必填 例 2018 - 03 - 31
nsrsbh: form.vatTaxpayerNum,//纳税人识别号 String 必填 北京的第2, 3位是11
nsrmc: form.name, //纳税人名称
zgswskfjDm: (areaCode || '1100').padStart('5', '0'),//'11102270000', //主管税务所科分局代码
//djxh: '10111101000060491228', //登记序号
cityNo: (areaCode || '1100').padStart('5', '0'),
accountingStandards: form.accountingStandards
}
paramExternalDto.zlbsxlDm = zlbsxlDmData.zlbsxlDm
const rptTitleList = this.metaAction.gf('data.source.rptTitleList')
this.injections.reduce('load', paramExternalDto, rptTitleList.toJS())
let showRptStates = this.setShowRptStates(paramExternalDto.cityNo, paramExternalDto.bbbsqDm)
const reduceArr = [{
path: 'data.other.balancesheetStatus',
value: showRptStates.balancesheetStatus
}, {
path: 'data.other.profitstatementStatus',
value: showRptStates.profitstatementStatus
}, {
path: 'data.other.cashflowstatementStatus',
value: showRptStates.cashflowstatementStatus
}, {
path: 'data.step.step0Visible',
value: false
}, {
path: 'data.step.step1Visible',
value: true
}, {
path: 'data.step.step2Visible',
value: false
}
]
this.injections.reduce('updateArr', reduceArr)
//判断是否存在历史数据
this.isExistHistoryReportData(paramExternalDto)
}
}
//保存校验
preSaveCheck = async (fieldPathAndValues) => {
let checkResults = [], resJson = {}, hasError = false
if (!fieldPathAndValues) {
return
}
for (let o of fieldPathAndValues) {
let r = { ...o }
if (o.path == 'data.form.vatTaxpayerNum') {
Object.assign(r, await this.vatTaxpayerNumCheck(o.value))
} else if (o.path == 'data.form.accountingStandards') {
Object.assign(r, await this.accountingStandardsCheck(o.value))
} else if (o.path == 'data.form.areaCode') {
Object.assign(r, await this.areaCodeCheck(o.value))
}
checkResults.push(r)
}
checkResults.forEach(o => {
resJson[o.errorPath] = o.message
if (o.message) {
hasError = true
}
})
this.metaAction.sfs(resJson)
return hasError
}
//1、校验纳税人识别号
vatTaxpayerNumCheck = async (vatTaxpayerNum) => {
var message
if (!vatTaxpayerNum)
message = '请输入纳税人识别号'
else if (vatTaxpayerNum.length <= 14)
message = "位数错误,请输入15、18、20位数字或字母"
else if (vatTaxpayerNum.length > 14 && vatTaxpayerNum.length !== 15 && vatTaxpayerNum.length !== 18 && vatTaxpayerNum.length !== 20)
message = "位数错误,请输入15、18、20位数字或字母"
else if (vatTaxpayerNum.length > 20)
message = "不能超过20位数字或字母"
return { errorPath: 'data.error.vatTaxpayerNum', message }
}
//2、校验会计制度准则
accountingStandardsCheck = async (accountingStandards) => {
var message
if (!accountingStandards)
message = '会计制度准则'
return { errorPath: 'data.error.accountingStandards', message }
}
//3、校验城市
areaCodeCheck = async (areaCode) => {
var message
if (!areaCode)
message = '请选择地区'
return { errorPath: 'data.error.areaCode', message }
}
/**
* 转为局端格式
*/
selectLocalRptClick = async () => {
//updateState 为false 代表没上传文件,不可以下一步
if (!this.metaAction.gf('data.btnState.updateState')) {
message.warning('请至少选择一个财务报表', 5);
return
}
LoadingMask.show()
let res = await this.webapi.tranreport.importDataSource(this.getParams('importDataSource'))
LoadingMask.hide()
if (res) {
let reduceArr = []
//报表转换--选择转换利润表,成功导入后前端的tab应该切换到利润表页签上。
let isMutilSelct = 0, currentRptName,
balancesheetData = 'balanceSheetRpt',//this.metaAction.gf('data.balancesheetData'),
cashflowstatementData = this.metaAction.gf('data.cashflowstatementData'),
profitstatementData = this.metaAction.gf('data.profitstatementData')
if (balancesheetData) {
isMutilSelct++
currentRptName = 'balanceSheetRpt'
_hmt && _hmt.push(['_trackEvent', '财务', '报表转换', '选择文件是“资产负债表”转为局端格式'])
}
if (profitstatementData) {
isMutilSelct++
currentRptName = 'profitStatementRpt'
_hmt && _hmt.push(['_trackEvent', '财务', '报表转换', '选择文件是“利润表”转为局端格式'])
}
if (cashflowstatementData) {
isMutilSelct++
currentRptName = 'cashflowStatementRpt'
_hmt && _hmt.push(['_trackEvent', '财务', '报表转换', '选择文件是“现金流量表”转为局端格式'])
}
if (isMutilSelct > 1) {
if (balancesheetData) {
currentRptName = 'balanceSheetRpt'
} else {
currentRptName = 'profitStatementRpt'
}
}
reduceArr.push({
path: 'data.other.rpttype',
value: currentRptName
})
//初始化第一个报表
const rptTitle = this.metaAction.gf('data.rptTitle')
reduceArr.push({
path: 'data.other.editStatus',
value: false
})
this.injections.reduce('setSourceRpt', res, currentRptName, rptTitle && rptTitle.toJS()[currentRptName])
reduceArr = [
...reduceArr,
{
//如果下一步调用接口成功,将updateState 改为false。文件名清空。返回上一步重新选择文件
path: 'data.btnState.updateState',
value: false
}, {
path: 'data.btnState.nextState',
value: false
}, {
path: 'data.balancesheetData',
value: undefined
}, {
path: 'data.cashflowstatementData',
value: undefined
}, {
path: 'data.profitstatementData',
value: undefined
}, {
path: 'data.step.step2Visible',