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),
}),
},
// 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);
}