diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index d314b6e..ddb3309 100644 --- a/src/components/Common/CommonTable/index.js +++ b/src/components/Common/CommonTable/index.js @@ -5,7 +5,7 @@ /* eslint-disable react/no-array-index-key */ /* eslint-disable react/jsx-closing-tag-location */ /* eslint-disable */ -import React, { useEffect, useRef, useState } from "react"; +import React, { useEffect, useRef, useState } from 'react'; import { CheckCircleFilled, ClockCircleFilled, @@ -26,53 +26,57 @@ import { ClearOutlined, CaretUpOutlined, CaretDownOutlined, - PlaySquareOutlined, -} from "@ant-design/icons"; -import { Icon as LegacyIcon } from "@ant-design/compatible"; + 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 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 cloneDeep from "lodash/cloneDeep"; +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 ResizeableTitle = (props) => { const { onResize, width, ...restProps } = props; if (!width) { return ; @@ -84,7 +88,7 @@ const ResizeableTitle = props => { handle={ { + onClick={(e) => { e.stopPropagation(); }} key={lodash.uniqueId()} @@ -100,18 +104,20 @@ const ResizeableTitle = props => { let dragingIndex = -1; // 用于设置拖拽Row时样式 let moverow = null; // 定义move事件,解决warn -const BodyRow = props => { - const { isOver, connectDragSource, connectDropTarget, move, ...restProps } = props; +const BodyRow = (props) => { + const { + isOver, connectDragSource, connectDropTarget, move, ...restProps + } = props; moverow = move; const ref = useRef(null); - const style = { ...restProps.style, cursor: "move" }; + const style = { ...restProps.style, cursor: 'move' }; let { className } = restProps; if (isOver) { if (restProps.index > dragingIndex) { - className += " drop-over-downward"; + className += ' drop-over-downward'; } if (restProps.index < dragingIndex) { - className += " drop-over-upward"; + className += ' drop-over-upward'; } } connectDragSource(connectDropTarget(ref)); @@ -120,12 +126,12 @@ const BodyRow = props => { // DragSource 拖拽事件的方法对象 const rowSource = { beginDrag(props) { - const dragingKey = props["data-row-key"]; + const dragingKey = props["data-row-key"] dragingIndex = props.index; return { - "data-row-key": dragingKey, + 'data-row-key':dragingKey, index: props.index, - }; + } // dragingIndex = props.index; // return { // index: props.index, @@ -142,19 +148,19 @@ const rowTarget = { if (dragKey === hoverKey) { return; } - props.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); + props.moveRow(dragIndex, hoverIndex,dragKey,hoverKey); monitor.getItem().index = hoverIndex; monitor.getItem()["data-row-key"] = hoverKey; }, }; -const DragableBodyRow = DropTarget("row", rowTarget, (connect, monitor) => ({ +const DragableBodyRow = DropTarget('row', rowTarget, (connect, monitor) => ({ connectDropTarget: connect.dropTarget(), isOver: monitor.isOver(), }))( - DragSource("row", rowSource, connect => ({ + DragSource('row', rowSource, connect => ({ connectDragSource: connect.dragSource(), - }))(BodyRow) + }))(BodyRow), ); /* ================================================================== */ class CommonTableRc extends React.Component { @@ -162,57 +168,54 @@ class CommonTableRc extends React.Component { constructor(props) { super(props); this.state = { - navigation: "navigation", - previewVisible: false /* 图片预览弹窗 */, - previewImage: "" /* 预览图片地址 */, - headerColumn: [] /* 表头信息(数据类型:数组对象) */, - slaveInfoHeaderColumn: [] /* 表头信息(数据类型:数组对象) */, - tableColumn: [] /* table的表头信息(数据类型:数组对象) */, + navigation: 'navigation', + previewVisible: false, /* 图片预览弹窗 */ + previewImage: '', /* 预览图片地址 */ + headerColumn: [], /* 表头信息(数据类型:数组对象) */ + slaveInfoHeaderColumn: [], /* 表头信息(数据类型:数组对象) */ + tableColumn: [], /* table的表头信息(数据类型:数组对象) */ tableInfoColumn: [], slaveInfoTableColumn: [], - selectedRowKeys: [] /* 已选择的数据行(数据格式:数组) */, + selectedRowKeys: [], /* 已选择的数据行(数据格式:数组) */ slaveInfoSelectedRowKeys: [], - dataSource: [] /* 数据(数据格式:数组对象) */, - totalData: [] /* 总计数据 */, - totalData1: [] /* 总计数据1 */, - enabled: false /* 是否为编辑 */, - filteredValue: [] /* 过滤数据值 */, - expKeys: [] /* 展开数据行(数据格式:数组) */, + dataSource: [], /* 数据(数据格式:数组对象) */ + totalData: [], /* 总计数据 */ + totalData1: [], /* 总计数据1 */ + enabled: false, /* 是否为编辑 */ + filteredValue: [], /* 过滤数据值 */ + expKeys:[], /* 展开数据行(数据格式:数组) */ showimgs: false, // 必须字段控制弹框显示隐藏 firstIndex: 0, // 点击时默认下标 - commonPopupVisible: false, - commonFieldPopupVisible: false, + commonPopupVisible:false, + commonFieldPopupVisible:false, openNewTabFlag: false, // 是否因在弹窗中打开新页签离开本页; randomId: commonUtils.createSid(), realizeHeight: 0, - tableClassName: "table_" + commonUtils.createSid(), + tableClassName: 'table_' + commonUtils.createSid(), commonFileDownloadVisible: false, // 多文件下载弹窗 commonFileDownloadList: [], // 多文件列表 pdfFileVisible: false, // pdf文件弹窗 - bOperateMoreVisible: false /* 复制更多弹窗 */, - pdfFileUrl: "", - currentHoverSid: "", + bOperateMoreVisible : false, /* 复制更多弹窗 */ + pdfFileUrl: '', + currentHoverSid: '', simpleModalVisible: false, - simpleModalWord: "", + simpleModalWord: '', }; - this.rowKey = - commonUtils.isNotEmptyObject(props.tableProps) && !commonUtils.isEmpty(props.tableProps.rowKey) - ? props.tableProps.rowKey - : "sId"; /* 表格主键 */ + 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.scrollY = this.props.tableProps ? this.props.tableProps.AutoTableHeight ? this.props.tableProps.AutoTableHeight : 0 : 0; this.scrollInfoX = 0; /* 表格宽度统计值(数据格式:整形) */ - this.formId = ""; /* 窗体Id(数据格式:字符串) */ - this.sId = ""; /* 表格Id(数据格式:字符串) */ + 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.isModalRemarkShow = false;/* 是否显示材料备注控件(数据格式:布尔) */ this.isChooseProcessShow = false; /* 是否显示选择工序控件(数据格式:布尔) */ this.isCopyShow = false; /* 是否显示复制控件(数据格式:布尔) */ this.isCopyAllShow = false; /* 是否显示复制全部控件(数据格式:布尔) */ @@ -246,12 +249,12 @@ class CommonTableRc extends React.Component { this.slaveInfoHeaderMap = {}; this.mergeCellList = []; this.tableFilterData = []; - this.pathname = ""; + this.pathname = ''; this.hasSpanBgColor = false; // 是否有span背景色 this.curPagination = {}; // 当前分页数据 this.selectedRowKeysOld = []; // 记录选中数据 this.tableId = this.props.tableId; - this.isAllowConExpendKeys = ["19211681019715708440774010"].includes(props.formId); + this.isAllowConExpendKeys = ['19211681019715708440774010'].includes(props.formId); } /** 渲染前只执行一次 */ @@ -278,7 +281,7 @@ class CommonTableRc extends React.Component { this.props.onRenderFinish(); } - window.addEventListener("resize", () => { + window.addEventListener('resize', () => { this.computedTableHeight(); this.computedTdWidth(true); this.forceUpdate(); @@ -295,22 +298,22 @@ class CommonTableRc extends React.Component { } 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.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"; + 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"); + let divs = document.getElementsByClassName('noInputInsert'); if (divs.length) { Array.prototype.forEach.call(divs, item => { - item.parentNode.parentNode.parentNode.parentNode.classList.add("insertTd"); + item.parentNode.parentNode.parentNode.parentNode.classList.add('insertTd'); }); } @@ -318,33 +321,33 @@ class CommonTableRc extends React.Component { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (this.showExpAll && oTable) { - const getTh = dom => { + const getTh = (dom) => { if (!dom) { return false; } - if (dom.nodeName === "TH") { + 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 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"); + 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"); + const oFirstThDiv = oHeader.querySelector('.th-div'); oFirstThDiv && oFirstThDiv.prepend(oExpAllIcon); } } } } - if (this.simpleModalRef.current) this.simpleModalRef.current.innerHTML = this.state.simpleModalWord || ""; + if (this.simpleModalRef.current) this.simpleModalRef.current.innerHTML = this.state.simpleModalWord || ''; } /** props改变的时候触发s */ @@ -364,7 +367,7 @@ class CommonTableRc extends React.Component { } if (this.state.openNewTabFlag && this.pathname === location.pathname) { const dom = document.getElementsByClassName(`${this.state.randomId}-CommonListSelectTree`)[0]; - dom.parentElement.parentElement.style.display = "block"; + dom.parentElement.parentElement.style.display = 'block'; this.setState({ openNewTabFlag: false, }); @@ -374,26 +377,11 @@ class CommonTableRc extends React.Component { /** 返回true执行渲染,返回false不渲染 */ shouldComponentUpdate(nextProps, nextState) { const { - headerColumn, - tableColumn, - dataSource, - totalData, - totalData1, - selectedRowKeys, - enabled, - filteredValue, - previewVisible, - previewImage, - slaveInfoSelectedRowKeys, - slaveInfo, - expKeys, - commonPopupVisible, - commonFieldPopupVisible, - realizeHeight, + headerColumn, tableColumn, dataSource, totalData, totalData1, selectedRowKeys, enabled, filteredValue, + previewVisible, previewImage, slaveInfoSelectedRowKeys, slaveInfo, expKeys, commonPopupVisible, commonFieldPopupVisible, realizeHeight, bOperateMoreVisible, } = this.state; - return ( - enabled !== nextState.enabled || + 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) || @@ -416,13 +404,12 @@ class CommonTableRc extends React.Component { JSON.stringify(nextProps.slaveInfo) !== slaveInfo || JSON.stringify(nextProps.realizeHeight) !== realizeHeight || this.props.tableProps.newButton !== nextProps.tableProps.newButton || - this.state.simpleModalVisible !== nextState.simpleModalVisible - ); + this.state.simpleModalVisible !== nextState.simpleModalVisible; } componentWillUnmount() { this.mounted = false; - window.removeEventListener("resize", () => { + window.removeEventListener('resize', () => { this.computedTableHeight(); this.forceUpdate(); }); @@ -435,23 +422,23 @@ class CommonTableRc extends React.Component { simpleModalRef = React.createRef(); - handleLastTdMouseOver = event => { + 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"); + 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"; + 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 => { + 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; @@ -459,20 +446,20 @@ class CommonTableRc extends React.Component { diffx = Math.max(diffx, clientWidth - scrollWidth); } Object.assign(tempDom.style, { - left: left + "px", + left: left + 'px', }); - }; + } const resizableMouseup = () => { this.lastTdMouseOver = false; document.body.removeChild(mask); document.body.removeChild(tempDom); - document.removeEventListener("mouseup", resizableMouseup); - document.removeEventListener("mousemove", resizableMousemove); + 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; + const lastIndex = column.findIndex(item => item.dataIndex === 'tableLastEmpty') - 1; if (lastIndex > -1 && diffx !== 0) { const headerColumnNew = [...headerColumn]; const columnNew = [...column]; @@ -512,34 +499,34 @@ class CommonTableRc extends React.Component { sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}`, JSON.stringify(columnNew)); this.props.onSaveState({ headerColumn: headerColumnNew, - tableColumn: columnNew, + tableColumn: columnNew }); } - }; + } oResizable.onmousedown = () => { - const { y, height } = event.target.getBoundingClientRect(); + 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", + width: '2px', + height: height + 'px', + background: '#1990ff', + top: y + 'px', + left: maxLeft + 'px', + position: 'absolute', zIndex: 9999, - cursor: "col-resize", + 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); + document.removeEventListener('mouseup', resizableMouseup); + document.addEventListener('mouseup', resizableMouseup); + document.removeEventListener('mousemove', resizableMousemove); + document.addEventListener('mousemove', resizableMousemove); }; } } catch (error) {} - }; + } /** 列拖动s */ onHeaderCell = (isSlaveInfo, index, column) => { @@ -551,7 +538,7 @@ class CommonTableRc extends React.Component { } // 最后一列禁止拖动 let bNotResize = false; - const lastIndex = columns.findIndex(item => item.dataIndex === "tableLastEmpty") - 1; + 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) { @@ -565,7 +552,7 @@ class CommonTableRc extends React.Component { return { width: column.width, onResize: !bNotResize ? this.handleResize(index, column, isSlaveInfo) : null, - bnotresize: bNotResize ? "bNotResize" : null, + bnotresize: bNotResize ? 'bNotResize' : null, onClick: () => {}, onMouseDown: () => { if (this.lastTdMouseOver) { @@ -603,24 +590,24 @@ class CommonTableRc extends React.Component { if (columns[i].children[j].dataIndex === column.dataIndex) { columns[i].children[j] = { ...columns[i].children[j], - className: "hover-droping-cell", + className: 'hover-droping-cell', }; } else { columns[i].children[j] = { ...columns[i].children[j], - className: "", + className: '', }; } } } else if (columns[i].dataIndex === column.dataIndex) { columns[i] = { ...columns[i], - className: "hover-droping-cell", + className: 'hover-droping-cell', }; } else { columns[i] = { ...columns[i], - className: "", + className: '', }; } } @@ -630,7 +617,7 @@ class CommonTableRc extends React.Component { if (item.children) { item.children.forEach(child => { sortArr.push(child.dataIndex); - }); + }) } else { sortArr.push(item.dataIndex); } @@ -653,10 +640,9 @@ class CommonTableRc extends React.Component { 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) { - // 拖拽对象【单表头】、移动到的目标【单表头】 + if (!this.bInitColumnMuti && !bTargetMuti) { // 拖拽对象【单表头】、移动到的目标【单表头】 for (const i in columns) { - columns[i].className = ""; + columns[i].className = ''; if (columns[i].dataIndex === this.initColumn.dataIndex) { columns.splice(i, 1); spliceIndex = columns.findIndex(item => item.dataIndex === column.dataIndex); @@ -665,8 +651,7 @@ class CommonTableRc extends React.Component { sortItems.push(column.dataIndex); } } - } else if (!this.bInitColumnMuti && bTargetMuti) { - // 拖拽对象【单表头】、移动到的目标【双表头】 + } else if (!this.bInitColumnMuti && bTargetMuti) { // 拖拽对象【单表头】、移动到的目标【双表头】 let iIndexArr = []; // 获取拖拽对象index const initColumnIndex = columns.findIndex(item => item.dataIndex === this.initColumn.dataIndex); @@ -676,7 +661,7 @@ class CommonTableRc extends React.Component { if (commonUtils.isNotEmptyArr(children)) { const iIndex = children.findIndex(item => item.dataIndex === column.dataIndex); if (iIndex !== -1) { - columns[i].children[iIndex].className = ""; + columns[i].children[iIndex].className = ''; iIndexArr = [i, iIndex]; break; } @@ -690,12 +675,10 @@ class CommonTableRc extends React.Component { if (spliceIndex >= initColumnIndex) { spliceIndex -= 1; } - if (iIndexArr[1] === 0) { - //如果目标对象是第一个 + if (iIndexArr[1] === 0) { //如果目标对象是第一个 // 将拖拽对象插入到目标对象前面 columns.splice(spliceIndex, 0, this.initColumn); - } else if (iIndexArr[1] > 0) { - // 如果目标对象不是第一个 + } else if (iIndexArr[1] > 0) { // 如果目标对象不是第一个 // 取出目标对象数组 const targetColumn = columns.splice(spliceIndex, 1)[0]; const column1 = { ...targetColumn, children: targetColumn.children.filter((item, index) => index < iIndexArr[1]) }; @@ -703,8 +686,7 @@ class CommonTableRc extends React.Component { columns.splice(spliceIndex, 0, column1, this.initColumn, column2); } } - } else if (this.bInitColumnMuti && !bTargetMuti) { - // 拖拽对象【双表头】、移动到的目标【单表头】 + } else if (this.bInitColumnMuti && !bTargetMuti) { // 拖拽对象【双表头】、移动到的目标【单表头】 // 获取拖拽对象index let initColumnIndexArr = []; for (const i in columns) { @@ -718,23 +700,20 @@ class CommonTableRc extends React.Component { } if (commonUtils.isNotEmptyArr(initColumnIndexArr)) { spliceIndex = columns.findIndex(item => item.dataIndex === column.dataIndex); - columns[spliceIndex].className = ""; + 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]]], + children: [columns[initColumnIndexArr[0]].children[initColumnIndexArr[1]]] }; - columns[initColumnIndexArr[0]].children = columns[initColumnIndexArr[0]].children.filter( - item => item.dataIndex !== newColumn.children[0].dataIndex - ); + columns[initColumnIndexArr[0]].children = columns[initColumnIndexArr[0]].children.filter(item => item.dataIndex !== newColumn.children[0].dataIndex); columns.splice(spliceIndex, 0, newColumn); } } - } else { - // 拖拽对象【双表头】、移动到的目标【双表头】 + } else { // 拖拽对象【双表头】、移动到的目标【双表头】 // 获取拖拽对象index let initColumnIndexArr = []; for (const i in columns) { @@ -754,7 +733,7 @@ class CommonTableRc extends React.Component { if (commonUtils.isNotEmptyArr(children)) { const iIndex = children.findIndex(item => item.dataIndex === column.dataIndex); if (iIndex !== -1) { - columns[i].children[iIndex].className = ""; + columns[i].children[iIndex].className = ''; iIndexArr = [i, iIndex]; break; } @@ -762,33 +741,27 @@ class CommonTableRc extends React.Component { } if (commonUtils.isNotEmptyArr(initColumnIndexArr) && commonUtils.isNotEmptyArr(iIndexArr)) { - if (initColumnIndexArr[0] === iIndexArr[0]) { - // 同一个一级表头 + 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 { - // 不同的一级表头 + } else { // 不同的一级表头 const newColumn = { ...columns[initColumnIndexArr[0]], - children: [columns[initColumnIndexArr[0]].children[initColumnIndexArr[1]]], + children: [columns[initColumnIndexArr[0]].children[initColumnIndexArr[1]]] }; - if (iIndexArr[1] === 0) { - // 最前面 + if (iIndexArr[1] === 0) { // 最前面 columns[initColumnIndexArr[0]].children.splice(initColumnIndexArr[1], 1); spliceIndex = iIndexArr[0]; - if (columns[initColumnIndexArr[0]].children.length === 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 { - // 插到其它二级表头中间 + } else { // 插到其它二级表头中间 columns[initColumnIndexArr[0]].children.splice(initColumnIndexArr[1], 1); spliceIndex = iIndexArr[0]; - if (columns[initColumnIndexArr[0]].children.length === 0) { - // 剩下的二层表头为空 + if (columns[initColumnIndexArr[0]].children.length === 0) { // 剩下的二层表头为空 columns.splice(initColumnIndexArr[0], 1); spliceIndex = initColumnIndexArr[0] < spliceIndex ? spliceIndex - 1 : spliceIndex; } @@ -799,6 +772,7 @@ class CommonTableRc extends React.Component { } } } + } // 合并一级表头相同的相邻的column columns = columns.reduce((prev, cur) => { @@ -823,7 +797,7 @@ class CommonTableRc extends React.Component { if (item.children) { item.children.forEach(child => { sortArr.push(child.dataIndex); - }); + }) } else { sortArr.push(item.dataIndex); } @@ -848,7 +822,7 @@ class CommonTableRc extends React.Component { this.droping = false; } }, - onContextMenu: event => { + onContextMenu: (event) => { window.event.returnValue = false; }, }; @@ -888,16 +862,17 @@ class CommonTableRc extends React.Component { // this.handleSelectRowChange(this.props.name, [record[this.rowKey]]); }, 150); } - }; + } - onRowMouseLeave = () => { + onRowMouseLeave= () => { if (this.timerSelectRowChange) { this.setState({ - currentHoverSid: "", + currentHoverSid: '', }); clearTimeout(this.timerSelectRowChange); } - }; + } + rowClickRef = React.createRef(); @@ -909,32 +884,28 @@ class CommonTableRc extends React.Component { this.stopRowClick = false; return; } - const { bMutiSelect, tableProps, bMutiSelect1, bRowClick, bContinueClick } = this.props; + 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 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]; + 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) { + 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) { + 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 (bMutiSelect && rowSelection !== null && !bMutiSelect1) { /* 有多选、复选框情况下 */ if (commonUtils.isEmptyArr(selectedRowKeys) || bContinueClick) { const keys = []; keys.push(record[rowKey]); @@ -943,7 +914,7 @@ class CommonTableRc extends React.Component { const indexKey = selectedRowKeys.indexOf(record[rowKey]); if (indexKey === -1) { selectedRowKeys.push(record[rowKey]); - } else if (indexKey !== -1 && type !== "drag") { + } else if (indexKey !== -1 && type !== 'drag') { if (!bRowClick) { selectedRowKeys.splice(indexKey, 1); /* 可输入行,行内点击时 不去除selectedRowKeys */ } @@ -961,28 +932,28 @@ class CommonTableRc extends React.Component { 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; + handleMutiSelectRowKeys = (selectedRowKeys) => { + const { + bMutiSelect, tableProps, bMutiSelect1, + } = this.props; const { rowSelection } = tableProps; - if (bMutiSelect && rowSelection !== null && !bMutiSelect1) { - /* 有多选、复选框情况下 */ + if (bMutiSelect && rowSelection !== null && !bMutiSelect1) { /* 有多选、复选框情况下 */ // 判断是选中还是取消 - const type = selectedRowKeys.length > this.selectedRowKeysOld.length ? "add" : "del"; + const type = selectedRowKeys.length > this.selectedRowKeysOld.length ? 'add' : 'del'; // 找出变化的数据 - const diffArr = this.selectedRowKeysOld - .concat(selectedRowKeys) - .filter(v => !this.selectedRowKeysOld.includes(v) || !selectedRowKeys.includes(v)); + const diffArr = this.selectedRowKeysOld.concat(selectedRowKeys) + .filter(v => !this.selectedRowKeysOld.includes((v)) || !selectedRowKeys.includes((v))); if (diffArr.length === 1) { // 将数据扁平化 let { data } = this.props; @@ -994,7 +965,7 @@ class CommonTableRc extends React.Component { } return result; }, []); - if (type === "add") { + if (type === 'add') { // 合并选中行 selectedRowKeys = Array.from(new Set([...selectedRowKeys, ...selectedRowKeysExtra])); } else { @@ -1014,7 +985,7 @@ class CommonTableRc extends React.Component { /** 行选择 */ onDoubleClick = (name, record) => { - const picArrConfig = this.props.config.gdsconfigformslave.find(item => item.sName === "picArr"); + const picArrConfig = this.props.config.gdsconfigformslave.find(item => item.sName === 'picArr'); if (picArrConfig?.sActiveId === "172129113112117442504826460") { // 自动拼版 if (record.bMakeUpEnd) { @@ -1032,59 +1003,53 @@ class CommonTableRc extends React.Component { }; onKeyDownDiv = (e, sName) => { - if (e.key === "F10") { + if (e.key === 'F10') { message.info(sName); } else if (e.ctrlKey && e.keyCode === 67) { - console.log("复制成功!"); + 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 => { + 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")) { + } else if (el.classList.contains('ant-modal-root')) { return true; } else { return bInModal(el.parentNode); } - }; - if (bInModal(e.target)) { - // 如果是在modal里的表格,不允许跳转 + } + if (bInModal(e.target)) { // 如果是在modal里的表格,不允许跳转 return; } const myTableConfig = JSON.parse(JSON.stringify(config)); - myTableConfig.sActiveId = "16411004790004762980820285096000"; + myTableConfig.sActiveId = '16411004790004762980820285096000'; myTableConfig.sName = sName; const myTableConfigArr = []; myTableConfigArr.push(myTableConfig); - this.props.onViewClick(name, "myTableConfig", data[0], 0, myTableConfigArr, configName); + this.props.onViewClick(name, 'myTableConfig', data[0], 0, myTableConfigArr, configName); } - } else if (e.key !== "F12") { + } 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"; + dom.parentElement.parentElement.style.display = 'none'; this.pathname = location.pathname; this.setState({ openNewTabFlag: true, @@ -1095,16 +1060,14 @@ class CommonTableRc extends React.Component { if (this.showExpAll) { this.showExpAll = false; this.setState({ - expKeys: [], + expKeys: [] }); } if (commonUtils.isNotEmptyObject(filters)) { const filterValueArr = Object.values(filters); - if (filterValueArr.join("") !== "" && commonUtils.isNotEmptyArr(extra.currentDataSource)) { - // 过滤了数据 + if (filterValueArr.join('') !== '' && commonUtils.isNotEmptyArr(extra.currentDataSource)) { // 过滤了数据 this.tableFilterData = extra.currentDataSource; - } else { - // 没有过滤数据 + } else { // 没有过滤数据 this.tableFilterData = []; } // 生成cell list @@ -1122,53 +1085,44 @@ class CommonTableRc extends React.Component { this.props.tableProps.onChange(pagination, filters, sorter, extra); } this.props.onSaveState({ sortedInfo: sorter }); - }; + } /* 动态参数全选、取消全选 */ - onParamChange = e => { + 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") { + let newslistStyle = ''; + if (commonUtils.isNotEmptyObject(this.props.formId) && this.props.formId === '15669750700007338351055957774000') { if (record.bIsView === false) { - newslistStyle = "newsNoRead"; + newslistStyle = 'newsNoRead'; } } - const bSlaveInfo = tabType && tabType.includes("slave") && tabType.includes("Info"); + 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" - : ""; + 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)) { - // 如果有合并单元格 + 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" : ""; + 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(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}`; + allRowClassName = `SetRow_${record.costomRowColor}` } return allRowClassName; @@ -1177,17 +1131,16 @@ class CommonTableRc extends React.Component { /** 获取复选框对象的props */ getRowSelection = (name, type) => { const { bMutiSelect, bisMutiSelect } = this.props; - if (name === "control" || (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf("commonAuto") > -1)) { - // 控制表中可以通过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) /* 选择行发生改变时调用的函数 */, + 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 */, + style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, + }), /* 过滤合计的选择框 */ + type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } else { @@ -1196,14 +1149,14 @@ class CommonTableRc extends React.Component { } else { return { preserveSelectedRowKeys: true, - selectedRowKeys: type === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys /* 已选择的数据集 */, - onChange: value => { + 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 */, + style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, + }), /* 过滤合计的选择框 */ + type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } @@ -1220,450 +1173,313 @@ class CommonTableRc extends React.Component { } 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")); + 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} - - ); - }; + 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(","); + 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} -
- ); + 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})`} - ); + return { + this.setState({ + commonFileDownloadVisible: true, + commonFileDownloadList: fileList.map(item => {return { url: item, checked: false }}), + }) + }} + >{`附件(${fileList.length})`}; } - }; + } } if (commonUtils.isNotEmptyArr(sMakeUpPath)) { sMakeUpPath.forEach(item => { - item.render = (value = "", record) => { + item.render = (value = '', record) => { const { formId, name, enabled } = this.props; - const { token } = this.props.app; - let divProps = { + const { token } = this.props.app; + const divProps = { action: `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}`, - onChange: info => { + 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: "*/*", + accept: '*/*', showUploadList: false, multiple: false, }; - if (config.sTbName === "sisboxcomponent") { - divProps = { - // action: `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}`, - action: `${commonConfig.server_host}file/uploadPrice?sLogoName=logo${name}${formId}${new Date().getTime()}`, - 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 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)} - style={{ width: "30px", height: "20px" }} - /> - - ); + return
+ { + value && [''].map(() => { + const iconProps = { + className: styles.imgPDf, + onClick: () => { + this.setState({ + officePreviewVisible: true, + officeFileUrl: value, + }) } + }; + + 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)} style={{ width: '30px', height: '20px' }} />; + } - return imgBox; - })} - {enabled && ( - - - - )} -
- ); - }; - }); + return imgBox; + }) + } + { + enabled && + } +
; + } + }) } - this.props.onCostomColums?.([...tableColumn, ...subTableColumn]); + 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 => { + 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 sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; - 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"; - } - } - return ( -
- {commonUtils.isNotEmptyObject(t.sProcessName) ? t.sProcessName : ""} - {i + 1 === sPartItemLength ? "" : } -
- ); - }) + { + 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 sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; + 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'; + } } -
- ); - }} - > -
+ 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"; + let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; - switch ( - Number(sState) // 根据状态显示颜色 - ) { + switch (Number(sState)) { // 根据状态显示颜色 case 0: - colorValue = "#808080"; /* 0:灰色 */ + colorValue = '#808080'; /* 0:灰色 */ break; case 1: - colorValue = "#808080"; /* 1:灰色 */ + colorValue = '#808080'; /* 1:灰色 */ break; case 2: - colorValue = "#ff4d4f"; /* 2:红色 */ + colorValue = '#ff4d4f'; /* 2:红色 */ break; case 3: - colorValue = "#d4b106"; /* 3:黄色 */ + colorValue = '#d4b106'; /* 3:黄色 */ break; case 4: - colorValue = "#000000"; /* 黑色 */ + colorValue = '#000000'; /* 黑色 */ break; case 5: - colorValue = "#49aa19"; /* 5:绿色 */ + colorValue = '#49aa19'; /* 5:绿色 */ break; default: - colorValue = "#000000"; + colorValue = '#000000'; } } return ( -
- {commonUtils.isNotEmptyObject(t.sProcessName) ? t.sProcessName : ""} - {i + 1 === sPartItemLength ? "" : } +
+ {commonUtils.isNotEmptyObject(t.sProcessName) ? t.sProcessName : ''} + { i + 1 === sPartItemLength ? '' : }
); }) }
+ ); } }; } else { - sPartNameStatus[0].render = itemStr => { + sPartNameStatus[0].render = (itemStr) => { if (itemStr) { - const sPartItem = itemStr.split("->"); + 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 = ""; + 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 = ; + ArrItemNumChange = '未排程'; + icon = ; break; case 1: - ArrItemNumChange = "未完成"; - icon = ; + ArrItemNumChange = '未完成'; + icon = ; break; case 2: - ArrItemNumChange = "生产中"; - icon = ; + ArrItemNumChange = '生产中'; + icon = ; break; case 3: - ArrItemNumChange = "暂停"; - icon = ; + ArrItemNumChange = '暂停'; + icon = ; break; case 4: - ArrItemNumChange = "取消"; - icon = ; + ArrItemNumChange = '取消'; + icon = ; break; case 5: - ArrItemNumChange = "完成"; - icon = ; + 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} -
- ) : ( - "" - )} +
工序名称:{ArrItemStr}
+
状态:{ArrItemNumChange}
+
机台名称:{ArrItemName}
+
班组:{ArrItemBanZhu}
+
排单时间:{ArrItemTime}
+
排程数:{ArrItemPCNum}
+
上报数:{ArrItemSBNum}
+ { + ArrItem7Num ?
包数:{ArrItem7Num}
:'' + } + { + ArrItem8Num ?
每包数量:{ArrItem8Num}
:'' + } + { + ArrItem9Num ?
零头数量:{ArrItem9Num}
:'' + }
); // 数字转换图标 return ( -
+
{icon} - - {ArrItemStr} - + {ArrItemStr} {/*{ i + 1 === sPartItemLength ? '' : }*/}
); }) } + +
); } @@ -1673,168 +1489,112 @@ class CommonTableRc extends React.Component { // 判断材料准备状态 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 - ) { + 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解析 */ + const sBackGroundColor = jsonStatus.bReadonly ? '#f1f2f8' : ''; + if (commonUtils.isNotEmptyArr(jsonStatus.children)) { /* 嵌套列头JSON解析 */ for (const obj of jsonStatus.children) { - obj.render = itemStr => { + 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); + 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"; + 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 ? "" : -} -
- ); - }) + { + 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"; + let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; - switch ( - Number(sState) // 根据状态显示颜色 - ) { + switch (Number(sState)) { // 根据状态显示颜色 case 0: - colorValue = "#000000"; /* 0:黑色 */ + colorValue = '#000000'; /* 0:黑色 */ break; case 1: - colorValue = "#ff4d4f"; /* 1:红色 */ + colorValue = '#ff4d4f'; /* 1:红色 */ break; case 2: - colorValue = "#49aa19"; /* 2:绿色 */ + colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: - colorValue = "#49aa19"; /* 3:绿色 */ + colorValue = '#49aa19'; /* 3:绿色 */ break; case 4: - colorValue = "#ff4d4f"; /* 4:红色 */ + colorValue = '#ff4d4f'; /* 4:红色 */ break; default: - colorValue = "#000000"; + colorValue = '#000000'; } } return ( -
- {commonUtils.isNotEmptyObject(t.sMaterialsName) ? ( - - {t.sMaterialsName} - - ) : ( - "" - )} - {i + 1 === sPartItemLength ? "" : -} +
+ {commonUtils.isNotEmptyObject(t.sMaterialsName) ? + + {t.sMaterialsName} + : ''} + { i + 1 === sPartItemLength ? '' : -}
); }) @@ -1846,157 +1606,105 @@ class CommonTableRc extends React.Component { return itemStr; } }; - } - } else { - /* 无嵌套列头JSON列解析 */ - sMaterialsStatus[index].render = 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); + 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"; + 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 ? "" : -} -
- ); - }) + { + 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"; + let colorValue = '#000000'; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; - switch ( - Number(sState) // 根据状态显示颜色 - ) { + switch (Number(sState)) { // 根据状态显示颜色 case 0: - colorValue = "#000000"; /* 0:黑色 */ + colorValue = '#000000'; /* 0:黑色 */ break; case 1: - colorValue = "#ff4d4f"; /* 1:红色 */ + colorValue = '#ff4d4f'; /* 1:红色 */ break; case 2: - colorValue = "#49aa19"; /* 2:绿色 */ + colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: - colorValue = "#49aa19"; /* 3:绿色 */ + colorValue = '#49aa19'; /* 3:绿色 */ break; case 4: - colorValue = "#ff4d4f"; /* 4:红色 */ + colorValue = '#ff4d4f'; /* 4:红色 */ break; default: - colorValue = "#000000"; + colorValue = '#000000'; } } return ( -
- {commonUtils.isNotEmptyObject(t.sMaterialsName) ? ( - - {t.sMaterialsName} - - ) : ( - "" - )} - {i + 1 === sPartItemLength ? "" : -} +
+ {commonUtils.isNotEmptyObject(t.sMaterialsName) ? + + {t.sMaterialsName} + : ''} + { i + 1 === sPartItemLength ? '' : -}
); }) @@ -2005,12 +1713,7 @@ class CommonTableRc extends React.Component { ); } else { - return ( -
- {" "} - {itemStr}{" "} -
- ); + return
{itemStr}
; } }; } @@ -2021,51 +1724,40 @@ class CommonTableRc extends React.Component { /* 动态列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")); + 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 => { + 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"; + let colorValue = '#000000'; const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; - switch ( - Number(sState) // 根据状态显示颜色 - ) { + switch (Number(sState)) { // 根据状态显示颜色 case 1: - colorValue = "#ff0000"; /* 1:红色 */ + colorValue = '#ff0000'; /* 1:红色 */ break; case 2: - colorValue = "#49aa19"; /* 2:绿色 */ + colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: - colorValue = "#ffff00"; /* 3:黄色 */ + colorValue = '#ffff00'; /* 3:黄色 */ break; case 0: - colorValue = ""; /* 3:不要颜色 */ + colorValue = ''; /* 3:不要颜色 */ break; default: - colorValue = ""; + colorValue = ''; } return (
{t.dSchedulHours}
@@ -2077,37 +1769,38 @@ class CommonTableRc extends React.Component { ); } }; - } - } else { - /* 无嵌套列头JSON列解析 */ - dynamicColumn[index].render = itemStr => { + }; + } 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"; + let colorValue = '#000000'; const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; - switch ( - Number(sState) // 根据状态显示颜色 - ) { + switch (Number(sState)) { // 根据状态显示颜色 case 1: - colorValue = "#ff0000"; /* 1:红色 */ + colorValue = '#ff0000'; /* 1:红色 */ break; case 2: - colorValue = "#49aa19"; /* 2:绿色 */ + colorValue = '#49aa19'; /* 2:绿色 */ break; case 3: - colorValue = "#ffff00"; /* 3:黄色 */ + colorValue = '#ffff00'; /* 3:黄色 */ break; default: - colorValue = "#666"; + colorValue = '#666'; } return ( -
+
{t.dSchedulHours}
); @@ -2125,18 +1818,18 @@ class CommonTableRc extends React.Component { // 判断时间状态 if (commonUtils.isNotEmptyArr(sTimeStatus) && commonUtils.isNotEmptyArr(dataSource)) { - sTimeStatus[0].render = itemStr => { + sTimeStatus[0].render = (itemStr) => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); - const linkStyle = "sTimeStatusStyle"; /* 弹窗 */ + 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 dWidth = t.dRate !== undefined && t.dRate !== 0 ? `${t.dRate * 500}px` : '100px'; const content = (

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

@@ -2148,13 +1841,7 @@ class CommonTableRc extends React.Component {
@@ -2174,39 +1861,34 @@ class CommonTableRc extends React.Component { // 判断拼板状态 if (commonUtils.isNotEmptyArr(sScheduleStatusJson) && commonUtils.isNotEmptyArr(dataSource)) { this.useVListNew = true; - sScheduleStatusJson[0].render = itemStr => { + 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; + const { sState, sColor = '#000000', sName = '' } = t; return ( -
- {sName} - {i + 1 === itemLength ? "" : } +
+ {sName}{ i + 1 === itemLength ? '' : }
); - }); + }) return (
- { - return
{content}
; - }} - > - {content} -
+ whiteSpace: 'nowrap', + width: 'auto', + maxWidth: '100%', + height: '29px', + overflow: 'hidden', + lineHeight: '29px', + textOverflow: 'ellipsis' + }}> + { + return
{content}
+ }}> + {content} +
); } @@ -2221,16 +1903,16 @@ class CommonTableRc extends React.Component { } let bPagination = true; /* 默认表格分页s */ if (commonUtils.isNotEmptyObject(this.props)) { - bPagination = commonUtils.isNotEmptyObject(this.props.tableProps) && commonUtils.isNotEmptyObject(this.props.tableProps.pagination); + 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]) { + if(this.props.config && this.props.config.gdsconfigformslave.filter(item => item.sControlName === 'bNoVlist')[0]) { noVlistController = true; } /* 特殊情况的表格 在虚拟列表情况 会无法滑动 */ let noVlistTable = false; - if (this.props.noVlistTable) { + if(this.props.noVlistTable) { noVlistTable = true; } // 判断是否有合并单元格, 有的话默认关闭虚拟滚动 @@ -2251,26 +1933,22 @@ class CommonTableRc extends React.Component { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (oTable) { - const oBody = oTable.querySelector(".ant-table-body"); + 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); - }, - }); + 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 }; + components = {...this.Vcomponents, ...components}; } else { // vid是多个列表在同个页面中,同时渲染会促发问题 // vid不可以为随机数,随机数会导致双击时,点击的两个VList id不同 @@ -2281,51 +1959,46 @@ class CommonTableRc extends React.Component { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (oTable) { - const oBody = oTable.querySelector(".ant-table-body"); + 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); - }, - }); + 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) { + if(tableColumn[index].fixedHelp) { tableColumn[index].fixed = false; tableColumn[index].fixedHelp = false; } if (index < this.props.config.iFreezeColumn) { - tableColumn[index].fixed = "left"; + 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; + 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)) { + if(commonUtils.isNotEmptyObject(array[fromIndex].sWorkOrderUsed)) { message.error(array[fromIndex].sWorkOrderUsed); return; } @@ -2338,7 +2011,7 @@ class CommonTableRc extends React.Component { arrayMoveMutable(array, fromIndex, toIndex); return array; } - const DragHandle = sortableHandle(() => ); + const DragHandle = sortableHandle(() => ); const SortableItem = sortableElement(props => ); const SortableContainer = sortableContainer(props => ); const onSortEnd = ({ oldIndex, newIndex }) => { @@ -2349,17 +2022,23 @@ class CommonTableRc extends React.Component { } }; 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 ; + 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) { + let bDrag = this.props.enabled && !this.props.bForbiddenDrag;/* 是否可以拖动 */ + if(bDrag) { if (!this.DraggableContainer) { this.DraggableContainer = DraggableContainer; } @@ -2367,20 +2046,22 @@ class CommonTableRc extends React.Component { this.DraggableBodyRow = DraggableBodyRow; } } - if (!handleSort) { - components = { ...components, body: { wrapper: this.DraggableContainer, row: this.DraggableBodyRow } }; + if(!handleSort) { + components = {...components, body: {wrapper: this.DraggableContainer, row: this.DraggableBodyRow}}; } else { - components = { ...components, body: { wrapper: this.DraggableContainer, row: this.DraggableBodyRow } }; + 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: () => , - }); + tableColumn.unshift( + { + title: handleSortTitle, + dataIndex: 'handleSort', + fixed: 'left', + width: 40, + className: 'drag-visible', + render: () => , + }, + ) } } @@ -2394,9 +2075,9 @@ class CommonTableRc extends React.Component { } } - let rowSelection = this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, "slave"); // 是否选择多选框的问题 + 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; + rowSelection = null } const { expKeys } = this.state; @@ -2404,54 +2085,36 @@ class CommonTableRc extends React.Component { return { components, rowKey: this.rowKey, - size: "middle", - bordered: true /* 显示边框 */, - className: !this.props.enabled ? styles.disabledProup : styles.proup /* 样式控制 */, - scroll: { x: "max-content" } /* 宽度 */, - dataSource /* 数据 */, - columns: tableColumn /* 表头 */, + 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"), + 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"); + 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(); - }, + onClick: () => { this.onRowClick(record, index, undefined, this.props.name, 'slave'); }, + onDoubleClick: () => { this.onDoubleClick(this.props.name, record); }, + onMouseEnter: () => { this.onRowMouseEnter(record); }, + onMouseLeave: () => { this.onRowMouseLeave(); }, }; } }, @@ -2461,32 +2124,31 @@ class CommonTableRc extends React.Component { const expKeysNew = [...expKeys, record[this.rowKey]]; this.currentExpKeys = expKeysNew; this.setState({ - expKeys: expKeysNew, + expKeys: expKeysNew }); } else { const expKeysNew = expKeys.filter(item => item !== record[this.rowKey]); this.currentExpKeys = expKeysNew; this.setState({ - expKeys: expKeysNew, + expKeys: expKeysNew }); } } - this.onExpand(expanded, record, "slave"); /* 点击展开图标时触发s */ + this.onExpand(expanded, record, 'slave'); /* 点击展开图标时触发s */ }, expandedRowKeys: expKeys.length || this.showExpAll || this.isAllowConExpendKeys ? expKeys : null, - id: commonUtils.isEmptyArr(dataSource) ? "unDataBox" : "dataBox" /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */, + 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, - }; - }, + pagination: bPagination ? { + ...this.props.tableProps.pagination, + onChange: (current, size) => { + this.curPagination = { + current, pageSize: size } - : false /* 表格是否分页 */, + } + } : false, /* 表格是否分页 */ onChange: this.onChange, }; }; @@ -2494,21 +2156,20 @@ class CommonTableRc extends React.Component { /** 获取子从表复选框对象的props */ getSlaveRowSelection = (name, type) => { const { bMutiSelect } = this.props.slaveInfo; /* 显示单选框还是复选框 */ - let { bisMutiSelect } = this.props.slaveInfo; /* 是否显示选择框 */ + let { bisMutiSelect } = this.props.slaveInfo; /* 是否显示选择框 */ if (this.props.slaveInfo.config) { - bisMutiSelect = this.props.slaveInfo.config.bisMutiSelect; + bisMutiSelect = this.props.slaveInfo.config.bisMutiSelect } - if (name === "control" || (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf("commonAuto") > -1)) { - // 控制表中可以通过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) /* 选择行发生改变时调用的函数 */, + 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 */, + style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, + }), /* 过滤合计的选择框 */ + type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } else { @@ -2517,12 +2178,12 @@ class CommonTableRc extends React.Component { } else { return { preserveSelectedRowKeys: true, - selectedRowKeys: type === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys /* 已选择的数据集 */, - onChange: this.handleSelectRowChange.bind(this, name) /* 选择行发生改变时调用的函数 */, + 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 */, + style: record.bSum && commonConfig.hasSum ? { display: 'none' } : { display: 'checkbox' }, + }), /* 过滤合计的选择框 */ + type: bMutiSelect ? this.props.rowSelectionType : 'radio', /* checkbox or radio */ columnWidth: 37, }; } @@ -2531,8 +2192,10 @@ class CommonTableRc extends React.Component { /** 获取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; + 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) { @@ -2542,46 +2205,45 @@ class CommonTableRc extends React.Component { components.header = { cell: ResizeableTitle }; } - let rowSelection = this.props.rowSelection !== undefined ? this.props.rowSelection : this.getSlaveRowSelection(slaveInfoName, "slaveInfo"); - if (slaveInfoConfig && !slaveInfoConfig.bisMutiSelect) { - /* 如果子表配置不显示选择框 则不显示选择框 */ + 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"), + 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"); + this.onRowClick(record, index, undefined, slaveInfoName, 'slaveInfo'); }, onDoubleClick: () => { - this.onDoubleClick(record, index, undefined, slaveInfoName, "slaveInfo"); + this.onDoubleClick(record, index, undefined, slaveInfoName, 'slaveInfo'); }, - moveRow: (dragIndex, hoverIndex, dragKey, hoverKey) => { - this.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); + moveRow: (dragIndex, hoverIndex,dragKey,hoverKey) => { + this.moveRow(dragIndex, hoverIndex,dragKey,hoverKey); }, - onDragClick: type => { - this.onRowClick(record, index, type, slaveInfoName, "slaveInfo"); + onDragClick: (type) => { + this.onRowClick(record, index, type, slaveInfoName, 'slaveInfo'); }, }; } else { return { index, onClick: () => { - this.onRowClick(record, index, undefined, slaveInfoName, "slaveInfo"); + this.onRowClick(record, index, undefined, slaveInfoName, 'slaveInfo'); }, onDoubleClick: () => { this.onDoubleClick(slaveInfoName, record); @@ -2590,13 +2252,13 @@ class CommonTableRc extends React.Component { } }, // footer: this.props.footer === undefined ? this.tableFooter : undefined, - id: commonUtils.isEmptyArr(dataSource) ? "unDataBox" : "dataBox" /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */, + id: commonUtils.isEmptyArr(dataSource) ? + 'unDataBox' : + 'dataBox', /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */ ...this.props.slaveInfo.tableProps, onChange: this.onChange, }; - } else { - return null; - } + } else { return null; } }; getTableFilterData = () => { @@ -2609,13 +2271,13 @@ class CommonTableRc extends React.Component { } else { filterData = dataSource.length; } - if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sZczlxShowName)) { - if (masterData.sZczlxShowName === "删除" || masterData.sZczlxShowName === "恢复") { + if(commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sZczlxShowName)) { + if(masterData.sZczlxShowName === '删除' || masterData.sZczlxShowName === '恢复'){ filterData += 1; } } return filterData; - }; + } /** 获取showConfig */ getShowConfig = (props, sName, isSlaveInfo) => { /* 返回值声明 */ @@ -2637,9 +2299,10 @@ class CommonTableRc extends React.Component { 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]; + showConfig = showConfigArr[0]; } } + } /* 返回值 */ return showConfig; @@ -2651,30 +2314,25 @@ class CommonTableRc extends React.Component { /* 通过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 - ); + 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 - ); + 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 - ); + 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; @@ -2683,66 +2341,65 @@ class CommonTableRc extends React.Component { rowColorData = React.createRef(); getColorStyle = (record, isRowShow) => { - let styleColorArrTotal = ""; + let styleColorArrTotal = ''; const showConfigArr = this.getColorConfig(); /* 拿到颜色配置json */ if (commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) { for (const showConfig of showConfigArr) { - let styleColorArr = ""; + let styleColorArr = ''; const colorConditon = commonUtils.isNotEmptyObject(showConfig) ? showConfig.sColorTerms : null; - if (commonUtils.isNotEmptyObject(colorConditon)) { - let colorConditionArr = ""; + if (commonUtils.isNotEmptyObject((colorConditon))) { + let colorConditionArr = ''; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { - colorConditionArr = ""; + colorConditionArr = ''; } - colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ""; /* 判断是否是数组 */ + colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ''; /* 判断是否是数组 */ for (const item of colorConditionArr) { - let styleColor = ""; - const { column, condition, conditionValue, color, isRow } = item; + 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("#", "-")}`; + 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 { + .color${color.replace('#', '-')} td { background-color:${color}!important; .ant-table-selection-column { background-color:${color}!important; } } `; - document.getElementsByTagName("head")[0].appendChild(style); + document.getElementsByTagName('head')[0].appendChild(style); } - if (isRow && isRowShow && !commonUtils.isEmpty(record[column]) && commonUtils.isNotEmptyObject(record[column].toString())) { - /* 配置行 */ + 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 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("#", "-")}` : ""; + styleColor = record[column] === sXValue ? `SetRow_${color} color${color.replace('#', '-')}` : ''; } } else { - styleColor = record[column] === conditionValue ? `SetRow_${color} color${color.replace("#", "-")}` : ""; + 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("#", "-")}` : ""; + } 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('#', '-')}` : ''; } } } @@ -2752,7 +2409,7 @@ class CommonTableRc extends React.Component { 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 }]; + 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); @@ -2763,93 +2420,94 @@ class CommonTableRc extends React.Component { } } return styleColorArrTotal; - }; + } /** 获取单元格颜色配置 */ getCellColorConfig = (text, record, sName) => { - let styleColorArrTotal = ""; /* 单元格文字颜色 */ - let styleColorArrTotalB = ""; /* 单元格背景颜色 */ - let styleColorArr = ""; - let styleColorArrB = ""; + 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 = ""; + if (commonUtils.isNotEmptyObject((colorConditon))) { + let colorConditionArr = ''; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { - colorConditionArr = ""; + colorConditionArr = ''; } - colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ""; + colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ''; for (const item of colorConditionArr) { - let styleColor = ""; + let styleColor = ''; // eslint-disable-next-line no-unused-vars - let styleBackground = ""; - const { column, condition, color, background, isRow } = item; - if (!isRow) { - /* 根据配置设置单元格颜色 */ + 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 : ""; + 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)) { + } 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; + 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 : ""; + 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 : ""; + } 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 : ''; } } } @@ -2858,10 +2516,10 @@ class CommonTableRc extends React.Component { } styleColorArr += styleColor; styleColorArrB += styleBackground; - if (styleColor) { + if(styleColor) { styleColorArr = styleColor; } - if (styleBackground) { + if(styleBackground) { styleColorArrB = styleBackground; } } @@ -2873,7 +2531,7 @@ class CommonTableRc extends React.Component { const iIndex = showConfigArr.findIndex(item => item.sName === sName); if (iIndex !== -1) { const { sColorTerms } = showConfigArr[iIndex]; - if (sColorTerms && sColorTerms.startsWith("#")) { + if (sColorTerms && sColorTerms.startsWith('#')) { styleColorArrTotal = sColorTerms; } } @@ -2883,8 +2541,8 @@ class CommonTableRc extends React.Component { }; /** - * 部分字段不可编辑 - */ + * 部分字段不可编辑 + */ getSelectRowEditState = (sName, record, enabled) => { const { config, name, masterData } = this.props; let result = enabled; @@ -2895,15 +2553,15 @@ class CommonTableRc extends React.Component { const btnConfig = data.find(item => item && item.name === sName && item.enabled !== undefined); if (btnConfig && enabled) { const { enabled: enabledContent } = btnConfig; - if (typeof enabledContent === "boolean") { + if (typeof enabledContent === 'boolean') { result = enabledContent; } else if (enabledContent) { const tempData = { props: { - enabled, + enabled }, master: masterData, - [name]: record, + [name]: record }; let strNew = enabledContent; @@ -2922,7 +2580,7 @@ class CommonTableRc extends React.Component { } return result; - }; + } // 获取表格行按钮状态 getTableBtnState = (btnName, record) => { @@ -2935,10 +2593,10 @@ class CommonTableRc extends React.Component { result = false; } /* 若红冲单据 则按钮锁定 不能操作 */ - if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sMinusSrcId) && masterData.sMinusType === "1") { + if(commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sMinusSrcId) && masterData.sMinusType === '1') { result = false; } - if (btnName === "BtnAdd" && bLimitOperate) { + if(btnName === 'BtnAdd' && bLimitOperate){ result = false; } @@ -2949,15 +2607,15 @@ class CommonTableRc extends React.Component { const btnConfig = data.find(item => item && item.name === btnName && item.enabled !== undefined); if (btnConfig) { const { enabled: enabledContent } = btnConfig; - if (typeof enabledContent === "boolean") { + if (typeof enabledContent === 'boolean') { result = enabledContent; } else if (enabledContent) { const tempData = { props: { - enabled, + enabled }, master: masterData, - [name]: record, + [name]: record }; let strNew = enabledContent; @@ -2970,52 +2628,51 @@ class CommonTableRc extends React.Component { result = !!eval(evalStr); // console.log('=====表格行按钮状态结果', result, { btnName, enabledContent, tempData, strNew, evalStr }); } catch (error) { - console.log("=====表格行按钮状态错误", { error, enabledContent, strNew, tempData }); + console.log('=====表格行按钮状态错误', { error, enabledContent, strNew, tempData }); } } } return result; - }; + } - bCheckBoxColumm = column => { + bCheckBoxColumm = (column) => { const { gdsconfigformslave } = this.props.config || {}; const item = gdsconfigformslave?.find(i => i && i.sName === column?.dataIndex && i.bVisible); - if (item?.sControlName?.startsWith("bCheckBox")) { + 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} - - ); + 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" && + const isSlaveInfo = props.name === 'slaveInfo' || + ( + location.pathname === '/indexPage/commonCostomTabBill' && props.name && - props.name.includes("Info") && - commonUtils.isNotEmptyObject(this.props.slaveInfo)); + 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 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 : ""; /* 获取路由名称 */ + const specialRoute = commonUtils.isNotEmptyObject(this.props.app.currentPane) ? this.props.app.currentPane.route : ''; /* 获取路由名称 */ /* 遍历每一个表头标题 */ for (const column of headerColumn) { /* 表头标题 */ @@ -3023,65 +2680,44 @@ class CommonTableRc extends React.Component { const width = column.width; const bNotEmpty = column.bNotEmpty; /* 带'-'的表头是需要合并滴 */ - const index = commonUtils.isNotEmptyObject(title) ? title.indexOf("-") : -1; + 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 - ) { + 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]) - ); + 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] - ); + 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") - ) { + 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 - ) { + 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) { + 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 : ""; /* 标题字体颜色 */ + 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; @@ -3091,7 +2727,7 @@ class CommonTableRc extends React.Component { } const renderTitle = () => { // 树形表格在第一个column上加上全部展开/收起功能 - let expandedAllIcon = ""; + let expandedAllIcon = ''; const columnIndex = headerColumn.findIndex(item => column.title === item.title); let { data } = this.props; let { expKeys } = this.state; @@ -3100,45 +2736,41 @@ class CommonTableRc extends React.Component { data = commonUtils.isNotEmptyArr(data) ? data : []; const childrenList = []; - const getChildrenList = data => { + const getChildrenList = (data) => { data.forEach(item => { - if (item && typeof item.children === "object") { + if (item && typeof item.children === 'object') { childrenList.push(item); getChildrenList(item.children); } }); - }; + } getChildrenList(data); - if (columnIndex === 0 && childrenList.length) { - // 第一个column并且数据中有children + if (columnIndex === 0 && childrenList.length) { // 第一个column并且数据中有children this.showExpAll = true; this.tableCollapsed = !expKeys.length; - const marginLeft = this.props.bMutiSelect ? "6px" : "2px"; + const marginLeft = this.props.bMutiSelect ? '6px' : '2px'; expandedAllIcon = ( -
); }; - returnProps.filterIcon = filtered => ; - returnProps.onFilterDropdownVisibleChange = visible => { + returnProps.filterIcon = filtered => ; + returnProps.onFilterDropdownVisibleChange = (visible) => { if (visible) { setTimeout(() => this.searchInput.select()); } @@ -4014,7 +3327,7 @@ class CommonTableRc extends React.Component { 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 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]; @@ -4030,7 +3343,7 @@ class CommonTableRc extends React.Component { if (record[column.dataIndex] !== undefined && sValue !== undefined) { return sValue.toString().toLowerCase().includes(value.toLowerCase()); } else { - return "".toString().toLowerCase().includes(value.toLowerCase()); + return ''.toString().toLowerCase().includes(value.toLowerCase()); } }; if (!props.enabled) { @@ -4039,7 +3352,7 @@ class CommonTableRc extends React.Component { 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 sId = commonUtils.isEmpty(dropdownData[0].sSlaveId) ? 'sId' : 'sSlaveId'; const iDropdownIndex = dropdownData.findIndex(item => item[sId] === record[column.dataIndex]); if (text !== undefined && iDropdownIndex > -1) { @@ -4047,21 +3360,13 @@ class CommonTableRc extends React.Component { 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 ( - - ); + 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); } @@ -4076,77 +3381,71 @@ class CommonTableRc extends React.Component { const { enabled, sUseInfo, app, masterData } = props; /* 待用数据 */ const showConfig = this.getShowConfig(props, sName); /* 配置信息 */ - if (commonUtils.isEmptyObject(showConfig)) { - console.log("渲染失败:", showConfig, sName); + if(commonUtils.isEmptyObject(showConfig)) { + console.log('渲染失败:', showConfig, sName); } /* 返回值 */ - let enabledNew = enabled && !showConfig.bReadonly && !record.bInvalid && commonUtils.isEmpty(sUseInfo); + 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) { + if(commonUtils.isNotEmptyObject(masterData) && !masterData.bCheck) { enabledNew = true; } - } else if (record.rowTag === 1) { - /* 当rowTag为1时,锁定该行不可编辑 */ + } else if (record.rowTag === 1) { /* 当rowTag为1时,锁定该行不可编辑 */ enabledNew = false; - } else if (record.bInvLock) { - /* 当bInvLock时,锁定该行不可编辑 */ + } else if (record.bInvLock) { /* 当bInvLock时,锁定该行不可编辑 */ enabledNew = false; } /* 红冲中的单据 不可修改 */ - if ( - commonUtils.isNotEmptyObject(masterData) && - (commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed)) - ) { + 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")) { + 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")); + const iIndex = props.config.gdsconfigformslave.findIndex(item => item.sName === sName && item.sControlName.includes('portionField')); enabledNew = iIndex !== -1; } } - enabledNew = this.getSelectRowEditState(sName, record, enabledNew); + enabledNew= this.getSelectRowEditState(sName, record, enabledNew); - typeof props.otherlimitDisabled === "function" && (enabledNew = props.otherlimitDisabled({ enabledNew, record, sName })); + 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 = ""; + let styleColorArr = ''; + if (commonUtils.isNotEmptyObject((colorConditon))) { + let colorConditionArr = ''; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { - colorConditionArr = ""; + colorConditionArr = ''; } - colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ""; + colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ''; for (const item of colorConditionArr) { - let styleColor = ""; - const { column, condition, background, isRow } = item; - if (!isRow) { - /* 根据配置设置单元格颜色 */ + let styleColor = ''; + const { + column, condition, background, isRow, + } = item; + if (!isRow) { /* 根据配置设置单元格颜色 */ let { conditionValue: conditionValueOld } = item; - const conditionValue = record[conditionValueOld] ? record[conditionValueOld] : conditionValueOld; + 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}` : ""; + 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}` : ''; } } } @@ -4159,19 +3458,19 @@ class CommonTableRc extends React.Component { 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 /* 表单数据改变事件方法(数据格式:函数) */, + 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 /* 是否为表格数据 */, + onInputClick: props.onInputClick, /* 鼠标单击事件 */ + onContextMenu: props.onContextMenu, /* 字段右侧单击事件 */ + bTable: true, /* 是否为表格数据 */ getSqlDropDownData: props.getSqlDropDownData, getSqlCondition: props.getSqlCondition, handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, @@ -4185,9 +3484,9 @@ class CommonTableRc extends React.Component { onPreviewOffice: this.handlePreviewOffice, onDropdownVisibleChange: this.handleDropdownVisibleChange, onFilterDropDownData: props.onFilterDropDownData, - onFieldPopupModal: this.handleFieldPopupModal /* 字段选择弹窗 */, + onFieldPopupModal:this.handleFieldPopupModal, /* 字段选择弹窗 */ onFieldDoubleClick: this.props.onFieldDoubleClick, - onDropDownBlur: props.onDropDownBlur /* 下拉框多选离开事件 */, + onDropDownBlur: props.onDropDownBlur, /* 下拉框多选离开事件 */ className: styleColorArr, readOnly: props.readOnly, onSaveState: props.onSaveState, @@ -4201,130 +3500,131 @@ class CommonTableRc extends React.Component { /** 获取上传控件的props */ getUploadProps = () => { return { - disabled: this.props.name === "picFile" ? !this.findIsUpdByControlName(this.props, "BtnUpload") : !this.props.enabled /* 是否可用 */, - style: { display: commonUtils.convertBooleanToDisplayBlock(this.isUploadShow) } /* 是否显示 */, + 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) } /* 是否显示 */, + 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 /* 点击事件 */, + 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 /* 点击事件 */, + 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" } /* 是否显示 */, + 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) } /* 是否显示 */, + 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" } /* 是否显示 */, + 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" } /* 是否显示 */, + 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" } /* 是否显示 */, + 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" } /* 是否显示 */, + 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" } /* 是否显示 */, + 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 /* 点击事件 */, + 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 /* 点击事件 */, + 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 /* 点击事件 */, + 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 /* 样式名 */, + 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 /* 样式名 */, + 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" } /* 是否显示 */, + disabled: !this.props.enabled, /* 是否可用 */ + style: { display: commonUtils.convertBooleanToDisplayBlock(this.isPopupShow), margin: '0 10px' }, /* 是否显示 */ }; }; getParamPropsTableRow = () => { return { - disabled: !this.props.enabled /* 是否可用 */, + disabled: !this.props.enabled, /* 是否可用 */ // style: { display: commonUtils.convertBooleanToDisplayBlock(this.isParamShow), margin: '0 10px' }, /* 是否显示 */ - style: { display: "block", margin: "0 10px" } /* 是否显示 */, + style: { display: 'block', margin: '0 10px' }, /* 是否显示 */ }; }; /** 生成单元格stateMap */ @@ -4334,37 +3634,34 @@ class CommonTableRc extends React.Component { config = this.props.customConfig; } else { if (this.props.config) { - config = this.props.config.gdsconfigformslave; + 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); - } + 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 }; - }, {}); + } + 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 }; - }, {}); + 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); + bPagination = (commonUtils.isNotEmptyObject(this.props.tableProps) && commonUtils.isNotEmptyObject(this.props.tableProps.pagination)); pagination = this.props.tableProps.pagination; } @@ -4393,7 +3690,7 @@ class CommonTableRc extends React.Component { return; } /* 如果是树形 则返回 */ - if (this.props.sTableType && this.props.sTableType != "zero") { + if(this.props.sTableType && this.props.sTableType !='zero') { return; } const obj = {}; @@ -4407,10 +3704,10 @@ class CommonTableRc extends React.Component { } } data.forEach((item, index) => { - const mergeCellData = config.filter(item => item.sName === "sMergeCellFiled"); /* 查找合并单元格的基准字段 */ - const sMergeCellFiled = commonUtils.isNotEmptyArr(mergeCellData) ? mergeCellData[0].sActiveKey : ""; /* 基准字段 */ + 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 = ""; + item.sColor = ''; } // 第一条数据不需要检测 if (index !== 0) { @@ -4418,11 +3715,7 @@ class CommonTableRc extends React.Component { let flag = false; for (const key in item) { // 判断是否与上一个值相同 - if ( - item[key] !== "" && - item[key] === prevData[key] && - (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true) - ) { + if (item[key] !== '' && item[key] === prevData[key] && (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true) ) { if (!obj[key]) { obj[key] = []; } @@ -4434,26 +3727,23 @@ class CommonTableRc extends React.Component { } if (commonUtils.isNotEmptyArr(this.mergeCellList)) { if (flag) { - item.sColor = sColorIndex % 2 === 0 ? "dark-record-row" : ""; + item.sColor = sColorIndex % 2 === 0 ? 'dark-record-row' : ''; } else { sColorIndex++; - item.sColor = sColorIndex % 2 === 0 ? "dark-record-row" : ""; + 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()); + 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; } @@ -4464,20 +3754,14 @@ class CommonTableRc extends React.Component { } 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 : ""; /* 基准字段 */ + 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 (item[key] !== '' && item[key] === prevData[key] && (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true) ) { if (!obj[key]) { obj[key] = []; } @@ -4487,17 +3771,14 @@ class CommonTableRc extends React.Component { } }); 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()); + 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; } @@ -4505,11 +3786,11 @@ class CommonTableRc extends React.Component { modalTbRow = (record, tableName) => { this.handleModalRow(record, tableName); }; - modalRemarkTbRow = async record => { + modalRemarkTbRow = async (record) => { await this.onRowClick(record); this.handleModalRemarkRow(record); }; - chooseProcessTbRow = record => { + chooseProcessTbRow = (record) => { this.handleChooseProcessRow(record); }; @@ -4523,11 +3804,11 @@ class CommonTableRc extends React.Component { this.handleChooseProductMaterialsRow(index, record); }; - addTbRow = index => { + addTbRow = (index) => { this.handleAddRow(index); }; - addTbRowInHeader = index => { + addTbRowInHeader = (index) => { this.handleAddRow(index, this.props.bModalAdd); }; @@ -4545,43 +3826,30 @@ class CommonTableRc extends React.Component { const { rowTag, sWorkorderNo } = record; const { enabled } = this.props; if (enabled && rowTag === 1) { - const warning = commonFunc.showMessage(this.props.app.commonConst, "beUsed"); /* 复制部件 */ + const warning = commonFunc.showMessage(this.props.app.commonConst, 'beUsed');/* 复制部件 */ const { sModelsType } = this.props.app.currentPane; - if (sModelsType.includes("sales/")) { + if (sModelsType.includes('sales/')) { message.error(warning + sWorkorderNo); } } else { return null; } }; - handleSelectCancel = modelVisible => { + handleSelectCancel = (modelVisible) => { this.setState({ - [modelVisible]: false, + [modelVisible]:false, }); }; handleSelectCommonPopup = (name, selectConfig, selectData) => { - const { - commonPopupTbName, - commonPopupShowConfig, - commonFieldPopupVisible, - commonPopupVisible, - commonFieldPopupTbName, - commonFieldPopupShowConfig, - commonModalVisible, - commonModalShowConfig, - commonModalTbName, - } = this.state; + const { commonPopupTbName, commonPopupShowConfig, commonFieldPopupVisible, commonPopupVisible, commonFieldPopupTbName, commonFieldPopupShowConfig, + commonModalVisible, commonModalShowConfig, commonModalTbName } = this.state; /* 若是产品名称弹窗 并且配置了调用产品工艺卡标识copyFromTechnology 则走自己的逻辑 */ - if (selectConfig.sCompareColor === "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")) { + 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; } @@ -4594,10 +3862,10 @@ class CommonTableRc extends React.Component { this.props.onSelectCommonPopup(name, selectConfig, selectData, commonFieldPopupTbName, commonFieldPopupShowConfig); }; - copyTbRow = index => { + copyTbRow = (index) => { this.handleCopyRow(index); }; - copyAllTbRow = index => { + copyAllTbRow = (index) => { this.handleCopyAllRow(index); }; downloadTbRow = (index, record) => { @@ -4615,23 +3883,19 @@ class CommonTableRc extends React.Component { 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 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 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)}`; + const urlPrint = `${commonConfig.file_host}printReport/printPdfByFromDataId/${printsId}.pdf?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`; window.open(urlPrint); - } else if (showConfig.sActiveId === "172129113112117442504826460") { - // 生成拼板 + } else if (showConfig.sActiveId === "172129113112117442504826460") { // 生成拼板 if (record.bMakeUpEnd) { this.props.onSaveState({ makeUpPDFRecord: record, @@ -4639,8 +3903,7 @@ class CommonTableRc extends React.Component { } else { message.info("请先完成拼版!"); } - } else if (showConfig.sDropDownType && showConfig.sDropDownType.toLowerCase().includes("picarrmodal")) { - /* 蓝色链接跳转用Modal呈现 */ + } 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; @@ -4658,32 +3921,31 @@ class CommonTableRc extends React.Component { handleHideModal = () => { let antModalRootEl = null; - const bInModal = el => { + const bInModal = (el) => { if (commonUtils.isEmpty(el) || commonUtils.isEmpty(el.classList)) { return false; - } else if (el.classList.contains("ant-modal-root")) { + } else if (el.classList.contains('ant-modal-root')) { antModalRootEl = el; return true; } else { return bInModal(el.parentNode); } - }; - if (bInModal(event.target)) { - // 如果是在modal里的表格,不允许跳转 + } + 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); + 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) => { + handleQuickViewClick = async (name, sName, record, index , myConfigArr) => { const { slaveConfig, slaveData, @@ -4701,11 +3963,11 @@ class CommonTableRc extends React.Component { // masterData, // employeeConfig, } = this.props; - let picArr = ""; - if (commonUtils.isNotEmptyArr(slaveConfig)) { - picArr = slaveConfig.gdsconfigformslave.filter(item => item.sName === sName); + let picArr = '' + if(commonUtils.isNotEmptyArr(slaveConfig)){ + picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === sName)); } - if (commonUtils.isNotEmptyArr(myConfigArr)) { + if(commonUtils.isNotEmptyArr(myConfigArr)) { picArr = myConfigArr; } if (picArr.length > 0) { @@ -4714,60 +3976,59 @@ class CommonTableRc extends React.Component { 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("."); + 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") { + 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); + const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat); filterCondition.push({ bFilterName: item, - bFilterCondition: "=", + bFilterCondition: '=', bFilterValue: `${tStartDate},${tEndDate}`, }); } - } else if (item === "mStartDate_pro" || item.substring(0, 1) === "m") { + } 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); + 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: "=", + bFilterCondition: '=', bFilterValue: `${tStartDate},${tEndDate}`, }); } - } else if (item.substring(0, 1) === "t") { + } else if (item.substring(0, 1) === 't') { filterCondition.push({ bFilterName: item, - bFilterCondition: "=", + bFilterCondition: '=', bFilterValue: moment(conditionValues[item]).format(this.sDateFormat), }); } else { filterCondition.push({ bFilterName: item, - bFilterCondition: "=", + bFilterCondition: '=', bFilterValue: conditionValues[item], }); } }); } this.props.dispatch({ - type: "content/onRouter", + type: 'content/onRouter', payload: { url: sNameUrl, - refresh: getConfig.bind(this, name, sModelsId) /* 刷新方法 */, + refresh: getConfig.bind(this, name, sModelsId), /* 刷新方法 */ sTabId: commonUtils.createSid(), // sParentId: this.state.sTabId, - urlDataType: "newPane", + urlDataType: 'newPane', checkedId: myConfigArr[0].sId, sName: myConfigArr[0].sName, bFilter: slaveFilterCondition, @@ -4784,28 +4045,26 @@ class CommonTableRc extends React.Component { }; /* 文件下载 */ - handleFileDownload = fileUrl => { - const fileList = fileUrl.split(","); + 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 - )}`; + 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.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) { + 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"; + const a = document.createElement('a'); + a.style.display = 'none'; a.href = url; a.download = fileName; document.body.appendChild(a); @@ -4814,15 +4073,15 @@ class CommonTableRc extends React.Component { 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")) { + if (sName.includes('sTemplateFullMemo')) { return this.setState({ simpleModalVisible: true, simpleModalWord: record[sName] }); } const sCurrMemoProps = { @@ -4837,31 +4096,31 @@ class CommonTableRc extends React.Component { }; this.props.onSaveState({ sCurrMemoProps }); } - }; - handleViewChoose = (name, sName, record, index) => { + } + handleViewChoose= (name, sName, record, index) => { this.props.onViewChoose(name, sName, record, index); - }; + } /* 弹出通用窗体 */ - handlePopupModal = (showConfig, name) => { + handlePopupModal= (showConfig, name) => { this.setState({ - commonPopupVisible: true, - commonPopupTbName: name, - commonPopupShowConfig: showConfig, + commonPopupVisible:true, + commonPopupTbName:name, + commonPopupShowConfig:showConfig, }); - }; + } /* 字段弹窗 */ - handleFieldPopupModal = (showConfig, name, record) => { + handleFieldPopupModal= (showConfig, name, record) => { this.setState({ - commonFieldPopupVisible: true, - commonFieldPopupTbName: name, - commonFieldPopupShowConfig: showConfig, + commonFieldPopupVisible:true, + commonFieldPopupTbName:name, + commonFieldPopupShowConfig:showConfig, commonFieldPopupShowRecord: record, }); - }; + } /* 蓝色链接弹出通用窗体 */ - handleTabModalClick = (name, sName, record, index, showConfig, configName) => { + handleTabModalClick= (name, sName, record, index, showConfig, configName) => { // const { sourceAllData:data } = this.props; // let commonModalData = []; // if(sName === 'dSumCompleteAvailableStockQty' && commonUtils.isNotEmptyArr(data)) { @@ -4870,14 +4129,14 @@ class CommonTableRc extends React.Component { // item.bSecondMainMaterials); // } this.setState({ - commonModalVisible: true, - commonModalTbName: name, - commonModalShowConfig: showConfig, - commonModalRecord: record, - commonModalConfigName: configName, + commonModalVisible:true, + commonModalTbName:name, + commonModalShowConfig:showConfig, + commonModalRecord:record, + commonModalConfigName:configName, // commonModalData, }); - }; + } handleCellClick = (record) => { const { enabled } = this.props; @@ -4940,19 +4199,17 @@ class CommonTableRc extends React.Component { } /* 点击图片预览 */ - handlePreviewImage = (e, dataUrlArr) => { - e.stopPropagation(); /* 阻止父级穿透 */ + handlePreviewImage= (e, dataUrlArr) => { + 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; /* 预览 */ + 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, + previewImage:previewImageArr, previewVisible: true, showimgs: true, firstIndex: 0, @@ -4961,14 +4218,14 @@ class CommonTableRc extends React.Component { }; // office文件预览 - handlePreviewOffice = dataUrlArr => { + handlePreviewOffice = (dataUrlArr) => { this.setState({ officePreviewVisible: true, - officeFileUrl: dataUrlArr, + officeFileUrl: dataUrlArr }); }; - handleDropdownVisibleChange = open => { + handleDropdownVisibleChange = (open) => { // this.beSelectDropdownOpen = open; }; /* 生产排程工艺流程字段弹窗 - 生产进度详情 */ @@ -4986,49 +4243,46 @@ class CommonTableRc extends React.Component { 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 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 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 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( - '' - ); + newWin.document.write(''); // window.open(urlPrint); } else { - message.error("未找到对应过程名"); + message.error('未找到对应过程名'); } }; /* 右箭头点击 */ handleRightArrow = (name, sName, record, index, showConfig) => { - if (this.props.onRightArrow) { + 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++) { + 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 }); - }; + this.setState({ bOperateMoreVisible: false }) + } + - showimg = i => { + showimg = (i) => { this.setState({ showimgs: true, firstIndex: i }); }; toggleshow = () => { @@ -5039,7 +4293,7 @@ class CommonTableRc extends React.Component { previewVisible: false, }); }; - handleCancelModal = modelVisible => { + handleCancelModal = (modelVisible) => { this.props.onSaveState({ [modelVisible]: false, }); @@ -5054,135 +4308,123 @@ class CommonTableRc extends React.Component { if (size.width === column.width) { return; } - this.setState( - ({ tableColumn, tableInfoColumn }) => { - let nextColumns; - if (isSlaveInfo) { - nextColumns = [...tableInfoColumn]; - } else { - nextColumns = [...tableColumn]; - } + 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; - } + 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 + 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 (offset < 0) { - // 向左拉伸 - if (scrollRight < -offset) { - // 滚动条距离表格右边距离小于拉伸距离 - const diffWidth = -offset - scrollRight; - lastColumn.width += diffWidth; - lastColumn.widthExtra ? (lastColumn.widthExtra += diffWidth) : (lastColumn.widthExtra = diffWidth); - offset = -diffWidth; - } + } else if (!iWidthExtra && lastColumn.width - offset > 150) { // 没有额外宽度,但是减去位移后宽度大于150 + lastColumn.width -= offset; + offset = 0; } - - // 处理拖动幅度太大时,空白列会显示问题 - 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]; + } else if (offset < 0) { // 向左拉伸 + if (scrollRight < -offset) { // 滚动条距离表格右边距离小于拉伸距离 + const diffWidth = -offset - scrollRight; + lastColumn.width += diffWidth; + lastColumn.widthExtra ? (lastColumn.widthExtra += diffWidth) : (lastColumn.widthExtra = diffWidth); + offset = -diffWidth; } } - } - if (isSlaveInfo) { - if (this.scrollInfoX) { - this.scrollInfoX += offset; - } else { - this.scrollInfoX = 0; - this.scrollInfoX = this.countScrollX(nextColumns, true); + // 处理拖动幅度太大时,空白列会显示问题 + 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]; } - return { tableInfoColumn: nextColumns }; + } + } + + if (isSlaveInfo) { + if (this.scrollInfoX) { + this.scrollInfoX += offset; } else { - if (this.scrollX) { - this.scrollX += offset; - } else { - this.scrollX = 0; - this.scrollX = this.countScrollX(nextColumns); - } - return { tableColumn: nextColumns }; + this.scrollInfoX = 0; + this.scrollInfoX = this.countScrollX(nextColumns, true); } - }, - () => { - this.resize = false; - this.initColumn = null; - if (isSlaveInfo) { - sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}_info`, JSON.stringify(this.state.tableInfoColumn)); + return { tableInfoColumn: nextColumns }; + } else { + if (this.scrollX) { + this.scrollX += offset; } else { - sessionStorage.setItem(`${this.props.formId}_${this.props.config.sId}`, JSON.stringify(this.state.tableColumn)); + 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; @@ -5193,23 +4435,23 @@ class CommonTableRc extends React.Component { let colSpan = 0; if ((!totalData.length && !totalData1.length) || this.props.footer !== undefined) { - return <>; + return (<>); } - if (this.props.tableProps.rowSelection !== null && !(this.props.config && !this.props.config.bisMutiSelect)) { + if(this.props.tableProps.rowSelection !== null && !(this.props.config && !this.props.config.bisMutiSelect)) { colSpan = colSpan + 1; } - if (this.props.slaveInfo) { + if(this.props.slaveInfo) { colSpan = colSpan + 1; } - if (this.props.dragHandle) { + if(this.props.dragHandle) { // colSpan = colSpan + 1; // 临时处理标准精准报价单据工序信息表合计错位问题 } const cells = []; const cells1 = []; if (totalData.length) { - let summaryCellTotal = ""; + let summaryCellTotal = ''; summaryCellTotal = ( - + {sumset} ); @@ -5229,66 +4471,51 @@ class CommonTableRc extends React.Component { cells.push(summaryCellTotal); tableColumn.forEach((item, index) => { - if (colSpan === 0 && index === 0) { + if(colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; - if (tableColumn[index].children !== undefined && tableColumn[index].children.length > 0) { - /* 循环嵌套标题行 */ + 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 - ) { + 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 point = columnConfig.sFieldValidation.split(',')[1] || 2; + if(commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); - if (!isNaN(dConfigResult)) { + if(!isNaN(dConfigResult)) { sValue = dConfigResult; } } - } else if ( - (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("commonList")) || - (sModelsType && sModelsType.indexOf("commonMultiList") > -1) - ) { + } 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) - ) { + 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) { + 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) { + if(commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); - if (!isNaN(dConfigResult)) { + if(!isNaN(dConfigResult)) { sValue = dConfigResult; } } } } else { - if (commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.toLowerCase().endsWith("price")) { - /* 列表单价格式化显示1 */ - if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { + 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)) { + if(!isNaN(dResult)) { sValue = dResult; } } - } else if (commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.toLowerCase().endsWith("money")) { - /* 列表金额格式化显示 */ - if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { + } 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)) { + if(!isNaN(dResult)) { sValue = dResult; } } @@ -5297,42 +4524,33 @@ class CommonTableRc extends React.Component { } const cellChild = ( - - {sValue} - + {sValue} ); cells.push(cellChild); }); - } else { - /* 正常单层标题行 */ - let cell = ""; + } 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) - ) { + 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 - ) { + 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 point = columnConfig.sFieldValidation.split(',')[1] || 2; + if(commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils.convertFixNum(Number(sValue), point).toFixed(point); - if (!isNaN(dConfigResult)) { + if(!isNaN(dConfigResult)) { sValue = dConfigResult; } } - } else if (commonUtils.isNotEmptyObject(item.sDateFormat)) { + } else if ( commonUtils.isNotEmptyObject(item.sDateFormat)) { /* 取小数点位数 */ let point = 0; - let strIndex = item.sDateFormat.indexOf("."); + 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) { @@ -5343,16 +4561,14 @@ class CommonTableRc extends React.Component { } } } else { - if (commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.toLowerCase().endsWith("price")) { - /* 列表单价格式化显示1 */ + 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")) { - /* 列表金额格式化显示 */ + } 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)) { @@ -5364,9 +4580,9 @@ class CommonTableRc extends React.Component { } cell = ( - - {sValue} - + {sValue} ); cells.push(cell); @@ -5375,42 +4591,40 @@ class CommonTableRc extends React.Component { } if (totalData1.length) { - let summaryCellTotal1 = ""; + let summaryCellTotal1 = ''; summaryCellTotal1 = ( - + 总计 ); cells1.push(summaryCellTotal1); tableColumn.forEach((item, index) => { - if (colSpan === 0 && index === 0) { + if(colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; - if (tableColumn[index].children !== undefined && tableColumn[index].children.length > 0) { - /* 循环嵌套标题行 */ + if (tableColumn[index].children !== undefined && tableColumn[index].children.length > 0) { /* 循环嵌套标题行 */ tableColumn[index].children.forEach((itemChild, i) => { /* 合计 格式化单价、金额 */ let sValue = totalData1[0][itemChild.dataIndex]; const cellChild = ( - - {sValue} - + {sValue} ); cells1.push(cellChild); }); - } else { - /* 正常单层标题行 */ - let cell = ""; + } else { /* 正常单层标题行 */ + let cell = ''; /* commonList 格式化单价、金额 */ let sValue = totalData1[0][item.dataIndex]; cell = ( - - {sValue} - + {sValue} ); cells1.push(cell); @@ -5419,11 +4633,23 @@ class CommonTableRc extends React.Component { } return ( - {totalData.length ? {cells} : ""} - {totalData1.length ? {cells1} : ""} + { + totalData.length ? ( + + {cells} + + ) : '' + } + { + totalData1.length ? ( + + {cells1} + + ) : '' + } ); - }; + } handleSearch = (selectedKeys, confirm, searchColumnName, clearFilters) => { confirm(); @@ -5441,131 +4667,119 @@ class CommonTableRc extends React.Component { handleReset = (clearFilters, confirm) => { clearFilters(); if (this.mounted) { - this.setState({ searchText: "" }, () => { + this.setState({ searchText: '' }, () => { // 重置搜索条件 confirm(); }); } }; + /** 求和所有列 */ handleSumAllColumn = (config, dataSource) => { const tableDataTotal = {}; - const sumConfig = config.gdsconfigformslave.filter(item => item.sName !== "" && item.bVisible && item.bSum); + 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) - ); + 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)) { + 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) - ); + 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 { + tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } + } } }); }); } else { - sumConfig.forEach(sumItem => { + sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; - tableDataTotal.key = "0000"; + tableDataTotal.key = '0000'; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } - }; + } handleSumOtherColumn = (config, dataSource) => { const tableDataTotal = {}; - const sumConfig = config.gdsconfigformslave.filter(item => item.sName !== "" && item.bVisible && item.bSum); + 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; + const { selectedRowKeys } =this.state; /* 生产排程对选中行进行汇总 */ - if (commonUtils.isNotEmptyArr(selectedRowKeys)) { + 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) - ); + 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) - ); + 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) - ); + 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) - ); + tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } }); }); } } else { - sumConfig.forEach(sumItem => { + sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; - tableDataTotal.key = "0000"; + 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); + 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)) { + if (commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource) && commonUtils.isNotEmptyArr(filteredValue)) { /* 序号根据sSqlConditonId分组 序号重排 */ const groupedData = commonUtils.groupBy(dataSource, item => item.sSqlConditionId); let selectedData = []; @@ -5575,47 +4789,43 @@ class CommonTableRc extends React.Component { if (commonUtils.isNotEmptyArr(eachData)) { /* 看当前选中在哪个组里 */ const iIndex = eachData.findIndex(item => filteredValue.includes(item.sSqlConditionId)); - if (iIndex > -1) { + 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) - ); + 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) - ); + tableDataTotal[sumItem.sName] = commonUtils.convertFixNum(commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName)); } } }); }); } } else { - sumConfig.forEach(sumItem => { + sumConfig.forEach((sumItem) => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; - tableDataTotal.key = "0000"; + tableDataTotal.key = '0000'; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } - }; + } // 表格按钮点击后调用指令集 handleInstruct = (btnName, callback) => { - const { sInstruct: sInstructStr } = this.props.config; + const { sInstruct:sInstructStr } = this.props.config; const sInstruct = commonUtils.convertStrToObj(sInstructStr, {}); const { data = [] } = sInstruct; @@ -5638,60 +4848,61 @@ class CommonTableRc extends React.Component { } else { callback && callback(); } - }; + } /** 查看行 */ handleLookRow = () => { this.props.onLookRow(this.props.name); }; /** 材料备注行 */ - handleModalRemarkRow = index => { + handleModalRemarkRow = (index) => { this.props.onModalRow(index); }; /** modal行 */ handleModalRow = (recordIndex, tableName) => { if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseMaterialsConfigRow)) { - this.handleInstruct("BtnChooseMaterials", () => { + this.handleInstruct('BtnChooseMaterials', () => { const iIndex = this.props.tableProps.chooseMaterialsConfigRow; - this.props.onBtnChoose("materials", "BtnChooseMaterials", iIndex, recordIndex, tableName); // recordIndex选中行的索引 + this.props.onBtnChoose('materials', 'BtnChooseMaterials', iIndex, recordIndex, tableName); // recordIndex选中行的索引 }); } }; - handleChooseProcessRow = record => { + handleChooseProcessRow = (record) => { if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseProcessConfigRow)) { - this.handleInstruct("BtnChooseProcess", () => { + 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); - } + 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 => { + handleChooseProductProcessRow = (recordIndex) => { /* recordIndex 为选中行下标 */ if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseProductProcessConfigRow)) { const btnConfig = this.props.tableProps.chooseProductProcessConfigRow; - this.props.onBtnChoose("productProcess", "BtnChooseProductProcess", btnConfig, recordIndex); + this.props.onBtnChoose('productProcess', 'BtnChooseProductProcess', btnConfig, recordIndex); } }; /* 成品材料弹窗 */ - handleChooseProductMaterialsRow = recordIndex => { + handleChooseProductMaterialsRow = (recordIndex) => { /* recordIndex 为选中行下标 */ if (commonUtils.isNotEmptyObject(this.props.tableProps.chooseProductMaterialsConfigRow)) { const btnConfig = this.props.tableProps.chooseProductMaterialsConfigRow; - this.props.onBtnChoose("productMaterials", "BtnChooseProductMaterials", btnConfig, recordIndex); + this.props.onBtnChoose('productMaterials', 'BtnChooseProductMaterials', btnConfig, recordIndex); } }; @@ -5699,61 +4910,61 @@ class CommonTableRc extends React.Component { handleAddRow = (index, bModalAdd) => { this.stopRowClick = true; /* 多表树形删除 */ - if (this.props && this.props.slaveInfo && this.props.slaveInfo.tableProps && this.props.slaveInfo.tableProps.bSlaveInfo) { + 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.handleInstruct('BtnAdd', () => { this.props.onAddRow(this.props.name, null, index, this.props.bFinished, bModalAdd); }); } - }, 0); + }, 0) }; - handleAddInfoRow = index => { + handleAddInfoRow = (index) => { const tableInfoName = this.props.slaveInfo.name; setTimeout(() => { if (this.props.onAddRow) { - this.handleInstruct("BtnAdd", () => { + this.handleInstruct('BtnAdd', () => { this.props.onAddRow(tableInfoName, null, index, false, false); }); } - }, 0); + }, 0) }; handleTreeAdd = () => { setTimeout(() => { - this.handleInstruct("BtnAdd", () => { + this.handleInstruct('BtnAdd', () => { if (this.props.onTreeAdd) { - this.props.onTreeAdd(this.props.name, true, "sameNode"); + this.props.onTreeAdd(this.props.name, true, 'sameNode'); } }); - }, 0); + }, 0) }; handleTreeAddChild = () => { setTimeout(() => { - this.handleInstruct("BtnAddChildNode", () => { + this.handleInstruct('BtnAddChildNode', () => { if (this.props.onTreeAddChild) { - this.props.onTreeAddChild(this.props.name, true, "childNode"); + this.props.onTreeAddChild(this.props.name, true, 'childNode'); } }); - }, 0); + }, 0) }; handleTreeCopyAll = () => { setTimeout(() => { - this.handleInstruct("BtnCopyAll", () => { + this.handleInstruct('BtnCopyAll', () => { if (this.props.onTreeCopyAll) { - this.props.onTreeCopyAll(this.props.name, false, "isChild"); + this.props.onTreeCopyAll(this.props.name, false, 'isChild'); } }); - }, 0); + }, 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") : "确定?"; + 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, @@ -5764,7 +4975,7 @@ class CommonTableRc extends React.Component { return false; }, okText: BtnSure, - cancelText: BtnCancel, + cancelText: BtnCancel }); } else { this.handleTreeDelOk(index, record); @@ -5772,39 +4983,39 @@ class CommonTableRc extends React.Component { }; handleTreeDelOk = () => { setTimeout(() => { - this.handleInstruct("BtnDel", () => { + this.handleInstruct('BtnDel', () => { if (this.props.onTreeDel) { - this.props.onTreeDel(this.props.name, true, ""); + this.props.onTreeDel(this.props.name, true, ''); } }); - }, 0); + },0); }; /** 复制 */ - handleCopyRow = index => { + handleCopyRow = (index) => { setTimeout(() => { - this.handleInstruct("BtnCopy", () => { + this.handleInstruct('BtnCopy', () => { if (this.props.onCopyRow) { this.props.onCopyRow(this.props.name, undefined, undefined, index); } }); - }, 0); + },0) }; /** 复制全部 */ handleCopyAllRow = () => { setTimeout(() => { - this.handleInstruct("BtnCopyAll", () => { + this.handleInstruct('BtnCopyAll', () => { if (this.props.onCopyAllRow) { this.props.onCopyAllRow(this.props.name); } }); - }, 0); + }, 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") : "确定?"; + 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, @@ -5815,7 +5026,7 @@ class CommonTableRc extends React.Component { return false; }, okText: BtnSure, - cancelText: BtnCancel, + cancelText: BtnCancel }); } else { this.handleDelOkRow(index, record); @@ -5825,18 +5036,18 @@ class CommonTableRc extends React.Component { /** 删除行 */ handleDelOkRow = (index, record) => { const tableSelectedRowKeys = []; - if (this.props?.formId === "12710101117043535363530") { + 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) { + if(this.props && this.props.slaveInfo && this.props.slaveInfo.tableProps && this.props.slaveInfo.tableProps.bSlaveInfo) { this.handleDelInfoRow(index, record); return; } setTimeout(() => { - this.handleInstruct("BtnDel", () => { + this.handleInstruct('BtnDel', () => { if (this.props.onDelRow(this.props.name, false, tableSelectedRowKeys, undefined, index)) { this.handleSumAllColumn(this.props.config, this.state.dataSource); } @@ -5855,15 +5066,15 @@ class CommonTableRc extends React.Component { tableSelectedRowKeys.push(record.sId); const tableInfoName = this.props.slaveInfo.name; setTimeout(() => { - this.handleInstruct("BtnDel", () => { - this.props.onDelRow(tableInfoName, false, tableSelectedRowKeys); + this.handleInstruct('BtnDel', () => { + this.props.onDelRow(tableInfoName, false, tableSelectedRowKeys) }); }, 0); }; /** 复制 */ - handleCopyMoreRow = index => { - this.setState({ bOperateMoreVisible: true }); + handleCopyMoreRow = (index) => { + this.setState({ bOperateMoreVisible : true}); }; /** 提取数据 */ @@ -5886,28 +5097,25 @@ class CommonTableRc extends React.Component { 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); + 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") { + 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)) { + if(commonUtils.isNotEmptyObject(conditionValue)) { + if(commonUtils.isNotEmptyObject(conditionValue.warning)) { message.warn(conditionValue.warning); return; } } this.setState({ - commonPopupVisible: true, - commonPopupTbName: name, - commonPopupShowConfig: btnPupopConfig, - commonPopupRecord: record, + commonPopupVisible:true, + commonPopupTbName:name, + commonPopupShowConfig:btnPupopConfig, + commonPopupRecord:record, }); } } @@ -5926,12 +5134,8 @@ class CommonTableRc extends React.Component { 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); + 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; @@ -5948,41 +5152,37 @@ class CommonTableRc extends React.Component { handleData[sortIndexFirst].iOrder = handleData[sortIndexLast].iOrder; handleData[sortIndexLast].iOrder = tempOrder; - const postData = isSlaveInfo - ? { - [this.props.slaveInfo.config.sId]: handleData, - } - : { - [this.props.config.sId]: handleData, - }; + 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: "", + handleType: 'group', + sJurisdictionClassifyId: '', bDefault: true, handleData: postData, }; const options = { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + '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 }); - } - }); + 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 }); + } + }); }; /** 查找控件名是否存在 */ @@ -5999,10 +5199,10 @@ class CommonTableRc extends React.Component { // case 'BtnAdd': // propsIcon = props.tableProps.setAdd; // break; - case "BtnChooseMaterials": + case 'BtnChooseMaterials': propsIcon = props.tableProps.setMaterial; break; - case "BtnChooseProcess": + case 'BtnChooseProcess': propsIcon = props.tableProps.setProcess; break; // case 'BtnCopy': @@ -6021,13 +5221,9 @@ class CommonTableRc extends React.Component { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ - if ( - commonUtils.isNotEmptyArr(props.config) && - commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && - commonUtils.isNotEmptyStr(controlName) - ) { + 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); + ret = commonUtils.isEmptyArr(controlConfig) ? ( propsIcon ? true : false ) : commonUtils.converStrToBoolean(controlConfig[0].bVisible); } /* 返回值 */ return ret; @@ -6040,14 +5236,10 @@ class CommonTableRc extends React.Component { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ - if ( - commonUtils.isNotEmptyArr(props.config) && - commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && - commonUtils.isNotEmptyStr(controlName) - ) { + 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)) { + if(ret && controlName === 'BtnUpload' && Array.isArray(controlConfig)) { this.BtnUploadDivPropsAttr.current = controlConfig[0]; } } @@ -6060,11 +5252,7 @@ class CommonTableRc extends React.Component { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ - if ( - commonUtils.isNotEmptyArr(props.config) && - commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && - commonUtils.isNotEmptyStr(controlName) - ) { + 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); } @@ -6076,16 +5264,10 @@ class CommonTableRc extends React.Component { /* 返回值声明 */ 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(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") { + if (controlConfig[0].bVisible && controlConfig[0].sDropDownType === 'popup') { ret = true; } } @@ -6096,175 +5278,131 @@ class CommonTableRc extends React.Component { handleGetRjRes = (res, index, sName) => { const { masterData = {}, formId, enabled } = this.props; - if (enabled && formId === "12710101117225611571970" && masterData.sTeamName?.includes("质检") && sName === "sInspectionCode") { + if (enabled && formId === "12710101117225611571970" && masterData.sTeamName?.includes('质检') && sName === "sInspectionCode") { return ( <> {res}
); - }; - handleFastSearch = params => { + } + handleFastSearch = (params) => { const { sName, record, oldKey } = params; const { config, searchRowKeys = [], onBtnSearch } = this.props; const newKey = oldKey || commonUtils.createSid(); const sFirstFieldName = `sFirst-${newKey}`; - const { masterData } = this.props.onChange("master", sFirstFieldName, { [sFirstFieldName]: sName }, null, null, true); + const { masterData } = this.props.onChange('master', sFirstFieldName, { [sFirstFieldName]: sName }, null, null, true); const sFirstValue = masterData[sFirstFieldName]; - const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? "s" : sFirstValue.substring(0, 1); - const sSecondConditionPro = firstDataIndex === "s" && sFirstValue.endsWith("_pro"); + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1); + const sSecondConditionPro = firstDataIndex === 's' && sFirstValue.endsWith('_pro'); const iIndex = config.gdsconfigformslave.findIndex(item => item.sName === sFirstValue); - masterData[`sSecond-${newKey}`] = - sSecondConditionPro && iIndex > -1 && config.gdsconfigformslave[iIndex].sDropDownType === "sql" - ? commonConfig.seaJudge.s_proDropDown[0].sId - : sSecondConditionPro - ? commonConfig.seaJudge.s_pro[0].sId - : commonConfig.seaJudge[firstDataIndex][0].sId; - masterData[`${firstDataIndex}Third-${newKey}`] = - firstDataIndex === "b" ? false : firstDataIndex === "t" ? moment().format("YYYY-MM-DD") : masterData[`${firstDataIndex}Third-${newKey}`]; + masterData[`sSecond-${newKey}`] = sSecondConditionPro && iIndex > -1 && config.gdsconfigformslave[iIndex].sDropDownType === 'sql' ? + commonConfig.seaJudge.s_proDropDown[0].sId : sSecondConditionPro ? + commonConfig.seaJudge.s_pro[0].sId : commonConfig.seaJudge[firstDataIndex][0].sId; + masterData[`${firstDataIndex}Third-${newKey}`] = firstDataIndex === 'b' ? false : firstDataIndex === 't' ? moment().format('YYYY-MM-DD') : masterData[`${firstDataIndex}Third-${newKey}`]; const sThirdName = `${firstDataIndex}Third-${newKey}`; masterData[`${sThirdName}`] = record[sName]; @@ -7707,7 +6654,7 @@ class CommonTableRc extends React.Component { onBtnSearch(); }); }; - handleClearFastSearch = oldKey => { + handleClearFastSearch = (oldKey) => { const { searchRowKeys = [], onBtnSearch, masterData = {} } = this.props; if (searchRowKeys.length > 1) { const searchRowKeysNew = searchRowKeys.filter(item => item !== oldKey); @@ -7717,22 +6664,22 @@ class CommonTableRc extends React.Component { } else if (searchRowKeys.length === 1) { const sThirdName = Object.keys(masterData).find(key => key.indexOf(`Third-${oldKey}`) !== -1); if (sThirdName) { - masterData[sThirdName] = ""; + masterData[sThirdName] = ''; this.props.onSaveState({ masterData }, () => { onBtnSearch(); }); } } - }; + } // 进行拖动排序,数据展现必须按照iOrder 进行排序展现,必须进行选择才能拖动(废弃) moveRowOld = (dragIndex, hoverIndex) => { const { name } = this.props; const { selectedRowKeys } = this.state; if (commonUtils.isEmptyArr(selectedRowKeys)) { - message.warning("请选择后进行拖动"); + message.warning('请选择后进行拖动'); } else { // let mHoverIndex = hoverIndex; - selectedRowKeys.forEach(item => { + selectedRowKeys.forEach((item) => { const { dataSource } = this.state; const iIndex = dataSource.findIndex(newItem => item === newItem[this.rowKey]); const dragRow = dataSource[iIndex]; @@ -7740,10 +6687,7 @@ class CommonTableRc extends React.Component { const newState = update(this.state, { dataSource: { - $splice: [ - [iIndex, 1], - [hoverIndex, 0, dragRow], - ], + $splice: [[iIndex, 1], [hoverIndex, 0, dragRow]], }, }); this.setState(newState); @@ -7752,37 +6696,37 @@ class CommonTableRc extends React.Component { const { dataSource } = this.state; dataSource.forEach((item, index) => { if (commonUtils.isEmpty(item.handleType)) { - item.handleType = "update"; + item.handleType = 'update'; } item.iOrder = index + 1; }); this.setState(dataSource); this.props.onRowMove({ [`${name}Data`]: dataSource }); } - }; + } /* 拖拽改变对应层级 */ - moveRow = (dragIndex, hoverIndex, dragKey, hoverKey) => { - if (this.props.onMoveRow) { - this.props.onMoveRow(dragIndex, hoverIndex, dragKey, hoverKey, this.props); + moveRow = (dragIndex, hoverIndex,dragKey,hoverKey) => { + if(this.props.onMoveRow) { + this.props.onMoveRow(dragIndex, hoverIndex,dragKey,hoverKey); } }; BtnUploadDivProps = () => { return { - accept: this.BtnUploadDivPropsAttr.current?.sActiveKey || "*/*", - beforeUpload: file => { + accept: this.BtnUploadDivPropsAttr.current?.sActiveKey || '*/*', + beforeUpload: (file) => { const config = this.BtnUploadDivPropsAttr.current; - if (config?.sActiveKey && typeof config?.sActiveKey === "string") { - const isAllow = config?.sActiveKey?.split(",").includes(file.type); + if (config?.sActiveKey && typeof config?.sActiveKey === 'string') { + const isAllow = config?.sActiveKey?.split(',').includes(file.type); if (!isAllow) { - message.error(`请选择正确的文件类型,包含${config?.sActiveKey || ""}`); + message.error(`请选择正确的文件类型,包含${config?.sActiveKey || ''}`); } return isAllow; } return true; - }, - }; - }; + } + } + } /** 渲染 */ render() { @@ -7818,7 +6762,7 @@ class CommonTableRc extends React.Component { if (commonUtils.isNotEmptyObject(previewImage)) { if (commonUtils.isNotEmptyArr(this.props.data)) { if (this.props.data[0].sPicturePath) { - for (const item of this.props.data) { + for(const item of this.props.data) { const dataUrl = `${commonConfig.file_host}file/download?savePathStr=${item.sPicturePath}&sModelsId=100&token=${token}`; /* 缩略图 */ data.push(dataUrl); } @@ -7833,9 +6777,9 @@ class CommonTableRc extends React.Component { const divProps = { action: `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}`, onChange: this.handleUploadChange, - accept: "*/*", + accept: '*/*', showUploadList: false, - multiple: true, + multiple:true, beforeUpload: this.handleBeforeUpload, }; /* 获取look的props */ @@ -7869,7 +6813,7 @@ class CommonTableRc extends React.Component { /* 通用弹窗功能 */ let commonPopupProps = {}; - let commonPopupTitle = "选择弹窗"; + let commonPopupTitle = '选择弹窗'; let bCommonPopup = false; /* 多列弹出窗11 */ let bCommonPopup1 = false; /* 单列弹出窗 */ let bCommonPopupTree = false; /* 树形列弹出窗 */ @@ -7878,59 +6822,35 @@ class CommonTableRc extends React.Component { let commonPopupConfig = {}; const { config, sModelsId, app, selectedRowKeys } = this.props; if (commonUtils.isNotEmptyObject(config)) { - const iIndex = config.gdsconfigformslave.findIndex( - item => - commonUtils.isNotEmptyObject(item.sControlName) && - (item.sControlName.includes("BtnPopup") || item.sControlName.includes("BtnHeadPopup")) && - item.bVisible && - item.sDropDownType === "popup" - ); + const iIndex = config.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sControlName) && (item.sControlName.includes('BtnPopup') || item.sControlName.includes('BtnHeadPopup')) && item.bVisible && item.sDropDownType === 'popup'); if (iIndex > -1) { commonPopupConfig = config.gdsconfigformslave[iIndex]; - if (commonPopupShowConfig?.sControlName === "BtnPopupsAlumiteBomBillNo" || commonPopupShowConfig?.sControlName === "BtnChooseProcess") { + if(commonPopupShowConfig?.sControlName === 'BtnPopupsAlumiteBomBillNo' || commonPopupShowConfig?.sControlName === 'BtnChooseProcess') { commonPopupConfig = commonPopupShowConfig; - if (commonPopupShowConfig?.sControlName === "BtnChooseProcess") { + if(commonPopupShowConfig?.sControlName === 'BtnChooseProcess') { bCommonPopupProcess = true; } } - commonPopupTitle = - commonUtils.isNotEmptyObject(commonPopupConfig) && commonUtils.isNotEmptyObject(commonPopupConfig.sActiveName) - ? commonPopupConfig.sActiveName - : commonPopupTitle; - commonPopupTitle = commonUtils.isNotEmptyObject(commonPopupRecord) - ? commonPopupConfig.sActiveId === "1" - ? commonUtils.isEmpty(commonPopupRecord.sSrcFormName) - ? commonPopupTitle - : commonPopupRecord.sSrcFormName - : commonPopupTitle - : commonPopupTitle; - const sFormId = commonUtils.isNotEmptyObject(commonPopupRecord) - ? commonPopupConfig.sActiveId === "1" - ? commonUtils.isEmpty(commonPopupRecord.sFormId) - ? commonPopupRecord.sSrcFormId - : commonPopupRecord.sFormId - : commonPopupConfig.sActiveId - : commonPopupConfig.sActiveId; + commonPopupTitle = commonUtils.isNotEmptyObject(commonPopupConfig) && commonUtils.isNotEmptyObject(commonPopupConfig.sActiveName) ? commonPopupConfig.sActiveName : commonPopupTitle; + commonPopupTitle = commonUtils.isNotEmptyObject(commonPopupRecord) ? ( commonPopupConfig.sActiveId === '1' ? commonUtils.isEmpty(commonPopupRecord.sSrcFormName) ? commonPopupTitle : commonPopupRecord.sSrcFormName : commonPopupTitle ) : commonPopupTitle; + const sFormId = commonUtils.isNotEmptyObject(commonPopupRecord) ? ( commonPopupConfig.sActiveId === '1' ? commonUtils.isEmpty(commonPopupRecord.sFormId) ? commonPopupRecord.sSrcFormId : commonPopupRecord.sFormId : commonPopupConfig.sActiveId ) : commonPopupConfig.sActiveId; commonPopupProps = { app: { ...this.props.app, currentPane: { - name: "commonPopup", - bEdit: - commonUtils.isNotEmptyObject(app.currentPane) && - commonUtils.isNotEmptyObject(app.currentPane.route) && - app.currentPane.route.includes("commonBillDeliver"), + name: 'commonPopup', + bEdit: (commonUtils.isNotEmptyObject(app.currentPane) && commonUtils.isNotEmptyObject(app.currentPane.route) && app.currentPane.route.includes('commonBillDeliver')), config: commonPopupConfig, conditonValues: this.props.getSqlCondition(commonPopupConfig), - title: commonPopupTitle, - route: "/indexPage/commonList", - formRoute: "/indexPage/commonList", + title:commonPopupTitle, + route: '/indexPage/commonList', + formRoute: '/indexPage/commonList', formId: sFormId, key: sModelsId + commonPopupConfig.sId, - sModelsType: bCommonPopupProcess ? "search/commonProcess" : "search/commonPopup", - select: this.handleSelectCommonPopup, - selectCancel: this.handleSelectCancel.bind(this, "commonPopupVisible"), + sModelsType: bCommonPopupProcess ? 'search/commonProcess' : 'search/commonPopup', + select:this.handleSelectCommonPopup, + selectCancel: this.handleSelectCancel.bind(this, 'commonPopupVisible'), }, }, dispatch: this.props.dispatch, @@ -7938,57 +6858,38 @@ class CommonTableRc extends React.Component { id: randomId, onOpenNewTab: this.onOpenNewTab, outerMasterData: this.props.masterData, - realizeHeight: this.props.realizeHeight /* 拖动偏移高度 */, + realizeHeight: this.props.realizeHeight, /* 拖动偏移高度 */ }; } /* 多列弹出窗 */ - const commonPopupIndex = config.gdsconfigformslave.findIndex( - item => - commonUtils.isNotEmptyObject(item.sControlName) && - (item.sControlName.includes("BtnPopup") || item.sControlName.includes("BtnHeadPopup")) && - !["BtnPopup1"].includes(item.sControlName) && - !item.sControlName.startsWith("BtnPopupEdit") && - item.bVisible && - item.sDropDownType === "popup" - ); + const commonPopupIndex = config.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sControlName) && (item.sControlName.includes('BtnPopup') || item.sControlName.includes('BtnHeadPopup') ) && !['BtnPopup1'].includes(item.sControlName) && !item.sControlName.startsWith('BtnPopupEdit') && item.bVisible && item.sDropDownType === 'popup'); if (commonPopupIndex > -1) { bCommonPopup = true; } /* 单列弹出窗 */ - const commonPopupIndex1 = config.gdsconfigformslave.findIndex( - item => - commonUtils.isNotEmptyObject(item.sControlName) && - item.sControlName.includes("BtnPopup1") && - item.bVisible && - item.sDropDownType === "popup" - ); + const commonPopupIndex1 = config.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.includes('BtnPopup1') && item.bVisible && item.sDropDownType === 'popup'); if (commonPopupIndex1 > -1) { bCommonPopup1 = true; bCommonPopup = false; } /* commonListTree弹出窗 */ - const commonPopupIndexTree = config.gdsconfigformslave.findIndex( - item => - commonUtils.isNotEmptyObject(item.sControlName) && - item.sControlName === "BtnPopupListTree" && - item.bVisible && - item.sDropDownType === "popup" - ); + const commonPopupIndexTree = config.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName === 'BtnPopupListTree' && item.bVisible && item.sDropDownType === 'popup'); if (commonPopupIndexTree > -1) { bCommonPopupTree = true; } + } } /* 字段弹窗功能 */ let commonFieldPopupProps = {}; let bFieldPopup = true; /* 多列弹出窗 */ - let commonFieldPopupTitle = "选择弹窗"; - const commonFileDownloadTitle = "附件列表弹窗"; - const isBtnPopupEdit = this.state.commonFieldPopupShowConfig?.sControlName?.startsWith("BtnPopupEdit"); + let commonFieldPopupTitle = '选择弹窗'; + const commonFileDownloadTitle = '附件列表弹窗'; + const isBtnPopupEdit = this.state.commonFieldPopupShowConfig?.sControlName?.startsWith('BtnPopupEdit'); if (commonUtils.isNotEmptyObject(this.props)) { let commonFieldPopupConfig = {}; const { config, sModelsId } = this.props; @@ -7998,37 +6899,31 @@ class CommonTableRc extends React.Component { iIndex = 0; commonFieldPopupConfig = commonFieldPopupShowConfig; } else { - iIndex = config.gdsconfigformslave.findIndex( - item => commonUtils.isNotEmptyObject(item.sName) && (item.sDropDownType === "popup" || item.sDropDownType === "popupSingle") - ); + iIndex = config.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sName) && (item.sDropDownType === 'popup' || item.sDropDownType === 'popupSingle')); if (iIndex > -1) { commonFieldPopupConfig = config.gdsconfigformslave[iIndex]; } } if (iIndex > -1) { - if (commonFieldPopupConfig.sDropDownType === "popupSingle") { - /* 如果下拉类型是单列弹出窗 则为单列 */ + if(commonFieldPopupConfig.sDropDownType === 'popupSingle') { /* 如果下拉类型是单列弹出窗 则为单列 */ bFieldPopup = false; } - commonFieldPopupTitle = - commonUtils.isNotEmptyObject(commonFieldPopupConfig) && commonUtils.isNotEmptyObject(commonFieldPopupConfig.sActiveName) - ? commonFieldPopupConfig.sActiveName - : commonFieldPopupTitle; + commonFieldPopupTitle = commonUtils.isNotEmptyObject(commonFieldPopupConfig) && commonUtils.isNotEmptyObject(commonFieldPopupConfig.sActiveName) ? commonFieldPopupConfig.sActiveName : commonFieldPopupTitle; commonFieldPopupProps = { app: { ...this.props.app, currentPane: { - name: "commonPopup", + name: 'commonPopup', config: commonFieldPopupConfig, - title: commonFieldPopupTitle, - route: "/indexPage/commonList", - formRoute: "/indexPage/commonList", + title:commonFieldPopupTitle, + route: '/indexPage/commonList', + formRoute: '/indexPage/commonList', formId: commonFieldPopupConfig.sActiveId, key: sModelsId + commonFieldPopupConfig.sId, - sModelsType: "search/commonPopup", - select: this.handleSelectCommonFieldPopup, - selectCancel: this.handleSelectCancel.bind(this, "commonFieldPopupVisible"), + sModelsType: 'search/commonPopup', + select:this.handleSelectCommonFieldPopup, + selectCancel: this.handleSelectCancel.bind(this, 'commonFieldPopupVisible'), }, }, dispatch: this.props.dispatch, @@ -8036,20 +6931,16 @@ class CommonTableRc extends React.Component { id: randomId, onOpenNewTab: this.onOpenNewTab, outerMasterData: this.props.masterData, - realizeHeight: this.props.realizeHeight /* 拖动偏移高度 */, + realizeHeight: this.props.realizeHeight, /* 拖动偏移高度 */ }; - if (this.props.enabled && commonFieldPopupConfig?.sControlName?.includes("popupSingle_edit")) { - commonFieldPopupProps.app.currentPane.conditonValues = this.props.getSqlCondition( - commonFieldPopupConfig, - this.props.name, - commonFieldPopupShowRecord - ); + if (this.props.enabled && commonFieldPopupConfig?.sControlName?.includes('popupSingle_edit')) { + commonFieldPopupProps.app.currentPane.conditonValues = this.props.getSqlCondition(commonFieldPopupConfig, this.props.name, commonFieldPopupShowRecord); } else { commonFieldPopupProps.app.currentPane.conditonValues = this.props.getSqlCondition(commonFieldPopupConfig); } if (isBtnPopupEdit) { const selectData = tableProps.dataSource[this.rowClickRef.current] || {}; - const sMemoData = selectData?.[this.state.commonFieldPopupShowConfig?.sActiveKey] || "[]"; + const sMemoData = selectData?.[this.state.commonFieldPopupShowConfig?.sActiveKey] || '[]'; commonFieldPopupProps.app.sMemoData = JSON.parse(sMemoData); commonFieldPopupProps.app.originSlaveData = selectData; commonFieldPopupProps.app.currentPane.bEdit = isBtnPopupEdit; @@ -8059,42 +6950,33 @@ class CommonTableRc extends React.Component { } } + /* 蓝色链接弹Modal窗功能 */ let commonModalProps = {}; - let commonModalTitle = "查看"; + let commonModalTitle = '查看'; if (commonUtils.isNotEmptyObject(this.props)) { const { config, sModelsId, app, selectedRowKeys, enabled } = this.props; if (commonUtils.isNotEmptyObject(config)) { - commonModalTitle = - commonUtils.isNotEmptyObject(commonModalShowConfig) && commonUtils.isNotEmptyObject(commonModalShowConfig.sActiveName) - ? commonModalShowConfig.sActiveName - : commonModalTitle; - const sFormId = - commonUtils.isNotEmptyObject(commonModalRecord) && commonUtils.isNotEmptyObject(commonModalShowConfig) - ? commonModalShowConfig.sActiveId === "1" - ? commonUtils.isEmpty(commonModalRecord.sFormId) - ? commonModalRecord.sSrcFormId - : commonModalRecord.sFormId - : commonModalShowConfig.sActiveId - : commonModalShowConfig?.sActiveId; + commonModalTitle = commonUtils.isNotEmptyObject(commonModalShowConfig) && commonUtils.isNotEmptyObject(commonModalShowConfig.sActiveName) ? commonModalShowConfig.sActiveName : commonModalTitle; + const sFormId = commonUtils.isNotEmptyObject(commonModalRecord) && commonUtils.isNotEmptyObject(commonModalShowConfig) ? ( commonModalShowConfig.sActiveId === '1' ? commonUtils.isEmpty(commonModalRecord.sFormId) ? commonModalRecord.sSrcFormId : commonModalRecord.sFormId : commonModalShowConfig.sActiveId ) : commonModalShowConfig?.sActiveId; commonModalProps = { app: { ...this.props.app, currentPane: { - name: "commonModal", - bEdit: commonModalShowConfig?.sName === "dStockAuxiliaryQty" ? enabled : false, + name: 'commonModal', + bEdit: commonModalShowConfig?.sName === 'dStockAuxiliaryQty'? enabled:false, config: commonModalShowConfig, - conditonValues: commonModalShowConfig ? this.props.getSqlCondition(commonModalShowConfig, this.props.name, commonModalRecord) : {}, - title: commonModalTitle, - route: "/indexPage/commonList", - formRoute: "/indexPage/commonList", + conditonValues: commonModalShowConfig ? this.props.getSqlCondition(commonModalShowConfig, this.props.name, commonModalRecord) :{}, + title:commonModalTitle, + route: '/indexPage/commonList', + formRoute: '/indexPage/commonList', formId: sFormId, key: sModelsId + commonModalShowConfig?.sId, - sModelsType: "search/commonPopup", - select: this.handleSelectCommonPopup, - selectCancel: this.handleSelectCancel.bind(this, "commonModalVisible"), - slaveDataSource: commonModalShowConfig?.sName === "dStockAuxiliaryQty" ? [commonModalRecord] : [], + sModelsType: 'search/commonPopup', + select:this.handleSelectCommonPopup, + selectCancel: this.handleSelectCancel.bind(this, 'commonModalVisible'), + slaveDataSource :commonModalShowConfig?.sName === 'dStockAuxiliaryQty'? [commonModalRecord]: [], }, }, dispatch: this.props.dispatch, @@ -8102,29 +6984,30 @@ class CommonTableRc extends React.Component { id: randomId, onOpenNewTab: this.onOpenNewTab, outerMasterData: this.props.masterData, - realizeHeight: this.props.realizeHeight /* 拖动偏移高度 */, - bEdit: commonModalShowConfig?.sName === "dAvailableAuxiliaryQty" ? enabled : false, + realizeHeight: this.props.realizeHeight, /* 拖动偏移高度 */ + bEdit:commonModalShowConfig?.sName === 'dAvailableAuxiliaryQty'? enabled:false }; // if(commonModalShowConfig?.sName === 'dSumCompleteAvailableStockQty' ){ // commonModalProps.data = commonModalData; // } + } } + /* 表格可展开明细 */ - let slaveTableProps = ""; - let expandedRow = ""; - if (this.props.setExpandedRowRender !== undefined && this.props.setExpandedRowRender.toString() === "Y") { + let slaveTableProps = ''; + let expandedRow = ''; + if (this.props.setExpandedRowRender !== undefined && this.props.setExpandedRowRender.toString() === 'Y') { slaveTableProps = this.getSlaveTableProps(); - expandedRow = record => { + expandedRow = (record) => { let filterData = 0; - let columns = ""; + let columns = ''; let planLoading = false; - if (this.props.name === "slave" || location.pathname === "/indexPage/commonCostomTabBill") { - /* 过滤嵌套表 */ + if (this.props.name === 'slave' || location.pathname === '/indexPage/commonCostomTabBill') { /* 过滤嵌套表 */ /* 获取loading 加载状态 */ const planLoadingSate = this.props.slaveInfo.tableProps.planLoadingSate; - const planCurrentId = commonUtils.isNotEmptyObject(planLoadingSate) ? planLoadingSate.sId : ""; + const planCurrentId = commonUtils.isNotEmptyObject(planLoadingSate) ? planLoadingSate.sId : ''; if (record[this.rowKey] === planCurrentId) { planLoading = planLoadingSate.planLoading; } @@ -8133,32 +7016,26 @@ class CommonTableRc extends React.Component { columns = this.state.tableInfoColumn; const GetChildFilterData = this.props.onTableFilterData; if (GetChildFilterData !== undefined) { - const slaveInfoData = this.props.onTableFilterData("slave", AllData, record); + const slaveInfoData = this.props.onTableFilterData('slave', AllData, record); if (commonUtils.isNotEmptyArr(slaveInfoData) && slaveInfoData.length > 0) { filterData = slaveInfoData; } } } return ( -
- -
{ - this.myInfoDiv = ref; - }} - > +
+ +
{ this.myInfoDiv = ref; }}> @@ -8170,7 +7047,7 @@ class CommonTableRc extends React.Component { if (commonUtils.isNotEmptyArr(tableProps.columns)) { const lastColumn = tableProps.columns[tableProps.columns.length - 1]; - if (lastColumn.title && typeof lastColumn.title === "string" && lastColumn.title.indexOf("-") === -1) { + if (lastColumn.title && typeof lastColumn.title === 'string' && lastColumn.title.indexOf('-') === -1) { lastColumn.width && delete lastColumn.width; } } @@ -8183,7 +7060,7 @@ class CommonTableRc extends React.Component { bFullUrl: false, onCancel: () => { this.setState({ officePreviewVisible: false }); - }, + } }; let layoutScrollY; @@ -8196,335 +7073,260 @@ class CommonTableRc extends React.Component { layoutScrollY = this.props.fixedHeight; } let bShowBtnUpload = true; - if (commonUtils.isNotEmptyObject(this.props.masterData) && commonUtils.isNotEmptyObject(this.props.masterData.sZczlxShowName)) { - bShowBtnUpload = this.props.masterData.sZczlxShowName !== "删除" && this.props.masterData.sZczlxShowName !== "恢复"; + if(commonUtils.isNotEmptyObject(this.props.masterData) && commonUtils.isNotEmptyObject(this.props.masterData.sZczlxShowName)) { + bShowBtnUpload = this.props.masterData.sZczlxShowName !== '删除' && this.props.masterData.sZczlxShowName !== '恢复'; } const hasColorInfo = this.props?.masterConfig?.sTableColorTs; const BtnUpload = commonFunc.showLocalMessage(this.props, "BtnUpload", "上传"); - // 强制转换iorder - // tableProps.dataSource = tableProps.dataSource.sort((a, b) => { - // const hasA = a.hasOwnProperty("sName") && a.sName != null; - // const hasB = b.hasOwnProperty("sName") && b.sName != null; - // if (hasA && !hasB) return -1; - // if (!hasA && hasB) return 1; - - // // 2. bVisible 为 true 的在前 - // const visA = a.bVisible === true; - // const visB = b.bVisible === true; - // if (visA && !visB) return -1; - // if (!visA && visB) return 1; - - // // 3. 最后按 iOrder 升序 - // return a.iOrder - b.iOrder; - // }); - const list = tableProps.dataSource?.filter(x => x.sName); - - list.forEach((item, index) => { - if (item.iOrders === undefined || item.iOrders === null) { - // item.iOrder = (index + 1) * 10; - item.iOrders = item.iOrder; - item.isSettingFunctions = true; - } - }); - let newTableProps = cloneDeep(tableProps); - // 强制转换展示iOrder - if (this.props.isSettingFunctions) { - newTableProps.dataSource = newTableProps.dataSource.map((item, index) => { - item.iOrder = (index + 1) * 10; - item.iOrders = tableProps.dataSource[index].iOrder; - item.isSettingFunctions = true; - return item; - }); - } - // 排序 return ( - +
- {this.props.name === "picFile" || - (commonUtils.isNotEmptyObject(this.props.name) && this.props.name.indexOf("file") > -1) || - (this.props.name.startsWith("slave") && this.findIsUpdByControlName(this.props, "BtnUpload") && bShowBtnUpload) ? ( - - - - ) : null} + { + this.props.name === 'picFile' || (commonUtils.isNotEmptyObject(this.props.name) && this.props.name.indexOf('file') > -1) || + (this.props.name.startsWith('slave') && this.findIsUpdByControlName(this.props, 'BtnUpload') && bShowBtnUpload ) ? + + + + : null }
{ + className={`xlyCommonTable ${tableClassName} ${this.hasSpanBgColor ? 'tableNoPadding' : ''} ${this.props.enabled ? 'tableEnabled' : ''}` } + style={{ height: isSmall ? 'calc(100% - 44px)' : '' }} ref={(ref) => { this.mydiv = ref; if (this.mydiv) { this.computedTdWidth(); - if (false && commonUtils.isNotEmptyObject(location.pathname) && location.pathname.includes("commonListTab")) { - this.mydiv.getElementsByClassName("ant-table-body")[0].style.height = this.tableHeight ? this.tableHeight + "px" : 80 + "px"; + if (false && commonUtils.isNotEmptyObject(location.pathname) && location.pathname.includes('commonListTab')) { + this.mydiv.getElementsByClassName('ant-table-body')[0].style.height = this.tableHeight ? this.tableHeight + 'px': 80 + 'px'; } if (layoutScrollY) { - this.mydiv.getElementsByClassName("ant-table-body")[0].style.height = - typeof layoutScrollY === "number" ? layoutScrollY + "px" : layoutScrollY; + this.mydiv.getElementsByClassName('ant-table-body')[0].style.height = typeof layoutScrollY === 'number' ? layoutScrollY + 'px' : layoutScrollY; } } }} id={`table_${this.props.formId}_${this.props.config?.sId}`} > - {this.isDragAndDrop ? ( - -
- - ) : ( -
-
- - )} + { + this.isDragAndDrop ? + +
+ : +
+
+ + } - {hasColorInfo && ( - (this.colorInfo = e)}> - - - + { hasColorInfo && + this.colorInfo = e}> + - {tableProps.pagination && ( - { - this.onChange({ current: page, pageSize }); - }} - /> - )} + { tableProps.pagination && {this.onChange({ current: page, pageSize })}} + /> } - )} + } + - {previewVisible ? ( - -
- {/* 图片正常的列表显示 */} -
- {commonUtils.isNotEmptyArr(data) - ? data.map((item, i) => { - return ( - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions - example this.showimg(i)} key={item} /> - ); - }) - : ""} + { + previewVisible ? + +
+ {/* 图片正常的列表显示 */} +
+ {commonUtils.isNotEmptyArr(data) ? data.map((item, i) => { + return ( + // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions + example this.showimg(i)} + key={item} + /> + ); + }) : ''} +
+ {/* 引入的image组件s */} +
- {/* 引入的image组件s */} - -
- - ) : ( - "" - )} - {commonPopupVisible ? ( + + : '' + }{ + commonPopupVisible ? - {bCommonPopup ? ( + {bCommonPopup ? - ) : bCommonPopup1 ? ( - - ) : bCommonPopupTree ? ( - - ) : ( - "" - )} + : bCommonPopup1 ? + + : bCommonPopupTree ? + : '' + } - ) : ( - "" - )} - {commonFieldPopupVisible ? ( - - {[""].map(() => { - if (commonFieldPopupShowConfig.sControlName?.includes("popupSingle")) { - if (this.props.enabled && commonFieldPopupShowConfig.sControlName?.includes("edit")) { - commonFieldPopupProps.editable = true; + : '' + } + { + commonFieldPopupVisible ? + + {[''].map(() => { + if (commonFieldPopupShowConfig.sControlName?.includes("popupSingle")) { + if (this.props.enabled && commonFieldPopupShowConfig.sControlName?.includes("edit")) { + commonFieldPopupProps.editable = true; + } + return ; + } else { + return isBtnPopupEdit ? : bFieldPopup ? : ; } - return ; - } else { - return isBtnPopupEdit ? ( - - ) : bFieldPopup ? ( - - ) : ( - - ); - } - })} - - ) : ( - "" - )} + })} + + : '' + } - {commonModalVisible ? ( - - - - ) : ( - "" - )} + { + commonModalVisible ? + + + + : '' + } - {commonFileDownloadVisible ? ( - { - const newList = [...commonFileDownloadList]; - const checkState = newList.find(item => !item.checked); - newList.forEach(item => (item.checked = checkState)); - this.setState({ - commonFileDownloadList: newList, - }); - }} - > - 全选/取消全选 - , - , - , - ]} - > -
- {commonFileDownloadList.map(item => { - const { url, checked } = item; - const fileName = url.split("/").pop().split("_").pop(); - const fileType = fileName.split(".").pop().toLowerCase(); - const previewFileList = ["jpg", "png", "jepg", "webp", "svg", "bmp", "apng", "pdf"]; - return ( - -
- { - if (sessionStorage.previewFlag) { - sessionStorage.removeItem("previewFlag"); - } else { - const newList = [...commonFileDownloadList]; - newList.find(item => item.url === url).checked = e.target.checked; - this.setState({ - commonFileDownloadList: newList, - }); - } - }} - > - { + }>全选/取消全选, + , + , + ]} + > +
{ + commonFileDownloadList.map(item => { + const { url, checked } = item; + const fileName = url.split('/').pop().split('_').pop(); + const fileType = fileName.split('.').pop().toLowerCase(); + const previewFileList = ['jpg', 'png', 'jepg', 'webp', 'svg', 'bmp', 'apng', 'pdf']; + return ( + + - - ); - })} -
- - ) : ( - "" - )} - {pdfFileVisible ? ( - { - this.setState({ - pdfFileVisible: false, - }); - }} - > -
- -
-
- ) : ( - "" - )} - {bOperateMoreVisible ? ( - { - this.setState({ - bOperateMoreVisible: false, - }); - }} - > -
- -
-
- ) : ( - "" - )} + }} title="预览"> + {fileName} +
+
+
+ ) + }) + }
+
+ : '' + } + { + pdfFileVisible ? + { + this.setState({ + pdfFileVisible: false + }); + }} + > +
+ +
+
: '' + } + { + bOperateMoreVisible ? + { + this.setState({ + bOperateMoreVisible: false + }); + }} + > +
+ +
+
: '' + } {officePreviewVisible && } {/* 简单对话框 */} - {this.state.simpleModalVisible && ( - this.setState({ simpleModalVisible: false, simpleModalWord: "" })} - > -
- - )} + { this.state.simpleModalVisible && this.setState({ simpleModalVisible: false, simpleModalWord: '' })} + > +
+ } ); } } -const CommonTable = props => { +const CommonTable = (props) => { const { name, data = [] } = props; const [headerColumn, setHeaderColumn] = useState([]); const addState = {}; - if (name !== "master") { + if (name !== 'master') { const config = props.onMergeSlaveConfig && props.onMergeSlaveConfig(props.config); if (commonUtils.isNotEmptyObject(config)) { addState.config = config; @@ -8641,7 +7428,7 @@ const CommonTable = props => { }, [JSON.stringify(data)]); if (props.defaultExpandAllRows !== undefined && props.data === undefined) { - return ""; + return ''; } const handleMoveLine = ({ index, direction }) => { @@ -8660,11 +7447,11 @@ const CommonTable = props => { data[indexNew].iOrder = iOrder1; const tempItem = data[index]; - data[index] = { ...data[indexNew], handleType: data[indexNew].handleType || "update" }; - data[indexNew] = { ...tempItem, handleType: tempItem.handleType || "update" }; + data[index] = {...data[indexNew], handleType: data[indexNew].handleType || "update"}; + data[indexNew] = {...tempItem, handleType: tempItem.handleType || "update"}; props.onSaveState({ - [`${props.name}Data`]: data, + [`${props.name}Data`]: data }); }; @@ -8676,15 +7463,15 @@ const CommonTable = props => { delete props.tableProps.AutoTableHeight; } } - const setTempFixedHeight = height => { + const setTempFixedHeight = (height) => { sessionStorage.setItem(`${props.formId}_${props.config.sId}_tableHeight`, height); window.vlistNewSearh = true; setUpdateRowNumTime(pre => pre + 1); - }; + } const uniqueTableId = `table_${props.formId}_${props.config?.sId}`; return ( - + @@ -8694,12 +7481,12 @@ const CommonTable = props => { const handleSetIRowNum = (data, props) => { data.forEach((item, index) => { item.iRowNum = index + 1; - if (["12710101117007068710620"].includes(props?.app?.currentPane?.formId)) { + if (['12710101117007068710620'].includes(props?.app?.currentPane?.formId)) { item.sVersionNum = item.iRowNum.toString().padStart(2, 0); } // 排除成品盘点、材料盘点(数据太多,循环页面卡死) - if (props.name === "slaveChild" && !["192116810113315264733417750", "192116810113315228128521360"].includes(props?.app?.currentPane?.formId)) { + if (props.name === 'slaveChild' && !['192116810113315264733417750', '192116810113315228128521360'].includes(props?.app?.currentPane?.formId)) { /* 序号根据sSqlConditonId分组 序号重排 */ const groupedData = commonUtils.groupBy(data, item => item.sSqlConditionId); if (commonUtils.isNotEmptyObject(groupedData)) { @@ -8708,26 +7495,28 @@ const handleSetIRowNum = (data, props) => { if (commonUtils.isNotEmptyArr(eachData)) { eachData.forEach((item, index) => { /* 采购 */ - item.iRowNum = index + 1; + item.iRowNum = index +1; const iIndex = data.findIndex(row => row.sId === item.sId); - if (iIndex > -1) { - data[iIndex] = { ...data[iIndex], iRowNum: index + 1 }; + if(iIndex > -1) { + data[iIndex] ={...data[iIndex], iRowNum: index +1} } + }); } } } } - if (location.pathname !== "/indexPage/commonClassify") { + if(location.pathname !== '/indexPage/commonClassify'){ if (commonUtils.isNotEmptyArr(item.children)) { handleSetIRowNum(item.children, props); } } }); -}; +} -const MoveLineComponent = props => { - if (!location.pathname.includes("commonSubBill")) { +const MoveLineComponent = (props) => { + + if (!location.pathname.includes('commonSubBill')) { return ""; } @@ -8742,28 +7531,28 @@ const MoveLineComponent = props => { const initialBottom = position.bottom; const initialY = e.clientY; - const moveHandler = moveEvent => { + const moveHandler = (moveEvent) => { const newY = moveEvent.clientY; const newBottom = initialBottom - (newY - initialY); setPosition({ bottom: newBottom }); }; const upHandler = () => { - const preHeight = document.querySelector(`#${props.uniqueTableId}`).querySelector(".ant-table-body").getBoundingClientRect().height; + const preHeight = document.querySelector(`#${props.uniqueTableId}`).querySelector('.ant-table-body').getBoundingClientRect().height; props.setTempFixedHeight(Math.max(preHeight - positionRef.current.bottom, 37)); setPosition({ bottom: 0 }); document.body.onselectstart = () => true; - document.removeEventListener("mousemove", moveHandler); - document.removeEventListener("mouseup", upHandler); + document.removeEventListener('mousemove', moveHandler); + document.removeEventListener('mouseup', upHandler); }; document.body.onselectstart = () => false; - document.addEventListener("mousemove", moveHandler); - document.addEventListener("mouseup", upHandler); - }, + document.addEventListener('mousemove', moveHandler); + document.addEventListener('mouseup', upHandler); + } }; return
; -}; +} export default CommonTable;