Commit 2eca352ab0daefc794c483fc12cf8e1533feed90
1 parent
a0998944
1.'dLockUpFei', 'dMadeUpFei', 'iLaminatingPaper', 'dLabelQty',
'dAdvanceReportQty''dAdvanceLockUpFei', 'dAdvanceMadeUpFei','iAdvanceLaminatingPaper',这几个字段输入后焦点离开改成直接调用存储过程, 不用指令集调用
Showing
3 changed files
with
91 additions
and
2 deletions
src/components/Common/CommonComponent/index.js
| @@ -307,12 +307,33 @@ export default class CommonComponent extends Component { | @@ -307,12 +307,33 @@ export default class CommonComponent extends Component { | ||
| 307 | this.onBlurText(event, 500); | 307 | this.onBlurText(event, 500); |
| 308 | }; | 308 | }; |
| 309 | 309 | ||
| 310 | - onBlurText = (event, timeout = 0) => { | 310 | + onBlurText = async (event, timeout = 0) => { |
| 311 | const currentValue = event?.target?.value; | 311 | const currentValue = event?.target?.value; |
| 312 | if (currentValue == this.lastValue) { | 312 | if (currentValue == this.lastValue) { |
| 313 | this.props.app.globalFun?.onSetMask(false); | 313 | this.props.app.globalFun?.onSetMask(false); |
| 314 | return; | 314 | return; |
| 315 | } | 315 | } |
| 316 | + | ||
| 317 | + const { name, record, onQuickFieldUpdate, showConfig } = this.props; | ||
| 318 | + if (onQuickFieldUpdate && showConfig) { | ||
| 319 | + const { sName } = showConfig; | ||
| 320 | + const changeValue = { [sName]: currentValue }; | ||
| 321 | + console.log('changeValue', changeValue); | ||
| 322 | + console.log('name', name); | ||
| 323 | + console.log('sName', sName); | ||
| 324 | + console.log('record.sId', record.sId); | ||
| 325 | + try { | ||
| 326 | + const quickHandled = await onQuickFieldUpdate(name, sName, changeValue, record.sId, showConfig); | ||
| 327 | + if (quickHandled) { | ||
| 328 | + this.lastValue = currentValue; | ||
| 329 | + this.props.app.globalFun?.onSetMask(false); | ||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + } catch (error) { | ||
| 333 | + console.error('onQuickFieldUpdate error:', error); | ||
| 334 | + } | ||
| 335 | + } | ||
| 336 | + | ||
| 316 | if (this.onExecInstructSet('blur')) { | 337 | if (this.onExecInstructSet('blur')) { |
| 317 | this.lastValue = currentValue; | 338 | this.lastValue = currentValue; |
| 318 | return; | 339 | return; |
src/components/Common/CommonHooks/useCommonBase.js
| @@ -2156,7 +2156,7 @@ const useCommonBase = props => { | @@ -2156,7 +2156,7 @@ const useCommonBase = props => { | ||
| 2156 | }); | 2156 | }); |
| 2157 | return; | 2157 | return; |
| 2158 | } | 2158 | } |
| 2159 | - | 2159 | + |
| 2160 | Modal.confirm({ | 2160 | Modal.confirm({ |
| 2161 | title: "温馨提示:", | 2161 | title: "温馨提示:", |
| 2162 | content: <div>{handleGetMsg(msg)}</div>, | 2162 | content: <div>{handleGetMsg(msg)}</div>, |
| @@ -2425,6 +2425,72 @@ const useCommonBase = props => { | @@ -2425,6 +2425,72 @@ const useCommonBase = props => { | ||
| 2425 | return result; | 2425 | return result; |
| 2426 | }; | 2426 | }; |
| 2427 | 2427 | ||
| 2428 | + // 处理特定字段的快速更新 | ||
| 2429 | + const handleQuickFieldUpdate = async (name, sFieldName, changeValue, sId, tableConfig) => { | ||
| 2430 | + // 定义需要快速处理的字段列表 | ||
| 2431 | + const quickFields = [ | ||
| 2432 | + 'dLockUpFei', 'dMadeUpFei', 'iLaminatingPaper', 'dLabelQty', | ||
| 2433 | + 'dAdvanceReportQty', 'dAdvanceLockUpFei', 'dAdvanceMadeUpFei', 'iAdvanceLaminatingPaper' | ||
| 2434 | + ]; | ||
| 2435 | + | ||
| 2436 | + console.log('处理特定字段的快速更新', sFieldName); | ||
| 2437 | + | ||
| 2438 | + // 检查是否是需要快速处理的字段 | ||
| 2439 | + if (!quickFields.includes(sFieldName)) return false; | ||
| 2440 | + | ||
| 2441 | + // 显示loading状态 | ||
| 2442 | + props.app.globalFun.onSetMask(true); | ||
| 2443 | + | ||
| 2444 | + try { | ||
| 2445 | + // 获取表格配置和数据 | ||
| 2446 | + const { [`${name}Data`]: tableData } = state; | ||
| 2447 | + const iIndex = tableData.findIndex(item => item.sId === sId); | ||
| 2448 | + if (iIndex === -1) return false; | ||
| 2449 | + | ||
| 2450 | + const record = tableData[iIndex]; | ||
| 2451 | + | ||
| 2452 | + // 从 tableConfig 中提取 procedure 配置 | ||
| 2453 | + let procedureConfig = null; | ||
| 2454 | + if (tableConfig && tableConfig.sOnChangeInstruct) { | ||
| 2455 | + try { | ||
| 2456 | + const onChangeInstruct = commonUtils.convertStrToObj(tableConfig.sOnChangeInstruct, {}); | ||
| 2457 | + if (onChangeInstruct.blur && Array.isArray(onChangeInstruct.blur)) { | ||
| 2458 | + // 查找 procedure 操作 | ||
| 2459 | + const procedureOp = onChangeInstruct.blur.find(op => op.opr === 'procedure'); | ||
| 2460 | + if (procedureOp && procedureOp.config) { | ||
| 2461 | + procedureConfig = procedureOp.config; | ||
| 2462 | + } | ||
| 2463 | + } | ||
| 2464 | + } catch (error) { | ||
| 2465 | + console.error('解析 sOnChangeInstruct 失败:', error); | ||
| 2466 | + } | ||
| 2467 | + } | ||
| 2468 | + | ||
| 2469 | + // 如果找到 procedure 配置,调用存储过程 | ||
| 2470 | + if (procedureConfig) { | ||
| 2471 | + await handleProcedureCall({ | ||
| 2472 | + btnConfig: { | ||
| 2473 | + sButtonParam: JSON.stringify(procedureConfig) | ||
| 2474 | + }, | ||
| 2475 | + tableData: [record], | ||
| 2476 | + sValue: changeValue | ||
| 2477 | + }); | ||
| 2478 | + | ||
| 2479 | + // 刷新表格 | ||
| 2480 | + handleSaveState({ refreshTableList: [name] }); | ||
| 2481 | + } | ||
| 2482 | + | ||
| 2483 | + return true; | ||
| 2484 | + } catch (error) { | ||
| 2485 | + console.error('快速字段更新失败:', error); | ||
| 2486 | + message.error('处理失败,请重试'); | ||
| 2487 | + return false; | ||
| 2488 | + } finally { | ||
| 2489 | + // 关闭loading状态 | ||
| 2490 | + props.app.globalFun.onSetMask(false); | ||
| 2491 | + } | ||
| 2492 | + }; | ||
| 2493 | + | ||
| 2428 | // 执行指令集 | 2494 | // 执行指令集 |
| 2429 | const handleExecInstructSet = params => { | 2495 | const handleExecInstructSet = params => { |
| 2430 | const { | 2496 | const { |
| @@ -2690,6 +2756,7 @@ const useCommonBase = props => { | @@ -2690,6 +2756,7 @@ const useCommonBase = props => { | ||
| 2690 | handleSqlDropDownNewRecord, | 2756 | handleSqlDropDownNewRecord, |
| 2691 | onChange: handleMasterChange, // 主表数据变化 | 2757 | onChange: handleMasterChange, // 主表数据变化 |
| 2692 | onDataChange: handleTableChange, // 表格数据变化 | 2758 | onDataChange: handleTableChange, // 表格数据变化 |
| 2759 | + onQuickFieldUpdate: handleQuickFieldUpdate, // 快速字段更新 | ||
| 2693 | onGetDataSet: handleGetDataSet, | 2760 | onGetDataSet: handleGetDataSet, |
| 2694 | onGetTreeDataSet: handleGetTreeDataSet, // 获取树型数据 | 2761 | onGetTreeDataSet: handleGetTreeDataSet, // 获取树型数据 |
| 2695 | onSaveState: handleSaveState, | 2762 | onSaveState: handleSaveState, |
src/components/Common/CommonViewTable/index.js
| @@ -506,6 +506,7 @@ class CommonViewTableRc extends Component { | @@ -506,6 +506,7 @@ class CommonViewTableRc extends Component { | ||
| 506 | .handleSqlDropDownNewRecord, | 506 | .handleSqlDropDownNewRecord, |
| 507 | getFloatNum: this.props.getFloatNum, | 507 | getFloatNum: this.props.getFloatNum, |
| 508 | onChange: this.props.onDataChange, | 508 | onChange: this.props.onDataChange, |
| 509 | + onQuickFieldUpdate: this.props.onQuickFieldUpdate, | ||
| 509 | showConfig: child, | 510 | showConfig: child, |
| 510 | slaveConfig: this.props[`${tableName}Config`], | 511 | slaveConfig: this.props[`${tableName}Config`], |
| 511 | formItemLayout, | 512 | formItemLayout, |