crud-page-react 0.3.1 → 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
@@ -1254,8 +1254,10 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1254
1254
  }
1255
1255
  const updateApiConfig = schema.api.update;
1256
1256
  try {
1257
+ // 使用原始记录数据进行模板变量替换(来自detail或列表数据)
1258
+ const templateData = modalState.record || {};
1257
1259
  // 构建 URL,动态替换占位符
1258
- let url = buildUrl(updateApiConfig.url, values);
1260
+ let url = buildUrl(updateApiConfig.url, templateData);
1259
1261
  // 构建请求选项
1260
1262
  const options = {
1261
1263
  method: updateApiConfig.method || 'PUT',
@@ -1264,7 +1266,8 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1264
1266
  // 处理请求体数据
1265
1267
  let requestData = Object.assign({}, values);
1266
1268
  if (updateApiConfig.data) {
1267
- const processedData = processTemplateData(updateApiConfig.data, values);
1269
+ // 使用原始记录数据处理模板变量,而不是表单值
1270
+ const processedData = processTemplateData(updateApiConfig.data, templateData);
1268
1271
  requestData = Object.assign(Object.assign(Object.assign({}, requestData), processedData), { timestamp: new Date().toISOString() });
1269
1272
  }
1270
1273
  options.body = JSON.stringify(requestData);
@@ -1279,7 +1282,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1279
1282
  }
1280
1283
  }
1281
1284
  }, [
1282
- request, modalState.mode, schema.api, fetchList, messageApi,
1285
+ request, modalState.mode, modalState.record, schema.api, fetchList, messageApi,
1283
1286
  ]);
1284
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: {
1285
1288
  current: page,