Commit 5aa99ed17938ac961eb9f6ca39cc32a425ba349c
1 parent
77adc61b
表格默认值 、 隐藏侧边快捷键
Showing
7 changed files
with
117 additions
and
67 deletions
src/components/Common/CommonTable/index.js
| ... | ... | @@ -4795,13 +4795,11 @@ class CommonTableRc extends React.Component { |
| 4795 | 4795 | }} |
| 4796 | 4796 | /> |
| 4797 | 4797 | } |
| 4798 | - console.log(props?.parentProps?.sModelType, props, 'messsss'); | |
| 4799 | - | |
| 4800 | 4798 | |
| 4801 | 4799 | if (this.isPopupShow) { |
| 4802 | 4800 | const enabled = this.getTableBtnState('BtnPopup', record); |
| 4803 | 4801 | const setDownload = commonFunc.showMessage(props.app.commonConst, 'setPopup');/* 弹窗 */ |
| 4804 | - operatePopupModal = <a title={setDownload} {...choosePopupProps} onClick={enabled ? this.popupModalTbRow.bind(this, index, record) : null}>{enabled ? <SvgIcon iconClass="search" fill="#1296db" size="14" alt="弹窗"></SvgIcon> : <SvgIcon iconClass="search" fill="rgb(189, 189, 189)" size="14" alt="弹窗"></SvgIcon>}</a>; | |
| 4802 | + operatePopupModal = <a title={setDownload} {...choosePopupProps} onClick={enabled ? this.popupModalTbRow.bind(this, index, record) : null} className="btnIcon">{enabled ? <SvgIcon iconClass="search" fill="#1296db" size="14" alt="弹窗"></SvgIcon> : <SvgIcon iconClass="search" fill="rgb(189, 189, 189)" size="14" alt="弹窗"></SvgIcon>}</a>; | |
| 4805 | 4803 | } |
| 4806 | 4804 | const tableBtnsConfig = |
| 4807 | 4805 | typeof props.tableBtnsConfig === "function" |
| ... | ... | @@ -4812,7 +4810,6 @@ class CommonTableRc extends React.Component { |
| 4812 | 4810 | tableData: props.data |
| 4813 | 4811 | }) |
| 4814 | 4812 | : props.tableBtnsConfig || []; |
| 4815 | - console.log(tableBtnsConfig, typeof props.tableBtnsConfig === "function", 'tableBtnsConfig'); | |
| 4816 | 4813 | |
| 4817 | 4814 | return ( |
| 4818 | 4815 | <div | ... | ... |
src/components/Common/CommonTable/index.less
src/components/Common/commonFunc.js
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | import moment from 'moment'; |
| 3 | 3 | import lodash from 'lodash'; |
| 4 | 4 | import * as commonUtils from '@/utils/utils'; |
| 5 | - | |
| 5 | +import config from '@/utils/config'; | |
| 6 | 6 | /* 根据控件名 通过配置 得到是否显示与是否有权限 */ |
| 7 | 7 | // type control, field 控件、字段 |
| 8 | 8 | // name 名称 |
| ... | ... | @@ -143,75 +143,124 @@ export function mapPropsToFields(masterData, form, masterConfig) { |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** 获取数据默认值 取消其他表值数据时 sTaxId:master.sTaxId */ |
| 146 | -export function getDefaultData(config, allTableData, extraData = {}) { | |
| 146 | +export function getDefaultData(config, allTableData = {}, extraData = {}) { | |
| 147 | 147 | const { newSid } = extraData; |
| 148 | 148 | const returnData = {}; |
| 149 | 149 | if (commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyObject(config.gdsconfigformslave)) { |
| 150 | 150 | config.gdsconfigformslave.forEach((childConfig) => { |
| 151 | 151 | const { sDefault, sName } = childConfig; |
| 152 | - if (sDefault !== null) { | |
| 153 | - if (sDefault !== '' && sName && sDefault !== undefined && sDefault.indexOf(':') > -1 && sDefault.indexOf('.') > -1) { | |
| 154 | - const oldFieldName = sDefault.split(':')[1]; | |
| 155 | - const tableName = oldFieldName.split('.')[0]; | |
| 156 | - const oldTableFieldName = oldFieldName.split('.')[1]; | |
| 157 | - if (oldTableFieldName === 'sId' && newSid) { | |
| 158 | - returnData[sName] = newSid; | |
| 159 | - } else if (!commonUtils.isEmptyObject(allTableData[tableName])) { | |
| 160 | - if (oldFieldName.includes('+') || oldFieldName.includes('-') || oldFieldName.includes('*') || | |
| 161 | - oldFieldName.includes('/') || oldFieldName.includes('(') || oldFieldName.includes(')')) { | |
| 162 | - let sFormula = oldFieldName; | |
| 163 | - let sFormulaSplit = oldFieldName; | |
| 164 | - sFormulaSplit = sFormulaSplit.split('+').join('$'); | |
| 165 | - sFormulaSplit = sFormulaSplit.split('-').join('$'); | |
| 166 | - sFormulaSplit = sFormulaSplit.split('*').join('$'); | |
| 167 | - sFormulaSplit = sFormulaSplit.split('/').join('$'); | |
| 168 | - sFormulaSplit = sFormulaSplit.split('(').join('$'); | |
| 169 | - sFormulaSplit = sFormulaSplit.split(')').join('$'); | |
| 170 | - sFormulaSplit.split('$').forEach((oldFieldNameItem) => { | |
| 171 | - const oldFieldItem = oldFieldNameItem.trim(); | |
| 172 | - if (oldFieldItem.indexOf('.') > -1) { | |
| 173 | - const tableName = oldFieldItem.split('.')[0].trim(); | |
| 174 | - const oldTableFieldName = oldFieldItem.split('.')[1].trim(); | |
| 175 | - if (!commonUtils.isEmptyObject(allTableData[tableName]) && allTableData[tableName][oldTableFieldName] !== undefined) { | |
| 176 | - sFormula = sFormula.replace(oldFieldItem, allTableData[tableName][oldTableFieldName]); | |
| 177 | - } | |
| 178 | - } else { | |
| 179 | - const oldTableFieldName = oldFieldItem.trim(); | |
| 180 | - if (allTableData[tableName][oldTableFieldName] !== undefined) { | |
| 181 | - sFormula = sFormula.replace(oldTableFieldName, `(${allTableData[tableName][oldTableFieldName]})`); /* 加括号处理当值为负数时的异常 */ | |
| 182 | - } | |
| 152 | + if (typeof sDefault === 'string' && sDefault !== '' && sName && sDefault !== undefined && sDefault.indexOf(':') > -1 && sDefault.indexOf('.') > -1) { | |
| 153 | + const oldFieldName = sDefault.split(':')[1]; | |
| 154 | + const tableName = oldFieldName.split('.')[0]; | |
| 155 | + if (sDefault && sDefault.includes('Fx')) { /* 默认值支持自定义函数 */ | |
| 156 | + let result = ''; | |
| 157 | + const indexOf = tableName.indexOf('('); | |
| 158 | + const tbName = tableName.substring(indexOf + 1, tableName.length); | |
| 159 | + const fxName = oldFieldName.replace('Fx_', '').trim(); | |
| 160 | + const tableData = allTableData[tbName]; | |
| 161 | + const tbField1 = fxName.substring(fxName.indexOf('.') + 1, fxName.indexOf(',')).trim(); /* 第一个参数名称: master.[字段] */ | |
| 162 | + const tbField2 = fxName.substring(fxName.indexOf(',') + 1, fxName.indexOf(')')).trim(); /* 第二个参数名称: 格式YYYY-MM-DD */ | |
| 163 | + let tbFieldValue1 = ''; | |
| 164 | + if (!Array.isArray(tableData)) { | |
| 165 | + tbFieldValue1 = tableData[tbField1]; | |
| 166 | + } | |
| 167 | + if (sDefault.includes('getDate')) { | |
| 168 | + result = commonUtils.getDate(tbFieldValue1, tbField2); | |
| 169 | + } | |
| 170 | + returnData[sName] = result; | |
| 171 | + return returnData; | |
| 172 | + } | |
| 173 | + const oldTableFieldName = oldFieldName.split('.')[1]; | |
| 174 | + if (oldTableFieldName === 'sId' && newSid) { | |
| 175 | + returnData[sName] = newSid; | |
| 176 | + } else if (!commonUtils.isEmptyObject(allTableData[tableName])) { | |
| 177 | + if (oldFieldName.includes('+') || oldFieldName.includes('-') || oldFieldName.includes('*') || | |
| 178 | + oldFieldName.includes('/') || oldFieldName.includes('(') || oldFieldName.includes(')')) { | |
| 179 | + let sFormula = oldFieldName; | |
| 180 | + let sFormulaSplit = oldFieldName; | |
| 181 | + sFormulaSplit = sFormulaSplit.split('+').join('$'); | |
| 182 | + sFormulaSplit = sFormulaSplit.split('-').join('$'); | |
| 183 | + sFormulaSplit = sFormulaSplit.split('*').join('$'); | |
| 184 | + sFormulaSplit = sFormulaSplit.split('/').join('$'); | |
| 185 | + sFormulaSplit = sFormulaSplit.split('(').join('$'); | |
| 186 | + sFormulaSplit = sFormulaSplit.split(')').join('$'); | |
| 187 | + sFormulaSplit.split('$').forEach((oldFieldNameItem) => { | |
| 188 | + const oldFieldItem = oldFieldNameItem.trim(); | |
| 189 | + if (oldFieldItem.indexOf('.') > -1) { | |
| 190 | + const tableName = oldFieldItem.split('.')[0].trim(); | |
| 191 | + const oldTableFieldName = oldFieldItem.split('.')[1].trim(); | |
| 192 | + if (!commonUtils.isEmptyObject(allTableData[tableName]) && allTableData[tableName][oldTableFieldName] !== undefined) { | |
| 193 | + sFormula = sFormula.replace(oldFieldItem, allTableData[tableName][oldTableFieldName]); | |
| 183 | 194 | } |
| 184 | - }); | |
| 185 | - returnData[sName] = oldTableFieldName.substring(0, 1) === '&' ? sFormula.split('+').join('') : commonUtils.convertFixNum(eval(sFormula), 6); | |
| 186 | - } else { | |
| 187 | - returnData[sName] = allTableData[tableName][oldTableFieldName]; | |
| 188 | - } | |
| 195 | + } else { | |
| 196 | + const oldTableFieldName = oldFieldItem.trim(); | |
| 197 | + if (allTableData[tableName][oldTableFieldName] !== undefined) { | |
| 198 | + sFormula = sFormula.replace(oldTableFieldName, `(${allTableData[tableName][oldTableFieldName]})`); /* 加括号处理当值为负数时的异常 */ | |
| 199 | + } | |
| 200 | + } | |
| 201 | + }); | |
| 202 | + returnData[sName] = oldTableFieldName.substring(0, 1) === '&' ? sFormula.split('+').join('') : commonUtils.convertFixNum(eval(sFormula), 6); | |
| 203 | + } else if (sDefault.split(',').length > 1 && sDefault.split(':').length > 1) { | |
| 204 | + sDefault.split(',').forEach(item => { | |
| 205 | + const oldFieldName = item.split(':')[1]; | |
| 206 | + const [tableName, oldTableFieldName] = oldFieldName.split('.'); | |
| 207 | + const newFieldName = item.split(':')[0]; | |
| 208 | + returnData[newFieldName] = allTableData[tableName][oldTableFieldName]; | |
| 209 | + }); | |
| 210 | + } else { | |
| 211 | + returnData[sName] = allTableData[tableName][oldTableFieldName]; | |
| 189 | 212 | } |
| 190 | - } else if (sName && sDefault !== '' && sDefault !== undefined) { | |
| 191 | - if (sName.substring(0, 1) === 'b') { | |
| 192 | - returnData[sName] = commonUtils.converNumStrToBoolean(sDefault); | |
| 193 | - } else if (sName.substring(0, 1) === 't' && (sDefault === 'today' || sDefault === 'now')) { | |
| 194 | - if (sDefault === 'now') { | |
| 195 | - returnData[sName] = moment().format('YYYY-MM-DD HH:mm:ss'); | |
| 196 | - } else { | |
| 197 | - returnData[sName] = moment().format('YYYY-MM-DD'); | |
| 198 | - } | |
| 199 | - } else if (sName.substring(0, 1) === 'i') { | |
| 200 | - returnData[sName] = parseInt(sDefault); | |
| 201 | - } else if (sName.substring(0, 1) === 'd') { | |
| 202 | - returnData[sName] = parseFloat(sDefault); | |
| 203 | - } else if (sDefault === '&+') { | |
| 204 | - returnData[sName] = ''; | |
| 213 | + } | |
| 214 | + } else if (sName && sDefault !== '' && sDefault !== undefined) { | |
| 215 | + if (sName.substring(0, 1) === 'b') { | |
| 216 | + returnData[sName] = commonUtils.converNumStrToBoolean(sDefault); | |
| 217 | + } else if (sName.substring(0, 1) === 't' && (sDefault === 'today' || sDefault === 'now')) { | |
| 218 | + if (sDefault === 'now') { | |
| 219 | + returnData[sName] = moment().format('YYYY-MM-DD HH:mm:ss'); | |
| 205 | 220 | } else { |
| 206 | - returnData[sName] = sDefault; | |
| 221 | + returnData[sName] = moment().format('YYYY-MM-DD'); | |
| 207 | 222 | } |
| 223 | + } else if (sName.substring(0, 1) === 'i') { | |
| 224 | + returnData[sName] = parseInt(sDefault); | |
| 225 | + } else if (sName.substring(0, 1) === 'd') { | |
| 226 | + returnData[sName] = parseFloat(sDefault); | |
| 227 | + } else if (sDefault === '&+') { | |
| 228 | + returnData[sName] = ''; | |
| 229 | + } else { | |
| 230 | + returnData[sName] = sDefault; | |
| 231 | + } | |
| 232 | + } else if (sName) { | |
| 233 | + const value = handleDefaultSName(childConfig); | |
| 234 | + if (value) { | |
| 235 | + returnData[sName] = value; | |
| 208 | 236 | } |
| 209 | 237 | } |
| 210 | 238 | }); |
| 211 | 239 | } |
| 212 | 240 | return returnData; |
| 213 | 241 | } |
| 214 | - | |
| 242 | +/** | |
| 243 | + * 处理用户信息 | |
| 244 | + */ | |
| 245 | +const handleDefaultSName = (itemConfig) => { | |
| 246 | + const { sControlName, sDefault, sName } = itemConfig || {}; | |
| 247 | + const key = sControlName?.split('-')?.[1]; | |
| 248 | + if (!key || sDefault) return false; | |
| 249 | + try { | |
| 250 | + let userinfo = localStorage.getItem(`${config.prefix}userinfo`); | |
| 251 | + userinfo = JSON.parse(userinfo); | |
| 252 | + const userinfoKey = Object.keys(userinfo); | |
| 253 | + if (userinfoKey.includes(key)) { | |
| 254 | + if (sName?.substring(0, 1) === 't') { | |
| 255 | + return moment(userinfo[key]); | |
| 256 | + } | |
| 257 | + return userinfo[key]; | |
| 258 | + } | |
| 259 | + } catch (error) { | |
| 260 | + return false; | |
| 261 | + } | |
| 262 | + return false; | |
| 263 | +}; | |
| 215 | 264 | /** 获取数据默认值 */ |
| 216 | 265 | export function getAssignFieldValue(sAssignField, srcData, allTableData, bMultiTable, bCommon) { |
| 217 | 266 | const returnData = {}; | ... | ... |
src/default.less
| ... | ... | @@ -911,9 +911,12 @@ |
| 911 | 911 | |
| 912 | 912 | .operate-bar { |
| 913 | 913 | min-height: 28px; |
| 914 | - | |
| 914 | + display: flex; | |
| 915 | + align-items: center; | |
| 916 | + justify-content: space-between; | |
| 915 | 917 | a { |
| 916 | - width: 40px; | |
| 918 | + width: 24px; | |
| 919 | + height: 24px; | |
| 917 | 920 | margin: 0 !important; |
| 918 | 921 | position: relative; |
| 919 | 922 | ... | ... |
src/mes/common/commonModalComponent/index.js
src/mes/common/commonModelComponent/index.js
| ... | ... | @@ -325,7 +325,6 @@ const useCommonModelEvent = props => { |
| 325 | 325 | ...addState, |
| 326 | 326 | ...handleMergeCustomColumn(addState, tableList) |
| 327 | 327 | }; |
| 328 | - console.log(addState, 'addState'); | |
| 329 | 328 | |
| 330 | 329 | props.onSaveState(addState); |
| 331 | 330 | } |
| ... | ... | @@ -415,7 +414,6 @@ const useCommonModelEvent = props => { |
| 415 | 414 | sFormId: sModelsId, |
| 416 | 415 | ...masterDataCopyTo |
| 417 | 416 | }; |
| 418 | - | |
| 419 | 417 | props.onSaveState({ masterData: masterDataNew, enabled: true, }); |
| 420 | 418 | }, |
| 421 | 419 | [props.bFinish] |
| ... | ... | @@ -492,7 +490,6 @@ const useCommonModelEvent = props => { |
| 492 | 490 | const handleGetData = async (tableList = [], isWait, bInit) => { |
| 493 | 491 | let addState = {}; |
| 494 | 492 | const currentIds = currentId ? currentId : props?.parentProps?.record?.sId |
| 495 | - console.log("🚀 ~ handleGetData ~ currentIds:", currentIds, props?.parentProps?.record ) | |
| 496 | 493 | for (let i = 0; i < tableList.length; i++) { |
| 497 | 494 | const tableName = tableList[i]; |
| 498 | 495 | const config = formData.find(item => item.sGrd === tableName); | ... | ... |
src/mes/productionExec/quickSwitchTabComponent/index.js
| ... | ... | @@ -105,7 +105,7 @@ const QuickSwitchTabComponent = baseProps => { |
| 105 | 105 | |
| 106 | 106 | return ( |
| 107 | 107 | <div className={styles.quickSwitchTabComponent} ref={ref}> |
| 108 | - {list.map((title, index) => { | |
| 108 | + {/* {list.map((title, index) => { | |
| 109 | 109 | const currentId = listId[index]; |
| 110 | 110 | const currentMesPane = commonUtils.convertStrToObj( |
| 111 | 111 | localStorage.xlybusinesscurrentMesPane |
| ... | ... | @@ -138,7 +138,7 @@ const QuickSwitchTabComponent = baseProps => { |
| 138 | 138 | {title} |
| 139 | 139 | </div> |
| 140 | 140 | ); |
| 141 | - })} | |
| 141 | + })} */} | |
| 142 | 142 | </div> |
| 143 | 143 | ); |
| 144 | 144 | }; | ... | ... |