jeesite 组件联动问题

        本人是一个前端小白,第一份工作使用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',
},

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

&Mr.文

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值