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

调整表格值规则 --fix2

上级 d24611ed
......@@ -707,7 +707,8 @@ ${gridColumn.getName()}
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public rules: any = {
public rules(){
return {
<#list ctrl.getPSDEGridEditItems() as edititem>
${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' },
......@@ -737,6 +738,7 @@ ${gridColumn.getName()}
],
</#list>
}
}
/**
* 表格行编辑项校验
......@@ -750,7 +752,7 @@ ${gridColumn.getName()}
*/
public validate(property:string, data:any, rowIndex:number):Promise<any>{
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);
resolve(true);
}).catch(({ errors, fields }) => {
......@@ -774,7 +776,7 @@ ${gridColumn.getName()}
let tempMessage: string = '';
index++;
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)) {
validateState = false;
tempMessage = tempMessage + '<p>' + this.gridItemsModel[index][property].error + '<p>';
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册