<template>
	<u-form class="jnpf-wrap-form" ref="dataForm" :rules="rules" :model="formData" :errorType="['toast']"
		:label-position="formConf.labelPosition==='top'?'top':'left'"
		:label-width="formConf.labelWidth?formConf.labelWidth*1.5:150"
		:label-align="formConf.labelPosition==='right'?'right':'left'" :class="formClass+' '+formConfCopy.className">
		<view v-for="(item, index) in formConfCopy.fields" :key="item.__config__.renderKey">
			<Item v-if="!item.__config__.noShow && item.__config__.isVisibility" :itemData="item" :formConf="formConf"
				:formData="formData" :ref="'ref'+item.__config__.formId" :class="item.__config__.className"
				@clickIcon='clickIcon' @clickFun="onClick" @collapse-change="onCollapseChange" @tab-change="onTabChange"
				@input="setValue" />
		</view>
		<u-modal v-model="showTipsModal" width='70%' border-radius="16" :content-style="contentStyle"
			:content="tipsContent" :titleStyle="titleStyle" :title="tipsTitle" :confirm-style="confirmStyle"
			:confirm-text="$t('common.okText')" />
	</u-form>
</template>
<script>
	import Item from './Item'
	import {
		getDataInterfaceRes,
		getDictionaryDataSelector
	} from '@/api/common'
	const dyOptionsList = ['radio', 'checkbox', 'select', 'cascader', 'treeSelect']
	export default {
		components: {
			Item
		},
		props: {
			formConf: {
				type: Object,
				required: true
			},
			loading: {
				type: Boolean,
				default: false
			},
			isShortLink: {
				type: Boolean,
				default: false
			},
		},
		data() {
			const data = {
				formClass: 'form-' + this.jnpf.idGenerator(),
				formConfCopy: this.$u.deepClone(this.formConf),
				formData: {},
				rules: {},
				options: {},
				tableRefs: {},
				relations: {},
				refList: [],
				contentStyle: {
					fontSize: '28rpx',
					padding: '20rpx',
					lineHeight: '44rpx',
					textAlign: 'left'
				},
				titleStyle: {
					padding: '20rpx'
				},
				confirmStyle: {
					height: '80rpx',
					lineHeight: '80rpx',
				},
				tipsContent: '',
				tipsTitle: this.$t('common.tipTitle'),
				showTipsModal: false
			}
			this.beforeInit(data.formConfCopy.fields)
			this.initRelationForm(data.formConfCopy.fields)
			this.initFormData(data.formConfCopy.fields, data.formData, data.tableRefs)
			this.buildRules(this.$u.deepClone(data.formConfCopy.fields), data.rules)
			this.buildOptions(data.formConfCopy.fields, data.options, data.formData)
			this.buildRelations(data.formConfCopy.fields, data.relations)
			this.$nextTick(() => {
				this.onLoadFunc(data.formConfCopy)
				this.getRefList()
			})
			return data
		},
		provide() {
			return {
				parameter: this.parameter,
				relations: this.relations,
				isShortLink: this.isShortLink
			}
		},
		computed: {
			parameter() {
				const oldFormData = this.formConfCopy.formData ? this.formConfCopy.formData : {}
				this.formData.id = oldFormData.id || null
				this.formData.flowId = oldFormData.flowId || ''
				return {
					formData: this.formData,
					setFormData: this.setFormData,
					setShowOrHide: this.setShowOrHide,
					setRequired: this.setRequired,
					setDisabled: this.setDisabled,
					onlineUtils: this.jnpf.onlineUtils,
				}
			}
		},
		mounted() {
			this.$refs.dataForm.setRules(this.rules);
			this.initRelationData()
			uni.$on('subChange', (field) => {
				this.handleRelation(field.__vModel__)
			})
			this.initCss(this.formConfCopy)
		},
		methods: {
			beforeInit(fields) {
				const loop = (list) => {
					for (var index = 0; index < list.length; index++) {
						const config = list[index].__config__
						if (config.children && config.children.length) loop(config.children)
						if (config.jnpfKey == 'tableGrid') {
							let newList = []
							for (var i = 0; i < config.children.length; i++) {
								let element = config.children[i]
								for (var j = 0; j < element.__config__.children.length; j++) {
									let item = element.__config__.children[j]
									newList.push(...item.__config__.children)
								}
							}
							list.splice(index, 1, ...newList)
						}
					}
				}
				loop(fields)
			},
			initRelationForm(componentList) {
				componentList.forEach(cur => {
					const config = cur.__config__
					if (config.jnpfKey == 'relationFormAttr' || config.jnpfKey == 'popupAttr') {
						const relationKey = cur.relationField.split("_jnpfTable_")[0]
						componentList.forEach(item => {
							const noVisibility = Array.isArray(item.__config__.visibility) && !item
								.__config__.visibility.includes('app')
							if ((relationKey == item.__vModel__) && (noVisibility || !!item.__config__
									.noShow) && !cur.__vModel__) {
								cur.__config__.noShow = true
							}
						})
					}
					if (cur.__config__.children && cur.__config__.children.length) this.initRelationForm(cur
						.__config__.children)
				})
			},
			initFormData(componentList, formData, tableRefs) {
				componentList.forEach(cur => {
					const config = cur.__config__
					if (cur.__vModel__) {
						formData[cur.__vModel__] = config.defaultValue
						if (cur.__config__.jnpfKey == 'table' && !cur.__config__.noShow) {
							tableRefs[cur.__vModel__] = cur
						}
					}
					if (config.children && cur.__config__.jnpfKey !== 'table') {
						this.initFormData(config.children, formData, tableRefs)
					}
				})
			},
			buildOptions(componentList, data, formData) {
				componentList.forEach(cur => {
					const config = cur.__config__
					if (dyOptionsList.indexOf(config.jnpfKey) > -1) {
						if (config.dataType === 'dictionary' && config.dictionaryType) {
							cur.options = []
							getDictionaryDataSelector(config.dictionaryType).then(res => {
								cur.options = res.data.list || []
								data[cur.__vModel__ + 'Options'] = cur.options
								this.setFieldOptions(cur.__vModel__, cur.options)
								this.$nextTick(() => {
									uni.$emit("initCollapse")
								})
							})
						} else if (config.dataType === 'dynamic' && config.propsUrl) {
							cur.options = []
							let query = {
								paramList: this.jnpf.getParamList(config.templateJson, formData),
							}
							getDataInterfaceRes(config.propsUrl, query).then(res => {
								cur.options = Array.isArray(res.data) ? res.data : []
								data[cur.__vModel__ + 'Options'] = cur.options
								this.setFieldOptions(cur.__vModel__, cur.options)
								uni.$emit("initCollapse")
							})
						} else {
							data[cur.__vModel__ + 'Options'] = cur.options
						}
					}
					if (config.children && config.jnpfKey !== 'table') this.buildOptions(config.children, data,
						formData)
				})
			},
			buildRules(componentList, rules) {
				componentList.forEach(cur => {
					const config = cur.__config__
					const jnpfKey = config.jnpfKey
					const useNumList = ['inputNumber', 'switch', 'datePicker', 'rate', 'slider', 'calculate']
					const useArrayList = ['select', 'posSelect', 'userSelect', 'treeSelect', 'popupTableSelect',
						'organizeSelect'
					]
					config.regList = !config.regList ? [] : config.regList
					if (config.required) {
						const label = config.labelI18nCode ?
							this.$t(config.labelI18nCode, config.label) : config.label;
						let requiredItem = {
							required: config.required,
							message: `${label} ${this.$t('sys.validate.textRequiredSuffix')}`
						};
						config.regList.push(requiredItem)
					}
					const rule = config.regList.map(item => {
						if (item.pattern) {
							item.pattern = item.pattern.toString()
							let start = item.pattern.indexOf('/')
							let stop = item.pattern.lastIndexOf('/')
							let str = item.pattern.substring(start + 1, stop)
							let reg = new RegExp(str)
							item.pattern = reg
						}
						item.trigger = config.trigger || 'change, blur'
						if (Array.isArray(config.defaultValue)) item.type = 'array'
						if (useNumList.includes(jnpfKey)) item.type = 'number'
						if (useArrayList.includes(jnpfKey) && cur.multiple) item.type = 'array'
						if (jnpfKey === 'usersSelect' || jnpfKey === 'areaSelect' || jnpfKey ===
							'checkbox' || jnpfKey === 'cascader') item.type = 'array'

						if (jnpfKey === 'relationForm' || jnpfKey === 'popupSelect' || jnpfKey ===
							'select' || jnpfKey === 'radio' || jnpfKey === 'treeSelect') {
							item.type = 'any',
								item.validator = (rule, value, callback) => {
									if (value || value === 0) {
										callback();
									} else {
										callback(new Error(config.label + '不能为空'));
									}
								}
						}
						if (item.messageI18nCode) {
							item.message = this.$t(item.messageI18nCode, item.message);
						}
						return item
					})
					if (rule.length) rules[cur.__vModel__] = rule
					if (config.children && jnpfKey !== 'table') this.buildRules(this.$u.deepClone(config.children),
						rules)
				})
			},
			/**
			 * cur 对象
			 * relationField 关联的数据项
			 * relations 包含所有相关的配置信息
			 * opType 类型
			 **/
			addRelationItem(cur, relationField, relations, opType) {
				let realVModel = cur.__config__.isSubTable ? `${cur.__config__.parentVModel}-${cur.__vModel__}` : cur
					.__vModel__;
				let item = {
					...cur,
					realVModel,
					opType
				};
				if (relations.hasOwnProperty(relationField)) {
					if (!relations[relationField].some(o => o.realVModel === item.realVModel)) {
						relations[relationField].push(item);
					}
				} else {
					relations[relationField] = [item];
				}
			},
			/**
			 * config 对象
			 * type 开始或者结束类型
			 * target 目标字段
			 * value 开始或者结束时间值 
			 **/
			processTimeRule(config, type, target, value) {
				let time;
				switch (type) {
					case 1:
						return value || (type === 'startTime' ? '00:00:00' : '23:59:59');
					case 3:
						return this.jnpf.toDate(new Date(), config.format === 'HH:mm' ? 'HH:mm:00' : config.format);
					default:
						let offset = Number(value);
						if (target === 1) {
							time = new Date().setHours(type === 4 ? new Date().getHours() - offset : new Date()
								.getHours() + offset);
						} else if (target === 2) {
							time = new Date().setMinutes(type === 4 ? new Date().getMinutes() - offset : new Date()
								.getMinutes() + offset);
						} else if (target === 3) {
							time = new Date().setSeconds(type === 4 ? new Date().getSeconds() - offset : new Date()
								.getSeconds() + offset);
						}
						return this.$u.timeFormat(time, 'hh:MM:ss');
				}
			},
			/**
			 * type 开始或者结束类型
			 * target 目标字段
			 * value 开始或者结束时间值 
			 **/
			calculateDateOffset(type, value, target) {
				let date = new Date();
				switch (type) {
					case 1:
						return Number(value);
					case 3:
						return date.getTime();
					default:
						let offset = Number(value);
						if (target === 1) {
							date.setFullYear(date.getFullYear() + (type === 4 ? -offset : offset));
						} else if (target === 2) {
							date.setMonth(date.getMonth() + (type === 4 ? -offset : offset));
						} else if (target === 3) {
							date.setDate(date.getDate() + (type === 4 ? -offset : offset));
						}
						return date.getTime();
				}
			},
			buildRelations(componentList, relations) {
				const selectType = ['org', 'pos', 'role', 'group'];
				componentList.forEach(cur => {
					const config = cur.__config__;
					const vModel = cur.__vModel__;

					if (config.jnpfKey === 'userSelect' && selectType.includes(cur.selectType)) {
						if (cur.relationField) this.addRelationItem(cur, cur.relationField, relations,
							'setUserOptions');
					}
					if (dyOptionsList.indexOf(config.jnpfKey) > -1 && config.dataType === 'dynamic' && config
						.templateJson && config.templateJson.length) {
						config.templateJson.forEach(e => {
							if (e.relationField) this.addRelationItem(cur, e.relationField, relations,
								'setOptions');
						});
					}
					if (config.jnpfKey === 'datePicker') {
						if (config.startTimeRule) cur.startTime = this.calculateDateOffset(config.startTimeType,
							config.startTimeValue, config.startTimeTarget);
						if (config.endTimeRule) cur.endTime = this.calculateDateOffset(config.endTimeType,
							config.endTimeValue, config.endTimeTarget);
						if (config.startRelationField) this.addRelationItem(cur, config.startRelationField,
							relations, 'setDate');
						if (config.endRelationField) this.addRelationItem(cur, config.endRelationField, relations,
							'setDate');
					}
					if (config.jnpfKey === 'timePicker') {
						if (config.startTimeRule) cur.startTime = this.processTimeRule(config,
							config.startTimeType, config.startTimeTarget, config.startTimeValue);
						if (config.endTimeRule) cur.endTime = this.processTimeRule(config, config.endTimeType,
							config.endTimeTarget, config.endTimeValue);
						if (config.startRelationField) this.addRelationItem(cur, config.startRelationField,
							relations, 'setTime');
						if (config.endRelationField) this.addRelationItem(cur, config.endRelationField, relations,
							'setTime');
					}
					if (config.jnpfKey === 'popupSelect' && cur.templateJson && cur.templateJson.length) {
						cur.templateJson.forEach(e => {
							if (e.relationField) this.addRelationItem(cur, e.relationField, relations,
								'setPopupOptions');
						});
					}
					if (config.children) this.buildRelations(config.children, relations);
				});
			},
			onLoadFunc(formConfCopy) {
				if (!formConfCopy || !formConfCopy.funcs || !formConfCopy.funcs.onLoad) return
				const onLoadFunc = this.jnpf.getScriptFunc(formConfCopy.funcs.onLoad)
				if (!onLoadFunc) return
				onLoadFunc(this.parameter)
			},
			initRelationData() {
				const handleRelationFun = (list) => {
					list.forEach(cur => {
						const config = cur.__config__
						this.handleDefaultRelation(cur.__vModel__)
						if (config.children) handleRelationFun(config.children)
					})
				}
				handleRelationFun(this.formConfCopy.fields)
			},
			initCss(formCopy) {
				// #ifdef H5
				if (!formCopy.classJson) return
				if (document.getElementById('styleId')) document.getElementById('styleId').remove()
				let head = document.getElementsByTagName('head')[0]
				let style = document.createElement('style')
				style.type = 'text/css'
				style.id = 'styleId'
				style.innerText = this.buildCSS(formCopy.classJson)
				head.appendChild(style)
				//#endif
			},
			buildCSS(str) {
				str = str.trim();
				let newStr = '';
				let cut = str.split('}');
				cut.forEach(item => {
					if (item) {
						item = '.' + this.formClass + ' ' + item + '}';
						newStr += item;
					}
				});
				return newStr;
			},
			handleRelation(field) {
				if (!field) return
				const currRelations = this.relations
				for (let key in currRelations) {
					if (key === field) {
						for (let i = 0; i < currRelations[key].length; i++) {
							const e = currRelations[key][i];
							let vModel = e.realVModel || e.__vModel__
							const config = e.__config__
							const jnpfKey = config.jnpfKey
							let defaultValue = ''
							if (['checkbox', 'cascader'].includes(jnpfKey) || (['select', 'treeSelect', 'popupSelect',
									'popupTableSelect', 'userSelect'
								].includes(jnpfKey) && e.multiple)) {
								defaultValue = []
							}
							if (vModel.includes('-')) { // 子表字段
								const tableVModel = vModel.split('-')[0]
								uni.$emit('handleRelation', e, defaultValue, true)
							} else {
								this.setFormData(vModel, defaultValue)
								if (e.opType === 'setOptions') {
									let query = {
										paramList: this.jnpf.getParamList(config.templateJson, this.formData)
									}
									getDataInterfaceRes(config.propsUrl, query).then(res => {
										let realData = res.data || []
										this.setFieldOptions(vModel, realData)
										uni.$emit("initCollapse")
									})
								}
								if (e.opType === 'setUserOptions') {
									let value = this.formData[e.relationField] || []
									this.comSet('ableRelationIds', vModel, Array.isArray(value) ? value : [value])
								}
								if (e.opType === 'setDate' || e.opType === 'setTime') {
									let startTime = ''
									let endTime = ''
									if (config.startTimeType == 2) {
										startTime = this.formData[config.startRelationField] || 0
										if (e.opType === 'setTime') {
											startTime = this.formData[config.startRelationField] ||
												'00:00:00'
											if (startTime && (startTime.split(':').length == 3)) {
												startTime = startTime
											} else {
												startTime = startTime + ':00'
											}
										}
									} else {
										startTime = e.startTime
									}
									if (config.endTimeType == 2) {
										endTime = this.formData[config.endRelationField] || 0
										if (e.opType === 'setTime') {
											endTime = this.formData[config.endRelationField] ||
												'00:00:00'
											if (endTime && (endTime.split(':').length == 3)) {
												endTime = endTime
											} else {
												endTime = endTime + ':00'
											}
										}
									} else {
										endTime = e.endTime
									}
									this.comSet('startTime', vModel, startTime)
									this.comSet('endTime', vModel, endTime)
								}
							}
						}
					}
				}
			},
			handleDefaultRelation(field) {
				if (!field) return
				const currRelations = this.relations
				for (let key in currRelations) {
					if (key === field) {
						for (let i = 0; i < currRelations[key].length; i++) {
							const e = currRelations[key][i];
							let vModel = e.realVModel || e.__vModel__
							const config = e.__config__
							let defaultValue = ''
							if (vModel.includes('-')) { // 子表字段
								const tableVModel = vModel.split('-')[0]
								uni.$emit('handleRelation', e, defaultValue)
							} else {
								if (e.opType === 'setUserOptions') {
									let value = this.formData[e.relationField] || []
									this.comSet('ableRelationIds', e.__vModel__, Array.isArray(value) ? value : [value])
								}
								if (e.opType === 'setDate' || e.opType === 'setTime') {
									let startTime = ''
									let endTime = ''
									if (config.startTimeType == 2) {
										startTime = this.formData[config.startRelationField] || 0
										if (e.opType === 'setTime') {
											startTime = this.formData[config.startRelationField] ||
												'00:00:00'
											if (startTime && (startTime.split(':').length == 3)) {
												startTime = startTime
											} else {
												startTime = startTime + ':00'
											}
										}
									} else {
										startTime = e.startTime
									}
									if (config.endTimeType == 2) {
										endTime = this.formData[config.endRelationField] || 0
										if (e.opType === 'setTime') {
											endTime = this.formData[config.endRelationField] ||
												'23:59:59'
											if (endTime && (endTime.split(':').length == 3)) {
												endTime = endTime
											} else {
												endTime = endTime + ':00'
											}
										}
									} else {
										endTime = e.endTime
									}
									this.comSet('startTime', e.__vModel__, startTime)
									this.comSet('endTime', e.__vModel__, endTime)
								}
							}
						}
					}
				}
			},
			onChange(field) {
				this.handleRelation(field.__vModel__)
			},
			setValue(item) {
				if (item.__vModel__) {
					this.$set(this.formData, item.__vModel__, item.__config__.defaultValue)
				}
			},
			setFormData(prop, value) {
				if (!prop || this.formData[prop] === value) return;
				const isChildTable = prop.indexOf('.') > -1
				if (isChildTable) {
					const list = prop.split('.')
					for (let i = 0; i < this.refList.length; i++) {
						const item = this.refList[i]
						if (item[0] == list[0]) {
							const tableRef = Array.isArray(item[1]) ? item[1][0] : item[1]
							tableRef.setTableFormData(list[1], value)
							break
						}
					}
				} else {
					this.comSet('defaultValue', prop, value)
					this.formData[prop] = value
				}
				this.handleRelation(prop)
			},
			setShowOrHide(prop, value) {
				const newVal = !!value
				const isChildTable = prop.indexOf('.') > -1
				if (!isChildTable) {
					this.comSet('noShow', prop, !newVal)
				}
			},
			setRequired(prop, value) {
				const newVal = !!value
				const isChildTable = prop.indexOf('.') > -1
				if (!isChildTable) {
					this.comSet('required', prop, newVal)
					this.rules = {}
					this.buildRules(this.$u.deepClone(this.formConfCopy.fields), this.rules)
					this.$refs.dataForm.setRules(this.rules);
				}
			},
			setDisabled(prop, value) {
				const newVal = !!value
				const isChildTable = prop.indexOf('.') > -1
				if (!isChildTable) {
					this.comSet('disabled', prop, newVal)
				}
			},
			setFieldOptions(prop, value) {
				const newVal = Array.isArray(value) ? value : []
				const isChildTable = prop.indexOf('.') > -1
				if (!isChildTable) {
					this.comSet('options', prop, newVal)
				}
			},
			comSet(field, prop, value) {
				if (!prop) return
				const loop = list => {
					for (let i = 0; i < list.length; i++) {
						let item = list[i]
						const config = item.__config__
						if (item.__vModel__ && item.__vModel__ === prop) {
							config.defaultValue = this.formData[prop]
							switch (field) {
								case 'disabled':
									item[field] = value
									break;
								case 'ableRelationIds':
									this.$set(item, field, value)
								case 'options':
									if (dyOptionsList.indexOf(config.jnpfKey) > -1) item.options = value
									break;
								case 'startTime':
									this.$set(item, field, value)
									break;
								case 'endTime':
									this.$set(item, field, value)
									break;
								default:
									config[field] = value
									this.setValue(item)
									break;
							}
							config.renderKey = +new Date() + item.__vModel__
							break;
						}
						if (config && config.jnpfKey !== 'table' && config.children && Array.isArray(config
								.children)) loop(config.children)
					}
				}
				loop(this.formConfCopy.fields)
			},
			submitForm() {
				try {
					this.beforeSubmit().then(() => {
						this.submit()
					})
				} catch (e) {
					this.submit()
				}
			},
			submit() {
				this.$refs.dataForm.validate(valid => {
					if (!valid) return
					if (!this.checkTableData()) return
					this.$emit('submit', this.formData, this.afterSubmit)
				});
			},
			beforeSubmit() {
				if (!this.formConfCopy || !this.formConfCopy.funcs || !this.formConfCopy.funcs.beforeSubmit) return Promise
					.resolve()
				const func = this.jnpf.getScriptFunc(this.formConfCopy.funcs.beforeSubmit)
				if (!func) return Promise.resolve()
				return func(this.parameter)
			},
			afterSubmit() {
				if (!this.formConfCopy || !this.formConfCopy.funcs || !this.formConfCopy.funcs.afterSubmit) return
				const func = this.jnpf.getScriptFunc(this.formConfCopy.funcs.afterSubmit)
				if (!func) return
				func(this.parameter)
			},
			// 子表必填验证，子表赋值
			checkTableData() {
				this.getRefList();
				let isValid = true;
				for (const vModel in this.tableRefs) {
					const config = this.tableRefs[vModel].__config__;
					if (!config.isVisibility || config.noShow) continue;

					const tableRef = this.findTableRef(vModel);
					if (!tableRef) continue;

					const submitResult = this.getTableSubmitResult(tableRef, vModel);
					if (submitResult) {
						this.formData[vModel] = submitResult;
					} else {
						isValid = false;
					}
				}
				return isValid;
			},
			findTableRef(vModel) {
				for (const item of this.refList) {
					if (item[0] === vModel) {
						return Array.isArray(item[1]) ? item[1][0] : item[1];
					}
				}
				return null;
			},
			getTableSubmitResult(tableRef, vModel) {
				const refToSubmit = tableRef.$refs && tableRef.$refs[vModel] ? tableRef.$refs[vModel] : tableRef;
				return refToSubmit.submit ? refToSubmit.submit() : false;
			},
			//获取子表实例ref 
			getRefList() {
				this.refList = [];
				const refList = this.$refs || [];
				const loopRefs = (refs) => {
					if (!refs) return
					for (const key in refs) {
						const ref = refs[key];
						if (Array.isArray(ref)) {
							ref.forEach(item => loopRefs(item));
						} else {
							this.refList.push([key, ref]);
						}
					}
				};

				if (Array.isArray(refList)) {
					refList.forEach(item => loopRefs(item));
				} else {
					loopRefs(refList);
				}
			},
			clickIcon(e) {
				if (!e?.__config__) return;
				const {
					tipLabel,
					label: configLabel,
					jnpfKey
				} = e.__config__;
				const {
					helpMessage
				} = e;
				if (!tipLabel && !helpMessage) return;
				this.tipsContent = helpMessage || tipLabel;
				this.tipsTitle =
					jnpfKey === 'card' ? e.header :
					jnpfKey === 'groupTitle' ? e.content :
					configLabel;

				this.showTipsModal = true;
			},
			onBlur(item, data) {
				this.setValue(item)
				this.setScriptFunc(data, item, 'blur')
			},
			onTabChange(item, data) {
				this.setScriptFunc(data, item, 'tabClick')
			},
			onClick(item, data) {
				this.setScriptFunc(data, item, 'click')
			},
			onCollapseChange(item, data) {
				this.setScriptFunc(data, item)
			},
			setScriptFunc(val, data, type = 'change') {
				if (data && data.on && data.on[type]) {
					const func = this.jnpf.getScriptFunc(data.on[type]);
					if (!func) return
					func.call(this, {
						data: val,
						...this.parameter
					})
				}
			},
		}
	}
</script>