MesgRender.js 6 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
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;
}