本人是一个前端小白,第一份工作使用jeesite做平台,边开发边摸索,并做下此记录方便后期查看。
多select联动
{
label: t('客户'),
field: 'cuId',
fieldLabel: 'cuCompanyName',
required: true,
component: 'TreeSelect',
colProps: { lg: 8, md: 24 },
componentProps: ({ formActionType, formModel }) => {
//formActionType: 操作表单的函数
//formModel: 表单的双向绑定对象
return {
api: officeTreeData,
params: { officeTypes: 4 },
onChange: (e: any) => {
//onChange:文件列表内容改变触发事件
//e:被选中数据信息
customer.value = [];
const test = {
'employee.office.officeCode': e, // 将选中数据存入test
};
empUserListData(test).then((res) => { // 使用选中客户数据做请求,获取客户联系人数据。
res.list.forEach((resource: any) => { // 通过接口获取到该客户绑定有多个联系人,进行数据遍历。
let temp = { //遍历数据存入temp对象
label: resource.refName,
value: resource.refCode,
key: resource.refCode,
};
customer.value.push(temp); //temp对象添加进customer数组
});
const { updateSchema } = formActionType;
//updateSchema:更新表单的 schema, 只更新函数所传的参数
updateSchema({
//更新表单内field为'customerContact'的组件,options值为customer.value
field: 'customerContact',
componentProps: () => {
return {
options: customer.value,
};
},
});
});
},
};
},
},
{
label: '客户联系人',
field: 'customerContact',
component: 'Input',
colProps: { lg: 8, md: 24 },
componentProps: ({}) => {
return {
options: voyage.value,
};
},
},
select与input联动
{
label: t('客户'),
field: 'cuId',
fieldLabel: 'cuCompanyName',
required: true,
component: 'TreeSelect',
colProps: { lg: 8, md: 24 },
componentProps: ({ formActionType, formModel }) => {
//formActionType: 操作表单的函数
//formModel: 表单的双向绑定对象
return {
api: officeTreeData,
params: { officeTypes: 4 },
onChange: (e: any) => {
//onChange:文件列表内容改变触发事件
//e:被选中数据信息
customer.value = ''
const test = {
'employee.office.officeCode': e, // 将选中数据存入test
};
empUserListData(test).then((res) => { // 使用选中客户数据做请求,获取客户联系人数据。
customer.value = res.customerContact //请求成功,将返回数据内customerContact字段数据的赋值给customer
});
//将表单内customerContact字段的值与customer.value绑定
formModel.customerContact = customer.value;
};
},
},
{
label: '客户联系人',
field: 'customerContact',
component: 'Input',
},