@grid-form/common
Advanced tools
+1
-1
| { | ||
| "name": "@grid-form/common", | ||
| "version": "0.0.6", | ||
| "version": "0.0.8", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/0604hx/grid-form", |
+26
-9
@@ -5,2 +5,4 @@ import { ref, reactive, toRaw, unref, onMounted, nextTick, watch } from 'vue' | ||
| const DEFAULT_ACTION = "post" | ||
| export const RenderProps = { | ||
@@ -56,5 +58,3 @@ renders:{type:Object}, | ||
| const _submitDo = (formObj, action='post') =>{ | ||
| delete formObj['_disabled'] | ||
| const _checkRequire = formObj=>{ | ||
| if(props.review){ | ||
@@ -73,15 +73,32 @@ //进行表单项校验 | ||
| if(fails.length) return emits("failed", fails) | ||
| if(fails.length){ | ||
| props.debug && track(`[表单检查]`, fails) | ||
| return emits("failed", fails) | ||
| } | ||
| } | ||
| return true | ||
| } | ||
| emits("submit", formObj, action) | ||
| const _submitDo = (formObj, action=DEFAULT_ACTION) =>{ | ||
| delete formObj['_disabled'] | ||
| if(_checkRequire(formObj) === true) | ||
| emits("submit", formObj, action) | ||
| } | ||
| /** | ||
| * 点击主按钮时回调 | ||
| * | ||
| */ | ||
| const toSubmit = ()=>{ | ||
| let { onSubmit } = props.form | ||
| let formObj = _raw(formData) | ||
| if(!!onSubmit && typeof(onSubmit==='string')){ | ||
| if(_checkRequire(formObj) != true) return | ||
| triggerBeforeSubmit(onSubmit, formData, _raw(props.form.items)).then(obj=>{ | ||
| if(props.debug) track("<onSubmit> 回调函数返回(仅当返回布尔 true 方能继续提交表单)=", obj) | ||
| if(props.debug) track("<onSubmit> 回调函数返回(仅当返回布尔 true 方能继续提交表单)", obj) | ||
| if(obj === true){ | ||
| _submitDo(typeof(obj) === 'object'? obj: _raw(formData)) | ||
| // _submitDo(typeof(obj) === 'object'? obj: _raw(formData)) | ||
| emits("submit", formObj, DEFAULT_ACTION) | ||
| } | ||
@@ -94,3 +111,3 @@ else{ | ||
| else{ | ||
| _submitDo(_raw(formData)) | ||
| _submitDo(formObj) | ||
| } | ||
@@ -185,3 +202,3 @@ } | ||
| if(result === false){ | ||
| if(result !== true){ | ||
| if(props.debug) track(`<自定义按钮点击> 返回 ${result} 故中断后续的动作`) | ||
@@ -188,0 +205,0 @@ return |
+2
-2
| export const lifeCycles = [ | ||
| { name:"onLoad", text:"加载完成", summary:"表单加载完成后调用,参数格式为:function onLoad(form)", promise:false}, | ||
| { name:"onSubmit", text:"表单提交前", summary:"表单提交前触发,以 Promise 形式返回,当报错或者返回 false 时中断提交", promise:true}, | ||
| { name:"onLoad", text:"加载完成时", summary:"表单加载完成后调用,参数格式为:function onLoad(form, items)", promise:false}, | ||
| { name:"onSubmit", text:"表单提交前", summary:"表单提交前触发,以 Promise 形式返回,当报错或者返回非 true 时中断提交,参数:form, items", promise:true}, | ||
| { name:"onChange", text:"表单值变动时", summary:"表单值变动时出发,参数格式为:function onChange(form, agent, items)", promise: false }, | ||
@@ -5,0 +5,0 @@ { name:"afterSubmit", text:"表单提交后", summary:"表单成功提交后触发,参数格式为:function afterSubmit(form)", promise:false}, |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
17226
1.07%417
3.73%1
-50%