首页 > 其他 > 详细

react antd Table封装的可编辑组件 Radio 与 input 联动点击后input 发生改变

时间:2021-08-13 14:52:06      阅读:20      评论:0      收藏:0      [点我收藏+]

 React  antd Table  组件上

        {
          title: ‘是否为小微企业‘,
          dataIndex: ‘isXw‘,
          align: ‘center‘,
          width: 150,
          onCell: (record, index) => ({
            index,
            record,
            dataIndex: ‘isXw‘,
            inputType: ‘isRadio‘,
            handleOnChange: (dataIndex, value) => handleCellChange(index, dataIndex, value),
          }),
        },
        {
          title: `属于小微企业产品价格合计`,
          dataIndex: ‘de181Xw‘,
          align: ‘center‘,
          onCell: (record, index) => ({
            index,
            record,
            dataIndex: ‘de181Xw‘,
            inputType: ‘money‘,
            max: record.de181Bj,
            width: 230,
            handleOnChange: (dataIndex, value) => handleCellChange(index, dataIndex, value),
          }),
        },

  

React  antd Table  组件上 Oncell 方式上 change 事件方法

  // input选择变化
  function handleCellChange(index, dataIndex, value) {
    const newList = tableList.slice();
    if (dataIndex === ‘isXw‘) {
      if (value === 1) {
        newList[index] = { ...newList[index], [dataIndex]: value, de181Xw: 9000 };
        form.setFieldsValue(newList);
      } else {
        newList[index] = { ...newList[index], [dataIndex]: value, de181Xw: 0 };
        form.setFieldsValue(newList);
      }
    } else {
      form.setFieldsValue(newList);
      newList[index] = { ...newList[index], [dataIndex]: value };
      setTableList(newList);
    }
    setTableList(newList);
  }

  

react antd Table封装的可编辑组件 Radio 与 input 联动点击后input 发生改变

原文:https://www.cnblogs.com/zz19998/p/15135941.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!