Commit 90b122b177acf0393ef74219f98eca198bc1b6fe
1 parent
8a6c3d1a
下拉离开事件
Showing
6 changed files
with
400 additions
and
30 deletions
src/components/Common/CommonComponent/index.js
| ... | ... | @@ -300,7 +300,9 @@ export default class CommonComponent extends Component { |
| 300 | 300 | } |
| 301 | 301 | /* 若下拉配置了movesql 则离开时 调用下拉sql数据 */ |
| 302 | 302 | if (this.props.showConfig && (this.props.showConfig.sDropDownType === 'movesql' || commonUtils.isNotEmptyObject(this.props.showConfig.sButtonParam))) { |
| 303 | - this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig); | |
| 303 | + this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig); | |
| 304 | + console.log(this.props, 'onDropDownBlur'); | |
| 305 | + | |
| 304 | 306 | } |
| 305 | 307 | |
| 306 | 308 | this.onCheckFields(500); |
| ... | ... | @@ -334,7 +336,7 @@ export default class CommonComponent extends Component { |
| 334 | 336 | const { sActiveKey = '' } = item; |
| 335 | 337 | return sActiveKey.split(',').includes(`${name}.${sName}`); |
| 336 | 338 | }) |
| 337 | - || {}; | |
| 339 | + || {}; | |
| 338 | 340 | if (!sActiveKey) return; |
| 339 | 341 | this.lastValue = currentValue; |
| 340 | 342 | onToolBarBtnClick({ key: sControlName }); |
| ... | ... | @@ -733,11 +735,24 @@ export default class CommonComponent extends Component { |
| 733 | 735 | /* 返回值 */ |
| 734 | 736 | return obj; |
| 735 | 737 | }; |
| 736 | - | |
| 738 | + getLocalizedString = (jsonStr, language) => { | |
| 739 | + try { | |
| 740 | + const data = JSON.parse(jsonStr); | |
| 741 | + return data[language] || ""; | |
| 742 | + } catch (e) { | |
| 743 | + console.error("Error parsing JSON:", e); | |
| 744 | + return ""; | |
| 745 | + } | |
| 746 | + }; | |
| 737 | 747 | getSelectTableOption = () => { |
| 738 | 748 | const { selectTableData } = this.state; |
| 739 | - const { showConfig } = this.props; | |
| 740 | - const { sTableTitleSql } = showConfig; | |
| 749 | + const { showConfig , app} = this.props; | |
| 750 | + const { userinfo } = app; | |
| 751 | + let { sTableTitleSql } = showConfig; | |
| 752 | + /* 根据用户配置语言 设置表格标题 */ | |
| 753 | + if (commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes("Chinese")) { | |
| 754 | + sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage); | |
| 755 | + } | |
| 741 | 756 | const tempColumnArr = sTableTitleSql.split(','); |
| 742 | 757 | let scrollX = 0; |
| 743 | 758 | const columns = tempColumnArr.map((item, index) => { |
| ... | ... | @@ -1029,8 +1044,8 @@ export default class CommonComponent extends Component { |
| 1029 | 1044 | if (this.isReportInfo && this.props.enabled) { |
| 1030 | 1045 | innerInputProps.addonAfter = <PlusOutlined |
| 1031 | 1046 | onClick={() => { |
| 1032 | - this.props.handleReportInfo?.(this.props.showConfig); | |
| 1033 | - }} | |
| 1047 | + this.props.handleReportInfo?.(this.props.showConfig); | |
| 1048 | + }} | |
| 1034 | 1049 | />; |
| 1035 | 1050 | } |
| 1036 | 1051 | return <InputA {...innerInputProps} />; |
| ... | ... | @@ -1066,7 +1081,7 @@ export default class CommonComponent extends Component { |
| 1066 | 1081 | loading: this.state.buttonLoading, |
| 1067 | 1082 | style: { |
| 1068 | 1083 | position: 'absolute', |
| 1069 | - right:3, | |
| 1084 | + right: 3, | |
| 1070 | 1085 | top: 3, |
| 1071 | 1086 | minWidth: "auto" |
| 1072 | 1087 | }, |
| ... | ... | @@ -1093,9 +1108,9 @@ export default class CommonComponent extends Component { |
| 1093 | 1108 | |
| 1094 | 1109 | const sIndexNoClick = (num) => { |
| 1095 | 1110 | const oPrint = document.querySelector(`#salveWydm2Print${num}`); |
| 1096 | - if (oPrint) { | |
| 1097 | - oPrint.click(); | |
| 1098 | - } | |
| 1111 | + if (oPrint) { | |
| 1112 | + oPrint.click(); | |
| 1113 | + } | |
| 1099 | 1114 | }; |
| 1100 | 1115 | |
| 1101 | 1116 | return ( |
| ... | ... | @@ -1402,7 +1417,7 @@ export default class CommonComponent extends Component { |
| 1402 | 1417 | obj.title = obj.value; |
| 1403 | 1418 | } |
| 1404 | 1419 | obj.placeholder = this.props.showConfig.placeholder; |
| 1405 | - | |
| 1420 | + | |
| 1406 | 1421 | if (this.props.name === "tableS0" && this.props.showConfig.sName === "sStatus") { |
| 1407 | 1422 | if (this.state.dataValue === "已提交") { |
| 1408 | 1423 | obj.className = "sStatusSubmit"; |
| ... | ... | @@ -1442,7 +1457,7 @@ export default class CommonComponent extends Component { |
| 1442 | 1457 | disabled: !this.state.enabled, /* 是否可编辑 */ |
| 1443 | 1458 | onChange: (newValue, dateString) => { |
| 1444 | 1459 | let dateStringNew = dateString; |
| 1445 | - if (dateStringNew &&sDateFormat === 'MM-DD') { | |
| 1460 | + if (dateStringNew && sDateFormat === 'MM-DD') { | |
| 1446 | 1461 | dateStringNew = `${moment().format('YYYY')}-${dateString} 00:00:00`; |
| 1447 | 1462 | } else if (dateStringNew && sDateFormat === 'HH:mm') { |
| 1448 | 1463 | dateStringNew = `${moment().format('YYYY-MM-DD')} ${dateString}:00`; |
| ... | ... | @@ -2655,7 +2670,7 @@ export default class CommonComponent extends Component { |
| 2655 | 2670 | handleViewChoose = () => { |
| 2656 | 2671 | this.props.onViewChoose(this.props.name, this.props.showConfig.sName, this.props.record); |
| 2657 | 2672 | } |
| 2658 | - handleMemoShow= () => { | |
| 2673 | + handleMemoShow = () => { | |
| 2659 | 2674 | this.props.onMemoShow(this.props.name, this.props.showConfig.sName, this.props.record, 0, this.props.showConfig); |
| 2660 | 2675 | } |
| 2661 | 2676 | |
| ... | ... | @@ -2955,11 +2970,11 @@ export default class CommonComponent extends Component { |
| 2955 | 2970 | } |
| 2956 | 2971 | /* 获取outformitem控件参数 */ |
| 2957 | 2972 | const outFormItemProps = this.getOutFormItemProps(); |
| 2958 | - | |
| 2973 | + | |
| 2959 | 2974 | /* 获取fieldDecorator参数 */ |
| 2960 | 2975 | const fieldDecoratorProps = this.getFieldDecoratorProps(); |
| 2961 | 2976 | /* 通用组件(主表存在getFieldDecorator表单验证,而从表则不需要) */ |
| 2962 | - const commonAssembly = this.props.bNewForm ? innerInput: ( | |
| 2977 | + const commonAssembly = this.props.bNewForm ? innerInput : ( | |
| 2963 | 2978 | <FormItem {...outFormItemProps}> |
| 2964 | 2979 | {viewInfo} |
| 2965 | 2980 | {speacilNote} |
| ... | ... | @@ -2967,11 +2982,11 @@ export default class CommonComponent extends Component { |
| 2967 | 2982 | {!this.props.bTable && this.getFieldDecorator ? this.getFieldDecorator(this.props.showConfig.sName, fieldDecoratorProps)(innerInput) : innerInput} |
| 2968 | 2983 | </FormItem> |
| 2969 | 2984 | ); |
| 2970 | - const { iColValue, showConfig, enabled, bViewTable} = this.props; | |
| 2985 | + const { iColValue, showConfig, enabled, bViewTable } = this.props; | |
| 2971 | 2986 | const readonlyStyle = showConfig.bReadonly || showConfig.iTag === 1 ? 'readonlyStyle' : ''; |
| 2972 | 2987 | const costomStyle = showConfig.costomStyle || ''; |
| 2973 | 2988 | |
| 2974 | - const { bNotEmpty } = showConfig; | |
| 2989 | + const { bNotEmpty } = showConfig; | |
| 2975 | 2990 | let oPreDot = ''; |
| 2976 | 2991 | if (enabled && bViewTable && !location.pathname.includes('login')) { |
| 2977 | 2992 | oPreDot = bNotEmpty ? |
| ... | ... | @@ -2987,12 +3002,12 @@ export default class CommonComponent extends Component { |
| 2987 | 3002 | this.props.showConfig.sName === 'dReportQty' |
| 2988 | 3003 | && this.props.showConfig.sControlName === 'dReportQtyBllb' |
| 2989 | 3004 | ) || ( |
| 2990 | - this.props.showConfig.sName === 'dLittleReportQty' | |
| 2991 | - && this.props.showConfig.sControlName === 'dLittleReportQtyBllb' | |
| 2992 | - )) | |
| 3005 | + this.props.showConfig.sName === 'dLittleReportQty' | |
| 3006 | + && this.props.showConfig.sControlName === 'dLittleReportQtyBllb' | |
| 3007 | + )) | |
| 2993 | 3008 | ) { |
| 2994 | 3009 | oBllb = <div className='productionExecBllb'> |
| 2995 | - <span>{ '质量标识' } </span> | |
| 3010 | + <span>{'质量标识'} </span> | |
| 2996 | 3011 | <Button |
| 2997 | 3012 | type="link" |
| 2998 | 3013 | size="large" | ... | ... |
src/components/Common/CommonHooks/useCommonBase.js
| ... | ... | @@ -41,6 +41,8 @@ const useCommonBase = props => { |
| 41 | 41 | const [state, dispatch] = useReducer(reducer, getInitialState(props)); |
| 42 | 42 | const tempRef = useRef({}); |
| 43 | 43 | let mounted = true |
| 44 | + console.log(props, 'useCommonBase'); | |
| 45 | + | |
| 44 | 46 | const setTempRef = (params, bRewrite) => { |
| 45 | 47 | if (bRewrite) { |
| 46 | 48 | tempRef.current = params; |
| ... | ... | @@ -1832,7 +1834,7 @@ const useCommonBase = props => { |
| 1832 | 1834 | }; |
| 1833 | 1835 | |
| 1834 | 1836 | /** 表格数据更改 */ |
| 1835 | - const handleTableChange = ( | |
| 1837 | + const handleTableChange = async ( | |
| 1836 | 1838 | name, |
| 1837 | 1839 | sFieldName, |
| 1838 | 1840 | changeValue, |
| ... | ... | @@ -1856,7 +1858,6 @@ const useCommonBase = props => { |
| 1856 | 1858 | [`${name}Config`]: tableConfig, |
| 1857 | 1859 | sModelsId |
| 1858 | 1860 | } = state; |
| 1859 | - | |
| 1860 | 1861 | const iIndex = tableData.findIndex(item => item.sId === sId); |
| 1861 | 1862 | let { handleType } = tableData[iIndex]; |
| 1862 | 1863 | handleType = commonUtils.isEmpty(handleType) ? "update" : handleType; |
| ... | ... | @@ -1907,11 +1908,18 @@ const useCommonBase = props => { |
| 1907 | 1908 | changeValue = { ...tableDataAfter }; |
| 1908 | 1909 | } |
| 1909 | 1910 | } |
| 1911 | + const models = name === 'materials' ? 'Materials' : '' | |
| 1912 | + let tableDataRow = { ...tableData[iIndex], ...changeValue, handleType } | |
| 1913 | + const { masterData } = state | |
| 1914 | + const { app } = props | |
| 1915 | + const { token } = app || {} | |
| 1916 | + tableDataRow = await handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models); | |
| 1917 | + console.log(tableDataRow, 'tableDataRow'); | |
| 1910 | 1918 | if (isWait) { |
| 1911 | - return { ...tableData[iIndex], ...changeValue, handleType }; | |
| 1919 | + return tableDataRow; | |
| 1912 | 1920 | } else { |
| 1913 | 1921 | const rowDataOld = JSON.parse(JSON.stringify(tableData[iIndex])); |
| 1914 | - tableData[iIndex] = { ...tableData[iIndex], ...changeValue, handleType }; | |
| 1922 | + tableData[iIndex] = tableDataRow; | |
| 1915 | 1923 | handleSaveState( |
| 1916 | 1924 | { [`${name}Data`]: tableData, sUseInfo: "" }, |
| 1917 | 1925 | nextProps => { |
| ... | ... | @@ -1930,7 +1938,112 @@ const useCommonBase = props => { |
| 1930 | 1938 | ); |
| 1931 | 1939 | } |
| 1932 | 1940 | }; |
| 1933 | - | |
| 1941 | + const handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => { | |
| 1942 | + const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow; | |
| 1943 | + const sFormulaIdType = tableDataRow.bInverse ? 'sReComputeId' : 'sComputeId'; /* 正算、反算类型 */ | |
| 1944 | + if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle' || sFieldName === 'dProductQty') { | |
| 1945 | + if (sFieldName === 'dReelAuxiliaryQty') { | |
| 1946 | + if (tableDataRow.sMaterialsUnit === '吨' && tableDataRow.bReel && tableDataRow.dGramWeight > 0) { | |
| 1947 | + tableDataRow = commonBusiness.getMaterialsQty(app, { ...tableDataRow, sMaterialsStyle: tableDataRow.sReelMaterialsStyle }, 'dReelAuxiliaryQty', 'dMaterialsQty'); | |
| 1948 | + tableDataRow.dAuxiliaryQty = tableDataRow.dMaterialsQty; | |
| 1949 | + tableDataRow.sMaterialsStyle = tableDataRow.sMaterialsStyle !== undefined && tableDataRow.sMaterialsStyle.split('*').length > 1 ? tableDataRow.sMaterialsStyle.split('*')[0] : tableDataRow.sMaterialsStyle; | |
| 1950 | + tableDataRow.sAuxiliaryUnit = tableDataRow.sMaterialsUnit; | |
| 1951 | + } else if (tableDataRow.sMaterialsUnit.toUpper() === 'M2' && tableDataRow.bReel) { | |
| 1952 | + tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dReelAuxiliaryQty', 'dMaterialsQty'); | |
| 1953 | + tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty; | |
| 1954 | + } else { | |
| 1955 | + tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty; | |
| 1956 | + } | |
| 1957 | + } | |
| 1958 | + if (commonUtils.isEmpty(sComputeId) && sFieldName !== 'dConversionQty') { | |
| 1959 | + if (sFieldName === 'dProductQty') { | |
| 1960 | + tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dProductQty', 'dMaterialsQty'); | |
| 1961 | + } else if (app.currentPane.sModelsType && app.currentPane.sModelsType.includes('outside/')) { | |
| 1962 | + tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dAuxiliaryQty', 'dMaterialsQty'); | |
| 1963 | + } else { | |
| 1964 | + tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({ | |
| 1965 | + token, sModelsId, masterData, tableDataRow, sComputeId, sFormulaIdType, | |
| 1966 | + }); | |
| 1967 | + } | |
| 1968 | + } else if (!commonUtils.isEmpty(sComputeId)) { | |
| 1969 | + tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({ | |
| 1970 | + token, sModelsId, masterData, tableDataRow, sComputeId, | |
| 1971 | + }); | |
| 1972 | + } | |
| 1973 | + if (sFieldName !== 'dConversionQty' && !commonUtils.isEmpty(sConversionComputeId)) { | |
| 1974 | + tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({ | |
| 1975 | + token, sModelsId, masterData, tableDataRow, sComputeId: sConversionComputeId, | |
| 1976 | + }); | |
| 1977 | + } | |
| 1978 | + } else if (sFieldName === 'dMaterialsQty') { | |
| 1979 | + const { sReComputeId } = tableDataRow; | |
| 1980 | + if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) { | |
| 1981 | + if (app.currentPane.sModelsType && app.currentPane.sModelsType.includes('outside/')) { | |
| 1982 | + tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryQty'); | |
| 1983 | + } else { | |
| 1984 | + tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({ | |
| 1985 | + token, sModelsId, masterData, tableDataRow, sReComputeId, sFormulaIdType, | |
| 1986 | + }); | |
| 1987 | + } | |
| 1988 | + } else if (tableDataRow.bInverse) { | |
| 1989 | + tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({ | |
| 1990 | + token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId, | |
| 1991 | + }); | |
| 1992 | + if (commonUtils.isNotEmptyArr(tableDataRow.dAuxiliaryQty) && tableDataRow.dAuxiliaryQty !== 0) { | |
| 1993 | + tableDataRow.dProductQty = tableDataRow.dAuxiliaryQty; | |
| 1994 | + } | |
| 1995 | + } | |
| 1996 | + if (!commonUtils.isEmpty(sReConversionComputeId)) { | |
| 1997 | + tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({ | |
| 1998 | + token, sModelsId, masterData, tableDataRow, sComputeId: sReConversionComputeId, | |
| 1999 | + }); | |
| 2000 | + } | |
| 2001 | + } else if (sFieldName === 'dAuxiliaryLossQty') { | |
| 2002 | + const tableDataRowNew = { ...tableDataRow, dAuxiliaryQty: tableDataRow.dAuxiliaryLossQty }; | |
| 2003 | + if (commonUtils.isEmpty(sComputeId)) { | |
| 2004 | + // tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName, 'dLossQty'); | |
| 2005 | + tableDataRow.dLossQty = await commonBusiness.getFormulaValue({ | |
| 2006 | + token, sModelsId, masterData, tableDataRow: tableDataRowNew, sComputeId, sFormulaIdType, | |
| 2007 | + }); | |
| 2008 | + } else { | |
| 2009 | + tableDataRow.dLossQty = await commonBusiness.getFormulaValue({ | |
| 2010 | + token, sModelsId, masterData, tableDataRow: tableDataRowNew, sComputeId, | |
| 2011 | + }); | |
| 2012 | + } | |
| 2013 | + if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) { | |
| 2014 | + tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty; | |
| 2015 | + tableDataRow.dMaterialsQty = commonUtils.convertFixNum(tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty, 6); | |
| 2016 | + } | |
| 2017 | + } else if (sFieldName === 'dLossQty') { | |
| 2018 | + const { sReComputeId } = tableDataRow; | |
| 2019 | + const tableDataRowNew = { ...tableDataRow, dMaterialsQty: tableDataRow.dLossQty }; | |
| 2020 | + if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) { | |
| 2021 | + // tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryLossQty'); | |
| 2022 | + tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({ | |
| 2023 | + token, sModelsId, masterData, tableDataRow: tableDataRowNew, sReComputeId, sFormulaIdType, | |
| 2024 | + }); | |
| 2025 | + } else { | |
| 2026 | + tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({ | |
| 2027 | + token, sModelsId, masterData, tableDataRow: tableDataRowNew, sComputeId: sReComputeId, | |
| 2028 | + }); | |
| 2029 | + } | |
| 2030 | + if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) { | |
| 2031 | + tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty; | |
| 2032 | + tableDataRow.dMaterialsQty = tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty; | |
| 2033 | + } | |
| 2034 | + } else if (sFieldName === 'sProcessId' || sFieldName === 'sProcessNo' || sFieldName === 'sProcessName') { | |
| 2035 | + const sProcessId = changeValue.sProcessId; | |
| 2036 | + const url = `${commonConfig.server_host}process/outsideprocess?sModelsId=${sModelsId}&sProcessId=${sProcessId}`; | |
| 2037 | + const dataReturn = (await commonServices.getService(token, url)).data; | |
| 2038 | + if (dataReturn.code === 1) { | |
| 2039 | + if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) { | |
| 2040 | + tableDataRow.dMaterialsPrice = dataReturn.dataset.rows[0].dMaterialsPrice; | |
| 2041 | + } | |
| 2042 | + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dMaterialsPrice', masterData, tableDataRow); | |
| 2043 | + } | |
| 2044 | + } | |
| 2045 | + return tableDataRow; | |
| 2046 | + } | |
| 1934 | 2047 | const handleFilterDropDownData = (dropDownData, showConfig, name, record) => { |
| 1935 | 2048 | if (!commonUtils.isEmptyArr(dropDownData)) { |
| 1936 | 2049 | const conditon = showConfig.sSqlCondition.split(","); |
| ... | ... | @@ -2358,7 +2471,245 @@ const useCommonBase = props => { |
| 2358 | 2471 | }); |
| 2359 | 2472 | } |
| 2360 | 2473 | }; |
| 2474 | + /* 下拉多选离开事件 */ | |
| 2475 | + const handleTableBlur = async (name, sFileName, record, tableConfig, other) => { | |
| 2476 | + const { sModelsId, app } = props; | |
| 2477 | + const { controlData, slaveConfig, [`${name}Data`]: tableData, [`${name}Config`]: tempConfig } = state; | |
| 2478 | + let { slaveData: slaveDataOld, masterData, slaveDelData, } = state; | |
| 2479 | + const addState = {}; | |
| 2480 | + if (commonUtils.isEmptyArr(slaveDelData)) { | |
| 2481 | + slaveDelData = []; | |
| 2482 | + } | |
| 2483 | + if (sFileName === 'sPartsNameNew') { | |
| 2484 | + if (commonUtils.isNotEmptyArr(controlData)) { | |
| 2485 | + /* 离开时 把sPartsNameNewId数据挂载到sControlParentId */ | |
| 2486 | + let iIndex = controlData.findIndex(item => item.sId === record.sId); | |
| 2487 | + if (iIndex === -1) { | |
| 2488 | + if (record.sId && record.sId.split('-').length > 1) { | |
| 2489 | + iIndex = controlData.findIndex(item => item.sId === record.sId.split('-')[0]); | |
| 2490 | + } | |
| 2491 | + } | |
| 2492 | + if (iIndex > -1) { | |
| 2493 | + addState.sControlParentId = controlData[iIndex].sPartsNameNewId; | |
| 2494 | + if (commonUtils.isNotEmptyObject(controlData[iIndex].sPartsNameNewId)) { | |
| 2495 | + controlData[iIndex] = { ...controlData[iIndex], ...addState }; | |
| 2496 | + props.onSaveState({ controlData: controlData }); | |
| 2497 | + } | |
| 2498 | + } | |
| 2499 | + } | |
| 2500 | + } else if (tableConfig.sDropDownType === 'movesql') { /* 通用字段离开调下拉事件 */ | |
| 2501 | + let slaveRow = record; | |
| 2502 | + const sqlDropDownData = await getSqlDropDownData(sModelsId, name, tableConfig, slaveRow); | |
| 2503 | + const dDropDownData = sqlDropDownData.dropDownData; | |
| 2504 | + const iIndex = tableData.findIndex(item => item.sId === record.sId); | |
| 2505 | + if (commonUtils.isNotEmptyArr(dDropDownData) && iIndex > -1) { | |
| 2506 | + slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(tableConfig.sAssignField, dDropDownData[0]) }; // 取赋值字段 | |
| 2507 | + slaveRow.handleType = commonUtils.isEmpty(slaveRow.handleType) ? 'update' : slaveRow.handleType; | |
| 2508 | + const sButtonParam = tableConfig.sButtonParam; /* 设置多级联动 */ | |
| 2509 | + if (commonUtils.isNotEmptyObject(sButtonParam)) { | |
| 2510 | + let sLinkFieldName = 'dMaterialsPrice'; | |
| 2511 | + if (commonUtils.isJSON(sButtonParam)) { /* 按钮条件 */ | |
| 2512 | + const linkObj = JSON.parse(sButtonParam); /* 联动配置 */ | |
| 2513 | + let models = 'Materials'; | |
| 2514 | + if (linkObj.linkMaterials) { | |
| 2515 | + sLinkFieldName = linkObj.linkMaterials; | |
| 2516 | + models = 'Materials'; | |
| 2517 | + } else if (linkObj.linkProduct) { | |
| 2518 | + sLinkFieldName = linkObj.linkProduct; | |
| 2519 | + models = 'Product'; | |
| 2520 | + } | |
| 2521 | + slaveRow = commonBusiness.getCalculateAllMoney(app, models, sLinkFieldName, masterData, slaveRow); | |
| 2522 | + } | |
| 2523 | + } | |
| 2361 | 2524 | |
| 2525 | + tableData[iIndex] = { ...tableData[iIndex], ...slaveRow }; | |
| 2526 | + handleSaveState({ ...addState }); | |
| 2527 | + } | |
| 2528 | + } else if (commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyObject(tableConfig.sButtonParam)) { | |
| 2529 | + let slaveNewData = []; | |
| 2530 | + const allConfig = { slaveConfig }; | |
| 2531 | + // console.log('sTmpInfoConfigArr', sTmpInfoConfigArr); | |
| 2532 | + const sTmpInfoConfig = tableConfig; | |
| 2533 | + const sButtonParam = tableConfig.sButtonParam; | |
| 2534 | + const btn = commonUtils.isNotEmptyObject(sButtonParam) && commonUtils.isJSON(sButtonParam) ? JSON.parse(sButtonParam) : {};; | |
| 2535 | + const sProName = commonUtils.isNotEmptyObject(btn) ? btn.sproName : ''; | |
| 2536 | + const sTmpInfoBySqlBtnName = commonUtils.isNotEmptyObject(btn) ? btn.sControlName : ''; | |
| 2537 | + const sActiveKey = sTmpInfoConfig.sActiveKey; | |
| 2538 | + if (commonUtils.isNotEmptyObject(sTmpInfoConfig)) { | |
| 2539 | + if (commonUtils.isEmptyObject(sTmpInfoBySqlBtnName)) { | |
| 2540 | + const newCopyTo = {}; | |
| 2541 | + newCopyTo.master = masterData; | |
| 2542 | + // newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0]; | |
| 2543 | + // const sRowData = copyTo.slaveData; | |
| 2544 | + const sRowData = masterData; | |
| 2545 | + const value = { sProName, sProInParam: JSON.stringify({ params: sRowData }) }; | |
| 2546 | + if (other?.iFlag === 1) { | |
| 2547 | + value.iFlag = 1; | |
| 2548 | + } | |
| 2549 | + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`; | |
| 2550 | + const dataReturn = (await commonServices.postValueService(app.token, value, url)).data; | |
| 2551 | + if (dataReturn.code === 1) { | |
| 2552 | + if (commonUtils.isNotEmptyArr(slaveDataOld)) { | |
| 2553 | + slaveDataOld.forEach((item) => { | |
| 2554 | + item.handleType = 'del'; | |
| 2555 | + slaveDelData.push(item); | |
| 2556 | + }); | |
| 2557 | + addState.slaveDelData = slaveDelData; | |
| 2558 | + } | |
| 2559 | + const returnData = dataReturn.dataset.rows[0]; | |
| 2560 | + const slaveReturn = returnData.dataSet.proData; | |
| 2561 | + if (commonUtils.isNotEmptyArr(slaveReturn)) { | |
| 2562 | + slaveReturn.forEach((slaveItem) => { | |
| 2563 | + newCopyTo.slave = slaveItem; | |
| 2564 | + let slaveRow = commonFunc.getDefaultData(allConfig.slaveConfig, newCopyTo); // 取默认值 | |
| 2565 | + // if (salveDetailAssignField) { | |
| 2566 | + // slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo)}; | |
| 2567 | + // } else if (salveAssignField) { | |
| 2568 | + // slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo)}; // 取赋值字段 | |
| 2569 | + // } | |
| 2570 | + slaveRow = { ...slaveRow, ...slaveItem }; | |
| 2571 | + slaveRow.handleType = 'add'; | |
| 2572 | + slaveRow.sId = commonUtils.createSid(); | |
| 2573 | + slaveRow.sParentId = masterData.sId; | |
| 2574 | + slaveNewData.push(slaveRow); | |
| 2575 | + }); | |
| 2576 | + } | |
| 2577 | + addState.slaveData = slaveNewData; | |
| 2578 | + handleSaveState({ ...addState }); | |
| 2579 | + } else { | |
| 2580 | + getServiceError({ ...dataReturn, fn: () => handleTableBlur(name, sFileName, record, tableConfig, { iFlag: 1 }) }); | |
| 2581 | + } | |
| 2582 | + } else if (sTmpInfoBySqlBtnName.includes('sTmpInfoBySql')) { /* 走TmpInfo逻辑 */ | |
| 2583 | + const newCopyTo = {}; | |
| 2584 | + newCopyTo.master = masterData; | |
| 2585 | + /* 找到自定义TempInfo配置 */ | |
| 2586 | + | |
| 2587 | + const btnConfig = tempConfig.gdsconfigformslave.filter(item => item.sControlName.includes(sTmpInfoBySqlBtnName)); | |
| 2588 | + const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`; | |
| 2589 | + const sConfigformId = commonUtils.isEmpty(btnConfig) ? '' : btnConfig[0].sParentId; | |
| 2590 | + const sControlName = commonUtils.isNotEmptyObject(sTmpInfoBySqlBtnName) ? sTmpInfoBySqlBtnName : 'TmpInfoBySql'; | |
| 2591 | + const sAssignField = btnConfig[0].sAssignField; | |
| 2592 | + const sActiveKeyNew = btnConfig[0].sActiveKey; | |
| 2593 | + let sRowData = [record]; | |
| 2594 | + if (name === 'master' && sTmpInfoBySqlBtnName.includes('_update')) { | |
| 2595 | + const { slaveData } = state; | |
| 2596 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 2597 | + sRowData = [...sRowData, ...slaveData]; | |
| 2598 | + } | |
| 2599 | + } | |
| 2600 | + const values = { sConfigformId, sControlName, sRowData }; | |
| 2601 | + if (true) { | |
| 2602 | + const dataReturn = (await commonServices.postValueService(app.token, values, dataUrl)).data; | |
| 2603 | + const allReturnMap = {}; | |
| 2604 | + if (dataReturn.code === 1) { | |
| 2605 | + const returnData = dataReturn.dataset.rows[0]; | |
| 2606 | + if (commonUtils.isNotEmptyObject(returnData)) { | |
| 2607 | + for (const key of Object.keys(returnData)) { | |
| 2608 | + const sName = `${key}Data`; | |
| 2609 | + const sDelName = `${key}DelData`; | |
| 2610 | + // allReturnMap[sName] = returnData[key]; | |
| 2611 | + let { [`${key}Data`]: oldData, [`${key}Data`]: oldDelData } = state; | |
| 2612 | + if (commonUtils.isEmptyArr(oldDelData)) { | |
| 2613 | + oldDelData = []; | |
| 2614 | + } | |
| 2615 | + if (commonUtils.isEmptyArr(oldData)) { | |
| 2616 | + oldData = []; | |
| 2617 | + } | |
| 2618 | + if (sTmpInfoBySqlBtnName.includes('_edit')) { /* 替换 根据对应字段对比 相同的不管 不同的插入 */ | |
| 2619 | + /* 对应字段 */ | |
| 2620 | + const sActiveKey = sTmpInfoConfig.sActiveKey; | |
| 2621 | + const keyData = returnData[key]; | |
| 2622 | + let newData = []; | |
| 2623 | + if (commonUtils.isNotEmptyArr(keyData)) { | |
| 2624 | + keyData.forEach((child) => { | |
| 2625 | + const filterData = oldData.filter(item => item[sActiveKeyNew] !== child[sActiveKeyNew]); | |
| 2626 | + if (commonUtils.isNotEmptyArr(filterData) && filterData.length === oldData.length) { | |
| 2627 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | |
| 2628 | + tableRow.sId = commonUtils.createSid(); | |
| 2629 | + tableRow.sParentId = masterData.sId; | |
| 2630 | + tableRow.handleType = 'add'; | |
| 2631 | + newData.push(tableRow); | |
| 2632 | + } else { /* 相同的根据赋值字段覆盖 */ | |
| 2633 | + const iIndex = oldData.findIndex(item => item[sActiveKeyNew] === child[sActiveKeyNew]); | |
| 2634 | + if (iIndex > -1) { | |
| 2635 | + if (sAssignField) { | |
| 2636 | + oldData[iIndex] = { ...oldData[iIndex], ...commonFunc.getAssignFieldValue(sAssignField, child) }; | |
| 2637 | + } else { | |
| 2638 | + oldData[iIndex] = { ...oldData[iIndex], ...child }; | |
| 2639 | + } | |
| 2640 | + oldData[iIndex].handleType = commonUtils.isEmpty(oldData[iIndex].handleType) ? 'update' : oldData[iIndex].handleType; | |
| 2641 | + } | |
| 2642 | + } | |
| 2643 | + }); | |
| 2644 | + newData = oldData.concat(newData) | |
| 2645 | + } | |
| 2646 | + | |
| 2647 | + } else if (sTmpInfoBySqlBtnName.includes('_del')) { /* 替换 根据对应字段对比 相同的不管 不同的插入 */ | |
| 2648 | + /* 对应字段 */ | |
| 2649 | + oldData.forEach((child) => { | |
| 2650 | + child.handleType = 'del'; | |
| 2651 | + oldDelData.push(child); | |
| 2652 | + }); | |
| 2653 | + allReturnMap[sDelName] = oldDelData; | |
| 2654 | + oldData = []; | |
| 2655 | + const keyData = returnData[key]; | |
| 2656 | + if (commonUtils.isNotEmptyArr(keyData)) { | |
| 2657 | + keyData.forEach((child) => { | |
| 2658 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | |
| 2659 | + tableRow.sId = commonUtils.createSid(); | |
| 2660 | + if (sName === 'slaveData' && !tableRow.sSqlConditionId) { | |
| 2661 | + tableRow.sSqlConditionId = tableRow.sId; | |
| 2662 | + } | |
| 2663 | + tableRow.sParentId = masterData.sId; | |
| 2664 | + tableRow.handleType = 'add'; | |
| 2665 | + oldData.push(tableRow); | |
| 2666 | + }); | |
| 2667 | + } | |
| 2668 | + allReturnMap[sName] = oldData; | |
| 2669 | + } else if (sTmpInfoBySqlBtnName.includes('_update')) { /* 更新字段 */ | |
| 2670 | + const keyData = returnData[key]; | |
| 2671 | + if (commonUtils.isNotEmptyArr(keyData) && sActiveKeyNew) { | |
| 2672 | + const [linkField, onchangeField] = sActiveKeyNew.split(','); | |
| 2673 | + const tableName = key.split('_update')[0]; | |
| 2674 | + const { [`${tableName}Data`]: tableData = [] } = state; | |
| 2675 | + | |
| 2676 | + for (let i = 0; i < keyData.length; i++) { | |
| 2677 | + const child = keyData[i]; | |
| 2678 | + const tableDataFilter = tableData.filter(item => item[linkField] === child[linkField]); | |
| 2679 | + for (let j = 0; j < tableDataFilter.length; j++) { | |
| 2680 | + const item = tableDataFilter[j]; | |
| 2681 | + const iIndex = tableData.findIndex(row => row.sId === item.sId); | |
| 2682 | + tableData[iIndex] = { ...item, ...child }; | |
| 2683 | + if (onchangeField && state.onEventDataChange) { | |
| 2684 | + const { sId, [onchangeField]: fieldsValue } = tableData[iIndex]; | |
| 2685 | + window.tmpSlaveData = tableData; | |
| 2686 | + tableData[iIndex] = await state.onEventDataChange('slave', onchangeField, { [onchangeField]: fieldsValue }, sId, [], true); | |
| 2687 | + window.tmpSlaveData = null; | |
| 2688 | + } | |
| 2689 | + } | |
| 2690 | + } | |
| 2691 | + allReturnMap[`${tableName}Data`] = tableData; | |
| 2692 | + } | |
| 2693 | + } else { | |
| 2694 | + allReturnMap[sName] = returnData[key]; | |
| 2695 | + } | |
| 2696 | + | |
| 2697 | + } | |
| 2698 | + if (commonUtils.isNotEmptyArr(allReturnMap.masterData) && Array.isArray(allReturnMap.masterData)) { | |
| 2699 | + allReturnMap.masterData = allReturnMap.masterData[0]; | |
| 2700 | + } | |
| 2701 | + handleSaveState({ ...allReturnMap }); | |
| 2702 | + } | |
| 2703 | + } else { | |
| 2704 | + getServiceError(dataReturn); | |
| 2705 | + } | |
| 2706 | + } | |
| 2707 | + } | |
| 2708 | + } else { | |
| 2709 | + message.error('请正确配置自定义按钮!'); | |
| 2710 | + } | |
| 2711 | + } | |
| 2712 | + }; | |
| 2362 | 2713 | // 通用表格行按钮操作 |
| 2363 | 2714 | const handleTableBtnClick = async params => { |
| 2364 | 2715 | const { app } = props; |
| ... | ... | @@ -2961,7 +3312,8 @@ const useCommonBase = props => { |
| 2961 | 3312 | onCopyTo: handleCopyTo, // 复制到 |
| 2962 | 3313 | onMergeTableConfig: handleMergeTableConfig, // 合并config配置和所有sButtonEnabled配置 |
| 2963 | 3314 | awaitPromiseReturn: awaitPromiseReturn, |
| 2964 | - onSelectCommonPopup: handleSelectCommonPopup | |
| 3315 | + onSelectCommonPopup: handleSelectCommonPopup, | |
| 3316 | + onDropDownBlur: handleTableBlur | |
| 2965 | 3317 | }; |
| 2966 | 3318 | |
| 2967 | 3319 | // 切换页面时,加载角标数据 | ... | ... |
src/components/Common/CommonListTreeEvent.js
| ... | ... | @@ -2355,6 +2355,8 @@ export default (ChildComponent) => { |
| 2355 | 2355 | // onBtnEent={this.handleBtnEent} |
| 2356 | 2356 | onOeeBtnEent={this.handleOeeBtnEent} // onBtnEent={this.handleBtnEent} |
| 2357 | 2357 | onGetSlaveTreeData={this.handleGetSlaveTreeData} |
| 2358 | + onDropDownBlur={console.log(11111) | |
| 2359 | + } | |
| 2358 | 2360 | /> |
| 2359 | 2361 | ); |
| 2360 | 2362 | } | ... | ... |
src/components/Common/CommonSubBillEvent.js
src/components/Common/CommonViewTable/index.js
| ... | ... | @@ -525,7 +525,8 @@ class CommonViewTableRc extends Component { |
| 525 | 525 | onCostomChange: this.props.onCostomChange, // 控件后自定义按钮事件, |
| 526 | 526 | onExecInstructSet: this.props.onExecInstructSet, // 调用指令集 |
| 527 | 527 | handleReportInfo: this.props.handleReportInfo, |
| 528 | - showTooltip: this.props.showTooltip | |
| 528 | + showTooltip: this.props.showTooltip, | |
| 529 | + onDropDownBlur: this.props.onDropDownBlur | |
| 529 | 530 | }; |
| 530 | 531 | return ( |
| 531 | 532 | <Col | ... | ... |
src/mes/common/commonModelComponent/index.js