UNPKG

ttk-app-core

Version:
453 lines (409 loc) 16.5 kB
import React from 'react' import ReactDOM from 'react-dom' import config from './config' import moment from 'moment' import extend from './extend' import * as data from './data' import utils, { fetch } from 'edf-utils' import { action as MetaAction, AppLoader, } from 'edf-meta-engine' import { Checkbox, Radio } from 'antd' import { Modal, Icon, LoadingMask } from 'edf-component' import { List, is } from 'immutable' import { consts } from 'edf-consts' class action { constructor(option) { this.metaAction = option.metaAction this.extendAction = option.extendAction this.config = config.current this.webapi = this.config.webapi } onInit = ({ component, injections }) => { this.extendAction.gridAction.onInit({ component, injections }) this.component = component this.injections = injections injections.reduce('init') if (this.component.props.setOkListener) { this.component.props.setOkListener(this.onOk) } this.load(this.component.props.initData || {}) } load = async (paramDtos) => { LoadingMask.show() let response = await this.webapi.chargeback.queryUnpaid({}) if (response){ if (response.mxxxs == undefined || (response.mxxxs && response.mxxxs.mxxx == undefined)) { this.metaAction.toast('warning', '您的税款金额为0.00元,无需缴款') } else { response.paramDtos = paramDtos let mxxx = response.mxxxs ? response.mxxxs.mxxx : undefined this.injections.reduce('load', mxxx, response) } } LoadingMask.hide() } //表格复选框 getRowSelection = () => { return { onChange: (selectedRowKeys, selectedRows) => { this.checkboxChange(selectedRowKeys, selectedRows) } } } //选择数据改变 checkboxChange = (selectedRowKeys, selectedRows) => { let preSelectedRowKeys = this.metaAction.gf('data.tableCheckbox.selectedRowKeys').toJS(), curSelectedRowKeys = [...selectedRowKeys], list = this.metaAction.gf('data.list').toJS() // 增加勾选 let a = "", b="" if (curSelectedRowKeys.length > preSelectedRowKeys.length) { for(var i = curSelectedRowKeys.length-1 ; i>=0 ; i-- ){ a = curSelectedRowKeys[i] for( var j = preSelectedRowKeys.length - 1 ; j>=0 ; j--){ b = preSelectedRowKeys[j] if( a == b){ curSelectedRowKeys.splice(i,1) break } } } let curYzpzmxRow = selectedRows.find(item => item.sortNo == curSelectedRowKeys[0]+1) if (curYzpzmxRow) { for (var i = 0; i < list.length; i++) { if (list[i].yzpzxh == curYzpzmxRow.yzpzxh && list[i].sortNo != curYzpzmxRow.sortNo) { selectedRowKeys.push(parseInt(list[i].sortNo)-1) selectedRows.push(list[i]) } } } // 取消勾选 } else { for(var i = preSelectedRowKeys.length-1 ; i>=0 ; i-- ){ a = preSelectedRowKeys[i] for( var j = curSelectedRowKeys.length-1 ; j>=0 ; j--){ b = curSelectedRowKeys[j] if( a == b){ preSelectedRowKeys.splice(i,1) break } } } let preSelectedRows = this.metaAction.gf('data.tableCheckbox.selectedRows').toJS() let curUncheckedYzpzmxRow = preSelectedRows.find(item => item.sortNo == preSelectedRowKeys[0]+1) if (curUncheckedYzpzmxRow) { for (var i = 0; i < list.length; i++) { if (list[i].yzpzxh == curUncheckedYzpzmxRow.yzpzxh) { let index = selectedRowKeys.indexOf(parseInt(list[i].sortNo)-1) if (index > -1) { selectedRowKeys.splice(index, 1) for (var i = selectedRows.length -1; i>=0; i--) { if (selectedRows[i].yzpzxh == list[i].yzpzxh) { selectedRows.splice(i, 1) } } } } } } } let total = { records: selectedRows.length, actualFee: 0, lateFee: 0, totalFee: 0, } selectedRows.forEach(item => { item.se = utils.number.clearThousPos(item.se) item.znje = utils.number.clearThousPos(item.znje) if(item.se) total.actualFee = Number(total.actualFee) + Number(item.se) if(item.znje) total.lateFee = Number(total.lateFee) + Number(item.znje) total.totalFee = Number(total.actualFee) + Number(total.lateFee) }) if (total.actualFee != 0) total.actualFee = utils.number.addThousPos(total.actualFee) if (total.lateFee != 0) total.lateFee = utils.number.addThousPos(total.lateFee) if (total.totalFee != 0) total.totalFee = utils.number.addThousPos(total.totalFee) this.injections.reduce('checkboxChange', total, selectedRows, selectedRowKeys) } closeClick = () => { this.component.props.closeModal() } getPreClick = () => { this.injections.reduce('setPaymentMethod', data.PAGETYPE_LIST) } onOk = async () => { let pageType = this.metaAction.gf('data.other.pageType') if(pageType == data.PAGETYPE_LIST){ let selectedRows = this.metaAction.gf('data.tableCheckbox.selectedRows').toJS() //复选框选择校验 if(!selectedRows.length){ this.metaAction.toast('warning', '请选择缴款项目') return false } let skssqq = selectedRows[0].skssqQ, skssqz = selectedRows[0].skssqZ let response = await this.webapi.chargeback.queryNsrsfxx({skssqq: skssqq, skssqz: skssqz}) if (response) { this.injections.reduce('loadYhxxs', response.yhxxs) } //跳到选择缴款方式列表 this.injections.reduce('setPaymentMethod', data.PAGETYPE_SFXY) return false }else if(pageType == data.PAGETYPE_SFXY){ let paymentMethodList = this.metaAction.gf('data.paymentMethodList').toJS(), isSelectYH = false, sfxyh for (var i = 0; i < paymentMethodList.length; i++) { if (paymentMethodList[i].c1 == true) { isSelectYH = true sfxyh = paymentMethodList[i].sfxyh break } } if (!isSelectYH) { this.metaAction.toast('warning', '请先选择银行网点') return false } const ret = await this.metaAction.modal('confirm', { title: '立即缴款', width: 420, content: '缴款成功后,将不能作废。确认要缴款吗?' }) if (ret) { let response = await this.save(sfxyh) this.metaAction.sf('data.other.chargeResult', true) this.injections.reduce('setPaymentMethod', data.PAGETYPE_LJJK) } } else { this.component.props.closeModal() } } save = async (sfxyh) => { let allList = this.metaAction.gf('data.allList').toJS(), totalFee = utils.number.clearThousPos(this.metaAction.gf('data.total').toJS().totalFee) allList.sfxyh = sfxyh allList.hjxx.bcjnse = totalFee allList.hjxx.se = totalFee allList.hjxx.ybtse = totalFee // 缴款接口已调通,开发阶段暂时不调用 //let res = await this.webapi.chargeback.paymentAmount(allList) let response = {} // 为屏蔽缴款接口增加,后续需要删除 response.skssqQ = allList.mxxxs.mxxx[0].skssqQ response.skssqZ = allList.mxxxs.mxxx[0].skssqZ response.zsxmMc = allList.mxxxs.mxxx[0].zsxmMc response.yzpzxh = allList.mxxxs.mxxx[0].yzpzxh response.se = allList.mxxxs.mxxx[0].se // 为屏蔽缴款接口增加,后续需要删除 response.zsjgs = [ { yzpzmxxh: 1, dzsphm: '320180621000002010', kkfhxx: '业务处理成功', se: '800.00' } ] // 为屏蔽缴款接口增加,后续需要删除 if (response) { this.injections.reduce('setReceipt', response.zsjgs) // const ret = await this.metaAction.modal('show', { // title: '提示', // okText: '确定', // width: 600, // wrapClassName: 'batchchargeback-tip', // children: this.getContent(response) // }) } } getContent = (res) => { let currentOrg = this.metaAction.context.get("currentOrg"), vatTaxpayerNum = currentOrg.vatTaxpayerNum ? currentOrg.vatTaxpayerNum : '' return <div> <p className='chenggongtishi'><Icon type="chenggongtishi" fontFamily='edficon'/><span>缴款成功</span></p > <p>尊敬的{currentOrg.name}税号:{vatTaxpayerNum}</p> <p>您的税款所属期为{res.skssqQ}至{res.skssqZ}的{res.zsxmMc}(应征凭证序号为:{res.yzpzxh})已成功缴款。</p> </div> } getColumns = (pageType) => { if(pageType == data.PAGETYPE_SFXY){ return [ { title: '选择', dataIndex: 'c1', align: 'center', width: 45, key: 'c1', render: this.renderRadioBox }, { title: '序号', dataIndex: 'sortNo', width: 45, align: 'center', key: 'sortNo' }, { title: '银行网点', dataIndex: 'yhMc', key: 'yhMc' }, { title: '银行账户', dataIndex: 'khzh', key: 'khzh' } ] }else if(pageType == data.PAGETYPE_LIST){ return [{ title: '序号', dataIndex: 'sortNo', key: 'sortNo', width: 45, align: 'center' }, { title: '应征凭证序号', dataIndex: 'yzpzxh', width: 150, key: 'yzpzxh' }, { title: '税(费)种', dataIndex: 'zsxmMc', width: 120, key: 'zsxmMc' }, { title: '税(品)目', dataIndex: 'zspmMc', width: 120, key: 'zspmMc' }, { title: '所属期起', dataIndex: 'skssqQ', key: 'skssqQ', width: 83, align: 'center' }, { title: '所属期止', dataIndex: 'skssqZ', key: 'skssqZ', width: 83, align: 'center' }, { title: '缴款期限', dataIndex: 'jkqx', key: 'jkqx', width: 83, align: 'center' }, { title: '应补退税额', dataIndex: 'ybtse', key: 'ybtse', width: 100, align: 'right' }, { title: '实缴金额', dataIndex: 'se', key: 'se', width: 100, align: 'right' }, { title: '滞纳金', dataIndex: 'znje', key: 'znje', width: 100, align: 'right' }, { title: '是否逾期', dataIndex: 'isYqjkXs', key: 'isYqjkXs', width: 70, align: 'center' } ] } else { return [{ title: '税(费)种', dataIndex: 'zsxmMc', width: 120, key: 'zsxmMc' }, { title: '税(品)目', dataIndex: 'zspmMc', width: 120, key: 'zspmMc' }, { title: '税款所属期起', dataIndex: 'skssqQ', key: 'skssqQ', width: 83, align: 'center' }, { title: '税款所属期止', dataIndex: 'skssqZ', key: 'skssqZ', width: 83, align: 'center' }, { title: '应补(退)税额', dataIndex: 'ybtse', key: 'ybtse', width: 100, align: 'right' }, { title: '实缴金额', dataIndex: 'se', key: 'se', width: 100, align: 'right' }, { title: '滞纳金', dataIndex: 'znje', key: 'znje', width: 100, align: 'right' } ] } } getPayInColumns = () => { return [ { title: '序号', dataIndex: 'yzpzmxxh', width: 45, align: 'center', key: 'yzpzmxxh' }, { title: '电子税票号码', dataIndex: 'dzsphm', key: 'dzsphm' }, { title: '缴款返回信息', dataIndex: 'kkfhxx', key: 'kkfhxx' }, { title: '缴款金额', dataIndex: 'se', key: 'se' } ] } renderRadioBox = (text, record, index) => { let reduce = this.injections.reduce return <Radio checked={record.c1} onChange={function(){ reduce('radioBoxChange', text, record, index) }}></Radio> } getOKName = () => { let pageType = this.metaAction.gf('data.other.pageType'), okBtnName if (pageType == data.PAGETYPE_LIST) { okBtnName = '立即缴款' } else if (pageType == data.PAGETYPE_SFXY) { okBtnName = '三方协议缴款' } else if (pageType == data.PAGETYPE_LJJK) { okBtnName = '确定' } return okBtnName } isDisplayPreBtn = () => { return this.metaAction.gf('data.other.pageType') == data.PAGETYPE_SFXY } isDisplayCancelBtn = () => { return this.metaAction.gf('data.other.pageType') != data.PAGETYPE_LJJK } } export default function creator(option) { const metaAction = new MetaAction(option), extendAction = extend.actionCreator({ ...option, metaAction }), o = new action({ ...option, metaAction, extendAction }), ret = { ...metaAction, ...extendAction.gridAction, ...o } metaAction.config({ metaHandlers: ret }) return ret }