crud-page-react 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -759,8 +759,7 @@ function DynamicForm({ schema, mode, visible, initialValues, onSubmit, onCancel,
759
759
  view: `查看${entityName}`,
760
760
  };
761
761
  const formFields = schema.fields.filter((f) => {
762
- if (mode === 'view')
763
- return f.table !== false && f.table !== undefined;
762
+ // 查看模式和编辑模式都应该遵循form字段配置
764
763
  return f.form !== false && f.form !== undefined;
765
764
  });
766
765
  useEffect(() => {
@@ -1255,8 +1254,10 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1255
1254
  }
1256
1255
  const updateApiConfig = schema.api.update;
1257
1256
  try {
1257
+ // 使用原始记录数据进行模板变量替换(来自detail或列表数据)
1258
+ const templateData = modalState.record || {};
1258
1259
  // 构建 URL,动态替换占位符
1259
- let url = buildUrl(updateApiConfig.url, values);
1260
+ let url = buildUrl(updateApiConfig.url, templateData);
1260
1261
  // 构建请求选项
1261
1262
  const options = {
1262
1263
  method: updateApiConfig.method || 'PUT',
@@ -1265,7 +1266,8 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1265
1266
  // 处理请求体数据
1266
1267
  let requestData = Object.assign({}, values);
1267
1268
  if (updateApiConfig.data) {
1268
- const processedData = processTemplateData(updateApiConfig.data, values);
1269
+ // 使用原始记录数据处理模板变量,而不是表单值
1270
+ const processedData = processTemplateData(updateApiConfig.data, templateData);
1269
1271
  requestData = Object.assign(Object.assign(Object.assign({}, requestData), processedData), { timestamp: new Date().toISOString() });
1270
1272
  }
1271
1273
  options.body = JSON.stringify(requestData);
@@ -1280,7 +1282,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1280
1282
  }
1281
1283
  }
1282
1284
  }, [
1283
- request, modalState.mode, schema.api, fetchList, messageApi,
1285
+ request, modalState.mode, modalState.record, schema.api, fetchList, messageApi,
1284
1286
  ]);
1285
1287
  return (jsx(ConfigProvider, { locale: locale, children: jsxs("div", { style: { padding: 24, background: '#f5f6fa', minHeight: '100vh' }, children: [contextHolder, jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }, children: [jsx(Title, { level: 4, style: { margin: 0 }, children: schema.title }), schema.api.create && (jsx(Button, { type: "primary", icon: jsx(PlusOutlined, {}), onClick: () => setModalState({ open: true, mode: 'create', record: undefined }), children: schema.createButtonLabel || '新增' }))] }), jsx(DynamicFilter, { schema: schema, onSearch: handleSearch, onReset: () => handleSearch({}) }), jsx(DynamicTable, { schema: schema, data: data, loading: loading, pagination: {
1286
1288
  current: page,