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.js CHANGED
@@ -1255,8 +1255,10 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1255
1255
  }
1256
1256
  const updateApiConfig = schema.api.update;
1257
1257
  try {
1258
+ // 使用原始记录数据进行模板变量替换(来自detail或列表数据)
1259
+ const templateData = modalState.record || {};
1258
1260
  // 构建 URL,动态替换占位符
1259
- let url = buildUrl(updateApiConfig.url, values);
1261
+ let url = buildUrl(updateApiConfig.url, templateData);
1260
1262
  // 构建请求选项
1261
1263
  const options = {
1262
1264
  method: updateApiConfig.method || 'PUT',
@@ -1265,7 +1267,8 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1265
1267
  // 处理请求体数据
1266
1268
  let requestData = Object.assign({}, values);
1267
1269
  if (updateApiConfig.data) {
1268
- const processedData = processTemplateData(updateApiConfig.data, values);
1270
+ // 使用原始记录数据处理模板变量,而不是表单值
1271
+ const processedData = processTemplateData(updateApiConfig.data, templateData);
1269
1272
  requestData = Object.assign(Object.assign(Object.assign({}, requestData), processedData), { timestamp: new Date().toISOString() });
1270
1273
  }
1271
1274
  options.body = JSON.stringify(requestData);
@@ -1280,7 +1283,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, loca
1280
1283
  }
1281
1284
  }
1282
1285
  }, [
1283
- request, modalState.mode, schema.api, fetchList, messageApi,
1286
+ request, modalState.mode, modalState.record, schema.api, fetchList, messageApi,
1284
1287
  ]);
1285
1288
  return (jsxRuntime.jsx(antd.ConfigProvider, { locale: locale, children: jsxRuntime.jsxs("div", { style: { padding: 24, background: '#f5f6fa', minHeight: '100vh' }, children: [contextHolder, jsxRuntime.jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }, children: [jsxRuntime.jsx(Title, { level: 4, style: { margin: 0 }, children: schema.title }), schema.api.create && (jsxRuntime.jsx(antd.Button, { type: "primary", icon: jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => setModalState({ open: true, mode: 'create', record: undefined }), children: schema.createButtonLabel || '新增' }))] }), jsxRuntime.jsx(DynamicFilter, { schema: schema, onSearch: handleSearch, onReset: () => handleSearch({}) }), jsxRuntime.jsx(DynamicTable, { schema: schema, data: data, loading: loading, pagination: {
1286
1289
  current: page,