编辑表单只读、默认值、必填、全部只读,表单设置默认值
给弹出框表单设置默认值或者表单只读

vue3 代码
//设置编辑表单全部只读
this.setFormReadonly(true);
//取消编辑表单全部只读
this.setFormReadonly(false);
//弹出框打开后设置只读、必填、默认值
const modelOpenAfter=(row,currentAction,isCopyClick)=> {
//新建时设置表单字段只读
gridRef.getFormOption("字段").readonly=gridRef.currentAction == 'Add'
//或者(注意代码生成器不要设置只读了)
gridRef.getFormOption("字段").disabled=gridRef.currentAction == 'Add'
//新建时设置默认值
if(gridRef.currentAction == 'Add'){
//如果是给下拉框设置值,值必须是字符串类型(自定义sql除外)
gridRef.editFormFields.字段 = "1";
//也可以设置数据源的第一个选项为默认值
// gridRef.editFormOptions.forEach(item => {
// item.forEach(x => {
// if (x.field == "字段") {
// //设置表单下拉框的值为第一个选项
// gridRef.editFormFields.字段=x.data[0].key
// }
// })
// })
}
//判断是否为编辑 gridRef.currentAction != 'Add'
}
vue2 代码
//设置编辑表单全部只读
this.setFormReadonly(true);
//取消编辑表单全部只读
this.setFormReadonly(false);
//弹出框打开后设置只读、必填、默认值
modelOpenAfter(row,currentAction,isCopyClick) {
//新建时设置表单字段只读
this.getFormOption("字段").readonly=this.currentAction == 'Add'
//或者(注意代码生成器不要设置只读了)
this.getFormOption("字段").disabled=this.currentAction == 'Add'
//新建时设置默认值
if(this.currentAction == 'Add'){
//如果是给下拉框设置值,值必须是字符串类型(自定义sql除外)
this.editFormFields.字段 = "1";
//也可以设置数据源的第一个选项为默认值
// this.editFormOptions.forEach(item => {
// item.forEach(x => {
// if (x.field == "字段") {
// //设置表单下拉框的值为第一个选项
// this.editFormFields.字段=x.data[0].key
// }
// })
// })
}
//判断是否为编辑 this.currentAction != 'Add'
}