提交 ac3b16f6 编写于 作者: tony001's avatar tony001

调整表格值规则 --fix2

上级 d24611ed
...@@ -707,7 +707,8 @@ ${gridColumn.getName()} ...@@ -707,7 +707,8 @@ ${gridColumn.getName()}
* @type {*} * @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public rules: any = { public rules(){
return {
<#list ctrl.getPSDEGridEditItems() as edititem> <#list ctrl.getPSDEGridEditItems() as edititem>
${edititem.getName()}: [ ${edititem.getName()}: [
{ required: <#if edititem.isAllowEmpty()>false<#else>true</#if>, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: `<#if langbase??><#noparse>${</#noparse>this.$t('${langbase}.columns.${edititem.getName()?lower_case}')<#noparse>}</#noparse><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse><#else><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse></#if>`, trigger: 'change' }, { required: <#if edititem.isAllowEmpty()>false<#else>true</#if>, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: `<#if langbase??><#noparse>${</#noparse>this.$t('${langbase}.columns.${edititem.getName()?lower_case}')<#noparse>}</#noparse><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse><#else><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse></#if>`, trigger: 'change' },
...@@ -737,6 +738,7 @@ ${gridColumn.getName()} ...@@ -737,6 +738,7 @@ ${gridColumn.getName()}
], ],
</#list> </#list>
} }
}
/** /**
* 表格行编辑项校验 * 表格行编辑项校验
...@@ -750,7 +752,7 @@ ${gridColumn.getName()} ...@@ -750,7 +752,7 @@ ${gridColumn.getName()}
*/ */
public validate(property:string, data:any, rowIndex:number):Promise<any>{ public validate(property:string, data:any, rowIndex:number):Promise<any>{
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules()).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true); resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
...@@ -774,7 +776,7 @@ ${gridColumn.getName()} ...@@ -774,7 +776,7 @@ ${gridColumn.getName()}
let tempMessage: string = ''; let tempMessage: string = '';
index++; index++;
if (item.rowDataState === "create" || item.rowDataState === "update") { if (item.rowDataState === "create" || item.rowDataState === "update") {
for (let property of Object.keys(this.rules)) { for (let property of Object.keys(this.rules())) {
if (!await this.validate(property, item, index)) { if (!await this.validate(property, item, index)) {
validateState = false; validateState = false;
tempMessage = tempMessage + '<p>' + this.gridItemsModel[index][property].error + '<p>'; tempMessage = tempMessage + '<p>' + this.gridItemsModel[index][property].error + '<p>';
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册