Commit 72fcbd94c208b6cd4c2511f5c3f905a106d14cc3
1 parent
1895c083
迁移部分代码;
Showing
100 changed files
with
55193 additions
and
5 deletions
Too many changes to show.
To preserve performance only 7 of 100 files are displayed.
.umirc.ts
| @@ -4,7 +4,11 @@ export default defineConfig({ | @@ -4,7 +4,11 @@ export default defineConfig({ | ||
| 4 | routes: [ | 4 | routes: [ |
| 5 | { path: '/', redirect: '/login' }, | 5 | { path: '/', redirect: '/login' }, |
| 6 | { path: '/login', component: '@/routes/login/login' }, | 6 | { path: '/login', component: '@/routes/login/login' }, |
| 7 | - { path: '/indexPage', component: '@/routes/indexPage' }, | 7 | + { |
| 8 | + path: '/indexPage', | ||
| 9 | + component: '@/routes/indexPage', | ||
| 10 | + routes: [{ path: '/indexPage/CommonList' }], | ||
| 11 | + }, | ||
| 8 | ], | 12 | ], |
| 9 | 13 | ||
| 10 | npmClient: 'pnpm', | 14 | npmClient: 'pnpm', |
package.json
| @@ -11,10 +11,21 @@ | @@ -11,10 +11,21 @@ | ||
| 11 | "dependencies": { | 11 | "dependencies": { |
| 12 | "@ant-design/compatible": "^1.1.2", | 12 | "@ant-design/compatible": "^1.1.2", |
| 13 | "@ant-design/icons": "^5.6.1", | 13 | "@ant-design/icons": "^5.6.1", |
| 14 | + "@js-preview/docx": "^1.6.4", | ||
| 15 | + "@js-preview/excel": "^1.7.14", | ||
| 14 | "antd": "^5.24.3", | 16 | "antd": "^5.24.3", |
| 17 | + "antd-mobile": "2.3.4", | ||
| 15 | "antd-v4": "npm:antd@4.24.16", | 18 | "antd-v4": "npm:antd@4.24.16", |
| 19 | + "braft-editor": "^2.3.9", | ||
| 20 | + "immutability-helper": "^3.1.1", | ||
| 16 | "lodash": "^4.17.21", | 21 | "lodash": "^4.17.21", |
| 17 | "moment": "^2.30.1", | 22 | "moment": "^2.30.1", |
| 23 | + "react-dnd": "^14.0.5", | ||
| 24 | + "react-dnd-html5-backend": "^14.1.0", | ||
| 25 | + "react-highlight-words": "^0.21.0", | ||
| 26 | + "react-pdf": "^9.2.1", | ||
| 27 | + "react-resizable": "^3.0.5", | ||
| 28 | + "react-sortable-hoc": "^2.0.0", | ||
| 18 | "umi": "^4.4.6" | 29 | "umi": "^4.4.6" |
| 19 | }, | 30 | }, |
| 20 | "devDependencies": { | 31 | "devDependencies": { |
src/components/Common/AffixMenu.js
0 → 100644
| 1 | +/* eslint-disable */ | ||
| 2 | +import React, { Component } from 'react'; | ||
| 3 | +import { Affix, Table, Checkbox, Input, Select, message, Tabs, Alert } from 'antd-v4'; | ||
| 4 | +import styles from '@/index.less'; | ||
| 5 | +import lodash from 'lodash'; | ||
| 6 | +import * as commonUtils from '@/utils/utils'; | ||
| 7 | +import config from '@/utils/config'; | ||
| 8 | +import * as commonFunc from '@/components/Common/commonFunc'; | ||
| 9 | +import AntdDraggableModal from '@/components/Common/AntdDraggableModal'; | ||
| 10 | +import SvgIcon from '../SvgIcon'; | ||
| 11 | + | ||
| 12 | +const { Option } = Select; | ||
| 13 | +const { TabPane } = Tabs; | ||
| 14 | + | ||
| 15 | +class AffixMenuComponent extends Component { | ||
| 16 | + constructor(props) { | ||
| 17 | + super(props); | ||
| 18 | + const UserPersonalization = commonFunc.showMessage(props.app.commonConst, 'UserPersonalization');/* 用户个性化配置 */ | ||
| 19 | + this.state = { | ||
| 20 | + top: 10, | ||
| 21 | + modalPanel: { title: UserPersonalization }, | ||
| 22 | + modalVisible: false, | ||
| 23 | + modalData: [], | ||
| 24 | + modalContent: [], /* 面板展示内容 */ | ||
| 25 | + modalContentData1: [], | ||
| 26 | + modalContentData2: [], | ||
| 27 | + modalContentData3: [], | ||
| 28 | + modalContentData4: [], | ||
| 29 | + modalContentData5: [], | ||
| 30 | + modalContentData6: [], | ||
| 31 | + modalContentData7: [], | ||
| 32 | + modalContentData8: [], | ||
| 33 | + modalContentData9: [], | ||
| 34 | + modalContentData10: [], | ||
| 35 | + roleShow: '', /* 角色 */ | ||
| 36 | + roleSelectData: '', /* 选择的角色 */ | ||
| 37 | + }; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + onInit() { | ||
| 41 | + const sActiveId = this.props.app.currentPane.formId; | ||
| 42 | + const { formSrcRoute } = this.props; | ||
| 43 | + const url = `${config.server_host}configform/getConfigformData/${sActiveId}?sModelsId=${sActiveId}&sName=${formSrcRoute}`; | ||
| 44 | + const { token } = this.props.app; | ||
| 45 | + const options = { | ||
| 46 | + method: 'GET', | ||
| 47 | + headers: { | ||
| 48 | + 'Content-Type': 'application/json', | ||
| 49 | + authorization: token, | ||
| 50 | + }, | ||
| 51 | + }; | ||
| 52 | + | ||
| 53 | + const originData = {}; | ||
| 54 | + fetch(url, options).then(response => response.json()).then((json) => { | ||
| 55 | + if (json.code === 1) { | ||
| 56 | + const data = json.dataset.rows[0]; | ||
| 57 | + this.setState({ modalData: data }); | ||
| 58 | + Object.keys(data).forEach((child) => { | ||
| 59 | + const spitArr = commonUtils.isNotEmptyObject(child) ? child.split('_') : []; | ||
| 60 | + /* 数据增加key属性用于table展示 */ | ||
| 61 | + for (const item of data[child]) { | ||
| 62 | + item.key = item.sId; | ||
| 63 | + } | ||
| 64 | + originData[`modalContentData_${spitArr[1]}`] = data[child]; | ||
| 65 | + }); | ||
| 66 | + this.setState({ ...originData }, () => { this.handleClick(); }); | ||
| 67 | + } else { | ||
| 68 | + // console.log(json.msg); | ||
| 69 | + } | ||
| 70 | + }); | ||
| 71 | + if (this.props.app.userinfo.sType === 'sysadmin') { | ||
| 72 | + const chooseRole = commonFunc.showMessage(this.props.app.commonConst, 'chooseRole');/* 选择角色 */ | ||
| 73 | + const chooseOneRole = commonFunc.showMessage(this.props.app.commonConst, 'chooseOneRole');/* 请选择一个角色 */ | ||
| 74 | + const roleUrl = `${config.server_host}configform/getLogininfosupplygroup?sModelsId=${sActiveId}&sName=${formSrcRoute}`; | ||
| 75 | + /* 获取角色下拉 */ | ||
| 76 | + fetch(roleUrl, options).then(response => response.json()).then((json) => { | ||
| 77 | + if (json.code === 1) { | ||
| 78 | + const data = json.dataset.rows; | ||
| 79 | + const oPtinon = []; | ||
| 80 | + for (const child of data) { | ||
| 81 | + oPtinon.push(<Option key={child.sId} value={child.sId}>{child.sName}</Option>); | ||
| 82 | + } | ||
| 83 | + const roleShow = ( | ||
| 84 | + <Alert | ||
| 85 | + message={( | ||
| 86 | + <div className={styles.affixMenuShow}> | ||
| 87 | + <span>{chooseRole}</span> | ||
| 88 | + <Select | ||
| 89 | + style={{ width: 'calc(100% - 58px)' }} | ||
| 90 | + filterOption={(input, option) => | ||
| 91 | + option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} | ||
| 92 | + onChange={e => this.handleSelectChange(e)} | ||
| 93 | + placeholder={chooseOneRole} | ||
| 94 | + > | ||
| 95 | + {oPtinon} | ||
| 96 | + </Select> | ||
| 97 | + </div> | ||
| 98 | + | ||
| 99 | + )} | ||
| 100 | + type="info" | ||
| 101 | + showIcon | ||
| 102 | + /> | ||
| 103 | + ); | ||
| 104 | + this.setState({ roleShow }); | ||
| 105 | + } else { | ||
| 106 | + // console.log(json.msg); | ||
| 107 | + } | ||
| 108 | + }); | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + onCheckChange = (e) => { | ||
| 113 | + this.setState({ | ||
| 114 | + indeterminate: false, | ||
| 115 | + checkValue: e.target.checked ? true : '', | ||
| 116 | + }); | ||
| 117 | + }; | ||
| 118 | + | ||
| 119 | + onCheckAll = (e, name, count, configId) => { | ||
| 120 | + const data = JSON.parse(JSON.stringify(this.state.modalData[name] || [])); | ||
| 121 | + const temp = JSON.parse(JSON.stringify(this.state[`modalContentData${count}`] || [])); | ||
| 122 | + const config = JSON.parse(JSON.stringify(this.state[`modalContentData_${configId}`] || [])); | ||
| 123 | + data.forEach((item, idx) => { | ||
| 124 | + data[idx].bVisible = e.target.checked; | ||
| 125 | + }); | ||
| 126 | + temp.forEach((item, idx) => { | ||
| 127 | + temp[idx].bVisible = e.target.checked; | ||
| 128 | + }); | ||
| 129 | + config.forEach((item, idx) => { | ||
| 130 | + config[idx].bVisible = e.target.checked; | ||
| 131 | + }); | ||
| 132 | + this.setState({ | ||
| 133 | + modalData: { ...this.state.modalData, [name]: data }, | ||
| 134 | + [`modalContentData${count}`]: temp, | ||
| 135 | + [`modalContentData_${configId}`]: config, | ||
| 136 | + }); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + handleClick=() => { | ||
| 140 | + const { sModelsId } = this.props; | ||
| 141 | + const addStateData = {}; | ||
| 142 | + const sessionKeys = Object.keys(sessionStorage); /* 找到配置 */ | ||
| 143 | + for (const key of sessionKeys) { /* 通过缓存中key的name匹配config配置,通过config配置获取配置sId,通过配置sId在state中找到对应的数据集 */ | ||
| 144 | + const keyArr = commonUtils.isNotEmptyObject(key) ? key.split('_') : []; | ||
| 145 | + if (commonUtils.isNotEmptyArr(keyArr) && sModelsId === keyArr[0]) { /* 防止多页签name名重复导致缓存匹配错误 */ | ||
| 146 | + const tableSid = keyArr[1]; /* 取表名称 */ | ||
| 147 | + if (tableSid) { | ||
| 148 | + let { [`modalContentData_${tableSid}`]: tableData } = this.state; | ||
| 149 | + if (addStateData[`modalContentData_${tableSid}`]) { | ||
| 150 | + tableData = addStateData[`modalContentData_${tableSid}`]; | ||
| 151 | + } else { | ||
| 152 | + tableData = JSON.parse(JSON.stringify(tableData)); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + /* 取缓存中的数据 */ | ||
| 156 | + if (commonUtils.isJSON(sessionStorage[key]) && JSON.parse(sessionStorage[key]).length > 0) { | ||
| 157 | + const sessionData = JSON.parse(sessionStorage[key]); | ||
| 158 | + if (commonUtils.isNotEmptyArr(sessionData) && commonUtils.isNotEmptyArr(tableData) && key.indexOf('headerColumns') === -1) { | ||
| 159 | + tableData.forEach((item, index) => { | ||
| 160 | + const iIndex = sessionData.findIndex(session => session.dataIndex === item.sName); | ||
| 161 | + if (iIndex > -1) { | ||
| 162 | + const addState = {}; | ||
| 163 | + if (addState.iFitWidth !== sessionData[iIndex].width) { | ||
| 164 | + addState.iFitWidth = sessionData[iIndex].width; | ||
| 165 | + tableData[index] = { ...tableData[index], ...addState }; | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + }); | ||
| 169 | + } | ||
| 170 | + if (key === `${sModelsId}_${tableSid}_headerColumns` || key === `${sModelsId}_${tableSid}_info_headerColumns`) { | ||
| 171 | + const sessionData = JSON.parse(sessionStorage[key]); | ||
| 172 | + const iOrderSort = tableData.map(item => item.iOrder).sort((a, b) => a - b); | ||
| 173 | + const obj = {}; | ||
| 174 | + sessionData.forEach((item, idx) => { | ||
| 175 | + obj[item] = iOrderSort[idx]; | ||
| 176 | + }); | ||
| 177 | + tableData.forEach((item, idx) => { | ||
| 178 | + tableData[idx].iOrder = obj[item.sName]; | ||
| 179 | + }); | ||
| 180 | + tableData.sort((a, b) => a.iOrder - b.iOrder) | ||
| 181 | + tableData.forEach((item, idx) => { | ||
| 182 | + tableData[idx].iOrder = idx + 1; | ||
| 183 | + }) | ||
| 184 | + } | ||
| 185 | + addStateData[`modalContentData_${tableSid}`] = tableData; | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + this.setState({ ...addStateData }); | ||
| 191 | + }; | ||
| 192 | + | ||
| 193 | + handlePpopUpPaneCancel=() => { | ||
| 194 | + this.setState({ modalVisible: false }); | ||
| 195 | + }; | ||
| 196 | + | ||
| 197 | + handleChange=(value, count, record, name) => { | ||
| 198 | + const data = JSON.parse(JSON.stringify(this.state[`modalContentData_${count}`])); | ||
| 199 | + const dataMap = data.filter(item => (item.key === record.key))[0]; | ||
| 200 | + if (dataMap !== undefined) { | ||
| 201 | + dataMap[`${name}`] = value; | ||
| 202 | + } | ||
| 203 | + this.setState({ [`modalContentData_${count}`]: data }); | ||
| 204 | + }; | ||
| 205 | + | ||
| 206 | + handleSelectChange=(value) => { | ||
| 207 | + /* 调用接口 */ | ||
| 208 | + const { formSrcRoute } = this.props; | ||
| 209 | + this.setState({ roleSelectData: value }); | ||
| 210 | + const sActiveId = this.props.app.currentPane.formId; | ||
| 211 | + const url = `${config.server_host}configform/getConfigformData/${sActiveId}?roleSelectId=${value}&&sModelsId=${sActiveId}&sName=${formSrcRoute}`; | ||
| 212 | + const { token } = this.props.app; | ||
| 213 | + const options = { | ||
| 214 | + method: 'GET', | ||
| 215 | + headers: { | ||
| 216 | + 'Content-Type': 'application/json', | ||
| 217 | + authorization: token, | ||
| 218 | + }, | ||
| 219 | + }; | ||
| 220 | + fetch(url, options).then(response => response.json()).then((json) => { | ||
| 221 | + if (json.code === 1) { | ||
| 222 | + const data = json.dataset.rows[0]; | ||
| 223 | + this.setState({ modalData: data }); | ||
| 224 | + Object.keys(data).forEach((child) => { | ||
| 225 | + const spitArr = commonUtils.isNotEmptyObject(child) ? child.split('_') : []; /* 取菜单ID */ | ||
| 226 | + /* 数据增加key属性用于table展示 */ | ||
| 227 | + for (const item of data[child]) { | ||
| 228 | + item.key = item.sId; | ||
| 229 | + } | ||
| 230 | + this.setState({ [`modalContentData_${spitArr[1]}`]: data[child] }); | ||
| 231 | + }); | ||
| 232 | + } else { | ||
| 233 | + // console.log(json.msg); | ||
| 234 | + } | ||
| 235 | + }); | ||
| 236 | + }; | ||
| 237 | + | ||
| 238 | + handleOk=() => { | ||
| 239 | + const { formSrcRoute } = this.props; | ||
| 240 | + const sActiveId = this.props.app.currentPane.formId; | ||
| 241 | + const url = `${config.server_host}configform/sHandleConfigform?sModelsId=${sActiveId}&sName=${formSrcRoute}`; | ||
| 242 | + const { token } = this.props.app; | ||
| 243 | + const { roleShow, roleSelectData, modalData } = this.state; | ||
| 244 | + // const pleaseChooseRole = commonFunc.showMessage(this.props.app.commonConst, 'pleaseChooseRole');/* 请选择角色 */ | ||
| 245 | + // if (roleShow !== '' && roleSelectData === '') { | ||
| 246 | + // message.warning(pleaseChooseRole); | ||
| 247 | + // return; | ||
| 248 | + // } | ||
| 249 | + const submitData = {}; | ||
| 250 | + // let count = 1; | ||
| 251 | + let num = 0; | ||
| 252 | + | ||
| 253 | + Object.keys(modalData).forEach((item) => { | ||
| 254 | + const splitArr = commonUtils.isNotEmptyObject(item) && commonUtils.isNotEmptyArr(item.split('_')) ? item.split('_') : []; | ||
| 255 | + const configId = commonUtils.isNotEmptyArr(splitArr) ? splitArr[1] : ''; | ||
| 256 | + const { [`modalContentData_${configId}`]: tableData } = this.state; | ||
| 257 | + if (commonUtils.isNotEmptyArr(tableData) && tableData.length > 0) { | ||
| 258 | + num = 0; | ||
| 259 | + for (const child of tableData) { | ||
| 260 | + if (num === 0) { | ||
| 261 | + submitData[`${child.sParentId}`] = []; | ||
| 262 | + } | ||
| 263 | + // if (child.bVisible) { | ||
| 264 | + // submitData[`${child.sParentId}`].push(child); | ||
| 265 | + // } | ||
| 266 | + submitData[`${child.sParentId}`].push(child); | ||
| 267 | + num += 1; | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + }); | ||
| 271 | + | ||
| 272 | + let value = ''; | ||
| 273 | + if (roleShow !== '') { | ||
| 274 | + value = { | ||
| 275 | + handleType: 'group', | ||
| 276 | + sJurisdictionClassifyId: roleSelectData, | ||
| 277 | + handleData: submitData, | ||
| 278 | + bDefault: commonUtils.isEmpty(roleSelectData) ? true : this.state.checkValue, /* bDefault为true代表更新到后台配置库里 */ | ||
| 279 | + }; | ||
| 280 | + } else { | ||
| 281 | + value = { | ||
| 282 | + handleType: 'user', | ||
| 283 | + handleData: submitData, | ||
| 284 | + }; | ||
| 285 | + } | ||
| 286 | + const options = { | ||
| 287 | + method: 'POST', | ||
| 288 | + headers: { | ||
| 289 | + 'Content-Type': 'application/json', | ||
| 290 | + authorization: token, | ||
| 291 | + }, | ||
| 292 | + body: JSON.stringify(value), | ||
| 293 | + }; | ||
| 294 | + const { dispatch } = this.props; | ||
| 295 | + fetch(url, options).then(response => response.json()).then((json) => { | ||
| 296 | + if (json.code === 1) { | ||
| 297 | + message.success(json.msg); | ||
| 298 | + | ||
| 299 | + // 清除缓存 | ||
| 300 | + if(sessionStorage !== undefined) { | ||
| 301 | + const sessionKeys = Object.keys(sessionStorage); /* 找到配置 */ | ||
| 302 | + for (const key of sessionKeys) { | ||
| 303 | + if(key !== 'feedbackBtnRecord') { | ||
| 304 | + sessionStorage.removeItem(key); | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + this.handlePpopUpPaneCancel(); | ||
| 310 | + } else if (json.code === -2) { | ||
| 311 | + dispatch({ type: 'app/throwError', payload: json }); | ||
| 312 | + } | ||
| 313 | + }); | ||
| 314 | + }; | ||
| 315 | + | ||
| 316 | + renderColumns=(text, name, count, record) => { | ||
| 317 | + if (name === 'bVisible' || name === 'bReadonly') { | ||
| 318 | + return <Checkbox defaultChecked={text} checked={text} onChange={e => this.handleChange(e.target.checked, count, record, name)} />; | ||
| 319 | + } else { | ||
| 320 | + let flag = false; | ||
| 321 | + if (name === 'showName' || name === 'sName') { | ||
| 322 | + flag = true; | ||
| 323 | + } | ||
| 324 | + return <Input value={text} disabled={flag} onChange={e => this.handleChange(e.target.value, count, record, name)} />; | ||
| 325 | + } | ||
| 326 | + }; | ||
| 327 | + | ||
| 328 | + openModal = () => { | ||
| 329 | + this.setState({ | ||
| 330 | + modalVisible: true, | ||
| 331 | + }) | ||
| 332 | + this.onInit(); | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + render() { | ||
| 336 | + const { modalData, roleShow } = this.state; | ||
| 337 | + const { app, sTabId, sModelsType } = this.props; | ||
| 338 | + // const { userinfo } = app; | ||
| 339 | + const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0]; | ||
| 340 | + const modalContent = []; | ||
| 341 | + let count = 1; | ||
| 342 | + let checkBoxShow = ''; | ||
| 343 | + let checkAll = ''; | ||
| 344 | + const columniOrder = commonFunc.showMessage(app.commonConst, 'columniOrder');/* 排序 */ | ||
| 345 | + const columnShowName = commonFunc.showMessage(app.commonConst, 'columnShowName');/* 显示名 */ | ||
| 346 | + // const columnChinese = commonFunc.showMessage(app.commonConst, 'columnChinese');/* 显示名 */ | ||
| 347 | + // const columnEnglish = commonFunc.showMessage(app.commonConst, 'columnEnglish');/* 显示名 */ | ||
| 348 | + // const columnBig5 = commonFunc.showMessage(app.commonConst, 'columnBig5');/* 显示名 */ | ||
| 349 | + const columniFitWidth = commonFunc.showMessage(app.commonConst, 'columniFitWidth');/* 宽度 */ | ||
| 350 | + const columnbVisible = commonFunc.showMessage(app.commonConst, 'columnbVisible');/* 是否显示 */ | ||
| 351 | + const columnsName = commonFunc.showMessage(app.commonConst, 'columnsName');/* 字段名 */ | ||
| 352 | + const isDefault = commonFunc.showMessage(app.commonConst, 'isDefault');/* 是否设置默认 */ | ||
| 353 | + // eslint-disable-next-line no-unused-vars | ||
| 354 | + Object.keys(modalData).forEach((child, i) => { | ||
| 355 | + const splitArr = commonUtils.isNotEmptyObject(child) && commonUtils.isNotEmptyArr(child.split('_')) ? child.split('_') : []; | ||
| 356 | + const configName = commonUtils.isNotEmptyArr(splitArr) ? splitArr[0] : ''; | ||
| 357 | + const configId = commonUtils.isNotEmptyArr(splitArr) ? splitArr[1] : ''; | ||
| 358 | + let childTable = ''; | ||
| 359 | + let dataSource = []; | ||
| 360 | + if (commonUtils.isNotEmptyObject(configId)) { /* 从缓存中取宽度 */ | ||
| 361 | + dataSource = this.state[`modalContentData_${configId}`]; | ||
| 362 | + } else { | ||
| 363 | + dataSource = this.state[`modalContentData${count}`]; | ||
| 364 | + } | ||
| 365 | + const columns = [{ | ||
| 366 | + title: columniOrder, | ||
| 367 | + dataIndex: 'iOrder', | ||
| 368 | + render: (text, record) => this.renderColumns(text, 'iOrder', configId, record), | ||
| 369 | + width: 40, | ||
| 370 | + }, { | ||
| 371 | + title: columniFitWidth, | ||
| 372 | + dataIndex: 'iFitWidth', | ||
| 373 | + render: (text, record) => this.renderColumns(text, 'iFitWidth', configId, record), | ||
| 374 | + width: 40, | ||
| 375 | + }, { | ||
| 376 | + title: columnShowName, | ||
| 377 | + dataIndex: 'showName', | ||
| 378 | + render: (text, record) => this.renderColumns(text, 'showName', configId, record), | ||
| 379 | + width: 100, | ||
| 380 | + }]; | ||
| 381 | + if (this.props.app.userinfo.sType === 'sysadmin' || true) { /* 管理员显示字段名 */ | ||
| 382 | + columns.push({ | ||
| 383 | + title: columnsName, | ||
| 384 | + dataIndex: 'sName', | ||
| 385 | + render: (text, record) => this.renderColumns(text, 'sName', configId, record), | ||
| 386 | + width: 80, | ||
| 387 | + }); | ||
| 388 | + } | ||
| 389 | + if (this.props.app.userinfo.sType === 'sysadmin' || true) { /* 管理员设置列是否显示 */ | ||
| 390 | + columns.push({ | ||
| 391 | + title: columnbVisible, | ||
| 392 | + dataIndex: 'bVisible', | ||
| 393 | + render: (text, record) => this.renderColumns(text, 'bVisible', configId, record), | ||
| 394 | + width: 80, | ||
| 395 | + }); | ||
| 396 | + } | ||
| 397 | + if (this.props.app.userinfo.sType === 'sysadmin') { /* 配置选择框 */ | ||
| 398 | + // checkBoxShow = <span>{isDefault} <Checkbox defaultChecked={false} onChange={this.onCheckChange} /></span>; | ||
| 399 | + checkBoxShow = ''; | ||
| 400 | + let visible = 0; | ||
| 401 | + const len = dataSource ? dataSource.length : 0; | ||
| 402 | + for (let i = 0; i < len; i += 1) { | ||
| 403 | + if (dataSource[i].bVisible) { | ||
| 404 | + visible += 1; | ||
| 405 | + } | ||
| 406 | + } | ||
| 407 | + checkAll = <span>全选 <Checkbox indeterminate={visible !== len && visible} defaultChecked={visible === len} onChange={e => this.onCheckAll(e, child, count, configId)} /></span>; | ||
| 408 | + } | ||
| 409 | + if (this.props.app.userinfo.sType === 'sysadmin' || true) { /* 管理员设置列是否可修改 */ | ||
| 410 | + columns.push({ | ||
| 411 | + title: '是否只读', | ||
| 412 | + dataIndex: 'bReadonly', | ||
| 413 | + render: (text, record) => this.renderColumns(text, 'bReadonly', configId, record), | ||
| 414 | + width: 80, | ||
| 415 | + }); | ||
| 416 | + } | ||
| 417 | + if (this.props.app.userinfo.sType === 'sysadmin' || true) { /* 管理员设置列颜色 */ | ||
| 418 | + columns.push({ | ||
| 419 | + title: '字体颜色', | ||
| 420 | + dataIndex: 'sFontColor', | ||
| 421 | + render: (text, record) => this.renderColumns(text, 'sFontColor', configId, record), | ||
| 422 | + width: 80, | ||
| 423 | + }); | ||
| 424 | + } | ||
| 425 | + | ||
| 426 | + /* 动态列解析 将字段表头换成 动态列返的 */ | ||
| 427 | + // if (!(commonUtils.isNotEmptyObject(sModelsType) && !sModelsType.includes('dynamicList'))) { | ||
| 428 | + // const { slaveConfig } = this.props; | ||
| 429 | + // const columnConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.showName !== '' && !(item.sControlName !== '' && item.sControlName.indexOf('Btn') > -1)) : []; | ||
| 430 | + // /* 动态列 需要将中文名称替换掉 */ | ||
| 431 | + // if (commonUtils.isNotEmptyArr(columnConfig) && dataSource && dataSource.length === columnConfig.length) { | ||
| 432 | + // columnConfig.forEach((item, iIndex) => { | ||
| 433 | + // // dataSource[iIndex].sName = item.sName; | ||
| 434 | + // dataSource[iIndex].showName = item.showName; | ||
| 435 | + // dataSource[iIndex].sChinese = item.sChinese; | ||
| 436 | + // }); | ||
| 437 | + // } | ||
| 438 | + // } | ||
| 439 | + | ||
| 440 | + const dataSource_dep = lodash.cloneDeep(dataSource); | ||
| 441 | + if (dataSource_dep && dataSource_dep.length) { | ||
| 442 | + let min = 0; | ||
| 443 | + for (let i = 0; i < dataSource_dep.length - 1; i += 1) { | ||
| 444 | + min = i; | ||
| 445 | + for (let j = i + 1; j < dataSource_dep.length; j += 1) { | ||
| 446 | + if (Number(dataSource_dep[min].iOrder) > Number(dataSource_dep[j].iOrder)) { | ||
| 447 | + const temp = dataSource_dep[min]; | ||
| 448 | + dataSource_dep[min] = dataSource_dep[j]; | ||
| 449 | + dataSource_dep[j] = temp; | ||
| 450 | + } | ||
| 451 | + } | ||
| 452 | + } | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + childTable = ( | ||
| 456 | + <TabPane tab={configName} key={count}> | ||
| 457 | + <div key={count} className={styles.affixMenuTableAll}> | ||
| 458 | + {checkBoxShow} | ||
| 459 | + | ||
| 460 | + {checkAll} | ||
| 461 | + <Table | ||
| 462 | + bordered | ||
| 463 | + columns={columns} | ||
| 464 | + dataSource={dataSource_dep} | ||
| 465 | + pagination={false} | ||
| 466 | + scroll={{ y: 310 }} | ||
| 467 | + className={styles.affixMenuTable} | ||
| 468 | + /> | ||
| 469 | + </div> | ||
| 470 | + </TabPane> | ||
| 471 | + ); | ||
| 472 | + modalContent.push(childTable); | ||
| 473 | + count += 1; | ||
| 474 | + }); | ||
| 475 | + return ( | ||
| 476 | + <div> | ||
| 477 | + <Affix offsetTop={this.state.top} style={{ position: 'absolute', top: 50, left: 1000 }}> | ||
| 478 | + <div className={styles.affixMenu}> | ||
| 479 | + <SvgIcon iconClass="setting" fill="#fff" size="16" onClick={this.openModal.bind(this)} /> | ||
| 480 | + {(pane?.notCurrentPane ? false : this.state.modalVisible) ? | ||
| 481 | + <AntdDraggableModal | ||
| 482 | + title={Object.keys(this.state.modalPanel).length > 0 ? this.state.modalPanel.title : ''} | ||
| 483 | + visible={pane?.notCurrentPane ? false : this.state.modalVisible} | ||
| 484 | + onCancel={this.handlePpopUpPaneCancel.bind(this)} | ||
| 485 | + onOk={this.handleOk.bind(this)} | ||
| 486 | + width={1000} | ||
| 487 | + > | ||
| 488 | + <div className={styles.modalsContent}> | ||
| 489 | + { | ||
| 490 | + roleShow !== '' ? roleShow : '' | ||
| 491 | + } | ||
| 492 | + <div id="slaveTabs"> | ||
| 493 | + <Tabs className={styles.slaveTabs}> | ||
| 494 | + {modalContent} | ||
| 495 | + </Tabs> | ||
| 496 | + </div> | ||
| 497 | + </div> | ||
| 498 | + </AntdDraggableModal> | ||
| 499 | + : ''} | ||
| 500 | + </div> | ||
| 501 | + </Affix> | ||
| 502 | + </div> | ||
| 503 | + ); | ||
| 504 | + } | ||
| 505 | +} | ||
| 506 | + | ||
| 507 | +export default AffixMenuComponent; |
src/components/Common/AntdDraggableDiv.js
0 → 100644
| 1 | +import React, { Component } from 'react'; | ||
| 2 | +import styles from '../../index.less'; | ||
| 3 | + | ||
| 4 | +export default class AntdDraggableDiv extends Component { | ||
| 5 | + constructor(props) { | ||
| 6 | + super(props); | ||
| 7 | + this.state = { | ||
| 8 | + translateX: 0, | ||
| 9 | + translateY: 0, | ||
| 10 | + }; | ||
| 11 | + this.moving = false; | ||
| 12 | + this.lastX = null; | ||
| 13 | + this.lastY = null; | ||
| 14 | + window.onmouseup = e => this.onMouseUp(e); | ||
| 15 | + window.onmousemove = e => this.onMouseMove(e); | ||
| 16 | + } | ||
| 17 | + onMouseDown(e) { | ||
| 18 | + e.stopPropagation(); | ||
| 19 | + this.moving = true; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + onMouseUp() { | ||
| 23 | + this.moving = false; | ||
| 24 | + this.lastX = null; | ||
| 25 | + this.lastY = null; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + onMouseMove(e) { | ||
| 29 | + if (this.moving) { | ||
| 30 | + this.onMove(e); | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + onMove(e) { | ||
| 35 | + if (this.lastX && this.lastY) { | ||
| 36 | + const dx = e.clientX - this.lastX; | ||
| 37 | + const dy = e.clientY - this.lastY; | ||
| 38 | + this.setState({ translateX: this.state.translateX + dx, translateY: this.state.translateY + dy }); | ||
| 39 | + } | ||
| 40 | + this.lastX = e.clientX; | ||
| 41 | + this.lastY = e.clientY; | ||
| 42 | + } | ||
| 43 | + render() { | ||
| 44 | + const { children, draggableDivClassName } = this.props; | ||
| 45 | + return ( | ||
| 46 | + <div | ||
| 47 | + className={draggableDivClassName} | ||
| 48 | + onMouseDown={e => this.onMouseDown(e)} | ||
| 49 | + style={{ transform: `translateX(${this.state.translateX}px)translateY(${this.state.translateY}px)` }} | ||
| 50 | + > | ||
| 51 | + {children} | ||
| 52 | + <div className={styles.antModal} /> | ||
| 53 | + </div> | ||
| 54 | + ); | ||
| 55 | + } | ||
| 56 | +} |
src/components/Common/AntdDraggableModal.js
0 → 100644
| 1 | +import React from 'react'; | ||
| 2 | +import { Modal } from 'antd'; | ||
| 3 | +import './AntdDraggableModal/antDraggle.less'; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +class AntDraggableModal extends React.Component { | ||
| 7 | + constructor(props) { | ||
| 8 | + super(props); | ||
| 9 | + this.simpleClass = Math.random().toString(36).substring(2); | ||
| 10 | + this.state = { | ||
| 11 | + isDrop: false, | ||
| 12 | + // eslint-disable-next-line react/no-unused-state | ||
| 13 | + offsetLeft: 0, | ||
| 14 | + // eslint-disable-next-line react/no-unused-state | ||
| 15 | + offsetTop: 0, | ||
| 16 | + realizeHeight: 0, | ||
| 17 | + modalHeight: 0, | ||
| 18 | + }; | ||
| 19 | + this.deltaX = 0; | ||
| 20 | + this.deltaY = 0; | ||
| 21 | + this.contain = {}; | ||
| 22 | + this.antModal = {}; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + // eslint-disable-next-line react/sort-comp | ||
| 26 | + handleMove = (event) => { | ||
| 27 | + if (this.state.isDrop) { | ||
| 28 | + this.antModal.style.margin = 0; | ||
| 29 | + this.antModal.style.padding = 0; | ||
| 30 | + const left = event.pageX - this.deltaX; | ||
| 31 | + const top = event.pageY - this.deltaY; | ||
| 32 | + // if (left < 0) { | ||
| 33 | + // left = 0; | ||
| 34 | + // } else if (left > (document.offsetWidth - this.antModal.offsetWidth)) { | ||
| 35 | + // left = document.offsetWidth - this.antModal.offsetWidth; | ||
| 36 | + // } | ||
| 37 | + // if (top < 0) { | ||
| 38 | + // top = 0; | ||
| 39 | + // } else if (top > (document.offsetHeight - this.antModal.offsetHeight)) { | ||
| 40 | + // top = document.offsetHeight - this.antModal.offsetHeight; | ||
| 41 | + // } | ||
| 42 | + this.antModal.style.left = `${left}px`; | ||
| 43 | + this.antModal.style.top = `${top}px`; | ||
| 44 | + } | ||
| 45 | + }; | ||
| 46 | + | ||
| 47 | + addResizeListener = () => { | ||
| 48 | + document.addEventListener('mousedown', this.handleResize); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + handleResize = (downEl) => { | ||
| 52 | + const ableList = ['resize-s', 'resize-sw', 'resize-se']; | ||
| 53 | + if (ableList.indexOf(downEl.target.className) === -1) { | ||
| 54 | + return; | ||
| 55 | + } | ||
| 56 | + // const modalContent = document.getElementsByClassName('ant-modal-content')[0]; | ||
| 57 | + const modalContent = downEl.target.parentNode.parentNode; | ||
| 58 | + const modalContentHeight = modalContent.offsetHeight; | ||
| 59 | + if (!this.state.modalHeight) { | ||
| 60 | + this.setState({ | ||
| 61 | + modalHeight: modalContentHeight, | ||
| 62 | + }); | ||
| 63 | + } | ||
| 64 | + const modalContentWidth = modalContent.offsetWidth; | ||
| 65 | + const modalContentLeft = modalContent.offsetLeft; | ||
| 66 | + let resizedHeight = 0; | ||
| 67 | + let resizeYPx = 0; | ||
| 68 | + let resizeXPx = 0; | ||
| 69 | + document.onmousemove = (moveEvent) => { | ||
| 70 | + resizeYPx = moveEvent.pageY - downEl.pageY; | ||
| 71 | + resizeXPx = moveEvent.pageX - downEl.pageX; | ||
| 72 | + resizedHeight = this.state.modalHeight + this.state.realizeHeight + resizeYPx; | ||
| 73 | + if (resizedHeight <= this.state.modalHeight) { | ||
| 74 | + return false; | ||
| 75 | + } | ||
| 76 | + switch (downEl.target.className) { | ||
| 77 | + case 'resize-s': | ||
| 78 | + modalContent.style.height = `${resizedHeight}px`; | ||
| 79 | + break; | ||
| 80 | + case 'resize-sw': | ||
| 81 | + modalContent.style.height = `${resizedHeight}px`; | ||
| 82 | + modalContent.style.width = `${modalContentWidth - resizeXPx}px`; | ||
| 83 | + modalContent.style.left = `${modalContentLeft + resizeXPx}px`; | ||
| 84 | + break; | ||
| 85 | + case 'resize-se': | ||
| 86 | + modalContent.style.height = `${resizedHeight}px`; | ||
| 87 | + modalContent.style.width = `${modalContentWidth + resizeXPx}px`; | ||
| 88 | + break; | ||
| 89 | + default: | ||
| 90 | + break; | ||
| 91 | + } | ||
| 92 | + }; | ||
| 93 | + document.onmouseup = () => { | ||
| 94 | + document.onmousemove = null; | ||
| 95 | + document.onmouseup = null; | ||
| 96 | + setTimeout(() => { | ||
| 97 | + // eslint-disable-next-line no-unused-expressions | ||
| 98 | + window.onSetTableKey && window.onSetTableKey(); | ||
| 99 | + }, 1000); | ||
| 100 | + if (this.state.realizeHeight + resizeYPx <= 0 && this.props.onSaveState) { | ||
| 101 | + this.setState({ | ||
| 102 | + realizeHeight: 0, | ||
| 103 | + }); | ||
| 104 | + this.props.onSaveState({ realizeHeight: this.state.realizeHeight }); | ||
| 105 | + return; | ||
| 106 | + } | ||
| 107 | + if (this.props.onSaveState && resizeYPx !== 0) { | ||
| 108 | + this.setState((prev) => { | ||
| 109 | + return { | ||
| 110 | + realizeHeight: prev.realizeHeight + resizeYPx, | ||
| 111 | + }; | ||
| 112 | + }); | ||
| 113 | + this.props.onSaveState({ realizeHeight: this.state.realizeHeight }); | ||
| 114 | + } | ||
| 115 | + }; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + initialEvent = (visible) => { | ||
| 119 | + const { title } = this.props; | ||
| 120 | + if (title && visible) { | ||
| 121 | + setTimeout(() => { | ||
| 122 | + window.removeEventListener('mouseup', this.removeUp, false); | ||
| 123 | + // eslint-disable-next-line prefer-destructuring | ||
| 124 | + this.contain = document.getElementsByClassName(this.simpleClass)[0]; | ||
| 125 | + // eslint-disable-next-line prefer-destructuring | ||
| 126 | + this.header = this.contain.getElementsByClassName('ant-modal-header')[0]; | ||
| 127 | + this.header.style.cursor = 'all-scroll'; | ||
| 128 | + // eslint-disable-next-line prefer-destructuring | ||
| 129 | + this.antModal = this.contain.getElementsByClassName('ant-modal')[0]; | ||
| 130 | + this.header.onmousedown = (e) => { | ||
| 131 | + const disx = e.pageX - this.antModal.offsetLeft; | ||
| 132 | + const disy = e.pageY - this.antModal.offsetTop; | ||
| 133 | + this.deltaX = disx; | ||
| 134 | + this.deltaY = disy; | ||
| 135 | + this.setState({ | ||
| 136 | + isDrop: true, | ||
| 137 | + }); | ||
| 138 | + document.body.onselectstart = () => false; | ||
| 139 | + window.addEventListener('mousemove', this.handleMove.bind(this), false); | ||
| 140 | + }; | ||
| 141 | + window.addEventListener('mouseup', this.removeUp, false); | ||
| 142 | + this.addResizeListener(); | ||
| 143 | + }, 0); | ||
| 144 | + } | ||
| 145 | + }; | ||
| 146 | + | ||
| 147 | + removeUp = () => { | ||
| 148 | + this.setState({ isDrop: false }); | ||
| 149 | + document.body.onselectstart = () => true; | ||
| 150 | + }; | ||
| 151 | + | ||
| 152 | + componentDidMount() { | ||
| 153 | + const { visible = false, open = false } = this.props; | ||
| 154 | + this.initialEvent(open || visible); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + componentWillUnmount() { | ||
| 158 | + window.removeEventListener('mousedown', this.handleResize, false); | ||
| 159 | + window.removeEventListener('mouseup', this.removeUp, false); | ||
| 160 | + if (this.props.onSaveState) { | ||
| 161 | + this.props.onSaveState({ realizeHeight: 0 }); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + render() { | ||
| 166 | + const { | ||
| 167 | + children, wrapClassName, pageLoading, forbidResize, ...other | ||
| 168 | + } = this.props; | ||
| 169 | + | ||
| 170 | + const wrapModalClassName = wrapClassName ? `${wrapClassName} ${this.simpleClass}` : `${this.simpleClass}`; | ||
| 171 | + return ( | ||
| 172 | + <Modal | ||
| 173 | + {...other} | ||
| 174 | + maskClosable={false} | ||
| 175 | + keyboard | ||
| 176 | + wrapClassName={wrapModalClassName} | ||
| 177 | + > | ||
| 178 | + {children} | ||
| 179 | + {!forbidResize && <div className="resize-s" />} | ||
| 180 | + {!forbidResize && <div className="resize-sw" />} | ||
| 181 | + {!forbidResize && <div className="resize-se" />} | ||
| 182 | + </Modal> | ||
| 183 | + ); | ||
| 184 | + } | ||
| 185 | +} | ||
| 186 | +export default AntDraggableModal; |
src/components/Common/AntdDraggableModal/antDraggle.less
0 → 100644
| 1 | +:global { | ||
| 2 | + .ant-modal-content{ | ||
| 3 | + .resize-s{ | ||
| 4 | + width: 100%; | ||
| 5 | + height: 5px; | ||
| 6 | + position: absolute; | ||
| 7 | + left: 0; | ||
| 8 | + bottom: 0; | ||
| 9 | + z-index: 10; | ||
| 10 | + cursor: s-resize; | ||
| 11 | + } | ||
| 12 | + .resize-sw, .resize-se{ | ||
| 13 | + width: 10px; | ||
| 14 | + height: 10px; | ||
| 15 | + position: absolute; | ||
| 16 | + bottom: 0; | ||
| 17 | + z-index: 10; | ||
| 18 | + } | ||
| 19 | + .resize-sw{ | ||
| 20 | + left: 0; | ||
| 21 | + cursor: sw-resize; | ||
| 22 | + } | ||
| 23 | + .resize-se{ | ||
| 24 | + right: 0; | ||
| 25 | + cursor: se-resize; | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + |
src/components/Common/CommonBase.js
0 → 100644
| 1 | +/* eslint-disable */ | ||
| 2 | +/* eslint-disable prefer-destructuring */ | ||
| 3 | +/** | ||
| 4 | + * Created by mar105 on 2019-02-15. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import React, { Component } from 'react'; | ||
| 8 | +import { message } from '@/utils/common/message'; | ||
| 9 | +import moment from 'moment'; | ||
| 10 | +import lodash from 'lodash'; | ||
| 11 | +import commonConfig from '../../utils/config'; | ||
| 12 | +import * as commonUtils from '../../utils/utils'; | ||
| 13 | +import * as commonServices from '../../services/services'; | ||
| 14 | +import * as commonFunc from './commonFunc'; | ||
| 15 | +import * as commonBusiness from './commonBusiness'; /* 通用单据方法 */ | ||
| 16 | +import instructSet from "@/components/Common/CommonInstructSet"; | ||
| 17 | + | ||
| 18 | +export default (ChildComponent) => { | ||
| 19 | + return class extends Component { | ||
| 20 | + constructor(props) { | ||
| 21 | + super(props); | ||
| 22 | + this.state = { | ||
| 23 | + pageLoading: true, | ||
| 24 | + token: props.routing ? props.formRoute === '/indexOee' ? props.app.token : '' : props.app.token, // /indexOee为oee报产页面 | ||
| 25 | + sTabId: this.handleConfigValue('key', props.formRoute), // type无论是indexoee和一般的都使用eles | ||
| 26 | + sSrcModelsId: props.app.currentPane.sSrcModelsId, /* 获取配置数据用的modelId */ | ||
| 27 | + sModelsId: props.routing ? props.sModelsId : (commonUtils.isNotEmptyStr(props.formRoute) && props.formRoute.indexOf('/indexOee') > -1) ? props.sModelsId : this.handleConfigValue('formId'), /* 获取配置数据用的modelId */ | ||
| 28 | + formRoute: props.routing ? props.formRoute : (commonUtils.isNotEmptyStr(props.formRoute) && props.formRoute.indexOf('/indexOee') > -1) ? props.formRoute : this.handleConfigValue('route'), /* 组件名: 路由名称 */ | ||
| 29 | + formSrcRoute: props.routing ? props.routing.pathname.replace('/', '') : commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase() === '/loginoee' ? '/commonAuto' : '', | ||
| 30 | + sModelsType: this.handleConfigValue('sModelsType', props.formRoute), /* 组件名: 路由名称 */ | ||
| 31 | + bFastOrderView: this.handleConfigValue('bFastOrderView'), /* 是否显示快速下单 */ | ||
| 32 | + formData: [], /* 所有配置 */ | ||
| 33 | + gdsformconst: [], /* 获取配置常量 */ | ||
| 34 | + gdsjurisdiction: [], /* 获取配置权限 */ | ||
| 35 | + currentId: (commonUtils.isNotEmptyStr(props.formRoute) && props.formRoute.indexOf('/indexOee') > -1) ? props.checkedId : props.app.currentPane.checkedId, /* 当前数据的Id */ | ||
| 36 | + selectedRowKeys: [], /* 已选择的数据行(数据格式:数组) */ | ||
| 37 | + clearArray: [], /* table清除数组 */ | ||
| 38 | + calculated: false, // 工单是否经过计算 | ||
| 39 | + iPageSize: commonConfig.pageSize, /* 默认config配置的pageSize */ | ||
| 40 | + showTableName: false, // 展示控件名称 | ||
| 41 | + noChangeDiffMap: props.noChangeDiffMap | ||
| 42 | + }; | ||
| 43 | + this.sDateFormat = 'YYYY-MM-DD'; | ||
| 44 | + window.addEventListener('beforeunload', this.beforeunload); | ||
| 45 | + window.addEventListener('unload', this.unload); | ||
| 46 | + window.addEventListener('keydown', this.handleF9KeyPress); | ||
| 47 | + console.log('sSrcModelsId', this.state.sSrcModelsId); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + async componentWillMount() { | ||
| 51 | + if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase() !== '/loginoee') { | ||
| 52 | + if (this.props.app.webSocket === null || this.props.app.webSocket.readyState !== WebSocket.OPEN) { | ||
| 53 | + this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch: this.props.dispatch } }); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + /* 获取配置 */ | ||
| 57 | + this.mounted = true; | ||
| 58 | + const { token, sModelsId, formSrcRoute } = this.state; | ||
| 59 | + let { iPageSize } = this.state; | ||
| 60 | + const config = await commonUtils.getStoreDropDownData(sModelsId, '', ''); | ||
| 61 | + if (commonUtils.isEmpty(config)) { | ||
| 62 | + const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; | ||
| 63 | + const configReturn = (await commonServices.getService(token, configUrl)).data; | ||
| 64 | + if (configReturn.code === 1) { | ||
| 65 | + const [configData] = configReturn.dataset.rows; | ||
| 66 | + const { formData } = configData; | ||
| 67 | + if (commonUtils.isNotEmptyArr(formData)) { | ||
| 68 | + if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) { | ||
| 69 | + iPageSize = formData[0].iPageSize;/* 后台设定页数 */ | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + if (this.mounted) { | ||
| 73 | + commonUtils.setStoreDropDownData(sModelsId, '', '', configData); | ||
| 74 | + this.handleSaveState({ ...configData, iPageSize }); | ||
| 75 | + } | ||
| 76 | + } else { | ||
| 77 | + this.getServiceError(configReturn); | ||
| 78 | + } | ||
| 79 | + } else { | ||
| 80 | + this.handleSaveState({ ...config }); | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + componentDidMount() { | ||
| 85 | + if (this.state.sTabId && !this.state.noChangeDiffMap) { | ||
| 86 | + this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: this.state.sTabId, changed: false } }); | ||
| 87 | + } | ||
| 88 | + if (this.state.formRoute && this.state.formRoute.indexOf('/indexOee') > -1 && this.state.sModelsId && this.state.formRoute) { | ||
| 89 | + const sModelData = { | ||
| 90 | + sModelsId: this.state.sModelsId, | ||
| 91 | + formRoute: this.state.formRoute, | ||
| 92 | + }; | ||
| 93 | + localStorage.setItem('oeeModelData', JSON.stringify(sModelData)); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /* 关闭浏览器前进行提示 */ | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + shouldComponentUpdate(nextProps, nextState) { | ||
| 100 | + // // 修改或新增后的保存功能 | ||
| 101 | + // if (nextState.enabled && !nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) { | ||
| 102 | + // this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: true } }); | ||
| 103 | + // } | ||
| 104 | + // if (!nextState.enabled && nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) { | ||
| 105 | + // this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: false } }); | ||
| 106 | + // } | ||
| 107 | + const currentKey = nextProps.app.currentPane.key; /* 当前页签key */ | ||
| 108 | + const { formData } = nextState; | ||
| 109 | + if (commonUtils.isNotEmptyObject(nextProps.formRoute) && nextProps.formRoute.indexOf('/indexOee') > -1) { | ||
| 110 | + return (formData.length > 0); | ||
| 111 | + } | ||
| 112 | + /* 处理loginOee下拉框切换 重新渲染 */ | ||
| 113 | + if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase() === '/loginoee') { | ||
| 114 | + return true; | ||
| 115 | + } | ||
| 116 | + if (nextProps.app.unReadSid !== this.props.app.unReadSid) { | ||
| 117 | + return false; | ||
| 118 | + } | ||
| 119 | + return (currentKey === nextState.sTabId && formData.length > 0) | ||
| 120 | + || (nextState.fastOrderModalVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.fastOrderModalVisible) | ||
| 121 | + || (nextState.visibleStatement !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleStatement) | ||
| 122 | + || (nextState.visibleBatchPriceUpdate !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleBatchPriceUpdate) | ||
| 123 | + || (nextState.modalVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.modalVisible) | ||
| 124 | + || (nextState.visibleModal !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleModal) | ||
| 125 | + || (nextState.materialsChooseVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.materialsChooseVisible) | ||
| 126 | + || (nextState.processChooseVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.processChooseVisible) | ||
| 127 | + || (nextState.visibleFilfile !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleFilfile) | ||
| 128 | + || (nextState.contextMenuModalVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.contextMenuModalVisible) | ||
| 129 | + || (nextState.bTabModal !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.bTabModal) | ||
| 130 | + || (nextState.workScheduleVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.workScheduleVisible); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + componentDidUpdate(nextProps, nextState) { | ||
| 134 | + // 修改或新增后的保存功能 | ||
| 135 | + if (nextProps.onRemovePane && nextState.enabled && !nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) { | ||
| 136 | + this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: true } }); | ||
| 137 | + } | ||
| 138 | + if (nextProps.onRemovePane && !nextState.enabled && nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) { | ||
| 139 | + this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: false } }); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + // 页面加载完成后执行一次指令集 | ||
| 143 | + this.initInstruct(); | ||
| 144 | + // 修改tab显示状态 | ||
| 145 | + this.handleChangeTabStatus(); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + componentWillUnmount() { | ||
| 149 | + const { | ||
| 150 | + currentId, | ||
| 151 | + } = this.state; | ||
| 152 | + const { userinfo } = this.props.app; | ||
| 153 | + window.removeEventListener('beforeunload', this.beforeunload); | ||
| 154 | + window.removeEventListener('unload', this.unload); | ||
| 155 | + window.removeEventListener('keydown', this.handleF9KeyPress); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + // 页面加载完成后执行一次指令集 | ||
| 159 | + initInstruct = () => { | ||
| 160 | + if (!this.bInit) { | ||
| 161 | + clearTimeout(this.initTimer); | ||
| 162 | + this.initTimer = setTimeout(() => { | ||
| 163 | + this.bInit = true; | ||
| 164 | + const { masterConfig = {} } = this.state; | ||
| 165 | + const { sOnShowInstruct } = masterConfig; | ||
| 166 | + if (sOnShowInstruct) { | ||
| 167 | + instructSet({ | ||
| 168 | + ...this.props, | ||
| 169 | + ...this.state, | ||
| 170 | + btnConfig: { sInstruct: sOnShowInstruct, showName: "页面初始化" }, | ||
| 171 | + onSaveState: this.handleSaveState | ||
| 172 | + }) | ||
| 173 | + } | ||
| 174 | + }, 500); | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + // 修改tab显示状态 | ||
| 179 | + handleChangeTabStatus = () => { | ||
| 180 | + clearTimeout(this.tabTimer); | ||
| 181 | + this.tabTimer = setTimeout(() => { | ||
| 182 | + this.handleChangeTabStatusFunc(); | ||
| 183 | + }, 300); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + // 修改tab显示状态方法 | ||
| 187 | + handleChangeTabStatusFunc = () => { | ||
| 188 | + if (!this.baseRef) return; | ||
| 189 | + | ||
| 190 | + const { masterConfig = {} } = this.state; | ||
| 191 | + const { sInstruct: sInstructStr } = masterConfig; | ||
| 192 | + if (!sInstructStr) { | ||
| 193 | + this.baseRef.classList.remove('xlyCommonBase'); | ||
| 194 | + return; | ||
| 195 | + }; | ||
| 196 | + | ||
| 197 | + const sInstruct = commonUtils.convertStrToObj(sInstructStr, {}); | ||
| 198 | + const { tabs = [] } = sInstruct; | ||
| 199 | + if (!tabs.length) { | ||
| 200 | + this.baseRef.classList.remove('xlyCommonBase'); | ||
| 201 | + return; | ||
| 202 | + }; | ||
| 203 | + | ||
| 204 | + // 根据配置获取要隐藏的tab | ||
| 205 | + const hideTabNameList = []; | ||
| 206 | + | ||
| 207 | + tabs.forEach(item => { | ||
| 208 | + const { name, show } = item; | ||
| 209 | + if (show === undefined) return; | ||
| 210 | + | ||
| 211 | + let result = false; | ||
| 212 | + if (typeof show === "boolean") { | ||
| 213 | + result = show; | ||
| 214 | + } else { | ||
| 215 | + result = commonFunc.getEvalResult({ | ||
| 216 | + props: {...this.props, ...this.state}, | ||
| 217 | + str: show, | ||
| 218 | + defaultValue: true | ||
| 219 | + }) | ||
| 220 | + } | ||
| 221 | + if (result === false) { | ||
| 222 | + hideTabNameList.push(name); | ||
| 223 | + } | ||
| 224 | + }); | ||
| 225 | + | ||
| 226 | + // 遍历所有tab页签,隐藏掉在hideTabNameList中的tab页签 | ||
| 227 | + const oTabBtns = this.baseRef.querySelectorAll('.ant-tabs-tab-btn'); | ||
| 228 | + oTabBtns.forEach(oDom => { | ||
| 229 | + const tabName = oDom.innerHTML; | ||
| 230 | + const oTab = oDom.parentNode; | ||
| 231 | + const bHide = hideTabNameList.includes(tabName); | ||
| 232 | + if (bHide) { | ||
| 233 | + oTab.style.display = 'none'; | ||
| 234 | + } else { | ||
| 235 | + oTab.style.display = ''; | ||
| 236 | + } | ||
| 237 | + }); | ||
| 238 | + | ||
| 239 | + // 遍历所有tabsList页签,如果下面的tab没有一个处于激活且显示状态的,默认点击第一个tab | ||
| 240 | + const oNavList = this.baseRef.querySelectorAll('.ant-tabs-nav-list'); | ||
| 241 | + oNavList.forEach(oList => { | ||
| 242 | + const { childNodes } = oList; | ||
| 243 | + const bHasActive = Array.from(childNodes).some(oTab => | ||
| 244 | + oTab.classList.contains("ant-tabs-tab-active") && | ||
| 245 | + oTab.style.display !== "none" | ||
| 246 | + ); | ||
| 247 | + if (!bHasActive) { | ||
| 248 | + const oTemp = Array.from(childNodes).find(oTab => | ||
| 249 | + oTab.style.display !== "none" | ||
| 250 | + ); | ||
| 251 | + if (oTemp) { | ||
| 252 | + oTemp.click(); | ||
| 253 | + } | ||
| 254 | + } | ||
| 255 | + }); | ||
| 256 | + | ||
| 257 | + this.baseRef.classList.remove('xlyCommonBase'); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + handleSearchNodes= (key, data, showNameNew) => { | ||
| 261 | + let tableRow = {}; | ||
| 262 | + if (commonUtils.isNotEmptyObject(key)) { | ||
| 263 | + for (let i = 0, len = data.length; i < len; i ++) { | ||
| 264 | + const item = data[i]; | ||
| 265 | + if (data[i].key === key) { | ||
| 266 | + tableRow = item; | ||
| 267 | + return tableRow; | ||
| 268 | + } else if (commonUtils.isNotEmptyArr(item.children)) { | ||
| 269 | + const res = this.handleSearchNodes(key, item.children, showNameNew); | ||
| 270 | + if(commonUtils.isNotEmptyObject(res)) { | ||
| 271 | + return res; | ||
| 272 | + } | ||
| 273 | + } | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + return tableRow; | ||
| 277 | + | ||
| 278 | + }; | ||
| 279 | + | ||
| 280 | + /* | ||
| 281 | + componentWillUnmount() { | ||
| 282 | + this.mounted = false; | ||
| 283 | + const { sModelsId } = this.state; | ||
| 284 | + const { app, currentId } = this.props; | ||
| 285 | + const { webSocket, userinfo, currentPane } = app; | ||
| 286 | + const { key } = currentPane; | ||
| 287 | + commonUtils.clearFormStoreDropDownData(sModelsId); | ||
| 288 | + const { copyTo } = app.currentPane; | ||
| 289 | + if (commonUtils.isNotEmptyObject(copyTo)) { | ||
| 290 | + const { slaveData } = copyTo; | ||
| 291 | + const sIdArray = []; | ||
| 292 | + slaveData.forEach((item) => { | ||
| 293 | + const redisKey = item.sSlaveId; | ||
| 294 | + sIdArray.push(redisKey); | ||
| 295 | + }); | ||
| 296 | + const sId = sIdArray.toString(); | ||
| 297 | + commonFunc.sendWebSocketMessage(webSocket, key, 'copyfinish', 'noAction', userinfo.sId, null, sId, userinfo.sId, null); | ||
| 298 | + } | ||
| 299 | + if (!commonUtils.isEmpty(currentId)) { | ||
| 300 | + commonFunc.sendWebSocketMessage(webSocket, key, 'release', 'noAction', userinfo.sId, null, currentId, userinfo.sId, null); | ||
| 301 | + } | ||
| 302 | + } */ | ||
| 303 | + | ||
| 304 | + /** sql条件 */ | ||
| 305 | + getSqlCondition = (showConfig, name, record) => { | ||
| 306 | + const conditonValues = {}; | ||
| 307 | + if (commonUtils.isNotEmptyStr(showConfig.sSqlCondition)) { | ||
| 308 | + // 电化铝bom单独处理,不作标版使用。 | ||
| 309 | + if (showConfig.sName === 'sAlumiteBomBillNo' || showConfig.sControlName === 'BtnPopupsAlumiteBomBillNo') { | ||
| 310 | + const { materialsData, processData: processDataOld, processSelectedRowKeys: processSelectedRowKeysOld } = this.state; | ||
| 311 | + const { slave0Data, slave0SelectedRowKeys } = this.state; | ||
| 312 | + const processData = commonUtils.isEmptyArr(processDataOld) && commonUtils.isEmptyArr(processSelectedRowKeysOld) ? slave0Data : processDataOld; | ||
| 313 | + const processSelectedRowKeys = commonUtils.isEmptyArr(processDataOld) && commonUtils.isEmptyArr(processSelectedRowKeysOld) ? slave0SelectedRowKeys : processSelectedRowKeysOld; | ||
| 314 | + if (commonUtils.isNotEmptyArr(materialsData) && commonUtils.isNotEmptyArr(processSelectedRowKeys)) { | ||
| 315 | + const iMaterialsIndex = materialsData.findIndex(item => item.sProcessTbId === processSelectedRowKeys[0]); | ||
| 316 | + if (iMaterialsIndex > -1) { | ||
| 317 | + conditonValues.iNumberOfTime = materialsData[iMaterialsIndex].iNumberOfTime; | ||
| 318 | + conditonValues.sVersionNum = materialsData[iMaterialsIndex].sVersionNum; | ||
| 319 | + } else { | ||
| 320 | + conditonValues.iNumberOfTime = 0; | ||
| 321 | + conditonValues.sVersionNum = ''; | ||
| 322 | + } | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + const conditon = showConfig.sSqlCondition.split(','); | ||
| 326 | + conditon.forEach((item) => { | ||
| 327 | + if (item.indexOf('.') > -1) { | ||
| 328 | + const tableName = item.split('.')[0]; | ||
| 329 | + let fieldName = item.split('.')[1]; | ||
| 330 | + let fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName; | ||
| 331 | + // master.sId 作为参数 master.sId.sId 作为filterDropdown过滤参数 | ||
| 332 | + if (showConfig.sDropDownType === 'picArr' || showConfig.sDropDownType === 'picArrModal' ) { | ||
| 333 | + fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName; | ||
| 334 | + if (fieldName.indexOf('&Search') > -1) { | ||
| 335 | + // 参数为&Search时认为是查找数据集中取数据 | ||
| 336 | + const data = this.state[`${tableName}Data`]; | ||
| 337 | + if (typeof data === 'object' && data.constructor === Object) { | ||
| 338 | + Object.keys(data).forEach((dataItem) => { | ||
| 339 | + if (`&Search${data[dataItem]}` === fieldName) { | ||
| 340 | + let sTmpName = dataItem; | ||
| 341 | + sTmpName = sTmpName.replace('First', 'Third'); | ||
| 342 | + if (data[dataItem].substring(0, 1) === 't') { | ||
| 343 | + fieldName = `p${sTmpName.substring(1, dataItem.length)}`; | ||
| 344 | + } else if (data[dataItem].substring(0, 1) === 'm') { | ||
| 345 | + fieldName = data[dataItem].substring(0, 1) + sTmpName.substring(1, sTmpName.length); | ||
| 346 | + } else { | ||
| 347 | + fieldName = data[dataItem].substring(0, 1) + sTmpName.substring(1, sTmpName.length); | ||
| 348 | + } | ||
| 349 | + } | ||
| 350 | + }); | ||
| 351 | + } | ||
| 352 | + } else if (fieldName.indexOf('&') > -1) { | ||
| 353 | + fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName; | ||
| 354 | + conditonValues[fieldNameFilter] = fieldName.replace('&', ''); | ||
| 355 | + return; | ||
| 356 | + } | ||
| 357 | + } | ||
| 358 | + if (fieldName !== '') { | ||
| 359 | + if (name === tableName && !commonUtils.isEmptyObject(record)) { | ||
| 360 | + const data = record; | ||
| 361 | + conditonValues[fieldNameFilter] = data[fieldName]; | ||
| 362 | + } else { | ||
| 363 | + let data = this.state[`${tableName}Data`]; | ||
| 364 | + if(commonUtils.isEmptyArr(data)) { | ||
| 365 | + const dataRelationJson = this.state.relateRelationJson; | ||
| 366 | + if(commonUtils.isNotEmptyObject(dataRelationJson)){ | ||
| 367 | + const relateName = dataRelationJson[tableName]; | ||
| 368 | + if(relateName) { | ||
| 369 | + data = this.state[`${relateName}Data`]; | ||
| 370 | + } | ||
| 371 | + } | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + let selectedRowKeys = this.state[`${tableName}SelectedRowKeys`]; | ||
| 375 | + if(tableName === 'tree') { | ||
| 376 | + selectedRowKeys = this.state[`${tableName}SelectedKeys`]; | ||
| 377 | + } | ||
| 378 | + if (typeof data === 'object' && data.constructor === Object) { | ||
| 379 | + conditonValues[fieldNameFilter] = data[fieldName]; | ||
| 380 | + } | ||
| 381 | + else if (fieldName.indexOf('_all') > -1) { | ||
| 382 | + let sAllConditionValue = ''; | ||
| 383 | + const fieldNameNew = fieldName.replace('_all', ''); | ||
| 384 | + if (commonUtils.isNotEmptyArr(data)) { | ||
| 385 | + // 电化铝bom单独处理,不作标版使用。 | ||
| 386 | + let dataNew = data; | ||
| 387 | + if (showConfig.sName === 'sAlumiteBomBillNo' || showConfig.sControlName === 'BtnPopupsAlumiteBomBillNo') { | ||
| 388 | + const { controlData, controlSelectedRowKeys: controlSelectedRowKeysOld, slave0Child1SelectedRowKeys } = this.state; | ||
| 389 | + const controlSelectedRowKeys = commonUtils.isEmptyArr(controlData) ? slave0Child1SelectedRowKeys : controlSelectedRowKeysOld; | ||
| 390 | + if (commonUtils.isNotEmptyArr(controlSelectedRowKeys)) { | ||
| 391 | + dataNew = data.filter(item => item.sControlId === controlSelectedRowKeys[0]); | ||
| 392 | + } | ||
| 393 | + } | ||
| 394 | + for(const item of dataNew) { | ||
| 395 | + if (item[fieldNameNew]) { | ||
| 396 | + sAllConditionValue = sAllConditionValue + ',' + item[fieldNameNew]; | ||
| 397 | + } | ||
| 398 | + } | ||
| 399 | + } | ||
| 400 | + conditonValues[fieldNameFilter] = sAllConditionValue; | ||
| 401 | + }else if(tableName ==='tree' && commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(data)) { | ||
| 402 | + const selectedKey = selectedRowKeys?.toString(); | ||
| 403 | + /* 如果是树形 递归查找选中行 */ | ||
| 404 | + const tableRow = this.handleSearchNodes(selectedKey, data); | ||
| 405 | + if(commonUtils.isNotEmptyObject(tableRow)) { | ||
| 406 | + conditonValues[fieldNameFilter] = tableRow[fieldName]; | ||
| 407 | + } | ||
| 408 | + } | ||
| 409 | + else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(data)) { | ||
| 410 | + let iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]); | ||
| 411 | + iIndex = iIndex > -1 ? iIndex : data.findIndex(itemData => itemData.sSlaveId === selectedRowKeys[0]); | ||
| 412 | + if (iIndex > -1) { | ||
| 413 | + conditonValues[fieldNameFilter] = data[iIndex][fieldName]; | ||
| 414 | + } | ||
| 415 | + } else if (commonUtils.isNotEmptyArr(data)) { | ||
| 416 | + conditonValues[fieldNameFilter] = data[0][fieldName]; | ||
| 417 | + } | ||
| 418 | + } | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + }); | ||
| 422 | + } | ||
| 423 | + return conditonValues; | ||
| 424 | + }; | ||
| 425 | + | ||
| 426 | + /** 获取sql下拉数据 */ | ||
| 427 | + getSqlDropDownData = async (formId, name, showConfig, record, sKeyUpFilterName, pageNum) => { | ||
| 428 | + /* 地址 */ | ||
| 429 | + const { formSrcRoute } = this.state; | ||
| 430 | + if (commonUtils.isEmpty(showConfig.sFieldToContent)) { | ||
| 431 | + if (commonUtils.isEmpty(showConfig.showDropDown)) { | ||
| 432 | + return { | ||
| 433 | + dropDownData: [], totalPageCount: 0, currentPageNo: 0, conditonValues: {}, | ||
| 434 | + }; | ||
| 435 | + } | ||
| 436 | + const url = `${commonConfig.server_host}business/getSelectLimit/${showConfig.sId}?sModelsId=${this.state.sModelsId}&sName=${formSrcRoute}`; | ||
| 437 | + /* 参数 */ | ||
| 438 | + const conditonValues = this.getSqlCondition(showConfig, name, record); | ||
| 439 | + | ||
| 440 | + const body = { | ||
| 441 | + sSqlCondition: commonUtils.isEmptyObject(conditonValues) ? '' : conditonValues, /* 查询条件 */ | ||
| 442 | + }; | ||
| 443 | + if (commonUtils.isEmpty(showConfig.sId)) { | ||
| 444 | + body.showDropDown = showConfig.showDropDown; | ||
| 445 | + body.sKeyUpFilter = showConfig.sKeyUpFilter; | ||
| 446 | + } | ||
| 447 | + if (!commonUtils.isEmpty(pageNum)) { | ||
| 448 | + body.sKeyUpFilterName = sKeyUpFilterName; /* 边输入边过滤,暂时没用1 */ | ||
| 449 | + body.pageNum = pageNum; | ||
| 450 | + // 下拉数据改为无限 | ||
| 451 | + body.pageSize = commonConfig.pageSize; | ||
| 452 | + // body.pageSize = 9999; | ||
| 453 | + } | ||
| 454 | + /* 获取数据 */ | ||
| 455 | + const json = await commonServices.postValueService(this.props.app.token, body, url); | ||
| 456 | + /* code为1代表获取数据成功 */ | ||
| 457 | + if (json.data.code === 1) { | ||
| 458 | + /* 获取数据集 */ | ||
| 459 | + const { rows, totalPageCount, currentPageNo, totalCount } = json.data.dataset; | ||
| 460 | + return { | ||
| 461 | + dropDownData: rows, totalPageCount, currentPageNo, conditonValues, totalCount, | ||
| 462 | + }; | ||
| 463 | + } else { | ||
| 464 | + return { | ||
| 465 | + dropDownData: [], totalPageCount: 0, currentPageNo: 0, conditonValues, | ||
| 466 | + }; | ||
| 467 | + } | ||
| 468 | + } else { | ||
| 469 | + const returnData = []; | ||
| 470 | + if (showConfig.sFieldToContent === '1') { | ||
| 471 | + if (name === 'master') { | ||
| 472 | + const { [`${name}Data`]: data } = this.state; | ||
| 473 | + const sName = `sParamDropDown${showConfig.sName.replace('sParamValue', '')}`; | ||
| 474 | + returnData.push(...commonUtils.objectToArr(data[sName])); | ||
| 475 | + } else { | ||
| 476 | + const { [`${name}Data`]: data, [`${name}SelectedRowKeys`]: selectedRowKeys } = this.state; | ||
| 477 | + const sName = `sParamDropDown${showConfig.sName.replace('sParamValue', '')}`; | ||
| 478 | + if (commonUtils.isNotEmptyObject(record)) { | ||
| 479 | + returnData.push(...commonUtils.objectToArr(record[sName])); | ||
| 480 | + } else if (commonUtils.isNotEmptyArr(data) && commonUtils.isNotEmptyArr(selectedRowKeys)) { | ||
| 481 | + const iIndex = data.findIndex(item => item.sId === selectedRowKeys.toString()); | ||
| 482 | + if (iIndex > -1) { | ||
| 483 | + returnData.push(...commonUtils.objectToArr(data[iIndex][sName])); | ||
| 484 | + } | ||
| 485 | + } | ||
| 486 | + } | ||
| 487 | + } else { | ||
| 488 | + const unionCondition = showConfig.sFieldToContent.split('&&'); | ||
| 489 | + unionCondition.forEach((unionItem) => { | ||
| 490 | + const conditon = unionItem.split(','); | ||
| 491 | + const tableNameContent = conditon[0].split('.')[0]; | ||
| 492 | + let data = this.state[`${tableNameContent}Data`]; | ||
| 493 | + if (commonUtils.isNotEmptyArr(data)) { | ||
| 494 | + if (showConfig.sSqlCondition !== '') { | ||
| 495 | + const sSqlCondition = showConfig.sSqlCondition; | ||
| 496 | + const sqlConditon = sSqlCondition.split(','); | ||
| 497 | + sqlConditon.forEach((item) => { | ||
| 498 | + const tableName = item.split('.')[0]; | ||
| 499 | + const fieldName = item.split('.')[1]; | ||
| 500 | + const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName; | ||
| 501 | + const dataCondition = this.state[`${tableName}Data`]; | ||
| 502 | + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`]; | ||
| 503 | + if (typeof dataCondition === 'object' && dataCondition.constructor === Object) { | ||
| 504 | + // 对象不用filter | ||
| 505 | + // data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[fieldName], '')); | ||
| 506 | + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) { | ||
| 507 | + let iIndex = dataCondition.findIndex(itemData => itemData.sId === selectedRowKeys[0]); | ||
| 508 | + iIndex = iIndex > -1 ? iIndex : dataCondition.findIndex(itemData => itemData.sSlaveId === selectedRowKeys[0]); | ||
| 509 | + if (iIndex > -1) { | ||
| 510 | + data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[iIndex][fieldName], '')); | ||
| 511 | + } | ||
| 512 | + } else if (commonUtils.isNotEmptyArr(data)) { | ||
| 513 | + data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[0][fieldName], '')); | ||
| 514 | + } | ||
| 515 | + }); | ||
| 516 | + } | ||
| 517 | + if (typeof data === 'object' && data.constructor === Object) { | ||
| 518 | + const dataRow = {}; | ||
| 519 | + conditon.forEach((item) => { | ||
| 520 | + const fieldName = item.split('.')[1]; | ||
| 521 | + const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName; | ||
| 522 | + if (fieldName.indexOf('-') >= 0) { | ||
| 523 | + fieldName.split('-').forEach((itemField) => { | ||
| 524 | + const sFieldValue = commonUtils.isEmpty(data[itemField]) ? '' : data[itemField].toString(); | ||
| 525 | + dataRow[fieldNameFilter] = commonUtils.isEmpty(dataRow[fieldNameFilter]) ? sFieldValue : `${dataRow[fieldNameFilter]}-${sFieldValue}`; | ||
| 526 | + }); | ||
| 527 | + } else { | ||
| 528 | + dataRow[fieldNameFilter] = commonUtils.isEmpty(data[fieldName]) ? '' : data[fieldName].toString(); | ||
| 529 | + } | ||
| 530 | + }); | ||
| 531 | + returnData.push(dataRow); | ||
| 532 | + } else { | ||
| 533 | + data.forEach((itemDataRow) => { | ||
| 534 | + const dataRow = {}; | ||
| 535 | + conditon.forEach((item) => { | ||
| 536 | + const fieldName = item.split('.')[1]; | ||
| 537 | + const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName; | ||
| 538 | + if (fieldName.indexOf('-') >= 0) { | ||
| 539 | + fieldName.split('-').forEach((itemField) => { | ||
| 540 | + const sFieldValue = commonUtils.isEmpty(itemDataRow[itemField]) ? '' : itemDataRow[itemField].toString(); | ||
| 541 | + dataRow[fieldNameFilter] = commonUtils.isEmpty(dataRow[fieldNameFilter]) ? sFieldValue : `${dataRow[fieldNameFilter]}-${sFieldValue}`; | ||
| 542 | + }); | ||
| 543 | + } else { | ||
| 544 | + dataRow[fieldNameFilter] = commonUtils.isEmpty(itemDataRow[fieldName]) ? '' : itemDataRow[fieldName].toString(); | ||
| 545 | + } | ||
| 546 | + }); | ||
| 547 | + returnData.push(dataRow); | ||
| 548 | + }); | ||
| 549 | + } | ||
| 550 | + } | ||
| 551 | + }); | ||
| 552 | + } | ||
| 553 | + return { dropDownData: returnData, totalPageCount: 0, currentPageNo: 0 }; | ||
| 554 | + } | ||
| 555 | + }; | ||
| 556 | + /* 获取数字格式化规范 */ | ||
| 557 | + getFloatNum = (sName) => { | ||
| 558 | + if (sName.toLowerCase().endsWith('price')) { /* 价格 */ | ||
| 559 | + return this.props.app.decimals.dNetPrice; | ||
| 560 | + } else if (sName.toLowerCase().endsWith('money')) { /* 金额 */ | ||
| 561 | + return this.props.app.decimals.dNetMoney; | ||
| 562 | + } else { /* 其它 */ | ||
| 563 | + return 6; | ||
| 564 | + } | ||
| 565 | + }; | ||
| 566 | + | ||
| 567 | + /** 获取sql下拉数据 */ | ||
| 568 | + getServiceError = async (returnData) => { | ||
| 569 | + if (location.pathname.indexOf('/indexOee/') > -1) { | ||
| 570 | + this.props.dispatch({ type: 'app/throwErrorOee', payload: returnData }); | ||
| 571 | + } else { | ||
| 572 | + this.props.dispatch({ type: 'app/throwError', payload: returnData }); | ||
| 573 | + } | ||
| 574 | + }; | ||
| 575 | + | ||
| 576 | + /* 获取数字格式化规范 */ | ||
| 577 | + getDateFormat = () => { | ||
| 578 | + return this.props.app.dateFormat; | ||
| 579 | + }; | ||
| 580 | + | ||
| 581 | + beforeunload = (e) => { | ||
| 582 | + const confirmationMessage = '您确定要离开么?'; | ||
| 583 | + if (e) { | ||
| 584 | + e.returnValue = confirmationMessage; | ||
| 585 | + } | ||
| 586 | + return confirmationMessage; | ||
| 587 | + } | ||
| 588 | + | ||
| 589 | + unload = () => { | ||
| 590 | + // sessionStorage.clear(); | ||
| 591 | + // const { | ||
| 592 | + // currentId, sModelsId, | ||
| 593 | + // } = this.state; | ||
| 594 | + // const url = `${commonConfig.server_host}logout`; | ||
| 595 | + // this.handleSendSocketMessage('release', 'noAction', currentId, this.props.app.userinfo.sId, null, null); | ||
| 596 | + // this.handleSendSocketMessage('release', 'noAction', sModelsId, this.props.app.userinfo.sId, null, null); | ||
| 597 | + // this.props.dispatch({ type: 'app/loginOut', payload: { url, sId: this.props.app.userinfo.sId, loginOutType: 'loginOut' } }); | ||
| 598 | + } | ||
| 599 | + | ||
| 600 | + handleF9KeyPress = (event) => { | ||
| 601 | + // 判断是否按下的是F9键 | ||
| 602 | + if (event.key === 'F9') { | ||
| 603 | + event.preventDefault(); | ||
| 604 | + this.setState({ | ||
| 605 | + showTableName: !this.state.showTableName, | ||
| 606 | + }); | ||
| 607 | + } | ||
| 608 | + } | ||
| 609 | + | ||
| 610 | + handleSendSocketMessage = (flag, showType, sId, sendTo, msgInfo, param) => { | ||
| 611 | + const { token } = this.props.app; | ||
| 612 | + const sendws = this.handleSendWebSocketMsg; | ||
| 613 | + const { dispatch } = this.props; | ||
| 614 | + if (commonUtils.isNotEmptyObject(token)) { | ||
| 615 | + if (this.props.app.webSocket !== null && this.props.app.webSocket.readyState === WebSocket.OPEN) { | ||
| 616 | + sendws(flag, showType, msgInfo, sId, sendTo, param); | ||
| 617 | + } else { | ||
| 618 | + this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } }); | ||
| 619 | + setTimeout(() => { | ||
| 620 | + sendws(flag, showType, msgInfo, sId, sendTo, param); | ||
| 621 | + }, 30000); | ||
| 622 | + } | ||
| 623 | + } | ||
| 624 | + }; | ||
| 625 | + handleSendWebSocketMsg = (flag, showType, msgInfo, sId, sendTo, param) => { | ||
| 626 | + const { app } = this.props; | ||
| 627 | + const { webSocket, userinfo, currentPane } = app; | ||
| 628 | + const { key } = currentPane; | ||
| 629 | + commonFunc.sendWebSocketMessage(webSocket, key, flag, showType, userinfo.sId, msgInfo, sId, sendTo, param); | ||
| 630 | + } | ||
| 631 | + /** sql下拉新增处理 */ | ||
| 632 | + handleSqlDropDownNewRecord = async (showConfig, name) => { | ||
| 633 | + const { | ||
| 634 | + [`${name}SelectedRowKeys`]: tableSelectedRowKeys, [`${name}Data`]: tableNewData, masterData, formSrcRoute, [`${name}Config`]: tableConfig, slaveData, | ||
| 635 | + } = this.state; | ||
| 636 | + /* 待用数据声明 */ | ||
| 637 | + const sTabId = this.props.app.currentPane.key; /* 当前标签页TabId */ | ||
| 638 | + /* 接口地址 */ | ||
| 639 | + const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${showConfig.sActiveId}?sModelsId=${showConfig.sActiveId}&sName=${formSrcRoute}`; | ||
| 640 | + const CallBackRecord = this.handleCallBackRecord;/* 字段名,主从表,字段名 */ | ||
| 641 | + /* newRecord时,如果是新增产品,则要带客户过去 */ | ||
| 642 | + let addStata = {}; | ||
| 643 | + for (const each of this.props.app.panes) { | ||
| 644 | + each.notCurrentPane = true; | ||
| 645 | + } | ||
| 646 | + const iIndex = name !== 'master' ? tableNewData.findIndex(item => item.sId === tableSelectedRowKeys.toString()) : -1; | ||
| 647 | + if (commonUtils.isNotEmptyObject(showConfig) && showConfig.sName === 'sProductName') { | ||
| 648 | + if (name !== 'master' && commonUtils.isNotEmptyObject(tableSelectedRowKeys)) { | ||
| 649 | + const newData = tableNewData[iIndex]; | ||
| 650 | + addStata.sCustomerId = newData.sCustomerId; | ||
| 651 | + addStata.sCustomerNo = newData.sCustomerNo; | ||
| 652 | + addStata.sCustomerName = newData.sCustomerName; | ||
| 653 | + if (commonUtils.isEmptyObject(addStata.sCustomerId)) { /* 新增产品时,看客户在从表还是主表。如果不在从表,那看是否在主表 */ | ||
| 654 | + addStata.sCustomerId = masterData.sCustomerId; | ||
| 655 | + addStata.sCustomerNo = masterData.sCustomerNo; | ||
| 656 | + addStata.sCustomerName = masterData.sCustomerName; | ||
| 657 | + } | ||
| 658 | + } | ||
| 659 | + } | ||
| 660 | + /* newRecord 根据配置赋值 带数据 */ | ||
| 661 | + const sCopyToConfigField = commonUtils.isNotEmptyObject(showConfig) && showConfig.sControlName && showConfig.sControlName.includes('BtnNewRecord') ? showConfig.sControlName : {}; | ||
| 662 | + let sCopyToConfigMaster = {}; | ||
| 663 | + if(commonUtils.isNotEmptyArr(sCopyToConfigField) && commonUtils.isNotEmptyArr(tableConfig)) { | ||
| 664 | + sCopyToConfigMaster = tableConfig.gdsconfigformslave.filter(item => item.sControlName === sCopyToConfigField); | ||
| 665 | + console.log(sCopyToConfigMaster, sCopyToConfigMaster); | ||
| 666 | + if(commonUtils.isNotEmptyArr(sCopyToConfigMaster)) { | ||
| 667 | + const sCopyToConfigMasterAssignField= sCopyToConfigMaster[0].sAssignField; | ||
| 668 | + const newCopyTo = {}; | ||
| 669 | + if(iIndex > -1) { | ||
| 670 | + const newData = tableNewData[iIndex]; | ||
| 671 | + newCopyTo.master = masterData; | ||
| 672 | + newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0]; | ||
| 673 | + newCopyTo.process = newData; | ||
| 674 | + addStata = { ...addStata, ...commonFunc.getAssignFieldValue(sCopyToConfigMasterAssignField, newData, newCopyTo)}; | ||
| 675 | + } | ||
| 676 | + } | ||
| 677 | + } | ||
| 678 | + /* 接口参数 */ | ||
| 679 | + const payload = { | ||
| 680 | + url: sNameUrl, | ||
| 681 | + sParentId: sTabId, | ||
| 682 | + classifyOption: 'add', | ||
| 683 | + newRecordFlag: `NewRecord_${sTabId}`, /* newRecord当前字段 */ | ||
| 684 | + newRecordRelation: addStata, /* newRecord 关联字段,如新增产品,带客户信息 */ | ||
| 685 | + newRecordMethod: CallBackRecord.bind(this, showConfig.sName, name), /* newRecord当前字段 */ | ||
| 686 | + sSrcModelsId: this.state.sModelsId | ||
| 687 | + }; | ||
| 688 | + /* 调用接口 */ | ||
| 689 | + this.props.dispatch({ type: 'content/onRouter', payload }); | ||
| 690 | + }; | ||
| 691 | + | ||
| 692 | + /* 获取配置数据用的sTabId,formId,formRoute */ | ||
| 693 | + handleConfigValue = (value, type) => { | ||
| 694 | + if (commonUtils.isNotEmptyObject(type) && type.indexOf('/indexOee') > -1) { | ||
| 695 | + return this.props[value]; | ||
| 696 | + } else { | ||
| 697 | + const { secondppopupPane, ppopupPane, currentPane } = this.props.app; | ||
| 698 | + return commonUtils.isNotEmptyObject(secondppopupPane) | ||
| 699 | + ? secondppopupPane[value] | ||
| 700 | + : commonUtils.isNotEmptyObject(ppopupPane) | ||
| 701 | + ? ppopupPane[value] : currentPane[value]; | ||
| 702 | + } | ||
| 703 | + }; | ||
| 704 | + | ||
| 705 | + /* 获取后台数据(单条) */ | ||
| 706 | + handleGetDataOne = async (params) => { | ||
| 707 | + const { token, sModelsId } = this.state; | ||
| 708 | + const { | ||
| 709 | + name, configData, condition, isWait, formSrcRoute, bEditClick, slaveConfig | ||
| 710 | + } = params; | ||
| 711 | + | ||
| 712 | + const lockUrl = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}&sName=${formSrcRoute}`; | ||
| 713 | + | ||
| 714 | + const configDataId = configData.sId; | ||
| 715 | + const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; | ||
| 716 | + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data; | ||
| 717 | + if (dataReturn.code === 1) { | ||
| 718 | + const [returnData] = dataReturn.dataset.rows[0].dataSet; | ||
| 719 | + if (commonUtils.isNotEmptyArr(returnData)) { | ||
| 720 | + let addState = {}; | ||
| 721 | + const value = { | ||
| 722 | + tableName: configData.sTbName, | ||
| 723 | + sId: [returnData.sId], | ||
| 724 | + }; | ||
| 725 | + if(bEditClick === 'update') { /* 只有点击修改时 调用addSysLocking */ | ||
| 726 | + const { data } = await commonServices.postValueService(token, value, lockUrl); | ||
| 727 | + if (data.code === 1) { /* 失败 */ | ||
| 728 | + addState.sUseInfo = ''; | ||
| 729 | + } else { /* 失败 */ | ||
| 730 | + addState.sUseInfo = data.msg; | ||
| 731 | + if (commonUtils.isNotEmptyObject(data.erroMsg)) { | ||
| 732 | + message.error(data.erroMsg); | ||
| 733 | + } | ||
| 734 | + } | ||
| 735 | + } | ||
| 736 | + addState[`${name}Data`] = returnData; | ||
| 737 | + if(commonUtils.isNotEmptyObject(returnData.customConfig) && commonUtils.isJSON(returnData.customConfig) && commonUtils.isNotEmptyObject(slaveConfig)) { | ||
| 738 | + const columnConfig = JSON.parse(returnData.customConfig); | ||
| 739 | + const newConfig =JSON.parse(JSON.stringify(slaveConfig)); | ||
| 740 | + let buttonConfig = []; | ||
| 741 | + if(commonUtils.isNotEmptyArr(slaveConfig?.gdsconfigformslave)) { | ||
| 742 | + buttonConfig = slaveConfig?.gdsconfigformslave.filter(item => commonUtils.isEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sControlName) ); | ||
| 743 | + } | ||
| 744 | + newConfig.gdsconfigformslave = columnConfig.concat(buttonConfig); | ||
| 745 | + addState.slaveConfig = newConfig; | ||
| 746 | + } | ||
| 747 | + addState.currentId = returnData.sId; | ||
| 748 | + if(bEditClick === 'update') { | ||
| 749 | + addState[`${name}Data`].enabled = true; | ||
| 750 | + } | ||
| 751 | + | ||
| 752 | + /* 获取主表数据时表字段数据根据条件控制 本表或其他表格字段的显示与隐藏功能 */ | ||
| 753 | + if (name === 'master' && commonUtils.isNotEmptyObject(configData)) { | ||
| 754 | + const addStateChange = this.handelControlFieldVisible(name, configData, returnData); | ||
| 755 | + if (commonUtils.isNotEmptyObject(addStateChange)) { | ||
| 756 | + addState = { ...addState, ...addStateChange }; | ||
| 757 | + } | ||
| 758 | + } | ||
| 759 | + | ||
| 760 | + if (isWait) { | ||
| 761 | + return addState; | ||
| 762 | + } else if (this.mounted) { | ||
| 763 | + this.handleSaveState({ ...addState }); | ||
| 764 | + } | ||
| 765 | + } | ||
| 766 | + } else { | ||
| 767 | + this.getServiceError(dataReturn); | ||
| 768 | + } | ||
| 769 | + }; | ||
| 770 | + | ||
| 771 | + /* 获取后台数据(数据集) */ | ||
| 772 | + handleGetDataSet = async (params) => { | ||
| 773 | + const { | ||
| 774 | + name, condition, flag, isWait, configData, clearSelectData, | ||
| 775 | + } = params; | ||
| 776 | + const { | ||
| 777 | + token, sModelsId, formRoute, [`${name}SelectedData`]: tableSelectedData, formSrcRoute, formData, [`${name}DelData`]: tableDelData, sModelsType, [`${name}PageSize`]: pageSize, [`${name}Config`]: tableConfig, | ||
| 778 | + } = this.state; | ||
| 779 | + let { | ||
| 780 | + menuChildData, | ||
| 781 | + [`${name}SelectedRowKeys`]: tableSelectedRowKeys, iPageSize, | ||
| 782 | + } = this.state; | ||
| 783 | + const masterConditionData = commonUtils.isNotEmptyObject(condition) ? condition.sSqlCondition : {}; | ||
| 784 | + /* 根据后台主表配置bPagination判断 是否分页 */ | ||
| 785 | + if (commonUtils.isNotEmptyObject(configData) && commonUtils.isNotEmptyObject(condition)) { | ||
| 786 | + const { bPagination } = configData; | ||
| 787 | + if (!bPagination || bPagination === undefined) { | ||
| 788 | + condition.pageSize = 10000; /* 不分页 */ | ||
| 789 | + iPageSize = 10000; | ||
| 790 | + } else { /* 分页 */ | ||
| 791 | + // eslint-disable-next-line no-lonely-if | ||
| 792 | + if (commonUtils.isNotEmptyArr(formData)) { | ||
| 793 | + if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) { | ||
| 794 | + iPageSize = formData[0].iPageSize;/* 后台设定页数 */ | ||
| 795 | + } | ||
| 796 | + } | ||
| 797 | + } | ||
| 798 | + } | ||
| 799 | + | ||
| 800 | + const configDataId = configData.sId; | ||
| 801 | + const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; | ||
| 802 | + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data; | ||
| 803 | + if (dataReturn.code === 1) { | ||
| 804 | + if( commonUtils.isNotEmptyObject(dataReturn.dataset) && commonUtils.isNotEmptyArr(dataReturn.dataset.rows) ) { | ||
| 805 | + let returnData = dataReturn.dataset.rows[0].dataSet; | ||
| 806 | + if (this.props && this.props.app && this.props.app.currentPane && this.props.app.currentPane.route && dataReturn.dataset.rows[0].columnConfig) { | ||
| 807 | + const columnConfig = dataReturn.dataset.rows[0].columnConfig; | ||
| 808 | + const newConfig = commonUtils.isNotEmptyObject(tableConfig) ? JSON.parse( JSON.stringify(tableConfig)) : JSON.parse(JSON.stringify(configData)) ; | ||
| 809 | + let buttonConfig = []; | ||
| 810 | + if(commonUtils.isNotEmptyArr(tableConfig?.gdsconfigformslave)) { | ||
| 811 | + buttonConfig = tableConfig?.gdsconfigformslave.filter(item => commonUtils.isEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sControlName) ); | ||
| 812 | + } | ||
| 813 | + newConfig.gdsconfigformslave = columnConfig.concat(buttonConfig); | ||
| 814 | + let addConfig = {}; | ||
| 815 | + if(name === 'slave' && commonUtils.isNotEmptyObject(newConfig)) { | ||
| 816 | + addConfig = { | ||
| 817 | + [`${name}Config`]:newConfig | ||
| 818 | + }; | ||
| 819 | + } | ||
| 820 | + this.handleSaveState({ | ||
| 821 | + customConfig: columnConfig, | ||
| 822 | + ...addConfig, | ||
| 823 | + }) | ||
| 824 | + } | ||
| 825 | + // const returnData = dataReturn.dataset.rows[0].dataSet; | ||
| 826 | + if (commonUtils.isNotEmptyObject(returnData)) { | ||
| 827 | + if (formRoute === '/indexPage/materialRequirementsPlanning') { | ||
| 828 | + returnData.forEach((tableDataRow) => { | ||
| 829 | + tableDataRow.sSlaveId = tableDataRow.sMaterialsId + tableDataRow.sMaterialsStyle; | ||
| 830 | + tableDataRow.dAuxiliaryQtyAll = tableDataRow.dAuxiliaryQty; | ||
| 831 | + tableDataRow.dMaterialsQtyAll = tableDataRow.dMaterialsQty; | ||
| 832 | + }); | ||
| 833 | + } | ||
| 834 | + if ((sModelsType && sModelsType.includes('linkTree'))) { | ||
| 835 | + returnData.forEach((tableDataRow) => { | ||
| 836 | + tableDataRow.dAuxiliaryQtyAll = tableDataRow.dAuxiliaryQty; | ||
| 837 | + tableDataRow.dMaterialsQtyAll = tableDataRow.dMaterialsQty; | ||
| 838 | + }); | ||
| 839 | + } | ||
| 840 | + /* 若有sDivRow则数据行上面插入一行 */ | ||
| 841 | + const returnFilterData = returnData.filter(item => commonUtils.isNotEmptyObject(item.sDivRow) && item.sDivRow !== ''); | ||
| 842 | + if (commonUtils.isNotEmptyArr(returnFilterData)) { | ||
| 843 | + returnFilterData.forEach((tableDataRow, index) => { | ||
| 844 | + /* 找到白班与晚班区间的汇总条数与工时 */ | ||
| 845 | + let startIndex = 0; /* 找到开始下标 */ | ||
| 846 | + let endindex = 0; /* 找到结束下标 */ | ||
| 847 | + let sliceData = []; | ||
| 848 | + startIndex = returnData.findIndex(item => item.sId === returnFilterData[index].sId); | ||
| 849 | + if (index + 1 < returnFilterData.length) { | ||
| 850 | + endindex = returnData.findIndex(item => item.sId === returnFilterData[index + 1].sId); | ||
| 851 | + } | ||
| 852 | + if (index === returnFilterData.length - 1) { | ||
| 853 | + endindex = returnData.length; | ||
| 854 | + } | ||
| 855 | + if (startIndex < endindex) { | ||
| 856 | + sliceData = returnData.slice(startIndex, endindex); | ||
| 857 | + } | ||
| 858 | + let num = 0; | ||
| 859 | + let dTime = 0; | ||
| 860 | + let dPlateQty = 0; /* 付版 */ | ||
| 861 | + let dProcessQty = 0; | ||
| 862 | + let endTime; | ||
| 863 | + const scheduleShow = ['16508090850002295893127095467000'].includes(sModelsId); | ||
| 864 | + let timeSName = 'dHour1'; | ||
| 865 | + if (scheduleShow) timeSName = 'dSumHour'; | ||
| 866 | + const newRow = {}; | ||
| 867 | + newRow.sId = 'sDivRow' + index; | ||
| 868 | + newRow.sSlaveId = 'sDivRow' + commonUtils.createSid(); | ||
| 869 | + if (commonUtils.isNotEmptyArr(sliceData)) { | ||
| 870 | + num = sliceData.length; | ||
| 871 | + sliceData.forEach((item) => { | ||
| 872 | + if (commonUtils.isNotEmptyNumber(item[timeSName])) { | ||
| 873 | + dTime += item[timeSName]; | ||
| 874 | + dPlateQty += commonUtils.isNotEmptyNumber(item.dPlateQty) ? item.dPlateQty : 0; | ||
| 875 | + dProcessQty += commonUtils.isNotEmptyNumber(item.dProcessQty) ? item.dProcessQty : 0; | ||
| 876 | + if (item?.tEndDate) { | ||
| 877 | + let value = item.tEndDate; | ||
| 878 | + if (endTime) { | ||
| 879 | + value = moment.max(moment(endTime), moment(item.tEndDate)); | ||
| 880 | + } | ||
| 881 | + endTime = value; | ||
| 882 | + } | ||
| 883 | + const iSrcIndex = returnData.findIndex(itemReturn => itemReturn.sSlaveId === item.sSlaveId); /* 汇总的每行上都加newRow的sSlaveId作为父级Id */ | ||
| 884 | + if (iSrcIndex > -1) { | ||
| 885 | + returnData[iSrcIndex] = {...returnData[iSrcIndex], sDivRowParentId: newRow.sSlaveId} | ||
| 886 | + } | ||
| 887 | + } | ||
| 888 | + }); | ||
| 889 | + } | ||
| 890 | + newRow.sDivRowNew = tableDataRow.sDivRow; | ||
| 891 | + newRow.bInsert = true; /* 新插入 */ | ||
| 892 | + newRow.sState = null; | ||
| 893 | + newRow.sProcessId = tableDataRow.sProcessId; | ||
| 894 | + /* 取第一个配置 */ | ||
| 895 | + const configArr = configData.gdsconfigformslave.filter(item => item.bVisible && item.sName !== ''); | ||
| 896 | + if (commonUtils.isNotEmptyArr(configArr)) { | ||
| 897 | + let firstName = ''; | ||
| 898 | + if (configArr[0].sName === 'iOrder') { | ||
| 899 | + firstName = configArr[1].sName; | ||
| 900 | + } else { | ||
| 901 | + firstName = configArr[1].sName; | ||
| 902 | + } | ||
| 903 | + if (commonUtils.isNotEmptyObject(firstName)) { | ||
| 904 | + const firstDataIndex = firstName.substring(0, 1); | ||
| 905 | + if (firstDataIndex !== 't' && firstDataIndex !== 'p') { | ||
| 906 | + newRow[firstName] = tableDataRow.sDivRow; | ||
| 907 | + if (num > 0) { | ||
| 908 | + newRow[firstName] += 'F' + num + '单'; | ||
| 909 | + } | ||
| 910 | + if (dProcessQty > 0) { | ||
| 911 | + newRow[firstName] += ' - ' + dProcessQty; | ||
| 912 | + } | ||
| 913 | + if (tableDataRow.sType === "1" && !scheduleShow ) { | ||
| 914 | + newRow[firstName] += ' - ' + dPlateQty + '付版'; | ||
| 915 | + } | ||
| 916 | + if (dTime > 0) { | ||
| 917 | + if (scheduleShow) { | ||
| 918 | + newRow[firstName] += ' - ' + Math.floor(dTime / 24) + "d" + (dTime % 24).toFixed(2) + 'h'; | ||
| 919 | + } else { | ||
| 920 | + newRow[firstName] += ' - ' + (dTime / 60).toFixed(2) + 'h'; | ||
| 921 | + } | ||
| 922 | + } | ||
| 923 | + if (endTime) { | ||
| 924 | + newRow[firstName] += ' - ' + moment(endTime).format('MM月DD日'); | ||
| 925 | + } | ||
| 926 | + } | ||
| 927 | + } | ||
| 928 | + } | ||
| 929 | + const iInsertIndex = returnData.findIndex(item => item.sSlaveId === tableDataRow.sSlaveId); | ||
| 930 | + if (iInsertIndex > -1) { | ||
| 931 | + returnData[iInsertIndex].sDivRow = ''; | ||
| 932 | + returnData.splice(iInsertIndex, 0, newRow); /* 在目标位置前面增加一行 */ | ||
| 933 | + } | ||
| 934 | + }); | ||
| 935 | + } | ||
| 936 | + if (commonUtils.isEmptyArr(tableSelectedData)) { | ||
| 937 | + if (formRoute !== '/indexPage/materialRequirementsPlanning' && formRoute !== '/indexPage/commonClassify' && | ||
| 938 | + sModelsId !=='12710101117238854446770') { | ||
| 939 | + if (commonUtils.isNotEmptyStr(returnData[0].sSlaveId)) { | ||
| 940 | + const keys = []; | ||
| 941 | + keys.push(returnData[0].sSlaveId); | ||
| 942 | + tableSelectedRowKeys = keys; | ||
| 943 | + } else { | ||
| 944 | + const keys = []; | ||
| 945 | + keys.push(returnData[0].sId); | ||
| 946 | + tableSelectedRowKeys = keys; | ||
| 947 | + } | ||
| 948 | + } | ||
| 949 | + if (flag) { | ||
| 950 | + tableSelectedRowKeys = []; | ||
| 951 | + menuChildData = []; // 打印下拉置空 | ||
| 952 | + } | ||
| 953 | + } | ||
| 954 | + } | ||
| 955 | + if (clearSelectData) { | ||
| 956 | + tableSelectedRowKeys = []; | ||
| 957 | + menuChildData = []; // 打印下拉置空 | ||
| 958 | + } | ||
| 959 | + /** | ||
| 960 | + * 修改日期:2021-03-30 | ||
| 961 | + * 修改人:吕杰 | ||
| 962 | + * 区域:以下 4 行 | ||
| 963 | + * BUG:2185 | ||
| 964 | + * 说明:右下角 增加单据个数显示 | ||
| 965 | + * 原代码: | ||
| 966 | + */ | ||
| 967 | + let billNum = ''; | ||
| 968 | + if (dataReturn.dataset.billNum) { | ||
| 969 | + billNum = `共${dataReturn.dataset.billNum}个单据 `; | ||
| 970 | + } | ||
| 971 | + const iOeeBillPageSize = iPageSize < 100 ? 100 : iPageSize; | ||
| 972 | + const pageSize = formRoute === '/indexPage/commonBill' || (formRoute === '/indexPage/productionMainPlan') | ||
| 973 | + || formRoute === '/indexPage/commonSubBill' || formRoute === '/indexPage/commonGroupBill' || formRoute === '/eleintefaceDialog' ? | ||
| 974 | + iPageSize : location.pathname.includes('commonOeeBill') ? iOeeBillPageSize : dataReturn.dataset.pageSize; | ||
| 975 | + const returnPagination = { | ||
| 976 | + total: dataReturn.dataset.totalCount, | ||
| 977 | + current: dataReturn.dataset.currentPageNo, | ||
| 978 | + pageSize: pageSize, | ||
| 979 | + showTotal: (total) => { | ||
| 980 | + return ( | ||
| 981 | + <span style={{fontWeight: 'bold'}}>{`当前显示 ${billNum}共${total}条记录`}</span> | ||
| 982 | + ); | ||
| 983 | + }, | ||
| 984 | + }; | ||
| 985 | + // 如果是commonNewBill,不取接口返回的分页数 | ||
| 986 | + if (formRoute === '/indexPage/commonNewBill' && pageSize) { | ||
| 987 | + const { bPagination } = configData; | ||
| 988 | + let iNewPageSize = pageSize; | ||
| 989 | + if (!bPagination || bPagination === undefined) { | ||
| 990 | + iNewPageSize = 10000; | ||
| 991 | + } else { /* 分页 */ | ||
| 992 | + if (commonUtils.isNotEmptyNumber(configData.iPageSize) && configData.iPageSize !== 0) { | ||
| 993 | + iNewPageSize = configData.iPageSize;/* 后台设定页数 */ | ||
| 994 | + } | ||
| 995 | + } | ||
| 996 | + returnPagination.pageSize = iNewPageSize; | ||
| 997 | + } | ||
| 998 | + // const sumSet1Default = [{ | ||
| 999 | + // "dProfit": '辊底重量:0.00', | ||
| 1000 | + // "dTotalProfitMoney": '转入重量:0.00', | ||
| 1001 | + // "dNetMargin": '分切重量:0.00', | ||
| 1002 | + // "dTotalNetProfit": '边料重量:0.00', | ||
| 1003 | + // "dMainBusinessMoney": '转出重量:0.00', | ||
| 1004 | + // "dOperaMoney": '总重量:0.00', | ||
| 1005 | + // "dFreight": '转入数量:0.00', | ||
| 1006 | + // "dOtherbusinessCostMoney": '转出数量:0.00', | ||
| 1007 | + // "dSellingExpenses": '总件数:0', | ||
| 1008 | + // }]; | ||
| 1009 | + const { sumSet, sumSet1 } = dataReturn.dataset.rows[0]; | ||
| 1010 | + const totalData = sumSet !== undefined ? sumSet : []; | ||
| 1011 | + const totalData1 = sumSet1 !== undefined ? sumSet1 : []; | ||
| 1012 | + const filterCondition = commonUtils.isNotEmptyObject(condition) ? condition.bFilter : ''; | ||
| 1013 | + const orderBy = commonUtils.isNotEmptyObject(condition) ? condition.sFilterOrderBy : ''; | ||
| 1014 | + /* 去除树搜索filterCondition */ | ||
| 1015 | + const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== 'tree') : ''; | ||
| 1016 | + let addState = { | ||
| 1017 | + [`${name}Data`]: returnData, | ||
| 1018 | + [`${name}Pagination`]: returnPagination, | ||
| 1019 | + [`${name}FilterCondition`]: filterConditionNew, | ||
| 1020 | + [`${name}OrderBy`]: orderBy, | ||
| 1021 | + [`${name}SelectedRowKeys`]: tableSelectedRowKeys, | ||
| 1022 | + menuChildData, | ||
| 1023 | + /* | ||
| 1024 | + 修改日期:2021-03-17 | ||
| 1025 | + 修改人:吕杰 | ||
| 1026 | + 区域:以下一行 | ||
| 1027 | + 需求变更:fix 2135 搜索时添加loading动画 | ||
| 1028 | + */ | ||
| 1029 | + pageLoading: false, | ||
| 1030 | + iPageSize, | ||
| 1031 | + masterConditionData | ||
| 1032 | + }; | ||
| 1033 | + if (commonUtils.isNotEmptyArr(totalData1)) { | ||
| 1034 | + addState = { ...addState, [`${name}Total1`]: totalData1, [`${name}AllTotal`]: totalData1 }; | ||
| 1035 | + } | ||
| 1036 | + if (dataReturn.dataset.currentPageNo === 1) { | ||
| 1037 | + addState = { ...addState, [`${name}Total`]: totalData, [`${name}AllTotal`]: totalData }; | ||
| 1038 | + } | ||
| 1039 | + if(commonUtils.isNotEmptyNumber(dataReturn?.dataset.totalCount)) { | ||
| 1040 | + const iCount = dataReturn.dataset.totalCount; | ||
| 1041 | + addState = { ...addState, [`${name}TotalCount`]: iCount }; | ||
| 1042 | + } | ||
| 1043 | + const slaveSelectedData = []; | ||
| 1044 | + if ((formRoute === '/indexPage/commonList' || formRoute === '/indexPage/materialRequirementsPlanning') && name === 'slave' && commonUtils.isNotEmptyArr(tableSelectedRowKeys) && !clearSelectData) { | ||
| 1045 | + tableSelectedRowKeys.forEach((item) => { | ||
| 1046 | + const iPageIndex = returnData.findIndex(pageItem => pageItem.sSlaveId === item); | ||
| 1047 | + if (iPageIndex > -1) { | ||
| 1048 | + slaveSelectedData.push(returnData[iPageIndex]); | ||
| 1049 | + } else if (commonUtils.isNotEmptyArr(tableSelectedData)) { | ||
| 1050 | + const iIndex = tableSelectedData.findIndex(pageItem => pageItem.sSlaveId === item); | ||
| 1051 | + if (iIndex > -1) { | ||
| 1052 | + slaveSelectedData.push(tableSelectedData[iIndex]); | ||
| 1053 | + } | ||
| 1054 | + } | ||
| 1055 | + }); | ||
| 1056 | + } else if (formRoute === '/indexPage/materialRequirementsPlanning' && clearSelectData) { /* 处理物料需求计划生成采购申请单,刷新时,数据重复问题 */ | ||
| 1057 | + addState.slaveInfoSelectedRowKeys = []; | ||
| 1058 | + addState.slaveInfoSelectedData = []; | ||
| 1059 | + } | ||
| 1060 | + addState[`${name}SelectedData`] = slaveSelectedData; | ||
| 1061 | + /* 如果获取数据集时候 删除数据集有数据 则清空 */ | ||
| 1062 | + if (commonUtils.isNotEmptyArr(tableDelData)) { | ||
| 1063 | + addState[`${name}DelData`] = []; | ||
| 1064 | + } | ||
| 1065 | + if (isWait) { | ||
| 1066 | + return addState; | ||
| 1067 | + } else if (this.mounted) { | ||
| 1068 | + this.handleSaveState(addState); | ||
| 1069 | + } | ||
| 1070 | + } else { | ||
| 1071 | + console.error(name +'表数据获取错误!'); | ||
| 1072 | + } | ||
| 1073 | + } else { | ||
| 1074 | + /* | ||
| 1075 | + 修改日期:2021-03-17 | ||
| 1076 | + 修改人:吕杰 | ||
| 1077 | + 区域:以下三行 | ||
| 1078 | + 需求变更:fix 2135 搜索时添加loading动画 | ||
| 1079 | + */ | ||
| 1080 | + if (!isWait && this.mounted) { | ||
| 1081 | + this.handleSaveState({ pageLoading: false }); | ||
| 1082 | + } | ||
| 1083 | + this.getServiceError(dataReturn); | ||
| 1084 | + } | ||
| 1085 | + }; | ||
| 1086 | + | ||
| 1087 | + /* 获取过滤树数据(数据集) */ | ||
| 1088 | + handleGetTreeDataSet = async (params, name) => { | ||
| 1089 | + const { | ||
| 1090 | + configData, condition, isWait, | ||
| 1091 | + } = params; | ||
| 1092 | + const { token, sModelsId, formSrcRoute } = this.state; | ||
| 1093 | + let treeData = []; | ||
| 1094 | + const expandedKeys = []; | ||
| 1095 | + const configDataId = configData.sParentId; | ||
| 1096 | + const dataUrl = `${commonConfig.server_host}filterTree/getFilterTree/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; | ||
| 1097 | + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data; | ||
| 1098 | + if (dataReturn.code === 1) { | ||
| 1099 | + const returnData = dataReturn.dataset.rows; | ||
| 1100 | + if (commonUtils.isNotEmptyArr(returnData)) { | ||
| 1101 | + /* 拼装树结构 */ | ||
| 1102 | + treeData = returnData; | ||
| 1103 | + /* 默认展开第一个父节点 */ | ||
| 1104 | + if (treeData.length > 0) { | ||
| 1105 | + if (commonUtils.isNotEmptyObject(treeData[0]) && commonUtils.isNotEmptyObject(treeData[0].key)) { | ||
| 1106 | + expandedKeys.push(treeData[0].key); | ||
| 1107 | + } else { | ||
| 1108 | + treeData =[]; | ||
| 1109 | + } | ||
| 1110 | + } | ||
| 1111 | + } | ||
| 1112 | + let addState = { | ||
| 1113 | + expandedKeys, | ||
| 1114 | + }; | ||
| 1115 | + if (name) { | ||
| 1116 | + addState[`${name}TreeData`] = treeData; | ||
| 1117 | + } else { | ||
| 1118 | + addState.treeData = treeData; | ||
| 1119 | + } | ||
| 1120 | + addState = { ...addState }; | ||
| 1121 | + if (isWait) { | ||
| 1122 | + return addState; | ||
| 1123 | + } else if (this.mounted) { | ||
| 1124 | + this.handleSaveState(addState); | ||
| 1125 | + } | ||
| 1126 | + } else { | ||
| 1127 | + this.getServiceError(dataReturn); | ||
| 1128 | + } | ||
| 1129 | + }; | ||
| 1130 | + | ||
| 1131 | + /* 重新获取界面配置 */ | ||
| 1132 | + handleGetTableConfig = async (name, sModelsId, oldConfig) => { | ||
| 1133 | + const { token, formSrcRoute, formRoute } = this.state; | ||
| 1134 | + let tableConfig = {}; | ||
| 1135 | + const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; | ||
| 1136 | + const configReturn = (await commonServices.getService(token, configUrl)).data; | ||
| 1137 | + if (configReturn.code === 1) { | ||
| 1138 | + const [configData] = configReturn.dataset.rows; | ||
| 1139 | + const { formData } = configData; | ||
| 1140 | + if (commonUtils.isNotEmptyArr(formData)) { | ||
| 1141 | + if (oldConfig) { | ||
| 1142 | + tableConfig = formData.find(item => item.sId === oldConfig.sId); | ||
| 1143 | + } else if(formRoute === '/indexPage/commonList') { | ||
| 1144 | + tableConfig = formData[0]; | ||
| 1145 | + } else if(formRoute === '/indexPage/commonNewBill') { | ||
| 1146 | + if (name === 'master') { | ||
| 1147 | + tableConfig = formData[0]; | ||
| 1148 | + } else if (name === 'slave') { | ||
| 1149 | + tableConfig = formData.length > 1 ? formData[1] : {}; | ||
| 1150 | + } else if (name === 'slave0') { | ||
| 1151 | + tableConfig = formData.length > 2 ? formData[2] : {}; | ||
| 1152 | + } else if (name === 'slave1') { | ||
| 1153 | + tableConfig = formData.length > 3 ? formData[3] : {}; | ||
| 1154 | + } else if (name === 'slave2') { | ||
| 1155 | + tableConfig = formData.length > 4 ? formData[4] : {}; | ||
| 1156 | + } | ||
| 1157 | + } else { | ||
| 1158 | + if (name === 'master') { | ||
| 1159 | + tableConfig = formData[0]; | ||
| 1160 | + } else if (name === 'slave') { | ||
| 1161 | + tableConfig = formData.length > 1 ? formData[1] : {}; | ||
| 1162 | + } else if (name === 'control') { | ||
| 1163 | + tableConfig = formData.length > 2 ? formData[2] : {}; | ||
| 1164 | + } else if (name === 'materials') { | ||
| 1165 | + tableConfig = formData.length > 3 ? formData[3] : {}; | ||
| 1166 | + } else if (name === 'process') { | ||
| 1167 | + tableConfig = formData.length > 4 ? formData[4] : {}; | ||
| 1168 | + } else if (name === 'slave0') { | ||
| 1169 | + tableConfig = formData.length > 2 ? formData[2] : {}; | ||
| 1170 | + } else if (name === 'slave1') { | ||
| 1171 | + tableConfig = formData.length > 3 ? formData[3] : {}; | ||
| 1172 | + } else if (name === 'slave2') { | ||
| 1173 | + tableConfig = formData.length > 4 ? formData[4] : {}; | ||
| 1174 | + } else if (name === 'slave3') { | ||
| 1175 | + tableConfig = formData.length > 5 ? formData[5] : {}; | ||
| 1176 | + } else if (name === 'slave4') { | ||
| 1177 | + tableConfig = formData.length > 6 ? formData[6] : {}; | ||
| 1178 | + } | ||
| 1179 | + } | ||
| 1180 | + } | ||
| 1181 | + } else { | ||
| 1182 | + this.getServiceError(configReturn); | ||
| 1183 | + } | ||
| 1184 | + return tableConfig; | ||
| 1185 | + } | ||
| 1186 | + /* | ||
| 1187 | + 修改日期:2021-03-18 | ||
| 1188 | + 修改人:吕杰 | ||
| 1189 | + 区域:以下handleSaveState函数 | ||
| 1190 | + 需求变更:添加回调 | ||
| 1191 | + 原代码: | ||
| 1192 | + handleSaveState = (values) => { | ||
| 1193 | + if (this.mounted) { | ||
| 1194 | + this.handleSaveState(values); | ||
| 1195 | + } | ||
| 1196 | + }; | ||
| 1197 | + */ | ||
| 1198 | + /* 数据保存到state */ | ||
| 1199 | + handleSaveState = (values = {}, callback) => { | ||
| 1200 | + if (this.mounted) { | ||
| 1201 | + // 如果将要保存的masterConfig是合并过的,则删除掉 | ||
| 1202 | + if (commonUtils.isNotEmptyObject(values.masterConfig) && values.masterConfig.bMerged) { | ||
| 1203 | + delete values.masterConfig; | ||
| 1204 | + } | ||
| 1205 | + Object.keys(values).forEach(key => { | ||
| 1206 | + // 如果将要保存的slaveConfig是合并过的,则删除掉 | ||
| 1207 | + if (key.startsWith('slave') && key.endsWith('Config') && commonUtils.isNotEmptyObject(values[key]) && values[key].bMerged) { | ||
| 1208 | + delete values[key]; | ||
| 1209 | + } | ||
| 1210 | + }); | ||
| 1211 | + // 如果改变了主表数据,遍历下所有配置sButtonEnabled的字段,生成配置 | ||
| 1212 | + const addState = {}; | ||
| 1213 | + const sRulesJsonTotal = this.handleGetRulesJsonTotal(values); | ||
| 1214 | + if (sRulesJsonTotal) { | ||
| 1215 | + addState.sRulesJsonTotal = sRulesJsonTotal; | ||
| 1216 | + } | ||
| 1217 | + // if (commonUtils.isNotEmptyObject(addState.sRulesJsonTotal)) { | ||
| 1218 | + // console.log('=====sRulesJsonTotal', addState.sRulesJsonTotal); | ||
| 1219 | + // } | ||
| 1220 | + this.setState({ ...values, ...addState }, typeof callback === 'function' ? callback : undefined); | ||
| 1221 | + } | ||
| 1222 | + }; | ||
| 1223 | + | ||
| 1224 | + // 遍历下所有配置sButtonEnabled的字段,生成配置 | ||
| 1225 | + handleGetRulesJsonTotal = (values) => { | ||
| 1226 | + const { masterConfig: masterConfig1, masterData: masterData1 } = values; | ||
| 1227 | + const { masterConfig: masterConfig2, masterData: masterData2, sRulesJsonTotal } = this.state; | ||
| 1228 | + | ||
| 1229 | + const masterConfig = masterConfig1 || masterConfig2; | ||
| 1230 | + const masterData = masterData1 || masterData2; | ||
| 1231 | + | ||
| 1232 | + const condition0 = commonUtils.isEmptyObject(masterConfig1) && commonUtils.isEmptyObject(masterData1); | ||
| 1233 | + const condition1 = commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData1); | ||
| 1234 | + const condition2 = commonUtils.isNotEmptyObject(masterConfig) && sRulesJsonTotal === undefined && commonUtils.isNotEmptyObject(masterData); | ||
| 1235 | + const condition3 = commonUtils.convertObjToStr(masterData1) === commonUtils.convertObjToStr(masterData2) && sRulesJsonTotal !== undefined; | ||
| 1236 | + | ||
| 1237 | + const { sRulesTableList = [] } = this.state; | ||
| 1238 | + let condition4 = false; | ||
| 1239 | + if (sRulesTableList.length) { | ||
| 1240 | + sRulesTableList.forEach(tableName => { | ||
| 1241 | + const { [`${tableName}Data`]: tableData1 } = values; | ||
| 1242 | + const { [`${tableName}Data`]: tableData2 = [] } = this.state; | ||
| 1243 | + if (tableData1 !== undefined && commonUtils.convertObjToStr(tableData1) !== commonUtils.convertObjToStr(tableData2)) { | ||
| 1244 | + condition4 = true; | ||
| 1245 | + } | ||
| 1246 | + }) | ||
| 1247 | + } | ||
| 1248 | + | ||
| 1249 | + if (condition0 || !(condition1 || condition2) || condition3) { | ||
| 1250 | + if (!condition4) { | ||
| 1251 | + return ''; | ||
| 1252 | + } | ||
| 1253 | + } | ||
| 1254 | + | ||
| 1255 | + const { gdsconfigformslave = [] } = masterConfig; | ||
| 1256 | + return gdsconfigformslave.reduce((result, config) => { | ||
| 1257 | + const { sButtonEnabled } = config; | ||
| 1258 | + const sRulesJson = commonUtils.convertStrToObj(sButtonEnabled, []); | ||
| 1259 | + if (commonUtils.isNotEmptyArr(sRulesJson)) { | ||
| 1260 | + for (let i = 0; i < sRulesJson.length; i += 1) { | ||
| 1261 | + const rule = sRulesJson[i] || {}; | ||
| 1262 | + const { condition = [] } = rule; | ||
| 1263 | + let flag = false; // 是否满足条件 | ||
| 1264 | + for (let j = 0; j < condition.length; j += 1) { | ||
| 1265 | + const item = condition[j]; | ||
| 1266 | + const { bFilterName, bFilterCondition, bFilterValue, jsCondition } = item; | ||
| 1267 | + if (jsCondition) { | ||
| 1268 | + flag = commonFunc.getEvalResult({ | ||
| 1269 | + props: {...this.props, ...this.state, ...values}, | ||
| 1270 | + str: jsCondition, | ||
| 1271 | + defaultValue: false, | ||
| 1272 | + reocrdRules: true, | ||
| 1273 | + onSaveState: this.handleSaveState, | ||
| 1274 | + }) | ||
| 1275 | + console.log('=====jsCondition', jsCondition, flag); | ||
| 1276 | + } else if (bFilterName !== undefined && bFilterCondition !== undefined && bFilterValue !== undefined) { | ||
| 1277 | + const currentValue = masterData[bFilterName]; | ||
| 1278 | + flag = this.handleCompareValues(currentValue, bFilterValue, bFilterCondition); | ||
| 1279 | + } | ||
| 1280 | + if (!flag) { | ||
| 1281 | + break; | ||
| 1282 | + } | ||
| 1283 | + } | ||
| 1284 | + if (flag) { | ||
| 1285 | + // console.log('=====匹配的规则', config, rule); | ||
| 1286 | + const columnList = Object.keys(rule).filter(columnName => columnName && columnName.indexOf('Column') !== -1); | ||
| 1287 | + columnList.forEach((columnName) => { | ||
| 1288 | + if (commonUtils.isEmptyArr(result[columnName])) { | ||
| 1289 | + result[columnName] = []; | ||
| 1290 | + } | ||
| 1291 | + result[columnName] = Array.from(new Set([...result[columnName], ...rule[columnName]])); | ||
| 1292 | + }); | ||
| 1293 | + // return result; | ||
| 1294 | + } | ||
| 1295 | + } | ||
| 1296 | + } | ||
| 1297 | + return result; | ||
| 1298 | + }, {}); | ||
| 1299 | + } | ||
| 1300 | + | ||
| 1301 | + // 根据两个值是否满足比较条件 | ||
| 1302 | + handleCompareValues = (value1, value2, compare) => { | ||
| 1303 | + if (value1 === undefined || value2 === undefined) { | ||
| 1304 | + return false; | ||
| 1305 | + } | ||
| 1306 | + switch (compare) { | ||
| 1307 | + case '=': | ||
| 1308 | + return value1 == value2; // eslint-disable-line | ||
| 1309 | + case '==': | ||
| 1310 | + return value1 === value2; | ||
| 1311 | + case '!=': | ||
| 1312 | + return value1 !== value2; | ||
| 1313 | + case '>': | ||
| 1314 | + return value1 > value2; | ||
| 1315 | + case '>=': | ||
| 1316 | + return value1 >= value2; | ||
| 1317 | + case '<': | ||
| 1318 | + return value1 < value2; | ||
| 1319 | + case '<=': | ||
| 1320 | + return value1 <= value2; | ||
| 1321 | + case 'like': | ||
| 1322 | + return value1.includes(value2); | ||
| 1323 | + default: | ||
| 1324 | + return false; | ||
| 1325 | + } | ||
| 1326 | + } | ||
| 1327 | + | ||
| 1328 | + // 合并主表配置和所有sButtonEnabled配置 | ||
| 1329 | + handleMergeMasterConfig = (config) => { | ||
| 1330 | + const { masterConfig: masterConfigOld, sRulesJsonTotal } = this.state; | ||
| 1331 | + const masterConfig = commonUtils.isNotEmptyObject(config) ? config : masterConfigOld; | ||
| 1332 | + if (commonUtils.isEmptyObject(masterConfig)) { | ||
| 1333 | + return {}; | ||
| 1334 | + } | ||
| 1335 | + if (commonUtils.isEmptyObject(sRulesJsonTotal)) { | ||
| 1336 | + return masterConfig; | ||
| 1337 | + } | ||
| 1338 | + const masterConfigNew = lodash.cloneDeep(masterConfig); | ||
| 1339 | + const { gdsconfigformslave } = masterConfigNew; | ||
| 1340 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.showColumn)) { | ||
| 1341 | + sRulesJsonTotal.showColumn.filter(item => item).forEach((item) => { | ||
| 1342 | + const iIndex = gdsconfigformslave.findIndex(child => item === child.sName); | ||
| 1343 | + if (iIndex !== -1) { | ||
| 1344 | + gdsconfigformslave[iIndex].bVisible = true; | ||
| 1345 | + } | ||
| 1346 | + }); | ||
| 1347 | + } | ||
| 1348 | + | ||
| 1349 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.hideColumn)) { | ||
| 1350 | + sRulesJsonTotal.hideColumn.filter(item => item).forEach((item) => { | ||
| 1351 | + const iIndex = gdsconfigformslave.findIndex(child => item === child.sName); | ||
| 1352 | + if (iIndex !== -1) { | ||
| 1353 | + gdsconfigformslave[iIndex].bVisible = false; | ||
| 1354 | + } | ||
| 1355 | + }); | ||
| 1356 | + } | ||
| 1357 | + | ||
| 1358 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.mustColumn)) { | ||
| 1359 | + sRulesJsonTotal.mustColumn.filter(item => item).forEach((item) => { | ||
| 1360 | + const iIndex = gdsconfigformslave.findIndex(child => item === child.sName); | ||
| 1361 | + if (iIndex !== -1) { | ||
| 1362 | + gdsconfigformslave[iIndex].bNotEmpty = true; | ||
| 1363 | + } | ||
| 1364 | + }); | ||
| 1365 | + } | ||
| 1366 | + | ||
| 1367 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.readOnlyColumn)) { | ||
| 1368 | + sRulesJsonTotal.readOnlyColumn.filter(item => item).forEach((item) => { | ||
| 1369 | + const iIndex = gdsconfigformslave.findIndex(child => item === child.sName); | ||
| 1370 | + if (iIndex !== -1) { | ||
| 1371 | + gdsconfigformslave[iIndex].bReadonly = true; | ||
| 1372 | + } | ||
| 1373 | + }); | ||
| 1374 | + } | ||
| 1375 | + return { ...masterConfigNew, bMerged: true }; | ||
| 1376 | + } | ||
| 1377 | + | ||
| 1378 | + // 合并从表配置和所有sButtonEnabled配置 | ||
| 1379 | + handleMergeSlaveConfig = (tableConfig) => { | ||
| 1380 | + const { sRulesJsonTotal } = this.state; | ||
| 1381 | + if (commonUtils.isEmptyObject(tableConfig)) { | ||
| 1382 | + return {}; | ||
| 1383 | + } | ||
| 1384 | + if (commonUtils.isEmptyObject(sRulesJsonTotal)) { | ||
| 1385 | + return tableConfig; | ||
| 1386 | + } | ||
| 1387 | + const { sTbName } = tableConfig; | ||
| 1388 | + const tableConfigNew = lodash.cloneDeep(tableConfig); | ||
| 1389 | + const { gdsconfigformslave } = tableConfigNew; | ||
| 1390 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.showColumn)) { | ||
| 1391 | + sRulesJsonTotal.showColumn.filter(item => item).forEach((item) => { | ||
| 1392 | + const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`); | ||
| 1393 | + if (iIndex !== -1) { | ||
| 1394 | + gdsconfigformslave[iIndex].bVisible = true; | ||
| 1395 | + } | ||
| 1396 | + const iIndex1 = gdsconfigformslave.findIndex(child => `${sTbName}.${child.sControlName}`.includes(item)); | ||
| 1397 | + if (iIndex1 !== -1) { | ||
| 1398 | + if (gdsconfigformslave[iIndex1].sControlName.includes('DividerArea')) { | ||
| 1399 | + gdsconfigformslave[iIndex1].sControlName = gdsconfigformslave[iIndex1].sControlName.split('.hide')[0]; | ||
| 1400 | + } else { | ||
| 1401 | + gdsconfigformslave[iIndex1].bControl = true; | ||
| 1402 | + } | ||
| 1403 | + } | ||
| 1404 | + }); | ||
| 1405 | + } | ||
| 1406 | + | ||
| 1407 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.hideColumn)) { | ||
| 1408 | + sRulesJsonTotal.hideColumn.filter(item => item).forEach((item) => { | ||
| 1409 | + const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`); | ||
| 1410 | + if (iIndex !== -1) { | ||
| 1411 | + gdsconfigformslave[iIndex].bVisible = false; | ||
| 1412 | + } | ||
| 1413 | + const iIndex1 = gdsconfigformslave.findIndex(child => `${sTbName}.${child.sControlName}`.includes(item)); | ||
| 1414 | + if (iIndex1 !== -1) { | ||
| 1415 | + if (gdsconfigformslave[iIndex1].sControlName.includes('DividerArea')) { | ||
| 1416 | + gdsconfigformslave[iIndex1].sControlName = `${gdsconfigformslave[iIndex1].sControlName}.hide`; | ||
| 1417 | + } else { | ||
| 1418 | + gdsconfigformslave[iIndex1].bControl = false; | ||
| 1419 | + } | ||
| 1420 | + } | ||
| 1421 | + }); | ||
| 1422 | + } | ||
| 1423 | + | ||
| 1424 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.mustColumn)) { | ||
| 1425 | + sRulesJsonTotal.mustColumn.filter(item => item).forEach((item) => { | ||
| 1426 | + const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`); | ||
| 1427 | + if (iIndex !== -1) { | ||
| 1428 | + gdsconfigformslave[iIndex].bNotEmpty = true; | ||
| 1429 | + } | ||
| 1430 | + }); | ||
| 1431 | + } | ||
| 1432 | + | ||
| 1433 | + if (commonUtils.isNotEmptyArr(sRulesJsonTotal.readOnlyColumn)) { | ||
| 1434 | + sRulesJsonTotal.readOnlyColumn.filter(item => item).forEach((item) => { | ||
| 1435 | + const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`); | ||
| 1436 | + if (iIndex !== -1) { | ||
| 1437 | + gdsconfigformslave[iIndex].bReadonly = true; | ||
| 1438 | + } | ||
| 1439 | + }); | ||
| 1440 | + } | ||
| 1441 | + return { ...tableConfigNew, bMerged: true }; | ||
| 1442 | + } | ||
| 1443 | + | ||
| 1444 | + /** 修改主表数据 */ | ||
| 1445 | + handleMasterChange = (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => { | ||
| 1446 | + const { masterData: masterDataOld } = this.state; | ||
| 1447 | + const { | ||
| 1448 | + sModelsId, masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config, | ||
| 1449 | + } = this.state; | ||
| 1450 | + const addState = {}; | ||
| 1451 | + let masterData = masterDataNew === undefined ? masterDataOld === undefined ? {} : masterDataOld : masterDataNew; | ||
| 1452 | + let { handleType } = masterData; | ||
| 1453 | + handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType; | ||
| 1454 | + if (sFieldName.substring(0, 1).toLowerCase() === 'c') { | ||
| 1455 | + const sAllField = sFieldName.substring(1, sFieldName.length); | ||
| 1456 | + const allField = sAllField.split('_'); | ||
| 1457 | + const value = changeValue[sFieldName]; | ||
| 1458 | + allField.forEach((item, iArr) => { | ||
| 1459 | + if (value.length > iArr) { | ||
| 1460 | + changeValue[item] = value[iArr]; | ||
| 1461 | + } | ||
| 1462 | + }); | ||
| 1463 | + } | ||
| 1464 | + const bClearSelectedRowKeys = location.pathname.includes('commonList') ? false : true; /* 是否清除从表选择行 */ | ||
| 1465 | + if (!commonUtils.isEmpty(masterConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName)) { | ||
| 1466 | + masterConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1467 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1468 | + (item.sSqlCondition.includes(sFieldName) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1469 | + commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []); | ||
| 1470 | + }); | ||
| 1471 | + if (commonUtils.isNotEmptyObject(slaveConfig)) { | ||
| 1472 | + slaveConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1473 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1474 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1475 | + commonUtils.setStoreDropDownData(sModelsId, 'slave', item.sName, []); | ||
| 1476 | + if (bClearSelectedRowKeys) { | ||
| 1477 | + addState.slaveSelectedRowKeys = []; | ||
| 1478 | + } | ||
| 1479 | + }); | ||
| 1480 | + } | ||
| 1481 | + if (commonUtils.isNotEmptyObject(slave0Config)) { | ||
| 1482 | + slave0Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1483 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1484 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1485 | + commonUtils.setStoreDropDownData(sModelsId, 'slave0', item.sName, []); | ||
| 1486 | + if (bClearSelectedRowKeys) { | ||
| 1487 | + addState.slave0SelectedRowKeys = []; | ||
| 1488 | + } | ||
| 1489 | + }); | ||
| 1490 | + } | ||
| 1491 | + if (commonUtils.isNotEmptyObject(slave1Config)) { | ||
| 1492 | + slave1Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1493 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1494 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1495 | + commonUtils.setStoreDropDownData(sModelsId, 'slave1', item.sName, []); | ||
| 1496 | + if (bClearSelectedRowKeys) { | ||
| 1497 | + addState.slave1SelectedRowKeys = []; | ||
| 1498 | + } | ||
| 1499 | + }); | ||
| 1500 | + } | ||
| 1501 | + if (commonUtils.isNotEmptyObject(slave2Config)) { | ||
| 1502 | + slave2Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1503 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1504 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1505 | + commonUtils.setStoreDropDownData(sModelsId, 'slave2', item.sName, []); | ||
| 1506 | + if (bClearSelectedRowKeys) { | ||
| 1507 | + addState.slave2SelectedRowKeys = []; | ||
| 1508 | + } | ||
| 1509 | + }); | ||
| 1510 | + } | ||
| 1511 | + if (commonUtils.isNotEmptyObject(slave3Config)) { | ||
| 1512 | + slave3Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1513 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1514 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1515 | + commonUtils.setStoreDropDownData(sModelsId, 'slave3', item.sName, []); | ||
| 1516 | + if (bClearSelectedRowKeys) { | ||
| 1517 | + addState.slave3SelectedRowKeys = []; | ||
| 1518 | + } | ||
| 1519 | + }); | ||
| 1520 | + } | ||
| 1521 | + if (commonUtils.isNotEmptyObject(slave4Config)) { | ||
| 1522 | + slave4Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1523 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1524 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1525 | + commonUtils.setStoreDropDownData(sModelsId, 'slave4', item.sName, []); | ||
| 1526 | + if (bClearSelectedRowKeys) { | ||
| 1527 | + addState.slave4SelectedRowKeys = []; | ||
| 1528 | + } | ||
| 1529 | + }); | ||
| 1530 | + } | ||
| 1531 | + if (commonUtils.isNotEmptyObject(slave5Config)) { | ||
| 1532 | + slave5Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1533 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1534 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1535 | + commonUtils.setStoreDropDownData(sModelsId, 'slave5', item.sName, []); | ||
| 1536 | + if (bClearSelectedRowKeys) { | ||
| 1537 | + addState.slave5SelectedRowKeys = []; | ||
| 1538 | + } | ||
| 1539 | + }); | ||
| 1540 | + } | ||
| 1541 | + /* 字段输入时 根据规则 控制其他字段的显示与隐藏 */ | ||
| 1542 | + // const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName); | ||
| 1543 | + // if (iConfigIndex > -1) { | ||
| 1544 | + // if (commonUtils.isEmptyObject(masterConfig.bak)) { | ||
| 1545 | + // masterConfig.bak = JSON.parse(JSON.stringify(masterConfig)); | ||
| 1546 | + // } | ||
| 1547 | + // const sFiledConfig = masterConfig.gdsconfigformslave[iConfigIndex]; | ||
| 1548 | + // if (commonUtils.isNotEmptyObject(sFiledConfig)) { | ||
| 1549 | + // const tableDataRow = { ...masterData, ...changeValue, handleType }; | ||
| 1550 | + // const sRulesJson = sFiledConfig.sButtonEnabled; | ||
| 1551 | + // if (commonUtils.isNotEmptyObject(sRulesJson) && commonUtils.isJSON(sRulesJson)) { | ||
| 1552 | + // const sRulesObjArr = JSON.parse(sRulesJson); | ||
| 1553 | + // if (commonUtils.isNotEmptyArr(sRulesObjArr)) { | ||
| 1554 | + // console.log('sRulesObjArr:', sRulesObjArr); | ||
| 1555 | + // sRulesObjArr.forEach((sRulesObj) => { | ||
| 1556 | + // const { | ||
| 1557 | + // showColumn, hideColumn, condition, tbName, sConfigName, | ||
| 1558 | + // } = sRulesObj; | ||
| 1559 | + // console.log('tbName:', tbName); | ||
| 1560 | + // /* 主表单表字段根据条件控制 其他字段的显示与隐藏 */ | ||
| 1561 | + // if (commonUtils.isEmptyObject(tbName)) { | ||
| 1562 | + // if (commonUtils.isNotEmptyArr(condition)) { | ||
| 1563 | + // let flag = false; | ||
| 1564 | + // for (const item of condition) { | ||
| 1565 | + // const { | ||
| 1566 | + // bFilterName, bFilterCondition, bFilterValue, | ||
| 1567 | + // } = item; | ||
| 1568 | + // if (bFilterCondition === '>') { | ||
| 1569 | + // if (tableDataRow[bFilterName] > bFilterValue) { | ||
| 1570 | + // flag = true; | ||
| 1571 | + // } | ||
| 1572 | + // } else if (bFilterCondition === '=') { | ||
| 1573 | + // if (tableDataRow[bFilterName] === bFilterValue) { | ||
| 1574 | + // flag = true; | ||
| 1575 | + // } | ||
| 1576 | + // } else if (bFilterCondition === '<') { | ||
| 1577 | + // if (tableDataRow[bFilterName] < bFilterValue) { | ||
| 1578 | + // flag = true; | ||
| 1579 | + // } | ||
| 1580 | + // } | ||
| 1581 | + // } | ||
| 1582 | + // if (flag) { | ||
| 1583 | + // if (commonUtils.isNotEmptyArr(showColumn)) { | ||
| 1584 | + // for (const column of showColumn) { | ||
| 1585 | + // const iShowIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 1586 | + // if (iShowIndex > -1) { | ||
| 1587 | + // const sFiledObj = masterConfig.gdsconfigformslave[iShowIndex]; | ||
| 1588 | + // if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 1589 | + // if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') { | ||
| 1590 | + // masterConfig.gdsconfigformslave[iShowIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */ | ||
| 1591 | + // } else { | ||
| 1592 | + // masterConfig.gdsconfigformslave[iShowIndex].bVisible = true; | ||
| 1593 | + // } | ||
| 1594 | + // } | ||
| 1595 | + // } | ||
| 1596 | + // } | ||
| 1597 | + // } | ||
| 1598 | + // if (commonUtils.isNotEmptyArr(hideColumn)) { | ||
| 1599 | + // for (const column of hideColumn) { | ||
| 1600 | + // const iHideIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 1601 | + // if (iHideIndex > -1) { | ||
| 1602 | + // if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') { | ||
| 1603 | + // masterConfig.gdsconfigformslave[iHideIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */ | ||
| 1604 | + // } else { | ||
| 1605 | + // masterConfig.gdsconfigformslave[iHideIndex].bVisible = false; | ||
| 1606 | + // } | ||
| 1607 | + // } | ||
| 1608 | + // } | ||
| 1609 | + // } | ||
| 1610 | + // addState.masterConfig = masterConfig; | ||
| 1611 | + // } | ||
| 1612 | + // } | ||
| 1613 | + // } else { /* 主表字段根据条件控制 其他表格字段的显示与隐藏 */ | ||
| 1614 | + // const { [`${tbName}Config`]: tableConfig } = this.state; | ||
| 1615 | + // // const { controlConfig: tableConfig } = this.state; | ||
| 1616 | + // if (commonUtils.isNotEmptyObject(tableConfig)) { | ||
| 1617 | + // if (commonUtils.isNotEmptyArr(condition)) { | ||
| 1618 | + // let flag = false; | ||
| 1619 | + // for (const item of condition) { | ||
| 1620 | + // const { | ||
| 1621 | + // bFilterName, bFilterCondition, bFilterValue, | ||
| 1622 | + // } = item; | ||
| 1623 | + // if (bFilterCondition === '>') { | ||
| 1624 | + // if (tableDataRow[bFilterName] > bFilterValue) { | ||
| 1625 | + // flag = true; | ||
| 1626 | + // } | ||
| 1627 | + // } else if (bFilterCondition === '=') { | ||
| 1628 | + // if (tableDataRow[bFilterName] === bFilterValue) { | ||
| 1629 | + // flag = true; | ||
| 1630 | + // } | ||
| 1631 | + // } else if (bFilterCondition === '<') { | ||
| 1632 | + // if (tableDataRow[bFilterName] < bFilterValue) { | ||
| 1633 | + // flag = true; | ||
| 1634 | + // } | ||
| 1635 | + // } | ||
| 1636 | + // } | ||
| 1637 | + // if (flag) { | ||
| 1638 | + // if (commonUtils.isNotEmptyArr(showColumn)) { | ||
| 1639 | + // for (const column of showColumn) { | ||
| 1640 | + // const iShowIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 1641 | + // if (iShowIndex > -1) { | ||
| 1642 | + // const sFiledObj = tableConfig.gdsconfigformslave[iShowIndex]; | ||
| 1643 | + // if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 1644 | + // tableConfig.gdsconfigformslave[iShowIndex].bVisible = true; | ||
| 1645 | + // } | ||
| 1646 | + // } | ||
| 1647 | + // } | ||
| 1648 | + // } | ||
| 1649 | + // if (commonUtils.isNotEmptyArr(hideColumn)) { | ||
| 1650 | + // for (const column of hideColumn) { | ||
| 1651 | + // const iHideIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 1652 | + // if (iHideIndex > -1) { | ||
| 1653 | + // const sFiledObj = tableConfig.gdsconfigformslave[iHideIndex]; | ||
| 1654 | + // if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 1655 | + // tableConfig.gdsconfigformslave[iHideIndex].bVisible = false; | ||
| 1656 | + // } | ||
| 1657 | + // } | ||
| 1658 | + // } | ||
| 1659 | + // } | ||
| 1660 | + // if (commonUtils.isNotEmptyObject(tableConfig)) { | ||
| 1661 | + // const tableColumn = commonFunc.getHeaderConfig(tableConfig); | ||
| 1662 | + // // addState.masterConfig = masterConfig; | ||
| 1663 | + // // addState.controlConfig = tableConfig; /* 表格配置塞到addState中 */ | ||
| 1664 | + // // addState.controlColumn = tbColumn; | ||
| 1665 | + // addState[`${tbName}Config`] = tableConfig; | ||
| 1666 | + // addState[`${tbName}Column`] = tableColumn; | ||
| 1667 | + // } | ||
| 1668 | + // } | ||
| 1669 | + // } | ||
| 1670 | + // } | ||
| 1671 | + // } | ||
| 1672 | + // }); | ||
| 1673 | + // } | ||
| 1674 | + // } | ||
| 1675 | + // } | ||
| 1676 | + | ||
| 1677 | + // // if (commonUtils.isEmptyObject(addState.masterConfig) && commonUtils.isNotEmptyObject(masterConfig.bak)) { | ||
| 1678 | + // // addState.masterConfig = masterConfig.bak; | ||
| 1679 | + // // } | ||
| 1680 | + // } | ||
| 1681 | + } | ||
| 1682 | + | ||
| 1683 | + masterData = { ...masterData, ...changeValue, handleType }; | ||
| 1684 | + | ||
| 1685 | + const { dGramWeight, dWlcd, dWlkd, iNumerator } = masterData; | ||
| 1686 | + if ( | ||
| 1687 | + ( | ||
| 1688 | + ['dGramWeight', 'dWlcd', 'dWlkd', 'iNumerator'].includes(sFieldName) || | ||
| 1689 | + commonUtils.isEmptyObject(changeValue) | ||
| 1690 | + ) && | ||
| 1691 | + !commonUtils.isEmpty(dGramWeight) && | ||
| 1692 | + !commonUtils.isEmpty(dWlcd) && | ||
| 1693 | + !commonUtils.isEmpty(dWlkd) && | ||
| 1694 | + !commonUtils.isEmpty(iNumerator) | ||
| 1695 | + ) { | ||
| 1696 | + masterData = commonBusiness.getMaterialsQty(this.props.app, { ...masterData, sMaterialsStyle: `${dWlcd}*${dWlkd}` }, 'iNumerator', 'iDenominatr'); | ||
| 1697 | + if (masterData.iDenominatr) { | ||
| 1698 | + masterData.iDenominatr = Number(masterData.iDenominatr).toFixed(0); | ||
| 1699 | + } | ||
| 1700 | + } | ||
| 1701 | + | ||
| 1702 | + if (isWait) { | ||
| 1703 | + return { masterData, ...addState }; // , sUseInfo: '' | ||
| 1704 | + } else if (this.mounted) { | ||
| 1705 | + this.handleSaveState({ masterData, ...addState }); // , sUseInfo: '' | ||
| 1706 | + return { masterData, ...addState }; | ||
| 1707 | + } | ||
| 1708 | + }; | ||
| 1709 | + | ||
| 1710 | + /** 表格数据更改 */ | ||
| 1711 | + // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData) | ||
| 1712 | + handleTableChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => { | ||
| 1713 | + const { | ||
| 1714 | + [`${name}Config`]: tableConfig, sModelsId, masterData, slaveData, controlData, materialsData, processData, slaveInfoData, slaveChildData, | ||
| 1715 | + slaveSelectedRowKeys, slaveInfoSelectedRowKeys, controlSelectedRowKeys, materialsSelectedRowKeys, processSelectedRowKeys, slaveChildSelectedRowKeys, | ||
| 1716 | + } = this.state; | ||
| 1717 | + const { app } = this.props; | ||
| 1718 | + let { [`${name}Data`]: tableData } = this.state; | ||
| 1719 | + if (name === 'slave' && window.tmpSlaveData) { | ||
| 1720 | + tableData = window.tmpSlaveData; | ||
| 1721 | + } | ||
| 1722 | + const iIndex = tableData.findIndex(item => item.sId === sId); | ||
| 1723 | + let { handleType } = tableData[iIndex]; | ||
| 1724 | + handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType; | ||
| 1725 | + if (sFieldName.substring(0, 1).toLowerCase() === 'c') { | ||
| 1726 | + const sAllField = sFieldName.substring(1, sFieldName.length); | ||
| 1727 | + const allField = sAllField.split('_'); | ||
| 1728 | + const value = changeValue[sFieldName]; | ||
| 1729 | + allField.forEach((item, iArr) => { | ||
| 1730 | + if (value.length > iArr) { | ||
| 1731 | + changeValue[item] = value[iArr]; | ||
| 1732 | + } | ||
| 1733 | + }); | ||
| 1734 | + } | ||
| 1735 | + | ||
| 1736 | + if (!commonUtils.isEmpty(tableConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(tableConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName)) { | ||
| 1737 | + tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 1738 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 1739 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 1740 | + commonUtils.setStoreDropDownData(sModelsId, 'slave', item.sName, []); | ||
| 1741 | + }); | ||
| 1742 | + // tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && item.sSqlCondition.includes(sFieldName)).forEach((item) => { | ||
| 1743 | + // commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []); | ||
| 1744 | + // }); | ||
| 1745 | + | ||
| 1746 | + /* 字段输入时 根据规则 控制其他字段的显示与隐藏 */ | ||
| 1747 | + const iConfigIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName); | ||
| 1748 | + if (iConfigIndex > -1) { | ||
| 1749 | + const sFiledConfig = tableConfig.gdsconfigformslave[iConfigIndex]; | ||
| 1750 | + if (commonUtils.isNotEmptyObject(sFiledConfig)) { | ||
| 1751 | + const tableDataRow = { ...tableData[iIndex], ...changeValue, handleType }; | ||
| 1752 | + const sRulesJson = sFiledConfig.sButtonEnabled; | ||
| 1753 | + if (commonUtils.isNotEmptyObject(sRulesJson) && commonUtils.isJSON(sRulesJson)) { | ||
| 1754 | + const sRulesObj = JSON.parse(sRulesJson); | ||
| 1755 | + if (commonUtils.isNotEmptyObject(sRulesObj)) { | ||
| 1756 | + const { showColumn, hideColumn, condition } = sRulesObj; | ||
| 1757 | + if (commonUtils.isNotEmptyArr(condition)) { | ||
| 1758 | + let flag = false; | ||
| 1759 | + for (const item of condition) { | ||
| 1760 | + const { | ||
| 1761 | + bFilterName, bFilterCondition, bFilterValue, | ||
| 1762 | + } = item; | ||
| 1763 | + if (bFilterCondition === '>') { | ||
| 1764 | + if (tableDataRow[bFilterName] > bFilterValue) { | ||
| 1765 | + flag = true; | ||
| 1766 | + } | ||
| 1767 | + } else if (bFilterCondition === '=') { | ||
| 1768 | + if (tableDataRow[bFilterName] === bFilterValue) { | ||
| 1769 | + flag = true; | ||
| 1770 | + } | ||
| 1771 | + } else if (bFilterCondition === '<') { | ||
| 1772 | + if (tableDataRow[bFilterName] < bFilterValue) { | ||
| 1773 | + flag = true; | ||
| 1774 | + } | ||
| 1775 | + } | ||
| 1776 | + } | ||
| 1777 | + if (flag) { | ||
| 1778 | + if (commonUtils.isNotEmptyArr(showColumn)) { | ||
| 1779 | + for (const column of showColumn) { | ||
| 1780 | + const iShowIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 1781 | + if (iShowIndex > -1) { | ||
| 1782 | + const sFiledObj = tableConfig.gdsconfigformslave[iShowIndex]; | ||
| 1783 | + if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 1784 | + tableConfig.gdsconfigformslave[iShowIndex].bVisible = true; | ||
| 1785 | + } | ||
| 1786 | + } | ||
| 1787 | + } | ||
| 1788 | + } | ||
| 1789 | + if (commonUtils.isNotEmptyArr(hideColumn)) { | ||
| 1790 | + for (const column of hideColumn) { | ||
| 1791 | + const iHideIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 1792 | + if (iHideIndex > -1) { | ||
| 1793 | + tableConfig.gdsconfigformslave[iHideIndex].bVisible = false; | ||
| 1794 | + } | ||
| 1795 | + } | ||
| 1796 | + } | ||
| 1797 | + | ||
| 1798 | + const tableColumn = commonFunc.getHeaderConfig(tableConfig); | ||
| 1799 | + this.handleSaveState({ [`${name}Config`]: tableConfig, [`${name}Column`]: tableColumn }); | ||
| 1800 | + } | ||
| 1801 | + } | ||
| 1802 | + } | ||
| 1803 | + } | ||
| 1804 | + } | ||
| 1805 | + } | ||
| 1806 | + /* 将选中行塞到tableSelectedData数据集合中 */ | ||
| 1807 | + let slaveRow = {}; | ||
| 1808 | + let controlRow = {}; | ||
| 1809 | + let materialsRow ={}; | ||
| 1810 | + let processRow = {}; | ||
| 1811 | + let slaveInfoRow = {}; | ||
| 1812 | + let slaveChildRow = {}; | ||
| 1813 | + if(commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { | ||
| 1814 | + const iSIndex = slaveData.findIndex(item =>slaveSelectedRowKeys.includes(item.sId)); | ||
| 1815 | + if(iSIndex > -1) { | ||
| 1816 | + slaveRow = slaveData[iSIndex]; | ||
| 1817 | + } | ||
| 1818 | + } | ||
| 1819 | + if(commonUtils.isNotEmptyArr(slaveInfoData) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys)) { | ||
| 1820 | + const iSIndex = slaveInfoData.findIndex(item =>slaveInfoSelectedRowKeys.includes(item.sId)); | ||
| 1821 | + if(iSIndex > -1) { | ||
| 1822 | + slaveInfoRow = slaveInfoData[iSIndex]; | ||
| 1823 | + } | ||
| 1824 | + } | ||
| 1825 | + if(commonUtils.isNotEmptyArr(slaveChildData) && commonUtils.isNotEmptyArr(slaveChildSelectedRowKeys)) { | ||
| 1826 | + const iSIndex = slaveChildData.findIndex(item => slaveChildSelectedRowKeys.includes(item.sId)); | ||
| 1827 | + if(iSIndex > -1) { | ||
| 1828 | + slaveChildRow = slaveChildData[iSIndex]; | ||
| 1829 | + } | ||
| 1830 | + } | ||
| 1831 | + if(commonUtils.isNotEmptyArr(controlData) && commonUtils.isNotEmptyArr(controlSelectedRowKeys)) { | ||
| 1832 | + const iCIndex = controlData.findIndex(item => controlSelectedRowKeys.includes(item.sId)); | ||
| 1833 | + if(iCIndex > -1) { | ||
| 1834 | + controlRow = controlData[iCIndex]; | ||
| 1835 | + } | ||
| 1836 | + } | ||
| 1837 | + if(commonUtils.isNotEmptyArr(materialsData) && commonUtils.isNotEmptyArr(materialsSelectedRowKeys)) { | ||
| 1838 | + const iMIndex = materialsData.findIndex(item => materialsSelectedRowKeys.includes(item.sId)); | ||
| 1839 | + if(iMIndex > -1) { | ||
| 1840 | + materialsRow = materialsData[iMIndex]; | ||
| 1841 | + } | ||
| 1842 | + } | ||
| 1843 | + if(commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyArr(processSelectedRowKeys)) { | ||
| 1844 | + const iPIndex = processData.findIndex(item => processSelectedRowKeys.includes(item.sId)); | ||
| 1845 | + if(iIndex > -1) { | ||
| 1846 | + processRow = processData[iPIndex]; | ||
| 1847 | + } | ||
| 1848 | + } | ||
| 1849 | + | ||
| 1850 | + const tableAllData = { | ||
| 1851 | + master: masterData, | ||
| 1852 | + slave: slaveData, | ||
| 1853 | + control: controlData, | ||
| 1854 | + materials: materialsData, | ||
| 1855 | + process: processData, | ||
| 1856 | + slaveInfo: slaveInfoData, | ||
| 1857 | + slaveChild: slaveChildData, | ||
| 1858 | + | ||
| 1859 | + }; | ||
| 1860 | + const tableSelectedData = { | ||
| 1861 | + master: masterData, | ||
| 1862 | + slaveRow: slaveRow, | ||
| 1863 | + controlRow: controlRow, | ||
| 1864 | + materialsRow: materialsRow, | ||
| 1865 | + processRow: processRow, | ||
| 1866 | + slaveInfoRow: slaveInfoRow, | ||
| 1867 | + slaveChildRow: slaveChildRow, | ||
| 1868 | + } | ||
| 1869 | + | ||
| 1870 | + const tableDataRowNew = { ...tableData[iIndex], ...changeValue, handleType }; | ||
| 1871 | + const tableDataAfter = commonBusiness.getKeyUpEvent(name, sFieldName, tableConfig, masterData, tableDataRowNew, true, tableAllData, tableSelectedData, app); | ||
| 1872 | + if (commonUtils.isNotEmptyObject(tableDataAfter)) { | ||
| 1873 | + changeValue = { ...tableDataAfter }; | ||
| 1874 | + } | ||
| 1875 | + } | ||
| 1876 | + if (isWait) { | ||
| 1877 | + return { ...tableData[iIndex], ...changeValue, handleType }; | ||
| 1878 | + } else { | ||
| 1879 | + tableData[iIndex] = { ...tableData[iIndex], ...changeValue, handleType }; | ||
| 1880 | + if (this.mounted) { | ||
| 1881 | + this.handleSaveState({ [`${name}Data`]: tableData, sUseInfo: '' }); | ||
| 1882 | + } | ||
| 1883 | + } | ||
| 1884 | + }; | ||
| 1885 | + /** 添加表格空行 */ | ||
| 1886 | + handleTableAdd = (name, isWait) => { | ||
| 1887 | + /* 外置处理业务 */ | ||
| 1888 | + const { | ||
| 1889 | + [`${name}Config`]: tableConfig, masterData, slaveData, slaveSelectedRowKeys, controlData, controlSelectedRowKeys, processData, processSelectedRowKeys, materialsData, materialsSelectedRowKeys | ||
| 1890 | + } = this.state; | ||
| 1891 | + let { [`${name}Data`]: tableData } = this.state; | ||
| 1892 | + tableData = commonUtils.isEmptyObject(tableData) ? [] : tableData; | ||
| 1893 | + const allTableData = {}; | ||
| 1894 | + allTableData.master = masterData; | ||
| 1895 | + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { | ||
| 1896 | + const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys.toString()); | ||
| 1897 | + allTableData.slave = slaveData[iSlaveIndex]; | ||
| 1898 | + } | ||
| 1899 | + if (commonUtils.isNotEmptyArr(controlSelectedRowKeys) && commonUtils.isNotEmptyArr(controlData)) { | ||
| 1900 | + const iSlaveIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys.toString()); | ||
| 1901 | + allTableData.control = controlData[iSlaveIndex]; | ||
| 1902 | + } | ||
| 1903 | + if (commonUtils.isNotEmptyArr(processSelectedRowKeys)) { | ||
| 1904 | + const iSlaveIndex = processData.findIndex(item => item.sId === processSelectedRowKeys.toString()); | ||
| 1905 | + allTableData.process = processData[iSlaveIndex]; | ||
| 1906 | + } | ||
| 1907 | + if (commonUtils.isNotEmptyArr(materialsSelectedRowKeys)) { | ||
| 1908 | + const iSlaveIndex = materialsData.findIndex(item => item.sId === materialsSelectedRowKeys.toString()); | ||
| 1909 | + allTableData.materials = materialsData[iSlaveIndex]; | ||
| 1910 | + } | ||
| 1911 | + | ||
| 1912 | + const iOrderArr = []; | ||
| 1913 | + tableData.forEach((item) => { | ||
| 1914 | + const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */ | ||
| 1915 | + iOrderArr.push(iOrder); | ||
| 1916 | + }); | ||
| 1917 | + const iOrderMax = Math.max(...iOrderArr); | ||
| 1918 | + let tableDataRow = {}; | ||
| 1919 | + tableDataRow.handleType = 'add'; | ||
| 1920 | + tableDataRow.sId = commonUtils.createSid(); | ||
| 1921 | + tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null; | ||
| 1922 | + tableDataRow.key = tableDataRow.sId; | ||
| 1923 | + tableDataRow.bDefault = false; | ||
| 1924 | + tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 1; | ||
| 1925 | + tableDataRow.defaultAdded = tableData.length === 0; | ||
| 1926 | + allTableData.self = tableDataRow; | ||
| 1927 | + if(tableConfig.sTableType === 'single' || name === 'control') { | ||
| 1928 | + tableDataRow.sNodeId = commonUtils.createSid(); /* 用于建立关联关系 */ | ||
| 1929 | + } | ||
| 1930 | + tableDataRow = { ...tableDataRow, ...commonFunc.getDefaultData(tableConfig, allTableData)}; | ||
| 1931 | + if (isWait) { | ||
| 1932 | + return tableDataRow; | ||
| 1933 | + } else { | ||
| 1934 | + // tableData.splice(index, 1, tableDataRow); /* 该处会导致新增时删除首行 */ | ||
| 1935 | + tableData.push(tableDataRow); | ||
| 1936 | + if (this.mounted) { | ||
| 1937 | + this.handleSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] }); | ||
| 1938 | + } | ||
| 1939 | + } | ||
| 1940 | + }; | ||
| 1941 | + | ||
| 1942 | + // name 不写完整的state名称作用为了要用到total | ||
| 1943 | + /** 删除表格数据 */ | ||
| 1944 | + handleTableDel = (name, isWait, tableSelectedRowKeys, callback) => { | ||
| 1945 | + const { app } = this.props; | ||
| 1946 | + const { [`${name}Data`]: tableDataOld = [] } = this.state; | ||
| 1947 | + let { [`${name}DelData`]: tableDelDataOld = [], [`${name}Pagination`]: pagination = {} } = this.state; | ||
| 1948 | + const tableData = [...tableDataOld]; | ||
| 1949 | + const tableDelData = [...tableDelDataOld]; | ||
| 1950 | + if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) { | ||
| 1951 | + for (const sId of tableSelectedRowKeys) { | ||
| 1952 | + /* 看看删除集合和从表中是否都存在该条数据 */ | ||
| 1953 | + let tableDataIndex = tableData.findIndex(item => item.sId === sId); | ||
| 1954 | + while (tableDataIndex > -1) { | ||
| 1955 | + /* 删除从表中的数据并存入删除集合中 */ | ||
| 1956 | + const slaveDataFilter = tableData[tableDataIndex]; | ||
| 1957 | + tableData.splice(tableDataIndex, 1); | ||
| 1958 | + slaveDataFilter.handleType = 'del'; | ||
| 1959 | + tableDelData.push(slaveDataFilter); | ||
| 1960 | + tableDataIndex = tableData.findIndex(item => item.sId === sId); | ||
| 1961 | + } | ||
| 1962 | + } | ||
| 1963 | + | ||
| 1964 | + const addState = {}; | ||
| 1965 | + if (commonUtils.isNotEmptyObject(pagination)) { | ||
| 1966 | + addState[`${name}Pagination`] = { | ||
| 1967 | + ...pagination, | ||
| 1968 | + total: tableData.length, | ||
| 1969 | + } | ||
| 1970 | + } | ||
| 1971 | + let newSelectedRowKeys = []; | ||
| 1972 | + if(name === 'slave') { /* 删除后定位最后一条 */ | ||
| 1973 | + if(commonUtils.isNotEmptyArr(tableData)) { | ||
| 1974 | + const len = tableData.length -1; | ||
| 1975 | + newSelectedRowKeys = [tableData[len].sId]; | ||
| 1976 | + } | ||
| 1977 | + } | ||
| 1978 | + | ||
| 1979 | + if (isWait) { | ||
| 1980 | + return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: newSelectedRowKeys, ...addState }; | ||
| 1981 | + } else { | ||
| 1982 | + if (this.mounted) { | ||
| 1983 | + this.handleSaveState({ | ||
| 1984 | + [`${name}Data`]: tableData, | ||
| 1985 | + [`${name}DelData`]: tableDelData, | ||
| 1986 | + [`${name}SelectedRowKeys`]: [], | ||
| 1987 | + ...addState, | ||
| 1988 | + }, () => { | ||
| 1989 | + callback && callback(); | ||
| 1990 | + }); | ||
| 1991 | + } | ||
| 1992 | + return true; | ||
| 1993 | + } | ||
| 1994 | + } else { | ||
| 1995 | + if (!isWait) { | ||
| 1996 | + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseDelData')); // 请选择删除数据 | ||
| 1997 | + } | ||
| 1998 | + return false; | ||
| 1999 | + } | ||
| 2000 | + }; | ||
| 2001 | + | ||
| 2002 | + /** 处理选择行发生改变 */ | ||
| 2003 | + handleTableSelectRowChange = (name, selectedRowKeys, isWait) => { | ||
| 2004 | + /* 外置处理业务 */ | ||
| 2005 | + const { | ||
| 2006 | + formRoute, slaveData, sModelsId, [`${name}Config`]: tableConfig, | ||
| 2007 | + } = this.state; | ||
| 2008 | + let { slaveSelectedData } = this.state; | ||
| 2009 | + const addState = {}; | ||
| 2010 | + addState[`${name}SelectedRowKeys`] = selectedRowKeys; | ||
| 2011 | + addState.searchUpDownData = {}; | ||
| 2012 | + const formRouteArr = [ | ||
| 2013 | + '/indexPage/commonList', | ||
| 2014 | + '/indexPage/commonListEdit', | ||
| 2015 | + '/indexPage/commonListTree', | ||
| 2016 | + '/indexPage/commonListLeft' | ||
| 2017 | + ]; | ||
| 2018 | + if (name === 'slave' && (formRouteArr.includes(formRoute) || formRoute.indexOf('/indexOee') > -1)) { | ||
| 2019 | + const slavePageData = slaveData.filter(item => selectedRowKeys.includes(item.sSlaveId)); | ||
| 2020 | + slaveSelectedData = commonUtils.isEmpty(slaveSelectedData) ? [] : slaveSelectedData.filter(item => selectedRowKeys.toString().includes(item.sSlaveId)); | ||
| 2021 | + selectedRowKeys.forEach((item) => { | ||
| 2022 | + const iIndex = slaveSelectedData.findIndex(selectItem => selectItem.sSlaveId === item); | ||
| 2023 | + if (iIndex === -1) { | ||
| 2024 | + const iPageIndex = slavePageData.findIndex(pageItem => pageItem.sSlaveId === item); | ||
| 2025 | + if (iPageIndex > -1) { | ||
| 2026 | + slaveSelectedData.push(slavePageData[iPageIndex]); | ||
| 2027 | + } | ||
| 2028 | + } | ||
| 2029 | + }); | ||
| 2030 | + addState.slaveSelectedData = slaveSelectedData; | ||
| 2031 | + } | ||
| 2032 | + if (commonUtils.isNotEmptyObject(tableConfig)) { | ||
| 2033 | + tableConfig.gdsconfigformslave.forEach((configItem) => { | ||
| 2034 | + const sFieldName = configItem.sName; | ||
| 2035 | + if (!commonUtils.isEmpty(tableConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(tableConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName) && | ||
| 2036 | + (commonUtils.isEmptyArr(this.state[`${name}SelectedRowKeys`]) || selectedRowKeys.toString() !== this.state[`${name}SelectedRowKeys`].toString())) { | ||
| 2037 | + tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) && | ||
| 2038 | + (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) && | ||
| 2039 | + (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => { | ||
| 2040 | + commonUtils.setStoreDropDownData(sModelsId, 'slave', item.sName, []); | ||
| 2041 | + }); | ||
| 2042 | + // tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && item.sSqlCondition.includes(sFieldName)).forEach((item) => { | ||
| 2043 | + // commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []); | ||
| 2044 | + // }); | ||
| 2045 | + } | ||
| 2046 | + }); | ||
| 2047 | + } | ||
| 2048 | + if (this.mounted) { | ||
| 2049 | + if (isWait) { | ||
| 2050 | + return addState; | ||
| 2051 | + } else { | ||
| 2052 | + this.handleSaveState(addState); | ||
| 2053 | + } | ||
| 2054 | + } | ||
| 2055 | + }; | ||
| 2056 | + | ||
| 2057 | + handleViewClick = (name, sName, record, index) => { | ||
| 2058 | + const { | ||
| 2059 | + [`${name}Config`]: slaveConfig, customConfig, [`${name}Data`]: slaveData, [`${name}Pagination`]: slavePagination, formSrcRoute, masterConfig, | ||
| 2060 | + } = this.state; | ||
| 2061 | + let { | ||
| 2062 | + [`${name}FilterCondition`]: slaveFilterCondition, | ||
| 2063 | + } = this.state; | ||
| 2064 | + let picArr = slaveConfig?.gdsconfigformslave.filter(item => (item.sName === sName)); | ||
| 2065 | + if (commonUtils.isNotEmptyArr(customConfig)) { | ||
| 2066 | + picArr = customConfig.filter(item => item.sName === sName); | ||
| 2067 | + } | ||
| 2068 | + if (commonUtils.isNotEmptyObject(sName) && sName.includes('BtnEject')) { | ||
| 2069 | + picArr = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sControlName === sName); | ||
| 2070 | + } | ||
| 2071 | + if (picArr.length > 0) { | ||
| 2072 | + const tableDataRow = record; | ||
| 2073 | + const iIndex = index; | ||
| 2074 | + // let tableDataRow = {}; | ||
| 2075 | + // let iIndex = 0; | ||
| 2076 | + /* 判断slaveData是数组还是对象 */ | ||
| 2077 | + // if (commonUtils.isNotEmptyObject(slaveData) && slaveData.length > 0) { | ||
| 2078 | + // iIndex = slaveData.findIndex(item => item.sId === sId); | ||
| 2079 | + // tableDataRow = iIndex > -1 ? slaveData[iIndex] : {}; | ||
| 2080 | + // } else if (commonUtils.isNotEmptyObject(slaveData)) { | ||
| 2081 | + // tableDataRow = slaveData; | ||
| 2082 | + // } | ||
| 2083 | + const [{ sActiveId }] = picArr; | ||
| 2084 | + let [{ sActiveKey }] = picArr; | ||
| 2085 | + const sFormId = sActiveId === '1' ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId; | ||
| 2086 | + if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes('.')) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */ | ||
| 2087 | + const index = sActiveKey.lastIndexOf('.'); | ||
| 2088 | + sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length); | ||
| 2089 | + } | ||
| 2090 | + const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formSrcRoute}`; | ||
| 2091 | + const filterCondition = []; | ||
| 2092 | + const conditionValues = this.getSqlCondition(picArr[0], name, tableDataRow); | ||
| 2093 | + if (!commonUtils.isEmpty(conditionValues)) { | ||
| 2094 | + Object.keys(conditionValues).forEach((item) => { | ||
| 2095 | + if ((item === 'tStartDate_pro' || item.substring(0, 1) === 'p')) { | ||
| 2096 | + if (!commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2) { | ||
| 2097 | + const tStartDate = moment(conditionValues[item][0]).format(this.sDateFormat); | ||
| 2098 | + const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat); | ||
| 2099 | + filterCondition.push({ | ||
| 2100 | + bFilterName: item, | ||
| 2101 | + bFilterCondition: '=', | ||
| 2102 | + bFilterValue: `${tStartDate},${tEndDate}`, | ||
| 2103 | + }); | ||
| 2104 | + } | ||
| 2105 | + } else if ((item === 'mStartDate_pro' || item.substring(0, 1) === 'm')) { | ||
| 2106 | + if (!commonUtils.isEmpty(conditionValues[item])) { | ||
| 2107 | + const tStartDate = moment(conditionValues[item]).startOf('month').format(this.sDateFormat); | ||
| 2108 | + const tEndDate = moment(conditionValues[item]).endOf('month').add(1, 'days').format(this.sDateFormat); | ||
| 2109 | + filterCondition.push({ | ||
| 2110 | + bFilterName: `t${item.substring(1, item.length)}`, | ||
| 2111 | + bFilterCondition: '=', | ||
| 2112 | + bFilterValue: `${tStartDate},${tEndDate}`, | ||
| 2113 | + }); | ||
| 2114 | + } | ||
| 2115 | + } else if (item.substring(0, 1) === 't') { | ||
| 2116 | + filterCondition.push({ | ||
| 2117 | + bFilterName: item, | ||
| 2118 | + bFilterCondition: '=', | ||
| 2119 | + bFilterValue: moment(conditionValues[item]).format(this.sDateFormat), | ||
| 2120 | + }); | ||
| 2121 | + } else { | ||
| 2122 | + filterCondition.push({ | ||
| 2123 | + bFilterName: item, | ||
| 2124 | + bFilterCondition: '=', | ||
| 2125 | + bFilterValue: conditionValues[item], | ||
| 2126 | + }); | ||
| 2127 | + } | ||
| 2128 | + }); | ||
| 2129 | + } | ||
| 2130 | + let copyTo ={}; | ||
| 2131 | + let bLinkPlanTree = commonUtils.isNotEmptyObject(tableDataRow) && tableDataRow.bLinkPlanTree; | ||
| 2132 | + if(bLinkPlanTree) { | ||
| 2133 | + copyTo = { | ||
| 2134 | + treeKey : tableDataRow.sMachineId + tableDataRow.sWorkCenterId, | ||
| 2135 | + sWorkCenterName: tableDataRow.sWorkCenterName, | ||
| 2136 | + } | ||
| 2137 | + } | ||
| 2138 | + | ||
| 2139 | + let payload = { | ||
| 2140 | + url: sNameUrl, | ||
| 2141 | + sTabId: commonUtils.createSid(), | ||
| 2142 | + sParentId: this.state.sTabId, | ||
| 2143 | + urlDataType: 'newPane', | ||
| 2144 | + checkedId: tableDataRow[sActiveKey], | ||
| 2145 | + bFilter: slaveFilterCondition, | ||
| 2146 | + pageSize: this.state.iPageSize, | ||
| 2147 | + pages: slavePagination, | ||
| 2148 | + currentData: [tableDataRow], | ||
| 2149 | + conditonValues: bLinkPlanTree ? undefined : conditionValues, | ||
| 2150 | + sListFormmasterId: slaveConfig?.sId, | ||
| 2151 | + newKey: tableDataRow[sActiveKey], | ||
| 2152 | + currentIndex: iIndex, | ||
| 2153 | + filterCondition: bLinkPlanTree ? undefined : filterCondition, | ||
| 2154 | + copyTo: copyTo, | ||
| 2155 | + sSrcModelsId: this.state.sModelsId, | ||
| 2156 | + } | ||
| 2157 | + this.props.dispatch({ | ||
| 2158 | + type: 'content/onRouter', | ||
| 2159 | + payload | ||
| 2160 | + }); | ||
| 2161 | + } | ||
| 2162 | + }; | ||
| 2163 | + /* 快捷键跳转 */ | ||
| 2164 | + handleQuickViewClick = (name, sName, record, index, myConfigArr) => { | ||
| 2165 | + const { | ||
| 2166 | + [`${name}Config`]: slaveConfig, customConfig, [`${name}FilterCondition`]: slaveFilterCondition, [`${name}Pagination`]: slavePagination, formSrcRoute, masterConfig, | ||
| 2167 | + } = this.state; | ||
| 2168 | + | ||
| 2169 | + let picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === sName)); | ||
| 2170 | + | ||
| 2171 | + if (commonUtils.isNotEmptyArr(customConfig)) { | ||
| 2172 | + picArr = customConfig.filter(item => item.sName === sName); | ||
| 2173 | + } | ||
| 2174 | + if (commonUtils.isNotEmptyObject(sName) && sName.includes('BtnEject')) { | ||
| 2175 | + picArr = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sControlName === sName); | ||
| 2176 | + } | ||
| 2177 | + if (commonUtils.isNotEmptyArr(myConfigArr)) { | ||
| 2178 | + picArr = myConfigArr; | ||
| 2179 | + } | ||
| 2180 | + if (picArr.length > 0) { | ||
| 2181 | + const tableDataRow = record; | ||
| 2182 | + const iIndex = index; | ||
| 2183 | + // let tableDataRow = {}; | ||
| 2184 | + // let iIndex = 0; | ||
| 2185 | + /* 判断slaveData是数组还是对象 */ | ||
| 2186 | + // if (commonUtils.isNotEmptyObject(slaveData) && slaveData.length > 0) { | ||
| 2187 | + // iIndex = slaveData.findIndex(item => item.sId === sId); | ||
| 2188 | + // tableDataRow = iIndex > -1 ? slaveData[iIndex] : {}; | ||
| 2189 | + // } else if (commonUtils.isNotEmptyObject(slaveData)) { | ||
| 2190 | + // tableDataRow = slaveData; | ||
| 2191 | + // } | ||
| 2192 | + const [{ sActiveId }] = picArr; | ||
| 2193 | + let [{ sActiveKey }] = picArr; | ||
| 2194 | + const sFormId = sActiveId === '1' ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId; | ||
| 2195 | + if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes('.')) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */ | ||
| 2196 | + const index = sActiveKey.lastIndexOf('.'); | ||
| 2197 | + sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length); | ||
| 2198 | + } | ||
| 2199 | + const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formSrcRoute}`; | ||
| 2200 | + const filterCondition = []; | ||
| 2201 | + const conditionValues = this.getSqlCondition(picArr[0], name, tableDataRow); | ||
| 2202 | + if (!commonUtils.isEmpty(conditionValues)) { | ||
| 2203 | + Object.keys(conditionValues).forEach((item) => { | ||
| 2204 | + if ((item === 'tStartDate_pro' || item.substring(0, 1) === 'p')) { | ||
| 2205 | + if (!commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2) { | ||
| 2206 | + const tStartDate = moment(conditionValues[item][0]).format(this.sDateFormat); | ||
| 2207 | + const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat); | ||
| 2208 | + filterCondition.push({ | ||
| 2209 | + bFilterName: item, | ||
| 2210 | + bFilterCondition: '=', | ||
| 2211 | + bFilterValue: `${tStartDate},${tEndDate}`, | ||
| 2212 | + }); | ||
| 2213 | + } | ||
| 2214 | + } else if ((item === 'mStartDate_pro' || item.substring(0, 1) === 'm')) { | ||
| 2215 | + if (!commonUtils.isEmpty(conditionValues[item])) { | ||
| 2216 | + const tStartDate = moment(conditionValues[item]).startOf('month').format(this.sDateFormat); | ||
| 2217 | + const tEndDate = moment(conditionValues[item]).endOf('month').add(1, 'days').format(this.sDateFormat); | ||
| 2218 | + filterCondition.push({ | ||
| 2219 | + bFilterName: `t${item.substring(1, item.length)}`, | ||
| 2220 | + bFilterCondition: '=', | ||
| 2221 | + bFilterValue: `${tStartDate},${tEndDate}`, | ||
| 2222 | + }); | ||
| 2223 | + } | ||
| 2224 | + } else if (item.substring(0, 1) === 't') { | ||
| 2225 | + filterCondition.push({ | ||
| 2226 | + bFilterName: item, | ||
| 2227 | + bFilterCondition: '=', | ||
| 2228 | + bFilterValue: moment(conditionValues[item]).format(this.sDateFormat), | ||
| 2229 | + }); | ||
| 2230 | + } else { | ||
| 2231 | + filterCondition.push({ | ||
| 2232 | + bFilterName: item, | ||
| 2233 | + bFilterCondition: '=', | ||
| 2234 | + bFilterValue: conditionValues[item], | ||
| 2235 | + }); | ||
| 2236 | + } | ||
| 2237 | + }); | ||
| 2238 | + } | ||
| 2239 | + let copyTo = {}; | ||
| 2240 | + if (commonUtils.isNotEmptyObject(tableDataRow) && tableDataRow.bLinkPlanTree) { | ||
| 2241 | + copyTo = { | ||
| 2242 | + treeKey: tableDataRow.sMachineId + tableDataRow.sWorkCenterId, | ||
| 2243 | + sWorkCenterName: tableDataRow.sWorkCenterName, | ||
| 2244 | + }; | ||
| 2245 | + } | ||
| 2246 | + this.props.dispatch({ | ||
| 2247 | + type: 'content/onRouter', | ||
| 2248 | + payload: { | ||
| 2249 | + url: sNameUrl, | ||
| 2250 | + sTabId: commonUtils.createSid(), | ||
| 2251 | + sParentId: this.state.sTabId, | ||
| 2252 | + urlDataType: 'newPane', | ||
| 2253 | + checkedId: (commonUtils.isNotEmptyObject(tableDataRow[sActiveKey])) ? tableDataRow[sActiveKey] : myConfigArr[0].sId, | ||
| 2254 | + sName: myConfigArr[0].sName, | ||
| 2255 | + bFilter: slaveFilterCondition, | ||
| 2256 | + pageSize: this.state.iPageSize, | ||
| 2257 | + pages: slavePagination, | ||
| 2258 | + currentData: [tableDataRow], | ||
| 2259 | + conditonValues: conditionValues, | ||
| 2260 | + sListFormmasterId: slaveConfig.sId, | ||
| 2261 | + newKey: tableDataRow[sActiveKey], | ||
| 2262 | + currentIndex: iIndex, | ||
| 2263 | + filterCondition, | ||
| 2264 | + copyTo, | ||
| 2265 | + sSrcModelsId: this.state.sModelsId, | ||
| 2266 | + }, | ||
| 2267 | + }); | ||
| 2268 | + } | ||
| 2269 | + }; | ||
| 2270 | + | ||
| 2271 | + handleTabModalClick = (name, sName, record, index, showConfig) => { | ||
| 2272 | + this.setState({ | ||
| 2273 | + bTabModal: true, | ||
| 2274 | + tabModalConfig: showConfig, | ||
| 2275 | + tabModalRecord: record, | ||
| 2276 | + }); | ||
| 2277 | + } | ||
| 2278 | + handleRowMove = (addState) => { | ||
| 2279 | + this.handleSaveState(addState); | ||
| 2280 | + }; | ||
| 2281 | + handleFilterDropDownData = (dropDownData, showConfig, name, record) => { | ||
| 2282 | + if (!commonUtils.isEmptyArr(dropDownData)) { | ||
| 2283 | + const conditon = showConfig.sSqlCondition.split(','); | ||
| 2284 | + let orTableName; | ||
| 2285 | + let orFieldName; | ||
| 2286 | + let orFieldNameFilter; | ||
| 2287 | + let orValue; | ||
| 2288 | + conditon.forEach((item) => { | ||
| 2289 | + if (item.indexOf('.') > -1) { | ||
| 2290 | + const tableName = item.split('.')[0]; | ||
| 2291 | + const fieldName = item.split('.')[1]; | ||
| 2292 | + const fieldNameFilter = item.split('.')[2]; | ||
| 2293 | + if (tableName.indexOf('|') > -1) { | ||
| 2294 | + orTableName = tableName.replace('|', ''); | ||
| 2295 | + orFieldName = fieldName; | ||
| 2296 | + orFieldNameFilter = fieldNameFilter; | ||
| 2297 | + if (orFieldName.indexOf('&') > -1) { | ||
| 2298 | + orValue = orFieldName.replace('&', ''); | ||
| 2299 | + } else if (!commonUtils.isEmpty(orFieldNameFilter)) { | ||
| 2300 | + if (name === orTableName && !commonUtils.isEmpty(record)) { | ||
| 2301 | + const data = record; | ||
| 2302 | + orValue = data[orFieldName]; | ||
| 2303 | + } else { | ||
| 2304 | + const data = this.state[`${orTableName}Data`]; | ||
| 2305 | + const selectedRowKeys = this.state[`${orTableName}SelectedRowKeys`]; | ||
| 2306 | + if (typeof data === 'object' && data.constructor === Object) { | ||
| 2307 | + orValue = data[orFieldName]; | ||
| 2308 | + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) { | ||
| 2309 | + const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]); | ||
| 2310 | + if (iIndex > -1) { | ||
| 2311 | + orValue = data[iIndex][orFieldName]; | ||
| 2312 | + } | ||
| 2313 | + } else if (commonUtils.isNotEmptyArr(data)) { | ||
| 2314 | + orValue = data[0][orFieldName]; | ||
| 2315 | + } | ||
| 2316 | + } | ||
| 2317 | + } | ||
| 2318 | + orValue = orValue.toString(); | ||
| 2319 | + } else if (!commonUtils.isEmpty(orFieldName)) { | ||
| 2320 | + // master.sId 作为参数 control.sId.sControlId 作为filterDropdown过滤参数 | ||
| 2321 | + if (!commonUtils.isEmpty(fieldNameFilter)) { | ||
| 2322 | + if (name === tableName && !commonUtils.isEmpty(record)) { | ||
| 2323 | + const data = record; | ||
| 2324 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName] || itemDrop[orFieldNameFilter] === orValue); | ||
| 2325 | + } else { | ||
| 2326 | + const data = this.state[`${tableName}Data`]; | ||
| 2327 | + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`]; | ||
| 2328 | + if (typeof data === 'object' && data.constructor === Object) { | ||
| 2329 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName] || itemDrop[orFieldNameFilter] === orValue); | ||
| 2330 | + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) { | ||
| 2331 | + const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]); | ||
| 2332 | + if (iIndex > -1) { | ||
| 2333 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[iIndex][fieldName] || itemDrop[orFieldNameFilter] === orValue); | ||
| 2334 | + } | ||
| 2335 | + } else if (commonUtils.isNotEmptyArr(data)) { | ||
| 2336 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[0][fieldName] || itemDrop[orFieldNameFilter] === orValue); | ||
| 2337 | + } | ||
| 2338 | + } | ||
| 2339 | + } | ||
| 2340 | + } else if (!commonUtils.isEmpty(fieldNameFilter)) { | ||
| 2341 | + if (name === tableName && !commonUtils.isEmpty(record)) { | ||
| 2342 | + const data = record; | ||
| 2343 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName]); | ||
| 2344 | + } else { | ||
| 2345 | + const data = this.state[`${tableName}Data`]; | ||
| 2346 | + const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`]; | ||
| 2347 | + if (typeof data === 'object' && data.constructor === Object) { | ||
| 2348 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName]); | ||
| 2349 | + } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) { | ||
| 2350 | + const iIndex = data.findIndex(itemData => (commonUtils.isEmpty(itemData.sSlaveId) ? itemData.sId : itemData.sSlaveId) === selectedRowKeys[0]); | ||
| 2351 | + if (iIndex > -1) { | ||
| 2352 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[iIndex][fieldName]); | ||
| 2353 | + } | ||
| 2354 | + } else if (commonUtils.isNotEmptyArr(data)) { | ||
| 2355 | + dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[0][fieldName]); | ||
| 2356 | + } | ||
| 2357 | + } | ||
| 2358 | + } | ||
| 2359 | + } | ||
| 2360 | + }); | ||
| 2361 | + } | ||
| 2362 | + | ||
| 2363 | + // let dropDownData = dropDownDataOld; | ||
| 2364 | + // const data = this.state[`${tableName}Data`]; | ||
| 2365 | + // const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`]; | ||
| 2366 | + // if (commonUtils.isNotEmptyArr(selectedRowKeys)) { | ||
| 2367 | + // const SelectedData = data.filter(item => item.sId === selectedRowKeys[0]); | ||
| 2368 | + // if (SelectedData.length > 0 && commonUtils.isNotEmptyStr(SelectedData[0][fieldName])) { | ||
| 2369 | + // if (commonUtils.isNotEmptyArr(dropDownData)) { | ||
| 2370 | + // dropDownData = dropDownData.filter(item => item[fieldName] === SelectedData[0][fieldName]); | ||
| 2371 | + // } | ||
| 2372 | + // } | ||
| 2373 | + // } | ||
| 2374 | + return dropDownData; | ||
| 2375 | + }; | ||
| 2376 | + /* newRecord新纪录保存后,将数据回到到下拉框中 字段名,主从表名,赋值字段 */ | ||
| 2377 | + handleCallBackRecord = async (sName, name, sId) => { | ||
| 2378 | + const { | ||
| 2379 | + [`${name}SelectedRowKeys`]: tableSelectedRowKeys, sModelsId, [`${name}Data`]: tableNewData, slaveData, masterData, sModelsType, token, formRoute, | ||
| 2380 | + } = this.state; | ||
| 2381 | + const { app } = this.props; | ||
| 2382 | + /* 获取下拉的字段showConfig */ | ||
| 2383 | + const { [`${[name]}Config`]: nameConfig } = this.state; | ||
| 2384 | + const filedShowConfig = nameConfig.gdsconfigformslave.filter(item => (item.sName === sName)); | ||
| 2385 | + const AssignField = commonUtils.isNotEmptyArr(filedShowConfig) ? filedShowConfig[0].sAssignField : ''; | ||
| 2386 | + const sqlDropDownData = await this.getSqlDropDownData(sModelsId, name, filedShowConfig[0]); | ||
| 2387 | + /* 根据sName得到过滤数据 */ | ||
| 2388 | + const dropdownData = sqlDropDownData.dropDownData; | ||
| 2389 | + const filterDataIndex = dropdownData.findIndex(item => (item.sId === sId) || (commonUtils.isNotEmptyObject(item.sNId) && item.sNId === sId)); | ||
| 2390 | + if (filterDataIndex > -1) { | ||
| 2391 | + if (name !== 'master' && commonUtils.isNotEmptyObject(tableSelectedRowKeys)) { | ||
| 2392 | + const newCopyTo = {}; | ||
| 2393 | + const iIndex = tableNewData.findIndex(item => item.sId === tableSelectedRowKeys.toString()); | ||
| 2394 | + newCopyTo.master = masterData; | ||
| 2395 | + newCopyTo.slave = tableNewData[iIndex]; | ||
| 2396 | + let slaveRow = {}; | ||
| 2397 | + slaveRow = { ...tableNewData[iIndex], ...commonFunc.getAssignFieldValue(AssignField, dropdownData[filterDataIndex], newCopyTo) }; // 取赋值字段 | ||
| 2398 | + slaveRow.handleType = commonUtils.isEmpty(slaveRow.handleType) ? 'update' : slaveRow.handleType; | ||
| 2399 | + if (sName === 'sProductId' || sName === 'sProductName') { | ||
| 2400 | + slaveRow.sProductInfo = ''; | ||
| 2401 | + } | ||
| 2402 | + tableNewData[iIndex] = slaveRow; | ||
| 2403 | + | ||
| 2404 | + /* 套装工单、报价单、工艺卡的从表, 点击newRecord后 回带控制表合版数据 */ | ||
| 2405 | + const addState = {}; | ||
| 2406 | + if(formRoute && formRoute.includes('PackTableTree') && name === 'slave') { | ||
| 2407 | + const { controlData } = this.state;; | ||
| 2408 | + let { packData } = this.state; | ||
| 2409 | + if(commonUtils.isEmptyArr(packData)){ | ||
| 2410 | + packData =[]; | ||
| 2411 | + } | ||
| 2412 | + if(controlData.length ===1) { | ||
| 2413 | + const controlRow = controlData[0]; | ||
| 2414 | + const iIndex = packData.findIndex(item=> item.sControlId === controlRow.sId); | ||
| 2415 | + if(iIndex > -1){ | ||
| 2416 | + const packFilterData = packData.filter(item => item.sControlId === controlRow.sId); | ||
| 2417 | + if (commonUtils.isNotEmptyArr(packFilterData)) { | ||
| 2418 | + packFilterData.forEach((itemPack, index) => { | ||
| 2419 | + let packDataRow = itemPack; | ||
| 2420 | + const sControlId = controlRow.sControlId; | ||
| 2421 | + packDataRow.sControlId = controlRow.sId; | ||
| 2422 | + packDataRow.sSlaveId = slaveRow.sId; | ||
| 2423 | + packDataRow.sProductId = slaveRow.sProductId; /* 产品id */ | ||
| 2424 | + packDataRow.sCustomerId = slaveRow.sCustomerId; /* 客户id */ | ||
| 2425 | + packDataRow.sCustomerName = slaveRow.sCustomerName; /* 客户名称 */ | ||
| 2426 | + packDataRow.sProductName = slaveRow.sProductName; /* 产品名称 */ | ||
| 2427 | + packDataRow.sProductNo = slaveRow.sProductNo; /* 产品编号 */ | ||
| 2428 | + packDataRow.dCombineQty = 1; | ||
| 2429 | + packData[index] = { ...packData[index], ...packDataRow }; | ||
| 2430 | + if (commonUtils.isNotEmptyObject(packData[index])) { | ||
| 2431 | + const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[0]; | ||
| 2432 | + const tableCombineSelectedData = []; | ||
| 2433 | + const jsonObj = {}; | ||
| 2434 | + jsonObj.sId = sId; | ||
| 2435 | + jsonObj.sProductNo = sProductNo; /* 产品编号 */ | ||
| 2436 | + jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */ | ||
| 2437 | + jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */ | ||
| 2438 | + jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */ | ||
| 2439 | + jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */ | ||
| 2440 | + tableCombineSelectedData.push(jsonObj); | ||
| 2441 | + const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) ? JSON.stringify(tableCombineSelectedData) : ''; /* JSON对象转换为字符串存放到合版信息中 */ | ||
| 2442 | + controlRow.sCombinedMemo =commonUtils.isNotEmptyObject(sCombinedMemo)? sCombinedMemo: '合版信息'; | ||
| 2443 | + controlRow.handleType = commonUtils.isEmpty(controlRow.handleType) ? 'update' : controlRow.handleType; | ||
| 2444 | + controlData[0]={...controlData,...controlRow}; | ||
| 2445 | + } | ||
| 2446 | + }); | ||
| 2447 | + addState.packData = packData; | ||
| 2448 | + addState.controlData = controlData; | ||
| 2449 | + } | ||
| 2450 | + } | ||
| 2451 | + } | ||
| 2452 | + } | ||
| 2453 | + | ||
| 2454 | + this.handleSaveState({ [`${name}Data`]: tableNewData, ...addState }); | ||
| 2455 | + } else { /* 主表赋值 */ | ||
| 2456 | + const changeValue = commonFunc.getAssignFieldValue(AssignField, dropdownData[filterDataIndex]); | ||
| 2457 | + const masterNewData = { ...masterData, ...changeValue }; // 取赋值字段 | ||
| 2458 | + const sFieldName = sName; | ||
| 2459 | + const addState = {}; | ||
| 2460 | + if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName' || sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName' || sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' || sFieldName === 'tDeliverDate') { | ||
| 2461 | + const slaveDataNew = []; | ||
| 2462 | + for (const item of slaveData) { | ||
| 2463 | + let tableDataRow = ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') && (sModelsType.includes('materialsStock/productionmaterialsadjust'))) ? | ||
| 2464 | + { ...item } : { ...item, [sFieldName]: changeValue[sFieldName] }; | ||
| 2465 | + if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName' || sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') { | ||
| 2466 | + tableDataRow.sTaxId = changeValue.sTaxId; | ||
| 2467 | + tableDataRow.sTaxNo = changeValue.sTaxNo; | ||
| 2468 | + tableDataRow.sTaxName = changeValue.sTaxName; | ||
| 2469 | + tableDataRow.dTaxRate = changeValue.dTaxRate; | ||
| 2470 | + tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType; | ||
| 2471 | + const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials'; | ||
| 2472 | + | ||
| 2473 | + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'sTaxId', masterData, tableDataRow); | ||
| 2474 | + let dMaterialsMoney = ''; | ||
| 2475 | + if (sModelsType.includes('outside/')) { /* 工序发外 */ | ||
| 2476 | + let sComputeId = ''; | ||
| 2477 | + const sSupplyId = changeValue.sSupplyId; | ||
| 2478 | + const sProcessId = tableDataRow.sProcessId; | ||
| 2479 | + /* 根据客户id,工序id获取公式ID */ | ||
| 2480 | + if (commonUtils.isNotEmptyObject(sSupplyId) && commonUtils.isNotEmptyObject(sProcessId)) { | ||
| 2481 | + sComputeId = await commonBusiness.getOutSideProcessFormula({ | ||
| 2482 | + token, sModelsId, sSupplyId, sProcessId, | ||
| 2483 | + }); | ||
| 2484 | + if (commonUtils.isNotEmptyObject(sComputeId)) { | ||
| 2485 | + dMaterialsMoney = await commonBusiness.getFormulaValue({ | ||
| 2486 | + token, sModelsId, masterData, tableDataRow, sComputeId, | ||
| 2487 | + }); | ||
| 2488 | + tableDataRow.dMaterialsMoney = dMaterialsMoney; | ||
| 2489 | + tableDataRow = commonBusiness.getCalculateMoney(app, masterData, tableDataRow, 'Materials'); | ||
| 2490 | + } | ||
| 2491 | + } | ||
| 2492 | + } | ||
| 2493 | + } | ||
| 2494 | + if ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') && (!sModelsType.includes('materialsStock/productionmaterialsadjust'))) { | ||
| 2495 | + tableDataRow.sWareHouseId = changeValue.sWareHouseId; | ||
| 2496 | + tableDataRow.sWareHouseNo = changeValue.sWareHouseNo; | ||
| 2497 | + tableDataRow.sWareHouseName = changeValue.sWareHouseName; | ||
| 2498 | + tableDataRow.sLocationId = changeValue.sLocationId; | ||
| 2499 | + tableDataRow.sLocationNo = changeValue.sLocationNo; | ||
| 2500 | + tableDataRow.sLocationName = changeValue.sLocationName; | ||
| 2501 | + tableDataRow.sWareHouseLocationId = changeValue.sWareHouseLocationId; | ||
| 2502 | + tableDataRow.sWareHouseLocationNo = changeValue.sWareHouseLocationNo; | ||
| 2503 | + tableDataRow.sWareHouseLocationName = changeValue.sWareHouseLocationName; | ||
| 2504 | + tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType; | ||
| 2505 | + } | ||
| 2506 | + slaveDataNew.push(tableDataRow); | ||
| 2507 | + } | ||
| 2508 | + addState.slaveData = slaveDataNew; | ||
| 2509 | + // this.props.onSaveState({ slaveData: slaveDataNew }); | ||
| 2510 | + } | ||
| 2511 | + this.handleSaveState({ [`${name}Data`]: masterNewData, ...addState }); | ||
| 2512 | + } | ||
| 2513 | + } | ||
| 2514 | + } | ||
| 2515 | + | ||
| 2516 | + /** 树选择 */ | ||
| 2517 | + handleTreeSelect = (name, selectedKeys, e) => { | ||
| 2518 | + const { treeNode } = e.node.props; | ||
| 2519 | + this.handleSaveState({ [`${name}SelectedKeys`]: selectedKeys, [`${name}TreeNode`]: treeNode }); | ||
| 2520 | + }; | ||
| 2521 | + /* 通用弹窗 选择数据带回窗体 */ | ||
| 2522 | + handleSelectCommonPopup = (currentPaneName, selectConfig, selectData, tbName, isWait) => { | ||
| 2523 | + // 如果配置了sAfterClickInstruct,先走指令集再走原逻辑,否值直接走原逻辑 | ||
| 2524 | + const { sAfterClickInstruct, showName } = selectConfig; | ||
| 2525 | + if (sAfterClickInstruct) { | ||
| 2526 | + instructSet({ | ||
| 2527 | + ...this.props, | ||
| 2528 | + ...this.state, | ||
| 2529 | + slavepupData: selectData, | ||
| 2530 | + btnConfig: { sInstruct: sAfterClickInstruct, showName }, | ||
| 2531 | + onSaveState: this.handleSaveState, | ||
| 2532 | + callback: () => { | ||
| 2533 | + this.handleSelectCommonPopupNew(currentPaneName, selectConfig, selectData, tbName, isWait); | ||
| 2534 | + } | ||
| 2535 | + }) | ||
| 2536 | + } else { | ||
| 2537 | + if(typeof isWait === 'boolean' && isWait) { | ||
| 2538 | + return this.handleSelectCommonPopupNew(currentPaneName, selectConfig, selectData, tbName, isWait); | ||
| 2539 | + } else { | ||
| 2540 | + this.handleSelectCommonPopupNew(currentPaneName, selectConfig, selectData, tbName); | ||
| 2541 | + } | ||
| 2542 | + } | ||
| 2543 | + }; | ||
| 2544 | + | ||
| 2545 | + handleSelectCommonPopupNew = (currentPaneName, selectConfig, selectData, tbName, isWait) => { | ||
| 2546 | + const { | ||
| 2547 | + [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData, | ||
| 2548 | + controlData, controlSelectedRowKeys, sModelsId, | ||
| 2549 | + } = this.state; | ||
| 2550 | + const { sOnChangeInstruct, showName } = selectConfig; | ||
| 2551 | + const type = 'change'; | ||
| 2552 | + const onChangeNew = commonUtils.convertStrToObj(sOnChangeInstruct, {}); | ||
| 2553 | + const instructType = onChangeNew[type]; | ||
| 2554 | + // 回弹字段直接设置单价 | ||
| 2555 | + async function setProductPrice(tableDataRowAdd, item, props) { | ||
| 2556 | + if (selectConfig.sName === 'sProductId' || selectConfig.sName === 'sProductName' || selectConfig.sName === 'sProductNo') { | ||
| 2557 | + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`; | ||
| 2558 | + const { sCustomerId } = masterData; /* 增加客户id参数 */ | ||
| 2559 | + const value = { | ||
| 2560 | + sProName: 'Sp_Cashier_GetProductPrice', | ||
| 2561 | + paramsMap: { | ||
| 2562 | + sProductGuid: item.sId, | ||
| 2563 | + sCustomerId, | ||
| 2564 | + }, | ||
| 2565 | + }; | ||
| 2566 | + const returnData = (await commonServices.postValueService(props.app.token, value, url)).data; | ||
| 2567 | + if (returnData.code === 1) { | ||
| 2568 | + tableDataRowAdd.dNProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; /* 产品单价 */ | ||
| 2569 | + const dProofingMoney = commonUtils.convertToNum(tableDataRowAdd.dProofingMoney); /* 打样金额 */ | ||
| 2570 | + const dPlateMoney = commonUtils.convertToNum(tableDataRowAdd.dPlateMoney); /* 制版金额 */ | ||
| 2571 | + const dKnifeMouldMoney = commonUtils.convertToNum(tableDataRowAdd.dKnifeMouldMoney); /* 刀模金额 */ | ||
| 2572 | + const dProductQty = commonUtils.convertToNum(tableDataRowAdd.dProductQty); /* 数量 */ | ||
| 2573 | + const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */ | ||
| 2574 | + const { dNetPrice } = props.app.decimals; | ||
| 2575 | + if (dProductQty === 0 || (dProofingMoney === 0 && dPlateMoney === 0 && dKnifeMouldMoney === 0)) { | ||
| 2576 | + const dProductForeignPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; | ||
| 2577 | + tableDataRowAdd.dProductForeignPrice = dProductForeignPrice; | ||
| 2578 | + tableDataRowAdd.dProductPrice = commonUtils.convertFixNum(dProductForeignPrice * dCurrencyRate, dNetPrice); | ||
| 2579 | + } | ||
| 2580 | + } | ||
| 2581 | + return tableDataRowAdd; | ||
| 2582 | + } else { | ||
| 2583 | + return tableDataRowAdd; | ||
| 2584 | + } | ||
| 2585 | + } | ||
| 2586 | + let { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination = {} } = this.state; | ||
| 2587 | + let addReturn = {}; | ||
| 2588 | + if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) { | ||
| 2589 | + const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0]) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1; | ||
| 2590 | + const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1; /* 控制表 */ | ||
| 2591 | + selectData.forEach(async (item, index) => { | ||
| 2592 | + const newCopyTo = {}; | ||
| 2593 | + newCopyTo.master = masterData; | ||
| 2594 | + const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */ | ||
| 2595 | + let sValue = ''; | ||
| 2596 | + if (iIndex > -1) { | ||
| 2597 | + newCopyTo.slave = tableData[iIndex]; | ||
| 2598 | + sValue = tableData[iIndex][sName]; | ||
| 2599 | + } | ||
| 2600 | + if (iControlIndex > -1) { | ||
| 2601 | + newCopyTo.control = controlData[iControlIndex]; | ||
| 2602 | + } | ||
| 2603 | + /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行 */ | ||
| 2604 | + if (selectData.length === 1 || (index === 0 && commonUtils.isEmptyObject(sValue))) { | ||
| 2605 | + let tableDataRow = {}; // 取默认值 | ||
| 2606 | + if (tbName === 'master') { | ||
| 2607 | + tableDataRow = { ...tableData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2608 | + tableData = tableDataRow; | ||
| 2609 | + tableData.handleType = commonUtils.isEmpty(tableData.handleType) ? 'update' : tableData.handleType; | ||
| 2610 | + if (instructType) { | ||
| 2611 | + this.handleExecInstructSet({ | ||
| 2612 | + type, | ||
| 2613 | + sInstruct: instructType, | ||
| 2614 | + showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`, | ||
| 2615 | + }); | ||
| 2616 | + } | ||
| 2617 | + | ||
| 2618 | + } else { | ||
| 2619 | + tableDataRow = { ...tableData[iIndex] }; | ||
| 2620 | + if (tbName === 'slave') { | ||
| 2621 | + tableDataRow.sSqlConditionId = tableDataRow.sId; | ||
| 2622 | + } | ||
| 2623 | + tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2624 | + | ||
| 2625 | + tableData[iIndex] = tableDataRow; | ||
| 2626 | + tableData[iIndex].handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType; | ||
| 2627 | + tableData[iIndex] = await setProductPrice(tableData[iIndex], item, this.props); | ||
| 2628 | + if (instructType) { | ||
| 2629 | + this.handleExecInstructSet({ | ||
| 2630 | + type, | ||
| 2631 | + sInstruct: instructType, | ||
| 2632 | + showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`, | ||
| 2633 | + }); | ||
| 2634 | + } | ||
| 2635 | + } | ||
| 2636 | + } else { | ||
| 2637 | + let tableDataRowAdd = this.handleTableAdd(tbName, true); | ||
| 2638 | + if (tbName === 'slave') { | ||
| 2639 | + tableDataRowAdd.sSqlConditionId = tableDataRowAdd.sId; | ||
| 2640 | + } | ||
| 2641 | + tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2642 | + tableDataRowAdd = await setProductPrice(tableDataRowAdd, item, this.props); | ||
| 2643 | + if (instructType) { | ||
| 2644 | + this.handleExecInstructSet({ | ||
| 2645 | + type, | ||
| 2646 | + sInstruct: instructType, | ||
| 2647 | + showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`, | ||
| 2648 | + }); | ||
| 2649 | + } | ||
| 2650 | + tableData.push(tableDataRowAdd); | ||
| 2651 | + } | ||
| 2652 | + | ||
| 2653 | + pagination = { | ||
| 2654 | + ...pagination, | ||
| 2655 | + total: tableData.length, | ||
| 2656 | + } | ||
| 2657 | + | ||
| 2658 | + if (tbName === 'master') { | ||
| 2659 | + const result = this.handleMasterChange(tbName, selectConfig.sName, {}, null, null, true, tableData); | ||
| 2660 | + tableData = result.masterData; | ||
| 2661 | + } | ||
| 2662 | + | ||
| 2663 | + const addState = { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination }; | ||
| 2664 | + if(typeof isWait !== 'boolean') { | ||
| 2665 | + this.handleSaveState(addState); | ||
| 2666 | + } | ||
| 2667 | + | ||
| 2668 | + }); | ||
| 2669 | + if(typeof isWait === 'boolean' && isWait) { | ||
| 2670 | + addReturn = { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination }; | ||
| 2671 | + return addReturn; | ||
| 2672 | + } | ||
| 2673 | + } | ||
| 2674 | + }; | ||
| 2675 | + | ||
| 2676 | + | ||
| 2677 | + /* 通用弹窗 将选择数据汇总求和带回窗体 */ | ||
| 2678 | + handleSelectCommonPopupSum = (currentPaneName, selectConfig, selectData, tbName) => { | ||
| 2679 | + const { | ||
| 2680 | + [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData, | ||
| 2681 | + controlData, controlSelectedRowKeys, sModelsId, | ||
| 2682 | + } = this.state; | ||
| 2683 | + // 回弹字段直接设置单价 | ||
| 2684 | + async function setProductPrice(tableDataRowAdd, item, props) { | ||
| 2685 | + if (selectConfig.sName === 'sProductId' || selectConfig.sName === 'sProductName' || selectConfig.sName === 'sProductNo') { | ||
| 2686 | + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`; | ||
| 2687 | + const { sCustomerId } = masterData; /* 增加客户id参数 */ | ||
| 2688 | + const value = { | ||
| 2689 | + sProName: 'Sp_Cashier_GetProductPrice', | ||
| 2690 | + paramsMap: { | ||
| 2691 | + sProductGuid: item.sId, | ||
| 2692 | + sCustomerId, | ||
| 2693 | + }, | ||
| 2694 | + }; | ||
| 2695 | + const returnData = (await commonServices.postValueService(props.app.token, value, url)).data; | ||
| 2696 | + if (returnData.code === 1) { | ||
| 2697 | + tableDataRowAdd.dNProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; /* 产品单价 */ | ||
| 2698 | + const dProofingMoney = commonUtils.convertToNum(tableDataRowAdd.dProofingMoney); /* 打样金额 */ | ||
| 2699 | + const dPlateMoney = commonUtils.convertToNum(tableDataRowAdd.dPlateMoney); /* 制版金额 */ | ||
| 2700 | + const dKnifeMouldMoney = commonUtils.convertToNum(tableDataRowAdd.dKnifeMouldMoney); /* 刀模金额 */ | ||
| 2701 | + const dProductQty = commonUtils.convertToNum(tableDataRowAdd.dProductQty); /* 数量 */ | ||
| 2702 | + const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */ | ||
| 2703 | + const { dNetPrice } = props.app.decimals; | ||
| 2704 | + if (dProductQty === 0 || (dProofingMoney === 0 && dPlateMoney === 0 && dKnifeMouldMoney === 0)) { | ||
| 2705 | + const dProductForeignPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; | ||
| 2706 | + tableDataRowAdd.dProductForeignPrice = dProductForeignPrice; | ||
| 2707 | + tableDataRowAdd.dProductPrice = commonUtils.convertFixNum(dProductForeignPrice * dCurrencyRate, dNetPrice); | ||
| 2708 | + } | ||
| 2709 | + } | ||
| 2710 | + return tableDataRowAdd; | ||
| 2711 | + } else { | ||
| 2712 | + return tableDataRowAdd; | ||
| 2713 | + } | ||
| 2714 | + } | ||
| 2715 | + let { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination = {} } = this.state; | ||
| 2716 | + if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) { | ||
| 2717 | + const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0]) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1; | ||
| 2718 | + const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1; /* 控制表 */ | ||
| 2719 | + let dModifyProductQty = 0; | ||
| 2720 | + const jsonData = []; | ||
| 2721 | + let jsonStr = ''; | ||
| 2722 | + selectData.forEach((item, index) => { | ||
| 2723 | + const newCopyTo = {}; | ||
| 2724 | + newCopyTo.master = masterData; | ||
| 2725 | + const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */ | ||
| 2726 | + let sValue = ''; | ||
| 2727 | + if (iIndex > -1) { | ||
| 2728 | + newCopyTo.slave = tableData[iIndex]; | ||
| 2729 | + sValue = tableData[iIndex][sName]; | ||
| 2730 | + } | ||
| 2731 | + if (iControlIndex > -1) { | ||
| 2732 | + newCopyTo.control = controlData[iControlIndex]; | ||
| 2733 | + } | ||
| 2734 | + /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行 */ | ||
| 2735 | + if (false) { | ||
| 2736 | + let tableDataRow = {}; // 取默认值 | ||
| 2737 | + if (tbName === 'master') { | ||
| 2738 | + tableDataRow = { ...tableData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2739 | + tableData = tableDataRow; | ||
| 2740 | + tableData.handleType = commonUtils.isEmpty(tableData.handleType) ? 'update' : tableData.handleType; | ||
| 2741 | + } else { | ||
| 2742 | + dProductQty += commonUtils.isNull(item.dProductQty, 0); /* 赠送数量叠加 */ | ||
| 2743 | + tableDataRow = { ...tableData[iIndex], ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2744 | + tableData[iIndex] = tableDataRow; | ||
| 2745 | + tableData[iIndex].handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType; | ||
| 2746 | + // tableData[iIndex] = await setProductPrice(tableData[iIndex], item, this.props); | ||
| 2747 | + } | ||
| 2748 | + } else { | ||
| 2749 | + let tableDataRowAdd = this.handleTableAdd(tbName, true); | ||
| 2750 | + /* 叠加求和 */ | ||
| 2751 | + dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0); /* 赠送数量叠加 */ | ||
| 2752 | + tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2753 | + // tableDataRowAdd = await setProductPrice(tableDataRowAdd, item, this.props); | ||
| 2754 | + // tableData.push(tableDataRowAdd); | ||
| 2755 | + } | ||
| 2756 | + | ||
| 2757 | + if(selectConfig.sControlName && selectConfig.sControlName.includes('dStockUpConsumeQty')) { /* 备货消耗数 特殊处理 */ | ||
| 2758 | + const obj ={}; | ||
| 2759 | + obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId; | ||
| 2760 | + obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0; | ||
| 2761 | + jsonData.push(obj); | ||
| 2762 | + } | ||
| 2763 | + | ||
| 2764 | + pagination = { | ||
| 2765 | + ...pagination, | ||
| 2766 | + total: tableData.length, | ||
| 2767 | + } | ||
| 2768 | + | ||
| 2769 | + if (tbName === 'master') { | ||
| 2770 | + const result = this.handleMasterChange(tbName, selectConfig.sName, {}, null, null, true, tableData); | ||
| 2771 | + tableData = result.masterData; | ||
| 2772 | + } | ||
| 2773 | + }); | ||
| 2774 | + const addState = {}; | ||
| 2775 | + if (selectConfig.sControlName && selectConfig.sControlName.includes('sumeQty')) { | ||
| 2776 | + /* 找到汇总字段 */ | ||
| 2777 | + const sFileSumName = selectConfig.sAssignField && selectConfig.sAssignField.split(':')[0]; | ||
| 2778 | + addState[sFileSumName] = dModifyProductQty; | ||
| 2779 | + addState.dRavailableQty = dModifyProductQty + tableData[iIndex].dConsumeQty; | ||
| 2780 | + addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType; | ||
| 2781 | + if(commonUtils.isNotEmptyArr(jsonData)) { | ||
| 2782 | + jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */ | ||
| 2783 | + addState.sStockUpConsume = jsonStr; | ||
| 2784 | + } | ||
| 2785 | + tableData[iIndex] = { ...tableData[iIndex], ...addState }; | ||
| 2786 | + } | ||
| 2787 | + this.handleSaveState({ [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination }); | ||
| 2788 | + } | ||
| 2789 | + }; | ||
| 2790 | + | ||
| 2791 | + /* 接口数据带入数据 */ | ||
| 2792 | + handleSelectDialog = (name, selectConfig, selectData, tbName) =>{ | ||
| 2793 | + const { | ||
| 2794 | + [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, sModelsId, slaveNameList, allDataList, masterConfig, | ||
| 2795 | + } = this.state; | ||
| 2796 | + let { masterData } = this.state; | ||
| 2797 | + const addState = {}; | ||
| 2798 | + let { [`${tbName}Data`]: tableData } = this.state; | ||
| 2799 | + if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) { | ||
| 2800 | + const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0]) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1; | ||
| 2801 | + let sControlNameMatchList = []; | ||
| 2802 | + if (tbName === 'master') { | ||
| 2803 | + sControlNameMatchList = ['BtnSendDialog', 'BtnSendDialog.master']; | ||
| 2804 | + } else { | ||
| 2805 | + sControlNameMatchList = [`BtnSendDialog.${tbName}`]; | ||
| 2806 | + } | ||
| 2807 | + | ||
| 2808 | + const btnConfig = masterConfig.gdsconfigformslave.find(item => | ||
| 2809 | + item.sControlName && | ||
| 2810 | + sControlNameMatchList.includes(item.sControlName)) || {} | ||
| 2811 | + | ||
| 2812 | + selectData.forEach(async (item, index) => { | ||
| 2813 | + let dataMap = {}; | ||
| 2814 | + /* 通过主键 找到对应的数据集 对应铺数据 */ | ||
| 2815 | + if(commonUtils.isNotEmptyArr(allDataList)) { | ||
| 2816 | + for (const key of Object.keys(allDataList)) { | ||
| 2817 | + let targetKey = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId; | ||
| 2818 | + targetKey = 'master-'+targetKey; | ||
| 2819 | + if(key && key === targetKey) { | ||
| 2820 | + dataMap = allDataList[key]; | ||
| 2821 | + if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyArr(dataMap)) { | ||
| 2822 | + slaveNameList.forEach((name) => { | ||
| 2823 | + const tableConfig = this.state[name +'Config']; /* 动态配置 */ | ||
| 2824 | + let tableData = []; | ||
| 2825 | + if(commonUtils.isNotEmptyObject(tableConfig)) { | ||
| 2826 | + tableData = dataMap[name +'-'+ tableConfig.sTbName]; /* 动态配置 */ | ||
| 2827 | + if(commonUtils.isNotEmptyObject(tableData)) { | ||
| 2828 | + const newCopyTo = {}; | ||
| 2829 | + newCopyTo.master = masterData; | ||
| 2830 | + const tableNewData = JSON.parse(JSON.stringify(tableData)); | ||
| 2831 | + if(name === 'master') { | ||
| 2832 | + masterData = { ...masterData, ...commonFunc.getAssignFieldValue(btnConfig.sAssignField, tableNewData, newCopyTo) }; // 取赋值字段 | ||
| 2833 | + addState.masterData = masterData; | ||
| 2834 | + } else { | ||
| 2835 | + const btnTableName = btnConfig.sControlName +'.'+ name; | ||
| 2836 | + const btnTableConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => (item.sControlName === btnTableName))) ? | ||
| 2837 | + masterConfig.gdsconfigformslave.filter(item => (item.sControlName === btnTableName))[0] : {};// sButtonEnabled sButtonParam | ||
| 2838 | + | ||
| 2839 | + const newData = []; | ||
| 2840 | + tableNewData.forEach((child) => { | ||
| 2841 | + let newRow ={}; | ||
| 2842 | + if(commonUtils.isNotEmptyObject(btnTableConfig) && btnTableConfig.sAssignField){ | ||
| 2843 | + newRow = { ...child, ...commonFunc.getAssignFieldValue(btnTableConfig.sAssignField, child, newCopyTo) }; // 取赋值字段 | ||
| 2844 | + }else { | ||
| 2845 | + newRow = child; | ||
| 2846 | + } | ||
| 2847 | + newRow = { | ||
| 2848 | + ...newRow, | ||
| 2849 | + handleType: 'add', | ||
| 2850 | + sId: commonUtils.createSid(), | ||
| 2851 | + sParentId: masterData.sId | ||
| 2852 | + }; | ||
| 2853 | + newData.push(newRow); | ||
| 2854 | + }); | ||
| 2855 | + addState[name +'Data'] = newData; | ||
| 2856 | + } | ||
| 2857 | + | ||
| 2858 | + } | ||
| 2859 | + } | ||
| 2860 | + | ||
| 2861 | + }); | ||
| 2862 | + } | ||
| 2863 | + | ||
| 2864 | + } | ||
| 2865 | + | ||
| 2866 | + } | ||
| 2867 | + } | ||
| 2868 | + }); | ||
| 2869 | + console.log('确定后数据:', addState); | ||
| 2870 | + this.handleSaveState({ ...addState }); | ||
| 2871 | + } | ||
| 2872 | + | ||
| 2873 | + } | ||
| 2874 | + | ||
| 2875 | + /* 自定义复制从窗体 选择数据带回窗体 */ | ||
| 2876 | + handleCopyFromSelect = (name, selectConfig, selectData) => { | ||
| 2877 | + const { sModelsType } = this.state; | ||
| 2878 | + let { masterData, slaveData } = this.state; | ||
| 2879 | + const addState = {}; | ||
| 2880 | + if (commonUtils.isNotEmptyArr(selectData)) { | ||
| 2881 | + const newCopyTo = {}; | ||
| 2882 | + newCopyTo.master = masterData; | ||
| 2883 | + selectData.forEach((item) => { | ||
| 2884 | + if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('onlyMaster')) { /* 单主表调用复制从数据 */ | ||
| 2885 | + masterData = { ...masterData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2886 | + masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType; | ||
| 2887 | + addState.masterData = masterData; | ||
| 2888 | + } else { /* 从表调用复制从数据 */ | ||
| 2889 | + if (commonUtils.isEmptyArr(slaveData)) { | ||
| 2890 | + slaveData = []; | ||
| 2891 | + } | ||
| 2892 | + let tableDataRowAdd = this.handleTableAdd('slave', true); | ||
| 2893 | + tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | ||
| 2894 | + slaveData.push(tableDataRowAdd); | ||
| 2895 | + addState.slaveData = slaveData; | ||
| 2896 | + } | ||
| 2897 | + }); | ||
| 2898 | + } | ||
| 2899 | + addState.copyFromChooseVisible = false; | ||
| 2900 | + this.handleSaveState({ ...addState }); | ||
| 2901 | + }; | ||
| 2902 | + | ||
| 2903 | + | ||
| 2904 | + handelControlFieldVisible = (name, configData, tableData) => { | ||
| 2905 | + const addState = {}; | ||
| 2906 | + /* 获取主表数据时表字段数据根据条件控制 本表或其他表格字段的显示与隐藏功能 */ | ||
| 2907 | + if (name === 'master' && commonUtils.isNotEmptyObject(configData) && commonUtils.isNotEmptyObject(tableData)) { | ||
| 2908 | + const masterConfig = configData; | ||
| 2909 | + const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sButtonEnabled)); | ||
| 2910 | + if (iConfigIndex > -1) { | ||
| 2911 | + const sFiledConfig = masterConfig.gdsconfigformslave[iConfigIndex]; | ||
| 2912 | + if (commonUtils.isNotEmptyObject(sFiledConfig)) { | ||
| 2913 | + const tableDataRow = tableData; | ||
| 2914 | + const sRulesJson = sFiledConfig.sButtonEnabled; | ||
| 2915 | + if (commonUtils.isNotEmptyObject(sRulesJson) && commonUtils.isJSON(sRulesJson)) { | ||
| 2916 | + const sRulesObjArr = JSON.parse(sRulesJson); | ||
| 2917 | + if (Array.isArray(sRulesObjArr) && commonUtils.isNotEmptyArr(sRulesObjArr)) { | ||
| 2918 | + console.log('sRulesObjArr:', sRulesObjArr); | ||
| 2919 | + sRulesObjArr.forEach((sRulesObj) => { | ||
| 2920 | + const { | ||
| 2921 | + showColumn, hideColumn, condition, tbName, sConfigName, | ||
| 2922 | + } = sRulesObj; | ||
| 2923 | + /* 主表单表字段根据条件控制 其他字段的显示与隐藏 */ | ||
| 2924 | + if (commonUtils.isEmptyObject(tbName)) { | ||
| 2925 | + if (commonUtils.isNotEmptyArr(condition)) { | ||
| 2926 | + let flag = false; | ||
| 2927 | + for (const item of condition) { | ||
| 2928 | + const { | ||
| 2929 | + bFilterName, bFilterCondition, bFilterValue, | ||
| 2930 | + } = item; | ||
| 2931 | + if (bFilterCondition === '>') { | ||
| 2932 | + if (tableDataRow[bFilterName] > bFilterValue) { | ||
| 2933 | + flag = true; | ||
| 2934 | + } | ||
| 2935 | + } else if (bFilterCondition === '=') { | ||
| 2936 | + if (tableDataRow[bFilterName] === bFilterValue) { | ||
| 2937 | + flag = true; | ||
| 2938 | + } | ||
| 2939 | + } else if (bFilterCondition === '<') { | ||
| 2940 | + if (tableDataRow[bFilterName] < bFilterValue) { | ||
| 2941 | + flag = true; | ||
| 2942 | + } | ||
| 2943 | + } | ||
| 2944 | + } | ||
| 2945 | + if (flag) { | ||
| 2946 | + if (commonUtils.isNotEmptyArr(showColumn)) { | ||
| 2947 | + for (const column of showColumn) { | ||
| 2948 | + const iShowIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 2949 | + if (iShowIndex > -1) { | ||
| 2950 | + const sFiledObj = masterConfig.gdsconfigformslave[iShowIndex]; | ||
| 2951 | + if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 2952 | + if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') { | ||
| 2953 | + masterConfig.gdsconfigformslave[iShowIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */ | ||
| 2954 | + } else { | ||
| 2955 | + masterConfig.gdsconfigformslave[iShowIndex].bVisible = true; | ||
| 2956 | + } | ||
| 2957 | + } | ||
| 2958 | + } | ||
| 2959 | + } | ||
| 2960 | + } | ||
| 2961 | + if (commonUtils.isNotEmptyArr(hideColumn)) { | ||
| 2962 | + for (const column of hideColumn) { | ||
| 2963 | + const iHideIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 2964 | + if (iHideIndex > -1) { | ||
| 2965 | + if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') { | ||
| 2966 | + masterConfig.gdsconfigformslave[iHideIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */ | ||
| 2967 | + } else { | ||
| 2968 | + masterConfig.gdsconfigformslave[iHideIndex].bVisible = false; | ||
| 2969 | + } | ||
| 2970 | + } | ||
| 2971 | + } | ||
| 2972 | + } | ||
| 2973 | + addState.masterConfig = masterConfig; | ||
| 2974 | + } | ||
| 2975 | + } | ||
| 2976 | + } else { /* 主表字段根据条件控制 其他表格字段的显示与隐藏 */ | ||
| 2977 | + const { [`${tbName}Config`]: tableConfig } = this.state; | ||
| 2978 | + // const { controlConfig: tableConfig } = this.state; | ||
| 2979 | + if (commonUtils.isNotEmptyObject(tableConfig)) { | ||
| 2980 | + if (commonUtils.isNotEmptyArr(condition)) { | ||
| 2981 | + let flag = false; | ||
| 2982 | + for (const item of condition) { | ||
| 2983 | + const { | ||
| 2984 | + bFilterName, bFilterCondition, bFilterValue, | ||
| 2985 | + } = item; | ||
| 2986 | + if (bFilterCondition === '>') { | ||
| 2987 | + if (tableDataRow[bFilterName] > bFilterValue) { | ||
| 2988 | + flag = true; | ||
| 2989 | + } | ||
| 2990 | + } else if (bFilterCondition === '=') { | ||
| 2991 | + if (tableDataRow[bFilterName] === bFilterValue) { | ||
| 2992 | + flag = true; | ||
| 2993 | + } | ||
| 2994 | + } else if (bFilterCondition === '<') { | ||
| 2995 | + if (tableDataRow[bFilterName] < bFilterValue) { | ||
| 2996 | + flag = true; | ||
| 2997 | + } | ||
| 2998 | + } | ||
| 2999 | + } | ||
| 3000 | + if (flag) { | ||
| 3001 | + if (commonUtils.isNotEmptyArr(showColumn)) { | ||
| 3002 | + for (const column of showColumn) { | ||
| 3003 | + const iShowIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 3004 | + if (iShowIndex > -1) { | ||
| 3005 | + const sFiledObj = tableConfig.gdsconfigformslave[iShowIndex]; | ||
| 3006 | + if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 3007 | + tableConfig.gdsconfigformslave[iShowIndex].bVisible = true; | ||
| 3008 | + } | ||
| 3009 | + } | ||
| 3010 | + } | ||
| 3011 | + } | ||
| 3012 | + if (commonUtils.isNotEmptyArr(hideColumn)) { | ||
| 3013 | + for (const column of hideColumn) { | ||
| 3014 | + const iHideIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column); | ||
| 3015 | + if (iHideIndex > -1) { | ||
| 3016 | + const sFiledObj = tableConfig.gdsconfigformslave[iHideIndex]; | ||
| 3017 | + if (commonUtils.isNotEmptyObject(sFiledObj)) { | ||
| 3018 | + tableConfig.gdsconfigformslave[iHideIndex].bVisible = false; | ||
| 3019 | + } | ||
| 3020 | + } | ||
| 3021 | + } | ||
| 3022 | + } | ||
| 3023 | + if (commonUtils.isNotEmptyObject(tableConfig)) { | ||
| 3024 | + const tableColumn = commonFunc.getHeaderConfig(tableConfig); | ||
| 3025 | + // addState.masterConfig = masterConfig; | ||
| 3026 | + // addState.controlConfig = tableConfig; /* 表格配置塞到addState中 */ | ||
| 3027 | + // addState.controlColumn = tbColumn; | ||
| 3028 | + addState[`${tbName}Config`] = tableConfig; | ||
| 3029 | + addState[`${tbName}Column`] = tableColumn; | ||
| 3030 | + } | ||
| 3031 | + } | ||
| 3032 | + } | ||
| 3033 | + } | ||
| 3034 | + } | ||
| 3035 | + }); | ||
| 3036 | + } | ||
| 3037 | + } | ||
| 3038 | + } | ||
| 3039 | + } | ||
| 3040 | + } | ||
| 3041 | + return addState; | ||
| 3042 | + } | ||
| 3043 | + | ||
| 3044 | + /* 下拉多选离开事件 */ | ||
| 3045 | + handleTableBlur = async (name, sFileName, record, tableConfig, other) => { | ||
| 3046 | + const { sModelsId, app } = this.props; | ||
| 3047 | + const { controlData, slaveConfig,[`${name}Data`]: tableData , [`${name}Config`]: tempConfig } = this.state; | ||
| 3048 | + let { slaveData: slaveDataOld, masterData, slaveDelData, } = this.state; | ||
| 3049 | + const addState = {}; | ||
| 3050 | + if(commonUtils.isEmptyArr(slaveDelData)) { | ||
| 3051 | + slaveDelData = []; | ||
| 3052 | + } | ||
| 3053 | + if (sFileName === 'sPartsNameNew') { | ||
| 3054 | + if(commonUtils.isNotEmptyArr(controlData)) { | ||
| 3055 | + /* 离开时 把sPartsNameNewId数据挂载到sControlParentId */ | ||
| 3056 | + let iIndex = controlData.findIndex(item => item.sId === record.sId); | ||
| 3057 | + if(iIndex === -1) { | ||
| 3058 | + if(record.sId && record.sId.split('-').length > 1) { | ||
| 3059 | + iIndex = controlData.findIndex(item => item.sId === record.sId.split('-')[0]); | ||
| 3060 | + } | ||
| 3061 | + } | ||
| 3062 | + if (iIndex > -1) { | ||
| 3063 | + addState.sControlParentId = controlData[iIndex].sPartsNameNewId; | ||
| 3064 | + if(commonUtils.isNotEmptyObject(controlData[iIndex].sPartsNameNewId)) { | ||
| 3065 | + controlData[iIndex] = {...controlData[iIndex], ...addState}; | ||
| 3066 | + this.props.onSaveState({ controlData: controlData }); | ||
| 3067 | + } | ||
| 3068 | + } | ||
| 3069 | + } | ||
| 3070 | + } else if (tableConfig.sDropDownType === 'movesql') { /* 通用字段离开调下拉事件 */ | ||
| 3071 | + let slaveRow = record; | ||
| 3072 | + const sqlDropDownData = await this.getSqlDropDownData(sModelsId, name, tableConfig, slaveRow); | ||
| 3073 | + const dDropDownData = sqlDropDownData.dropDownData; | ||
| 3074 | + const iIndex = tableData.findIndex(item => item.sId === record.sId); | ||
| 3075 | + if (commonUtils.isNotEmptyArr(dDropDownData) && iIndex > -1) { | ||
| 3076 | + slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(tableConfig.sAssignField, dDropDownData[0]) }; // 取赋值字段 | ||
| 3077 | + slaveRow.handleType = commonUtils.isEmpty(slaveRow.handleType) ? 'update' : slaveRow.handleType; | ||
| 3078 | + const sButtonParam = tableConfig.sButtonParam; /* 设置多级联动 */ | ||
| 3079 | + if(commonUtils.isNotEmptyObject(sButtonParam)) { | ||
| 3080 | + let sLinkFieldName = 'dMaterialsPrice'; | ||
| 3081 | + if (commonUtils.isJSON(sButtonParam)) { /* 按钮条件 */ | ||
| 3082 | + const linkObj = JSON.parse(sButtonParam); /* 联动配置 */ | ||
| 3083 | + let models = 'Materials'; | ||
| 3084 | + if (linkObj.linkMaterials) { | ||
| 3085 | + sLinkFieldName = linkObj.linkMaterials; | ||
| 3086 | + models = 'Materials'; | ||
| 3087 | + } else if (linkObj.linkProduct) { | ||
| 3088 | + sLinkFieldName = linkObj.linkProduct; | ||
| 3089 | + models = 'Product'; | ||
| 3090 | + } | ||
| 3091 | + slaveRow = commonBusiness.getCalculateAllMoney(app, models, sLinkFieldName, masterData, slaveRow); | ||
| 3092 | + } | ||
| 3093 | + } | ||
| 3094 | + | ||
| 3095 | + tableData[iIndex] = { ...tableData[iIndex] , ...slaveRow }; | ||
| 3096 | + this.setState({ ...addState }); | ||
| 3097 | + } | ||
| 3098 | + } else if(commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyObject(tableConfig.sButtonParam)) { | ||
| 3099 | + let slaveNewData = []; | ||
| 3100 | + const allConfig = { slaveConfig }; | ||
| 3101 | + // console.log('sTmpInfoConfigArr', sTmpInfoConfigArr); | ||
| 3102 | + const sTmpInfoConfig = tableConfig; | ||
| 3103 | + const sButtonParam = tableConfig.sButtonParam; | ||
| 3104 | + const btn = commonUtils.isNotEmptyObject(sButtonParam) && commonUtils.isJSON(sButtonParam)? JSON.parse(sButtonParam) : {};; | ||
| 3105 | + const sProName = commonUtils.isNotEmptyObject(btn) ? btn.sproName : ''; | ||
| 3106 | + const sTmpInfoBySqlBtnName = commonUtils.isNotEmptyObject(btn) ? btn.sControlName : ''; | ||
| 3107 | + const sActiveKey = sTmpInfoConfig.sActiveKey; | ||
| 3108 | + if (commonUtils.isNotEmptyObject(sTmpInfoConfig)) { | ||
| 3109 | + if (commonUtils.isEmptyObject(sTmpInfoBySqlBtnName)) { | ||
| 3110 | + const newCopyTo = {}; | ||
| 3111 | + newCopyTo.master = masterData; | ||
| 3112 | + // newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0]; | ||
| 3113 | + // const sRowData = copyTo.slaveData; | ||
| 3114 | + const sRowData = masterData; | ||
| 3115 | + const value = { sProName, sProInParam: JSON.stringify({ params: sRowData }) }; | ||
| 3116 | + if (other?.iFlag === 1) { | ||
| 3117 | + value.iFlag = 1; | ||
| 3118 | + } | ||
| 3119 | + const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`; | ||
| 3120 | + const dataReturn = (await commonServices.postValueService(app.token, value, url)).data; | ||
| 3121 | + console.log('dataReturn', dataReturn); | ||
| 3122 | + if (dataReturn.code === 1) { | ||
| 3123 | + if (commonUtils.isNotEmptyArr(slaveDataOld)) { | ||
| 3124 | + slaveDataOld.forEach((item) => { | ||
| 3125 | + item.handleType = 'del'; | ||
| 3126 | + slaveDelData.push(item); | ||
| 3127 | + }); | ||
| 3128 | + addState.slaveDelData = slaveDelData; | ||
| 3129 | + } | ||
| 3130 | + const returnData = dataReturn.dataset.rows[0]; | ||
| 3131 | + const slaveReturn = returnData.dataSet.proData; | ||
| 3132 | + if (commonUtils.isNotEmptyArr(slaveReturn)) { | ||
| 3133 | + slaveReturn.forEach((slaveItem) => { | ||
| 3134 | + newCopyTo.slave = slaveItem; | ||
| 3135 | + let slaveRow = commonFunc.getDefaultData(allConfig.slaveConfig, newCopyTo); // 取默认值 | ||
| 3136 | + // if (salveDetailAssignField) { | ||
| 3137 | + // slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo)}; | ||
| 3138 | + // } else if (salveAssignField) { | ||
| 3139 | + // slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo)}; // 取赋值字段 | ||
| 3140 | + // } | ||
| 3141 | + slaveRow = { ...slaveRow, ...slaveItem }; | ||
| 3142 | + slaveRow.handleType = 'add'; | ||
| 3143 | + slaveRow.sId = commonUtils.createSid(); | ||
| 3144 | + slaveRow.sParentId = masterData.sId; | ||
| 3145 | + slaveNewData.push(slaveRow); | ||
| 3146 | + }); | ||
| 3147 | + } | ||
| 3148 | + addState.slaveData = slaveNewData; | ||
| 3149 | + this.setState({ ...addState }); | ||
| 3150 | + } else { | ||
| 3151 | + this.getServiceError({ ...dataReturn, fn: () => this.handleTableBlur(name, sFileName, record, tableConfig, { iFlag: 1 }) }); | ||
| 3152 | + } | ||
| 3153 | + } else if(sTmpInfoBySqlBtnName.includes('sTmpInfoBySql')) { /* 走TmpInfo逻辑 */ | ||
| 3154 | + const newCopyTo = {}; | ||
| 3155 | + newCopyTo.master = masterData; | ||
| 3156 | + /* 找到自定义TempInfo配置 */ | ||
| 3157 | + | ||
| 3158 | + const btnConfig = tempConfig.gdsconfigformslave.filter(item => item.sControlName.includes(sTmpInfoBySqlBtnName)); | ||
| 3159 | + const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`; | ||
| 3160 | + const sConfigformId = commonUtils.isEmpty(btnConfig) ? '' : btnConfig[0].sParentId; | ||
| 3161 | + const sControlName = commonUtils.isNotEmptyObject(sTmpInfoBySqlBtnName) ? sTmpInfoBySqlBtnName : 'TmpInfoBySql'; | ||
| 3162 | + const sAssignField = btnConfig[0].sAssignField; | ||
| 3163 | + const sActiveKeyNew = btnConfig[0].sActiveKey; | ||
| 3164 | + let sRowData = [record]; | ||
| 3165 | + if (name === 'master' && sTmpInfoBySqlBtnName.includes('_update')) { | ||
| 3166 | + const { slaveData } = this.state; | ||
| 3167 | + if (commonUtils.isNotEmptyArr(slaveData)) { | ||
| 3168 | + sRowData = [...sRowData, ...slaveData]; | ||
| 3169 | + } | ||
| 3170 | + } | ||
| 3171 | + const values = { sConfigformId, sControlName, sRowData }; | ||
| 3172 | + if (true){ | ||
| 3173 | + const dataReturn = (await commonServices.postValueService(app.token, values, dataUrl)).data; | ||
| 3174 | + const allReturnMap = {}; | ||
| 3175 | + if (dataReturn.code === 1) { | ||
| 3176 | + const returnData = dataReturn.dataset.rows[0]; | ||
| 3177 | + if (commonUtils.isNotEmptyObject(returnData)) { | ||
| 3178 | + for (const key of Object.keys(returnData)) { | ||
| 3179 | + const sName = `${key}Data`; | ||
| 3180 | + const sDelName = `${key}DelData`; | ||
| 3181 | + // allReturnMap[sName] = returnData[key]; | ||
| 3182 | + let {[`${key}Data`]: oldData, [`${key}Data`]: oldDelData } = this.state; | ||
| 3183 | + if(commonUtils.isEmptyArr(oldDelData)) { | ||
| 3184 | + oldDelData = []; | ||
| 3185 | + } | ||
| 3186 | + if(commonUtils.isEmptyArr(oldData)) { | ||
| 3187 | + oldData = []; | ||
| 3188 | + } | ||
| 3189 | + if(sTmpInfoBySqlBtnName.includes('_edit')) { /* 替换 根据对应字段对比 相同的不管 不同的插入 */ | ||
| 3190 | + /* 对应字段 */ | ||
| 3191 | + const sActiveKey = sTmpInfoConfig.sActiveKey; | ||
| 3192 | + const keyData = returnData[key]; | ||
| 3193 | + let newData = []; | ||
| 3194 | + if(commonUtils.isNotEmptyArr(keyData)) { | ||
| 3195 | + keyData.forEach((child) => { | ||
| 3196 | + const filterData = oldData.filter(item => item[sActiveKeyNew] !== child[sActiveKeyNew]); | ||
| 3197 | + if(commonUtils.isNotEmptyArr(filterData) && filterData.length === oldData.length) { | ||
| 3198 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | ||
| 3199 | + tableRow.sId = commonUtils.createSid(); | ||
| 3200 | + tableRow.sParentId = masterData.sId; | ||
| 3201 | + tableRow.handleType = 'add'; | ||
| 3202 | + newData.push(tableRow); | ||
| 3203 | + } else { /* 相同的根据赋值字段覆盖 */ | ||
| 3204 | + const iIndex = oldData.findIndex(item => item[sActiveKeyNew] === child[sActiveKeyNew]); | ||
| 3205 | + if(iIndex > -1) { | ||
| 3206 | + if(sAssignField) { | ||
| 3207 | + oldData[iIndex] ={...oldData[iIndex], ...commonFunc.getAssignFieldValue(sAssignField, child) }; | ||
| 3208 | + } else { | ||
| 3209 | + oldData[iIndex] ={...oldData[iIndex], ...child }; | ||
| 3210 | + } | ||
| 3211 | + oldData[iIndex].handleType = commonUtils.isEmpty(oldData[iIndex].handleType) ? 'update' : oldData[iIndex].handleType; | ||
| 3212 | + } | ||
| 3213 | + } | ||
| 3214 | + }); | ||
| 3215 | + newData = oldData.concat(newData) | ||
| 3216 | + } | ||
| 3217 | + | ||
| 3218 | + }else if(sTmpInfoBySqlBtnName.includes('_del')) { /* 替换 根据对应字段对比 相同的不管 不同的插入 */ | ||
| 3219 | + /* 对应字段 */ | ||
| 3220 | + oldData.forEach((child) => { | ||
| 3221 | + child.handleType ='del'; | ||
| 3222 | + oldDelData.push(child); | ||
| 3223 | + }); | ||
| 3224 | + allReturnMap[sDelName] = oldDelData; | ||
| 3225 | + oldData = []; | ||
| 3226 | + const keyData = returnData[key]; | ||
| 3227 | + if(commonUtils.isNotEmptyArr(keyData)) { | ||
| 3228 | + keyData.forEach((child) => { | ||
| 3229 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | ||
| 3230 | + tableRow.sId = commonUtils.createSid(); | ||
| 3231 | + if (sName === 'slaveData' && !tableRow.sSqlConditionId) { | ||
| 3232 | + tableRow.sSqlConditionId = tableRow.sId; | ||
| 3233 | + } | ||
| 3234 | + tableRow.sParentId = masterData.sId; | ||
| 3235 | + tableRow.handleType = 'add'; | ||
| 3236 | + oldData.push(tableRow); | ||
| 3237 | + }); | ||
| 3238 | + } | ||
| 3239 | + allReturnMap[sName] = oldData; | ||
| 3240 | + } else if(sTmpInfoBySqlBtnName.includes('_update')) { /* 更新字段 */ | ||
| 3241 | + const keyData = returnData[key]; | ||
| 3242 | + if(commonUtils.isNotEmptyArr(keyData) && sActiveKeyNew) { | ||
| 3243 | + const [linkField, onchangeField] = sActiveKeyNew.split(','); | ||
| 3244 | + const tableName = key.split('_update')[0]; | ||
| 3245 | + const { [`${tableName}Data`]: tableData = [] } = this.state; | ||
| 3246 | + | ||
| 3247 | + for (let i = 0; i < keyData.length; i++) { | ||
| 3248 | + const child = keyData[i]; | ||
| 3249 | + const tableDataFilter = tableData.filter(item => item[linkField] === child[linkField]); | ||
| 3250 | + for (let j = 0; j < tableDataFilter.length; j++) { | ||
| 3251 | + const item = tableDataFilter[j]; | ||
| 3252 | + const iIndex = tableData.findIndex(row => row.sId === item.sId); | ||
| 3253 | + tableData[iIndex] = { ...item, ...child }; | ||
| 3254 | + if (onchangeField && this.state.onEventDataChange) { | ||
| 3255 | + const { sId, [onchangeField]: fieldsValue } = tableData[iIndex]; | ||
| 3256 | + window.tmpSlaveData = tableData; | ||
| 3257 | + tableData[iIndex] = await this.state.onEventDataChange('slave', onchangeField, { [onchangeField]: fieldsValue }, sId, [], true); | ||
| 3258 | + window.tmpSlaveData = null; | ||
| 3259 | + } | ||
| 3260 | + } | ||
| 3261 | + } | ||
| 3262 | + allReturnMap[`${tableName}Data`] = tableData; | ||
| 3263 | + } | ||
| 3264 | + } else { | ||
| 3265 | + allReturnMap[sName] = returnData[key]; | ||
| 3266 | + } | ||
| 3267 | + | ||
| 3268 | + } | ||
| 3269 | + if (commonUtils.isNotEmptyArr(allReturnMap.masterData) && Array.isArray(allReturnMap.masterData)) { | ||
| 3270 | + allReturnMap.masterData = allReturnMap.masterData[0]; | ||
| 3271 | + } | ||
| 3272 | + console.log('allReturnMap:', allReturnMap); | ||
| 3273 | + this.setState({ ...allReturnMap }); | ||
| 3274 | + } | ||
| 3275 | + } else { | ||
| 3276 | + this.getServiceError(dataReturn); | ||
| 3277 | + } | ||
| 3278 | + } | ||
| 3279 | + } | ||
| 3280 | + } else { | ||
| 3281 | + message.error('请正确配置自定义按钮!'); | ||
| 3282 | + } | ||
| 3283 | + } | ||
| 3284 | + }; | ||
| 3285 | + | ||
| 3286 | + /** 通用下载 */ | ||
| 3287 | + handleDownload = (name, flag, tableSelectedRowKeys) => { | ||
| 3288 | + const { sModelsId, app } = this.props; | ||
| 3289 | + const { | ||
| 3290 | + [`${name}Data`]: tableData } = this.state; | ||
| 3291 | + if (tableSelectedRowKeys === undefined || tableSelectedRowKeys.length !== 1) { | ||
| 3292 | + message.warn(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请先选择一条数据 */ | ||
| 3293 | + return; | ||
| 3294 | + } | ||
| 3295 | + const dataSelect = tableData.filter(item => item.sId === tableSelectedRowKeys[0]); | ||
| 3296 | + const { token } = this.props.app; | ||
| 3297 | + const { sPicturePath } = dataSelect[0]; | ||
| 3298 | + const urlPrint = `${commonConfig.file_host}file/download?sModelsId=${sModelsId}&token=${token}&savePathStr=${sPicturePath}`; | ||
| 3299 | + window.open(urlPrint); | ||
| 3300 | + }; | ||
| 3301 | + | ||
| 3302 | + // 调用指令集 | ||
| 3303 | + handleExecInstructSet = (params) => { | ||
| 3304 | + const { type, sInstruct, showName, callback } = params; | ||
| 3305 | + instructSet({ | ||
| 3306 | + ...this.props, | ||
| 3307 | + ...this.state, | ||
| 3308 | + btnConfig: { sInstruct: JSON.stringify(sInstruct), showName }, | ||
| 3309 | + onSaveState: this.handleSaveState, | ||
| 3310 | + callback | ||
| 3311 | + }) | ||
| 3312 | + } | ||
| 3313 | + | ||
| 3314 | + /** | ||
| 3315 | + * 色序反显 | ||
| 3316 | + * @returns | ||
| 3317 | + */ | ||
| 3318 | + showCacheData = (isSColorSerialMemo, data, processSelectedRowId) => { | ||
| 3319 | + if (isSColorSerialMemo && Array.isArray(data)) { | ||
| 3320 | + const value = data.find( | ||
| 3321 | + item => item && item.sId === processSelectedRowId | ||
| 3322 | + ); | ||
| 3323 | + try { | ||
| 3324 | + return { | ||
| 3325 | + sMemoData: JSON.parse(value?.sColorSerialMemo || '[]'), | ||
| 3326 | + isSColorSerialMemo, | ||
| 3327 | + } | ||
| 3328 | + } catch (error) { | ||
| 3329 | + return {} | ||
| 3330 | + } | ||
| 3331 | + } | ||
| 3332 | + } | ||
| 3333 | + | ||
| 3334 | + /** | ||
| 3335 | + * 取消当前页面websocket 状态 | ||
| 3336 | + * @returns | ||
| 3337 | + */ | ||
| 3338 | + handleSendSocketMessageProxy = (flag, showType, sId, sendTo, msgInfo, param) => { | ||
| 3339 | + if (!['noAction'].includes(showType) || !['release'].includes(flag)) { | ||
| 3340 | + return this.handleSendSocketMessage(flag, showType, sId, sendTo, msgInfo, param); | ||
| 3341 | + } | ||
| 3342 | + const { currentPane, userinfo } = this.props.app; | ||
| 3343 | + const { copyTo } = currentPane; | ||
| 3344 | + const { isNotEmptyObject, isNotEmptyArr } = commonUtils; | ||
| 3345 | + if (isNotEmptyObject(copyTo)) { | ||
| 3346 | + const { | ||
| 3347 | + slaveData, srcFormRoute, copyOtherData, masterData, copyToDataSid, | ||
| 3348 | + } = copyTo; | ||
| 3349 | + const sIdArray = [...copyToDataSid || []]; | ||
| 3350 | + | ||
| 3351 | + if (!currentPane?.checkedId) { | ||
| 3352 | + if (isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('materialRequirementsPlanning')) { /* 物料需求计划用sWorkOrderMaterialId作为唯一键 */ | ||
| 3353 | + if (isNotEmptyArr(copyOtherData) && copyOtherData[0]?.name === 'detail' && isNotEmptyArr(copyOtherData[0]?.data)) { | ||
| 3354 | + const slaveDetailData = copyOtherData[0].data; | ||
| 3355 | + slaveDetailData.forEach((item) => { | ||
| 3356 | + const redisKey = item.sWorkOrderMaterialId; | ||
| 3357 | + sIdArray.push(redisKey); | ||
| 3358 | + }); | ||
| 3359 | + } else { /* 变更单、采购申请单 */ | ||
| 3360 | + slaveData.forEach((item) => { | ||
| 3361 | + const redisKey = item.sWorkOrderMaterialId; | ||
| 3362 | + sIdArray.push(redisKey); | ||
| 3363 | + }); | ||
| 3364 | + } | ||
| 3365 | + } | ||
| 3366 | + } | ||
| 3367 | + | ||
| 3368 | + if (isNotEmptyObject(masterData) && | ||
| 3369 | + isNotEmptyObject(masterData.sSrcSlaveId)) { | ||
| 3370 | + sIdArray.push(masterData.sSrcSlaveId); | ||
| 3371 | + } | ||
| 3372 | + | ||
| 3373 | + if (Array.isArray(slaveData)) { | ||
| 3374 | + slaveData.forEach((item) => { | ||
| 3375 | + const redisKey = item.sSlaveId; | ||
| 3376 | + sIdArray.push(redisKey); | ||
| 3377 | + }); | ||
| 3378 | + } | ||
| 3379 | + | ||
| 3380 | + const sId = [...new Set(sIdArray)].filter(Boolean).toString(); | ||
| 3381 | + this.handleSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null); | ||
| 3382 | + } | ||
| 3383 | + this.handleSendSocketMessage('release', 'noAction', currentPane?.checkedId || '', userinfo.sId, null, null); | ||
| 3384 | + this.handleSendSocketMessage('release', 'noAction', currentPane?.formId || '', userinfo.sId, null, null); | ||
| 3385 | + }; | ||
| 3386 | + | ||
| 3387 | + render() { | ||
| 3388 | + return ( | ||
| 3389 | + <div | ||
| 3390 | + className='xlyCommonBase' | ||
| 3391 | + style={{ height: '100%' }} | ||
| 3392 | + ref={(ref) => { this.baseRef = ref; }} | ||
| 3393 | + > | ||
| 3394 | + <ChildComponent | ||
| 3395 | + style={{ height: '100%' }} | ||
| 3396 | + {...this.props} | ||
| 3397 | + {...this.state} | ||
| 3398 | + getSqlDropDownData={this.getSqlDropDownData} | ||
| 3399 | + getSqlCondition={this.getSqlCondition} | ||
| 3400 | + getServiceError={this.getServiceError} | ||
| 3401 | + handleSqlDropDownNewRecord={this.handleSqlDropDownNewRecord} | ||
| 3402 | + getFloatNum={this.getFloatNum} | ||
| 3403 | + getDateFormat={this.getDateFormat} | ||
| 3404 | + handleGetDataOne={this.handleGetDataOne} | ||
| 3405 | + handleGetDataSet={this.handleGetDataSet} | ||
| 3406 | + handleGetTreeDataSet={this.handleGetTreeDataSet} | ||
| 3407 | + onSaveState={this.handleSaveState} | ||
| 3408 | + onChange={this.handleMasterChange} | ||
| 3409 | + onDataChange={this.handleTableChange} | ||
| 3410 | + onDataRowAdd={this.handleTableAdd} | ||
| 3411 | + onDataRowDel={this.handleTableDel} | ||
| 3412 | + onTableSelectRowChange={this.handleTableSelectRowChange} | ||
| 3413 | + onViewClick={this.handleViewClick} | ||
| 3414 | + onTabModalClick={this.handleTabModalClick} | ||
| 3415 | + onQuickViewClick={this.handleQuickViewClick} | ||
| 3416 | + handleSendSocketMessage={this.handleSendSocketMessageProxy} | ||
| 3417 | + onRowMove={this.handleRowMove} | ||
| 3418 | + onFilterDropDownData={this.handleFilterDropDownData} | ||
| 3419 | + onTreeSelect={this.handleTreeSelect} | ||
| 3420 | + onSelectCommonPopup={this.handleSelectCommonPopup} | ||
| 3421 | + onSelectCommonPopupSum={this.handleSelectCommonPopupSum} | ||
| 3422 | + onSelectDialog={this.handleSelectDialog} | ||
| 3423 | + onCopyFromSelect={this.handleCopyFromSelect} | ||
| 3424 | + onGetTableConfig={this.handleGetTableConfig} | ||
| 3425 | + onDropDownBlur={this.handleTableBlur} | ||
| 3426 | + onMergeMasterConfig={this.handleMergeMasterConfig} | ||
| 3427 | + onMergeSlaveConfig={this.handleMergeSlaveConfig} | ||
| 3428 | + onDataRowDownload={this.handleDownload} | ||
| 3429 | + onExecInstructSet={this.handleExecInstructSet} // 调用指令集 | ||
| 3430 | + showCacheData={this.showCacheData} | ||
| 3431 | + /> | ||
| 3432 | + </div> | ||
| 3433 | + ); | ||
| 3434 | + } | ||
| 3435 | + }; | ||
| 3436 | +}; |