MesgRender.js 6 KB
import { MsgCodes } from './MesgJson/MsgCodes'
// import {MsgCodes} from '~/json/job.json'
import { contextValidate, fillNodeValue } from './MesgValidator'

const MSG_ID_KEY = "GrpHdr.MsgId" //消息号PATH

export default function MesgRender(msgtype, node, action = 'new') {
	if (action == 'read')
		return MesgReadRender(msgtype, node, action)

	//根据类型,返回组件名
	let { type, path } = node
	node.mty = msgtype.toLowerCase().split("_").join(".")
	let uid = path
	let renderObj = { is: 'elcs-empty' }
	if (uid == MSG_ID_KEY) {
		renderObj = { is: "elcs-msgid" }
	}
	else if (uid == 'GrpHdr.InstgPty' || uid == 'GrpHdr.InstgAgt.BrinchId.Id') //发送机构
	{
		renderObj = { is: "elcs-sendpty" }
	}
	else if (uid.endsWith(".BkCd") || type=="Bkcd" || uid.endsWith(".IssBkCd") || uid.endsWith(".PresnBkCode")) {
		renderObj = { is: 'elcs-bkcd' }
	}else if (uid.endsWith(".DocsDtls")) {
		renderObj = { is: 'table-doc' }
	}
	else if (uid == 'ChckInf.SnDt' && msgtype == 'ccms.991.001.01') {
		renderObj = { is: 'elcs-white-label', label: action == 'new' ? '【系统自动添加当前时间戳】' : 'HOT_LOAD' } //系统日期
		node.value = 'SYS_TIMESTAMP'
	}
	else if (/^Max\d{1,2}Text$/.test(type)) {
		let lenstr = type.substring(3, type.length - 4)
		renderObj = { is: 'elcs-max2d-text', length: Number(lenstr) }
	}
	else if (/^Max\d{3,}Text$/.test(type)) {
		let lenstr = type.substring(3, type.length - 4)
		renderObj = { is: 'elcs-max3d-text', length: Number(lenstr) }
	}
	else if (type == 'ISODateTime') {
		if (action == 'new' && uid == 'GrpHdr.CreDtTm')
			renderObj = { is: 'elcs-white-label', label: action == 'new' ? '【系统自动添加当前时间】' : 'HOT_LOAD' }
		else
			renderObj = { is: 'elcs-datetime-picker' }
	}
	else if (type == 'ISODate') {
		if (uid == 'PrcDt') {
			renderObj = { is: 'elcs-white-label', 'label': action == 'new' ? '由ELCS自动添加' : 'HOT_LOAD' }
		}
		else
			renderObj = { is: 'elcs-isodate' }
		if (uid == 'LCInfo.DtOfIss')
			renderObj.maxDate = SYS_DATE
		// else if (uid == 'ModInfo.ModDt') {
		// 	renderObj.minDate = SYS_DATE
		// 	node.value = SYS_DATE
		// }
	}
	else if (MsgCodes[type]) {
		if (type == 'RegistrationFlag(Max4Text)')
			type += '_W'
		renderObj = { is: 'elcs-combobox' }
	}
	else if (type == 'RegMsgType') {
		renderObj = { is: 'elcs-regmsgtype' }
		node.value = []
	}
	else if (type == 'Exact1NumericText') {
		renderObj = { is: 'elcs-white-label' }
	}
	else if (type == 'ActiveCurrencyAndAmount') {
		renderObj = { is: 'elcs-amount' }
	}
	else if (type == 'AmountRate') {
		renderObj = { is: 'elcs-amount-rate' }
	}
	else if (/^Max\dNumericText$/.test(type)) {
		let lenstr = type.substring(3, 4) //取出数字
		renderObj = {
			is: 'elcs-spinner', max:
				uid == 'LCInfo.Hon.ExpOfPmt' ? //付款期限不得超过366
					366 :
					Math.pow(10, Number(lenstr)),
			min: 0
		}
	}
	else if (type == 'NoticeStateCode(Max4Text)') {
		renderObj = { is: 'elcs-white-label', label: '拒绝通知' }
		node.value = 'ADRE'
	}
	else if (type == 'TransBankList') //转让行
	{
		renderObj = { is: 'elcs-transbank-list' }
		node.value = []
	}
	else if (type == 'Any') {
		renderObj = { is: 'elcs-any' }
	}
	else if (type == 'Exact8NumericText') {
		renderObj = { is: 'elcs-white-label', label: 'HOT_LOAD' }
	}
	else if (type == '720DTL') {
		renderObj = { is: 'elcs-720-dtl' }
		node.value = []
	}
	else if (type == '916ChngInf') {
		renderObj = { is: 'elcs-916-chnginf' }
		node.value = []
	}
	else if (type == 'Syspara') {
		renderObj = { is: 'elcs-syspara' }
		node.value = []
	}
	else if (type == 'TrsfBkInfo')
		renderObj = { is: 'elcs-transbank-list' }
	renderObj.action = action
	renderObj.contextValidate = contextValidate.bind(node)
	return renderObj;
}

export function MesgReadRender(msgtype, node, action = 'read') {
	//根据类型,返回组件名
	let { type, path } = node
	node.mty = msgtype.toLowerCase().split("_").join(".")
	let uid = path
	let renderObj = { is: 'elcs-plaintext' }
	if (uid == MSG_ID_KEY) {
		renderObj = { is: "elcs-plaintext" }
	}
	else if (uid == 'GrpHdr.InstgPty' || uid == 'GrpHdr.InstgAgt.BrinchId.Id') //发送机构
	{
		renderObj = { is: "elcs-plaintext" }
	}
	else if (uid.endsWith(".BkCd")) {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (uid == 'ChckInf.SnDt' && msgtype == 'ccms.991.001.01') {
		renderObj = { is: 'elcs-plaintext' } //系统日期

	}
	else if (/^Max\d{1,2}Text$/.test(type)) {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (/^Max\d{3,}Text$/.test(type)) {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (type == 'ISODateTime') {

		renderObj = { is: 'elcs-plaintext' }
	}
	else if (type == 'ISODate') {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (MsgCodes[type]) {
		if (type == 'RegistrationFlag(Max4Text)')
			type += '_W'
		renderObj = { is: 'elcs-codelabel', code: type }
	}
	else if (type == 'RegMsgType') {
		renderObj = { is: 'elcs-regmsgtype' }
		node.value = []
	}
	else if (type == 'Exact1NumericText') {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (type == 'ActiveCurrencyAndAmount') {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (type == 'AmountRate') {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (/^Max\dNumericText$/.test(type)) {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (type == 'NoticeStateCode(Max4Text)') {
		renderObj = { is: 'elcs-white-label', label: '拒绝通知' }
		node.value = 'ADRE'
	}
	else if (type == 'TransBankList') //转让行
	{
		renderObj = { is: 'elcs-transbank-list' }
		node.value = []
	}
	else if (type == 'Any') {
		renderObj = { is: 'elcs-any' }
	}
	else if (type == 'Exact8NumericText') {
		renderObj = { is: 'elcs-plaintext' }
	}
	else if (type == '720DTL') {
		renderObj = { is: 'elcs-720-dtl' }
		node.value = []
	}
	else if (type == '916ChngInf') {
		renderObj = { is: 'elcs-916-chnginf' }
		node.value = []
	}
	else if (type == 'Syspara') {
		renderObj = { is: 'elcs-syspara' }
		node.value = []
	}
	else if (type == 'TrsfBkInfo')
		renderObj = { is: 'elcs-transbank-list' }
	renderObj.action = action
	//renderObj.contextValidate = contextValidate.bind(node)
	return renderObj;
}