Commit a29f385b authored by zhangwenshuai's avatar zhangwenshuai

update

parent a346e562
...@@ -48,6 +48,7 @@ const Cell = (props: CellProps) => { ...@@ -48,6 +48,7 @@ const Cell = (props: CellProps) => {
renderEditCell, renderEditCell,
cellRenderProps, cellRenderProps,
readOnlyFlag, readOnlyFlag,
columnAttrObj,
} = columnConfig; } = columnConfig;
const cellUnit = useRef(null); const cellUnit = useRef(null);
const [status, setStatus] = useState('detail'); const [status, setStatus] = useState('detail');
...@@ -94,22 +95,6 @@ const Cell = (props: CellProps) => { ...@@ -94,22 +95,6 @@ const Cell = (props: CellProps) => {
}; };
const changeValue = async (changedValue: any, optionValue: any) => { const changeValue = async (changedValue: any, optionValue: any) => {
// 校验必填项
if (requiredFlag) {
if (!changedValue || changedValue.length === 0) {
message.error('该字段为必填项');
resetEditStatus();
return;
}
if (changedValue.length === 1) {
const data = changedValue[0];
if (!data.value && !data.text && data.value !== 0) {
message.error('该字段为必填项');
resetEditStatus();
return;
}
}
}
const extraData = FormHelper.changeTableData({ const extraData = FormHelper.changeTableData({
item: columnConfig, item: columnConfig,
changedKey: columnName, changedKey: columnName,
...@@ -367,6 +352,23 @@ const Cell = (props: CellProps) => { ...@@ -367,6 +352,23 @@ const Cell = (props: CellProps) => {
onChange={changeCellData} onChange={changeCellData}
rowData={record} rowData={record}
onEmitChange={(changedValue: any, optionValue: any, reset?: boolean) => { onEmitChange={(changedValue: any, optionValue: any, reset?: boolean) => {
// 校验必填项
if (requiredFlag&&!changedValue) {
message.error('该字段为必填项');
resetEditStatus();
return;
}
// 校验规则
if (columnAttrObj.rules) {
for (let i = 0; i < columnAttrObj.rules.length; i++) {
const rule = columnAttrObj.rules[i];
if (rule.pattern && !rule.pattern.test(changedValue)) {
message.error(rule.message || '请按正确格式填写');
resetEditStatus();
return;
}
}
}
const value = setFormat(editConfig, columnConfig, changedValue, optionValue); const value = setFormat(editConfig, columnConfig, changedValue, optionValue);
emitChangeCellData(value, optionValue, reset); emitChangeCellData(value, optionValue, reset);
}} }}
......
...@@ -125,7 +125,6 @@ class FormWrap extends Component { ...@@ -125,7 +125,6 @@ class FormWrap extends Component {
value, value,
renderEditForm, renderEditForm,
readOnlyFlag, readOnlyFlag,
rules = [],
validateFirst = true, validateFirst = true,
validateTrigger = 'onChange', validateTrigger = 'onChange',
dynamicCellConfigDTO, dynamicCellConfigDTO,
...@@ -196,7 +195,7 @@ class FormWrap extends Component { ...@@ -196,7 +195,7 @@ class FormWrap extends Component {
rules: [ rules: [
{ required: !!item.requiredFlag, message: '必填项不能为空' }, { required: !!item.requiredFlag, message: '必填项不能为空' },
{ validator: this.validateRequired.bind(this, item) }, { validator: this.validateRequired.bind(this, item) },
...rules, ...(item.columnAttrObj.rules || []),
], ],
initialValue: getFormat(detailConfig, item, value), initialValue: getFormat(detailConfig, item, value),
})( })(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment