/* eslint-disable */ /* eslint-disable react/no-multi-comp,key-spacing,space-in-parens */ /* eslint-disable guard-for-in */ /* eslint-disable no-undef,import/first,prefer-destructuring,jsx-a11y/alt-text */ /* eslint-disable react/no-array-index-key */ /* eslint-disable react/jsx-closing-tag-location */ /* eslint-disable */ import React, { useEffect, useRef, useState } from 'react'; import { CheckCircleFilled, ClockCircleFilled, CloseCircleFilled, DownloadOutlined, ExclamationCircleFilled, RightOutlined, SearchOutlined, StopFilled, UploadOutlined, EyeOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, ExportOutlined, FileOutlined, FileSearchOutlined, ClearOutlined, CaretUpOutlined, CaretDownOutlined, PlaySquareOutlined } from '@ant-design/icons'; import { Icon as LegacyIcon } from '@ant-design/compatible'; // import '@ant-design/compatible/assets/index.css'; import lodash from 'lodash'; import { Table, Input, Checkbox, Button, Upload, message, Popover, Spin, Space, Form, Tooltip, Row, Progress, Modal, Col, Pagination } from 'antd-v4'; import { DndProvider, DropTarget, DragSource } from 'react-dnd'; import { sortableContainer, sortableElement, sortableHandle, } from 'react-sortable-hoc'; import { MenuOutlined } from '@ant-design/icons'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { Resizable } from 'react-resizable'; import styles from './index.less'; import * as commonUtils from '@/utils/utils'; import ShowTypeNew from '@/components/Common/CommonComponent'; import Highlighter from 'react-highlight-words'; import commonConfig from '@/utils/config'; import update from 'immutability-helper'; import * as commonFunc from '@/components/Common/commonFunc'; import moment from 'moment'; import ParamIcon from '@/assets/param.svg'; import sAlumiteIcon from '@/assets/sAlumite.svg'; import ReplaceIcon from '@/assets/extract.svg'; import DisReplaceIcon from '@/assets/disableExtract.svg'; import DisAlumiteIcon from '@/assets/disabledsAlumite.svg'; import ShowImg from '@/components/Common/ShowImage/ShowImage'; import ShowImgStyle from '@/components/Common/ShowImage/ShowImage.less'; import AntdDraggableModal from '@/components/Common/AntdDraggableModal'; import CommonListSelectTree from '@/components/Common/CommonListSelectTree'; import CommonListSelect from '@/components/Common/CommonListSelect'; import CommonList from '@/components/Common/CommonList'; import CommonListTreeSelect from '@/components/Common/CommonListTreeSelect'; import AntdDraggableDiv from '@/components/Common/AntdDraggableDiv'; import SlaveMemo from '@/components/Common/SlaveMemo'; import { VList } from '@/components/Vlist'; import { VList as VListNew } from '@/components/VlistNew'; import SvgIcon from "../../SvgIcon"; import PrintPdf from '@/components/PrintPdf/PrintPdf'; import OfficePreview from '@/components/Common/OfficePreview'; import EditTableCommonListSelectFlex from '@/components/Common/CommonListSelectFlex/EditTableCommonListSelectFlex'; import ColorInfo from './colorInfo'; // import { VList } from 'virtuallist-antd'; /* 获取配置及数据 */ const FormItem = Form.Item; const { confirm } = Modal; const ResizeableTitle = (props) => { const { onResize, width, ...restProps } = props; if (!width) { return ; } return ( { e.stopPropagation(); }} key={lodash.uniqueId()} /> } onResize={onResize} draggableOpts={{ enableUserSelectHack: false }} > ); }; let dragingIndex = -1; // 用于设置拖拽Row时样式 let moverow = null; // 定义move事件,解决warn const BodyRow = (props) => { const { isOver, connectDragSource, connectDropTarget, move, ...restProps } = props; moverow = move; const ref = useRef(null); const style = { ...restProps.style, cursor: 'move' }; let { className } = restProps; if (isOver) { if (restProps.index > dragingIndex) { className += ' drop-over-downward'; } if (restProps.index < dragingIndex) { className += ' drop-over-upward'; } } connectDragSource(connectDropTarget(ref)); return ; }; // DragSource 拖拽事件的方法对象 const rowSource = { beginDrag(props) { const dragingKey = props["data-row-key"] dragingIndex = props.index; return { 'data-row-key': dragingKey, index: props.index, } // dragingIndex = props.index; // return { // index: props.index, // }; }, }; // DropTarget 拖拽事件的方法对象 const rowTarget = { drop(props, monitor) { const dragIndex = monitor.getItem().index; const hoverIndex = props.index; const dragKey = monitor.getItem()["data-row-key"]; const hoverKey = props["data-row-key"]; if (dragKey === hoverKey) { return; } props.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); monitor.getItem().index = hoverIndex; monitor.getItem()["data-row-key"] = hoverKey; }, }; const DragableBodyRow = DropTarget('row', rowTarget, (connect, monitor) => ({ connectDropTarget: connect.dropTarget(), isOver: monitor.isOver(), }))( DragSource('row', rowSource, connect => ({ connectDragSource: connect.dragSource(), }))(BodyRow), ); /* ================================================================== */ class CommonTableRc extends React.Component { /** 构造函数 */ constructor(props) { super(props); this.state = { navigation: 'navigation', previewVisible: false, /* 图片预览弹窗 */ previewImage: '', /* 预览图片地址 */ headerColumn: [], /* 表头信息(数据类型:数组对象) */ slaveInfoHeaderColumn: [], /* 表头信息(数据类型:数组对象) */ tableColumn: [], /* table的表头信息(数据类型:数组对象) */ tableInfoColumn: [], slaveInfoTableColumn: [], selectedRowKeys: [], /* 已选择的数据行(数据格式:数组) */ slaveInfoSelectedRowKeys: [], dataSource: [], /* 数据(数据格式:数组对象) */ totalData: [], /* 总计数据 */ totalData1: [], /* 总计数据1 */ enabled: false, /* 是否为编辑 */ filteredValue: [], /* 过滤数据值 */ expKeys: [], /* 展开数据行(数据格式:数组) */ showimgs: false, // 必须字段控制弹框显示隐藏 firstIndex: 0, // 点击时默认下标 commonPopupVisible: false, commonFieldPopupVisible: false, openNewTabFlag: false, // 是否因在弹窗中打开新页签离开本页; randomId: commonUtils.createSid(), realizeHeight: 0, tableClassName: 'table_' + commonUtils.createSid(), commonFileDownloadVisible: false, // 多文件下载弹窗 commonFileDownloadList: [], // 多文件列表 pdfFileVisible: false, // pdf文件弹窗 bOperateMoreVisible: false, /* 复制更多弹窗 */ pdfFileUrl: '', currentHoverSid: '', simpleModalVisible: false, simpleModalWord: '', selectedSumData: {}, /* 部分勾选合计数据 */ selectedRowCount: 0, /* 部分勾选行数 */ }; this.rowKey = commonUtils.isNotEmptyObject(props.tableProps) && !commonUtils.isEmpty(props.tableProps.rowKey) ? props.tableProps.rowKey : 'sId'; /* 表格主键 */ this.config = {}; /* 配置信息(基础)(数据格式:对象) */ this.tableColumn = []; /* table的表头信息(数据类型:数组对象) */ this.tableInfoColumn = []; this.scrollX = 0; /* 表格宽度统计值(数据格式:整形) */ this.scrollY = this.props.tableProps ? this.props.tableProps.AutoTableHeight ? this.props.tableProps.AutoTableHeight : 0 : 0; this.scrollInfoX = 0; /* 表格宽度统计值(数据格式:整形) */ this.formId = ''; /* 窗体Id(数据格式:字符串) */ this.sId = ''; /* 表格Id(数据格式:字符串) */ this.isUploadShow = false; /* 是否显示上传控件(数据格式:布尔) */ this.isDownloadShow = false; /* 是否显示上传控件(数据格式:布尔) */ this.isLookShow = false; /* 是否显示查看控件(数据格式:布尔) */ this.isAddShow = false; /* 是否显示添加控件(数据格式:布尔) */ this.isModalShow = false; /* 是否显示modal控件(数据格式:布尔) */ this.isModalRemarkShow = false;/* 是否显示材料备注控件(数据格式:布尔) */ this.isChooseProcessShow = false; /* 是否显示选择工序控件(数据格式:布尔) */ this.isCopyShow = false; /* 是否显示复制控件(数据格式:布尔) */ this.isCopyAllShow = false; /* 是否显示复制全部控件(数据格式:布尔) */ this.isDelShow = false; /* 是否显示删除控件(数据格式:布尔) */ this.isCopyMoreShow = false; /* 是否显示删除多行控件(数据格式:布尔) */ this.isPopupShow = false; /* 是否显示弹窗控件(数据格式:布尔) */ this.isParamShow = false; /* 是否显示弹窗控件(数据格式:布尔) */ this.isChooseProductProcess = false; /* 是否显示成品工序控件(数据格式:布尔) */ this.isChooseProductMaterials = false; /* 是否显示成品材料控件(数据格式:布尔) */ // this.onUploadChange = () => {}; /* 上传后执行函数(数据格式:函数) */ this.initColumn = null; this.finalColumn = null; this.droping = false; this.resize = false; this.isDragAndDrop = false; this.tableContentWidth = 0; this.tableInfoContentWidth = 0; this.mergeCellListMap = {}; // 合并单元格map; this.mergeCellStateMap = {}; // 是否合并单元格map this.mergeInfoCellListMap = {}; this.mergeInfoCellStateMap = {}; // this.beSelectDropdownOpen = false; this.uniqueId = null; // 虚拟列表vid this.hasMergeHeader = false; // 判断是否包含合并表头 this.sticky = this.props.tableProps.sticky ? this.props.tableProps.sticky : false; this.sortRendered = false; this.tableHeight = 0; this.DraggableContainer = null; this.DraggableBodyRow = null; this.curSlaveInfoData = []; this.slaveInfoHeaderMap = {}; this.mergeCellList = []; this.tableFilterData = []; this.pathname = ''; this.hasSpanBgColor = false; // 是否有span背景色 this.curPagination = {}; // 当前分页数据 this.selectedRowKeysOld = []; // 记录选中数据 this.tableId = this.props.tableId; this.isAllowConExpendKeys = ['19211681019715708440774010'].includes(props.formId); } /** 渲染前只执行一次 */ componentWillMount() { /* state和this属性赋值s */ this.mounted = true; this.assignmentWillProps(this.props); } componentDidMount() { /* 获取ant-table-body宽度 */ if (!commonUtils.isEmptyObject(this.mydiv)) { if (!this.tableContentWidth) { this.tableContentWidth = this.mydiv.offsetWidth; } } // 处理表单详情的tableWidth if (!commonUtils.isEmptyObject(this.myInfoDiv)) { if (!this.tableInfoContentWidth) { this.tableInfoContentWidth = this.myInfoDiv.offsetWidth; } } if (this.props.onRenderFinish) { this.props.onRenderFinish(); } window.addEventListener('resize', () => { this.computedTableHeight(); this.computedTdWidth(true); this.forceUpdate(); }); if (this.tableId) { window[`${this.tableId}FieldPopupModal`] = this.handleFieldPopupModal; } document.addEventListener('mouseover', this.handleLastTdMouseOver); // 监听鼠标右击事件 this.mydiv.addEventListener('contextmenu', this.handleContextMenu); } componentDidUpdate() { if ( this.props.app && this.props.app.currentPane && (this.props.app.currentPane.route.indexOf('commonList') !== -1 || this.props.app.currentPane.route.indexOf('productionScheduleTree') !== -1) ) { if (this.tableHeight !== '100%' && this.tableHeight !== 0) { if (this.props.name !== 'report') { this.mydiv.getElementsByClassName('ant-table-body')[0].style.height = this.tableHeight ? this.tableHeight + 'px' : 80 + 'px'; } } } let divs = document.getElementsByClassName('noInputInsert'); if (divs.length) { Array.prototype.forEach.call(divs, item => { item.parentNode.parentNode.parentNode.parentNode.classList.add('insertTd'); }); } // 判断树形表格展开/收起全部按钮是否在第一个column上 const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (this.showExpAll && oTable) { const getTh = (dom) => { if (!dom) { return false; } if (dom.nodeName === 'TH') { return dom; } else { return getTh(dom.parentNode); } } const oHeader = oTable.querySelector('.ant-table-header'); const oThDivs = oHeader.querySelectorAll('.th-div'); const oThs = Array.from(oThDivs).map(item => getTh(item)); // const oThs = oHeader.querySelectorAll('th[tabindex]'); const oExpAllIcon = oHeader.querySelector('.table-expAllIcon'); if (oExpAllIcon) { const oTh = getTh(oExpAllIcon); if (oTh) { const index = [].indexOf.call(oThs, oTh); if (index > 0) { const oFirstThDiv = oHeader.querySelector('.th-div'); oFirstThDiv && oFirstThDiv.prepend(oExpAllIcon); } } } } if (this.simpleModalRef.current) this.simpleModalRef.current.innerHTML = this.state.simpleModalWord || ''; } /** props改变的时候触发s */ componentWillReceiveProps(nextProps) { /* state和this属性赋值 */ this.assignmentWillProps(nextProps); // 等待加载完成后计算宽度s if (!commonUtils.isEmptyObject(this.mydiv)) { if (!this.tableContentWidth) { this.tableContentWidth = this.mydiv.offsetWidth; } } if (!commonUtils.isEmptyObject(this.myInfoDiv)) { if (!this.tableInfoContentWidth) { this.tableInfoContentWidth = this.myInfoDiv.offsetWidth; } } if (this.state.openNewTabFlag && this.pathname === location.pathname) { const dom = document.getElementsByClassName(`${this.state.randomId}-CommonListSelectTree`)[0]; dom.parentElement.parentElement.style.display = 'block'; this.setState({ openNewTabFlag: false, }); } } /** 返回true执行渲染,返回false不渲染 */ shouldComponentUpdate(nextProps, nextState) { const { headerColumn, tableColumn, dataSource, totalData, totalData1, selectedRowKeys, enabled, filteredValue, previewVisible, previewImage, slaveInfoSelectedRowKeys, slaveInfo, expKeys, commonPopupVisible, commonFieldPopupVisible, realizeHeight, bOperateMoreVisible, } = this.state; return enabled !== nextState.enabled || this.props.updateRowNumTime !== nextState.updateRowNumTime || JSON.stringify(this.props.isDragAndDrop) !== JSON.stringify(nextProps.isDragAndDrop) || // JSON.stringify(headerColumn) !== JSON.stringify(nextState.headerColumn) || JSON.stringify(this.props.config) !== JSON.stringify(nextProps.config) || JSON.stringify(tableColumn) !== JSON.stringify(nextState.tableColumn) || JSON.stringify(dataSource) !== JSON.stringify(nextState.dataSource) || JSON.stringify(totalData) !== JSON.stringify(nextState.totalData) || JSON.stringify(totalData1) !== JSON.stringify(nextState.totalData1) || JSON.stringify(selectedRowKeys) !== JSON.stringify(nextState.selectedRowKeys) || JSON.stringify(slaveInfoSelectedRowKeys) !== JSON.stringify(nextState.slaveInfoSelectedRowKeys) || JSON.stringify(expKeys) !== JSON.stringify(nextState.expKeys) || JSON.stringify(previewVisible) !== JSON.stringify(nextState.previewVisible) || JSON.stringify(commonPopupVisible) !== JSON.stringify(nextState.commonPopupVisible) || JSON.stringify(bOperateMoreVisible) !== JSON.stringify(nextState.bOperateMoreVisible) || JSON.stringify(commonFieldPopupVisible) !== JSON.stringify(nextState.commonFieldPopupVisible) || JSON.stringify(previewImage) !== JSON.stringify(nextState.previewImage) || JSON.stringify(filteredValue) !== JSON.stringify(nextState.filteredValue) || JSON.stringify(this.props.tableProps.pagination) !== JSON.stringify(nextProps.tableProps.pagination) || // JSON.stringify(this.props.tableProps.AutoTableHeight) !== JSON.stringify(nextProps.tableProps.AutoTableHeight) || JSON.stringify(nextProps.slaveInfo) !== slaveInfo || JSON.stringify(nextProps.realizeHeight) !== realizeHeight || this.props.tableProps.newButton !== nextProps.tableProps.newButton || this.state.simpleModalVisible !== nextState.simpleModalVisible; } componentWillUnmount() { this.mounted = false; window.removeEventListener('resize', () => { this.computedTableHeight(); this.forceUpdate(); }); document.removeEventListener('mouseover', this.handleLastTdMouseOver); this.mydiv.removeEventListener('contextmenu', this.handleContextMenu); if (this.tableId && window[`${this.tableId}FieldPopupModal`]) { delete window[`${this.tableId}FieldPopupModal`]; } } simpleModalRef = React.createRef(); handleLastTdMouseOver = (event) => { try { if (event.target.classList.contains('react-resizable-handle') && event.target.parentNode.getAttribute('bnotresize') === 'bNotResize') { const oBody = this.mydiv.querySelector('.ant-table-body'); const { scrollWidth, clientWidth } = oBody; const oResizable = event.target; if (scrollWidth === clientWidth) { oResizable.style.cursor = 'default'; return; } this.lastTdMouseOver = true; let minLeft, maxLeft, diffx; oResizable.style.cursor = 'col-resize'; const tempDom = document.createElement('div'); const mask = document.createElement('div'); mask.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; z-index: 9999;" const resizableMousemove = (e) => { const { clientX } = e; const left = Math.min(Math.max(minLeft, clientX), maxLeft + 200); diffx = left - maxLeft; if (diffx < 0) { diffx = Math.max(diffx, clientWidth - scrollWidth); } Object.assign(tempDom.style, { left: left + 'px', }); } const resizableMouseup = () => { this.lastTdMouseOver = false; document.body.removeChild(mask); document.body.removeChild(tempDom); document.removeEventListener('mouseup', resizableMouseup); document.removeEventListener('mousemove', resizableMousemove); const { tableColumn, headerColumn } = this.state; const sessionColumn = sessionStorage.getItem(`${this.props.formId}_${this.props.config.sId}`); const column = sessionColumn ? JSON.parse(sessionColumn) : tableColumn; const lastIndex = column.findIndex(item => item.dataIndex === 'tableLastEmpty') - 1; if (lastIndex > -1 && diffx !== 0) { const headerColumnNew = [...headerColumn]; const columnNew = [...column]; if (commonUtils.isNotEmptyArr(columnNew[lastIndex].children)) { const lastChildIndex = columnNew[lastIndex].children.length - 1; columnNew[lastIndex].children[lastChildIndex].width += diffx; if (columnNew[lastIndex].children[lastChildIndex].widthExtra) { columnNew[lastIndex].children[lastChildIndex].widthExtra += diffx; } else { columnNew[lastIndex].children[lastChildIndex].widthExtra = diffx; } if (columnNew[lastIndex].children[lastChildIndex].widthExtra < 0) { columnNew[lastIndex].children[lastChildIndex].widthExtra = 0; } const headerIndex = headerColumnNew.findIndex(item => item.dataIndex === columnNew[lastIndex].children[lastChildIndex].dataIndex); if (headerIndex !== -1) { headerColumnNew[headerIndex].width = columnNew[lastIndex].children[lastChildIndex].width; headerColumnNew[headerIndex].widthExtra = columnNew[lastIndex].children[lastChildIndex].widthExtra; } } else { columnNew[lastIndex].width += diffx; if (columnNew[lastIndex].widthExtra) { columnNew[lastIndex].widthExtra += diffx; } else { columnNew[lastIndex].widthExtra = diffx; } if (columnNew[lastIndex].widthExtra < 0) { columnNew[lastIndex].widthExtra = 0; } const headerIndex = headerColumnNew.findIndex(item => item.dataIndex === columnNew[lastIndex].dataIndex); if (headerIndex !== -1) { headerColumnNew[headerIndex].width = columnNew[lastIndex].width; headerColumnNew[headerIndex].widthExtra = columnNew[lastIndex].widthExtra; } } sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}`, JSON.stringify(columnNew)); this.props.onSaveState({ headerColumn: headerColumnNew, tableColumn: columnNew }); } } oResizable.onmousedown = () => { const { y, height } = event.target.getBoundingClientRect(); minLeft = event.target.parentNode.getBoundingClientRect().x + 50; maxLeft = event.target.parentNode.getBoundingClientRect().x + event.target.parentNode.getBoundingClientRect().width; Object.assign(tempDom.style, { width: '2px', height: height + 'px', background: '#1990ff', top: y + 'px', left: maxLeft + 'px', position: 'absolute', zIndex: 9999, cursor: 'col-resize' }); document.body.append(mask); document.body.append(tempDom); document.removeEventListener('mouseup', resizableMouseup); document.addEventListener('mouseup', resizableMouseup); document.removeEventListener('mousemove', resizableMousemove); document.addEventListener('mousemove', resizableMousemove); }; } } catch (error) { } } /** 列拖动s */ onHeaderCell = (isSlaveInfo, index, column) => { let columns; if (isSlaveInfo) { columns = this.state.tableInfoColumn.slice(0); } else { columns = this.state.tableColumn.slice(0); } // 最后一列禁止拖动 let bNotResize = false; const lastIndex = columns.findIndex(item => item.dataIndex === 'tableLastEmpty') - 1; if (lastIndex > -1) { if (commonUtils.isNotEmptyArr(columns[lastIndex].children)) { if (columns[lastIndex].children[columns[lastIndex].children.length - 1].dataIndex === column.dataIndex) { bNotResize = true; } } else if (columns[lastIndex].dataIndex === column.dataIndex) { bNotResize = true; } } return { width: column.width, onResize: !bNotResize ? this.handleResize(index, column, isSlaveInfo) : null, bnotresize: bNotResize ? 'bNotResize' : null, onClick: () => { }, onMouseDown: () => { if (this.lastTdMouseOver) { return; } const tableColumn = isSlaveInfo ? this.state.tableInfoColumn : this.state.tableColumn; for (const m in tableColumn) { if (commonUtils.isNotEmptyArr(columns[m].children)) { // 如果是双层表头 const initColumnIndex = columns[m].children.findIndex(item => item.dataIndex === column.dataIndex); if (initColumnIndex !== -1) { this.initColumn = columns[m].children[initColumnIndex]; this.droping = true; this.bInitColumnMuti = true; // 拖动对象是多表头下的子表头 break; } } else if (columns[m].dataIndex === column.dataIndex) { this.initColumn = columns[m]; this.droping = true; this.bInitColumnMuti = false; break; } } }, onMouseEnter: () => { if (this.resize) { this.droping = false; return false; } else if (this.resize === false) { if (!commonUtils.isEmpty(this.initColumn) && this.droping) { this.setState(() => { for (const i in columns) { if (commonUtils.isNotEmptyArr(columns[i].children)) { for (const j in columns[i].children) { if (columns[i].children[j].dataIndex === column.dataIndex) { columns[i].children[j] = { ...columns[i].children[j], className: 'hover-droping-cell', }; } else { columns[i].children[j] = { ...columns[i].children[j], className: '', }; } } } else if (columns[i].dataIndex === column.dataIndex) { columns[i] = { ...columns[i], className: 'hover-droping-cell', }; } else { columns[i] = { ...columns[i], className: '', }; } } // const sortArr = columns.map(item => item.dataIndex); let sortArr = []; columns.forEach(item => { if (item.children) { item.children.forEach(child => { sortArr.push(child.dataIndex); }) } else { sortArr.push(item.dataIndex); } }); if (isSlaveInfo) { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}_info_headerColumns`, JSON.stringify(sortArr)); return { tableInfoColumn: columns }; } else { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}_headerColumns`, JSON.stringify(sortArr)); return { tableColumn: columns }; } }); } else { this.droping = false; } } }, onMouseUp: () => { let spliceIndex = null; const sortItems = []; if (this.droping && !commonUtils.isEmpty(this.initColumn) && this.initColumn.dataIndex !== column.dataIndex) { const bTargetMuti = columns.findIndex(item => item.dataIndex === column.dataIndex) === -1; // 移动到的目标是否是多表头 if (!this.bInitColumnMuti && !bTargetMuti) { // 拖拽对象【单表头】、移动到的目标【单表头】 for (const i in columns) { columns[i].className = ''; if (columns[i].dataIndex === this.initColumn.dataIndex) { columns.splice(i, 1); spliceIndex = columns.findIndex(item => item.dataIndex === column.dataIndex); columns.splice(spliceIndex, 0, this.initColumn); sortItems.push(this.initColumn.dataIndex); sortItems.push(column.dataIndex); } } } else if (!this.bInitColumnMuti && bTargetMuti) { // 拖拽对象【单表头】、移动到的目标【双表头】 let iIndexArr = []; // 获取拖拽对象index const initColumnIndex = columns.findIndex(item => item.dataIndex === this.initColumn.dataIndex); // 获取目标index for (const i in columns) { const children = columns[i].children; if (commonUtils.isNotEmptyArr(children)) { const iIndex = children.findIndex(item => item.dataIndex === column.dataIndex); if (iIndex !== -1) { columns[i].children[iIndex].className = ''; iIndexArr = [i, iIndex]; break; } } } if (initColumnIndex !== -1) { // 去除拖拽对象数组 columns.splice(initColumnIndex, 1); // 目标对象index spliceIndex = iIndexArr[0]; if (spliceIndex >= initColumnIndex) { spliceIndex -= 1; } if (iIndexArr[1] === 0) { //如果目标对象是第一个 // 将拖拽对象插入到目标对象前面 columns.splice(spliceIndex, 0, this.initColumn); } else if (iIndexArr[1] > 0) { // 如果目标对象不是第一个 // 取出目标对象数组 const targetColumn = columns.splice(spliceIndex, 1)[0]; const column1 = { ...targetColumn, children: targetColumn.children.filter((item, index) => index < iIndexArr[1]) }; const column2 = { ...targetColumn, children: targetColumn.children.filter((item, index) => index >= iIndexArr[1]) }; columns.splice(spliceIndex, 0, column1, this.initColumn, column2); } } } else if (this.bInitColumnMuti && !bTargetMuti) { // 拖拽对象【双表头】、移动到的目标【单表头】 // 获取拖拽对象index let initColumnIndexArr = []; for (const i in columns) { if (commonUtils.isNotEmptyArr(columns[i].children)) { const iIndex = columns[i].children.findIndex(child => child.dataIndex === this.initColumn.dataIndex); if (iIndex !== -1) { initColumnIndexArr = [i, iIndex]; break; } } } if (commonUtils.isNotEmptyArr(initColumnIndexArr)) { spliceIndex = columns.findIndex(item => item.dataIndex === column.dataIndex); columns[spliceIndex].className = ''; if (columns[initColumnIndexArr[0]].children.length === 1) { const initColumnParent = columns.splice(initColumnIndexArr[0], 1)[0]; columns.splice(spliceIndex, 0, initColumnParent); } else { const newColumn = { ...columns[initColumnIndexArr[0]], children: [columns[initColumnIndexArr[0]].children[initColumnIndexArr[1]]] }; columns[initColumnIndexArr[0]].children = columns[initColumnIndexArr[0]].children.filter(item => item.dataIndex !== newColumn.children[0].dataIndex); columns.splice(spliceIndex, 0, newColumn); } } } else { // 拖拽对象【双表头】、移动到的目标【双表头】 // 获取拖拽对象index let initColumnIndexArr = []; for (const i in columns) { if (commonUtils.isNotEmptyArr(columns[i].children)) { const iIndex = columns[i].children.findIndex(child => child.dataIndex === this.initColumn.dataIndex); if (iIndex !== -1) { initColumnIndexArr = [i, iIndex]; break; } } } let iIndexArr = []; // 获取目标index for (const i in columns) { const children = columns[i].children; if (commonUtils.isNotEmptyArr(children)) { const iIndex = children.findIndex(item => item.dataIndex === column.dataIndex); if (iIndex !== -1) { columns[i].children[iIndex].className = ''; iIndexArr = [i, iIndex]; break; } } } if (commonUtils.isNotEmptyArr(initColumnIndexArr) && commonUtils.isNotEmptyArr(iIndexArr)) { if (initColumnIndexArr[0] === iIndexArr[0]) { // 同一个一级表头 columns[initColumnIndexArr[0]].children.splice(initColumnIndexArr[1], 1); spliceIndex = columns[initColumnIndexArr[0]].children.findIndex(item => item.dataIndex === column.dataIndex); columns[initColumnIndexArr[0]].children.splice(spliceIndex, 0, this.initColumn); } else { // 不同的一级表头 const newColumn = { ...columns[initColumnIndexArr[0]], children: [columns[initColumnIndexArr[0]].children[initColumnIndexArr[1]]] }; if (iIndexArr[1] === 0) { // 最前面 columns[initColumnIndexArr[0]].children.splice(initColumnIndexArr[1], 1); spliceIndex = iIndexArr[0]; if (columns[initColumnIndexArr[0]].children.length === 0) { // 剩下的二层表头为空 columns.splice(initColumnIndexArr[0], 1); spliceIndex = initColumnIndexArr[0] < spliceIndex ? spliceIndex - 1 : spliceIndex; } columns.splice(spliceIndex, 0, newColumn); } else { // 插到其它二级表头中间 columns[initColumnIndexArr[0]].children.splice(initColumnIndexArr[1], 1); spliceIndex = iIndexArr[0]; if (columns[initColumnIndexArr[0]].children.length === 0) { // 剩下的二层表头为空 columns.splice(initColumnIndexArr[0], 1); spliceIndex = initColumnIndexArr[0] < spliceIndex ? spliceIndex - 1 : spliceIndex; } const targetColumn = columns.splice(spliceIndex, 1)[0]; const column1 = { ...targetColumn, children: targetColumn.children.filter((item, index) => index < iIndexArr[1]) }; const column2 = { ...targetColumn, children: targetColumn.children.filter((item, index) => index >= iIndexArr[1]) }; columns.splice(spliceIndex, 0, column1, newColumn, column2); } } } } // 合并一级表头相同的相邻的column columns = columns.reduce((prev, cur) => { if (prev.length) { const prevColumn = prev[prev.length - 1]; if (commonUtils.isNotEmptyArr(prevColumn.children) && commonUtils.isNotEmptyArr(cur.children) && prevColumn.title === cur.title) { prevColumn.children = [...prevColumn.children, ...cur.children]; prev[prev.length - 1] = prevColumn; return prev; } else { prev.push(cur); return prev; } } else { prev.push(cur); return prev; } }, []); this.tableInfoColumn = columns; let sortArr = []; columns.forEach(item => { if (item.children) { item.children.forEach(child => { sortArr.push(child.dataIndex); }) } else { sortArr.push(item.dataIndex); } }); if (isSlaveInfo) { this.setState({ tableInfoColumn: columns }, () => { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}_info_headerColumns`, JSON.stringify(sortArr)); this.initColumn = null; this.droping = false; }); this.handleSaveOrder(sortItems, isSlaveInfo); } else { this.setState({ tableColumn: columns }, () => { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}_headerColumns`, JSON.stringify(sortArr)); this.initColumn = null; this.droping = false; }); this.handleSaveOrder(sortItems); } } else { this.resize = false; this.droping = false; } }, onContextMenu: (event) => { window.event.returnValue = false; }, }; }; handleContextMenu = (event) => { try { // 判断右键位置是否有选中文本 if (!window.getSelection().toString()) { const { target } = event; const { tagName } = target; const oDiv = { 'span': target.getAttribute('data-name') ? target : target.parentNode, 'td': target?.childNodes[0]?.childNodes[0], 'div': target.getAttribute('data-name') ? target : target.childNodes[0], 'input': target, }[tagName.toLowerCase()]; if (!oDiv) return; if (!oDiv.getAttribute('data-control-name')?.includes('_Sum')) return; // 阻止右键菜单 event.preventDefault(); this.setState({ totalDataNew: undefined, sumGroup: {} }); } } catch (error) {} } onRowMouseEnter = (record) => { // recor if (this.props.enabled && this.props.tableBelone !== 'list' && commonUtils.isNotEmptyObject(this.props.tableProps) && !this.beSelectDropdownOpen && commonUtils.isEmptyObject(this.props.tableProps.rowSelection) && this.state.currentHoverSid !== record.sId) { if (this.timerSelectRowChange) { clearTimeout(this.timerSelectRowChange); } this.timerSelectRowChange = setTimeout(() => { this.setState({ currentHoverSid: record.sId, }); // console.log('=====record', record); // this.handleSelectRowChange(this.props.name, [record[this.rowKey]]); }, 150); } } onRowMouseLeave = () => { if (this.timerSelectRowChange) { this.setState({ currentHoverSid: '', }); clearTimeout(this.timerSelectRowChange); } } rowClickRef = React.createRef(); /** 行选择 */ onRowClick = (record, index, type, name, tabType) => { if (this.handleCellClick(record)) return; if (this.stopRowClick) { this.stopRowClick = false; return; } const { bMutiSelect, tableProps, bMutiSelect1, bRowClick, bContinueClick, } = this.props; const { rowSelection } = tableProps; // let { selectedRowKeys } = this.props; this.rowClickRef.current = index; const bSlaveInfo = tabType && tabType.includes('slave') && tabType.includes('Info'); const rowKey = bSlaveInfo && commonUtils.isNotEmptyObject(this.props.slaveInfo.tableProps) ? this.props.slaveInfo.tableProps.rowKey : this.rowKey; let selectedRowKeys = bSlaveInfo && commonUtils.isNotEmptyObject(this.props.slaveInfo.tableProps) ? this.props.slaveInfo.selectedRowKeys === undefined ? undefined : [...this.props.slaveInfo.selectedRowKeys] : this.props.selectedRowKeys === undefined ? undefined : [...this.props.selectedRowKeys]; // bMutiSelect1默认都为false,如果想点击整行时勾选框不勾选,props里面设置bMutiSelect1为true即可 if (selectedRowKeys && selectedRowKeys.indexOf(record[rowKey]) !== -1 && name !== 'slave' && !this.props.bRowClickRepeat) { return; } if (selectedRowKeys && selectedRowKeys.indexOf(record[rowKey]) !== -1 && name !== 'slave' && !this.props.enabled && !this.props.bRowClickRepeat) { this.handleSelectRowChange(name, []); return; } if (bMutiSelect && rowSelection !== null && !bMutiSelect1) { /* 有多选、复选框情况下 */ if (commonUtils.isEmptyArr(selectedRowKeys) || bContinueClick) { const keys = []; keys.push(record[rowKey]); selectedRowKeys = keys; } else { const indexKey = selectedRowKeys.indexOf(record[rowKey]); if (indexKey === -1) { selectedRowKeys.push(record[rowKey]); } else if (indexKey !== -1 && type !== 'drag') { if (!bRowClick) { selectedRowKeys.splice(indexKey, 1); /* 可输入行,行内点击时 不去除selectedRowKeys */ } } } this.handleSelectRowChange(name, selectedRowKeys); } else { this.handleSelectRowChange(name, [record[rowKey]]); } }; // 数据扁平化 getDataAll = (data, parentRowKeyPath = []) => { let res = data.map(item => { return { ...item, parentRowKeyPath, } }); res.forEach(item => { if (commonUtils.isNotEmptyArr(item.children)) { res = [...res, ...this.getDataAll(item.children, [...parentRowKeyPath, item[this.rowKey]])]; } }) return res; } // 处理树形表格多选父子联动 handleMutiSelectRowKeys = (selectedRowKeys) => { const { bMutiSelect, tableProps, bMutiSelect1, } = this.props; const { rowSelection } = tableProps; if (bMutiSelect && rowSelection !== null && !bMutiSelect1) { /* 有多选、复选框情况下 */ // 判断是选中还是取消 const type = selectedRowKeys.length > this.selectedRowKeysOld.length ? 'add' : 'del'; // 找出变化的数据 const diffArr = this.selectedRowKeysOld.concat(selectedRowKeys) .filter(v => !this.selectedRowKeysOld.includes((v)) || !selectedRowKeys.includes((v))); if (diffArr.length === 1) { // 将数据扁平化 let { data } = this.props; const dataAll = this.getDataAll(data); // 额外的选中行(当前选中行的子数据) const selectedRowKeysExtra = dataAll.reduce((result, cur) => { if (cur.parentRowKeyPath.includes(diffArr[0])) { result.push(cur[this.rowKey]); } return result; }, []); if (type === 'add') { // 合并选中行 selectedRowKeys = Array.from(new Set([...selectedRowKeys, ...selectedRowKeysExtra])); } else { // 删除当前行子数据 selectedRowKeys = selectedRowKeys.reduce((result, cur) => { if (!selectedRowKeysExtra.includes(cur)) { result.push(cur); } return result; }, []); } } } this.selectedRowKeysOld = selectedRowKeys; return selectedRowKeys; }; /** 行选择 */ onDoubleClick = (name, record) => { const picArrConfig = this.props.config.gdsconfigformslave.find(item => item.sName === 'picArr'); if (picArrConfig?.sActiveId === "172129113112117442504826460") { // 自动拼版 if (record.bMakeUpEnd) { this.props.onSaveState({ makeUpPDFRecord: { ...record, picArrConfig }, }); } else { message.info("请先完成拼版!"); } return; } if (this.props.onDoubleClick !== undefined) { this.props.onDoubleClick(record); } }; onKeyDownDiv = (e, sName) => { if (e.key === 'F10') { message.info(sName); } else if (e.ctrlKey && e.keyCode === 67) { console.log('复制成功!'); } else if (e.ctrlKey && e.keyCode === 65) { console.log('全选成功!'); } else if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 71) { /* CTRL+ALT+G F7 设置界面 */ const { name, config, data, configName } = this.props; const { sType } = this.props?.app?.userinfo || {}; if (!['sysadmin'].includes(sType)) { return; } if (commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.config) && commonUtils.isNotEmptyObject(this.props.data)) { const bInModal = (el) => { if (commonUtils.isEmpty(el) || commonUtils.isEmpty(el.classList)) { return false; } else if (el.classList.contains('ant-modal-root')) { return true; } else { return bInModal(el.parentNode); } } if (bInModal(e.target)) { // 如果是在modal里的表格,不允许跳转 return; } const myTableConfig = JSON.parse(JSON.stringify(config)); myTableConfig.sActiveId = '16411004790004762980820285096000'; myTableConfig.sName = sName; const myTableConfigArr = []; myTableConfigArr.push(myTableConfig); this.props.onViewClick(name, 'myTableConfig', data[0], 0, myTableConfigArr, configName); } } else if (e.key !== 'F12') { e.preventDefault(); return false; } } onExpand = (expanded, record) => { if (this.props.onExpand !== undefined) { this.props.onExpand(expanded, record); } } onOpenNewTab = () => { const dom = document.getElementsByClassName(`${this.state.randomId}-CommonListSelectTree`)[0]; dom.parentElement.parentElement.style.display = 'none'; this.pathname = location.pathname; this.setState({ openNewTabFlag: true, }); }; onChange = (pagination, filters, sorter, extra) => { if (this.showExpAll) { this.showExpAll = false; this.setState({ expKeys: [] }); } if (commonUtils.isNotEmptyObject(filters)) { const filterValueArr = Object.values(filters); if (filterValueArr.join('') !== '' && commonUtils.isNotEmptyArr(extra.currentDataSource)) { // 过滤了数据 this.tableFilterData = extra.currentDataSource; } else { // 没有过滤数据 this.tableFilterData = []; } // 生成cell list this.genMergeListStateMap(); } if (sorter?.column) { sorter.columnKey = sorter.column.dataIndex; } else { sorter = {}; } if (this.props.slaveInfo && this.props.slaveInfo.tableProps && this.props.slaveInfo.tableProps.onChange) { this.props.slaveInfo.tableProps.onChange(pagination, filters, sorter, extra); } if (this.props && this.props.tableProps && this.props.tableProps.onChange) { this.props.tableProps.onChange(pagination, filters, sorter, extra); } this.props.onSaveState({ sortedInfo: sorter }); } /* 动态参数全选、取消全选 */ onParamChange = (e) => { this.props.onCheckChange(this.props.name); } setRowClassName = (tabType, record, index) => { const styleColor = this.getColorStyle(record, true); /* 消息列表未读的消息,整行文字加粗 */ let newslistStyle = ''; if (commonUtils.isNotEmptyObject(this.props.formId) && this.props.formId === '15669750700007338351055957774000') { if (record.bIsView === false) { newslistStyle = 'newsNoRead'; } } const bSlaveInfo = tabType && tabType.includes('slave') && tabType.includes('Info'); const selectedRowKeys = bSlaveInfo ? this.state.slaveInfoSelectedRowKeys : this.props.selectedRowKeys; const rowKey = bSlaveInfo && commonUtils.isNotEmptyObject(this.props.slaveInfo.tableProps) ? this.props.slaveInfo.tableProps : this.rowKey; const rowClassName = commonUtils.isNotEmptyArr(selectedRowKeys) && selectedRowKeys.indexOf(record[rowKey]) > -1 ? `${styleColor} selected-record-row` : commonUtils.isNotEmptyObject(styleColor) ? styleColor : (index % 2 === 1 && this.props.tableBelone === 'list') ? 'dark-record-row' : ''; let allRowClassName = commonUtils.isNotEmptyObject(newslistStyle) ? `${rowClassName} ${newslistStyle}` : rowClassName; if (tabType === 'slave' && commonUtils.isNotEmptyArr(this.mergeCellList)) { // 如果有合并单元格 allRowClassName = record.sColor; } else { if (commonUtils.isEmptyObject(allRowClassName) || commonUtils.isEmptyObject(allRowClassName.trim())) { /* 设置奇 偶行背景色 */ allRowClassName = (index % 2 === 1) ? 'dark-record-row' : ''; } } /* 如果行字段的sDivRow有值 则做成特殊样式 */ if (commonUtils.isNotEmptyObject(record) && commonUtils.isNotEmptyObject(record.sDivRowNew) && record.bInsert) { allRowClassName = 'split-record-row'; if (this.props.skipSlaveInfo) { allRowClassName = 'split-record-row-skip'; } } if (record?.costomRowColor) { allRowClassName = `SetRow_${record.costomRowColor}` } return allRowClassName; }; /** 获取复选框对象的props */ getRowSelection = (name, type) => { const { bMutiSelect, bisMutiSelect } = this.props; if (name === 'control' || (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf('commonAuto') > -1)) { // 控制表中可以通过bisMutiSelect显示或者隐藏勾选框 if (bisMutiSelect) { return { preserveSelectedRowKeys: true, selectedRowKeys: type === 'slaveInfo' ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys, /* 已选择的数据集 */ onChange: this.handleSelectRowChange.bind(this, name), /* 选择行发生改变时调用的函数 */ getCheckboxProps: record => ({ style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, }), /* 过滤合计的选择框 */ type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } else { return null; } } else { return { preserveSelectedRowKeys: true, selectedRowKeys: type === 'slaveInfo' ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys, /* 已选择的数据集 */ onChange: (value) => { this.handleSelectRowChange(name, value, true); }, /* 选择行发生改变时调用的函数 */ getCheckboxProps: record => ({ style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, }), /* 过滤合计的选择框 */ type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } }; /** 获取table对象的props */ getTableProps = () => { /* 给数据都添加上key */ const { tableColumn, dataSource } = this.state; // 二级表头 const subTableColumn = tableColumn.reduce((result, item) => { if (commonUtils.isNotEmptyArr(item.children)) { result = [...result, ...item.children]; } return result; }, []); const sPartNameStatus = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex === 'sPartNameStatus'); const sPicturePath = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex === 'sPicturePath'); const sMaterialsStatus = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex === 'sMaterialsStatus' || (commonUtils.isNotEmptyArr(item.children) && item.children.findIndex(itemChild => itemChild.dataIndex && itemChild.dataIndex === 'sMaterialsStatus') > -1)); const dynamicColumn = [...tableColumn, ...subTableColumn].filter(item => (commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.includes('_json')) || (commonUtils.isNotEmptyArr(item.children) && item.children.findIndex(itemChild => itemChild.dataIndex && itemChild.dataIndex.includes('_json')) > -1)); /* 动态列JSON解析 */ const sTimeStatus = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex === 'sTimeStatus'); /* 时间进度条状态 */ const sDownload = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex === 'sDownload'); const sScheduleStatusJson = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex && item.dataIndex.includes('sScheduleStatusJson')); // 拼版状态 const sMakeUpPath = [...tableColumn, ...subTableColumn].filter(item => item.dataIndex?.toLowerCase().includes('makeuppath')); if (commonUtils.isNotEmptyArr(sPicturePath)) { sPicturePath[0].render = (value = '') => { const picHref = value.includes('xlyerpfiles') ? `${commonConfig.file_host}file/download?savePathStr=${encodeURIComponent(value)}&sModelsId=100&token=${encodeURIComponent(this.props.app.token)}` : value; return {value}; } } if (commonUtils.isNotEmptyArr(sDownload)) { sDownload[0].render = (value) => { if (commonUtils.isEmpty(value)) return ''; const fileList = value.split(','); if (fileList.length === 1) { let fileName = fileList[0].substring(fileList[0].lastIndexOf('/') + 1); fileName = fileName.substring(fileName.indexOf('_') + 1); const picHref = `${commonConfig.file_host}file/download?savePathStr=${encodeURIComponent(value)}&sModelsId=100&token=${encodeURIComponent(this.props.app.token)}`; const fileType = fileName.split('.').pop().toLowerCase(); const previewFileList = ['jpg', 'png', 'jepg', 'webp', 'svg', 'bmp', 'apng', 'pdf']; return
{ if (fileType === 'pdf') { this.setState({ pdfFileVisible: true, pdfFileUrl: fileList[0], }); } else { this.handlePreviewImage(e, fileList); } }} title="预览"> {fileName}
} else { return { this.setState({ commonFileDownloadVisible: true, commonFileDownloadList: fileList.map(item => { return { url: item, checked: false } }), }) }} >{`附件(${fileList.length})`}; } } } if (commonUtils.isNotEmptyArr(sMakeUpPath)) { sMakeUpPath.forEach((item , index) => { item.render = (value = '', record) => { const { formId, name, enabled, config } = this.props; const { token } = this.props.app; const divProps = { action: `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}`, onChange: (info) => { this.handleUploadChange(info, () => { }); const savePathStr = info?.file?.response?.dataset?.rows?.[0]?.savePathStr; this.props.onDataChange(name, item.dataIndex, { [item.dataIndex]: savePathStr }, record.sId, []); }, accept: '*/*', showUploadList: false, multiple: false, }; return
{ value && [''].map(() => { const iconProps = { className: styles.imgPDf, onClick: () => { this.setState({ officePreviewVisible: true, officeFileUrl: value, }) } }; const removeExtension = (filename) => { const lastDotIndex = filename.lastIndexOf('.'); if (lastDotIndex === -1) { // 如果字符串中没有点,则返回原字符串 return filename; } return filename.substring(0, lastDotIndex); } const getImageUrl = (sName) => { const imageUrlNew = `${commonConfig.server_host}file/downloadPrice?sLogoName=${sName}&date=${new Date().getTime()}`; return imageUrlNew } const picAddr = commonUtils.isNotEmptyObject(value) ? value.split(',') : ''; let dataUrl = picAddr[0].includes('xlyerpfiles') ? `${commonConfig.file_host}file/download?savePathStr=${picAddr[0]}&scale=0.1&sModelsId=100&token=${token}` : picAddr[0]; /* 缩略图 */ if (config.sTbName === "sisboxcomponent") { dataUrl = getImageUrl(removeExtension(picAddr[0])); } // const picAddr = commonUtils.isNotEmptyObject(value) ? value.split(',') : ''; // const dataUrl = picAddr[0].includes('xlyerpfiles') ? `${commonConfig.file_host}file/download?savePathStr=${picAddr[0]}&scale=0.1&sModelsId=100&token=${token}` : picAddr[0]; /* 缩略图 */ const officeFileTypeList = ['PDF', 'DOCX', 'XLSX', 'MP4', 'WEBM', 'OGG']; const imgTypeList = ['PNG', 'SVG', 'JPG', 'JPEG', 'GIF', 'BMP', 'TIFF', 'ICO']; const officeFileType = picAddr[0].split('.').pop().toUpperCase(); let fileIcon = ; if (officeFileType === 'DOCX') { fileIcon = ; } else if (officeFileType === 'XLSX') { fileIcon = ; } else if (['MP4', 'WEBM', 'OGG'].includes(officeFileType)) { fileIcon = ; } let imgBox = ; if (officeFileTypeList.includes(officeFileType)) { imgBox = fileIcon; } else if (imgTypeList.includes(officeFileType)) { imgBox = img 0} onClick={e => this.handlePreviewImage(e, picAddr, index)} style={{ width: '30px', height: '20px' }} />; } return imgBox; }) } { enabled && }
; } }) } this.props.onCostomColums?.([...tableColumn, ...subTableColumn]); // 判断工序状态 if (commonUtils.isNotEmptyArr(sPartNameStatus) && commonUtils.isNotEmptyArr(dataSource)) { this.useVListNew = true; const sModelsType = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : ''; if (sModelsType === 'production/productionPlanInfo' || location.pathname.toLowerCase('commonList') || sModelsType === 'productionMainPlan/productionMainPlan' || location.pathname.toLowerCase().indexOf('oee') > -1) { sPartNameStatus[0].render = (itemStr) => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); return ( //
{ return
{ // eslint-disable-next-line array-callback-return sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; // const record = dataSource[i]; /* 获取每行数据 */ let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const iStatus = commonUtils.isEmpty(t.iStatus) ? 4 : t.iStatus; switch ( Number(iStatus) // 根据状态显示颜色 ) { case 0: colorValue = "#808080"; /* 0:灰色 */ break; case 1: colorValue = "#808080"; /* 1:灰色 */ break; case 2: colorValue = "#ff4d4f"; /* 2:红色 */ break; case 3: colorValue = "#d4b106"; /* 3:黄色 */ break; case 4: colorValue = "#000000"; /* 黑色 */ break; case 5: colorValue = "#49aa19"; /* 5:绿色 */ break; default: colorValue = "#000000"; } // switch ( // Number(sState) // 根据状态显示颜色 // ) { // case 2: // colorValue = "#FF6600"; /* 2:等待:黄色 */ // break; // case 4: // colorValue = "#648c4b"; /* 4:已完成:绿色 */ // break; // case 1: // case 3: // colorValue = "#106abe"; /* 1、3:进行中:蓝色 */ // break; // default: // colorValue = "#000000"; // } } return (
{commonUtils.isNotEmptyObject(t.sProcessName) ? t.sProcessName : ''} {i + 1 === sPartItemLength ? '' : }
); }) }
}}>
{ // eslint-disable-next-line array-callback-return sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; // const record = dataSource[i]; /* 获取每行数据 */ let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.iStatus) ? 4 : t.iStatus; switch (Number(sState)) { // 根据状态显示颜色 case 0: colorValue = '#808080'; /* 0:灰色 */ break; case 1: colorValue = '#808080'; /* 1:灰色 */ break; case 2: colorValue = '#ff4d4f'; /* 2:红色 */ break; case 3: colorValue = '#d4b106'; /* 3:黄色 */ break; case 4: colorValue = '#000000'; /* 黑色 */ break; case 5: colorValue = '#49aa19'; /* 5:绿色 */ break; default: colorValue = '#000000'; } // switch ( // Number(sState) // 根据状态显示颜色 // ) { // case 2: // colorValue = "#FF6600"; /* 2:等待:黄色 */ // break; // case 4: // colorValue = "#648c4b"; /* 4:已完成:绿色 */ // break; // case 1: // case 3: // colorValue = "#106abe"; /* 1、3:进行中:蓝色 */ // break; // default: // colorValue = "#000000"; // } // } return (
{commonUtils.isNotEmptyObject(t.sProcessName) ? t.sProcessName : ''} {i + 1 === sPartItemLength ? '' : }
); }) }
); } }; } else { sPartNameStatus[0].render = (itemStr) => { if (itemStr) { const sPartItem = itemStr.split('->'); return (
{ // eslint-disable-next-line array-callback-return sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; const ArrItemStr = t.split('#')[0]; /* 工序名称 */ const ArrItemNum = t.split('#')[1]; /* 状态 */ const ArrItemName = t.split('#')[2]; /* 机台名称 */ const ArrItemBanZhu = t.split('#')[3]; /* 班组 */ const ArrItemTime = t.split('#')[4]; /* 排单时间 */ const ArrItemPCNum = t.split('#')[5]; /* 排程数 */ const ArrItemSBNum = t.split('#')[6]; /* 上报数 */ const ArrItem7Num = commonUtils.isNotEmptyArr(t.split('#')) && t.split('#').length > 8 ? t.split('#')[8] : ''; /* 包数 */ const ArrItem8Num = commonUtils.isNotEmptyArr(t.split('#')) && t.split('#').length > 9 ? t.split('#')[9] : ''; /* 每包数量 */ const ArrItem9Num = commonUtils.isNotEmptyArr(t.split('#')) && t.split('#').length > 10 ? t.split('#')[10] : ''; /* 零头数量 */ let ArrItemNumChange = ''; let icon; // eslint-disable-next-line default-case switch (Number(ArrItemNum)) { case 0: ArrItemNumChange = '未排程'; icon = ; break; case 1: ArrItemNumChange = '未完成'; icon = ; break; case 2: ArrItemNumChange = '生产中'; icon = ; break; case 3: ArrItemNumChange = '暂停'; icon = ; break; case 4: ArrItemNumChange = '取消'; icon = ; break; case 5: ArrItemNumChange = '完成'; icon = ; break; } // eslint-disable-next-line no-unused-vars const content = (
工序名称:{ArrItemStr}
状态:{ArrItemNumChange}
机台名称:{ArrItemName}
班组:{ArrItemBanZhu}
排单时间:{ArrItemTime}
排程数:{ArrItemPCNum}
上报数:{ArrItemSBNum}
{ ArrItem7Num ?
包数:{ArrItem7Num}
: '' } { ArrItem8Num ?
每包数量:{ArrItem8Num}
: '' } { ArrItem9Num ?
零头数量:{ArrItem9Num}
: '' }
); // 数字转换图标 return (
{icon} {ArrItemStr} {/*{ i + 1 === sPartItemLength ? '' : }*/}
); }) }
); } }; } } // 判断材料准备状态 if (commonUtils.isNotEmptyArr(sMaterialsStatus) && commonUtils.isNotEmptyArr(dataSource)) { this.useVListNew = true; const sModelsType = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : ''; if (true || sModelsType === 'production/productionPlanInfo' || sModelsType === 'productionMainPlan/productionMainPlan' || (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('view/')) || location.pathname.toLowerCase().indexOf('oee') > -1) { /* 动态列Jsonn解析 */ if (commonUtils.isNotEmptyArr(sMaterialsStatus) && commonUtils.isNotEmptyArr(dataSource)) { sMaterialsStatus.forEach((jsonStatus, index) => { const dWidth = jsonStatus.width * 2; const sBackGroundColor = jsonStatus.bReadonly ? '#f1f2f8' : ''; if (commonUtils.isNotEmptyArr(jsonStatus.children)) { /* 嵌套列头JSON解析 */ for (const obj of jsonStatus.children) { obj.render = (itemStr) => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); /* 取箭头弹出的窗体配置 */ let showConfig = {}; let linkStyle = '';/* 弹窗 */ if (commonUtils.isNotEmptyArr(this.props.config) && commonUtils.isNotEmptyArr(this.props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr('sMaterialsStatus')) { const showConfigArr = this.props.config.gdsconfigformslave.filter(item => item.sName === 'sMaterialsStatus' && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; if (commonUtils.isNotEmptyObject(showConfig) && showConfig.sDropDownType === 'picArr' && !commonUtils.isEmpty(showConfig.sActiveId) && commonUtils.isEmptyArr(this.props.sGroupByList)) { linkStyle = 'sMaterialsStatusStyle'; } } } return ( { return
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch (Number(sState)) { // 根据状态显示颜色 case 0: colorValue = '#000000'; /* 0:黑色 */ break; case 1: colorValue = '#ff4d4f'; /* 1:红色 */ break; case 2: colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: colorValue = '#49aa19'; /* 3:绿色 */ break; case 4: colorValue = '#ff4d4f'; /* 4:红色 */ break; default: colorValue = '#000000'; } } return (
{commonUtils.isNotEmptyObject(t.sMaterialsName) ? {t.sMaterialsName} : ''} {i + 1 === sPartItemLength ? '' : -}
); }) }
}}>
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch (Number(sState)) { // 根据状态显示颜色 case 0: colorValue = '#000000'; /* 0:黑色 */ break; case 1: colorValue = '#ff4d4f'; /* 1:红色 */ break; case 2: colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: colorValue = '#49aa19'; /* 3:绿色 */ break; case 4: colorValue = '#ff4d4f'; /* 4:红色 */ break; default: colorValue = '#000000'; } } return (
{commonUtils.isNotEmptyObject(t.sMaterialsName) ? {t.sMaterialsName} : ''} {i + 1 === sPartItemLength ? '' : -}
); }) }
); } else { return itemStr; } }; }; } else { /* 无嵌套列头JSON列解析 */ sMaterialsStatus[index].render = (itemStr) => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); /* 取箭头弹出的窗体配置 */ let showConfig = {}; let linkStyle = '';/* 弹窗 */ if (commonUtils.isNotEmptyArr(this.props.config) && commonUtils.isNotEmptyArr(this.props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr('sMaterialsStatus')) { const showConfigArr = this.props.config.gdsconfigformslave.filter(item => item.sName === 'sMaterialsStatus' && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; if (commonUtils.isNotEmptyObject(showConfig) && showConfig.sDropDownType === 'picArr' && !commonUtils.isEmpty(showConfig.sActiveId) && commonUtils.isEmptyArr(this.props.sGroupByList)) { linkStyle = 'sMaterialsStatusStyle'; } } } return ( { return
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch (Number(sState)) { // 根据状态显示颜色 case 0: colorValue = '#000000'; /* 0:黑色 */ break; case 1: colorValue = '#ff4d4f'; /* 1:红色 */ break; case 2: colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: colorValue = '#49aa19'; /* 3:绿色 */ break; case 4: colorValue = '#ff4d4f'; /* 4:红色 */ break; default: colorValue = '#000000'; } } return (
{commonUtils.isNotEmptyObject(t.sMaterialsName) ? {t.sMaterialsName} : ''} {i + 1 === sPartItemLength ? '' : -}
); }) }
}}>
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch (Number(sState)) { // 根据状态显示颜色 case 0: colorValue = '#000000'; /* 0:黑色 */ break; case 1: colorValue = '#ff4d4f'; /* 1:红色 */ break; case 2: colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: colorValue = '#49aa19'; /* 3:绿色 */ break; case 4: colorValue = '#ff4d4f'; /* 4:红色 */ break; default: colorValue = '#000000'; } } return (
{commonUtils.isNotEmptyObject(t.sMaterialsName) ? {t.sMaterialsName} : ''} {i + 1 === sPartItemLength ? '' : -}
); }) }
); } else { return
{itemStr}
; } }; } }); } } } /* 动态列Jsonn解析 */ if (commonUtils.isNotEmptyArr(dynamicColumn) && commonUtils.isNotEmptyArr(dataSource)) { dynamicColumn.forEach((jsonStatus, index) => { if (commonUtils.isNotEmptyArr(jsonStatus.children)) { /* 嵌套列头JSON解析 */ const childrenJson = jsonStatus.children.filter(itemChild => itemChild.dataIndex && itemChild.dataIndex.includes('json')); for (const obj of childrenJson) { obj.render = (itemStr) => { if (commonUtils.isNotEmptyObject(itemStr) && commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); return (
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { // const sPartItemLength = sPartItem.length; let colorValue = '#000000'; const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch (Number(sState)) { // 根据状态显示颜色 case 1: colorValue = '#ff0000'; /* 1:红色 */ break; case 2: colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: colorValue = '#ffff00'; /* 3:黄色 */ break; case 0: colorValue = ''; /* 3:不要颜色 */ break; default: colorValue = ''; } return (
{t.dSchedulHours}
); }) }
); } }; }; } else { /* 无嵌套列头JSON列解析 */ dynamicColumn[index].render = (itemStr) => { if (commonUtils.isNotEmptyObject(itemStr) && commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); return (
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { // const sPartItemLength = sPartItem.length; let colorValue = '#000000'; const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch (Number(sState)) { // 根据状态显示颜色 case 1: colorValue = '#ff0000'; /* 1:红色 */ break; case 2: colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: colorValue = '#ffff00'; /* 3:黄色 */ break; default: colorValue = '#666'; } return (
{t.dSchedulHours}
); }) }
); } else { return itemStr; } }; } }); } // 判断时间状态 if (commonUtils.isNotEmptyArr(sTimeStatus) && commonUtils.isNotEmptyArr(dataSource)) { sTimeStatus[0].render = (itemStr) => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); const linkStyle = 'sTimeStatusStyle';/* 弹窗 */ return (
{ // eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; const sColor = t.sColor; const dWidth = t.dRate !== undefined && t.dRate !== 0 ? `${t.dRate * 500}px` : '100px'; const content = (

{`${t.sName} :${t.sValue}`}

); return (
{t.sValue}
); }) }
); } else { return itemStr; } }; } // 判断拼板状态 if (commonUtils.isNotEmptyArr(sScheduleStatusJson) && commonUtils.isNotEmptyArr(dataSource)) { this.useVListNew = true; sScheduleStatusJson[0].render = (itemStr) => { if (commonUtils.isJSON(itemStr)) { const itemJson = commonUtils.convertStrToObj(itemStr); const itemLength = itemJson.length; const content = itemJson.map((t, i) => { const { sState, sColor = '#000000', sName = '' } = t; return (
{sName}{i + 1 === itemLength ? '' : }
); }) return (
{ return
{content}
}}> {content}
); } }; } let components = {}; if (this.isDragAndDrop) { components.header = { cell: ResizeableTitle }; components.body = { row: DragableBodyRow }; } else { components.header = { cell: ResizeableTitle }; } let bPagination = true; /* 默认表格分页s */ if (commonUtils.isNotEmptyObject(this.props)) { bPagination = (commonUtils.isNotEmptyObject(this.props.tableProps) && commonUtils.isNotEmptyObject(this.props.tableProps.pagination)); } let noVlistController = false; if (this.props.config && this.props.config.gdsconfigformslave.filter(item => item.sControlName === 'bNoVlist')[0]) { noVlistController = true; } /* 特殊情况的表格 在虚拟列表情况 会无法滑动 */ let noVlistTable = false; if (this.props.noVlistTable) { noVlistTable = true; } // 判断是否有合并单元格, 有的话默认关闭虚拟滚动 // if (this.mergeCellStateMap) { // for (let key in this.mergeCellStateMap) { // if (this.mergeCellStateMap[key]) { // noVlistController= true; // } // } // } if (!noVlistTable && !this.props.xlyTableMax) { if (this.props.slaveInfo || this.useVListNew) { if (!this.uniqueId || window.vlistNewSearh) { this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); } if (!this.Vcomponents || window.vlistNewSearh) { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (oTable) { const oBody = oTable.querySelector('.ant-table-body'); oBody && (oBody.scrollTop = 0); } window.vlistNewSearh = null; this.Vcomponents = VListNew({ height: this.scrollY, vid: this.uniqueId, onScroll: () => { setTimeout(() => { let divs = document.getElementsByClassName('noInputInsert'); if (divs.length) { Array.prototype.forEach.call(divs, item => { item.parentNode.parentNode.parentNode.parentNode.classList.add('insertTd'); }); } }, 20); } }); } components = { ...this.Vcomponents, ...components }; } else { // vid是多个列表在同个页面中,同时渲染会促发问题 // vid不可以为随机数,随机数会导致双击时,点击的两个VList id不同 if (!this.uniqueId || window.vlistNewSearh) { this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); } if (!this.Vcomponents1 || window.vlistNewSearh) { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (oTable) { const oBody = oTable.querySelector('.ant-table-body'); oBody && (oBody.scrollTop = 0); } window.vlistNewSearh = null; this.Vcomponents1 = VList({ height: this.scrollY, vid: this.uniqueId, rowKey: this.rowKey, onScroll: () => { setTimeout(() => { let divs = document.getElementsByClassName('noInputInsert'); if (divs.length) { Array.prototype.forEach.call(divs, item => { item.parentNode.parentNode.parentNode.parentNode.classList.add('insertTd'); }); } }, 20); } }); } components = { ...this.Vcomponents1, ...components }; } } if (this.props.config && this.props.config.iFreezeColumn) { tableColumn.forEach((val, index) => { if (tableColumn[index].fixedHelp) { tableColumn[index].fixed = false; tableColumn[index].fixedHelp = false; } if (index < this.props.config.iFreezeColumn) { tableColumn[index].fixed = 'left'; tableColumn[index].fixedHelp = true; } }); } // 处理拖拽排序 if (this.props.dragHandle) { const handleSortTitle = commonFunc.showMessage(this.props.app.commonConst, 'sort') || '排序'; const handleSort = tableColumn.filter(item => item.dataIndex === 'handleSort').length; if (tableColumn[0]) { function arrayMoveMutable(array, fromIndex, toIndex) { const startIndex = fromIndex < 0 ? array.length + fromIndex : fromIndex; if (startIndex >= 0 && startIndex < array.length) { const endIndex = toIndex < 0 ? array.length + toIndex : toIndex; if (commonUtils.isNotEmptyObject(array[fromIndex].sWorkOrderUsed)) { message.error(array[fromIndex].sWorkOrderUsed); return; } const [item] = array.splice(fromIndex, 1); array.splice(endIndex, 0, item); } } function arrayMoveImmutable(array, fromIndex, toIndex) { array = [...array]; arrayMoveMutable(array, fromIndex, toIndex); return array; } const DragHandle = sortableHandle(() => ); const SortableItem = sortableElement(props => ); const SortableContainer = sortableContainer(props => ); const onSortEnd = ({ oldIndex, newIndex }) => { const { dataSource } = this.state; if (oldIndex !== newIndex) { const newData = arrayMoveImmutable([].concat(dataSource), oldIndex, newIndex).filter(el => !!el); this.props.onDrag(newData, this.props.name); } }; const DraggableContainer = props => ( ); const DraggableBodyRow = ({ className, style, ...restProps }) => { const { dataSource } = this.state; // function findIndex base on Table rowKey props and should always be a right array index const index = dataSource.findIndex(x => x.index === restProps['data-row-key']); return ; }; // 处理渲染后丢失input focus的bug. let bDrag = this.props.enabled && !this.props.bForbiddenDrag;/* 是否可以拖动 */ if (bDrag) { if (!this.DraggableContainer) { this.DraggableContainer = DraggableContainer; } if (!this.DraggableBodyRow) { this.DraggableBodyRow = DraggableBodyRow; } } if (!handleSort) { components = { ...components, body: { wrapper: this.DraggableContainer, row: this.DraggableBodyRow } }; } else { components = { ...components, body: { wrapper: this.DraggableContainer, row: this.DraggableBodyRow } }; tableColumn.shift(); } tableColumn.unshift( { title: handleSortTitle, dataIndex: 'handleSort', fixed: 'left', width: 40, className: 'drag-visible', render: () => , }, ) } } /** * 更新缓存数据 */ if (Array.isArray(tableColumn) && this.props.config) { const storageColumn = JSON.parse(sessionStorage.getItem(`${this.props.formId}_${this.props.config.sId}`)); if (storageColumn) { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}`, JSON.stringify(tableColumn)); } } let rowSelection = this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, 'slave'); // 是否选择多选框的问题 if (this.props.config && !this.props.config.bisMutiSelect) { rowSelection = null } const { expKeys } = this.state; /* 返回值 */ return { components, rowKey: this.rowKey, size: 'middle', bordered: true, /* 显示边框 */ className: !this.props.enabled ? styles.disabledProup : styles.proup, /* 样式控制 */ scroll: { x: 'max-content' }, /* 宽度 */ dataSource, /* 数据 */ columns: tableColumn, /* 表头 */ // rowSelection: this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, 'slave'), /* 添加的复选框(checkbox)功能 */ rowSelection, // pagination: false, /* 不分页 */ rowClassName: this.setRowClassName.bind(this, 'slave'), onRow: (record, index) => { if (this.isDragAndDrop) { return { index, onClick: () => { this.onRowClick(record, index, undefined, this.props.name, 'slave'); }, onMouseEnter: () => { this.onRowMouseEnter(record); }, onMouseLeave: () => { this.onRowMouseLeave(record); }, onDoubleClick: () => { this.onDoubleClick(this.props.name, record); }, moveRow: (dragIndex, hoverIndex, dragKey, hoverKey) => { this.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); }, onDragClick: (type) => { this.onRowClick(record, index, type, this.props.name, 'slave'); }, }; } else { return { index, onClick: () => { this.onRowClick(record, index, undefined, this.props.name, 'slave'); }, onDoubleClick: () => { this.onDoubleClick(this.props.name, record); }, onMouseEnter: () => { this.onRowMouseEnter(record); }, onMouseLeave: () => { this.onRowMouseLeave(); }, }; } }, onExpand: (expanded, record) => { if (this.showExpAll) { if (expanded) { const expKeysNew = [...expKeys, record[this.rowKey]]; this.currentExpKeys = expKeysNew; this.setState({ expKeys: expKeysNew }); } else { const expKeysNew = expKeys.filter(item => item !== record[this.rowKey]); this.currentExpKeys = expKeysNew; this.setState({ expKeys: expKeysNew }); } } this.onExpand(expanded, record, 'slave'); /* 点击展开图标时触发s */ }, expandedRowKeys: expKeys.length || this.showExpAll || this.isAllowConExpendKeys ? expKeys : null, id: commonUtils.isEmptyArr(dataSource) ? 'unDataBox' : 'dataBox', /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */ ...this.props.tableProps, pagination: bPagination ? { ...this.props.tableProps.pagination, onChange: (current, size) => { this.curPagination = { current, pageSize: size } } } : false, /* 表格是否分页 */ onChange: this.onChange, }; }; /** 获取子从表复选框对象的props */ getSlaveRowSelection = (name, type) => { const { bMutiSelect } = this.props.slaveInfo; /* 显示单选框还是复选框 */ let { bisMutiSelect } = this.props.slaveInfo; /* 是否显示选择框 */ if (this.props.slaveInfo.config) { bisMutiSelect = this.props.slaveInfo.config.bisMutiSelect } if (name === 'control' || (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf('commonAuto') > -1)) { // 控制表中可以通过bisMutiSelect显示或者隐藏勾选框 if (bisMutiSelect) { return { preserveSelectedRowKeys: true, selectedRowKeys: type === 'slaveInfo' ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys, /* 已选择的数据集 */ onChange: this.handleSelectRowChange.bind(this, name), /* 选择行发生改变时调用的函数 */ getCheckboxProps: record => ({ style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, }), /* 过滤合计的选择框 */ type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } else { return null; } } else { return { preserveSelectedRowKeys: true, selectedRowKeys: type === 'slaveInfo' ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys, /* 已选择的数据集 */ onChange: this.handleSelectRowChange.bind(this, name), /* 选择行发生改变时调用的函数 */ getCheckboxProps: record => ({ style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, }), /* 过滤合计的选择框 */ type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } }; /** 获取table对象的props */ getSlaveTableProps = () => { /* 给数据都添加上key */ if (this.props.setExpandedRowRender !== undefined && this.props.setExpandedRowRender.toString() === 'Y') { const { dataSource, tableColumn, tableProps, name: slaveInfoName, config: slaveInfoConfig, } = this.props.slaveInfo; // const scrollHeight = parseInt(document.body.clientHeight - 400, 10); const components = {}; if (this.isDragAndDrop) { components.header = { cell: ResizeableTitle }; components.body = { row: DragableBodyRow }; } else { components.header = { cell: ResizeableTitle }; } let rowSelection = this.props.rowSelection !== undefined ? this.props.rowSelection : this.getSlaveRowSelection(slaveInfoName, 'slaveInfo'); if (slaveInfoConfig && !slaveInfoConfig.bisMutiSelect) { /* 如果子表配置不显示选择框 则不显示选择框 */ rowSelection = null; } /* 返回值 */ return { components, rowKey: tableProps.rowKey, size: 'small', bordered: true, /* 显示边框 */ className: !this.props.enabled ? styles.disabledProup : styles.proup, /* 样式控制 */ scroll: { x: 'max-content' }, /* 宽度 */ dataSource, /* 数据 */ columns: tableColumn, /* 表头 */ rowSelection: rowSelection, /* s 添加的复选框(checkbox)功能 */ pagination: false, /* 不分页 */ rowClassName: this.setRowClassName.bind(this, 'slaveInfo'), onRow: (record, index) => { if (this.isDragAndDrop) { return { index, onClick: () => { this.onRowClick(record, index, undefined, slaveInfoName, 'slaveInfo'); }, onDoubleClick: () => { this.onDoubleClick(record, index, undefined, slaveInfoName, 'slaveInfo'); }, moveRow: (dragIndex, hoverIndex, dragKey, hoverKey) => { this.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); }, onDragClick: (type) => { this.onRowClick(record, index, type, slaveInfoName, 'slaveInfo'); }, }; } else { return { index, onClick: () => { this.onRowClick(record, index, undefined, slaveInfoName, 'slaveInfo'); }, onDoubleClick: () => { this.onDoubleClick(slaveInfoName, record); }, }; } }, // footer: this.props.footer === undefined ? this.tableFooter : undefined, id: commonUtils.isEmptyArr(dataSource) ? 'unDataBox' : 'dataBox', /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */ ...this.props.slaveInfo.tableProps, onChange: this.onChange, }; } else { return null; } }; getTableFilterData = () => { const { dataSource } = this.state; const { masterData } = this.props; let filterData = 0; const GetFilterData = this.props.OnGetFilterData; if (GetFilterData !== undefined) { filterData = this.props.OnGetFilterData(this.props.name, this.props.bFinished); } else { filterData = dataSource.length; } if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sZczlxShowName)) { if (masterData.sZczlxShowName === '删除' || masterData.sZczlxShowName === '恢复') { filterData += 1; } } return filterData; } /** 获取showConfig */ getShowConfig = (props, sName, isSlaveInfo) => { /* 返回值声明 */ let showConfig = []; /* 通过sName过滤出对应的showConfig */ if (props.customConfig) { const showConfigArr = props.customConfig.filter(item => item.sName === sName && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; } } else { if (props.config) { const showConfigArr = props.config.gdsconfigformslave.filter(item => item.sName === sName && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; } } if (isSlaveInfo && commonUtils.isNotEmptyObject(this.props.slaveInfo) && commonUtils.isNotEmptyObject(this.props.slaveInfo.config)) { const showConfigArr = this.props.slaveInfo.config.gdsconfigformslave.filter(item => item.sName === sName && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; } } } /* 返回值 */ return showConfig; }; /** 获取颜色Config */ getColorConfig = () => { let showConfig = []; /* 通过sName过滤出对应的showConfig */ /* 通过sName过滤出对应的showConfig */ if (this.props.customConfig) { const showConfigArr = this.props.customConfig.filter(item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } else { if (this.props.config) { const showConfigArr = this.props.config.gdsconfigformslave.filter(item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } if (commonUtils.isNotEmptyObject(this.props.slaveInfo) && commonUtils.isNotEmptyObject(this.props.slaveInfo.config)) { const showConfigArr = this.props.slaveInfo.config.gdsconfigformslave.filter(item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } } /* 返回值 */ return showConfig; }; rowColorData = React.createRef(); getColorStyle = (record, isRowShow) => { let styleColorArrTotal = ''; const showConfigArr = this.getColorConfig(); /* 拿到颜色配置json */ if (commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) { for (const showConfig of showConfigArr) { let styleColorArr = ''; const colorConditon = commonUtils.isNotEmptyObject(showConfig) ? showConfig.sColorTerms : null; if (commonUtils.isNotEmptyObject((colorConditon))) { let colorConditionArr = ''; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { colorConditionArr = ''; } colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ''; /* 判断是否是数组 */ for (const item of colorConditionArr) { let styleColor = ''; const { column, condition, conditionValue, color, isRow, } = item; if (record[column] !== undefined) { if (color && !document.getElementById(`color${color.replace('#', '-')}`)) { var style = document.createElement('style'); style.type = 'text/css'; style.id = `color${color.replace('#', '-')}`; style.innerHTML = ` .color${color.replace('#', '-')} td { background-color:${color}!important; .ant-table-selection-column { background-color:${color}!important; } } `; document.getElementsByTagName('head')[0].appendChild(style); } if (isRow && isRowShow && !commonUtils.isEmpty(record[column]) && commonUtils.isNotEmptyObject(record[column].toString())) { /* 配置行 */ let { conditionValue: conditionValueOld } = item; const conditionValue = record[conditionValueOld] ? record[conditionValueOld] : conditionValueOld; if (condition === '=') { if (commonUtils.isNotEmptyObject(conditionValue) && conditionValue.includes('#')) { const sXName = conditionValue.replace('#', '').replace('#', '').trim(); if (sXName && commonUtils.isNotEmptyObject(this.props[sXName])) { const sXValue = this.props[sXName]; styleColor = record[column] === sXValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } } else { styleColor = record[column] === conditionValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } } else if (condition === '!=') { styleColor = record[column] != conditionValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } else if (condition === 'like') { if (column.substring(0, 1) === 's') { styleColor = record[column]?.indexOf(conditionValue) > -1 ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } } else if (condition === '>') { styleColor = record[column] > conditionValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } else if (condition === '>=') { styleColor = record[column] >= conditionValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } else if (condition === '<') { styleColor = record[column] < conditionValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } else if (condition === '<=') { styleColor = record[column] <= conditionValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } } } styleColorArr += styleColor; const index = this.rowColorData.current?.findIndex(i => i && i.key === record?.[this.rowKey]); if (styleColor) { if (Array.isArray(this.rowColorData.current) && index >= 0) { this.rowColorData.current[index] = { key: record?.[this.rowKey], color }; } else { this.rowColorData.current = [...this.rowColorData.current || [], { key: record?.[this.rowKey], color }]; } } else { if (Array.isArray(this.rowColorData.current) && index >= 0) this.rowColorData.current?.splice(index, 1); } } } styleColorArrTotal += `${styleColorArr} `; } } return styleColorArrTotal; } /** 获取单元格颜色配置 */ getCellColorConfig = (text, record, sName) => { let styleColorArrTotal = ''; /* 单元格文字颜色 */ let styleColorArrTotalB = ''; /* 单元格背景颜色 */ let styleColorArr = ''; let styleColorArrB = ''; const styleColorArrTotalM = {}; const showConfigArr = this.getColorConfig(); /* 拿到颜色配置json */ if (commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) { for (const showConfig of showConfigArr) { const colorConditon = commonUtils.isNotEmptyObject(showConfig) ? showConfig.sColorTerms : null; if (commonUtils.isNotEmptyObject((colorConditon))) { let colorConditionArr = ''; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { colorConditionArr = ''; } colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ''; for (const item of colorConditionArr) { let styleColor = ''; // eslint-disable-next-line no-unused-vars let styleBackground = ''; const { column, condition, color, background, isRow, } = item; if (!isRow) { /* 根据配置设置单元格颜色 */ let { conditionValue: conditionValueOld } = item; const conditionValue = record[conditionValueOld] ? record[conditionValueOld] : conditionValueOld; if (column === sName && (column === showConfig.sName || showConfig.sControlName?.startsWith('canOtherConfig'))) { /* 只控制该配置的单元格 */ if (condition === '=') { styleColor = record[column] === conditionValue ? color : ''; styleBackground = record[column] === conditionValue ? background : ''; } else if (condition === '!=') { styleColor = record[column] != conditionValue ? color : ''; styleBackground = record[column] !== conditionValue ? background : ''; } else if (condition === 'like') { if (sName.substring(0, 1) === 's') { styleColor = record[column]?.indexOf(conditionValue) > -1 ? color : ''; styleBackground = record[column]?.indexOf(conditionValue) > -1 ? background : ''; } } else if (condition === '!=') { styleColor = record[column] !== conditionValue ? color : ''; styleBackground = record[column] !== conditionValue ? background : ''; } else if (condition === '>') { styleColor = record[column] > conditionValue ? color : ''; styleBackground = record[column] > conditionValue ? background : ''; } else if (condition === '>=') { styleColor = record[column] >= conditionValue ? color : ''; styleBackground = record[column] >= conditionValue ? background : ''; } else if (condition === '<') { styleColor = record[column] < conditionValue ? color : ''; styleBackground = record[column] < conditionValue ? background : ''; } else if (condition === '<=') { styleColor = record[column] <= conditionValue ? color : ''; styleBackground = record[column] <= conditionValue ? background : ''; } else if (Array.isArray(condition)) { /* 通过其他列条件控制该字段的颜色显示 */ if (commonUtils.isNotEmptyArr(condition)) { for (const itemConditon of condition) { const { bFilterName, bFilterCondition, color, background, } = itemConditon; let { bFilterValue: bFilterValueOld } = itemConditon; const bFilterValue = record[bFilterValueOld] ? record[bFilterValueOld] : bFilterValueOld; if (bFilterCondition === '=') { styleColor = record[bFilterName] === bFilterValue ? color : ''; styleBackground = record[bFilterName] === bFilterValue ? background : ''; } else if (bFilterCondition === 'like') { if (sName.substring(0, 1) === 's') { styleColor = record[bFilterName].indexOf(bFilterValue) > -1 ? color : ''; styleBackground = record[bFilterName].indexOf(bFilterValue) > -1 ? background : ''; } } else if (bFilterCondition === '!=') { styleColor = record[bFilterName] !== bFilterValue ? color : ''; styleBackground = record[bFilterName] !== bFilterValue ? background : ''; } else if (bFilterCondition === '>') { styleColor = record[bFilterName] > bFilterValue ? color : ''; styleBackground = record[bFilterName] > bFilterValue ? background : ''; } else if (bFilterCondition === '>=') { styleColor = record[bFilterName] >= bFilterValue ? color : ''; styleBackground = record[bFilterName] >= bFilterValue ? background : ''; } else if (bFilterCondition === '<') { styleColor = record[bFilterName] < bFilterValue ? color : ''; styleBackground = record[bFilterName] < bFilterValue ? background : ''; } else if (bFilterCondition === '<=') { styleColor = record[bFilterName] <= bFilterValue ? color : ''; styleBackground = record[bFilterName] <= bFilterValue ? background : ''; } } } } } } styleColorArr += styleColor; styleColorArrB += styleBackground; if (styleColor) { styleColorArr = styleColor; } if (styleBackground) { styleColorArrB = styleBackground; } } } styleColorArrTotal = styleColorArr; styleColorArrTotalB = styleColorArrB; } } const iIndex = showConfigArr.findIndex(item => item.sName === sName); if (iIndex !== -1) { const { sColorTerms } = showConfigArr[iIndex]; if (sColorTerms && sColorTerms.startsWith('#')) { styleColorArrTotal = sColorTerms; } } styleColorArrTotalM.styleColorArrTotal = styleColorArrTotal; styleColorArrTotalM.styleColorArrTotalB = styleColorArrTotalB; return styleColorArrTotalM; }; /** * 部分字段不可编辑 */ getSelectRowEditState = (sName, record, enabled) => { const { config, name, masterData } = this.props; let result = enabled; const { sInstruct: sInstructStr } = config; const sInstruct = commonUtils.convertStrToObj(sInstructStr, {}); const { data = [] } = sInstruct; const btnConfig = data.find(item => item && item.name === sName && item.enabled !== undefined); if (btnConfig && enabled) { const { enabled: enabledContent } = btnConfig; if (typeof enabledContent === 'boolean') { result = enabledContent; } else if (enabledContent) { const tempData = { props: { enabled }, master: masterData, [name]: record }; let strNew = enabledContent; Object.keys(tempData).forEach(key => { const reg = new RegExp(`${key}\\.`, "g"); strNew = strNew.replace(reg, `tempData["${key}"].`); }); try { const evalStr = eval("`" + strNew + "`"); result = !!eval(evalStr); // console.log('=====表格行按钮状态结果', result, { sName, enabledContent, tempData, strNew, evalStr }); } catch (error) { // console.log('=====表格行按钮状态错误', { error, enabledContent, strNew, tempData }); } } } return result; } // 获取表格行按钮状态 getTableBtnState = (btnName, record) => { let result = false; const { enabled, config, masterData, name, sUseInfo, bLimitOperate } = this.props; result = enabled; /* 订单占用,则该行锁定 不能操作 */ const { sWorkOrderUsed } = record; if (commonUtils.isNotEmptyObject(sWorkOrderUsed)) { result = false; } /* 若红冲单据 则按钮锁定 不能操作 */ if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sMinusSrcId) && masterData.sMinusType === '1') { result = false; } if (btnName === 'BtnAdd' && bLimitOperate) { result = false; } const { sInstruct: sInstructStr } = config; const sInstruct = commonUtils.convertStrToObj(sInstructStr, {}); const { data = [] } = sInstruct; const btnConfig = data.find(item => item && item.name === btnName && item.enabled !== undefined); if (btnConfig) { const { enabled: enabledContent } = btnConfig; if (typeof enabledContent === 'boolean') { result = enabledContent; } else if (enabledContent) { const tempData = { props: { enabled }, master: masterData, [name]: record }; let strNew = enabledContent; Object.keys(tempData).forEach(key => { const reg = new RegExp(`${key}\\.`, "g"); strNew = strNew.replace(reg, `tempData["${key}"].`); }); try { const evalStr = eval("`" + strNew + "`"); result = !!eval(evalStr); // console.log('=====表格行按钮状态结果', result, { btnName, enabledContent, tempData, strNew, evalStr }); } catch (error) { console.log('=====表格行按钮状态错误', { error, enabledContent, strNew, tempData }); } } } return result; } bCheckBoxColumm = (column) => { const { gdsconfigformslave } = this.props.config || {}; const item = gdsconfigformslave?.find(i => i && i.sName === column?.dataIndex && i.bVisible); if (item?.sControlName?.startsWith('bCheckBox')) { const checked = !!this.state.dataSource.length && !this.state.dataSource?.find(i => !i || !i[column?.dataIndex]); return <> { const { handleCheckBoxStatus } = this.props; typeof handleCheckBoxStatus === 'function' && handleCheckBoxStatus(e.target.checked, column?.dataIndex, this.props.name) }} /> {column?.title} } } /** 获取table的表头信息(主要是table中的表头信息合并,[{title:1-1},{title:1-2}]变成[{title:1,children:[{title:1},{title:2}]}]) type:是否过滤 */ getTableColumn = (headerColumn, type, props) => { // this.hasMergeHeader = false; // 判断是否是表单详情 const isSlaveInfo = props.name === 'slaveInfo' || ( location.pathname === '/indexPage/commonCostomTabBill' && props.name && props.name.includes('Info') && commonUtils.isNotEmptyObject(this.props.slaveInfo) ); const config = isSlaveInfo ? this.props.slaveInfo.config : this.props.config; const isSlaveInfoM = isSlaveInfo && commonUtils.isNotEmptyObject(config) ? config.showName === '工单物资评审' : false; /* 返回值声明 */ const tableColumn = []; let iIndex = 0; const specialRoute = commonUtils.isNotEmptyObject(this.props.app.currentPane) ? this.props.app.currentPane.route : ''; /* 获取路由名称 */ /* 遍历每一个表头标题 */ for (const column of headerColumn) { /* 表头标题 */ const title = column.title; const width = column.width; const bNotEmpty = column.bNotEmpty; /* 带'-'的表头是需要合并滴 */ const index = commonUtils.isNotEmptyObject(title) ? title.indexOf('-') : -1; /* 合并走合并的,不合并就直接push */ let columnNew = {}; let sorter; let search = true; if (props.tableProps !== undefined && props.tableProps.rowKey !== undefined && props.tableProps.rowKey !== 'sId' && !props.tableProps.sortSelf) { sorter = true; } else { const firstDataIndex = column.dataIndex.substring(0, 1); if (firstDataIndex === 'd' || firstDataIndex === 'i') { sorter = (a, b) => ((commonUtils.isEmpty(a[column.dataIndex]) ? 0 : a[column.dataIndex]) - (commonUtils.isEmpty(b[column.dataIndex]) ? 0 : b[column.dataIndex])); } else if (firstDataIndex === 't') { sorter = (a, b) => (moment(commonUtils.isEmpty(a[column.dataIndex]) ? '2000-01-01' : a[column.dataIndex]).diff(moment(commonUtils.isEmpty(b[column.dataIndex]) ? '2000-01-01' : b[column.dataIndex]))); } else { sorter = (a, b) => ((commonUtils.isEmpty(a[column.dataIndex]) ? '0' : a[column.dataIndex]).localeCompare((commonUtils.isEmpty(b[column.dataIndex]) ? '1' : b[column.dataIndex]))); } } /* 工单、工艺卡、报价单 去掉排序 */ if (this.props.name === 'sParam' || specialRoute.includes('workOrder') || specialRoute.includes('processCard') || specialRoute.includes('quotation')) { sorter = false; } /* 默认字段是排序的 通过配置bNotSort来设置字段不排序 */ if (config && commonUtils.isNotEmptyStr(config.gdsconfigformslave.filter(item => item.sName === column.dataIndex))) { if (config.gdsconfigformslave.filter(item => item.sName === column.dataIndex).length > 0 && config.gdsconfigformslave.filter(item => item.sName === column.dataIndex)[0].bNotSort) { sorter = false; } } if (config && commonUtils.isNotEmptyStr(config.gdsconfigformslave.filter(item => item.sName === column.dataIndex))) { if (config.gdsconfigformslave.filter(item => item.sName === column.dataIndex)[0].bNotSearch) { search = false; } } if (column.dataIndex === "spicture" || column.dataIndex === "tableLastEmpty") { sorter = false; } let sTitleBgColor = commonUtils.isNotEmptyObject(column.sTitleBgColor) ? column.sTitleBgColor : ''; /* 标题背景颜色 */ let sTitleColor = commonUtils.isNotEmptyObject(column.sTitleColor) ? column.sTitleColor : ''; /* 标题字体颜色 */ const styleObj = {}; if (commonUtils.isNotEmptyObject(sTitleBgColor)) { styleObj.background = sTitleBgColor; } if (commonUtils.isNotEmptyObject(sTitleColor)) { styleObj.color = sTitleColor; } const renderTitle = () => { // 树形表格在第一个column上加上全部展开/收起功能 let expandedAllIcon = ''; const columnIndex = headerColumn.findIndex(item => column.title === item.title); let { data } = this.props; let { expKeys } = this.state; expKeys = commonUtils.isNotEmptyArr(expKeys) ? expKeys : []; expKeys = this.currentExpKeys || expKeys; data = commonUtils.isNotEmptyArr(data) ? data : []; const childrenList = []; const getChildrenList = (data) => { data.forEach(item => { if (item && typeof item.children === 'object') { childrenList.push(item); getChildrenList(item.children); } }); } getChildrenList(data); if (columnIndex === 0 && childrenList.length) { // 第一个column并且数据中有children this.showExpAll = true; this.tableCollapsed = !expKeys.length; const marginLeft = this.props.bMutiSelect ? '6px' : '2px'; expandedAllIcon = (
); }; returnProps.filterIcon = filtered => ; returnProps.onFilterDropdownVisibleChange = (visible) => { if (visible) { setTimeout(() => this.searchInput.select()); } }; returnProps.onFilter = (value, record) => { let sValue = record[column.dataIndex]; const dropdownData = commonUtils.getStoreDropDownData(props.formId, props.name, column.dataIndex); if (commonUtils.isNotEmptyArr(dropdownData)) { const sId = commonUtils.isEmpty(dropdownData[0].sSlaveId) ? 'sId' : 'sSlaveId'; const iDropdownIndex = dropdownData.findIndex(item => item[sId] === record[column.dataIndex]); if (iDropdownIndex > -1) { const sFieldName = Object.keys(dropdownData[iDropdownIndex])[0]; sValue = dropdownData[iDropdownIndex][sFieldName]; } } else { const staticDropdownData = commonUtils.getStoreStaticDropDownData(props.formId, column.dataIndex); if (commonUtils.isNotEmptyObject(staticDropdownData)) { sValue = staticDropdownData[sValue]; } } if (record[column.dataIndex] !== undefined && sValue !== undefined) { return sValue.toString().toLowerCase().includes(value.toLowerCase()); } else { return ''.toString().toLowerCase().includes(value.toLowerCase()); } }; if (!props.enabled) { returnProps.render = (text, record, index) => { // 此处添加了row的index,原先一次渲染中包含searchProps的行的iIndex会相同,无法对行判断进行单元格合并 let sValue = record[column.dataIndex]; const dropdownData = commonUtils.getStoreDropDownData(props.formId, props.name, column.dataIndex); if (commonUtils.isNotEmptyArr(dropdownData)) { const sId = commonUtils.isEmpty(dropdownData[0].sSlaveId) ? 'sId' : 'sSlaveId'; const iDropdownIndex = dropdownData.findIndex(item => item[sId] === record[column.dataIndex]); if (text !== undefined && iDropdownIndex > -1) { const sFieldName = Object.keys(dropdownData[iDropdownIndex])[0]; sValue = dropdownData[iDropdownIndex][sFieldName]; } } if (!commonUtils.isEmpty(this.state.searchText) && column.bFind && column.dataIndex === this.state.searchColumnName && column.dataIndex.substring(0, 1) !== 'b' && column.dataIndex.substring(0, 1) !== 't') { return (); } else { return this.bindShowType(props, text, record, column.dataIndex, index); } }; } } return returnProps; }; /** 获取ShowType的props */ getShowTypeProps = (props, text, record, sName) => { const { enabled, sUseInfo, app, masterData } = props; /* 待用数据 */ const showConfig = this.getShowConfig(props, sName); /* 配置信息 */ if (commonUtils.isEmptyObject(showConfig)) { console.log('渲染失败:', showConfig, sName); } /* 返回值 */ let enabledNew = (enabled && !showConfig.bReadonly && !record.bInvalid && commonUtils.isEmpty(sUseInfo)); if (showConfig.iTag === 1) { enabledNew = false; } else if (showConfig.iTag === 3) { if (commonUtils.isNotEmptyObject(masterData) && !masterData.bCheck) { enabledNew = true; } } else if (record.rowTag === 1) { /* 当rowTag为1时,锁定该行不可编辑 */ enabledNew = false; } else if (record.bInvLock) { /* 当bInvLock时,锁定该行不可编辑 */ enabledNew = false; } /* 红冲中的单据 不可修改 */ if (commonUtils.isNotEmptyObject(masterData) && ((commonUtils.isNotEmptyObject(masterData.sMinusSrcId)) || commonUtils.isNotEmptyObject(masterData.sMinusUsed))) { enabledNew = false; if (app?.currentPane?.copyTo?.name && app.currentPane.copyTo.name.toLowerCase().includes('portion')) { // 部分红冲中可修改的字段 const iIndex = props.config.gdsconfigformslave.findIndex(item => item.sName === sName && item.sControlName.includes('portionField')); enabledNew = iIndex !== -1; } } enabledNew = this.getSelectRowEditState(sName, record, enabledNew); typeof props.otherlimitDisabled === 'function' && (enabledNew = props.otherlimitDisabled({ enabledNew, record, sName })); const showConfigAll = this.getColorConfig(); /* 拿到颜色配置json */ const showConfigArr = commonUtils.isNotEmptyArr(showConfigAll) ? showConfigAll.filter(item => item.sName === sName) : []; /* 找到该字段颜色配置 */ const colorConditon = commonUtils.isNotEmptyArr(showConfigArr) ? showConfigArr[0].sColorTerms : null; let styleColorArr = ''; if (commonUtils.isNotEmptyObject((colorConditon))) { let colorConditionArr = ''; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { colorConditionArr = ''; } colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ''; for (const item of colorConditionArr) { let styleColor = ''; const { column, condition, background, isRow, } = item; if (!isRow) { /* 根据配置设置单元格颜色 */ let { conditionValue: conditionValueOld } = item; const conditionValue = record[conditionValueOld] ? record[conditionValueOld] : conditionValueOld; if (column === sName && !commonUtils.isEmpty(record[column])) { if (condition === '=') { styleColor = record[column] === conditionValue ? `SetCell_${background}` : ''; } else if (condition === '!=') { styleColor = record[column] != conditionValue ? `SetCell_${background}` : ''; } else if (condition === 'like') { if (sName.substring(0, 1) === 's') { styleColor = record[column]?.indexOf(conditionValue) > -1 ? `SetCell_${color}` : ''; } } else if (condition === '>') { styleColor = record[column] > conditionValue ? `SetCell_${background}` : ''; } else if (condition === '>=') { styleColor = record[column] >= conditionValue ? `SetCell_${background}` : ''; } else if (condition === '<') { styleColor = record[column] < conditionValue ? `SetCell_${background}` : ''; } else if (condition === '<=') { styleColor = record[column] <= conditionValue ? `SetCell_${background}` : ''; } } } styleColorArr += styleColor; } } return { app, record, name: props.name, configName: props.configName, sTabId: props.sTabId, sId: record.sId, /* 修改当前编号(数据格式:字符串) */ dataValue: text, /* 本showType数据(数据格式:对象) */ enabled: enabledNew, /* 是否是查看状态(数据格式:布尔) */ showConfig, /* 关于本showType相关配置(数据格式:对象) */ tableConfig: props.config, /* 表格的所有配置 */ formId: this.formId, /* 窗体Id(数据格式:字符串) */ onChange: props.onDataChange, /* 表单数据改变事件方法(数据格式:函数) */ onKeyDown: (...args) => { props.onKeyDown && props.onKeyDown(...args, props.data); }, onInputClick: props.onInputClick, /* 鼠标单击事件 */ onContextMenu: props.onContextMenu, /* 字段右侧单击事件 */ bTable: true, /* 是否为表格数据 */ getSqlDropDownData: props.getSqlDropDownData, getSqlCondition: props.getSqlCondition, handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, getFloatNum: props.getFloatNum, getDateFormat: props.getDateFormat, onViewClick: this.handleViewClick, onTabModalClick: this.handleTabModalClick, onRightArrow: this.handleRightArrow, onViewChoose: this.handleViewChoose, onPreviewImage: this.handlePreviewImage, onPreviewOffice: this.handlePreviewOffice, onDropdownVisibleChange: this.handleDropdownVisibleChange, onFilterDropDownData: props.onFilterDropDownData, onFieldPopupModal: this.handleFieldPopupModal, /* 字段选择弹窗 */ onFieldDoubleClick: this.props.onFieldDoubleClick, onDropDownBlur: props.onDropDownBlur, /* 下拉框多选离开事件 */ className: styleColorArr, readOnly: props.readOnly, onSaveState: props.onSaveState, formRoute: props.formRoute, customDropData: props.customDropData, onGetParamsValue: props.onGetParamsValue, onExecInstructSet: props.onExecInstructSet, // 调用指令集 // handleSum: this.handleSum, }; }; /** 获取上传控件的props */ getUploadProps = () => { return { disabled: this.props.name === 'picFile' ? !this.findIsUpdByControlName(this.props, 'BtnUpload') : !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isUploadShow) }, /* 是否显示 */ }; }; /** 获取下载控件的props */ getDownProps = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isDownloadShow) }, /* 是否显示 */ }; }; /** 获取查看控件的props */ getLookProps = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isLookShow) }, /* 是否显示 */ onClick: this.handleLookRow, /* 点击事件 */ }; }; /** 获取添加控件的props */ getAddProps = () => { return { disabled: !this.props.enabled || this.findIsUpdByControlName(this.props, 'BtnAdd'), /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isAddShow) }, /* 是否显示 */ onClick: this.handleAddRow, /* 点击事件 */ }; }; getModalPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isModalShow), margin: '0 10px' }, /* 是否显示 */ }; }; getModalRemarkPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isModalRemarkShow) }, /* 是否显示 */ }; }; getChooseProcessPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isChooseProcessShow), margin: '0 10px' }, /* 是否显示 */ }; }; getChooseProductProcessPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isChooseProductProcess), margin: '0 10px' }, /* 是否显示 */ }; }; getChooseProductMaterialsPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isChooseProductMaterials), margin: '0 10px' }, /* 是否显示 */ }; }; getAddPropsTableRow = () => { return { disabled: !this.props.enabled || !this.findIsUpdByControlName(this.props, 'BtnAdd'), /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isAddShow), margin: '0 10px' }, /* 是否显示 */ }; }; getHeadPropsTableRow = () => { return { disabled: false, /* 是否可用 */ style: { margin: '0 0' }, /* 是否显示 */ }; }; /** 获取复制控件的props */ getCopyProps = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isCopyShow), margin: '0 10px' }, /* 是否显示 */ onClick: this.handleCopyRow, /* 点击事件 */ }; }; /** 获取复制全部控件的props */ getCopyAllProps = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isCopyAllShow), margin: '0 10px' }, /* 是否显示 */ onClick: this.handleCopyAllRow, /* 点击事件 */ }; }; /** 获取删除控件的props */ getDelProps = () => { return { disabled: !this.props.enabled || this.findIsUpdByControlName(this.props, 'BtnDel'), /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isDelShow) }, /* 是否显示 */ className: styles.del, /* 样式名 */ onClick: this.handleDelRow, /* 点击事件 */ }; }; getDelPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isDelShow), margin: '0 10px' }, /* 是否显示 */ className: styles.del, /* 样式名 */ }; }; getCopyMorePropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isCopyMoreShow), margin: '0 10px' }, /* 是否显示 */ className: styles.del, /* 样式名 */ }; }; getPopupPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ style: { display: commonUtils.convertBooleanToDisplayBlock(this.isPopupShow), margin: '0 10px' }, /* 是否显示 */ }; }; getParamPropsTableRow = () => { return { disabled: !this.props.enabled, /* 是否可用 */ // style: { display: commonUtils.convertBooleanToDisplayBlock(this.isParamShow), margin: '0 10px' }, /* 是否显示 */ style: { display: 'block', margin: '0 10px' }, /* 是否显示 */ }; }; /** 生成单元格stateMap */ genMergeCellStateMap() { let config = []; if (this.props.customConfig) { config = this.props.customConfig; } else { if (this.props.config) { config = this.props.config.gdsconfigformslave } } this.mergeCellStateMap = config.length && config.reduce((prev, cur) => { if (cur.sName) { prev[cur.sName] = cur.bMergeCell; if (cur.bMergeCell) { this.mergeCellList.push(cur.sName); } } return { ...prev }; }, {}); } genMergeInfoCellStateMap() { this.mergeInfoCellStateMap = this.props.slaveInfo.config && this.props.slaveInfo.config.gdsconfigformslave.reduce((prev, cur) => { if (cur.sName) { prev[cur.sName] = cur.bMergeCell; } return { ...prev }; }, {}); } /** 生成单元格list记录Map */ genMergeListStateMap() { let bPagination = true; /* 默认表格分页s */ let pagination = {}; if (commonUtils.isNotEmptyObject(this.props)) { bPagination = (commonUtils.isNotEmptyObject(this.props.tableProps) && commonUtils.isNotEmptyObject(this.props.tableProps.pagination)); pagination = this.props.tableProps.pagination; } let data; if (commonUtils.isNotEmptyArr(this.tableFilterData)) { const sSlaveIdArr = this.tableFilterData.map(item => item.sSlaveId); data = this.props.data.filter(item => sSlaveIdArr.includes(item.sSlaveId)); } else if (bPagination) { const { pageSize, current } = commonUtils.isNotEmptyObject(this.curPagination) ? this.curPagination : pagination; this.curPagination = {}; // 如果数据条数大于每页条数,说明是假分页,要截取当前页数据 if (this.props.data && pageSize && this.props.data.length > pageSize) { const maxCurrent = Math.ceil(this.props.data.length / pageSize); const newCurrent = Math.min(maxCurrent, current); const startIndex = (newCurrent - 1) * pageSize; const endIndex = startIndex + pageSize; data = this.props.data.slice(startIndex, endIndex); } else { data = this.props.data; } } else { data = this.props.data; } if (!data) { return; } /* 如果是树形 则返回 */ if (this.props.sTableType && this.props.sTableType != 'zero') { return; } const obj = {}; let sColorIndex = 1; let config = []; if (this.props.customConfig) { config = this.props.customConfig; } else { if (this.props.config) { config = this.props.config.gdsconfigformslave; } } data.forEach((item, index) => { const mergeCellData = config.filter(item => item.sName === 'sMergeCellFiled'); /* 查找合并单元格的基准字段 */ const sMergeCellFiled = commonUtils.isNotEmptyArr(mergeCellData) ? mergeCellData[0].sActiveKey : ''; /* 基准字段 */ if (index === 0 && commonUtils.isNotEmptyArr(this.mergeCellList)) { item.sColor = ''; } // 第一条数据不需要检测 if (index !== 0) { const prevData = data[index - 1]; let flag = false; for (const key in item) { // 判断是否与上一个值相同 if (item[key] !== '' && item[key] === prevData[key] && (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true)) { if (!obj[key]) { obj[key] = []; } obj[key].push(index - 1); if (this.mergeCellList.includes(key)) { flag = true; } } } if (commonUtils.isNotEmptyArr(this.mergeCellList)) { if (flag) { item.sColor = sColorIndex % 2 === 0 ? 'dark-record-row' : ''; } else { sColorIndex++; item.sColor = sColorIndex % 2 === 0 ? 'dark-record-row' : ''; } } } }); for (const key in obj) { obj[key] = obj[key].reduce((prev, cur) => { if (prev.length && (cur - prev[0][0]) === 1) { prev[0].unshift(cur); } else { prev.unshift([cur]); } return prev; }, []).reverse().map(a => a.reverse()); } this.mergeCellListMap = obj; } genMergeInfoListStateMap() { if (!this.curSlaveInfoData) { return; } const obj = {}; this.curSlaveInfoData.forEach((item, index) => { const mergeCellData = this.props.slaveInfo.config && this.props.slaveInfo.config.gdsconfigformslave.filter(item => item.sName === 'sMergeCellFiled'); /* 查找合并单元格的基准字段 */ const sMergeCellFiled = commonUtils.isNotEmptyArr(mergeCellData) ? mergeCellData[0].sActiveKey : ''; /* 基准字段 */ // 第一条数据不需要检测 if (index !== 0) { const prevData = this.curSlaveInfoData[index - 1]; for (const key in item) { // 判断是否与上一个值相同 if (item[key] !== '' && item[key] === prevData[key] && (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true)) { if (!obj[key]) { obj[key] = []; } obj[key].push(index - 1); } } } }); for (const key in obj) { obj[key] = obj[key].reduce((prev, cur) => { if (prev.length && (cur - prev[0][0]) === 1) { prev[0].unshift(cur); } else { prev.unshift([cur]); } return prev; }, []).reverse().map(a => a.reverse()); } this.mergeInfoCellListMap = obj; } modalTbRow = (record, tableName) => { this.handleModalRow(record, tableName); }; modalRemarkTbRow = async (record) => { await this.onRowClick(record); this.handleModalRemarkRow(record); }; chooseProcessTbRow = (record) => { this.handleChooseProcessRow(record); }; /* 选择成品工序 */ chooseProductProcessModalTbRow = (index, record) => { this.handleChooseProductProcessRow(index, record); }; /* 选择成品材料 */ chooseProductMaterialsModalTbRow = (index, record) => { this.handleChooseProductMaterialsRow(index, record); }; addTbRow = (index) => { this.handleAddRow(index); }; addTbRowInHeader = (index) => { this.handleAddRow(index, this.props.bModalAdd); }; delTbRow = (index, record) => { this.handleDelRow(index, record); }; copyTbMoreRow = (index, record) => { this.handleCopyMoreRow(index, record); }; replaceTbRow = (index, record) => { this.handleReplaceRow(index, record); }; /* 被占用的表格行不能删除 */ handleTbRowUsed = (index, record) => { const { rowTag, sWorkorderNo } = record; const { enabled } = this.props; if (enabled && rowTag === 1) { const warning = commonFunc.showMessage(this.props.app.commonConst, 'beUsed');/* 复制部件 */ const { sModelsType } = this.props.app.currentPane; if (sModelsType.includes('sales/')) { message.error(warning + sWorkorderNo); } } else { return null; } }; handleSelectCancel = (modelVisible) => { this.setState({ [modelVisible]: false, }); }; handleSelectCommonPopup = (name, selectConfig, selectData) => { const { commonPopupTbName, commonPopupShowConfig, commonFieldPopupVisible, commonPopupVisible, commonFieldPopupTbName, commonFieldPopupShowConfig, commonModalVisible, commonModalShowConfig, commonModalTbName } = this.state; /* 若是产品名称弹窗 并且配置了调用产品工艺卡标识copyFromTechnology 则走自己的逻辑 */ if (selectConfig.sCompareColor === 'copyFromTechnology') { this.props.onSelectCommonPopupProduct(name, selectConfig, selectData, commonPopupTbName, commonPopupShowConfig); } else { let tb = commonPopupVisible ? { name: commonPopupTbName, config: commonPopupShowConfig } : commonFieldPopupVisible ? { name: commonFieldPopupTbName, config: commonFieldPopupShowConfig } : undefined; tb = commonModalVisible ? { name: commonModalTbName, config: commonModalShowConfig } : tb; if (selectConfig.sControlName?.startsWith('BtnPopupEdit')) { this.props.onSelectCommonPopup(name, selectConfig, selectData, tb?.name, tb?.config, { index: this.rowClickRef.current }); return; } this.props.onSelectCommonPopup(name, selectConfig, selectData, tb?.name, commonPopupShowConfig); } }; handleSelectCommonFieldPopup = (name, selectConfig, selectData) => { const { commonFieldPopupTbName, commonFieldPopupShowConfig } = this.state; this.props.onSelectCommonPopup(name, selectConfig, selectData, commonFieldPopupTbName, commonFieldPopupShowConfig); }; copyTbRow = (index) => { this.handleCopyRow(index); }; copyAllTbRow = (index) => { this.handleCopyAllRow(index); }; downloadTbRow = (index, record) => { this.handleDownloadRow(index, record); }; popupModalTbRow = (index, record, btnName) => { setTimeout(() => { this.handlePopupRow(index, record, btnName); }, 0); }; paramModalTbRow = (index, record) => { this.handleParamRow(index, record); }; exitTbRow = (index, record) => { this.props.onExitTbRow(index, record); } handleViewClick = (name, sName, record, index, showConfig, configName) => { // console.log('vvvs', showConfig); if (commonUtils.isNotEmptyObject(showConfig) && commonUtils.isNotEmptyObject(record)) { const printPdf = showConfig.sControlName; /* 工单号配置调到打印界面,跳转打印页面 */ const sActiveKey = showConfig.sActiveKey;/* 弹出界面对应数据主字段 */ if (commonUtils.isNotEmptyObject(printPdf) && printPdf === 'printPdf' && commonUtils.isNotEmptyObject(sActiveKey)) { const token = this.props.app.token; const sActiveId = showConfig.sActiveId === '1' ? commonUtils.isEmpty(record.sFormId) ? record.sSrcFormId : record.sFormId : showConfig.sActiveId; const printsId = record[sActiveKey]; const urlPrint = `${commonConfig.file_host}printReport/printPdfByFromDataId/${printsId}.pdf?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`; window.open(urlPrint); } else if (showConfig.sActiveId === "172129113112117442504826460") { // 生成拼板 if (record.bMakeUpEnd) { this.props.onSaveState({ makeUpPDFRecord: record, }); } else { message.info("请先完成拼版!"); } } else if (showConfig.sDropDownType && showConfig.sDropDownType.toLowerCase().includes('picarrmodal')) { /* 蓝色链接跳转用Modal呈现 */ // this.props.onTabModalClick(name, sName, record, index, showConfig, configName); this.handleTabModalClick(name, sName, record, index, showConfig, configName); return; } else { if (this.handleHideModal()) { this.props.onViewClick(name, sName, { ...record, bLinkFieledClick: true }, index, showConfig, configName); } } } else { if (this.handleHideModal()) { this.props.onViewClick(name, sName, record, index, showConfig, configName); } } }; handleHideModal = () => { let antModalRootEl = null; const bInModal = (el) => { if (commonUtils.isEmpty(el) || commonUtils.isEmpty(el.classList)) { return false; } else if (el.classList.contains('ant-modal-root')) { antModalRootEl = el; return true; } else { return bInModal(el.parentNode); } } if (bInModal(event.target)) { // 如果是在modal里的表格,不允许跳转 const activeTab = document.querySelector('#navTabWrap .ant-tabs-nav-list>div[class*="ant-tabs-tab-active"]'); if (activeTab) { const modalId = activeTab.getAttribute('data-node-key') antModalRootEl.style.display = 'none'; antModalRootEl.setAttribute('data-attr-modalId', 'modalId_' + modalId); } else { return false; } } return true; } /* 快捷键跳转 */ handleQuickViewClick = async (name, sName, record, index, myConfigArr) => { const { slaveConfig, slaveData, dispatch, slaveFilterCondition, slavePagination, slaveOrderBy, sModelsType, formRoute, treeFilterCondition, app, iPageSize, sModelsId, // slaveSelectedData, // masterData, // employeeConfig, } = this.props; let picArr = '' if (commonUtils.isNotEmptyArr(slaveConfig)) { picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === sName)); } if (commonUtils.isNotEmptyArr(myConfigArr)) { picArr = myConfigArr; } if (picArr.length > 0) { const getConfig = this.handleGetTableConfig; const tableDataRow = record; const iIndex = index; const [{ sActiveId }] = picArr; let [{ sActiveKey }] = picArr; const sFormId = sActiveId === '1' ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId; if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes('.')) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */ const index = sActiveKey.lastIndexOf('.'); sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length); } const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formRoute}`; const filterCondition = []; const conditionValues = this.props.getSqlCondition(picArr[0], name, tableDataRow); if (!commonUtils.isEmpty(conditionValues)) { Object.keys(conditionValues).forEach((item) => { if ((item === 'tStartDate_pro' || item.substring(0, 1) === 'p')) { if (!commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2) { const tStartDate = moment(conditionValues[item][0]).format(this.sDateFormat); const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat); filterCondition.push({ bFilterName: item, bFilterCondition: '=', bFilterValue: `${tStartDate},${tEndDate}`, }); } } else if ((item === 'mStartDate_pro' || item.substring(0, 1) === 'm')) { if (!commonUtils.isEmpty(conditionValues[item])) { const tStartDate = moment(conditionValues[item]).startOf('month').format(this.sDateFormat); const tEndDate = moment(conditionValues[item]).endOf('month').add(1, 'days').format(this.sDateFormat); filterCondition.push({ bFilterName: `t${item.substring(1, item.length)}`, bFilterCondition: '=', bFilterValue: `${tStartDate},${tEndDate}`, }); } } else if (item.substring(0, 1) === 't') { filterCondition.push({ bFilterName: item, bFilterCondition: '=', bFilterValue: moment(conditionValues[item]).format(this.sDateFormat), }); } else { filterCondition.push({ bFilterName: item, bFilterCondition: '=', bFilterValue: conditionValues[item], }); } }); } this.props.dispatch({ type: 'content/onRouter', payload: { url: sNameUrl, refresh: getConfig.bind(this, name, sModelsId), /* 刷新方法 */ sTabId: commonUtils.createSid(), // sParentId: this.state.sTabId, urlDataType: 'newPane', checkedId: myConfigArr[0].sId, sName: myConfigArr[0].sName, bFilter: slaveFilterCondition, pageSize: commonConfig.pageSize, pages: slavePagination, currentData: slaveData, conditonValues: conditionValues, newKey: tableDataRow[sActiveKey], currentIndex: iIndex, filterCondition, }, }); } }; /* 文件下载 */ handleFileDownload = (fileUrl) => { const fileList = fileUrl.split(','); fileList.forEach(item => { let fileName = item.substring(item.lastIndexOf('/') + 1); fileName = fileName.substring(fileName.indexOf('_') + 1); const filepath = `${commonConfig.file_host}file/download?savePathStr=${encodeURIComponent(item)}&sModelsId=100&token=${encodeURIComponent(this.props.app.token)}`; const xhr = new XMLHttpRequest(); xhr.open('get', filepath); xhr.responseType = 'blob'; xhr.send(); xhr.onload = function () { if (this.status === 200 || this.status === 304) { // 如果是IE10及以上,不支持download属性,采用msSaveOrOpenBlob方法,但是IE10以下也不支持msSaveOrOpenBlob if ('msSaveOrOpenBlob' in navigator) { navigator.msSaveOrOpenBlob(this.response, fileName); return; } const url = URL.createObjectURL(this.response); const a = document.createElement('a'); a.style.display = 'none'; a.href = url; a.download = fileName; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } }; }) }; /* 所有备注非编辑状态下点击链接可以弹出备注窗体 */ handleMemoShow = (name, sName, record, index, showConfig) => { if (commonUtils.isNotEmptyObject(record)) { const sMemo = showConfig.sName; const title = showConfig.showName; if (sName.includes(['sTemplateFullMemo', 'sContentMemo'])) { return this.setState({ simpleModalVisible: true, simpleModalWord: record[sName] }); } const sCurrMemoProps = { title, name, sValue: record[sName], sMemoField: sMemo, bVisibleMemo: true, sRecord: record, sMemoConfig: showConfig, bOnlyShow: true, }; this.props.onSaveState({ sCurrMemoProps }); } } handleViewChoose = (name, sName, record, index) => { this.props.onViewChoose(name, sName, record, index); } /* 弹出通用窗体 */ handlePopupModal = (showConfig, name) => { this.setState({ commonPopupVisible: true, commonPopupTbName: name, commonPopupShowConfig: showConfig, }); } /* 字段弹窗 */ handleFieldPopupModal = (showConfig, name, record) => { this.setState({ commonFieldPopupVisible: true, commonFieldPopupTbName: name, commonFieldPopupShowConfig: showConfig, commonFieldPopupShowRecord: record, }); } /* 蓝色链接弹出通用窗体 */ handleTabModalClick = (name, sName, record, index, showConfig, configName) => { // const { sourceAllData:data } = this.props; // let commonModalData = []; // if(sName === 'dSumCompleteAvailableStockQty' && commonUtils.isNotEmptyArr(data)) { // commonModalData = data.filter(item => item.sInkBOMsSlaveId === record.sInkBOMsSlaveId && // commonUtils.isNotEmptyObject(item.sInkBOMsMaterialsChildId) && // item.bSecondMainMaterials); // } this.setState({ commonModalVisible: true, commonModalTbName: name, commonModalShowConfig: showConfig, commonModalRecord: record, commonModalConfigName: configName, // commonModalData, }); } handleCellClick = (record) => { try { const { target } = event; const { tagName } = target; const oDiv = { 'span': target.getAttribute('data-name') ? target : target.parentNode, 'td': target?.childNodes[0]?.childNodes[0], 'div': target.getAttribute('data-name') ? target : target.childNodes[0], 'input': target, }[tagName.toLowerCase()]; if (!oDiv || window.getSelection().toString()) return false; const [sName, sControlName] = [oDiv.getAttribute('data-name'), oDiv.getAttribute('data-control-name')]; if (sControlName?.includes('_Sum')) { const { sumGroup = {}, totalData = [{}], totalDataNew: totalDataNew0 = [{}] } = this.state; const { dNetMoney, dNetPrice } = this.props.app.decimals; sumGroup[sName] = sumGroup[sName] || []; if (sumGroup[sName].includes(record[this.rowKey])) { sumGroup[sName] = sumGroup[sName].filter(item => item !== record[this.rowKey]); } else { sumGroup[sName].push(record[this.rowKey]); } let totalDataNew = [...totalDataNew0]; if (sumGroup[sName].length) { const sum = sumGroup[sName].reduce((pre, cur) => { const curData = this.props.data.find(item => item[this.rowKey] === cur); if (curData) { let tempValue = 0; if (sName.toLowerCase().endsWith('price')) { /* 价格 */ tempValue = commonUtils.convertFixNum(commonUtils.convertFixNum(commonUtils.isNull(curData[sName], 0), dNetPrice) + commonUtils.convertFixNum(commonUtils.isNull(pre, 0), dNetPrice), dNetPrice); } else { /* 金额 */ tempValue = commonUtils.convertFixNum(commonUtils.convertFixNum(commonUtils.isNull(curData[sName], 0), dNetMoney) + commonUtils.convertFixNum(commonUtils.isNull(pre, 0), dNetMoney), dNetMoney); } return tempValue; } return pre; }, 0); totalDataNew = [{ ...totalData[0], ...totalDataNew[0], [sName]: sum }]; } else { totalDataNew[0][sName] = totalData[0][sName]; } this.setState({ sumGroup, totalDataNew }); return !this.props.enabled; } return false; } catch (error) { return false; } } handleGetSumStyle = (sName, record) => { const { sumGroup = {} } = this.state; const sumList = sumGroup[sName] || []; return sumList.includes(record?.[this.rowKey]) ? " tableSumColor" : ""; } /* 点击图片预览 */ handlePreviewImage = (e, dataUrlArr, index) => { e.stopPropagation(); /* 阻止父级穿透 */ if (commonUtils.isNotEmptyObject(dataUrlArr)) { const { token } = this.props.app; const previewImageArr = []; dataUrlArr.forEach((item = '') => { const dataPreviewUrl = item.includes('xlyerpfiles') ? `${commonConfig.file_host}file/download?savePathStr=${item}&sModelsId=100&token=${token}` : item; /* 预览 */ previewImageArr.push(dataPreviewUrl); }); this.setState({ previewImage: previewImageArr, previewVisible: true, showimgs: true, firstIndex: index, }); } }; // office文件预览 handlePreviewOffice = (dataUrlArr) => { this.setState({ officePreviewVisible: true, officeFileUrl: dataUrlArr }); }; handleDropdownVisibleChange = (open) => { // this.beSelectDropdownOpen = open; }; /* 生产排程工艺流程字段弹窗 - 生产进度详情 */ handlesPartNameStatus = (sName, sWorkOrderId) => { if (commonUtils.isNotEmptyObject(sName) && commonUtils.isNotEmptyObject(sWorkOrderId)) { const filterData = this.props.config.gdsconfigformslave.filter(item => item.sName === sName); const showConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : []; const record = {}; record.sWorkOrderId = sWorkOrderId; this.props.onPartNameClick(sName, showConfig, record); } }; /* 打开新窗口查看SQL编辑器 */ handleOpenWin = (name, sName, record, index, showConfig) => { const sBtnName = sName; const sBtnContent = record[sName]; const sFormId = commonUtils.isNotEmptyObject(record.sId) ? record.sId : ''; const sBtnControlName = commonUtils.isNotEmptyObject(showConfig.sControlName) ? showConfig.sControlName : ''; console.log('sFormId:', sFormId); if (commonUtils.isNotEmptyObject(sBtnContent)) { const urlPrint = `${commonConfig.server_host}template/getSql/${sBtnName}/?sBtnContent=${sBtnContent}&sBtnControlName=${sBtnControlName}&sFormId=${sFormId}`; const w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; const h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; //const newWin = window.open('','_blank'); const features = "width=" + (w + 350) + ",height=" + (h + 300) + ", top=0, left=0, toolbar=no, menubar=no,scrollbars=no,resizable=no, location =no, status=no"; const newWin = window.open("", "SQL查看器", features); newWin.document.write(''); // window.open(urlPrint); } else { message.error('未找到对应过程名'); } }; /* 右箭头点击 */ handleRightArrow = (name, sName, record, index, showConfig) => { if (this.props.onRightArrow) { this.props.onRightArrow(name, sName, record, index, showConfig); } } /* 确定按钮:复制多行 */ handleOperateMoreOk = () => { const sNumber = document.getElementById('iNumber').value; console.log('sNumber', sNumber); if (commonUtils.isNotEmptyObject(iNumber) && Number(sNumber) > 0) { const iNumber = Number(sNumber); for (let i = 0; i < iNumber; i++) { this.handleCopyRow(0); } } this.setState({ bOperateMoreVisible: false }) } showimg = (i) => { this.setState({ showimgs: true, firstIndex: i }); }; toggleshow = () => { this.setState({ showimgs: false, previewVisible: false }); }; handleOk = () => { this.props.onSaveState({ previewVisible: false, }); }; handleCancelModal = (modelVisible) => { this.props.onSaveState({ [modelVisible]: false, }); }; /** 调整列宽 */ handleResize = (index, column, isSlaveInfo) => { return (e, { size }) => { if (e) { this.resize = true; } if (size.width === column.width) { return; } this.setState(({ tableColumn, tableInfoColumn }) => { let nextColumns; if (isSlaveInfo) { nextColumns = [...tableInfoColumn]; } else { nextColumns = [...tableColumn]; } let iIndexList = []; let iWidth = 0; let offset = 0; const iIndex = nextColumns.findIndex(item => item.dataIndex === column.dataIndex); if (iIndex !== -1) { // 单层表头 iIndexList = [iIndex, -1]; iWidth = nextColumns[iIndex].width === undefined ? this.countOperate() : nextColumns[iIndex].width; offset = size.width - iWidth; nextColumns[iIndex].width = size.width; } else { // 双层表头 for (let i = 0; i < nextColumns.length; i++) { const item = nextColumns[i]; const { children } = item; if (commonUtils.isNotEmptyArr(children)) { const childIndex = children.findIndex(child => child.dataIndex === column.dataIndex); if (childIndex !== -1) { iIndexList = [i, childIndex]; iWidth = nextColumns[i].children[childIndex].width === undefined ? this.countOperate() : nextColumns[i].children[childIndex].width; offset = size.width - iWidth; // const iWidthTemp = nextColumns[i].width === undefined ? this.countOperate() : nextColumns[i].width; // nextColumns[i].width = iWidthTemp + offset; nextColumns[i].children[childIndex].width = size.width; break; } } } } if (commonUtils.isNotEmptyArr(iIndexList)) { let lastIndexList = []; let lastIndex = nextColumns.findIndex(item => item.dataIndex === 'tableLastEmpty') - 1; if (lastIndex < -1) { lastIndexList = [nextColumns.length - 1, -1]; } else if (commonUtils.isNotEmptyArr(nextColumns[lastIndex].children)) { lastIndexList = [lastIndex, nextColumns[lastIndex].children.length - 1]; } else { lastIndexList = [lastIndex, -1]; } const oBody = this.mydiv.querySelector('.ant-table-body'); const { scrollWidth, clientWidth, scrollLeft } = oBody; const scrollRight = scrollWidth - clientWidth - scrollLeft; // 判断当前拖动列是否在最后一列前面 if (iIndexList[0] < lastIndexList[0] || (iIndexList[0] === lastIndexList[0] && iIndexList[1] < lastIndexList[1])) { const lastColumn = lastIndexList[1] === -1 ? nextColumns[lastIndexList[0]] : nextColumns[lastIndexList[0]].children[lastIndexList[1]]; const iWidthExtra = lastColumn.widthExtra || 0; // 最后一列额外的宽度 if (offset > 0) { // 向右拉伸 if (iWidthExtra) { //有额外宽度 if (iWidthExtra >= offset) { lastColumn.width -= offset; lastColumn.widthExtra -= offset; offset = 0; } else { const diffWidth = offset - iWidthExtra; lastColumn.width -= iWidthExtra; lastColumn.widthExtra = 0; offset = diffWidth; } } else if (!iWidthExtra && lastColumn.width - offset > 150) { // 没有额外宽度,但是减去位移后宽度大于150 lastColumn.width -= offset; offset = 0; } } else if (offset < 0) { // 向左拉伸 if (scrollRight < -offset) { // 滚动条距离表格右边距离小于拉伸距离 const diffWidth = -offset - scrollRight; lastColumn.width += diffWidth; lastColumn.widthExtra ? (lastColumn.widthExtra += diffWidth) : (lastColumn.widthExtra = diffWidth); offset = -diffWidth; } } // 处理拖动幅度太大时,空白列会显示问题 const oCol = this.mydiv.querySelector('colgroup'); const oCols = oCol ? oCol.childNodes : []; const oColsWithList = Array.from(oCols).filter(item => !item.className).map(item => parseInt(item.style.width)); if (!oColsWithList.includes(0)) { lastColumn.width += oColsWithList[lastIndex + 1]; } } } if (isSlaveInfo) { if (this.scrollInfoX) { this.scrollInfoX += offset; } else { this.scrollInfoX = 0; this.scrollInfoX = this.countScrollX(nextColumns, true); } return { tableInfoColumn: nextColumns }; } else { if (this.scrollX) { this.scrollX += offset; } else { this.scrollX = 0; this.scrollX = this.countScrollX(nextColumns); } return { tableColumn: nextColumns }; } }, () => { this.resize = false; this.initColumn = null; if (isSlaveInfo) { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}_info`, JSON.stringify(this.state.tableInfoColumn)); } else { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}`, JSON.stringify(this.state.tableColumn)); } }); }; } genFooter = () => { const { tableColumn, totalData: totalData0, totalDataNew, sumGroup = {}, totalData1 } = this.state; const totalData = Object.keys(sumGroup).some(key => sumGroup[key]?.length) ? totalDataNew : totalData0; const { dNetMoney, dNetPrice } = this.props.app.decimals; const sModelsType = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : ''; const sumset = commonFunc.showMessage(this.props.app.commonConst, 'sumSet') || '合计'; let colSpan = 0; if (this.props.footer !== undefined) { return (<>); } // 即使 totalData 和 totalData1 都为空,也要显示部分勾选合计 if (!totalData.length && !totalData1.length && !this.state.selectedRowCount) { return (<>); } if (this.props.tableProps.rowSelection !== null && !(this.props.config && !this.props.config.bisMutiSelect)) { colSpan = colSpan + 1; } if (this.props.slaveInfo) { colSpan = colSpan + 1; } if (this.props.dragHandle) { // colSpan = colSpan + 1; // 临时处理标准精准报价单据工序信息表合计错位问题 } const cells = []; const cells1 = []; if (totalData.length) { let summaryCellTotal = ''; summaryCellTotal = ( {sumset} ); // if(this.props.slaveInfo) { // summaryCellTotal = ( // // 合计 // // ); // } else { // summaryCellTotal = ( // // 合计 // // ); // } cells.push(summaryCellTotal); tableColumn.forEach((item, index) => { if (colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; if (tableColumn[index].children !== undefined && tableColumn[index].children.length > 0) { /* 循环嵌套标题行 */ tableColumn[index].children.forEach((itemChild, i) => { /* 合计 格式化单价、金额 */ let sValue = totalData[0][itemChild.dataIndex]; const columnConfig = this.props.config.gdsconfigformslave.find(item => item.sName === itemChild.dataIndex); if (commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.substring(0, 1) === 'd' && columnConfig?.sDateFormat === 'decimalPoint' && columnConfig?.sFieldValidation) { /* 取小数点位数 */ const point = columnConfig.sFieldValidation.split(',')[1] || 2; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } else if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf('commonList') || (sModelsType && sModelsType.indexOf('commonMultiList') > -1)) { /* 有配置以配置为主 否则以系统设定为主 */ if (commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.substring(0, 1) === 'd' && commonUtils.isNotEmptyObject(itemChild.sDateFormat)) { /* 取小数点位数 */ let point = 0; let strIndex = itemChild.sDateFormat.indexOf('.'); if (strIndex > -1 && itemChild.sDateFormat.length > 1) { point = itemChild.sDateFormat.substring(strIndex + 1, itemChild.sDateFormat.length).length; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } } else { if (commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.toLowerCase().endsWith('price')) { /* 列表单价格式化显示1 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils.convertFixNum(Number(sValue), dNetPrice).toFixed(dNetPrice); if (!isNaN(dResult)) { sValue = dResult; } } } else if (commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.toLowerCase().endsWith('money')) { /* 列表金额格式化显示 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils.convertFixNum(Number(sValue), dNetMoney).toFixed(dNetMoney); if (!isNaN(dResult)) { sValue = dResult; } } } } } const cellChild = ( {this.formatThousands(sValue)} ); cells.push(cellChild); }); } else { /* 正常单层标题行 */ let cell = ''; /* commonList 格式化单价、金额 */ let sValue = totalData[0][item.dataIndex]; if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf('commonList') || (sModelsType && sModelsType.indexOf('commonMultiList') > -1)) { /* 有配置以配置为主 否则以系统设定为主 */ const columnConfig = this.props.config.gdsconfigformslave.find(item1 => item1.sName === item.dataIndex); if (commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.substring(0, 1) === 'd' && columnConfig?.sDateFormat === 'decimalPoint' && columnConfig?.sFieldValidation) { /* 取小数点位数 */ const point = columnConfig.sFieldValidation.split(',')[1] || 2; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } else if (commonUtils.isNotEmptyObject(item.sDateFormat)) { /* 取小数点位数 */ let point = 0; let strIndex = item.sDateFormat.indexOf('.'); if (strIndex > -1 && item.sDateFormat.length > 1) { point = item.sDateFormat.substring(strIndex + 1, item.sDateFormat.length).length; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } } else { if (commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.toLowerCase().endsWith('price')) { /* 列表单价格式化显示1 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils.convertFixNum(Number(sValue), dNetPrice); if (!isNaN(dResult)) { sValue = dResult; } } } else if (commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.toLowerCase().endsWith('money')) { /* 列表金额格式化显示 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils.convertFixNum(Number(sValue), dNetMoney); if (!isNaN(dResult)) { sValue = dResult; } } } } } // 金额 数量 价格 千分位处理 cell = ( {this.formatThousands(sValue)} ); cells.push(cell); } }); } if (totalData1.length) { let summaryCellTotal1 = ''; summaryCellTotal1 = ( 总计 ); cells1.push(summaryCellTotal1); tableColumn.forEach((item, index) => { if (colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; if (tableColumn[index].children !== undefined && tableColumn[index].children.length > 0) { /* 循环嵌套标题行 */ tableColumn[index].children.forEach((itemChild, i) => { /* 合计 格式化单价、金额 */ let sValue = totalData1[0][itemChild.dataIndex]; const cellChild = ( {this.formatThousands(sValue)} ); cells1.push(cellChild); }); } else { /* 正常单层标题行 */ let cell = ''; /* commonList 格式化单价、金额 */ let sValue = totalData1[0][item.dataIndex]; cell = ( {this.formatThousands(sValue)} ); cells1.push(cell); } }); } // 部分勾选合计 const { selectedSumData, selectedRowCount } = this.state; const selectedCells = []; if (selectedRowCount > 0) { let selectedSummaryCellTotal = ''; selectedSummaryCellTotal = ( 已选{selectedRowCount}行 ); selectedCells.push(selectedSummaryCellTotal); tableColumn.forEach((item, index) => { if (colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; if (tableColumn[index].children !== undefined && tableColumn[index].children.length > 0) { tableColumn[index].children.forEach((itemChild, i) => { const sValue = selectedSumData.hasOwnProperty(itemChild.dataIndex) ? selectedSumData[itemChild.dataIndex] : ''; const cellChild = ( {this.formatThousands(sValue)} ); selectedCells.push(cellChild); }); } else { const sValue = selectedSumData.hasOwnProperty(item.dataIndex) ? selectedSumData[item.dataIndex] : ''; const cell = ( {this.formatThousands(sValue)} ); selectedCells.push(cell); } }); } return ( { selectedRowCount > 0 ? ( {selectedCells} ) : '' } { totalData.length ? ( {cells} ) : '' } { totalData1.length ? ( {cells1} ) : '' } ); } handleSearch = (selectedKeys, confirm, searchColumnName, clearFilters) => { confirm(); if (this.mounted) { this.setState({ searchText: selectedKeys[0], searchColumnName }); } let { clearArray } = this.props; if (commonUtils.isEmptyArr(clearArray)) { clearArray = []; } clearArray.push({ confirm, clearFilters }); this.props.onSaveState({ clearArray }); }; handleReset = (clearFilters, confirm) => { clearFilters(); if (this.mounted) { this.setState({ searchText: '' }, () => { // 重置搜索条件 confirm(); }); } }; /** 求和所有列 */ handleSumAllColumn = (config, dataSource) => { const tableDataTotal = {}; const sumConfig = config.gdsconfigformslave.filter(item => item.sName !== '' && item.bVisible && item.bSum); if (commonUtils.isNotEmptyArr(sumConfig)) { if (commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource)) { dataSource.forEach((tableDataRow) => { sumConfig.forEach((sumItem) => { if (tableDataRow.handleType !== 'del') { if (sumItem.sName.substring(sumItem.sName.length - 5, sumItem.sName.length).toLowerCase() === 'Price'.toLowerCase()) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } else { /* 如果设置格式 按照设置格式来,否则按照系统设定 */ const sFieldConfigArr = config.gdsconfigformslave.filter(item => item.sName === sumItem.sName && item.bVisible); if (commonUtils.isNotEmptyArr(sFieldConfigArr)) { const { sFieldValidation: sFieldValidationOld, sName } = sFieldConfigArr[0]; if (commonUtils.isNotEmptyObject(sFieldValidationOld)) { const [length1, length2] = sFieldValidationOld.split(','); if (commonUtils.isNotEmptyNumber(length2)) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(length2)); } } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } } } }); }); } else { sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; tableDataTotal.key = '0000'; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } } handleSelectColumn = (config, dataSource) => { const tableDataTotal = {}; // 添加防御性检查 if (!config || !config.gdsconfigformslave || !Array.isArray(config.gdsconfigformslave)) { return; } const sumConfig = config.gdsconfigformslave.filter(item => item && item.sName !== '' && item.bVisible && item.bSum); if (commonUtils.isNotEmptyArr(sumConfig)) { if (commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource)) { // 筛选出 bMark === true 的行 const selectedRows = dataSource.filter(tableDataRow => tableDataRow && tableDataRow.bMark === true); selectedRows.forEach((tableDataRow) => { sumConfig.forEach((sumItem) => { if (tableDataRow && tableDataRow.handleType !== 'del' && sumItem && sumItem.sName) { if (sumItem.sName.substring(sumItem.sName.length - 5, sumItem.sName.length).toLowerCase() === 'Price'.toLowerCase()) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum ? this.props.getFloatNum(sumItem.sName) : 2); } else { /* 如果设置格式 按照设置格式来,否则按照系统设定 */ const sFieldConfigArr = config.gdsconfigformslave.filter(item => item.sName === sumItem.sName && item.bVisible); if (commonUtils.isNotEmptyArr(sFieldConfigArr)) { const { sFieldValidation: sFieldValidationOld, sName } = sFieldConfigArr[0]; if (commonUtils.isNotEmptyObject(sFieldValidationOld)) { const [length1, length2] = sFieldValidationOld.split(','); if (commonUtils.isNotEmptyNumber(length2)) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(length2)); } } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } } } }); }); } else { sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; tableDataTotal.key = '0000'; console.log('tableDat212222222aTotal', tableDataTotal); if (this.mounted) { // 计算选中的行数,添加防御性检查 const selectedRowCount = commonUtils.isNotEmptyArr(dataSource) ? dataSource.filter(row => row && row.bMark === true).length : 0; this.setState({ selectedSumData: tableDataTotal, selectedRowCount: selectedRowCount }); } } } handleSumOtherColumn = (config, dataSource) => { const tableDataTotal = {}; const sumConfig = config.gdsconfigformslave.filter(item => item.sName !== '' && item.bVisible && item.bSum); if (commonUtils.isNotEmptyArr(sumConfig)) { if (commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource)) { const { selectedRowKeys } = this.state; /* 生产排程对选中行进行汇总 */ if (commonUtils.isNotEmptyArr(selectedRowKeys)) { const selectedData = dataSource.filter(item => selectedRowKeys.includes(item.sSlaveId)); if (commonUtils.isNotEmptyArr(selectedData)) { selectedData.forEach((tableDataRow) => { sumConfig.forEach((sumItem) => { if (tableDataRow.handleType !== 'del') { if (sumItem.sName.substring(sumItem.sName.length - 5, sumItem.sName.length).toLowerCase() === 'Price'.toLowerCase()) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } }); }); } } else { dataSource.forEach((tableDataRow) => { sumConfig.forEach((sumItem) => { if (tableDataRow.handleType !== 'del') { if (sumItem.sName.substring(sumItem.sName.length - 5, sumItem.sName.length).toLowerCase() === 'Price'.toLowerCase()) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } }); }); } } else { sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; tableDataTotal.key = '0000'; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } } handleSumChildColumn = (config, dataSource) => { const tableDataTotal = {}; const { filteredValue } = this.state; const sumConfig = config.gdsconfigformslave.filter(item => item.sName !== '' && item.bVisible && item.bSum); if (commonUtils.isNotEmptyArr(sumConfig)) { if (commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource) && commonUtils.isNotEmptyArr(filteredValue)) { /* 序号根据sSqlConditonId分组 序号重排 */ const groupedData = commonUtils.groupBy(dataSource, item => item.sSqlConditionId); let selectedData = []; if (commonUtils.isNotEmptyObject(groupedData)) { for (const key of Object.keys(groupedData)) { const eachData = groupedData[key]; if (commonUtils.isNotEmptyArr(eachData)) { /* 看当前选中在哪个组里 */ const iIndex = eachData.findIndex(item => filteredValue.includes(item.sSqlConditionId)); if (iIndex > -1) { selectedData = eachData; } } } } if (commonUtils.isNotEmptyArr(selectedData)) { selectedData.forEach((tableDataRow) => { sumConfig.forEach((sumItem) => { if (tableDataRow.handleType !== 'del') { if (sumItem.sName.substring(sumItem.sName.length - 5, sumItem.sName.length).toLowerCase() === 'Price'.toLowerCase()) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } }); }); } } else { sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; tableDataTotal.key = '0000'; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } } // 表格按钮点击后调用指令集 handleInstruct = (btnName, callback) => { const { sInstruct: sInstructStr } = this.props.config; const sInstruct = commonUtils.convertStrToObj(sInstructStr, {}); const { data = [] } = sInstruct; const btnConfig = data.find(item => item && item.name === btnName && item.click); if (btnConfig) { const { click, afterClick, clickOnly } = btnConfig; if (clickOnly) { // 只执行指令集 this.props.onExecInstructSet({ sInstruct: click, showName: "表格按钮only" }); } else if (afterClick) { // 先按钮再指令集 callback && callback(); setTimeout(() => { this.props.onExecInstructSet({ sInstruct: click, showName: "表格按钮->指令集" }); }, 1000); } else { // 先指令集再按钮 this.props.onExecInstructSet({ sInstruct: click, showName: "指令集->表格按钮", callback }); } } else { callback && callback(); } } /** 查看行 */ handleLookRow = () => { this.props.onLookRow(this.props.name); }; /** 材料备注行 */ handleModalRemarkRow = (index) => { this.props.onModalRow(index); }; /** modal行 */ handleModalRow = (recordIndex, tableName) => { if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseMaterialsConfigRow)) { this.handleInstruct('BtnChooseMaterials', () => { const iIndex = this.props.tableProps.chooseMaterialsConfigRow; this.props.onBtnChoose('materials', 'BtnChooseMaterials', iIndex, recordIndex, tableName); // recordIndex选中行的索引 }); } }; handleChooseProcessRow = (record) => { if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseProcessConfigRow)) { this.handleInstruct('BtnChooseProcess', () => { const iIndex = this.props.tableProps.chooseProcessConfigRow; if (this.props.name === 'slave0Child1') { const { name } = this.props; let btnPupopConfig = this.props.tableProps.chooseProcessConfigRow; this.setState({ commonPopupVisible: true, commonPopupTbName: name, commonPopupShowConfig: btnPupopConfig, commonPopupRecord: record, }); } else { this.props.onBtnChoose('process', 'BtnChooseProcess', iIndex); } }); } }; /* 成品工序弹窗 */ handleChooseProductProcessRow = (recordIndex) => { /* recordIndex 为选中行下标 */ if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseProductProcessConfigRow)) { const btnConfig = this.props.tableProps.chooseProductProcessConfigRow; this.props.onBtnChoose('productProcess', 'BtnChooseProductProcess', btnConfig, recordIndex); } }; /* 成品材料弹窗 */ handleChooseProductMaterialsRow = (recordIndex) => { /* recordIndex 为选中行下标 */ if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseProductMaterialsConfigRow)) { const btnConfig = this.props.tableProps.chooseProductMaterialsConfigRow; this.props.onBtnChoose('productMaterials', 'BtnChooseProductMaterials', btnConfig, recordIndex); } }; /** 添加行 */ handleAddRow = (index, bModalAdd) => { this.stopRowClick = true; /* 多表树形删除 */ if (this.props && this.props.slaveInfo && this.props.slaveInfo.tableProps && this.props.slaveInfo.tableProps.bSlaveInfo) { this.handleAddInfoRow(index); return; } setTimeout(() => { if (this.props.onAddRow) { this.handleInstruct('BtnAdd', () => { this.props.onAddRow(this.props.name, null, index, this.props.bFinished, bModalAdd); }); } }, 0) }; handleAddInfoRow = (index) => { const tableInfoName = this.props.slaveInfo.name; setTimeout(() => { if (this.props.onAddRow) { this.handleInstruct('BtnAdd', () => { this.props.onAddRow(tableInfoName, null, index, false, false); }); } }, 0) }; handleTreeAdd = () => { setTimeout(() => { this.handleInstruct('BtnAdd', () => { if (this.props.onTreeAdd) { this.props.onTreeAdd(this.props.name, true, 'sameNode'); } }); }, 0) }; handleTreeAddChild = () => { setTimeout(() => { this.handleInstruct('BtnAddChildNode', () => { if (this.props.onTreeAddChild) { this.props.onTreeAddChild(this.props.name, true, 'childNode'); } }); }, 0) }; handleTreeCopyAll = () => { setTimeout(() => { this.handleInstruct('BtnCopyAll', () => { if (this.props.onTreeCopyAll) { this.props.onTreeCopyAll(this.props.name, false, 'isChild'); } }); }, 0) }; handleTreeDel = (index, record) => { if (this.props.name === 'control') { const sureDel = commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, 'SureDel') : '确认要删除吗?'; const BtnSure = commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, 'BtnSure') : '确定?'; const BtnCancel = commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, 'BtnCancel') : '确定?'; const _this = this; confirm({ title: sureDel, onOk() { _this.handleTreeDelOk(index, record); }, onCancel() { return false; }, okText: BtnSure, cancelText: BtnCancel }); } else { this.handleTreeDelOk(index, record); } }; handleTreeDelOk = () => { setTimeout(() => { this.handleInstruct('BtnDel', () => { if (this.props.onTreeDel) { this.props.onTreeDel(this.props.name, true, ''); } }); }, 0); }; /** 复制 */ handleCopyRow = (index) => { setTimeout(() => { this.handleInstruct('BtnCopy', () => { if (this.props.onCopyRow) { this.props.onCopyRow(this.props.name, undefined, undefined, index); } }); }, 0) }; /** 复制全部 */ handleCopyAllRow = () => { setTimeout(() => { this.handleInstruct('BtnCopyAll', () => { if (this.props.onCopyAllRow) { this.props.onCopyAllRow(this.props.name); } }); }, 0) }; /** 删除行 */ handleDelRow = (index, record) => { if (this.props.name !== 'slaveFilter') { const sureDel = commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, 'SureDel') : '确认要删除吗?'; const BtnSure = commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, 'BtnSure') : '确定?'; const BtnCancel = commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, 'BtnCancel') : '确定?'; const _this = this; confirm({ title: sureDel, onOk() { _this.handleDelOkRow(index, record); }, onCancel() { return false; }, okText: BtnSure, cancelText: BtnCancel }); } else { this.handleDelOkRow(index, record); } }; /** 删除行 */ handleDelOkRow = (index, record) => { const tableSelectedRowKeys = []; if (this.props?.formId === '12710101117043535363530') { tableSelectedRowKeys.push(record[this.rowKey]); } else { tableSelectedRowKeys.push(record.sId); } /* 多表树形删除 */ if (this.props && this.props.slaveInfo && this.props.slaveInfo.tableProps && this.props.slaveInfo.tableProps.bSlaveInfo) { this.handleDelInfoRow(index, record); return; } setTimeout(() => { this.handleInstruct('BtnDel', () => { if (this.props.onDelRow(this.props.name, false, tableSelectedRowKeys, undefined, index)) { this.handleSumAllColumn(this.props.config, this.state.dataSource); } }); }, 0); // if (this.props.formRoute === '/indexOee/processReport') { // localStorage.setItem(`${commonConfig.prefix}oeeEmployeeData`, JSON.stringify(this.props.data)); // this.props.onSaveState({ // employeeData: JSON.parse(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData`)), // }); // } }; handleDelInfoRow = (index, record) => { const tableSelectedRowKeys = []; tableSelectedRowKeys.push(record.sId); const tableInfoName = this.props.slaveInfo.name; setTimeout(() => { this.handleInstruct('BtnDel', () => { this.props.onDelRow(tableInfoName, false, tableSelectedRowKeys) }); }, 0); }; /** 复制 */ handleCopyMoreRow = (index) => { this.setState({ bOperateMoreVisible: true }); }; /** 提取数据 */ handleReplaceRow = (index, record) => { if (this.props.onReplaceRow) { this.props.onReplaceRow(this.props.name, record); } }; /** 下载行 */ handleDownloadRow = (index, record) => { const tableSelectedRowKeys = []; tableSelectedRowKeys.push(record.sId); if (this.props.onDownloadRow) { this.props.onDownloadRow(this.props.name, false, tableSelectedRowKeys); } }; /** 通用弹窗新增行 */ handlePopupRow = (index, record, btnName) => { const { name, config } = this.props; let btnPupopConfig = {}; if (commonUtils.isNotEmptyArr(config) && commonUtils.isNotEmptyArr(config.gdsconfigformslave)) { let controlConfig = config.gdsconfigformslave.filter(item => commonUtils.isNotEmptyObject(item.sControlName) && (item.sControlName.includes('BtnPopup') || item.sControlName.includes('BtnHeadPopup'))); if (btnName && typeof btnName === 'string') { controlConfig = config.gdsconfigformslave.filter(item => commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName === btnName); } if (commonUtils.isNotEmptyArr(controlConfig)) { if (controlConfig[0].bVisible && controlConfig[0].sDropDownType === 'popup') { btnPupopConfig = controlConfig[0]; const conditionValue = this.props.getSqlCondition(btnPupopConfig); if (commonUtils.isNotEmptyObject(conditionValue)) { if (commonUtils.isNotEmptyObject(conditionValue.warning)) { message.warn(conditionValue.warning); return; } } this.setState({ commonPopupVisible: true, commonPopupTbName: name, commonPopupShowConfig: btnPupopConfig, commonPopupRecord: record, }); } } } }; /** 查看工艺参数 */ handleParamRow = (index, record) => { const tableSelectedRowKeys = []; tableSelectedRowKeys.push(record.sId); this.props.onShowParamRow(this.props.name, record, tableSelectedRowKeys); }; /** 拖动排序 */ handleSaveOrder = (sortItems, isSlaveInfo) => { const { formSrcRoute } = isSlaveInfo ? this.props.slaveInfo : this.props; const { token } = isSlaveInfo ? this.props.slaveInfo.app : this.props.app; const sActiveId = isSlaveInfo ? this.props.slaveInfo.app.currentPane.formId : this.props.app.currentPane.formId; const url = `${commonConfig.server_host}configform/sHandleConfigform?sModelsId=${sActiveId}&sName=${formSrcRoute}`; const headerArr = isSlaveInfo ? this.props.slaveInfo.headerColumn.map(item => item.dataIndex) : this.props.headerColumn.map(item => item.dataIndex); const handleData = isSlaveInfo ? this.props.slaveInfo.config.gdsconfigformslave.filter(item => headerArr.indexOf(item.sName) !== -1) : this.props.config.gdsconfigformslave.filter(item => headerArr.indexOf(item.sName) !== -1); let sortIndexFirst = 0; let sortIndexLast = 0; handleData.forEach((item, index) => { if (item.sName === sortItems[0]) { sortIndexFirst = index; } if (item.sName === sortItems[1]) { sortIndexLast = index; } }); const tempOrder = handleData[sortIndexFirst].iOrder; handleData[sortIndexFirst].iOrder = handleData[sortIndexLast].iOrder; handleData[sortIndexLast].iOrder = tempOrder; const postData = isSlaveInfo ? { [this.props.slaveInfo.config.sId]: handleData, } : { [this.props.config.sId]: handleData, }; // console.log(postData, 'postData'); // console.log(sortItems, 'sortItems'); const value = { handleType: 'group', sJurisdictionClassifyId: '', bDefault: true, handleData: postData, }; const options = { method: 'POST', headers: { 'Content-Type': 'application/json', authorization: token, }, body: JSON.stringify(value), }; const { dispatch } = this.props; fetch(url, options).then(response => response.json()).then((json) => { if (json.code === 1) { this.forceUpdate(); } else if (json.code === -2) { dispatch({ type: 'app/throwError', payload: json }); } }); }; /** 查找控件名是否存在 */ findIsExistByControlName = (props, controlName) => { // 解决操作栏按钮没显示但是加上了宽度问题 let propsIcon = true; switch (controlName) { // case 'BtnUpload': // propsIcon = ''; // break; // case 'BtnLook': // propsIcon = ''; // break; // case 'BtnAdd': // propsIcon = props.tableProps.setAdd; // break; case 'BtnChooseMaterials': propsIcon = props.tableProps.setMaterial; break; case 'BtnChooseProcess': propsIcon = props.tableProps.setProcess; break; // case 'BtnCopy': // propsIcon = props.tableProps.setCopy; // break; // case 'BtnCopyAll': // propsIcon = props.tableProps.setCopyAll; // break; // case 'BtnDel': // propsIcon = props.tableProps.setDelete; // break; default: break; } /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if (commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName)) { const controlConfig = props.config.gdsconfigformslave.filter(item => item.sControlName === controlName); ret = commonUtils.isEmptyArr(controlConfig) ? (propsIcon ? true : false) : commonUtils.converStrToBoolean(controlConfig[0].bVisible); } /* 返回值 */ return ret; }; BtnUploadDivPropsAttr = React.createRef(); /** 查找控件名是否存在 */ findIsUpdByControlName = (props, controlName) => { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if (commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName)) { const controlConfig = props.config.gdsconfigformslave.filter(item => item.sControlName === controlName); ret = commonUtils.isNotEmptyArr(controlConfig) && commonUtils.converStrToBoolean(controlConfig[0].iTag === 3); if (ret && controlName === 'BtnUpload' && Array.isArray(controlConfig)) { this.BtnUploadDivPropsAttr.current = controlConfig[0]; } } /* 返回值 */ return ret; }; /** 查找控件名是否显示 */ findVisibleControlName = (props, controlName) => { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if (commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName)) { const controlConfig = props.config.gdsconfigformslave.filter(item => item.sControlName === controlName); ret = commonUtils.isNotEmptyArr(controlConfig) && commonUtils.converStrToBoolean(controlConfig[0].bVisible); } /* 返回值 */ return ret; }; /** 查找控件名是否存在 */ findIsExistByControlPopup = (props, controlName) => { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if (commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName)) { const controlConfig = props.config.gdsconfigformslave.filter(item => commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.includes(controlName) && !item.sControlName.includes('.')); if (commonUtils.isNotEmptyArr(controlConfig)) { if (controlConfig[0].bVisible && controlConfig[0].sDropDownType === 'popup') { ret = true; } } } /* 返回值 */ return ret; }; handleGetRjRes = (res, index, sName) => { const { masterData = {}, formId, enabled } = this.props; if (enabled && formId === "12710101117225611571970" && masterData.sTeamName?.includes('质检') && sName === "sInspectionCode") { return ( <> {res}