1、框架:jeecg低代码框架
2、需求:用到框架的JEditableTable组件,第二个字段需要根据第一个字段值变化而变化
首先设置了列的值
columns: [
{
title: ‘’,
key: ‘indexName’,
width: ‘50%’,
type: FormTypes.select,
options: [ // 下拉选项
],
defaultValue: '',
placeholder: '请输入${title}',
validateRules: [
{ required: true, message: '${title}不能为空' },
{
unique: true,
message: '${title}不能重复'
},
]
},
{
title: '',
key: 'indexValueDetail',
width: '50%',
type: FormTypes.popup,
popupCode: 'getDataValueByDeviceTypeDataId',
orgFields: 'index_name,index_value',
destFields: 'indexValueDetail,indexValue',
**param:‘第一个字段的id值’,**
onOpenPopup: this.onOpenPopup,
defaultValue: '',
placeholder: '请选择${title}',
validateRules: [{ required: true, message: '${title}不能为空' }]
},
]
方案:给jpopup组件上绑定一个事件绑定onOpenPopup方法,一点击jpopup弹窗的时候调用onOpenPopup方法,设置弹窗的时候,param参数总是为当前行第一个字段值的id,代码如下:
async onOpenPopup(target, rowIndex) {
const { values } = await target.getAll(false) //拿到JEditableTable对象的表单值
const indexName = values[rowIndex].indexName
this.qualitativeList.forEach(item => {
if (item.indexName === indexName) {
this.$set(this.qualitativeIndex.columns[1], ‘param’, { deviceTypeDataId: item.deviceDataId })
}
})
},