Commit 4a000ac096af71ad23051bdc1a3c1184dc550836
1 parent
e6d09b9d
自定义过程
Showing
2 changed files
with
198 additions
and
2 deletions
src/components/Common/CommonComponent/index.js
| ... | ... | @@ -762,7 +762,7 @@ export default class CommonComponent extends Component { |
| 762 | 762 | } else { // 没有配置列宽,就根据字符数算宽度 |
| 763 | 763 | // 获取中文字数、非中文字数, 中文12px,其它8px |
| 764 | 764 | const titleStr = title; |
| 765 | - const totalStringLen = titleStr.length; | |
| 765 | + const totalStringLen = titleStr?.length; | |
| 766 | 766 | const otherStrLen = titleStr.replace(/[^\x00-\xff]/g, '').length; // eslint-disable-line |
| 767 | 767 | const chineseStrLen = totalStringLen - otherStrLen; |
| 768 | 768 | const defaultWidth = (chineseStrLen * 20) + (otherStrLen * 12); | ... | ... |
src/mes/common/commonOperationBarComponent/MesToolbar.js
| ... | ... | @@ -122,7 +122,7 @@ const ToolbarFun = async (props) => { |
| 122 | 122 | } else { |
| 123 | 123 | props.onBtnCancelExamine(0); |
| 124 | 124 | } |
| 125 | - } else if (['btnevent', 'btnsubmit', 'btnsubmitcancel'].includes(btnName) || sButtonParam) { | |
| 125 | + } else if (['btnevent', 'btnsubmit', 'btnsubmitcancel'].includes(btnName)) { | |
| 126 | 126 | const { |
| 127 | 127 | slaveSelectedRowKeys, |
| 128 | 128 | slaveData, |
| ... | ... | @@ -278,6 +278,52 @@ const ToolbarFun = async (props) => { |
| 278 | 278 | loading: false, |
| 279 | 279 | }); |
| 280 | 280 | } |
| 281 | + } else if (btnName.includes('btnrepair')) { | |
| 282 | + if (btnName.toLowerCase().endsWith("choosedate")) { | |
| 283 | + handleForceComplete(props,btnName, "chooseDate"); | |
| 284 | + } else if (btnName.includes("btnrepairgroup") || btnName.includes("btnrepairuser")) { | |
| 285 | + /* 复制组权限单独处理 */ | |
| 286 | + props.onButtonClick(btnName); | |
| 287 | + } else { | |
| 288 | + /* 根据接口返回是之前调用还是之后调用 */ | |
| 289 | + if (false) { | |
| 290 | + const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1"); | |
| 291 | + const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2"); | |
| 292 | + if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) { | |
| 293 | + /* 之前调用 */ | |
| 294 | + | |
| 295 | + let flag = 0; | |
| 296 | + const asyncFunc = async () => { | |
| 297 | + for (let i = 0; i < beforeInterfaceArr.length; i++) { | |
| 298 | + const data = await handleInterfaceCall(beforeInterfaceArr[i]); | |
| 299 | + if (!data) { | |
| 300 | + flag += 1; | |
| 301 | + return; | |
| 302 | + } | |
| 303 | + } | |
| 304 | + }; | |
| 305 | + await asyncFunc(); | |
| 306 | + if (flag == 0) { | |
| 307 | + handleForceComplete(key); | |
| 308 | + } | |
| 309 | + } | |
| 310 | + if (commonUtils.isNotEmptyArr(afterInterfaceArr)) { | |
| 311 | + /* 之后调用 */ | |
| 312 | + const result = await handleForceComplete(key); | |
| 313 | + if (result !== -5) { | |
| 314 | + /* 只有审核成功 才能调用接口 -5代表审核失败 */ | |
| 315 | + const asyncFunc = async () => { | |
| 316 | + for (let i = 0; i < afterInterfaceArr.length; i++) { | |
| 317 | + await handleInterfaceCall(afterInterfaceArr[i], true); | |
| 318 | + } | |
| 319 | + }; | |
| 320 | + await asyncFunc(); | |
| 321 | + } | |
| 322 | + } | |
| 323 | + } else { | |
| 324 | + handleForceComplete(props,btnName); | |
| 325 | + } | |
| 326 | + } | |
| 281 | 327 | } |
| 282 | 328 | |
| 283 | 329 | |
| ... | ... | @@ -757,6 +803,156 @@ const handleInterfaceCall = async (props, obj, showTip, key, ids, slaveSelectedR |
| 757 | 803 | } |
| 758 | 804 | return bResult; |
| 759 | 805 | }; |
| 806 | +const handleForceComplete = (props, name, createDate) => { | |
| 807 | + let sysLogData = {}; | |
| 808 | + const slaveMemoConfigOld = []; | |
| 809 | + const { slaveSelectedRowKeys, slaveInfoSelectedRowKeys, app, masterConfig, slaveInfoData, masterData, slaveData, gdsformconst } = props; | |
| 810 | + const btnConfig = | |
| 811 | + commonUtils.isNotEmptyObject(masterConfig) && | |
| 812 | + commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === name)) | |
| 813 | + ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === name)[0] | |
| 814 | + : {}; // sButtonEnabled sButtonParam | |
| 815 | + const bNoMemo = btnConfig.sDefault === "noMemo"; | |
| 816 | + if (createDate !== "chooseDate") { | |
| 817 | + let target = ""; | |
| 818 | + if (btnConfig.sActiveKey) { | |
| 819 | + target = btnConfig.sActiveKey.split(",")[0].split(".")[0]; | |
| 820 | + } | |
| 821 | + if (target === "slave" && commonUtils.isEmptyArrNew(slaveSelectedRowKeys)) { | |
| 822 | + message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录 | |
| 823 | + } else if (target === "slaveInfo" && commonUtils.isEmptyArrNew(slaveInfoSelectedRowKeys)) { | |
| 824 | + message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录 | |
| 825 | + } else if (target === "slaveInfo" && !Array.isArray(slaveInfoData)) { | |
| 826 | + message.warn("请展开详情并选择数据。"); // 请选择记录 | |
| 827 | + } else { | |
| 828 | + let btnConfigNameArr = []; | |
| 829 | + let singleConfig = {}; | |
| 830 | + let singleRow = {}; /* 选中行的数据 */ | |
| 831 | + if (name.indexOf("BtnRepair") > -1) { | |
| 832 | + if (!commonUtils.isEmpty(btnConfig.sActiveKey)) { | |
| 833 | + btnConfigNameArr = btnConfig.sActiveKey.split(","); | |
| 834 | + } | |
| 835 | + if (commonUtils.isNotEmptyArr(btnConfigNameArr)) { | |
| 836 | + // eslint-disable-next-line array-callback-return | |
| 837 | + btnConfigNameArr.map(i => { | |
| 838 | + let sIndex = -1; | |
| 839 | + if (target === "slaveInfo") { | |
| 840 | + sIndex = props.slaveInfoConfig.gdsconfigformslave.findIndex(item => item.sName === i.split(".")[1]); | |
| 841 | + const iSlaveIndex = slaveInfoData.findIndex(item => slaveInfoSelectedRowKeys.includes(item.sSlaveId)); | |
| 842 | + if (iSlaveIndex > -1) { | |
| 843 | + singleRow = slaveInfoData[iSlaveIndex]; | |
| 844 | + } | |
| 845 | + } else if (target === "master") { | |
| 846 | + sIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sName === i.split(".")[1]); | |
| 847 | + singleRow = masterData; | |
| 848 | + } else { | |
| 849 | + if (commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.slaveConfig)) { | |
| 850 | + sIndex = props.slaveConfig.gdsconfigformslave.findIndex(item => item.sName === i); | |
| 851 | + const iSlaveIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId)); | |
| 852 | + if (iSlaveIndex > -1) { | |
| 853 | + singleRow = slaveData[iSlaveIndex]; | |
| 854 | + } | |
| 855 | + } | |
| 856 | + } | |
| 857 | + console.log("singleRow:", singleRow); | |
| 858 | + if (sIndex > -1) { | |
| 859 | + if (target === "slaveInfo") { | |
| 860 | + singleConfig = props.slaveInfoConfig.gdsconfigformslave[sIndex]; | |
| 861 | + } else if (target === "master") { | |
| 862 | + singleConfig = props.masterConfig.gdsconfigformslave[sIndex]; | |
| 863 | + } else { | |
| 864 | + singleConfig = props.slaveConfig.gdsconfigformslave[sIndex]; | |
| 865 | + } | |
| 866 | + if (masterData && commonUtils.isNotEmptyObject(singleRow)) { | |
| 867 | + masterData[singleConfig.sName] = singleRow[singleConfig.sName]; | |
| 868 | + } | |
| 869 | + // if (masterData && commonUtils.isNotEmptyObject(singleConfig)) { | |
| 870 | + // masterData[singleConfig.sName] = undefined; | |
| 871 | + // } | |
| 872 | + slaveMemoConfigOld.push(singleConfig); | |
| 873 | + } | |
| 874 | + }); | |
| 875 | + } | |
| 876 | + } | |
| 877 | + /* 时间格式的字段 若默认值为空 则取当前时间 */ | |
| 878 | + const activeKeyData = commonUtils.isNotEmptyObject(btnConfig.sActiveKey) ? btnConfig.sActiveKey.split(",") : []; | |
| 879 | + if (activeKeyData.length > 1) { | |
| 880 | + /* 当多字段时候 若时间格式的字段 若默认值为空 则取当前时间 */ | |
| 881 | + const filterData = activeKeyData.filter(item => item.substring(0, 1) === "t"); | |
| 882 | + if (commonUtils.isNotEmptyArr(filterData)) { | |
| 883 | + filterData.forEach(item => { | |
| 884 | + let currentDate = moment().format("YYYY-MM-DD HH:mm:ss"); | |
| 885 | + | |
| 886 | + // 如果默认值为0 则不设置默认时间 | |
| 887 | + const itemConfigIndex = masterConfig.gdsconfigformslave.findIndex(config => config.sName === item); | |
| 888 | + if (itemConfigIndex !== -1 && masterConfig.gdsconfigformslave[itemConfigIndex].sDefault === "0") { | |
| 889 | + currentDate = null; | |
| 890 | + } | |
| 891 | + if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmpty(masterData[item])) { | |
| 892 | + masterData[item] = currentDate; | |
| 893 | + } | |
| 894 | + }); | |
| 895 | + } | |
| 896 | + } else { | |
| 897 | + if (commonUtils.isNotEmptyObject(btnConfig.sActiveKey) && btnConfig.sActiveKey.substring(0, 1) === "t") { | |
| 898 | + if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmpty(masterData[btnConfig.sActiveKey])) { | |
| 899 | + masterData[btnConfig.sActiveKey] = moment().format("YYYY-MM-DD HH:mm:ss"); | |
| 900 | + } | |
| 901 | + } | |
| 902 | + } | |
| 903 | + // if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys === null) { | |
| 904 | + // message.warn('请选择数据!'); | |
| 905 | + // return; | |
| 906 | + // } | |
| 907 | + sysLogData = commonUtils.isNotEmptyArr(slaveSelectedRowKeys) ? { sId: slaveSelectedRowKeys.toString() } : {}; | |
| 908 | + props.onSaveState({ | |
| 909 | + slaveMemoConfig: slaveMemoConfigOld, | |
| 910 | + masterData: commonUtils.isNotEmptyObject(masterData) | |
| 911 | + ? lodash.cloneDeep(masterData) | |
| 912 | + : {} /* 将选中行数据深拷贝 变成两个互不相扰的独立数据源 */, | |
| 913 | + sCurrMemoProps: { | |
| 914 | + bVisibleMemo: true, | |
| 915 | + sMemoField: "sReason", | |
| 916 | + sRecord: sysLogData, | |
| 917 | + dataSource: sysLogData, | |
| 918 | + btnName: name, | |
| 919 | + bNoMemo, | |
| 920 | + }, | |
| 921 | + }); | |
| 922 | + } | |
| 923 | + } else { | |
| 924 | + /* 从系统常量中找到pChooseDate的sName */ | |
| 925 | + let pChooseDateName = "生成凭证"; | |
| 926 | + if (commonUtils.isNotEmptyArr(gdsformconst)) { | |
| 927 | + const iIndex = gdsformconst.findIndex(item => item.sName === "pChooseDate"); | |
| 928 | + if (iIndex > -1) { | |
| 929 | + pChooseDateName = gdsformconst[iIndex].showName; | |
| 930 | + } | |
| 931 | + } | |
| 932 | + const chooseDateConfig = { | |
| 933 | + sId: commonUtils.createSid(), | |
| 934 | + sName: "pChooseDate", | |
| 935 | + sDropDownType: "sql", | |
| 936 | + bNotEmpty: false, | |
| 937 | + iVisCount: 1, | |
| 938 | + dropDownData: [], | |
| 939 | + showName: pChooseDateName, | |
| 940 | + sDateFormat: btnConfig && btnConfig.sDateFormat ? btnConfig.sDateFormat : "YYYY-MM-DD", | |
| 941 | + }; | |
| 942 | + slaveMemoConfigOld.push(chooseDateConfig); | |
| 943 | + props.onSaveState({ | |
| 944 | + slaveMemoConfig: slaveMemoConfigOld, | |
| 945 | + sCurrMemoProps: { | |
| 946 | + bVisibleMemo: true, | |
| 947 | + sMemoField: "sReason", | |
| 948 | + sRecord: sysLogData, | |
| 949 | + dataSource: sysLogData, | |
| 950 | + btnName: name, | |
| 951 | + bNoMemo, | |
| 952 | + }, | |
| 953 | + }); | |
| 954 | + } | |
| 955 | +}; | |
| 760 | 956 | // 新增 |
| 761 | 957 | const handleAdd = (props) => { |
| 762 | 958 | const { slaveConfig } = props; | ... | ... |