From 90b122b177acf0393ef74219f98eca198bc1b6fe Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Thu, 18 Dec 2025 15:15:15 +0800 Subject: [PATCH] 下拉离开事件 --- src/components/Common/CommonComponent/index.js | 59 +++++++++++++++++++++++++++++++++++++---------------------- src/components/Common/CommonHooks/useCommonBase.js | 364 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ src/components/Common/CommonListTreeEvent.js | 2 ++ src/components/Common/CommonSubBillEvent.js | 1 + src/components/Common/CommonViewTable/index.js | 3 ++- src/mes/common/commonModelComponent/index.js | 1 - 6 files changed, 400 insertions(+), 30 deletions(-) diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index a7a3fa5..ab19884 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -300,7 +300,9 @@ export default class CommonComponent extends Component { } /* 若下拉配置了movesql 则离开时 调用下拉sql数据 */ if (this.props.showConfig && (this.props.showConfig.sDropDownType === 'movesql' || commonUtils.isNotEmptyObject(this.props.showConfig.sButtonParam))) { - this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig); + this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig); + console.log(this.props, 'onDropDownBlur'); + } this.onCheckFields(500); @@ -334,7 +336,7 @@ export default class CommonComponent extends Component { const { sActiveKey = '' } = item; return sActiveKey.split(',').includes(`${name}.${sName}`); }) - || {}; + || {}; if (!sActiveKey) return; this.lastValue = currentValue; onToolBarBtnClick({ key: sControlName }); @@ -733,11 +735,24 @@ export default class CommonComponent extends Component { /* 返回值 */ return obj; }; - + getLocalizedString = (jsonStr, language) => { + try { + const data = JSON.parse(jsonStr); + return data[language] || ""; + } catch (e) { + console.error("Error parsing JSON:", e); + return ""; + } + }; getSelectTableOption = () => { const { selectTableData } = this.state; - const { showConfig } = this.props; - const { sTableTitleSql } = showConfig; + const { showConfig , app} = this.props; + const { userinfo } = app; + let { sTableTitleSql } = showConfig; + /* 根据用户配置语言 设置表格标题 */ + if (commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes("Chinese")) { + sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage); + } const tempColumnArr = sTableTitleSql.split(','); let scrollX = 0; const columns = tempColumnArr.map((item, index) => { @@ -1029,8 +1044,8 @@ export default class CommonComponent extends Component { if (this.isReportInfo && this.props.enabled) { innerInputProps.addonAfter = { - this.props.handleReportInfo?.(this.props.showConfig); - }} + this.props.handleReportInfo?.(this.props.showConfig); + }} />; } return ; @@ -1066,7 +1081,7 @@ export default class CommonComponent extends Component { loading: this.state.buttonLoading, style: { position: 'absolute', - right:3, + right: 3, top: 3, minWidth: "auto" }, @@ -1093,9 +1108,9 @@ export default class CommonComponent extends Component { const sIndexNoClick = (num) => { const oPrint = document.querySelector(`#salveWydm2Print${num}`); - if (oPrint) { - oPrint.click(); - } + if (oPrint) { + oPrint.click(); + } }; return ( @@ -1402,7 +1417,7 @@ export default class CommonComponent extends Component { obj.title = obj.value; } obj.placeholder = this.props.showConfig.placeholder; - + if (this.props.name === "tableS0" && this.props.showConfig.sName === "sStatus") { if (this.state.dataValue === "已提交") { obj.className = "sStatusSubmit"; @@ -1442,7 +1457,7 @@ export default class CommonComponent extends Component { disabled: !this.state.enabled, /* 是否可编辑 */ onChange: (newValue, dateString) => { let dateStringNew = dateString; - if (dateStringNew &&sDateFormat === 'MM-DD') { + if (dateStringNew && sDateFormat === 'MM-DD') { dateStringNew = `${moment().format('YYYY')}-${dateString} 00:00:00`; } else if (dateStringNew && sDateFormat === 'HH:mm') { dateStringNew = `${moment().format('YYYY-MM-DD')} ${dateString}:00`; @@ -2655,7 +2670,7 @@ export default class CommonComponent extends Component { handleViewChoose = () => { this.props.onViewChoose(this.props.name, this.props.showConfig.sName, this.props.record); } - handleMemoShow= () => { + handleMemoShow = () => { this.props.onMemoShow(this.props.name, this.props.showConfig.sName, this.props.record, 0, this.props.showConfig); } @@ -2955,11 +2970,11 @@ export default class CommonComponent extends Component { } /* 获取outformitem控件参数 */ const outFormItemProps = this.getOutFormItemProps(); - + /* 获取fieldDecorator参数 */ const fieldDecoratorProps = this.getFieldDecoratorProps(); /* 通用组件(主表存在getFieldDecorator表单验证,而从表则不需要) */ - const commonAssembly = this.props.bNewForm ? innerInput: ( + const commonAssembly = this.props.bNewForm ? innerInput : ( {viewInfo} {speacilNote} @@ -2967,11 +2982,11 @@ export default class CommonComponent extends Component { {!this.props.bTable && this.getFieldDecorator ? this.getFieldDecorator(this.props.showConfig.sName, fieldDecoratorProps)(innerInput) : innerInput} ); - const { iColValue, showConfig, enabled, bViewTable} = this.props; + const { iColValue, showConfig, enabled, bViewTable } = this.props; const readonlyStyle = showConfig.bReadonly || showConfig.iTag === 1 ? 'readonlyStyle' : ''; const costomStyle = showConfig.costomStyle || ''; - const { bNotEmpty } = showConfig; + const { bNotEmpty } = showConfig; let oPreDot = ''; if (enabled && bViewTable && !location.pathname.includes('login')) { oPreDot = bNotEmpty ? @@ -2987,12 +3002,12 @@ export default class CommonComponent extends Component { this.props.showConfig.sName === 'dReportQty' && this.props.showConfig.sControlName === 'dReportQtyBllb' ) || ( - this.props.showConfig.sName === 'dLittleReportQty' - && this.props.showConfig.sControlName === 'dLittleReportQtyBllb' - )) + this.props.showConfig.sName === 'dLittleReportQty' + && this.props.showConfig.sControlName === 'dLittleReportQtyBllb' + )) ) { oBllb =
- { '质量标识' } + {'质量标识'}