/* eslint-disable */ /* eslint-disable react/no-multi-comp,key-spacing,space-in-parens */ /* eslint-disable guard-for-in */ /* eslint-disable no-undef,import/first,prefer-destructuring,jsx-a11y/alt-text */ /* eslint-disable react/no-array-index-key */ /* eslint-disable react/jsx-closing-tag-location */ /* eslint-disable */ import React, { useEffect, useRef, useState } from "react"; import { CheckCircleFilled, ClockCircleFilled, CloseCircleFilled, DownloadOutlined, ExclamationCircleFilled, RightOutlined, SearchOutlined, StopFilled, UploadOutlined, EyeOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, ExportOutlined, FileOutlined, FileSearchOutlined, ClearOutlined, PlusOutlined, MinusOutlined, CopyOutlined, FormOutlined, CaretUpOutlined, CaretDownOutlined, SaveOutlined } from "@ant-design/icons"; import { Icon as LegacyIcon } from "@ant-design/compatible"; import "@ant-design/compatible/assets/index.css"; import lodash, { cloneDeep } from "lodash"; import { Table, Input, Checkbox, Button, Upload, message, Popover, Spin, Space, Form, Tooltip, Row, Progress, Modal } from "antd"; 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 * as 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 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 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 AffixOeeMenu from "@/oee/common/AffixOeeMenu"; // import { VList } from 'virtuallist-antd'; /* 获取配置及数据 */ const FormItem = Form.Item; const ResizeableTitle = props => { const { onResize, width, ...restProps } = props; if (!width) { return ; } return ( { e.stopPropagation(); }} key={lodash.uniqueId()} /> } onResize={onResize} draggableOpts={{ enableUserSelectHack: false }} > ); }; let dragingIndex = -1; // 用于设置拖拽Row时样式 let moverow = null; // 定义move事件,解决warn const BodyRow = props => { const { isOver, connectDragSource, connectDropTarget, move, ...restProps } = props; moverow = move; const ref = useRef(null); const style = { ...restProps.style, cursor: "move" }; let { className } = restProps; if (isOver) { if (restProps.index > dragingIndex) { className += " drop-over-downward"; } if (restProps.index < dragingIndex) { className += " drop-over-upward"; } } connectDragSource(connectDropTarget(ref)); return ; }; // DragSource 拖拽事件的方法对象 const rowSource = { beginDrag(props) { const dragingKey = props["data-row-key"]; dragingIndex = props.index; return { "data-row-key": dragingKey, index: props.index }; // dragingIndex = props.index; // return { // index: props.index, // }; } }; // DropTarget 拖拽事件的方法对象 const rowTarget = { drop(props, monitor) { const dragIndex = monitor.getItem().index; const hoverIndex = props.index; const dragKey = monitor.getItem()["data-row-key"]; const hoverKey = props["data-row-key"]; if (dragKey === hoverKey) { return; } props.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); monitor.getItem().index = hoverIndex; monitor.getItem()["data-row-key"] = hoverKey; } }; const DragableBodyRow = DropTarget("row", rowTarget, (connect, monitor) => ({ connectDropTarget: connect.dropTarget(), isOver: monitor.isOver() }))( DragSource("row", rowSource, connect => ({ connectDragSource: connect.dragSource() }))(BodyRow) ); /* ================================================================== */ class CommonTableRc extends React.Component { /** 构造函数 */ constructor(props) { super(props); this.state = { navigation: "navigation", previewVisible: false /* 图片预览弹窗 */, previewImage: "" /* 预览图片地址 */, headerColumn: [] /* 表头信息(数据类型:数组对象) */, slaveInfoHeaderColumn: [] /* 表头信息(数据类型:数组对象) */, tableColumn: [] /* table的表头信息(数据类型:数组对象) */, tableInfoColumn: [], slaveInfoTableColumn: [], selectedRowKeys: [] /* 已选择的数据行(数据格式:数组) */, slaveInfoSelectedRowKeys: [], dataSource: [] /* 数据(数据格式:数组对象) */, totalData: [] /* 总计数据 */, totalData1: [] /* 总计数据1 */, enabled: false /* 是否为编辑 */, filteredValue: [] /* 过滤数据值 */, expKeys: [] /* 展开数据行(数据格式:数组) */, showimgs: false, // 必须字段控制弹框显示隐藏 firstIndex: 0, // 点击时默认下标 commonPopupVisible: false, commonFieldPopupVisible: false, openNewTabFlag: false, // 是否因在弹窗中打开新页签离开本页; randomId: commonUtils.createSid(), realizeHeight: 0, tableClassName: "table_" + commonUtils.createSid(), commonFileDownloadVisible: false, // 多文件下载弹窗 commonFileDownloadList: [], // 多文件列表 pdfFileVisible: false, // pdf文件弹窗 pdfFileUrl: "", currentHoverSid: "" }; this.rowKey = commonUtils.isNotEmptyObject(props.tableProps) && !commonUtils.isEmpty(props.tableProps.rowKey) ? props.tableProps.rowKey : "sId"; /* 表格主键 */ this.config = {}; /* 配置信息(基础)(数据格式:对象) */ this.tableColumn = []; /* table的表头信息(数据类型:数组对象) */ this.tableInfoColumn = []; this.scrollX = 0; /* 表格宽度统计值(数据格式:整形) */ this.scrollY = this.props.tableProps ? this.props.tableProps.AutoTableHeight ? this.props.tableProps.AutoTableHeight : 0 : 0; this.scrollInfoX = 0; /* 表格宽度统计值(数据格式:整形) */ this.formId = ""; /* 窗体Id(数据格式:字符串) */ this.sId = ""; /* 表格Id(数据格式:字符串) */ this.isUploadShow = false; /* 是否显示上传控件(数据格式:布尔) */ this.isDownloadShow = false; /* 是否显示上传控件(数据格式:布尔) */ this.isLookShow = false; /* 是否显示查看控件(数据格式:布尔) */ this.isAddShow = false; /* 是否显示添加控件(数据格式:布尔) */ this.isModalShow = false; /* 是否显示modal控件(数据格式:布尔) */ this.isModalRemarkShow = false; /* 是否显示材料备注控件(数据格式:布尔) */ this.isChooseProcessShow = false; /* 是否显示选择工序控件(数据格式:布尔) */ this.isCopyShow = false; /* 是否显示复制控件(数据格式:布尔) */ this.isCopyAllShow = false; /* 是否显示复制全部控件(数据格式:布尔) */ this.isDelShow = false; /* 是否显示删除控件(数据格式:布尔) */ this.isPopupShow = false; /* 是否显示弹窗控件(数据格式:布尔) */ this.isParamShow = false; /* 是否显示弹窗控件(数据格式:布尔) */ this.isChooseProductProcess = false; /* 是否显示成品工序控件(数据格式:布尔) */ this.isChooseProductMaterials = false; /* 是否显示成品材料控件(数据格式:布尔) */ // this.onUploadChange = () => {}; /* 上传后执行函数(数据格式:函数) */ this.initColumn = null; this.finalColumn = null; this.droping = false; this.resize = false; this.isDragAndDrop = false; this.tableContentWidth = 0; this.tableInfoContentWidth = 0; this.mergeCellListMap = {}; // 合并单元格map; this.mergeCellStateMap = {}; // 是否合并单元格map this.mergeInfoCellListMap = {}; this.mergeInfoCellStateMap = {}; // this.beSelectDropdownOpen = false; this.uniqueId = null; // 虚拟列表vid this.hasMergeHeader = false; // 判断是否包含合并表头 this.sticky = this.props.tableProps.sticky ? this.props.tableProps.sticky : false; this.sortRendered = false; this.tableHeight = 0; this.DraggableContainer = null; this.DraggableBodyRow = null; this.curSlaveInfoData = []; this.slaveInfoHeaderMap = {}; this.mergeCellList = []; this.tableFilterData = []; this.pathname = ""; this.hasSpanBgColor = false; // 是否有span背景色 this.curPagination = {}; // 当前分页数据 this.selectedRowKeysOld = []; // 记录选中数据 this.tableId = this.props.tableId; // this.bInTableKeyTime = false; } /** 渲染前只执行一次 */ componentWillMount() { /* state和this属性赋值s */ this.mounted = true; this.assignmentWillProps(this.props); } componentDidMount() { /* 获取ant-table-body宽度 */ if (!commonUtils.isEmptyObject(this.mydiv)) { if (!this.tableContentWidth) { this.tableContentWidth = this.mydiv.offsetWidth; } } // 处理表单详情的tableWidth if (!commonUtils.isEmptyObject(this.myInfoDiv)) { if (!this.tableInfoContentWidth) { this.tableInfoContentWidth = this.myInfoDiv.offsetWidth; } } if (this.props.onRenderFinish) { this.props.onRenderFinish(); } window.addEventListener("resize", () => { this.computedTableHeight(); // this.computedTdWidth(true); this.forceUpdate(); }); if (this.tableId) { window[`${this.tableId}FieldPopupModal`] = this.handleFieldPopupModal; } document.addEventListener("mouseover", this.handleLastTdMouseOver); document.addEventListener("keydown", this.handleTableKeyDown); } componentDidUpdate() { if ( this.props.app && this.props.app.currentPane && (this.props.app.currentPane.route.indexOf("commonList") !== -1 || this.props.app.currentPane.route.indexOf("productionScheduleTree") !== -1) ) { if (this.tableHeight !== "100%" && this.tableHeight !== 0) { if (this.props.name !== "report") { this.mydiv.getElementsByClassName( "ant-table-body" )[0].style.height = this.tableHeight ? this.tableHeight + "px" : 80 + "px"; } } } let divs = document.getElementsByClassName("noInputInsert"); if (divs.length) { Array.prototype.forEach.call(divs, item => { item.parentNode.parentNode.parentNode.parentNode.classList.add( "insertTd" ); }); } // 判断树形表格展开/收起全部按钮是否在第一个column上 const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (this.showExpAll && oTable) { const getTh = dom => { if (!dom) { return false; } if (dom.nodeName === "TH") { return dom; } else { return getTh(dom.parentNode); } }; const oHeader = oTable.querySelector(".ant-table-header"); const oThDivs = oHeader.querySelectorAll(".th-div"); const oThs = Array.from(oThDivs).map(item => getTh(item)); // const oThs = oHeader.querySelectorAll('th[tabindex]'); const oExpAllIcon = oHeader.querySelector(".table-expAllIcon"); if (oExpAllIcon) { const oTh = getTh(oExpAllIcon); if (oTh) { const index = [].indexOf.call(oThs, oTh); if (index > 0) { const oFirstThDiv = oHeader.querySelector(".th-div"); oFirstThDiv && oFirstThDiv.prepend(oExpAllIcon); } } } } } /** props改变的时候触发s */ componentWillReceiveProps(nextProps) { /* state和this属性赋值 */ this.assignmentWillProps(nextProps); // 等待加载完成后计算宽度s if (!commonUtils.isEmptyObject(this.mydiv)) { if (!this.tableContentWidth) { this.tableContentWidth = this.mydiv.offsetWidth; } } if (!commonUtils.isEmptyObject(this.myInfoDiv)) { if (!this.tableInfoContentWidth) { this.tableInfoContentWidth = this.myInfoDiv.offsetWidth; } } if (this.state.openNewTabFlag && this.pathname === location.pathname) { const dom = document.getElementsByClassName( `${this.state.randomId}-CommonListSelectTree` )[0]; dom.parentElement.parentElement.style.display = "block"; this.setState({ openNewTabFlag: false }); } } /** 返回true执行渲染,返回false不渲染 */ shouldComponentUpdate(nextProps, nextState) { const { headerColumn, tableColumn, dataSource, totalData, totalData1, selectedRowKeys, enabled, filteredValue, previewVisible, previewImage, slaveInfoSelectedRowKeys, slaveInfo, expKeys, commonPopupVisible, commonFieldPopupVisible, realizeHeight } = this.state; // if (this.props.data?.length !== nextProps.data?.length) { // this.bInTableKeyTime = true; // clearTimeout(this.tableTimer); // this.tableTimer = setTimeout(() => { // this.bInTableKeyTime = false; // }, 1000); // } return ( this.props.updateRowNumTime !== nextState.updateRowNumTime || enabled !== nextState.enabled || JSON.stringify(this.props.isDragAndDrop) !== JSON.stringify(nextProps.isDragAndDrop) || // JSON.stringify(headerColumn) !== JSON.stringify(nextState.headerColumn) || JSON.stringify(this.props.config) !== JSON.stringify(nextProps.config) || JSON.stringify(tableColumn) !== JSON.stringify(nextState.tableColumn) || JSON.stringify(dataSource) !== JSON.stringify(nextState.dataSource) || JSON.stringify(totalData) !== JSON.stringify(nextState.totalData) || JSON.stringify(totalData1) !== JSON.stringify(nextState.totalData1) || JSON.stringify(selectedRowKeys) !== JSON.stringify(nextState.selectedRowKeys) || JSON.stringify(slaveInfoSelectedRowKeys) !== JSON.stringify(nextState.slaveInfoSelectedRowKeys) || JSON.stringify(expKeys) !== JSON.stringify(nextState.expKeys) || JSON.stringify(previewVisible) !== JSON.stringify(nextState.previewVisible) || JSON.stringify(commonPopupVisible) !== JSON.stringify(nextState.commonPopupVisible) || JSON.stringify(commonFieldPopupVisible) !== JSON.stringify(nextState.commonFieldPopupVisible) || JSON.stringify(previewImage) !== JSON.stringify(nextState.previewImage) || JSON.stringify(filteredValue) !== JSON.stringify(nextState.filteredValue) || JSON.stringify(this.props.tableProps.pagination) !== JSON.stringify(nextProps.tableProps.pagination) || // JSON.stringify(this.props.tableProps.AutoTableHeight) !== JSON.stringify(nextProps.tableProps.AutoTableHeight) || JSON.stringify(nextProps.slaveInfo) !== slaveInfo || JSON.stringify(nextProps.realizeHeight) !== realizeHeight || this.props.tableProps.newButton !== nextProps.tableProps.newButton ); } componentWillUnmount() { this.mounted = false; window.removeEventListener("resize", () => { this.computedTableHeight(); this.forceUpdate(); }); document.removeEventListener("mouseover", this.handleLastTdMouseOver); document.removeEventListener("keydown", this.handleTableKeyDown); if (this.tableId && window[`${this.tableId}FieldPopupModal`]) { delete window[`${this.tableId}FieldPopupModal`]; } } handleLastTdMouseOver = event => { if ( event.target.classList.contains("react-resizable-handle") && event.target.parentNode.getAttribute("bnotresize") === "bNotResize" ) { const oBody = this.mydiv.querySelector(".ant-table-body"); const { scrollWidth, clientWidth } = oBody; const oResizable = event.target; if (scrollWidth === clientWidth) { oResizable.style.cursor = "default"; return; } this.lastTdMouseOver = true; let minLeft, maxLeft, diffx; oResizable.style.cursor = "col-resize"; const tempDom = document.createElement("div"); const mask = document.createElement("div"); mask.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; z-index: 9999;"; const resizableMousemove = e => { const { clientX } = e; const left = Math.min(Math.max(minLeft, clientX), maxLeft + 200); diffx = left - maxLeft; if (diffx < 0) { diffx = Math.max(diffx, clientWidth - scrollWidth); } Object.assign(tempDom.style, { left: left + "px" }); }; const resizableMouseup = () => { this.lastTdMouseOver = false; document.body.removeChild(mask); document.body.removeChild(tempDom); document.removeEventListener("mouseup", resizableMouseup); document.removeEventListener("mousemove", resizableMousemove); const { tableColumn, headerColumn } = this.state; const sessionColumn = sessionStorage.getItem( `${this.props.formId}_${this.props.config.sId}` ); const column = sessionColumn ? JSON.parse(sessionColumn) : tableColumn; const lastIndex = column.findIndex(item => item.dataIndex === "tableLastEmpty") - 1; if (lastIndex > -1 && diffx !== 0) { const headerColumnNew = [...headerColumn]; const columnNew = [...column]; if (commonUtils.isNotEmptyArr(columnNew[lastIndex].children)) { const lastChildIndex = columnNew[lastIndex].children.length - 1; columnNew[lastIndex].children[lastChildIndex].width += diffx; if (columnNew[lastIndex].children[lastChildIndex].widthExtra) { columnNew[lastIndex].children[lastChildIndex].widthExtra += diffx; } else { columnNew[lastIndex].children[lastChildIndex].widthExtra = diffx; } if (columnNew[lastIndex].children[lastChildIndex].widthExtra < 0) { columnNew[lastIndex].children[lastChildIndex].widthExtra = 0; } const headerIndex = headerColumnNew.findIndex( item => item.dataIndex === columnNew[lastIndex].children[lastChildIndex].dataIndex ); if (headerIndex !== -1) { headerColumnNew[headerIndex].width = columnNew[lastIndex].children[lastChildIndex].width; headerColumnNew[headerIndex].widthExtra = columnNew[lastIndex].children[lastChildIndex].widthExtra; } } else { columnNew[lastIndex].width += diffx; if (columnNew[lastIndex].widthExtra) { columnNew[lastIndex].widthExtra += diffx; } else { columnNew[lastIndex].widthExtra = diffx; } if (columnNew[lastIndex].widthExtra < 0) { columnNew[lastIndex].widthExtra = 0; } const headerIndex = headerColumnNew.findIndex( item => item.dataIndex === columnNew[lastIndex].dataIndex ); if (headerIndex !== -1) { headerColumnNew[headerIndex].width = columnNew[lastIndex].width; headerColumnNew[headerIndex].widthExtra = columnNew[lastIndex].widthExtra; } } sessionStorage.setItem( `${this.props.formId}_${this.props.config.sId}`, JSON.stringify(columnNew) ); this.props.onSaveState({ headerColumn: headerColumnNew, tableColumn: columnNew }); } }; oResizable.onmousedown = () => { const { y, height } = event.target.getBoundingClientRect(); minLeft = event.target.parentNode.getBoundingClientRect().x + 50; maxLeft = event.target.parentNode.getBoundingClientRect().x + event.target.parentNode.getBoundingClientRect().width; Object.assign(tempDom.style, { width: "2px", height: height + "px", background: "#1990ff", top: y + "px", left: maxLeft + "px", position: "absolute", zIndex: 9999, cursor: "col-resize" }); document.body.append(mask); document.body.append(tempDom); document.removeEventListener("mouseup", resizableMouseup); document.addEventListener("mouseup", resizableMouseup); document.removeEventListener("mousemove", resizableMousemove); document.addEventListener("mousemove", resizableMousemove); }; } }; handleTableKeyDown = event => { if ( event.ctrlKey && (event.altKey || event.metaKey) && event.keyCode === 83 && this.bMouseEnter ) { // ctrl+alt+s 弹出表格布局 event.preventDefault(); // 阻止默认的保存行为,如果有的话 this.setState({ affixMenuVisible: true }); } else if ( event.ctrlKey && (event.altKey || event.metaKey) && event.keyCode === 78 && this.bMouseEnter ) { // ctrl+alt+n 显示表格名 event.preventDefault(); // 阻止默认的保存行为,如果有的话 message.info(this.props.name); } }; /** 列拖动s */ onHeaderCell = (isSlaveInfo, index, column) => { let columns; if (isSlaveInfo) { columns = this.state.tableInfoColumn.slice(0); } else { columns = this.state.tableColumn.slice(0); } // 最后一列禁止拖动 let bNotResize = false; const lastIndex = columns.findIndex(item => item.dataIndex === "tableLastEmpty") - 1; if (lastIndex > -1) { if (commonUtils.isNotEmptyArr(columns[lastIndex].children)) { if ( columns[lastIndex].children[columns[lastIndex].children.length - 1] .dataIndex === column.dataIndex ) { bNotResize = true; } } else if (columns[lastIndex].dataIndex === column.dataIndex) { bNotResize = true; } } return { width: column.width, onResize: !bNotResize ? this.handleResize(index, column, isSlaveInfo) : null, bnotresize: bNotResize ? "bNotResize" : null, onClick: () => {}, onMouseDown: () => { if (this.lastTdMouseOver) { return; } const tableColumn = isSlaveInfo ? this.state.tableInfoColumn : this.state.tableColumn; for (const m in tableColumn) { if (commonUtils.isNotEmptyArr(columns[m].children)) { // 如果是双层表头 const initColumnIndex = columns[m].children.findIndex( item => item.dataIndex === column.dataIndex ); if (initColumnIndex !== -1) { this.initColumn = columns[m].children[initColumnIndex]; this.droping = true; this.bInitColumnMuti = true; // 拖动对象是多表头下的子表头 break; } } else if (columns[m].dataIndex === column.dataIndex) { this.initColumn = columns[m]; this.droping = true; this.bInitColumnMuti = false; break; } } }, onMouseEnter: () => { if (this.resize) { this.droping = false; return false; } else if (this.resize === false) { if (!commonUtils.isEmpty(this.initColumn) && this.droping) { this.setState(() => { for (const i in columns) { if (commonUtils.isNotEmptyArr(columns[i].children)) { for (const j in columns[i].children) { if (columns[i].children[j].dataIndex === column.dataIndex) { columns[i].children[j] = { ...columns[i].children[j], className: "hover-droping-cell" }; } else { columns[i].children[j] = { ...columns[i].children[j], className: "" }; } } } else if (columns[i].dataIndex === column.dataIndex) { columns[i] = { ...columns[i], className: "hover-droping-cell" }; } else { columns[i] = { ...columns[i], className: "" }; } } // const sortArr = columns.map(item => item.dataIndex); let sortArr = []; columns.forEach(item => { if (item.children) { item.children.forEach(child => { sortArr.push(child.dataIndex); }); } else { sortArr.push(item.dataIndex); } }); if (isSlaveInfo) { sessionStorage.setItem( `${this.props.formId}_${ this.props.config.sId }_info_headerColumns`, JSON.stringify(sortArr) ); return { tableInfoColumn: columns }; } else { sessionStorage.setItem( `${this.props.formId}_${this.props.config.sId}_headerColumns`, JSON.stringify(sortArr) ); return { tableColumn: columns }; } }); } else { this.droping = false; } } }, onMouseUp: () => { let spliceIndex = null; const sortItems = []; if ( this.droping && !commonUtils.isEmpty(this.initColumn) && this.initColumn.dataIndex !== column.dataIndex ) { const bTargetMuti = columns.findIndex(item => item.dataIndex === column.dataIndex) === -1; // 移动到的目标是否是多表头 if (!this.bInitColumnMuti && !bTargetMuti) { // 拖拽对象【单表头】、移动到的目标【单表头】 for (const i in columns) { columns[i].className = ""; if (columns[i].dataIndex === this.initColumn.dataIndex) { columns.splice(i, 1); spliceIndex = columns.findIndex( item => item.dataIndex === column.dataIndex ); columns.splice(spliceIndex, 0, this.initColumn); sortItems.push(this.initColumn.dataIndex); sortItems.push(column.dataIndex); } } } else if (!this.bInitColumnMuti && bTargetMuti) { // 拖拽对象【单表头】、移动到的目标【双表头】 let iIndexArr = []; // 获取拖拽对象index const initColumnIndex = columns.findIndex( item => item.dataIndex === this.initColumn.dataIndex ); // 获取目标index for (const i in columns) { const children = columns[i].children; if (commonUtils.isNotEmptyArr(children)) { const iIndex = children.findIndex( item => item.dataIndex === column.dataIndex ); if (iIndex !== -1) { columns[i].children[iIndex].className = ""; iIndexArr = [i, iIndex]; break; } } } if (initColumnIndex !== -1) { // 去除拖拽对象数组 columns.splice(initColumnIndex, 1); // 目标对象index spliceIndex = iIndexArr[0]; if (spliceIndex >= initColumnIndex) { spliceIndex -= 1; } if (iIndexArr[1] === 0) { //如果目标对象是第一个 // 将拖拽对象插入到目标对象前面 columns.splice(spliceIndex, 0, this.initColumn); } else if (iIndexArr[1] > 0) { // 如果目标对象不是第一个 // 取出目标对象数组 const targetColumn = columns.splice(spliceIndex, 1)[0]; const column1 = { ...targetColumn, children: targetColumn.children.filter( (item, index) => index < iIndexArr[1] ) }; const column2 = { ...targetColumn, children: targetColumn.children.filter( (item, index) => index >= iIndexArr[1] ) }; columns.splice( spliceIndex, 0, column1, this.initColumn, column2 ); } } } else if (this.bInitColumnMuti && !bTargetMuti) { // 拖拽对象【双表头】、移动到的目标【单表头】 // 获取拖拽对象index let initColumnIndexArr = []; for (const i in columns) { if (commonUtils.isNotEmptyArr(columns[i].children)) { const iIndex = columns[i].children.findIndex( child => child.dataIndex === this.initColumn.dataIndex ); if (iIndex !== -1) { initColumnIndexArr = [i, iIndex]; break; } } } if (commonUtils.isNotEmptyArr(initColumnIndexArr)) { spliceIndex = columns.findIndex( item => item.dataIndex === column.dataIndex ); columns[spliceIndex].className = ""; if (columns[initColumnIndexArr[0]].children.length === 1) { const initColumnParent = columns.splice( initColumnIndexArr[0], 1 )[0]; columns.splice(spliceIndex, 0, initColumnParent); } else { const newColumn = { ...columns[initColumnIndexArr[0]], children: [ columns[initColumnIndexArr[0]].children[ initColumnIndexArr[1] ] ] }; columns[initColumnIndexArr[0]].children = columns[ initColumnIndexArr[0] ].children.filter( item => item.dataIndex !== newColumn.children[0].dataIndex ); columns.splice(spliceIndex, 0, newColumn); } } } else { // 拖拽对象【双表头】、移动到的目标【双表头】 // 获取拖拽对象index let initColumnIndexArr = []; for (const i in columns) { if (commonUtils.isNotEmptyArr(columns[i].children)) { const iIndex = columns[i].children.findIndex( child => child.dataIndex === this.initColumn.dataIndex ); if (iIndex !== -1) { initColumnIndexArr = [i, iIndex]; break; } } } let iIndexArr = []; // 获取目标index for (const i in columns) { const children = columns[i].children; if (commonUtils.isNotEmptyArr(children)) { const iIndex = children.findIndex( item => item.dataIndex === column.dataIndex ); if (iIndex !== -1) { columns[i].children[iIndex].className = ""; iIndexArr = [i, iIndex]; break; } } } if ( commonUtils.isNotEmptyArr(initColumnIndexArr) && commonUtils.isNotEmptyArr(iIndexArr) ) { if (initColumnIndexArr[0] === iIndexArr[0]) { // 同一个一级表头 columns[initColumnIndexArr[0]].children.splice( initColumnIndexArr[1], 1 ); spliceIndex = columns[initColumnIndexArr[0]].children.findIndex( item => item.dataIndex === column.dataIndex ); columns[initColumnIndexArr[0]].children.splice( spliceIndex, 0, this.initColumn ); } else { // 不同的一级表头 const newColumn = { ...columns[initColumnIndexArr[0]], children: [ columns[initColumnIndexArr[0]].children[ initColumnIndexArr[1] ] ] }; if (iIndexArr[1] === 0) { // 最前面 columns[initColumnIndexArr[0]].children.splice( initColumnIndexArr[1], 1 ); spliceIndex = iIndexArr[0]; if (columns[initColumnIndexArr[0]].children.length === 0) { // 剩下的二层表头为空 columns.splice(initColumnIndexArr[0], 1); spliceIndex = initColumnIndexArr[0] < spliceIndex ? spliceIndex - 1 : spliceIndex; } columns.splice(spliceIndex, 0, newColumn); } else { // 插到其它二级表头中间 columns[initColumnIndexArr[0]].children.splice( initColumnIndexArr[1], 1 ); spliceIndex = iIndexArr[0]; if (columns[initColumnIndexArr[0]].children.length === 0) { // 剩下的二层表头为空 columns.splice(initColumnIndexArr[0], 1); spliceIndex = initColumnIndexArr[0] < spliceIndex ? spliceIndex - 1 : spliceIndex; } const targetColumn = columns.splice(spliceIndex, 1)[0]; const column1 = { ...targetColumn, children: targetColumn.children.filter( (item, index) => index < iIndexArr[1] ) }; const column2 = { ...targetColumn, children: targetColumn.children.filter( (item, index) => index >= iIndexArr[1] ) }; columns.splice(spliceIndex, 0, column1, newColumn, column2); } } } } // 合并一级表头相同的相邻的column columns = columns.reduce((prev, cur) => { if (prev.length) { const prevColumn = prev[prev.length - 1]; if ( commonUtils.isNotEmptyArr(prevColumn.children) && commonUtils.isNotEmptyArr(cur.children) && prevColumn.title === cur.title ) { prevColumn.children = [...prevColumn.children, ...cur.children]; prev[prev.length - 1] = prevColumn; return prev; } else { prev.push(cur); return prev; } } else { prev.push(cur); return prev; } }, []); this.tableInfoColumn = columns; let sortArr = []; columns.forEach(item => { if (item.children) { item.children.forEach(child => { sortArr.push(child.dataIndex); }); } else { sortArr.push(item.dataIndex); } }); if (isSlaveInfo) { this.setState({ tableInfoColumn: columns }, () => { sessionStorage.setItem( `${this.props.formId}_${ this.props.config.sId }_info_headerColumns`, JSON.stringify(sortArr) ); this.initColumn = null; this.droping = false; }); this.handleSaveOrder(sortItems, isSlaveInfo); } else { this.setState({ tableColumn: columns }, () => { sessionStorage.setItem( `${this.props.formId}_${this.props.config.sId}_headerColumns`, JSON.stringify(sortArr) ); this.initColumn = null; this.droping = false; }); this.handleSaveOrder(sortItems); } } else { this.resize = false; this.droping = false; } }, onContextMenu: event => { window.event.returnValue = false; } }; }; onRowMouseEnter = record => { // recor if ( this.props.enabled && this.props.tableBelone !== "list" && commonUtils.isNotEmptyObject(this.props.tableProps) && !this.beSelectDropdownOpen && commonUtils.isEmptyObject(this.props.tableProps.rowSelection) && this.state.currentHoverSid !== record.sId ) { if (this.timerSelectRowChange) { clearTimeout(this.timerSelectRowChange); } this.timerSelectRowChange = setTimeout(() => { this.setState({ currentHoverSid: record.sId }); // console.log('=====record', record); // this.handleSelectRowChange(this.props.name, [record[this.rowKey]]); }, 150); } }; onRowMouseLeave = () => { if (this.timerSelectRowChange) { clearTimeout(this.timerSelectRowChange); } }; /** 行选择 */ onRowClick = (record, index, type, name, tabType) => { if (this.stopRowClick) { this.stopRowClick = false; return; } if (record.checkboxDisabled) return; const { bMutiSelect, tableProps, bMutiSelect1, bRowClick, bContinueClick } = this.props; const { rowSelection } = tableProps; // let { selectedRowKeys } = this.props; const rowKey = tabType === "slaveInfo" && commonUtils.isNotEmptyObject(this.props.slaveInfo.tableProps) ? this.props.slaveInfo.tableProps.rowKey : this.rowKey; let selectedRowKeys = tabType === "slaveInfo" && 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" ) { return; } if ( selectedRowKeys && selectedRowKeys.indexOf(record[rowKey]) !== -1 && name !== "slave" && !this.props.enabled ) { this.handleSelectRowChange(name, []); return; } if (bMutiSelect && rowSelection !== null && !bMutiSelect1) { /* 有多选、复选框情况下 */ if (commonUtils.isEmptyArr(selectedRowKeys) || bContinueClick) { const keys = []; keys.push(record[rowKey]); selectedRowKeys = keys; } else { const indexKey = selectedRowKeys.indexOf(record[rowKey]); if (indexKey === -1) { selectedRowKeys.push(record[rowKey]); } else if (indexKey !== -1 && type !== "drag") { if (!bRowClick) { selectedRowKeys.splice( indexKey, 1 ); /* 可输入行,行内点击时 不去除selectedRowKeys */ } } } this.handleSelectRowChange(name, selectedRowKeys); } else { this.handleSelectRowChange(name, [record[rowKey]]); } }; // 数据扁平化 getDataAll = (data, parentRowKeyPath = []) => { let res = data.map(item => { return { ...item, parentRowKeyPath }; }); res.forEach(item => { if (commonUtils.isNotEmptyArr(item.children)) { res = [ ...res, ...this.getDataAll(item.children, [ ...parentRowKeyPath, item[this.rowKey] ]) ]; } }); return res; }; // 处理树形表格多选父子联动 handleMutiSelectRowKeys = selectedRowKeys => { const { bMutiSelect, tableProps, bMutiSelect1 } = this.props; const { rowSelection } = tableProps; if (bMutiSelect && rowSelection !== null && !bMutiSelect1) { /* 有多选、复选框情况下 */ // 判断是选中还是取消 const type = selectedRowKeys.length > this.selectedRowKeysOld.length ? "add" : "del"; // 找出变化的数据 const diffArr = this.selectedRowKeysOld .concat(selectedRowKeys) .filter( v => !this.selectedRowKeysOld.includes(v) || !selectedRowKeys.includes(v) ); if (diffArr.length === 1) { // 将数据扁平化 let { data } = this.props; const dataAll = this.getDataAll(data); // 额外的选中行(当前选中行的子数据) const selectedRowKeysExtra = dataAll.reduce((result, cur) => { if (cur.parentRowKeyPath.includes(diffArr[0])) { result.push(cur[this.rowKey]); } return result; }, []); if (type === "add") { // 合并选中行 selectedRowKeys = Array.from( new Set([...selectedRowKeys, ...selectedRowKeysExtra]) ); } else { // 删除当前行子数据 selectedRowKeys = selectedRowKeys.reduce((result, cur) => { if (!selectedRowKeysExtra.includes(cur)) { result.push(cur); } return result; }, []); } } } this.selectedRowKeysOld = selectedRowKeys; return selectedRowKeys; }; /** 行选择 */ onDoubleClick = (name, record) => { if (this.props.onDoubleClickNew) { this.props.onDoubleClickNew({ name, record }); } else if (this.props.onDoubleClick !== undefined) { this.props.onDoubleClick(record); } }; onKeyDownDiv = (e, sName) => { if (e.key === "F10") { message.info(sName); } else if (e.ctrlKey && e.keyCode === 67) { console.log("复制成功!"); } else if (e.ctrlKey && e.keyCode === 65) { console.log("全选成功!"); } else if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 71) { /* CTRL+ALT+G F7 设置界面 */ const { name, config, data, configName } = this.props; if ( commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.config) && commonUtils.isNotEmptyObject(this.props.data) ) { const bInModal = el => { if (commonUtils.isEmpty(el) || commonUtils.isEmpty(el.classList)) { return false; } else if (el.classList.contains("ant-modal-root")) { return true; } else { return bInModal(el.parentNode); } }; if (bInModal(e.target)) { // 如果是在modal里的表格,不允许跳转 return; } const myTableConfig = JSON.parse(JSON.stringify(config)); myTableConfig.sActiveId = "16411004790004762980820285096000"; myTableConfig.sName = sName; const myTableConfigArr = []; myTableConfigArr.push(myTableConfig); this.props.onViewClick( name, "myTableConfig", data[0], 0, myTableConfigArr, configName ); } } else if (e.key !== "F12") { e.preventDefault(); return false; } }; onExpand = (expanded, record) => { if (this.props.onExpand !== undefined) { this.props.onExpand(expanded, record); } }; onOpenNewTab = () => { const dom = document.getElementsByClassName( `${this.state.randomId}-CommonListSelectTree` )[0]; dom.parentElement.parentElement.style.display = "none"; this.pathname = location.pathname; this.setState({ openNewTabFlag: true }); }; onChange = (pagination, filters, sorter, extra) => { if (this.showExpAll) { this.showExpAll = false; this.setState({ expKeys: [] }); } if (commonUtils.isNotEmptyObject(filters)) { const filterValueArr = Object.values(filters); if ( filterValueArr.join("") !== "" && commonUtils.isNotEmptyArr(extra.currentDataSource) ) { // 过滤了数据 this.tableFilterData = extra.currentDataSource; } else { // 没有过滤数据 this.tableFilterData = []; } // 生成cell list this.genMergeListStateMap(); } if (sorter.column) { sorter.columnKey = sorter.column.dataIndex; } else { sorter = {}; } if ( this.props.slaveInfo && this.props.slaveInfo.tableProps && this.props.slaveInfo.tableProps.onChange ) { this.props.slaveInfo.tableProps.onChange( pagination, filters, sorter, extra ); } if (this.props && this.props.tableProps && this.props.tableProps.onChange) { this.props.tableProps.onChange(pagination, filters, sorter, extra); } this.props.onSaveState({ sortedInfo: sorter }); }; /* 动态参数全选、取消全选 */ onParamChange = e => { this.props.onCheckChange(this.props.name); }; setRowClassName = (tabType, record, index) => { const styleColor = this.getColorStyle(record, true); /* 消息列表未读的消息,整行文字加粗 */ let newslistStyle = ""; if ( commonUtils.isNotEmptyObject(this.props.formId) && this.props.formId === "15669750700007338351055957774000" ) { if (record.bIsView === false) { newslistStyle = "newsNoRead"; } } const selectedRowKeys = tabType === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.props.selectedRowKeys; const rowKey = tabType === "slaveInfo" && commonUtils.isNotEmptyObject(this.props.slaveInfo.tableProps) ? this.props.slaveInfo.tableProps : this.rowKey; const rowClassName = commonUtils.isNotEmptyArr(selectedRowKeys) && selectedRowKeys.indexOf(record[rowKey]) > -1 ? `selected-record-row ${styleColor}` : commonUtils.isNotEmptyObject(styleColor) ? styleColor : index % 2 === 1 && this.props.tableBelone === "list" ? "dark-record-row" : ""; let allRowClassName = commonUtils.isNotEmptyObject(newslistStyle) ? `${rowClassName} ${newslistStyle}` : rowClassName; if (tabType === "slave" && commonUtils.isNotEmptyArr(this.mergeCellList)) { // 如果有合并单元格 allRowClassName = record.sColor; } else { if ( commonUtils.isEmptyObject(allRowClassName) || commonUtils.isEmptyObject(allRowClassName.trim()) ) { /* 设置奇 偶行背景色 */ allRowClassName = index % 2 === 1 ? "dark-record-row" : ""; } } /* 如果行字段的sDivRow有值 则做成特殊样式 */ if ( commonUtils.isNotEmptyObject(record) && commonUtils.isNotEmptyObject(record.sDivRowNew) && record.bInsert ) { allRowClassName = "split-record-row"; if (this.props.skipSlaveInfo) { allRowClassName = "split-record-row-skip"; } } if (this.props.bGyXunjian) { allRowClassName = `${allRowClassName} xunjianclass`; } if (["table0", "slave0"].includes(this.props.name) && record.bUnChanged) { allRowClassName = `${allRowClassName} SetRow_mesOrange`; } // 根据配置高亮显示 const displayHighLightConfig = this.props.config?.gdsconfigformslave?.find( item => item.bVisible && item.sControlName?.toLowerCase() === "displayhighlight" ); // 行车记录合并高亮 if (["table001"].includes(this.props.name) && record.bDisplayHighLight) { allRowClassName = `${allRowClassName} SetRow_mesBlue`; } // 多选并且有选中项目 const { bMutiSelect } = this.props; const bMutiAndSelected = bMutiSelect && selectedRowKeys?.length; if (displayHighLightConfig && !bMutiAndSelected) { const { sDefault } = displayHighLightConfig; const result = !this.props.getBtnDisabled({ str: sDefault, record, defaultValue: true, noDefaultRow: true }); if (result) { allRowClassName = `${allRowClassName} ${styles.lightHighRecordRow}`; } } return allRowClassName; }; /** 获取复选框对象的props */ getRowSelection = (name, type) => { const { bMutiSelect, bisMutiSelect } = this.props; if ( name === "control" || (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf("commonAuto") > -1) ) { // 控制表中可以通过bisMutiSelect显示或者隐藏勾选框 if (bisMutiSelect) { return { preserveSelectedRowKeys: true, selectedRowKeys: type === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys /* 已选择的数据集 */, onChange: this.handleSelectRowChange.bind( this, name ) /* 选择行发生改变时调用的函数 */, getCheckboxProps: record => ({ disabled: !!record.checkboxDisabled, style: record.bSum && commonConfig.hasSum ? { display: "none" } : { display: "checkbox" } }) /* 过滤合计的选择框 */, type: bMutiSelect ? this.props.rowSelectionType : "radio" /* checkbox or radio */, columnWidth: 37 }; } else { return null; } } else { return { preserveSelectedRowKeys: true, selectedRowKeys: type === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys /* 已选择的数据集 */, onChange: this.handleSelectRowChange.bind( this, name ) /* 选择行发生改变时调用的函数 */, getCheckboxProps: record => ({ disabled: !!record.checkboxDisabled || record.bDisplayHighLight, style: record.bSum && commonConfig.hasSum ? { display: "none" } : { display: "checkbox" } }) /* 过滤合计的选择框 */, type: bMutiSelect ? this.props.rowSelectionType : "radio" /* checkbox or radio */, columnWidth: 37 }; } }; // 生产顺序号点击事件 sIndexNoClick = (index, record, event) => { const { selectedRowKeys = [] } = this.props; const oBtns0 = document.querySelectorAll(".rightFormBtn0 .ant-btn"); const oBtns1 = document.querySelectorAll(".slaveWyrj.btnContent .ant-btn"); const oBtns = oBtns0.length ? oBtns0 : oBtns1.length ? oBtns1 : document.querySelectorAll(".rightFormBtn .ant-btn"); if (selectedRowKeys[0] !== record.sId && oBtns.length) return; const indexMap = { 1: "①", 2: "②", 3: "③", 4: "④" }; // 第一步:找class为rightFormBtn下的按钮 let oBtn = null; if (oBtns.length) { oBtn = Array.from(oBtns).find(item => item.children?.[0].innerHTML?.includes(indexMap[index]) ); } // 第二步:找当前行操作栏中的按钮 if (!oBtn) { function findNearestTr(element) { while (element && element.tagName.toLowerCase() !== "tr") { element = element.parentElement; } return element; } // 找到最近的tr const targetTr = findNearestTr(event.target); if (targetTr) { const oLineBtns = targetTr.querySelectorAll(".operate-bar .ant-btn"); if (oLineBtns.length) { oBtn = Array.from(oLineBtns).find(item => item.children?.[0].innerHTML?.includes(indexMap[index]) ); } } } if (oBtn) { setTimeout(() => { oBtn.click(); }, 0); } }; /** 获取table对象的props */ getTableProps = () => { /* 给数据都添加上key */ const { tableColumn, dataSource } = this.state; // 二级表头 const subTableColumn = tableColumn.reduce((result, item) => { if (commonUtils.isNotEmptyArr(item.children)) { result = [...result, ...item.children]; } return result; }, []); const sPartNameStatus = [...tableColumn, ...subTableColumn].filter( item => item.dataIndex === "sPartNameStatus" ); const sPicturePath = [...tableColumn, ...subTableColumn].filter( item => item.dataIndex === "sPicturePath" ); const sMaterialsStatus = [...tableColumn, ...subTableColumn].filter( item => item.dataIndex === "sMaterialsStatus" || (commonUtils.isNotEmptyArr(item.children) && item.children.findIndex( itemChild => itemChild.dataIndex && itemChild.dataIndex === "sMaterialsStatus" ) > -1) ); const dynamicColumn = [...tableColumn, ...subTableColumn].filter( item => (commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.includes("_json")) || (commonUtils.isNotEmptyArr(item.children) && item.children.findIndex( itemChild => itemChild.dataIndex && itemChild.dataIndex.includes("_json") ) > -1) ); /* 动态列JSON解析 */ const sTimeStatus = [...tableColumn, ...subTableColumn].filter( item => item.dataIndex === "sTimeStatus" ); /* 时间进度条状态 */ const sDownload = [...tableColumn, ...subTableColumn].filter( item => item.dataIndex === "sDownload" ); const sScheduleStatusJson = [...tableColumn, ...subTableColumn].filter( item => item.dataIndex && item.dataIndex.includes("sScheduleStatusJson") ); // 拼版状态 if (commonUtils.isNotEmptyArr(sPicturePath)) { sPicturePath[0].render = (value = "") => { const picHref = value.includes("xlyerpfiles") ? `${ commonConfig.server_host }file/download?savePathStr=${encodeURIComponent( value )}&sModelsId=100&token=${encodeURIComponent(this.props.app.token)}` : value; return ( {value} ); }; } if (commonUtils.isNotEmptyArr(sDownload)) { sDownload[0].render = value => { if (commonUtils.isEmpty(value)) return ""; const fileList = value.split(","); if (fileList.length === 1) { let fileName = fileList[0].substring( fileList[0].lastIndexOf("/") + 1 ); fileName = fileName.substring(fileName.indexOf("_") + 1); const picHref = `${ commonConfig.server_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})`} ); } }; } // 生产顺序号/标条 const sIndexNo = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "sIndexNo" ); if ( sIndexNo && ![ "slaveWyrj1", "slaveWytf2", "slaveWypj1", "salveWybz1", "slaveWyfq1" ].includes(this.props.name) && !["12710101117087404588200", "12710101117260270570210"].includes( this.props.parentProps.sModelsId ) ) { sIndexNo.render = (value, record) => { const { bClStatus, bCpStatus, bYcStatus, bWlStatus } = record; return (
{value}
1
{![ "slaveWydj", "slaveWytf1", "salveWydm1", "salveWybz3" ].includes(this.props.name) ? (
2
) : ( "" )} {![ "slaveWydj", "slaveWytf1", "salveWydm1", "salveWybz3" ].includes(this.props.name) ? (
3
) : ( "" )} {![ "slaveWyfq2", "slaveWydj", "slaveWytf1", "slaveWyrj2", "slaveWyrj3", "salveWydm1", "salveWybz3" ].includes(this.props.name) ? (
4
) : ( "" )}
); }; } // 通用①②③④ const printStatusShowFConfigGroup = this.props.config?.gdsconfigformslave.filter( item => item.sControlName?.includes("bPrintStatusShow") && item.bVisible ); if (commonUtils.isNotEmptyArr(printStatusShowFConfigGroup)) { printStatusShowFConfigGroup.forEach(printStatusShowFConfig => { const { sDefault } = printStatusShowFConfig; if (sDefault) { const [ sFieldName, sFieldName1, sFieldName2, sFieldName3, sFieldName4 ] = sDefault.split(","); const fieldColumn = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === sFieldName ); if (fieldColumn) { fieldColumn.render = (value, record) => { const { [sFieldName1]: bStatus1, [sFieldName2]: bStatus2, [sFieldName3]: bStatus3, [sFieldName4]: bStatus4 } = record; return (
{value}
1
{sFieldName2 && (
2
)} {sFieldName3 && (
3
)} {sFieldName4 && (
4
)}
); }; } } }); } // 动态分钟 const iminutes = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "iminutes" ); if (iminutes && !["table0", "slave0"].includes(this.props.name)) { iminutes.render = (value, record) => { if (value) { return ( {value} ); } else { return ( ); } }; } // 动态结束时间 // const tEndDate = [...tableColumn, ...subTableColumn].find( // item => item.dataIndex === "tEndDate" // ); // if ( // tEndDate && // this.props.name === "table0" && // this.props.formId === "12710101117087404588200" // ) { // tEndDate.render = (value, record, index) => { // const { sFieldMinutes } = record; // if (record[sFieldMinutes] || index > 0) { // return ( // // ); // } else { // return ( // // // // ); // } // }; // } // 动态托盘计数 const dQty = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "dQty" ); if (dQty) { dQty.render = (value, record) => { const { iJobStatus } = record; if (iJobStatus !== 1) { return ( {value} ); } else { return ( ); } }; } // 动态托盘计数(品检正品数) const dMesQualifiedQty = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "dMesQualifiedQty" ); if (dMesQualifiedQty) { dMesQualifiedQty.render = (value, record) => { const { iJobStatus } = record; if (iJobStatus !== 1) { return ( {value} ); } else { return ( ); } }; } // 动态托盘计数(品检废品数) const dMesUnqualifiedQty = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "dMesUnqualifiedQty" ); if (dMesUnqualifiedQty) { dMesUnqualifiedQty.render = (value, record) => { const { iJobStatus } = record; if (iJobStatus !== 1) { return ( {value} ); } else { return ( ); } }; } // 标牌颜色 const sLabelColor = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "sLabelColor" ); if (sLabelColor) { sLabelColor.render = (value = "白", record) => { const colorList = "白粉青蓝橙绿黄红".split(""); let colorIndex = colorList.findIndex(item => item === value); colorIndex = colorIndex === -1 ? 0 : colorIndex; return ( { const { sModelType } = this.props.parentProps; if (sModelType !== "/indexMes/productionExec") return; this.setState({ labelColorModalVisible: true, labelColorModalRecord: record }); }} > {value} ); }; } // 废品描述sWasteType const sWasteType = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "sWasteType" ); if (sWasteType) { sWasteType.render = (value, record, index) => { return (
); }; } // 评管QC确认 const sQcMemo = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "sQcMemo" ); if (sQcMemo) { sQcMemo.render = (value, record, index) => { return (
); }; } // 复卷剔废确认信息 const sOperatorMemo = [...tableColumn, ...subTableColumn].find( item => item.dataIndex === "sOperatorMemo" ); if (sOperatorMemo) { sOperatorMemo.render = (value, record, index) => { return (
); }; } // 巡检✓/✗ const { xunjianList = [] } = this.props; const xunjianColumns = [...tableColumn, ...subTableColumn].filter(item => xunjianList.includes(item.dataIndex) ); const xunjianClick = params => { const { bEnabled, value, index, sName } = params; if (!bEnabled) return; let newValue = ""; if (!value) { newValue = "✓"; } else if (["1", "✓"].includes(value)) { newValue = "✗"; } const dataNew = [...this.props.data]; dataNew[index][sName] = newValue; this.props.onSaveState({ [`${this.props.name}Data`]: dataNew }); const { config = {} } = this.props; const { gdsconfigformslave = [] } = config; const sFieldsConfig = gdsconfigformslave.find( item => item.sName === sName && item.sOnChangeInstruct ); if (sFieldsConfig) { const { sOnChangeInstruct: sOnChangeInstructStr } = sFieldsConfig; const sOnChangeInstruct = commonUtils.convertStrToObj( sOnChangeInstructStr ); const instruct = sOnChangeInstruct.change || sOnChangeInstruct.blur; clearTimeout(this.xunjianTimer); this.xunjianTimer = setTimeout(() => { this.props.parentProps.onExecInstructSet({ btnConfig: { showName: "变化", sInstruct: JSON.stringify(instruct) }, nextProps: { [`${this.props.name}Data`]: dataNew } }); }, 200); } }; xunjianColumns.forEach(column => { column.render = (value, record, index) => { const { costomEnabledList = [] } = record; const bEnabled = costomEnabledList.includes(column.dataIndex); if (value === "1" || value === "✓") { return (
); } else if (value === "0" || value === "✗") { return (
); } else { return (
); } }; }); // 通用✓/✗ const checkMarkList = [...tableColumn, ...subTableColumn].filter(item => { const { dataIndex } = item; const config = this.props.config.gdsconfigformslave.find( item => item.sName === dataIndex ) || {}; return config.sControlName?.includes("checkmark"); }); checkMarkList.forEach(column => { column.render = (value, record, index) => { const { costomEnabledList = [] } = record; const bEnabled = costomEnabledList.includes(column.dataIndex) || this.props.enabled; if (value === "1" || value === "✓") { return (
); } else if (value === "0" || value === "✗") { return (
); } else { return (
{bEnabled ? "待确认" : ""}
); } }; }); this.props.parentProps.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, record) => { if (commonUtils.isJSON(itemStr)) { const sPartItemOld = JSON.parse(itemStr); let sPartItem = [...sPartItemOld]; if (sPartItemOld?.[0]?.sProcessName?.includes("】")) { const sPartItemOldFirst = sPartItemOld.splice(0, 1)[0]; const [name1, name2] = sPartItemOldFirst.sProcessName.split("】"); const part1 = { ...sPartItemOldFirst, sProcessName: `${name1}】`, sState: 10 }; const part2 = { ...sPartItemOldFirst, sProcessName: name2 }; sPartItem = [part1, part2, ...sPartItemOld]; } const { iStar } = record; const content = (
{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 2: colorValue = "#FF6600"; /* 2:等待:黄色 */ break; case 4: colorValue = "#648c4b"; /* 4:已完成:绿色 */ break; case 1: case 3: colorValue = "#106abe"; /* 1、3:进行中:蓝色 */ break; default: colorValue = "#000000"; } } return (
{commonUtils.isNotEmptyObject(t.sProcessName) ? t.sProcessName : ""} {i + 1 === sPartItemLength || t.sState === 10 ? ( "" ) : ( )}
); })}
); return ( //
{ return content; }} >
{content}
); } }; } else { sPartNameStatus[0].render = itemStr => { if (itemStr) { const sPartItem = itemStr.split("->"); return (
{// eslint-disable-next-line array-callback-return sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; const ArrItemStr = t.split("#")[0]; /* 工序名称 */ const ArrItemNum = t.split("#")[1]; /* 状态 */ const ArrItemName = t.split("#")[2]; /* 机台名称 */ const ArrItemBanZhu = t.split("#")[3]; /* 班组 */ const ArrItemTime = t.split("#")[4]; /* 排单时间 */ const ArrItemPCNum = t.split("#")[5]; /* 排程数 */ const ArrItemSBNum = t.split("#")[6]; /* 上报数 */ const ArrItem7Num = commonUtils.isNotEmptyArr(t.split("#")) && t.split("#").length > 8 ? t.split("#")[8] : ""; /* 包数 */ const ArrItem8Num = commonUtils.isNotEmptyArr(t.split("#")) && t.split("#").length > 9 ? t.split("#")[9] : ""; /* 每包数量 */ const ArrItem9Num = commonUtils.isNotEmptyArr(t.split("#")) && t.split("#").length > 10 ? t.split("#")[10] : ""; /* 零头数量 */ let ArrItemNumChange = ""; let icon; // eslint-disable-next-line default-case switch (Number(ArrItemNum)) { case 0: ArrItemNumChange = "未排程"; icon = ( ); break; case 1: ArrItemNumChange = "未完成"; icon = ( ); break; case 2: ArrItemNumChange = "生产中"; icon = ( ); break; case 3: ArrItemNumChange = "暂停"; icon = ( ); break; case 4: ArrItemNumChange = "取消"; icon = ( ); break; case 5: ArrItemNumChange = "完成"; icon = ( ); break; } // eslint-disable-next-line no-unused-vars const content = (
工序名称: {ArrItemStr}
状态: {ArrItemNumChange}
机台名称: {ArrItemName}
班组: {ArrItemBanZhu}
排单时间: {ArrItemTime}
排程数: {ArrItemPCNum}
上报数: {ArrItemSBNum}
{ArrItem7Num ? (
包数: {ArrItem7Num}
) : ( "" )} {ArrItem8Num ? (
每包数量: {ArrItem8Num}
) : ( "" )} {ArrItem9Num ? (
零头数量: {ArrItem9Num}
) : ( "" )}
); // 数字转换图标 return (
{icon} {ArrItemStr} {/*{ i + 1 === sPartItemLength ? '' : }*/}
); })}
); } }; } } // 判断材料准备状态 if ( commonUtils.isNotEmptyArr(sMaterialsStatus) && commonUtils.isNotEmptyArr(dataSource) ) { this.useVListNew = true; const sModelsType = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : ""; if ( true || sModelsType === "production/productionPlanInfo" || sModelsType === "productionMainPlan/productionMainPlan" || (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes("view/")) || location.pathname.toLowerCase().indexOf("oee") > -1 ) { /* 动态列Jsonn解析 */ if ( commonUtils.isNotEmptyArr(sMaterialsStatus) && commonUtils.isNotEmptyArr(dataSource) ) { sMaterialsStatus.forEach((jsonStatus, index) => { if (commonUtils.isNotEmptyArr(jsonStatus.children)) { /* 嵌套列头JSON解析 */ for (const obj of jsonStatus.children) { obj.render = itemStr => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); /* 取箭头弹出的窗体配置 */ let showConfig = {}; let linkStyle = ""; /* 弹窗 */ if ( commonUtils.isNotEmptyArr(this.props.config) && commonUtils.isNotEmptyArr( this.props.config.gdsconfigformslave ) && commonUtils.isNotEmptyStr("sMaterialsStatus") ) { const showConfigArr = this.props.config.gdsconfigformslave.filter( item => item.sName === "sMaterialsStatus" && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; if ( commonUtils.isNotEmptyObject(showConfig) && showConfig.sDropDownType === "picArr" && !commonUtils.isEmpty(showConfig.sActiveId) && commonUtils.isEmptyArr(this.props.sGroupByList) ) { linkStyle = "sMaterialsStatusStyle"; } } } return ( { return (
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = "#000000"; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch ( Number(sState) // 根据状态显示颜色 ) { case 0: colorValue = "#000000"; /* 0:黑色 */ break; case 1: colorValue = "#ff4d4f"; /* 1:红色 */ break; case 2: colorValue = "#49aa19"; /* 2:绿色 */ break; case 3: colorValue = "#49aa19"; /* 3:绿色 */ break; case 4: colorValue = "#ff4d4f"; /* 4:红色 */ break; default: colorValue = "#000000"; } } return (
{commonUtils.isNotEmptyObject( t.sMaterialsName ) ? ( {t.sMaterialsName} ) : ( "" )} {i + 1 === sPartItemLength ? ( "" ) : ( - )}
); })}
); }} >
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = "#000000"; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch ( Number(sState) // 根据状态显示颜色 ) { case 0: colorValue = "#000000"; /* 0:黑色 */ break; case 1: colorValue = "#ff4d4f"; /* 1:红色 */ break; case 2: colorValue = "#49aa19"; /* 2:绿色 */ break; case 3: colorValue = "#49aa19"; /* 3:绿色 */ break; case 4: colorValue = "#ff4d4f"; /* 4:红色 */ break; default: colorValue = "#000000"; } } return (
{commonUtils.isNotEmptyObject( t.sMaterialsName ) ? ( {t.sMaterialsName} ) : ( "" )} {i + 1 === sPartItemLength ? ( "" ) : ( - )}
); })}
); } else { return itemStr; } }; } } else { /* 无嵌套列头JSON列解析 */ sMaterialsStatus[index].render = itemStr => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); /* 取箭头弹出的窗体配置 */ let showConfig = {}; let linkStyle = ""; /* 弹窗 */ if ( commonUtils.isNotEmptyArr(this.props.config) && commonUtils.isNotEmptyArr( this.props.config.gdsconfigformslave ) && commonUtils.isNotEmptyStr("sMaterialsStatus") ) { const showConfigArr = this.props.config.gdsconfigformslave.filter( item => item.sName === "sMaterialsStatus" && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; if ( commonUtils.isNotEmptyObject(showConfig) && showConfig.sDropDownType === "picArr" && !commonUtils.isEmpty(showConfig.sActiveId) && commonUtils.isEmptyArr(this.props.sGroupByList) ) { linkStyle = "sMaterialsStatusStyle"; } } } return ( { return (
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = "#000000"; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch ( Number(sState) // 根据状态显示颜色 ) { case 0: colorValue = "#000000"; /* 0:黑色 */ break; case 1: colorValue = "#ff4d4f"; /* 1:红色 */ break; case 2: colorValue = "#49aa19"; /* 2:绿色 */ break; case 3: colorValue = "#49aa19"; /* 3:绿色 */ break; case 4: colorValue = "#ff4d4f"; /* 4:红色 */ break; default: colorValue = "#000000"; } } return (
{commonUtils.isNotEmptyObject( t.sMaterialsName ) ? ( {t.sMaterialsName} ) : ( "" )} {i + 1 === sPartItemLength ? ( "" ) : ( - )}
); })}
); }} >
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; let colorValue = "#000000"; if (t?.background) { colorValue = t.background; } else { const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch ( Number(sState) // 根据状态显示颜色 ) { case 0: colorValue = "#000000"; /* 0:黑色 */ break; case 1: colorValue = "#ff4d4f"; /* 1:红色 */ break; case 2: colorValue = "#49aa19"; /* 2:绿色 */ break; case 3: colorValue = "#49aa19"; /* 3:绿色 */ break; case 4: colorValue = "#ff4d4f"; /* 4:红色 */ break; default: colorValue = "#000000"; } } return (
{commonUtils.isNotEmptyObject( t.sMaterialsName ) ? ( {t.sMaterialsName} ) : ( "" )} {i + 1 === sPartItemLength ? ( "" ) : ( - )}
); })}
); } else { return itemStr; } }; } }); } } } /* 动态列Jsonn解析 */ if ( commonUtils.isNotEmptyArr(dynamicColumn) && commonUtils.isNotEmptyArr(dataSource) ) { dynamicColumn.forEach((jsonStatus, index) => { if (commonUtils.isNotEmptyArr(jsonStatus.children)) { /* 嵌套列头JSON解析 */ const childrenJson = jsonStatus.children.filter( itemChild => itemChild.dataIndex && itemChild.dataIndex.includes("json") ); for (const obj of childrenJson) { obj.render = itemStr => { if ( commonUtils.isNotEmptyObject(itemStr) && commonUtils.isJSON(itemStr) ) { const sPartItem = JSON.parse(itemStr); return (
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { // const sPartItemLength = sPartItem.length; let colorValue = "#000000"; const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch ( Number(sState) // 根据状态显示颜色 ) { case 1: colorValue = "#ff0000"; /* 1:红色 */ break; case 2: colorValue = "#49aa19"; /* 2:绿色 */ break; case 3: colorValue = "#ffff00"; /* 3:黄色 */ break; case 0: colorValue = ""; /* 3:不要颜色 */ break; default: colorValue = ""; } return (
{t.dSchedulHours}
); })}
); } }; } } else { /* 无嵌套列头JSON列解析 */ dynamicColumn[index].render = itemStr => { if ( commonUtils.isNotEmptyObject(itemStr) && commonUtils.isJSON(itemStr) ) { const sPartItem = JSON.parse(itemStr); return (
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { // const sPartItemLength = sPartItem.length; let colorValue = "#000000"; const sState = commonUtils.isEmpty(t.sState) ? 4 : t.sState; switch ( Number(sState) // 根据状态显示颜色 ) { case 1: colorValue = "#ff0000"; /* 1:红色 */ break; case 2: colorValue = "#49aa19"; /* 2:绿色 */ break; case 3: colorValue = "#ffff00"; /* 3:黄色 */ break; default: colorValue = "#666"; } return (
{t.dSchedulHours}
); })}
); } else { return itemStr; } }; } }); } // 判断时间状态 if ( commonUtils.isNotEmptyArr(sTimeStatus) && commonUtils.isNotEmptyArr(dataSource) ) { sTimeStatus[0].render = itemStr => { if (commonUtils.isJSON(itemStr)) { const sPartItem = JSON.parse(itemStr); const linkStyle = "sTimeStatusStyle"; /* 弹窗 */ return (
{// eslint-disable-next-line array-callback-return; sPartItem.map((t, i) => { const sPartItemLength = sPartItem.length; const sColor = t.sColor; const dWidth = t.dRate !== undefined && t.dRate !== 0 ? `${t.dRate * 500}px` : "100px"; const content = (

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

); return (
{t.sValue}
); })}
); } else { return itemStr; } }; } // 判断拼板状态 if ( commonUtils.isNotEmptyArr(sScheduleStatusJson) && commonUtils.isNotEmptyArr(dataSource) ) { this.useVListNew = true; sScheduleStatusJson[0].render = itemStr => { if (commonUtils.isJSON(itemStr)) { const itemJson = commonUtils.convertStrToObj(itemStr); const itemLength = itemJson.length; const content = itemJson.map((t, i) => { const { sState, sColor = "#000000", sName = "" } = t; return (
{sName} {i + 1 === itemLength ? "" : }
); }); return (
{ return
{content}
; }} > {content}
); } }; } let components = {}; if (this.isDragAndDrop) { components.header = { cell: ResizeableTitle }; components.body = { row: DragableBodyRow }; } else { components.header = { cell: ResizeableTitle }; } let bPagination = true; /* 默认表格分页s */ if (commonUtils.isNotEmptyObject(this.props)) { bPagination = commonUtils.isNotEmptyObject(this.props.tableProps) && commonUtils.isNotEmptyObject(this.props.tableProps.pagination); } let noVlistController = false; if ( this.props.config && this.props.config.gdsconfigformslave.filter( item => item.sControlName === "bNoVlist" )[0] ) { noVlistController = true; } // 判断是否有合并单元格, 有的话默认关闭虚拟滚动 // if (this.mergeCellStateMap) { // for (let key in this.mergeCellStateMap) { // if (this.mergeCellStateMap[key]) { // noVlistController= true; // } // } // } // if (!this.props.noVlist && !noVlistController) { if (this.props.slaveInfo || this.useVListNew) { if (!this.uniqueId) { this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); } if (!this.Vcomponents || window.vlistNewSearh) { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (oTable) { const oBody = oTable.querySelector(".ant-table-body"); oBody && (oBody.scrollTop = 0); } window.vlistNewSearh = null; this.Vcomponents = VListNew({ height: this.scrollY, vid: this.uniqueId, onScroll: () => { setTimeout(() => { let divs = document.getElementsByClassName("noInputInsert"); if (divs.length) { Array.prototype.forEach.call(divs, item => { item.parentNode.parentNode.parentNode.parentNode.classList.add( "insertTd" ); }); } }, 20); } }); } components = { ...this.Vcomponents, ...components }; } else { // vid是多个列表在同个页面中,同时渲染会促发问题 // vid不可以为随机数,随机数会导致双击时,点击的两个VList id不同 if (!this.uniqueId) { this.uniqueId = this.props.formId ? `${this.props.formId}_${lodash.uniqueId()}` : lodash.uniqueId(); } if (!this.Vcomponents1 || window.vlistNewSearh) { const { tableClassName } = this.state; const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; if (oTable) { const oBody = oTable.querySelector(".ant-table-body"); oBody && (oBody.scrollTop = 0); } window.vlistNewSearh = null; this.Vcomponents1 = VList({ height: this.scrollY, vid: this.uniqueId, rowKey: this.rowKey, onScroll: () => { setTimeout(() => { let divs = document.getElementsByClassName("noInputInsert"); if (divs.length) { Array.prototype.forEach.call(divs, item => { item.parentNode.parentNode.parentNode.parentNode.classList.add( "insertTd" ); }); } }, 20); } }); } components = { ...this.Vcomponents1, ...components }; } // } if (this.props.config && this.props.config.iFreezeColumn) { tableColumn.forEach((val, index) => { if (tableColumn[index].fixedHelp) { tableColumn[index].fixed = false; tableColumn[index].fixedHelp = false; } if (index < this.props.config.iFreezeColumn) { tableColumn[index].fixed = "left"; tableColumn[index].fixedHelp = true; } }); } // 处理拖拽排序 if (this.props.dragHandle) { const 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; const [item] = array.splice(fromIndex, 1); array.splice(endIndex, 0, item); } } function arrayMoveImmutable(array, fromIndex, toIndex) { array = [...array]; arrayMoveMutable(array, fromIndex, toIndex); return array; } const DragHandle = sortableHandle(() => ( )); const SortableItem = sortableElement(props => ); const SortableContainer = sortableContainer(props => ( )); const onSortEnd = ({ oldIndex, newIndex }) => { const { dataSource } = this.state; if (oldIndex !== newIndex) { const newData = arrayMoveImmutable( [].concat(dataSource), oldIndex, newIndex ).filter(el => !!el); this.props.onDrag(newData, this.props.name); } }; const DraggableContainer = props => ( ); const DraggableBodyRow = ({ className, style, ...restProps }) => { const { dataSource } = this.state; // function findIndex base on Table rowKey props and should always be a right array index const index = dataSource.findIndex( x => x.index === restProps["data-row-key"] ); return ( ); }; // 处理渲染后丢失input focus的bug. if (!this.DraggableContainer) { this.DraggableContainer = DraggableContainer; } if (!this.DraggableBodyRow) { this.DraggableBodyRow = DraggableBodyRow; } if (!handleSort) { components = { ...components, body: { wrapper: this.DraggableContainer, row: this.DraggableBodyRow } }; } else { components = { ...components, body: { wrapper: this.DraggableContainer, row: this.DraggableBodyRow } }; tableColumn.shift(); } tableColumn.unshift({ title: "排序", dataIndex: "handleSort", fixed: "left", width: 40, className: "drag-visible", render: () => }); } } let rowSelection = this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, "slave"); // 是否选择多选框的问题 if (this.props.config && !this.props.config.bisMutiSelect) { rowSelection = null; } const { expKeys } = this.state; /* 返回值 */ return { components, rowKey: this.rowKey, // size: 'middle', bordered: true /* 显示边框 */, className: !this.props.enabled ? styles.disabledProup : styles.proup /* 样式控制 */, scroll: { x: "max-content" } /* 宽度 */, dataSource /* 数据 */, columns: tableColumn /* 表头 */, // rowSelection: this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, 'slave'), /* 添加的复选框(checkbox)功能 */ rowSelection, // pagination: false, /* 不分页 */ rowClassName: this.setRowClassName.bind(this, "slave"), onRow: (record, index) => { if (this.isDragAndDrop) { return { index, onClick: () => { this.onRowClick( record, index, undefined, this.props.name, "slave" ); }, onMouseEnter: () => { this.onRowMouseEnter(record); }, onMouseLeave: () => { this.onRowMouseLeave(record); }, onDoubleClick: () => { this.onDoubleClick(this.props.name, record); }, moveRow: (dragIndex, hoverIndex, dragKey, hoverKey) => { this.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); }, onDragClick: type => { this.onRowClick(record, index, type, this.props.name, "slave"); } }; } else { return { index, style: { background: this.props.bGyXunjian && this.props.getXunBgColor && this.props.getXunBgColor(record, undefined, true) }, onClick: () => { this.onRowClick( record, index, undefined, this.props.name, "slave" ); }, onDoubleClick: () => { this.onDoubleClick(this.props.name, record); }, onMouseEnter: () => { this.onRowMouseEnter(record); }, onMouseLeave: () => { this.onRowMouseLeave(); } }; } }, onExpand: (expanded, record) => { if (this.showExpAll) { if (expanded) { const expKeysNew = [...expKeys, record[this.rowKey]]; this.currentExpKeys = expKeysNew; this.setState({ expKeys: expKeysNew }); } else { const expKeysNew = expKeys.filter( item => item !== record[this.rowKey] ); this.currentExpKeys = expKeysNew; this.setState({ expKeys: expKeysNew }); } } this.onExpand(expanded, record, "slave"); /* 点击展开图标时触发s */ }, expandedRowKeys: expKeys.length || this.showExpAll ? expKeys : null, id: commonUtils.isEmptyArr(dataSource) ? "unDataBox" : "dataBox" /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */, ...this.props.tableProps, pagination: bPagination ? { ...this.props.tableProps.pagination, onChange: (current, size) => { this.curPagination = { current, pageSize: size }; } } : false /* 表格是否分页 */, onChange: this.onChange }; }; /** 获取子从表复选框对象的props */ getSlaveRowSelection = (name, type) => { const { bMutiSelect } = this.props.slaveInfo; /* 显示单选框还是复选框 */ let { bisMutiSelect } = this.props.slaveInfo; /* 是否显示选择框 */ if (this.props.slaveInfo.config) { bisMutiSelect = this.props.slaveInfo.config.bisMutiSelect; } if ( name === "control" || (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf("commonAuto") > -1) ) { // 控制表中可以通过bisMutiSelect显示或者隐藏勾选框 if (bisMutiSelect) { return { preserveSelectedRowKeys: true, selectedRowKeys: type === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys /* 已选择的数据集 */, onChange: this.handleSelectRowChange.bind( this, name ) /* 选择行发生改变时调用的函数 */, getCheckboxProps: record => ({ disabled: !!record.checkboxDisabled, style: record.bSum && commonConfig.hasSum ? { display: "none" } : { display: "checkbox" } }) /* 过滤合计的选择框 */, type: bMutiSelect ? this.props.rowSelectionType : "radio" /* checkbox or radio */, columnWidth: 37 }; } else { return null; } } else { return { preserveSelectedRowKeys: true, selectedRowKeys: type === "slaveInfo" ? this.state.slaveInfoSelectedRowKeys : this.state.selectedRowKeys /* 已选择的数据集 */, onChange: this.handleSelectRowChange.bind( this, name ) /* 选择行发生改变时调用的函数 */, getCheckboxProps: record => ({ disabled: !!record.checkboxDisabled, style: record.bSum && commonConfig.hasSum ? { display: "none" } : { display: "checkbox" } }) /* 过滤合计的选择框 */, type: bMutiSelect ? this.props.rowSelectionType : "radio" /* checkbox or radio */, columnWidth: 37 }; } }; /** 获取table对象的props */ getSlaveTableProps = () => { /* 给数据都添加上key */ if ( this.props.setExpandedRowRender !== undefined && this.props.setExpandedRowRender.toString() === "Y" ) { const { dataSource, tableColumn, tableProps, name: slaveInfoName, config: slaveInfoConfig } = this.props.slaveInfo; // const scrollHeight = parseInt(document.body.clientHeight - 400, 10); const components = {}; if (this.isDragAndDrop) { components.header = { cell: ResizeableTitle }; components.body = { row: DragableBodyRow }; } else { components.header = { cell: ResizeableTitle }; } let rowSelection = this.props.rowSelection !== undefined ? this.props.rowSelection : this.getSlaveRowSelection(slaveInfoName, "slaveInfo"); if (slaveInfoConfig && !slaveInfoConfig.bisMutiSelect) { /* 如果子表配置不显示选择框 则不显示选择框 */ rowSelection = null; } /* 返回值 */ return { components, rowKey: tableProps.rowKey, size: "small", bordered: true /* 显示边框 */, className: !this.props.enabled ? styles.disabledProup : styles.proup /* 样式控制 */, scroll: { x: "max-content" } /* 宽度 */, dataSource /* 数据 */, columns: tableColumn /* 表头 */, rowSelection: rowSelection /* s 添加的复选框(checkbox)功能 */, pagination: false /* 不分页 */, rowClassName: this.setRowClassName.bind(this, "slaveInfo"), onRow: (record, index) => { if (this.isDragAndDrop) { return { index, onClick: () => { this.onRowClick( record, index, undefined, slaveInfoName, "slaveInfo" ); }, onDoubleClick: () => { this.onDoubleClick( record, index, undefined, slaveInfoName, "slaveInfo" ); }, moveRow: (dragIndex, hoverIndex, dragKey, hoverKey) => { this.moveRow(dragIndex, hoverIndex, dragKey, hoverKey); }, onDragClick: type => { this.onRowClick( record, index, type, slaveInfoName, "slaveInfo" ); } }; } else { return { index, onClick: () => { this.onRowClick( record, index, undefined, slaveInfoName, "slaveInfo" ); }, onDoubleClick: () => { this.onDoubleClick(slaveInfoName, record); } }; } }, // footer: this.props.footer === undefined ? this.tableFooter : undefined, id: commonUtils.isEmptyArr(dataSource) ? "unDataBox" : "dataBox" /* 用户修改antd table中自带的样式(我听别人说的要这么弄,你们别骂我) */, ...this.props.slaveInfo.tableProps, onChange: this.onChange }; } else { return null; } }; getTableFilterData = () => { const { dataSource } = this.state; let filterData = 0; const GetFilterData = this.props.OnGetFilterData; if (GetFilterData !== undefined) { filterData = this.props.OnGetFilterData( this.props.name, this.props.bFinished ); } else { filterData = dataSource.length; } return filterData; }; /** 获取showConfig */ getShowConfig = (props, sName) => { /* 返回值声明 */ let showConfig = []; /* 通过sName过滤出对应的showConfig */ if (props.customConfig) { const showConfigArr = props.customConfig.filter( item => item.sName === sName && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; } } else { if (props.config) { const showConfigArr = props.config.gdsconfigformslave.filter( item => item.sName === sName && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr[0]; } } if ( commonUtils.isNotEmptyObject(this.props.slaveInfo) && commonUtils.isNotEmptyObject(this.props.slaveInfo.config) ) { const showConfigArr = this.props.slaveInfo.config.gdsconfigformslave.filter( item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } } /* 返回值 */ return showConfig; }; /** 获取颜色Config */ getColorConfig = () => { let showConfig = []; /* 通过sName过滤出对应的showConfig */ /* 通过sName过滤出对应的showConfig */ if (this.props.customConfig) { const showConfigArr = this.props.customConfig.filter( item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } else { if (this.props.config) { const showConfigArr = this.props.config.gdsconfigformslave.filter( item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } if ( commonUtils.isNotEmptyObject(this.props.slaveInfo) && commonUtils.isNotEmptyObject(this.props.slaveInfo.config) ) { const showConfigArr = this.props.slaveInfo.config.gdsconfigformslave.filter( item => commonUtils.isNotEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sColorTerms) && item.bVisible ); if (commonUtils.isNotEmptyArr(showConfigArr)) { showConfig = showConfigArr; } } } /* 返回值 */ return showConfig; }; getColorStyle = (record, isRowShow) => { let styleColorArrTotal = ""; const showConfigArr = this.getColorConfig(); /* 拿到颜色配置json */ if (commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) { for (const showConfig of showConfigArr) { let styleColorArr = ""; const colorConditon = commonUtils.isNotEmptyObject(showConfig) ? showConfig.sColorTerms : null; if (commonUtils.isNotEmptyObject(colorConditon)) { let colorConditionArr = ""; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { colorConditionArr = ""; } colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ""; /* 判断是否是数组 */ for (const item of colorConditionArr) { let styleColor = ""; const { column, condition, conditionValue, color, isRow } = item; if (record[column] !== undefined) { if ( color && !document.getElementById(`color${color.replace("#", "-")}`) ) { var style = document.createElement("style"); style.type = "text/css"; style.id = `color${color.replace("#", "-")}`; style.innerHTML = ` .color${color.replace("#", "-")} td { background-color:${color}!important; .ant-table-selection-column { background-color:${color}!important; } } `; document.getElementsByTagName("head")[0].appendChild(style); } if ( isRow && isRowShow && !commonUtils.isEmpty(record[column]) && commonUtils.isNotEmptyObject(record[column].toString()) ) { /* 配置行 */ if (condition === "=") { styleColor = record[column] === conditionValue ? `SetRow_${color} color${color.replace("#", "-")}` : ""; } else if (condition === "like") { if (column.substring(0, 1) === "s") { styleColor = record[column].indexOf(conditionValue) > -1 ? `SetRow_${color} color${color.replace("#", "-")}` : ""; } } else if (condition === ">") { styleColor = record[column] > conditionValue ? `SetRow_${color} color${color.replace("#", "-")}` : ""; } else if (condition === ">=") { styleColor = record[column] >= conditionValue ? `SetRow_${color} color${color.replace("#", "-")}` : ""; } else if (condition === "<") { styleColor = record[column] < conditionValue ? `SetRow_${color} color${color.replace("#", "-")}` : ""; } else if (condition === "<=") { styleColor = record[column] <= conditionValue ? `SetRow_${color} color${color.replace("#", "-")}` : ""; } } } styleColorArr += styleColor; } } styleColorArrTotal += `${styleColorArr} `; } } return styleColorArrTotal; }; /** 获取单元格颜色配置 */ getCellColorConfig = (text, record, sName) => { let styleColorArrTotal = ""; /* 单元格文字颜色 */ let styleColorArrTotalB = ""; /* 单元格背景颜色 */ let styleColorArr = ""; let styleColorArrB = ""; const styleColorArrTotalM = {}; const showConfigArr = this.getColorConfig(); /* 拿到颜色配置json */ if (commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) { for (const showConfig of showConfigArr) { const colorConditon = commonUtils.isNotEmptyObject(showConfig) ? showConfig.sColorTerms : null; if (commonUtils.isNotEmptyObject(colorConditon)) { let colorConditionArr = ""; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { colorConditionArr = ""; } colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ""; for (const item of colorConditionArr) { let styleColor = ""; // eslint-disable-next-line no-unused-vars let styleBackground = ""; const { column, condition, conditionValue, color, background, isRow } = item; if (!isRow) { /* 根据配置设置单元格颜色 */ if (column === sName && column === showConfig.sName) { /* 只控制该配置的单元格 */ if (condition === "=") { styleColor = record[column] === conditionValue ? color : ""; styleBackground = record[column] === conditionValue ? background : ""; } else if (condition === "like") { if (sName.substring(0, 1) === "s") { styleColor = record[column].indexOf(conditionValue) > -1 ? color : ""; styleBackground = record[column].indexOf(conditionValue) > -1 ? background : ""; } } else if (condition === "!=") { styleColor = record[column] !== conditionValue ? color : ""; styleBackground = record[column] !== conditionValue ? background : ""; } else if (condition === ">") { styleColor = record[column] > conditionValue ? color : ""; styleBackground = record[column] > conditionValue ? background : ""; } else if (condition === ">=") { styleColor = record[column] >= conditionValue ? color : ""; styleBackground = record[column] >= conditionValue ? background : ""; } else if (condition === "<") { styleColor = record[column] < conditionValue ? color : ""; styleBackground = record[column] < conditionValue ? background : ""; } else if (condition === "<=") { styleColor = record[column] <= conditionValue ? color : ""; styleBackground = record[column] <= conditionValue ? background : ""; } else if (Array.isArray(condition)) { /* 通过其他列条件控制该字段的颜色显示 */ if (commonUtils.isNotEmptyArr(condition)) { for (const itemConditon of condition) { const { bFilterName, bFilterCondition, bFilterValue, color, background } = itemConditon; if (bFilterCondition === "=") { styleColor = record[bFilterName] === bFilterValue ? color : ""; styleBackground = record[bFilterName] === bFilterValue ? background : ""; } else if (bFilterCondition === "like") { if (sName.substring(0, 1) === "s") { styleColor = record[bFilterName].indexOf(bFilterValue) > -1 ? color : ""; styleBackground = record[bFilterName].indexOf(bFilterValue) > -1 ? background : ""; } } else if (bFilterCondition === "!=") { styleColor = record[bFilterName] !== bFilterValue ? color : ""; styleBackground = record[bFilterName] !== bFilterValue ? background : ""; } else if (bFilterCondition === ">") { styleColor = record[bFilterName] > bFilterValue ? color : ""; styleBackground = record[bFilterName] > bFilterValue ? background : ""; } else if (bFilterCondition === ">=") { styleColor = record[bFilterName] >= bFilterValue ? color : ""; styleBackground = record[bFilterName] >= bFilterValue ? background : ""; } else if (bFilterCondition === "<") { styleColor = record[bFilterName] < bFilterValue ? color : ""; styleBackground = record[bFilterName] < bFilterValue ? background : ""; } else if (bFilterCondition === "<=") { styleColor = record[bFilterName] <= bFilterValue ? color : ""; styleBackground = record[bFilterName] <= bFilterValue ? background : ""; } } } } } } styleColorArr += styleColor; styleColorArrB += styleBackground; if (styleColor) { styleColorArr = styleColor; } if (styleBackground) { styleColorArrB = styleBackground; } } } styleColorArrTotal = styleColorArr; styleColorArrTotalB = styleColorArrB; } } const iIndex = showConfigArr.findIndex(item => item.sName === sName); if (iIndex !== -1) { const { sColorTerms } = showConfigArr[iIndex]; if (sColorTerms && sColorTerms.startsWith("#")) { styleColorArrTotal = sColorTerms; } } styleColorArrTotalM.styleColorArrTotal = styleColorArrTotal; styleColorArrTotalM.styleColorArrTotalB = styleColorArrTotalB; return styleColorArrTotalM; }; /** 获取table的表头信息(主要是table中的表头信息合并,[{title:1-1},{title:1-2}]变成[{title:1,children:[{title:1},{title:2}]}]) type:是否过滤 */ getTableColumn = (headerColumn, type, props) => { // this.hasMergeHeader = false; // 判断是否是表单详情 const isSlaveInfo = props.name === "slaveInfo" || (location.pathname === "/indexPage/commonCostomTabBill" && props.name.includes("Info") && commonUtils.isNotEmptyObject(this.props.slaveInfo)); const config = isSlaveInfo ? this.props.slaveInfo.config : this.props.config; /* 返回值声明 */ const tableColumn = []; let iIndex = 0; const specialRoute = commonUtils.isNotEmptyObject( this.props.app.currentPane ) ? this.props.app.currentPane.route : ""; /* 获取路由名称 */ /* 遍历每一个表头标题 */ for (const column of headerColumn) { /* 表头标题 */ const title = column.title; const width = column.width; const bNotEmpty = column.bNotEmpty; /* 带'-'的表头是需要合并滴 */ const index = commonUtils.isNotEmptyObject(title) ? title.indexOf("-") : -1; /* 合并走合并的,不合并就直接push */ let columnNew = {}; let sorter; let search = true; if ( props.tableProps !== undefined && props.tableProps.rowKey !== undefined && props.tableProps.rowKey !== "sId" && !props.tableProps.sortSelf ) { sorter = true; } else { const firstDataIndex = column.dataIndex.substring(0, 1); if (firstDataIndex === "d" || firstDataIndex === "i") { sorter = (a, b) => (commonUtils.isEmpty(a[column.dataIndex]) ? 0 : a[column.dataIndex]) - (commonUtils.isEmpty(b[column.dataIndex]) ? 0 : b[column.dataIndex]); } else if (firstDataIndex === "t") { sorter = (a, b) => moment( commonUtils.isEmpty(a[column.dataIndex]) ? "2000-01-01" : a[column.dataIndex] ).diff( moment( commonUtils.isEmpty(b[column.dataIndex]) ? "2000-01-01" : b[column.dataIndex] ) ); } else { sorter = (a, b) => (commonUtils.isEmpty(a[column.dataIndex]) ? "0" : a[column.dataIndex] ).localeCompare( commonUtils.isEmpty(b[column.dataIndex]) ? "1" : b[column.dataIndex] ); } } /* 工单、工艺卡、报价单 去掉排序 */ if ( this.props.name === "sParam" || specialRoute.includes("workOrder") || specialRoute.includes("processCard") || specialRoute.includes("quotation") ) { sorter = false; } /* 默认字段是排序的 通过配置bNotSort来设置字段不排序 */ if ( config && commonUtils.isNotEmptyStr( config.gdsconfigformslave.filter( item => item.sName === column.dataIndex ) ) ) { if ( config.gdsconfigformslave.filter( item => item.sName === column.dataIndex ).length > 0 && config.gdsconfigformslave.filter( item => item.sName === column.dataIndex )[0].bNotSort ) { sorter = false; } } if ( config && commonUtils.isNotEmptyStr( config.gdsconfigformslave.filter( item => item.sName === column.dataIndex ) ) ) { if ( config.gdsconfigformslave.filter( item => item.sName === column.dataIndex )[0].bNotSearch ) { search = false; } } if ( column.dataIndex === "spicture" || column.dataIndex === "tableLastEmpty" || props.data?.some(item => item.costomEnabledList?.includes(column.dataIndex) ) ) { sorter = false; } let sTitleBgColor = commonUtils.isNotEmptyObject(column.sTitleBgColor) ? column.sTitleBgColor : ""; /* 标题背景颜色 */ let sTitleColor = commonUtils.isNotEmptyObject(column.sTitleColor) ? column.sTitleColor : ""; /* 标题字体颜色 */ const styleObj = {}; if (commonUtils.isNotEmptyObject(sTitleBgColor)) { styleObj.background = sTitleBgColor; } if (commonUtils.isNotEmptyObject(sTitleColor)) { styleObj.color = sTitleColor; } const renderTitle = () => { // 树形表格在第一个column上加上全部展开/收起功能 let expandedAllIcon = ""; const columnIndex = headerColumn.findIndex( item => column.title === item.title ); let { data } = this.props; let { expKeys } = this.state; expKeys = commonUtils.isNotEmptyArr(expKeys) ? expKeys : []; expKeys = this.currentExpKeys || expKeys; data = commonUtils.isNotEmptyArr(data) ? data : []; const childrenList = []; const getChildrenList = data => { data.forEach(item => { if (item && typeof item.children === "object") { childrenList.push(item); getChildrenList(item.children); } }); }; getChildrenList(data); if (columnIndex === 0 && childrenList.length) { // 第一个column并且数据中有children this.showExpAll = true; this.tableCollapsed = !expKeys.length; const marginLeft = this.props.bMutiSelect ? "6px" : "2px"; expandedAllIcon = ( ); })} {bEmptyTableBtnsConfig ? ( ) : ( "" )} {props.mesCopy ? props.mesCopy({ tableName: props.name, record, index, tableClassName: this.state.tableClassName }) : ""} {props.mesSave ? props.mesSave() : ""} {props.mesDel ? props.mesDel({ tableName: props.name, record, index }) : ""}
); }, title: () => (
{setOperation}
{/* 班组报工行车记录 */} {["12710101117087404588200", "12710101117260270570210"].includes( props.formId ) && props.name === "table0" ? ( // || // (props.formId === "12710101117087371044360" && // props.name === "slave0") ) : ( "" )} {props.mesAdd ? props.mesAdd({ tableName: props.name, tableClassName: this.state.tableClassName }) : ""} {props.choosePlate()}
), width: tableBtnsWidth, fixed: "right" }; const isReverse = props.config.gdsconfigformslave?.find( item => item.sControlName?.toLowerCase() === "operation_reverse" ); if (isReverse) { tableColumn.unshift({ ...operationCol, fixed: "left" }); } else { tableColumn.push(operationCol); } } else if (this.props.setOpterationColumnBak === "Y") { /* 获取choose的props */ const chooseProcessProps = { ...this.getChooseProcessPropsTableRow(), disabled: false }; /* 获取modal的props */ const modalProps = { ...this.getModalPropsTableRow(), disabled: false }; /* 获取modal的props */ const modalRemarkProps = { ...this.getModalRemarkPropsTableRow(), disabled: false, style: { display: "block", margin: "0 10px" } }; /* 获取add的props */ const addProps = { ...this.getAddPropsTableRow(), disabled: false }; const headProps = { ...this.getHeadPropsTableRow(), disabled: false }; /* 获取del的props */ const delProps = { ...this.getDelPropsTableRow(), disabled: false }; /* 获取复制的props */ const copyProps = { ...this.getCopyProps(), disabled: false }; /* 通用弹窗按钮 */ const choosePopupProps = { ...this.getPopupPropsTableRow(), disabled: false }; const chooseParamProps = { ...this.getParamPropsTableRow(), disabled: false }; /* 通用弹窗按钮 */ const chooseProductProcessProps = { ...this.getChooseProductProcessPropsTableRow(), disabled: false }; /* 通用弹窗按钮 */ const chooseProductMaterialsProps = { ...this.getChooseProductMaterialsPropsTableRow(), disabled: false }; /* 获取复制全部的props */ // const copyAllProps = { ...this.getCopyAllProps(), disabled: false, style: { display: 'block', margin: '0 10px' } }; const copyAllProps = { ...this.getCopyAllProps(), disabled: false }; const uploadProps = { ...this.getUploadProps(), disabled: false, style: { margin: "0 10px", "caret-color": "transparent" } }; const downloadProps = { ...this.getDownProps(), disabled: false, style: { display: "block", margin: "0 5px" } }; const { formId } = props; const { token } = props.app; const divProps = { action: `${ commonConfig.server_host }file/upload?sModelsId=${formId}&token=${token}`, onChange: this.handleUploadChange, accept: "*/*", showUploadList: false, multiple: true, beforeUpload: this.handleBeforeUpload }; const addIcon = props.tableProps.setAdd; /* 增加操作 */ const copyIcon = props.tableProps.setCopy; /* 复制操作 */ const copyAllIcon = props.tableProps.setCopyAll; /* 复制部件操作 */ const delIcon = props.tableProps.setDelete; /* 删除操作 */ const materialIcon = props.tableProps.setMaterial; /* 材料操作 */ const processIcon = props.tableProps.setProcess; /* 工序操作 */ const materailremarkIcon = props.tableProps.setMaterialRemark; /* 材料备注 */ let uploadIcon = props.tableProps.setUpload; /* 上传 */ let downloadIcon = props.tableProps.setDownload; /* 下载 */ let headPopup = false; /* 表头放大镜 */ const bShowTreeAdd = props.tableProps.bShowTreeAdd && this.findIsExistByControlName(props, "BtnAdd"); /* 添加树节点 */ const bShowTreeAddChild = props.tableProps.bShowTreeAddChild && this.findIsExistByControlName( props, "BtnAddChildNode" ); /* 添加树节点 */ const bShowTreeDel = props.tableProps.bShowTreeDel && this.findIsExistByControlName(props, "BtnDel"); /* 添加树节点 */ const bShowTreeCopyAll = props.tableProps.bShowTreeCopyAll && this.findIsExistByControlName(props, "BtnCopyAll"); /* 添加树节点 */ const exitIcon = props.tableProps.setExit; /* 退出操作 */ let bShowProductProcess = false; /* 选择成品工序 */ if ( commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.tableProps) && props.tableProps.bShowProductProcess !== undefined ) { bShowProductProcess = props.tableProps.bShowProductProcess; /* 选择成品工序 */ } let bShowProductMaterials = false; /* 选择成品材料 */ if ( commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.tableProps) && props.tableProps.bShowProductMaterials !== undefined ) { bShowProductMaterials = props.tableProps.bShowProductMaterials; /* 选择成品工序 */ } /* 操作栏设置上传 */ uploadIcon = this.findVisibleControlName(this.props, "BtnSetUpload"); downloadIcon = this.findVisibleControlName(this.props, "BtnSetDownload"); headPopup = this.findVisibleControlName( this.props, "BtnHeadPopup" ); /* 表头放大镜 */ const setNoCommonOperate = props.tableProps.setNoCommonOperate; /* 没有默认的增加删除按钮 */ let operateWidth = 0; if (addProps.style.display === "inline-block") { operateWidth += 40; } if (delProps.style.display === "inline-block") { operateWidth += 40; } if (copyProps.style.display === "inline-block") { operateWidth += 40; } if (copyAllProps.style.display === "inline-block") { operateWidth += 40; } if (setNoCommonOperate) { operateWidth = 0; } if (!setNoCommonOperate && this.props.name === "sWorkOrderParamList") { operateWidth -= 80; } if (this.props.bHideCopyAll) { operateWidth -= 40; } if (modalProps.style.display === "inline-block") { operateWidth += 40; } if (!commonUtils.isEmpty(materailremarkIcon)) { operateWidth += 40; } if (chooseProcessProps.style.display === "inline-block") { operateWidth += 40; } if (choosePopupProps.style.display === "inline-block") { operateWidth += 40; } if (chooseParamProps.style.display === "inline-block") { operateWidth += 40; } if (bShowProductProcess) { operateWidth += 40; } if (bShowTreeAdd) { operateWidth += 40; } if (bShowTreeAddChild) { operateWidth += 40; } if (bShowTreeDel) { operateWidth += 40; } if (bShowTreeCopyAll) { operateWidth += 40; } if (bShowProductMaterials) { operateWidth += 40; } if (exitIcon) { operateWidth += 60; } if (headPopup) { operateWidth += 20; } let scrollWidth = 18; if ( commonUtils.isNotEmptyStr(this.props.tableProps.f) && this.props.tableProps.AutoTableHeight.indexOf("calc") === -1 ) { /* 固定列计算 */ scrollWidth = 0; } const tableAllWidth = tableWidth + CheckBoxWidth + operateWidth + lastRowOld; if (commonUtils.isNotEmptyObject(props.tableProps.CalLastWidth)) { this.tableContentWidth = props.tableProps.CalLastWidth; /* 解决材料与工艺Modal最后一行问题 */ scrollWidth = 18; } let lastRow = 0; if (props.bNaturalWidth) { /* 取后台配置原始宽度 不进行最后一列计算 */ tableColumn[tableColumn.length - 1].width = lastRowOld; } else if (tableAllWidth < this.tableContentWidth) { lastRow = this.tableContentWidth - tableWidth - operateWidth - CheckBoxWidth - scrollWidth - 1; // 1像素为border宽度; if (lastRow > 0 && tableColumn.length > 0) { delete tableColumn[tableColumn.length - 1].width; // tableColumn[tableColumn.length - 1].width = lastRow;; } } else if (tableColumn.length > 0) { tableColumn[tableColumn.length - 1].width = lastRowOld; } /* 动态加载操作行 */ tableColumn.push({ dataIndex: "operation", render: (text, record, index) => { let operateAdd = null; let operateCopy = null; let operateDel = null; let operateMaterial = null; let operateProcess = null; let operateCopyAll = null; let operateMaterailRemark = null; let operateDownload = null; let operatePopupModal = null; let operateParamModal = null; let operateProductProcess = null; let operateProductMaterials = null; let operateTreeAdd = null; let operateTreeDel = null; let operateTreeCopyAll = null; let operateTreeAddChild = null; let operateExit = null; const setAdd = commonFunc.showMessage( props.app.commonConst, "setAdd" ); /* 新增s */ const setCopy = commonFunc.showMessage( props.app.commonConst, "setCopy" ); /* 复制 */ const setDelete = commonFunc.showMessage( props.app.commonConst, "setDelete" ); /* 删除 */ const setCopyAll = commonFunc.showMessage( props.app.commonConst, "setCopyAll" ); /* 复制部件 */ let { rowTag } = record; /* 锁定行标识 */ const { sWorkOrderUsed } = record; /* 订单被工单占用,则该行不能修改、删除 */ if (commonUtils.isNotEmptyObject(sWorkOrderUsed)) { record.rowTag = 1; rowTag = 1; } if (commonUtils.isNotEmptyObject(this.props.sUseInfo)) { rowTag = 1; } /** 树节点添加 */ if (bShowTreeAdd) { operateTreeAdd = ( {props.enabled ? ( ) : ( )} ); } /** 树节点删除 */ if (bShowTreeDel) { operateTreeDel = ( {props.enabled ? ( ) : ( )} ); } /** 树节点添加子类 */ if (bShowTreeAddChild) { operateTreeAddChild = ( {props.enabled ? ( ) : ( )} ); } /** 树节点复制 */ if (bShowTreeCopyAll) { operateTreeCopyAll = ( {props.enabled ? ( ) : ( )} ); } /** 放置添加图标 添加为默认显示 */ if (!commonUtils.isEmpty(addIcon)) { operateAdd = ( {props.enabled || this.findIsUpdByControlName(this.props, "BtnAdd") ? ( ) : ( )} ); } else { operateAdd = ( {" "} {props.enabled || this.findIsUpdByControlName(this.props, "BtnAdd") ? ( ) : ( )} ); // if (uploadIcon) { // operateAdd = ''; /* 通用上传不用复制 */ // } if (setNoCommonOperate) { operateAdd = ""; } } /** 放置复制图标 */ if (!commonUtils.isEmpty(copyIcon)) { operateCopy = ( {props.enabled ? ( ) : ( )} ); } else { operateCopy = ( {" "} {props.enabled ? ( ) : ( )} ); // if (uploadIcon) { // operateCopy = '';/* 通用上传不用复制 */ // } if ( setNoCommonOperate || this.props.name === "sWorkOrderParamList" ) { operateCopy = ""; } } /** 放置复制部件图标 */ if (!commonUtils.isEmpty(copyAllIcon)) { operateCopyAll = ( {props.enabled && rowTag !== 1 ? ( ) : ( )} ); } else { operateCopyAll = ( {props.enabled || this.findIsUpdByControlName(this.props, "BtnCopyAll") ? ( ) : ( )} ); if ( setNoCommonOperate || this.props.bHideCopyAll || this.props.name === "sWorkOrderParamList" ) { operateCopyAll = ""; } } /** 放置删除图标 删除为默认显示 */ if (!commonUtils.isEmpty(delIcon)) { operateDel = ( {props.enabled && rowTag !== 1 ? ( ) : ( )} ); } else { operateDel = ( {props.enabled || this.findIsUpdByControlName(this.props, "BtnDel") ? ( ) : ( )} ); if (setNoCommonOperate) { operateDel = ""; } } /** 放置选择材料图标 */ if (!commonUtils.isEmpty(materialIcon)) { const setMaterial = commonFunc.showMessage( props.app.commonConst, "setMaterial" ); /* 选择材料 */ operateMaterial = ( {props.enabled && rowTag !== 1 ? ( ) : ( )} ); } /** 放置材料备注图标 */ if (!commonUtils.isEmpty(materailremarkIcon)) { const setMaterailRemark = commonFunc.showMessage( props.app.commonConst, "setMaterailRemark" ); /* 选择材料工艺 */ operateMaterailRemark = ( ); } /** 放置选择工序材料图标 */ if (!commonUtils.isEmpty(processIcon)) { const setProcess = commonFunc.showMessage( props.app.commonConst, "setProcess" ); /* 选择工序 */ operateProcess = ( {props.enabled ? ( ) : ( )} ); } /** 选择成品工序图标 */ if (bShowProductProcess) { const setProductProcess = commonFunc.showMessage( props.app.commonConst, "setProductProcess" ); /* 选择成品工序 */ operateProductProcess = ( {props.enabled ? ( ) : ( )} ); } /** 选择成品材料图标 */ if (bShowProductMaterials) { const setProductMaterials = commonFunc.showMessage( props.app.commonConst, "setProductMaterials" ); /* 选择成品材料 */ operateProductMaterials = ( {props.enabled ? ( ) : ( )} ); } if (downloadIcon) { const setDownload = commonFunc.showMessage( props.app.commonConst, "setDownload" ); /* 下载 */ operateDownload = ( {} ); } if (this.isPopupShow) { const setDownload = commonFunc.showMessage( props.app.commonConst, "setPopup" ); /* 弹窗 */ operatePopupModal = ( {props.enabled ? ( ) : ( )} ); } if (this.isParamShow) { const setParam = commonUtils.isNotEmptyObject( commonFunc.showMessage(props.app.commonConst, "setParam") ) ? commonFunc.showMessage(props.app.commonConst, "setParam") : "查看参数"; /* 参数 */ operateParamModal = ( { 查看工艺参数 } ); } if (exitIcon) { const setExit = "退出"; operateExit = ( {} ); } return (
{operateTreeAdd} {operateTreeAddChild} {operateTreeCopyAll} {operateTreeDel} {operateAdd} {operatePopupModal} {operateCopy} {operateCopyAll} {operateMaterial} {operateProductMaterials} {operateMaterailRemark} {operateProcess} {operateParamModal} {operateDel} {operateDownload} {operateProductProcess} {operateExit}
); }, title: () => this.props.setOpterationColumn === "Y" && this.getTableFilterData() === 0 ? ( 操作{" "} {uploadIcon ? ( { this.uploadRef1 = ref; }} onPaste={this.handleUploadByClipboard} onMouseOver={() => { this.uploadRef1.setAttribute("contenteditable", "true"); }} onKeyDown={() => { this.uploadRef1.setAttribute("contenteditable", "false"); }} onKeyUp={() => { this.uploadRef1.setAttribute("contenteditable", "true"); }} > {this.props.enabled ? ( ) : ( )} ) : ( {props.enabled || this.findIsUpdByControlName(this.props, "BtnAdd") ? ( ) : ( )} {headPopup ? ( {props.enabled || this.findIsUpdByControlName( this.props, "BtnHeadPopup" ) ? ( ) : ( )} ) : ( "" )} )} ) : uploadIcon ? ( {" "} { this.uploadRef1 = ref; }} onPaste={this.handleUploadByClipboard} onMouseOver={() => { this.uploadRef1.setAttribute("contenteditable", "true"); }} onKeyDown={() => { this.uploadRef1.setAttribute("contenteditable", "false"); }} onKeyUp={() => { this.uploadRef1.setAttribute("contenteditable", "true"); }} > {this.props.enabled ? ( ) : ( )} ) : ( {" "} 操作{" "} {headPopup ? ( {props.enabled || this.findIsUpdByControlName(this.props, "BtnHeadPopup") ? ( ) : ( )} ) : ( "" )}{" "} ), width: operateWidth + "px", // fixed: commonUtils.isNotEmptyObject(this.props.tableProps.AutoTableHeight) ? 'right' : false, fixed: "right" }); } else { const tableAllWidth = tableWidth + lastRowOld + CheckBoxWidth; if (tableAllWidth < this.tableContentWidth) { const lastRow = this.tableContentWidth - tableWidth - CheckBoxWidth - 18; /* ant-table-body的div宽度-操作列宽度-选择列宽度36 */ if (lastRow > 0 && tableColumn.length > 0 && lastRow > lastRowOld) { delete tableColumn[tableColumn.length - 1].width; // tableColumn[tableColumn.length - 1].width = lastRow; } } } /* 返回值 s */ return tableColumn; }; getColumnSearchProps = (iIndex, column, type, props, search) => { const returnProps = {}; if ( props.onFilterData !== undefined && iIndex === 0 && type === "filter" && !this.resize ) { returnProps.onFilter = props.onFilterData.bind( this, props.name, column.dataIndex ); } else if ( column.dataIndex !== undefined && column.bFind && type === "filter" && !this.resize ) { if (!search) { return false; } returnProps.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => { return (
{ this.searchInput = node; }} // onClick={this.handleInputOnClick.bind(this, 'searchInput')} placeholder={`Search ${column.title}`} value={selectedKeys[0]} onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : []) } onPressEnter={() => this.handleSearch( selectedKeys, confirm, column.dataIndex, clearFilters ) } style={{ marginBottom: 8 }} />
); }; returnProps.filterIcon = filtered => ( ); returnProps.onFilterDropdownVisibleChange = visible => { if (visible) { setTimeout(() => this.searchInput.select()); } }; returnProps.onFilter = (value, record) => { let sValue = record[column.dataIndex]; const dropdownData = commonUtils.getStoreDropDownData( props.formId, props.name, column.dataIndex ); if (commonUtils.isNotEmptyArr(dropdownData)) { const sId = commonUtils.isEmpty(dropdownData[0].sSlaveId) ? "sId" : "sSlaveId"; const iDropdownIndex = dropdownData.findIndex( item => item[sId] === record[column.dataIndex] ); if (iDropdownIndex > -1) { const sFieldName = Object.keys(dropdownData[iDropdownIndex])[0]; sValue = dropdownData[iDropdownIndex][sFieldName]; } } else { const staticDropdownData = commonUtils.getStoreStaticDropDownData( props.formId, column.dataIndex ); if (commonUtils.isNotEmptyObject(staticDropdownData)) { sValue = staticDropdownData[sValue]; } } // 核检废过滤板号特殊处理 if ( location.pathname?.startsWith("/indexPad") && column.dataIndex === "sBoardNo" ) { return sValue.toString().toLowerCase() === value.toLowerCase(); } if (record[column.dataIndex] !== undefined && sValue !== undefined) { return sValue .toString() .toLowerCase() .includes(value.toLowerCase()); } else { return "" .toString() .toLowerCase() .includes(value.toLowerCase()); } }; if (!props.enabled) { returnProps.render = (text, record, index) => { // 此处添加了row的index,原先一次渲染中包含searchProps的行的iIndex会相同,无法对行判断进行单元格合并 let sValue = record[column.dataIndex]; const dropdownData = commonUtils.getStoreDropDownData( props.formId, props.name, column.dataIndex ); if (commonUtils.isNotEmptyArr(dropdownData)) { const sId = commonUtils.isEmpty(dropdownData[0].sSlaveId) ? "sId" : "sSlaveId"; const iDropdownIndex = dropdownData.findIndex( item => item[sId] === record[column.dataIndex] ); if (text !== undefined && iDropdownIndex > -1) { const sFieldName = Object.keys(dropdownData[iDropdownIndex])[0]; sValue = dropdownData[iDropdownIndex][sFieldName]; } } if ( !commonUtils.isEmpty(this.state.searchText) && column.bFind && column.dataIndex === this.state.searchColumnName && column.dataIndex.substring(0, 1) !== "b" && column.dataIndex.substring(0, 1) !== "t" ) { return ( ); } else { return this.bindShowType( props, text, record, column.dataIndex, index ); } }; } } return returnProps; }; /** 获取ShowType的props */ getShowTypeProps = (props, text, record, sName) => { const { enabled, sUseInfo, app, masterData } = props; /* 待用数据 */ const showConfig = this.getShowConfig(props, sName); /* 配置信息 */ if (commonUtils.isEmptyObject(showConfig)) { console.log("渲染失败:", showConfig, sName); } /* 返回值 */ let enabledNew = enabled && !showConfig.bReadonly && !record.bInvalid && commonUtils.isEmpty(sUseInfo); if (showConfig.iTag === 1) { enabledNew = false; } else if (showConfig.iTag === 3) { if (commonUtils.isNotEmptyObject(masterData) && !masterData.bCheck) { enabledNew = true; } } else if (record.rowTag === 1) { /* 当rowTag为1时,锁定该行不可编辑 */ enabledNew = false; } if (sName === "sLabelColor") { enabledNew = true; } if (record.costomEnabledList?.includes(sName)) { enabledNew = true; } /* 红冲中的单据 不可修改 */ if ( commonUtils.isNotEmptyObject(masterData) && (commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed)) ) { // 红冲中可修改的字段 const iIndex = props.config.gdsconfigformslave.findIndex( item => item.sName === sName && item.sControlName.includes("portionField") ); enabledNew = iIndex !== -1; } const showConfigAll = this.getColorConfig(); /* 拿到颜色配置json */ const showConfigArr = commonUtils.isNotEmptyArr(showConfigAll) ? showConfigAll.filter(item => item.sName === sName) : []; /* 找到该字段颜色配置 */ const colorConditon = commonUtils.isNotEmptyArr(showConfigArr) ? showConfigArr[0].sColorTerms : null; let styleColorArr = ""; if (commonUtils.isNotEmptyObject(colorConditon)) { let colorConditionArr = ""; try { colorConditionArr = JSON.parse(colorConditon); /* 转化为json */ } catch (e) { colorConditionArr = ""; } colorConditionArr = Array.isArray(colorConditionArr) ? colorConditionArr : ""; for (const item of colorConditionArr) { let styleColor = ""; const { column, condition, conditionValue, background, isRow } = item; if (!isRow) { /* 根据配置设置单元格颜色 */ if (column === sName && !commonUtils.isEmpty(record[column])) { if (condition === "=") { styleColor = record[column] === conditionValue ? `SetCell_${background}` : ""; } else if (condition === "like") { if (sName.substring(0, 1) === "s") { styleColor = record[column].indexOf(conditionValue) > -1 ? `SetCell_${color}` : ""; } } else if (condition === ">") { styleColor = record[column] > conditionValue ? `SetCell_${background}` : ""; } else if (condition === ">=") { styleColor = record[column] >= conditionValue ? `SetCell_${background}` : ""; } else if (condition === "<") { styleColor = record[column] < conditionValue ? `SetCell_${background}` : ""; } else if (condition === "<=") { styleColor = record[column] <= conditionValue ? `SetCell_${background}` : ""; } } } styleColorArr += styleColor; } } const addState = {}; if (props.allowClear != undefined) { addState.allowClear = props.allowClear; } return { app, record, name: props.name, configName: props.configName, sTabId: props.sTabId, sId: record.sId /* 修改当前编号(数据格式:字符串) */, dataValue: text /* 本showType数据(数据格式:对象) */, enabled: enabledNew /* 是否是查看状态(数据格式:布尔) */, showConfig /* 关于本showType相关配置(数据格式:对象) */, tableConfig: props.config /* 表格的所有配置 */, formId: this.formId /* 窗体Id(数据格式:字符串) */, slaveConfig: this.props.config, onChange: props.onDataChange /* 表单数据改变事件方法(数据格式:函数) */, onKeyDown: props.onKeyDown, onContextMenu: props.onContextMenu /* 字段右侧单击事件 */, bTable: true /* 是否为表格数据 */, getSqlDropDownData: props.getSqlDropDownData, getSqlCondition: props.getSqlCondition, handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord, getFloatNum: props.getFloatNum, getDateFormat: props.getDateFormat, onViewClick: this.handleViewClick, onViewChoose: this.handleViewChoose, onPreviewImage: this.handlePreviewImage, onPreviewOffice: this.handlePreviewOffice, onDropdownVisibleChange: this.handleDropdownVisibleChange, onFilterDropDownData: props.onFilterDropDownData, onFieldPopupModal: this.handleFieldPopupModal /* 字段选择弹窗 */, onFieldDoubleClick: this.props.onFieldDoubleClick, onDropDownBlur: props.onDropDownBlur /* 下拉框多选离开事件 */, className: styleColorArr, readOnly: props.readOnly, onSaveState: props.onSaveState, formRoute: props.formRoute, customDropData: props.customDropData, onExecInstructSet: props.parentProps.onExecInstructSet, ...addState // handleSum: this.handleSum, }; }; /** 获取上传控件的props */ getUploadProps = () => { return { disabled: this.props.name === "picFile" ? !this.findIsUpdByControlName(this.props, "BtnUpload") : !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isUploadShow) } /* 是否显示 */ }; }; /** 获取下载控件的props */ getDownProps = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isDownloadShow) } /* 是否显示 */ }; }; /** 获取查看控件的props */ getLookProps = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isLookShow) } /* 是否显示 */, onClick: this.handleLookRow /* 点击事件 */ }; }; /** 获取添加控件的props */ getAddProps = () => { return { disabled: !this.props.enabled || this.findIsUpdByControlName(this.props, "BtnAdd") /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isAddShow) } /* 是否显示 */, onClick: this.handleAddRow /* 点击事件 */ }; }; getModalPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isModalShow), margin: "0 10px" } /* 是否显示 */ }; }; getModalRemarkPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock( this.isModalRemarkShow ) } /* 是否显示 */ }; }; getChooseProcessPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock( this.isChooseProcessShow ), margin: "0 10px" } /* 是否显示 */ }; }; getChooseProductProcessPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock( this.isChooseProductProcess ), margin: "0 10px" } /* 是否显示 */ }; }; getChooseProductMaterialsPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock( this.isChooseProductMaterials ), margin: "0 10px" } /* 是否显示 */ }; }; getAddPropsTableRow = () => { return { disabled: !this.props.enabled || !this.findIsUpdByControlName(this.props, "BtnAdd") /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isAddShow), margin: "0 10px" } /* 是否显示 */ }; }; getHeadPropsTableRow = () => { return { disabled: false /* 是否可用 */, style: { margin: "0 0" } /* 是否显示 */ }; }; /** 获取复制控件的props */ getCopyProps = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isCopyShow), margin: "0 10px" } /* 是否显示 */, onClick: this.handleCopyRow /* 点击事件 */ }; }; /** 获取复制全部控件的props */ getCopyAllProps = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isCopyAllShow), margin: "0 10px" } /* 是否显示 */, onClick: this.handleCopyAllRow /* 点击事件 */ }; }; /** 获取删除控件的props */ getDelProps = () => { return { disabled: !this.props.enabled || this.findIsUpdByControlName(this.props, "BtnDel") /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isDelShow) } /* 是否显示 */, className: styles.del /* 样式名 */, onClick: this.handleDelRow /* 点击事件 */ }; }; getDelPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isDelShow), margin: "0 10px" } /* 是否显示 */, className: styles.del /* 样式名 */ }; }; getPopupPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, style: { display: commonUtils.convertBooleanToDisplayBlock(this.isPopupShow), margin: "0 10px" } /* 是否显示 */ }; }; getParamPropsTableRow = () => { return { disabled: !this.props.enabled /* 是否可用 */, // style: { display: commonUtils.convertBooleanToDisplayBlock(this.isParamShow), margin: '0 10px' }, /* 是否显示 */ style: { display: "block", margin: "0 10px" } /* 是否显示 */ }; }; /** 生成单元格stateMap */ genMergeCellStateMap() { let config = []; if (this.props.customConfig) { config = this.props.customConfig; } else { if (this.props.config) { config = this.props.config.gdsconfigformslave; } } this.mergeCellStateMap = config.length && config.reduce((prev, cur) => { if (cur.sName) { prev[cur.sName] = cur.bMergeCell; if (cur.bMergeCell) { this.mergeCellList.push(cur.sName); } } return { ...prev }; }, {}); } genMergeInfoCellStateMap() { this.mergeInfoCellStateMap = this.props.slaveInfo.config && this.props.slaveInfo.config.gdsconfigformslave.reduce((prev, cur) => { if (cur.sName) { prev[cur.sName] = cur.bMergeCell; } return { ...prev }; }, {}); } /** 生成单元格list记录Map */ genMergeListStateMap() { let bPagination = true; /* 默认表格分页s */ let pagination = {}; if (commonUtils.isNotEmptyObject(this.props)) { bPagination = commonUtils.isNotEmptyObject(this.props.tableProps) && commonUtils.isNotEmptyObject(this.props.tableProps.pagination); pagination = this.props.tableProps.pagination; } let data; if (commonUtils.isNotEmptyArr(this.tableFilterData)) { const sSlaveIdArr = this.tableFilterData.map(item => item.sSlaveId); data = this.props.data.filter(item => sSlaveIdArr.includes(item.sSlaveId) ); } else if (bPagination) { const { pageSize, current } = commonUtils.isNotEmptyObject( this.curPagination ) ? this.curPagination : pagination; this.curPagination = {}; // 如果数据条数大于每页条数,说明是假分页,要截取当前页数据 if (this.props.data && pageSize && this.props.data.length > pageSize) { const maxCurrent = Math.ceil(this.props.data.length / pageSize); const newCurrent = Math.min(maxCurrent, current); const startIndex = (newCurrent - 1) * pageSize; const endIndex = startIndex + pageSize; data = this.props.data.slice(startIndex, endIndex); } else { data = this.props.data; } } else { data = this.props.data; } if (!data) { return; } /* 如果是树形 则返回 */ if (this.props.sTableType && this.props.sTableType != "zero") { return; } const obj = {}; let sColorIndex = 1; let config = []; if (this.props.customConfig) { config = this.props.customConfig; } else { if (this.props.config) { config = this.props.config.gdsconfigformslave; } } data.forEach((item, index) => { const mergeCellData = config.filter( item => item.sName === "sMergeCellFiled" ); /* 查找合并单元格的基准字段 */ const sMergeCellFiled = commonUtils.isNotEmptyArr(mergeCellData) ? mergeCellData[0].sActiveKey : ""; /* 基准字段 */ if (index === 0 && commonUtils.isNotEmptyArr(this.mergeCellList)) { item.sColor = ""; } // 第一条数据不需要检测 if (index !== 0) { const prevData = data[index - 1]; let flag = false; for (const key in item) { // 判断是否与上一个值相同 if ( item[key] !== "" && item[key] === prevData[key] && (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true) ) { if (!obj[key]) { obj[key] = []; } obj[key].push(index - 1); if (this.mergeCellList.includes(key)) { flag = true; } } } if (commonUtils.isNotEmptyArr(this.mergeCellList)) { if (flag) { item.sColor = sColorIndex % 2 === 0 ? "dark-record-row" : ""; } else { sColorIndex++; item.sColor = sColorIndex % 2 === 0 ? "dark-record-row" : ""; } } } }); for (const key in obj) { obj[key] = obj[key] .reduce((prev, cur) => { if (prev.length && cur - prev[0][0] === 1) { prev[0].unshift(cur); } else { prev.unshift([cur]); } return prev; }, []) .reverse() .map(a => a.reverse()); } this.mergeCellListMap = obj; } genMergeInfoListStateMap() { if (!this.curSlaveInfoData) { return; } const obj = {}; this.curSlaveInfoData.forEach((item, index) => { const mergeCellData = this.props.slaveInfo.config && this.props.slaveInfo.config.gdsconfigformslave.filter( item => item.sName === "sMergeCellFiled" ); /* 查找合并单元格的基准字段 */ const sMergeCellFiled = commonUtils.isNotEmptyArr(mergeCellData) ? mergeCellData[0].sActiveKey : ""; /* 基准字段 */ // 第一条数据不需要检测 if (index !== 0) { const prevData = this.curSlaveInfoData[index - 1]; for (const key in item) { // 判断是否与上一个值相同 if ( item[key] !== "" && item[key] === prevData[key] && (commonUtils.isNotEmptyObject(sMergeCellFiled) ? item[sMergeCellFiled] === prevData[sMergeCellFiled] : true) ) { if (!obj[key]) { obj[key] = []; } obj[key].push(index - 1); } } } }); for (const key in obj) { obj[key] = obj[key] .reduce((prev, cur) => { if (prev.length && cur - prev[0][0] === 1) { prev[0].unshift(cur); } else { prev.unshift([cur]); } return prev; }, []) .reverse() .map(a => a.reverse()); } this.mergeInfoCellListMap = obj; } modalTbRow = (record, tableName) => { this.handleModalRow(record, tableName); }; modalRemarkTbRow = async record => { await this.onRowClick(record); this.handleModalRemarkRow(record); }; chooseProcessTbRow = record => { this.handleChooseProcessRow(record); }; /* 选择成品工序 */ chooseProductProcessModalTbRow = (index, record) => { this.handleChooseProductProcessRow(index, record); }; /* 选择成品材料 */ chooseProductMaterialsModalTbRow = (index, record) => { this.handleChooseProductMaterialsRow(index, record); }; addTbRow = index => { this.handleAddRow(index); }; addTbRowInHeader = index => { this.handleAddRow(index, this.props.bModalAdd); }; delTbRow = (index, record) => { this.handleDelRow(index, record); }; /* 被占用的表格行不能删除 */ handleTbRowUsed = (index, record) => { const { rowTag, sWorkorderNo } = record; const { enabled } = this.props; if (enabled && rowTag === 1) { const warning = commonFunc.showMessage( this.props.app.commonConst, "beUsed" ); /* 复制部件 */ const { sModelsType } = this.props.app.currentPane; if (sModelsType.includes("sales/")) { message.error(warning + sWorkorderNo); } } else { return null; } }; handleSelectCancel = modelVisible => { this.setState({ [modelVisible]: false }); }; handleSelectCommonPopup = (name, selectConfig, selectData) => { const { commonPopupTbName, commonPopupShowConfig } = this.state; /* 若是产品名称弹窗 并且配置了调用产品工艺卡标识copyFromTechnology 则走自己的逻辑 */ if (selectConfig.sCompareColor === "copyFromTechnology") { this.props.onSelectCommonPopupProduct( name, selectConfig, selectData, commonPopupTbName, commonPopupShowConfig ); } else { this.props.onSelectCommonPopup( name, selectConfig, selectData, commonPopupTbName, commonPopupShowConfig ); } }; handleSelectCommonFieldPopup = (name, selectConfig, selectData) => { const { commonFieldPopupTbName, commonFieldPopupShowConfig } = this.state; this.handleSelectCommonPopupNew( name, selectConfig, selectData, commonFieldPopupTbName, commonFieldPopupShowConfig ); }; handleSelectCommonPopupNew = ( currentPaneName, selectConfig, selectData, tbName ) => { const { [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData } = this.props.parentProps; let { [`${tbName}Data`]: tableData } = this.props.parentProps; if ( commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData) ) { const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0]) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1; selectData.forEach((item, index) => { const newCopyTo = {}; newCopyTo.master = masterData; const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */ let sValue = ""; if (iIndex > -1) { newCopyTo.slave = tableData[iIndex]; sValue = tableData[iIndex][sName]; } /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行 */ if ( selectData.length === 1 || (index === 0 && commonUtils.isEmptyObject(sValue)) ) { let tableDataRow = {}; // 取默认值 tableDataRow = { ...tableData[iIndex] }; if (tbName === "slave") { tableDataRow.sSqlConditionId = tableDataRow.sId; } tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue( selectConfig.sAssignField, item, newCopyTo ) }; // 取赋值字段 tableData[iIndex] = tableDataRow; tableData[iIndex].handleType = commonUtils.isEmpty( tableData[iIndex].handleType ) ? "update" : tableData[iIndex].handleType; } const addState = { [`${tbName}Data`]: tableData }; this.props.onSaveState(addState); }); } }; copyTbRow = index => { this.handleCopyRow(index); }; copyAllTbRow = index => { this.handleCopyAllRow(index); }; downloadTbRow = (index, record) => { this.handleDownloadRow(index, record); }; popupModalTbRow = (index, record) => { this.handlePopupRow(index, record); }; paramModalTbRow = (index, record) => { this.handleParamRow(index, record); }; exitTbRow = (index, record) => { this.props.onExitTbRow(index, record); }; handleViewClick = (name, sName, record, index, showConfig, configName) => { if ( commonUtils.isNotEmptyObject(showConfig) && commonUtils.isNotEmptyObject(record) ) { const printPdf = showConfig.sControlName; /* 工单号配置调到打印界面,跳转打印页面 */ const sActiveKey = showConfig.sActiveKey; /* 弹出界面对应数据主字段 */ if ( commonUtils.isNotEmptyObject(printPdf) && printPdf === "printPdf" && commonUtils.isNotEmptyObject(sActiveKey) ) { const token = this.props.app.token; const sActiveId = showConfig.sActiveId === "1" ? commonUtils.isEmpty(record.sFormId) ? record.sSrcFormId : record.sFormId : showConfig.sActiveId; const printsId = record[sActiveKey]; const urlPrint = `${ commonConfig.server_host }printReport/printPdfByFromDataId/${printsId}.pdf?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent( token )}`; window.open(urlPrint); } else { if (this.handleHideModal()) { this.props.onViewClick && this.props.onViewClick( name, sName, record, index, showConfig, configName ); } } } else { if (this.handleHideModal()) { this.props.onViewClick( name, sName, record, index, showConfig, configName ); } } }; handleHideModal = () => { let antModalRootEl = null; const bInModal = el => { if (commonUtils.isEmpty(el) || commonUtils.isEmpty(el.classList)) { return false; } else if (el.classList.contains("ant-modal-root")) { antModalRootEl = el; return true; } else { return bInModal(el.parentNode); } }; if (bInModal(event.target)) { // 如果是在modal里的表格,不允许跳转 const activeTab = document.querySelector( '#navTabWrap .ant-tabs-nav-list>div[class*="ant-tabs-tab-active"]' ); if (activeTab) { const modalId = activeTab.getAttribute("data-node-key"); antModalRootEl.style.display = "none"; antModalRootEl.setAttribute("data-attr-modalId", "modalId_" + modalId); } else { return false; } } return true; }; /* 快捷键跳转 */ handleQuickViewClick = async (name, sName, record, index, myConfigArr) => { const { slaveConfig, slaveData, dispatch, slaveFilterCondition, slavePagination, slaveOrderBy, sModelsType, formRoute, treeFilterCondition, app, iPageSize, sModelsId // slaveSelectedData, // masterData, // employeeConfig, } = this.props; let picArr = ""; if (commonUtils.isNotEmptyArr(slaveConfig)) { picArr = slaveConfig.gdsconfigformslave.filter( item => item.sName === sName ); } if (commonUtils.isNotEmptyArr(myConfigArr)) { picArr = myConfigArr; } if (picArr.length > 0) { const getConfig = this.handleGetTableConfig; const tableDataRow = record; const iIndex = index; const [{ sActiveId }] = picArr; let [{ sActiveKey }] = picArr; const sFormId = sActiveId === "1" ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId; if ( commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes(".") ) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */ const index = sActiveKey.lastIndexOf("."); sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length); } const sNameUrl = `${ commonConfig.server_host }gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formRoute}`; const filterCondition = []; const conditionValues = this.props.getSqlCondition( picArr[0], name, tableDataRow ); if (!commonUtils.isEmpty(conditionValues)) { Object.keys(conditionValues).forEach(item => { if (item === "tStartDate_pro" || item.substring(0, 1) === "p") { if ( !commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2 ) { const tStartDate = moment(conditionValues[item][0]).format( this.sDateFormat ); const tEndDate = moment(conditionValues[item][1]) .add(1, "days") .format(this.sDateFormat); filterCondition.push({ bFilterName: item, bFilterCondition: "=", bFilterValue: `${tStartDate},${tEndDate}` }); } } else if ( item === "mStartDate_pro" || item.substring(0, 1) === "m" ) { if (!commonUtils.isEmpty(conditionValues[item])) { const tStartDate = moment(conditionValues[item]) .startOf("month") .format(this.sDateFormat); const tEndDate = moment(conditionValues[item]) .endOf("month") .add(1, "days") .format(this.sDateFormat); filterCondition.push({ bFilterName: `t${item.substring(1, item.length)}`, bFilterCondition: "=", bFilterValue: `${tStartDate},${tEndDate}` }); } } else if (item.substring(0, 1) === "t") { filterCondition.push({ bFilterName: item, bFilterCondition: "=", bFilterValue: moment(conditionValues[item]).format( this.sDateFormat ) }); } else { filterCondition.push({ bFilterName: item, bFilterCondition: "=", bFilterValue: conditionValues[item] }); } }); } this.props.dispatch({ type: "content/onRouter", payload: { url: sNameUrl, refresh: getConfig.bind(this, name, sModelsId) /* 刷新方法 */, sTabId: commonUtils.createSid(), // sParentId: this.state.sTabId, urlDataType: "newPane", checkedId: myConfigArr[0].sId, sName: myConfigArr[0].sName, bFilter: slaveFilterCondition, pageSize: commonConfig.pageSize, pages: slavePagination, currentData: slaveData, conditonValues: conditionValues, newKey: tableDataRow[sActiveKey], currentIndex: iIndex, filterCondition } }); } }; /* 文件下载 */ handleFileDownload = fileUrl => { const fileList = fileUrl.split(","); fileList.forEach(item => { let fileName = item.substring(item.lastIndexOf("/") + 1); fileName = fileName.substring(fileName.indexOf("_") + 1); const filepath = `${ commonConfig.server_host }file/download?savePathStr=${encodeURIComponent( item )}&sModelsId=100&token=${encodeURIComponent(this.props.app.token)}`; const xhr = new XMLHttpRequest(); xhr.open("get", filepath); xhr.responseType = "blob"; xhr.send(); xhr.onload = function() { if (this.status === 200 || this.status === 304) { // 如果是IE10及以上,不支持download属性,采用msSaveOrOpenBlob方法,但是IE10以下也不支持msSaveOrOpenBlob if ("msSaveOrOpenBlob" in navigator) { navigator.msSaveOrOpenBlob(this.response, fileName); return; } const url = URL.createObjectURL(this.response); const a = document.createElement("a"); a.style.display = "none"; a.href = url; a.download = fileName; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } }; }); }; /* 所有备注非编辑状态下点击链接可以弹出备注窗体 */ handleMemoShow = (name, sName, record, index, showConfig) => { if (commonUtils.isNotEmptyObject(record)) { if (sName.includes("sTemplateFullMemo")) { this.props.onShowSimpleModal && this.props.onShowSimpleModal(record[sName]); return; } const sMemo = showConfig.sName; const title = showConfig.showName; const sCurrMemoProps = { title, name, sValue: record[sName], sMemoField: sMemo, bVisibleMemo: true, sRecord: record, sMemoConfig: showConfig, bOnlyShow: true }; this.setState({ sCurrMemoProps }); } }; handleViewChoose = (name, sName, record, index) => { this.props.onViewChoose(name, sName, record, index); }; /* 弹出通用窗体 */ handlePopupModal = (showConfig, name) => { this.setState({ commonPopupVisible: true, commonPopupTbName: name, commonPopupShowConfig: showConfig }); }; /* 字段弹窗 */ handleFieldPopupModal = (showConfig, name) => { this.setState({ commonFieldPopupVisible: true, commonFieldPopupTbName: name, commonFieldPopupShowConfig: showConfig }); }; /* 点击图片预览 */ 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.server_host }file/download?savePathStr=${item}&width=800&&height=500&sModelsId=100&token=${token}` : item; /* 预览 */ previewImageArr.push(dataPreviewUrl); }); this.setState({ previewImage: previewImageArr, previewVisible: true, showimgs: true, firstIndex: 0 }); } }; // office文件预览 handlePreviewOffice = dataUrlArr => { this.setState({ officePreviewVisible: true, officeFileUrl: dataUrlArr }); }; handleDropdownVisibleChange = open => { // this.beSelectDropdownOpen = open; }; /* 生产排程工艺流程字段弹窗 - 生产进度详情 */ handlesPartNameStatus = (sName, sWorkOrderId) => { if ( commonUtils.isNotEmptyObject(sName) && commonUtils.isNotEmptyObject(sWorkOrderId) ) { const filterData = this.props.config.gdsconfigformslave.filter( item => item.sName === sName ); const showConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : []; const record = {}; record.sWorkOrderId = sWorkOrderId; this.props.onPartNameClick(sName, showConfig, record); } }; /* 打开新窗口查看SQL编辑器 */ handleOpenWin = (name, sName, record, index, showConfig) => { const sBtnName = sName; const sBtnContent = record[sName]; const sFormId = commonUtils.isNotEmptyObject(record.sId) ? record.sId : ""; const sBtnControlName = commonUtils.isNotEmptyObject( showConfig.sControlName ) ? showConfig.sControlName : ""; console.log("sFormId:", sFormId); if (commonUtils.isNotEmptyObject(sBtnContent)) { const urlPrint = `${ commonConfig.server_host }template/getSql/${sBtnName}/?sBtnContent=${sBtnContent}&sBtnControlName=${sBtnControlName}&sFormId=${sFormId}`; const w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; const h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; //const newWin = window.open('','_blank'); const features = "width=" + (w + 350) + ",height=" + (h + 300) + ", top=0, left=0, toolbar=no, menubar=no,scrollbars=no,resizable=no, location =no, status=no"; const newWin = window.open("", "SQL查看器", features); newWin.document.write( '' ); // window.open(urlPrint); } else { message.error("未找到对应过程名"); } }; showimg = i => { this.setState({ showimgs: true, firstIndex: i }); }; toggleshow = () => { this.setState({ showimgs: false, previewVisible: false }); }; handleOk = () => { this.props.onSaveState({ previewVisible: false }); }; handleCancelModal = modelVisible => { this.props.onSaveState({ [modelVisible]: false }); }; /** 调整列宽 */ handleResize = (index, column, isSlaveInfo) => { return (e, { size }) => { if (e) { this.resize = true; } if (size.width === column.width) { return; } this.setState( ({ tableColumn, tableInfoColumn }) => { let nextColumns; if (isSlaveInfo) { nextColumns = [...tableInfoColumn]; } else { nextColumns = [...tableColumn]; } let iIndexList = []; let iWidth = 0; let offset = 0; const iIndex = nextColumns.findIndex( item => item.dataIndex === column.dataIndex ); if (iIndex !== -1) { // 单层表头 iIndexList = [iIndex, -1]; iWidth = nextColumns[iIndex].width === undefined ? this.countOperate() : nextColumns[iIndex].width; offset = size.width - iWidth; nextColumns[iIndex].width = size.width; } else { // 双层表头 for (let i = 0; i < nextColumns.length; i++) { const item = nextColumns[i]; const { children } = item; if (commonUtils.isNotEmptyArr(children)) { const childIndex = children.findIndex( child => child.dataIndex === column.dataIndex ); if (childIndex !== -1) { iIndexList = [i, childIndex]; iWidth = nextColumns[i].children[childIndex].width === undefined ? this.countOperate() : nextColumns[i].children[childIndex].width; offset = size.width - iWidth; // const iWidthTemp = nextColumns[i].width === undefined ? this.countOperate() : nextColumns[i].width; // nextColumns[i].width = iWidthTemp + offset; nextColumns[i].children[childIndex].width = size.width; break; } } } } if (commonUtils.isNotEmptyArr(iIndexList)) { let lastIndexList = []; let lastIndex = nextColumns.findIndex( item => item.dataIndex === "tableLastEmpty" ) - 1; if (lastIndex < -1) { lastIndexList = [nextColumns.length - 1, -1]; } else if ( commonUtils.isNotEmptyArr(nextColumns[lastIndex].children) ) { lastIndexList = [ lastIndex, nextColumns[lastIndex].children.length - 1 ]; } else { lastIndexList = [lastIndex, -1]; } const oBody = this.mydiv.querySelector(".ant-table-body"); const { scrollWidth, clientWidth, scrollLeft } = oBody; const scrollRight = scrollWidth - clientWidth - scrollLeft; // 判断当前拖动列是否在最后一列前面 if ( iIndexList[0] < lastIndexList[0] || (iIndexList[0] === lastIndexList[0] && iIndexList[1] < lastIndexList[1]) ) { const lastColumn = lastIndexList[1] === -1 ? nextColumns[lastIndexList[0]] : nextColumns[lastIndexList[0]].children[lastIndexList[1]]; const iWidthExtra = lastColumn.widthExtra || 0; // 最后一列额外的宽度 if (offset > 0) { // 向右拉伸 if (iWidthExtra) { //有额外宽度 if (iWidthExtra >= offset) { lastColumn.width -= offset; lastColumn.widthExtra -= offset; offset = 0; } else { const diffWidth = offset - iWidthExtra; lastColumn.width -= iWidthExtra; lastColumn.widthExtra = 0; offset = diffWidth; } } else if (!iWidthExtra && lastColumn.width - offset > 150) { // 没有额外宽度,但是减去位移后宽度大于150 lastColumn.width -= offset; offset = 0; } } else if (offset < 0) { // 向左拉伸 if (scrollRight < -offset) { // 滚动条距离表格右边距离小于拉伸距离 const diffWidth = -offset - scrollRight; lastColumn.width += diffWidth; lastColumn.widthExtra ? (lastColumn.widthExtra += diffWidth) : (lastColumn.widthExtra = diffWidth); offset = -diffWidth; } } // 处理拖动幅度太大时,空白列会显示问题 const oCol = this.mydiv.querySelector("colgroup"); const oCols = oCol ? oCol.childNodes : []; const oColsWithList = Array.from(oCols) .filter(item => !item.className) .map(item => parseInt(item.style.width)); if (!oColsWithList.includes(0)) { lastColumn.width += oColsWithList[lastIndex + 1]; } } } if (isSlaveInfo) { if (this.scrollInfoX) { this.scrollInfoX += offset; } else { this.scrollInfoX = 0; this.scrollInfoX = this.countScrollX(nextColumns, true); } return { tableInfoColumn: nextColumns }; } else { if (this.scrollX) { this.scrollX += offset; } else { this.scrollX = 0; this.scrollX = this.countScrollX(nextColumns); } return { tableColumn: nextColumns }; } }, () => { this.resize = false; this.initColumn = null; if (isSlaveInfo) { sessionStorage.setItem( `${this.props.formId}_${this.props.config.sId}_info`, JSON.stringify(this.state.tableInfoColumn) ); } else { sessionStorage.setItem( `${this.props.formId}_${this.props.config.sId}`, JSON.stringify(this.state.tableColumn) ); } } ); }; }; genFooter = () => { const { tableColumn, totalData, totalData1 } = this.state; const { dNetMoney, dNetPrice } = this.props.app.decimals; const sModelsType = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : ""; let colSpan = 0; if ( (!totalData.length && !totalData1.length) || this.props.footer !== undefined ) { return null; } if ( this.props.tableProps.rowSelection !== null && !(this.props.config && !this.props.config.bisMutiSelect) ) { colSpan = colSpan + 1; } if (this.props.slaveInfo) { colSpan = colSpan + 1; } if (this.props.dragHandle) { colSpan = colSpan + 1; } const cells = []; const cells1 = []; if (totalData.length) { let summaryCellTotal = ""; summaryCellTotal = ( 合计 ); // if(this.props.slaveInfo) { // summaryCellTotal = ( // // 合计 // // ); // } else { // summaryCellTotal = ( // // 合计 // // ); // } cells.push(summaryCellTotal); tableColumn.forEach((item, index) => { if (colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; if ( tableColumn[index].children !== undefined && tableColumn[index].children.length > 0 ) { /* 循环嵌套标题行 */ tableColumn[index].children.forEach((itemChild, i) => { /* 合计 格式化单价、金额 */ let sValue = totalData[0][itemChild.dataIndex]; if ( (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("commonList")) || (sModelsType && sModelsType.indexOf("commonMultiList") > -1) ) { /* 有配置以配置为主 否则以系统设定为主 */ if ( commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.substring(0, 1) === "d" && commonUtils.isNotEmptyObject(itemChild.sDateFormat) ) { /* 取小数点位数 */ let point = 0; let strIndex = itemChild.sDateFormat.indexOf("."); if (strIndex > -1 && itemChild.sDateFormat.length > 1) { point = itemChild.sDateFormat.substring( strIndex + 1, itemChild.sDateFormat.length ).length; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils .convertFixNum(Number(sValue), point) .toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } } else { if ( commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.toLowerCase().endsWith("price") ) { /* 列表单价格式化显示1 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils .convertFixNum(Number(sValue), dNetPrice) .toFixed(dNetPrice); if (!isNaN(dResult)) { sValue = dResult; } } } else if ( commonUtils.isNotEmptyObject(itemChild.dataIndex) && itemChild.dataIndex.toLowerCase().endsWith("money") ) { /* 列表金额格式化显示 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils .convertFixNum(Number(sValue), dNetMoney) .toFixed(dNetMoney); if (!isNaN(dResult)) { sValue = dResult; } } } } } const cellChild = ( {sValue} ); cells.push(cellChild); }); } else { /* 正常单层标题行 */ let cell = ""; /* commonList 格式化单价、金额 */ let sValue = totalData[0][item.dataIndex]; if ( (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("commonList")) || (sModelsType && sModelsType.indexOf("commonMultiList") > -1) ) { /* 有配置以配置为主 否则以系统设定为主 */ if (commonUtils.isNotEmptyObject(item.sDateFormat)) { /* 取小数点位数 */ let point = 0; let strIndex = item.sDateFormat.indexOf("."); if (strIndex > -1 && item.sDateFormat.length > 1) { point = item.sDateFormat.substring( strIndex + 1, item.sDateFormat.length ).length; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils .convertFixNum(Number(sValue), point) .toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } } else { if ( commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.toLowerCase().endsWith("price") ) { /* 列表单价格式化显示1 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils.convertFixNum( Number(sValue), dNetPrice ); if (!isNaN(dResult)) { sValue = dResult; } } } else if ( commonUtils.isNotEmptyObject(item.dataIndex) && item.dataIndex.toLowerCase().endsWith("money") ) { /* 列表金额格式化显示 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils.convertFixNum( Number(sValue), dNetMoney ); if (!isNaN(dResult)) { sValue = dResult; } } } } } cell = ( {sValue} ); cells.push(cell); } }); } if (totalData1.length) { let summaryCellTotal1 = ""; summaryCellTotal1 = ( 总计 ); cells1.push(summaryCellTotal1); tableColumn.forEach((item, index) => { if (colSpan === 0 && index === 0) { return; } let iTag = index + colSpan; if ( tableColumn[index].children !== undefined && tableColumn[index].children.length > 0 ) { /* 循环嵌套标题行 */ tableColumn[index].children.forEach((itemChild, i) => { /* 合计 格式化单价、金额 */ let sValue = totalData1[0][itemChild.dataIndex]; const cellChild = ( {sValue} ); cells1.push(cellChild); }); } else { /* 正常单层标题行 */ let cell = ""; /* commonList 格式化单价、金额 */ let sValue = totalData1[0][item.dataIndex]; cell = ( {sValue} ); cells1.push(cell); } }); } return ( {totalData.length ? {cells} : ""} {totalData1.length ? ( {cells1} ) : ( "" )} ); }; handleSearch = (selectedKeys, confirm, searchColumnName, clearFilters) => { confirm(); if (this.mounted) { this.setState({ searchText: selectedKeys[0], searchColumnName }); } let { clearArray } = this.props; if (commonUtils.isEmptyArr(clearArray)) { clearArray = []; } clearArray.push({ confirm, clearFilters }); this.props.onSaveState({ clearArray }); }; handleReset = (clearFilters, confirm) => { clearFilters(); if (this.mounted) { this.setState({ searchText: "" }, () => { // 重置搜索条件 confirm(); }); } }; /** 求和所有列 */ handleSumAllColumn = (config, dataSource) => { const tableDataTotal = {}; const sumConfig = config.gdsconfigformslave.filter( item => item.sName !== "" && item.bVisible && item.bSum ); if (commonUtils.isNotEmptyArr(sumConfig)) { if ( commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource) ) { dataSource.forEach(tableDataRow => { sumConfig.forEach(sumItem => { if (tableDataRow.handleType !== "del") { if ( sumItem.sName .substring(sumItem.sName.length - 5, sumItem.sName.length) .toLowerCase() === "Price".toLowerCase() ) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum( commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName) ); } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum( commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName) ); } } }); }); } else { sumConfig.forEach(sumItem => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; tableDataTotal.key = "0000"; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } }; handleSumOtherColumn = (config, dataSource) => { const tableDataTotal = {}; const sumConfig = config.gdsconfigformslave.filter( item => item.sName !== "" && item.bVisible && item.bSum ); if (commonUtils.isNotEmptyArr(sumConfig)) { if ( commonUtils.isNotEmptyObject(config) && commonUtils.isNotEmptyArr(dataSource) ) { const { selectedRowKeys } = this.state; /* 生产排程对选中行进行汇总 */ if (commonUtils.isNotEmptyArr(selectedRowKeys)) { const selectedData = dataSource.filter(item => selectedRowKeys.includes(item.sSlaveId) ); if (commonUtils.isNotEmptyArr(selectedData)) { selectedData.forEach(tableDataRow => { sumConfig.forEach(sumItem => { if (tableDataRow.handleType !== "del") { if ( sumItem.sName .substring(sumItem.sName.length - 5, sumItem.sName.length) .toLowerCase() === "Price".toLowerCase() ) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum( commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName) ); } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum( commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName) ); } } }); }); } } else { dataSource.forEach(tableDataRow => { sumConfig.forEach(sumItem => { if (tableDataRow.handleType !== "del") { if ( sumItem.sName .substring(sumItem.sName.length - 5, sumItem.sName.length) .toLowerCase() === "Price".toLowerCase() ) { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum( commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName) ); } else { tableDataTotal[sumItem.sName] = commonUtils.convertFixNum( commonUtils.convertToNum(tableDataTotal[sumItem.sName]) + commonUtils.convertToNum(tableDataRow[sumItem.sName]), this.props.getFloatNum(sumItem.sName) ); } } }); }); } } else { sumConfig.forEach(sumItem => { tableDataTotal[sumItem.sName] = 0; }); } tableDataTotal.bSum = true; tableDataTotal.key = "0000"; if (this.mounted) { this.setState({ totalData: [tableDataTotal] }); } } }; /** 查看行 */ handleLookRow = () => { this.props.onLookRow(this.props.name); }; /** 材料备注行 */ handleModalRemarkRow = index => { this.props.onModalRow(index); }; /** modal行 */ handleModalRow = (recordIndex, tableName) => { if ( commonUtils.isNotEmptyObject( this.props.tableProps.chooseMaterialsConfigRow ) ) { const iIndex = this.props.tableProps.chooseMaterialsConfigRow; this.props.onBtnChoose( "materials", "BtnChooseMaterials", iIndex, recordIndex, tableName ); // recordIndex选中行的索引 } }; handleChooseProcessRow = () => { if ( commonUtils.isNotEmptyObject(this.props.tableProps.chooseProcessConfigRow) ) { const iIndex = this.props.tableProps.chooseProcessConfigRow; this.props.onBtnChoose("process", "BtnChooseProcess", iIndex); } }; /* 成品工序弹窗 */ handleChooseProductProcessRow = recordIndex => { /* recordIndex 为选中行下标 */ if ( commonUtils.isNotEmptyObject( this.props.tableProps.chooseProductProcessConfigRow ) ) { const btnConfig = this.props.tableProps.chooseProductProcessConfigRow; this.props.onBtnChoose( "productProcess", "BtnChooseProductProcess", btnConfig, recordIndex ); } }; /* 成品材料弹窗 */ handleChooseProductMaterialsRow = recordIndex => { /* recordIndex 为选中行下标 */ if ( commonUtils.isNotEmptyObject( this.props.tableProps.chooseProductMaterialsConfigRow ) ) { const btnConfig = this.props.tableProps.chooseProductMaterialsConfigRow; this.props.onBtnChoose( "productMaterials", "BtnChooseProductMaterials", btnConfig, recordIndex ); } }; /** 添加行 */ handleAddRow = (index, bModalAdd) => { setTimeout(() => { if (this.props.onAddRow) { this.props.onAddRow( this.props.name, null, index, this.props.bFinished, bModalAdd ); } }, 0); }; handleTreeAdd = () => { setTimeout(() => { if (this.props.onTreeAdd) { this.props.onTreeAdd(this.props.name, true, "sameNode"); } }, 0); }; handleTreeAddChild = () => { setTimeout(() => { if (this.props.onTreeAddChild) { this.props.onTreeAddChild(this.props.name, true, "childNode"); } }, 0); }; handleTreeCopyAll = () => { setTimeout(() => { if (this.props.onTreeCopyAll) { this.props.onTreeCopyAll(this.props.name, false, "isChild"); } }, 0); }; handleTreeDel = () => { setTimeout(() => { if (this.props.onTreeDel) { this.props.onTreeDel(this.props.name, true, ""); } }, 0); }; /** 复制 */ handleCopyRow = () => { setTimeout(() => { if (this.props.onCopyRow) { this.props.onCopyRow(this.props.name); } }, 0); }; /** 复制全部 */ handleCopyAllRow = () => { setTimeout(() => { if (this.props.onCopyAllRow) { this.props.onCopyAllRow(this.props.name); } }, 0); }; /** 删除行 */ handleDelRow = (index, record) => { const tableSelectedRowKeys = []; tableSelectedRowKeys.push(record.sId); setTimeout(() => { if (this.props.onDelRow(this.props.name, false, tableSelectedRowKeys)) { this.handleSumAllColumn(this.props.config, this.state.dataSource); } }, 0); // if (this.props.formRoute === '/indexOee/processReport') { // localStorage.setItem(`${commonConfig.prefix}oeeEmployeeData`, JSON.stringify(this.props.data)); // this.props.onSaveState({ // employeeData: JSON.parse(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData`)), // }); // } }; /** 下载行 */ handleDownloadRow = (index, record) => { const tableSelectedRowKeys = []; tableSelectedRowKeys.push(record.sId); this.props.onDownloadRow(this.props.name, false, tableSelectedRowKeys); }; /** 通用弹窗新增行 */ handlePopupRow = () => { const { name, config } = this.props; let btnPupopConfig = {}; if ( commonUtils.isNotEmptyArr(config) && commonUtils.isNotEmptyArr(config.gdsconfigformslave) ) { const controlConfig = config.gdsconfigformslave.filter( item => commonUtils.isNotEmptyObject(item.sControlName) && (item.sControlName.includes("BtnPopup") || item.sControlName.includes("BtnHeadPopup")) ); if (commonUtils.isNotEmptyArr(controlConfig)) { if ( controlConfig[0].bVisible && controlConfig[0].sDropDownType === "popup" ) { btnPupopConfig = controlConfig[0]; this.setState({ commonPopupVisible: true, commonPopupTbName: name, commonPopupShowConfig: btnPupopConfig }); } } } }; /** 查看工艺参数 */ handleParamRow = (index, record) => { const tableSelectedRowKeys = []; tableSelectedRowKeys.push(record.sId); this.props.onShowParamRow(this.props.name, record, tableSelectedRowKeys); }; /** 拖动排序 */ handleSaveOrder = (sortItems, isSlaveInfo) => { const { formSrcRoute } = isSlaveInfo ? this.props.slaveInfo : this.props; const { token } = isSlaveInfo ? this.props.slaveInfo.app : this.props.app; const sActiveId = isSlaveInfo ? this.props.slaveInfo.app.currentPane.formId : this.props.app.currentPane.formId; const url = `${ commonConfig.server_host }configform/sHandleConfigform?sModelsId=${sActiveId}&sName=${formSrcRoute}`; const headerArr = isSlaveInfo ? this.props.slaveInfo.headerColumn.map(item => item.dataIndex) : this.props.headerColumn.map(item => item.dataIndex); const handleData = isSlaveInfo ? this.props.slaveInfo.config.gdsconfigformslave.filter( item => headerArr.indexOf(item.sName) !== -1 ) : this.props.config.gdsconfigformslave.filter( item => headerArr.indexOf(item.sName) !== -1 ); let sortIndexFirst = 0; let sortIndexLast = 0; handleData.forEach((item, index) => { if (item.sName === sortItems[0]) { sortIndexFirst = index; } if (item.sName === sortItems[1]) { sortIndexLast = index; } }); const tempOrder = handleData[sortIndexFirst].iOrder; handleData[sortIndexFirst].iOrder = handleData[sortIndexLast].iOrder; handleData[sortIndexLast].iOrder = tempOrder; const postData = isSlaveInfo ? { [this.props.slaveInfo.config.sId]: handleData } : { [this.props.config.sId]: handleData }; // console.log(postData, 'postData'); // console.log(sortItems, 'sortItems'); const value = { handleType: "group", sJurisdictionClassifyId: "", bDefault: true, handleData: postData }; const options = { method: "POST", headers: { "Content-Type": "application/json", authorization: token }, body: JSON.stringify(value) }; const { dispatch } = this.props; fetch(url, options) .then(response => response.json()) .then(json => { if (json.code === 1) { this.forceUpdate(); } else if (json.code === -2) { dispatch({ type: "app/throwError", payload: json }); } }); }; /** 查找控件名是否存在 */ findIsExistByControlName = (props, controlName) => { // 解决操作栏按钮没显示但是加上了宽度问题 let propsIcon = true; switch (controlName) { // case 'BtnUpload': // propsIcon = ''; // break; // case 'BtnLook': // propsIcon = ''; // break; // case 'BtnAdd': // propsIcon = props.tableProps.setAdd; // break; case "BtnChooseMaterials": propsIcon = props.tableProps.setMaterial; break; case "BtnChooseProcess": propsIcon = props.tableProps.setProcess; break; // case 'BtnCopy': // propsIcon = props.tableProps.setCopy; // break; // case 'BtnCopyAll': // propsIcon = props.tableProps.setCopyAll; // break; // case 'BtnDel': // propsIcon = props.tableProps.setDelete; // break; default: break; } /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if ( commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName) ) { const controlConfig = props.config.gdsconfigformslave.filter( item => item.sControlName === controlName ); ret = commonUtils.isEmptyArr(controlConfig) ? propsIcon ? true : false : commonUtils.converStrToBoolean(controlConfig[0].bVisible); } /* 返回值 */ return ret; }; /** 查找控件名是否存在 */ findIsUpdByControlName = (props, controlName) => { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if ( commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName) ) { const controlConfig = props.config.gdsconfigformslave.filter( item => item.sControlName === controlName ); ret = commonUtils.isNotEmptyArr(controlConfig) && commonUtils.converStrToBoolean(controlConfig[0].iTag === 3); } /* 返回值 */ return ret; }; /** 查找控件名是否显示 */ findVisibleControlName = (props, controlName) => { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if ( commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName) ) { const controlConfig = props.config.gdsconfigformslave.filter( item => item.sControlName === controlName ); ret = commonUtils.isNotEmptyArr(controlConfig) && commonUtils.converStrToBoolean(controlConfig[0].bVisible); } /* 返回值 */ return ret; }; /** 查找控件名是否存在 */ findIsExistByControlPopup = (props, controlName) => { /* 返回值声明 */ let ret = false; /* 查询控件名是否存在 */ if ( commonUtils.isNotEmptyArr(props.config) && commonUtils.isNotEmptyArr(props.config.gdsconfigformslave) && commonUtils.isNotEmptyStr(controlName) ) { const controlConfig = props.config.gdsconfigformslave.filter( item => commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.includes(controlName) && !item.sControlName.includes(".") ); if (commonUtils.isNotEmptyArr(controlConfig)) { if ( controlConfig[0].bVisible && controlConfig[0].sDropDownType === "popup" ) { ret = true; } } } /* 返回值 */ return ret; }; /** 绑定showType控件 */ bindShowType = (props, text, record, sName, index, isSlaveInfo) => { /* 如果从表没有数据就返回一个默认的input text,不返回showType了 */ let res = ""; const idx = index; const inputProps = { disabled: true, value: record[sName] }; if (sName === "tableLastEmpty") { return ""; } if (["iOrder_Custom"].includes(sName)) { return (
{index + 1}
); } const showConfigObj = this.getShowConfig(props, sName); const { dNetMoney, dNetPrice } = props.app.decimals; let bShow = ""; /* 如果是布尔类型 ,加checkbox */ if (commonUtils.isNotEmptyObject(sName) && sName.substring(0, 1) === "b") { if (props.enabled && !showConfigObj.bReadonly) { bShow = ( this.onKeyDownDiv(e, sName)} suppressContentEditableWarning contentEditable="true" > {" "} ); } else { bShow = ( this.onKeyDownDiv(e, sName)} suppressContentEditableWarning contentEditable="true" > {" "} ); } } /* 如果是图片类型 ,加载图片 */ let imgBox = ""; if (commonUtils.isNotEmptyObject(sName) && sName.indexOf("picture") > -1) { const picAddr = commonUtils.isNotEmptyObject(record[sName]) ? record[sName].split(",") : ""; if (commonUtils.isNotEmptyObject(picAddr)) { const { token } = props.app; const dataUrl = picAddr[0].includes("xlyerpfiles") ? `${commonConfig.server_host}file/download?savePathStr=${ picAddr[0] }&scale=0.1&sModelsId=100&token=${token}` : picAddr[0]; /* 缩略图 */ const officeFileTypeList = ["PDF", "DOCX", "XLSX"]; 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 = ; } if (officeFileTypeList.includes(officeFileType)) { imgBox = ( { this.setState({ officePreviewVisible: true, officeFileUrl: picAddr[0] }); }} > {fileIcon} ); } else if (imgTypeList.includes(officeFileType)) { imgBox = ( {" "} img 0} onClick={e => this.handlePreviewImage(e, picAddr)} style={{ width: "30px", height: "20px" }} /> ); } else { imgBox = ( ); } } } /* 变量设置 显示字段名 */ let specialTitle = ""; if (sName !== "" && sName.includes("sValue")) { specialTitle = `R${idx}_${sName}`; } if (record.bSum && commonConfig.hasSum) { /* 从表无数据 */ res = ; const cell = this.mergeTableCell(res, idx, sName, isSlaveInfo); return cell; } else if ( props.tableBelone === "list" || (commonUtils.isNotEmptyObject(props.slaveInfo) && props.slaveInfo.tableBelone === "list") ) { /* CommonList列表加下划线 */ const showConfig = this.getShowConfig(props, sName) || {}; /* 获取单元格颜色配置 */ let cellColor = ""; let backgroundColor = ""; if (commonUtils.isNotEmptyArr(showConfig)) { const cellStyle = this.getCellColorConfig(text, record, sName); if (commonUtils.isNotEmptyObject(cellStyle)) { cellColor = cellStyle.styleColorArrTotal; backgroundColor = cellStyle.styleColorArrTotalB; } } let sValue = record[sName]; let linkStyle = ""; let displayAlign = "left"; if ( commonUtils.isNotEmptyObject(sName) && sName.substring(0, 1) === "d" ) { const { dNumAlign } = props.app.decimals; displayAlign = dNumAlign === "1" ? "right" : "left"; /* 判断如果是数字格式,对齐方式根据系统设定s */ } const firstDataIndex = commonUtils.isNotEmptyObject(sName) ? sName.substring(0, 1) : ""; /* 控件首字母(数据格式:字符串) */ if ( showConfig.sDropDownType === "picArr" && !commonUtils.isEmpty(showConfig.sActiveId) && commonUtils.isEmptyArr(props.sGroupByList) ) { linkStyle = "linksActiveIdStyle"; /* 列表加弹窗,如果有分组,则不加弹窗 */ if (sName === "sDetailMemoview") { // record.sDetailMemotemp = sValue; /* 存放值字段 */ sValue = sValue !== undefined ? "查看操作日志" : sValue; } } else if (showConfig.sDropDownType === "const") { let showDropDown = []; if (typeof showConfig.showDropDown === "object") { showDropDown = showConfig.showDropDown; } else { showDropDown = commonUtils.objectToArr( commonUtils.convertStrToObj(showConfig.showDropDown) ); } const iIndex = commonUtils.isEmpty(record[sName]) ? -1 : showDropDown.findIndex( item => item.sId === record[sName].toString() ); sValue = iIndex > -1 ? showDropDown[iIndex].value : ""; } else if ( firstDataIndex === "t" || firstDataIndex === "p" || firstDataIndex === "m" ) { const { sDateFormat } = showConfig; if (!commonUtils.isEmpty(sValue)) { if (commonUtils.isNotEmptyStr(sDateFormat)) { sValue = moment(sValue).format(sDateFormat); } else if (!commonUtils.isEmpty(sValue)) { sValue = moment(sValue).format(props.getDateFormat()); } } } else if (firstDataIndex === "d") { const { sDateFormat } = showConfig; /* 如果配置时间格式中设置了0.0000则以配置为准,没有设置时间格式 则以系统设定为主 */ if (commonUtils.isNotEmptyObject(sDateFormat)) { /* 取小数点位数 */ let point = 0; let strIndex = sDateFormat.indexOf("."); if (strIndex > -1 && sDateFormat.length > 1) { point = sDateFormat.substring(strIndex + 1, sDateFormat.length) .length; if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dConfigResult = commonUtils .convertFixNum(Number(sValue), point) .toFixed(point); if (!isNaN(dConfigResult)) { sValue = dConfigResult; } } } } else { if (firstDataIndex === "d" && sName.toLowerCase().endsWith("price")) { /* 列表单价格式化显示 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils .convertFixNum(Number(sValue), dNetPrice) .toFixed(dNetPrice); if (!isNaN(dResult)) { sValue = dResult; } } } else if ( firstDataIndex === "d" && sName.toLowerCase().endsWith("money") ) { /* 列表金额格式化显示 */ if (commonUtils.isNotEmptyNumber(sValue) && sValue !== null) { const dResult = commonUtils .convertFixNum(Number(sValue), dNetMoney) .toFixed(dNetMoney); if (!isNaN(dResult)) { sValue = dResult; } } } } } /* 如果列表行包含sDivRow并且sDivRow有值 则代表该行行不渲染数据 只做分割作用 */ if (commonUtils.isNotEmptyObject(record.sDivRow) && record.bInsert) { bShow = ""; if (sName !== "sDivRow") { sValue = ""; } } if (commonUtils.isNotEmptyObject(sName) && sName === "sColorSerialMemo") { if (sName === "sColorSerialMemo") { let JsonData = []; if (commonUtils.isNotEmptyObject(sValue)) { try { JsonData = JSON.parse(sValue); } catch (e) { JsonData = []; } } /* 将色序json解析成需要的字符串形式 */ let sMemo = ""; if (commonUtils.isNotEmptyArr(JsonData)) { JsonData.forEach(item => { sMemo += `${item.sName}+`; }); sMemo = commonUtils.isNotEmptyObject(sMemo) ? sMemo.substr(0, sMemo.length - 1) : ""; sValue = sMemo; } } } if (cellColor && sName !== "sState") { res = (
{(commonUtils.isNotEmptyObject(sName) && sName.substring(0, 1) === "b") || imgBox !== "" ? ( "" ) : (
this.onKeyDownDiv(e, sName)} onCut={e => e.preventDefault()} onPaste={e => e.preventDefault()} suppressContentEditableWarning contentEditable="true" onClick={ commonUtils.isNotEmptyObject(linkStyle) ? this.handleViewClick.bind( this, isSlaveInfo ? "slaveInfo" : this.props.name, showConfig.sName, record, index, showConfig ) : null } > {" "} {sValue}
)} {bShow} {imgBox}
); } else { res = (
{(commonUtils.isNotEmptyObject(sName) && sName.substring(0, 1) === "b") || imgBox !== "" ? ( "" ) : ( {sValue}} > this.onKeyDownDiv(e, sName)} onCut={e => e.preventDefault()} onPaste={e => e.preventDefault()} suppressContentEditableWarning contentEditable="true" onClick={ commonUtils.isNotEmptyObject(linkStyle) ? this.handleViewClick.bind( this, isSlaveInfo ? "slaveInfo" : this.props.name, showConfig.sName, record, index, showConfig ) : null } > {" "} {sValue} )} {bShow} {imgBox} {this.handleGetFastSearchBtn({ record, sName, isSlaveInfo })}
); } const cell = this.mergeTableCell(res, idx, sName, isSlaveInfo); return cell; } else if ( (commonUtils.isNotEmptyObject(showConfigObj) && (props.enabled || showConfigObj.iTag === 3) && commonUtils.isEmptyObject(record.sDivRowNew) && ((commonUtils.isNotEmptyArr(props.selectedRowKeys) && props.selectedRowKeys.toString().includes(record.sId)) || props.name === "sParam")) || (props.enabled && record.sId === this.state.currentHoverSid) || record.costomEnabledList?.includes(sName) ) { const showTypeNewProps = this.getShowTypeProps( props, text, record, sName ); if (showTypeNewProps.enabled) { if ( (props.name === "table131" && ["dProcessCalQty", "dTimeHour"].includes(sName)) || (props.name === "table132" && ["dWageHour", "dTimeHour"].includes(sName)) ) { // 人检/包装特殊处理 res = ( <>