import moment from "moment"; import React, { Component, createRef } from "react"; import reactComponentDebounce from "@/components/Common/ReactDebounce"; import * as commonFunc from "@/components/Common//commonFunc"; /* 通用单据方法 */ /* 通用单据方法 */ // import '@ant-design/compatible/assets/index.css'; import InstructSetSetting from "@/components/Common/InstructSetSetting" import { InputNumber, Checkbox, DatePicker, Input, Cascader, Select, AutoComplete, Spin, message, Form, Upload, Image, Button, Space, Table, Pagination, Tooltip, Modal, } from "antd-v4"; import { DeleteOutlined, EyeOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FileOutlined, RightOutlined, PlaySquareOutlined, EditOutlined, } from "@ant-design/icons"; import * as commonUtils from "@/utils/utils"; import styles from "@/index.less"; import Provinces from "@/assets/provinces.json"; import Cities from "@/assets/cities.json"; import Areas from "@/assets/areas.json"; import commonConfig from "@/utils/config"; import { VirtualKeyboard } from "@/oee/common/oeeKeyBoard"; // 虚拟软键盘 import "braft-editor/dist/output.css"; import SvgBox from "../BoxDesignCompontent/svg"; const FormItem = Form.Item; const { Option } = Select; const { TextArea } = Input; const { Search } = Input; const InputNumberA1 = reactComponentDebounce(300)(InputNumber); const InputA1 = reactComponentDebounce(300)(Input); const AutoCompleteA1 = reactComponentDebounce(300)(AutoComplete); /* 处理快速选择产品后离开 产品无法赋值问题s */ const TextAreaA1 = reactComponentDebounce(500)(TextArea); // const InputNumberA = InputNumber; // const InputA = Input; // const AutoCompleteA = AutoComplete; // const TextAreaA = TextArea; const { RangePicker, MonthPicker } = DatePicker; export default class CommonComponent extends Component { /** 构造函数 */ constructor(props) { super(props); this.state = { dataValue: props.dataValue /* 本showType数据 */, enabled: props.enabled /* 是否是查看状态(数据格式:布尔) */, dropDownData: [] /* 下拉数据集(如果不是下拉控件该值为空,数据格式:数组对象) */, conditonValues: {}, sFieldName: props.showConfig.sName, // 字段名 bNotEmpty: props.showConfig.bNotEmpty, mode: props.showConfig.bMultipleChoice ? "multiple" : "default", bNewRecord: props.showConfig.bNewRecord /* 是否有新纪录 */, sActiveDisplay: true, pageNum: 0, totalPageCount: 1, searchValue: "", searchDropDownData: [], searchTotalPageCount: 1, searchPageNum: 0, spinState: false, currentPage: 1, selectTableData: [], buttonLoading: false, key: 0, selectTableIndex: 0, }; this.firstDataIndex = props.showConfig.sName.substring(0, 1); /* 控件首字母(数据格式:字符串) */ this.max = props.showConfig.sMaxValue; /* 最大值(数据格式:数字) */ this.min = props.showConfig.sMinValue; /* 最小值(数据格式:数字) */ // 重构修改 this.getFieldDecorator = commonUtils.isUndefined(props.form) ? undefined : props.form.getFieldDecorator; /* 字段验证(数据格式:数字) */ // this.getFieldDecorator = commonUtils.isUndefined(props.form) ? undefined : undefined; /* 字段验证(数据格式:数字) */ this.floatNum = this.props.getFloatNum(props.showConfig.sName); /* 数字格式化规范转换(数据格式:数字) */ this.floatPrice = this.getFloatPrice(this.floatNum); /* 价格格式化规范转换(数据格式:数字) */ this.formItemLayout = commonUtils.isNotEmptyObject(props.formItemLayout) ? props.formItemLayout : location.pathname.toLowerCase().indexOf("oee") > -1 ? { labelCol: { span: 7, style: { color: "rgba(0, 0, 0, 0.65)", backgroundColor: "#BFEFFF" } }, wrapperCol: { span: 15 } } : { labelCol: { span: 7, style: { height: "27.82px", color: "rgba(0, 0, 0, 0.65)", backgroundColor: "#BFEFFF" } }, wrapperCol: { span: 15 }, }; /* 表格样式(主要是colspan和rowspan,数据格式:对象) */ this.isDropdownFilter = false; this.V = { value: props.dataValue }; this.myRef = createRef(); this.dropDownCount = 0; this.bSpecial = location.pathname?.includes("ResearchTableTree") && props.showConfig.sName === "sProductName"; } /** 渲染前只执行一次 */ componentWillMount() { this.mounted = true; if (this.props.showConfig.sDropDownType === "const") { /* 常量下拉 */ /* 常量下拉其实只取一次数据就可以啦,去过数据的会给state中的dropDownData赋值,所以dropDownData有值的情况就不需要再获取了 */ const showDropDown = commonUtils.isNotEmptyArr(this.props.showConfig.dropDownData) ? this.props.showConfig.dropDownData : typeof this.props.showConfig.showDropDown === "object" ? this.props.showConfig.showDropDown : commonUtils.objectToArr(commonUtils.convertStrToObj(this.props.showConfig.showDropDown)); /* 给state赋值 */ if (this.mounted) { this.setState({ dropDownData: showDropDown, }); } } else if (this.props.showConfig.sDropDownType === "sql" && !commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) { if (this.mounted) { this.setState({ dropDownData: this.props.showConfig.dropDownData, }); } } } componentDidMount() { const currentNode = this.myRef.current; const selectInputNode = currentNode.querySelector("input[class*='ant-select-selection-search-input']"); const antInput = currentNode.querySelector("input[class*='ant-input']"); const oInput = selectInputNode || antInput; if (oInput && !this.props.noDebounce) { oInput.addEventListener("compositionstart", () => { this.chineseInputting = true; }); oInput.addEventListener("compositionend", () => { this.chineseInputting = false; if (this.handleCompleteInputEventCache) { this.handleCompleteInputEventCache(); } }); } if (currentNode) { if (["t", "m", "y"].includes(this.firstDataIndex)) { const oInput = currentNode.querySelector(`input[id*="${this.props.showConfig.sName}"]`); if (oInput) { let { sDateFormat } = this.props.showConfig; if (commonUtils.isEmptyStr(sDateFormat)) { if (this.firstDataIndex === "m") { sDateFormat = "YYYY-MM"; } else if (this.firstDataIndex === "y") { sDateFormat = "YYYY"; } else { sDateFormat = this.props.getDateFormat(); } } oInput.oninput = e => { const { value } = e.target; const isValidDate = moment(value, sDateFormat, true).isValid(); if (isValidDate) { this.handleSelectOptionEvent(moment(this.state.dataValue), value); } }; } } } document.addEventListener("mousedown", this.handleSelectClick); } /** props改变的时候触发 */ componentWillReceiveProps(nextProps) { /* 如果是下拉控件,则要获取数据(获取下拉数据前要先更新sqlCondition) */ const { dataValue, enabled, sFieldName, bNotEmpty, showName, sDropDownType } = this.state; if (nextProps.showConfig === undefined || this.props.showConfig === undefined) return; this.firstDataIndex = nextProps.showConfig.sName.substring(0, 1); /* 控件首字母(数据格式:字符串) */ if (nextProps.showConfig.sDropDownType === "const") { /* 常量下拉 */ /* 常量下拉其实只取一次数据就可以啦,去过数据的会给state中的dropDownData赋值,所以dropDownData有值的情况就不需要再获取了 */ const showDropDown = commonUtils.isNotEmptyArr(nextProps.showConfig.dropDownData) ? nextProps.showConfig.dropDownData : typeof nextProps.showConfig.showDropDown === "object" ? nextProps.showConfig.showDropDown : commonUtils.objectToArr(commonUtils.convertStrToObj(nextProps.showConfig.showDropDown)); // 对应工序单独处理 // if (this.props.showConfig.showName === '对应工序') { // showDropDown = nextProps.customDropData; // } /* 给state赋值 */ if (this.mounted) { this.setState({ dropDownData: showDropDown, }); } } else if (nextProps.showConfig.sDropDownType === "sql" && !commonUtils.isEmptyArr(nextProps.showConfig.dropDownData)) { if (this.mounted) { this.setState({ dropDownData: nextProps.showConfig.dropDownData, }); } } /* 把需要更新的数据setState */ if ( dataValue !== nextProps.dataValue || enabled !== nextProps.enabled || bNotEmpty !== nextProps.showConfig.bNotEmpty || sFieldName !== nextProps.showConfig.sName || showName !== nextProps.showConfig.showName || !showName || sDropDownType !== nextProps.showConfig.sDropDownType || (this.bSpecial && this.props.record.sProductNo !== nextProps.record.sProductNo) ) { if (this.mounted) { if (commonUtils.isEmpty(nextProps.dataValue)) { this.lastValue = nextProps.dataValue; } const addState = { dataValue: nextProps.dataValue, enabled: nextProps.enabled, sFieldName: nextProps.showConfig.sName, sDropDownType: nextProps.showConfig.sDropDownType, bNotEmpty: nextProps.showConfig.bNotEmpty, showName: nextProps.showConfig.showName, }; if (this.bSpecial && this.completeSelectFlag) { addState.key = this.state.key + 1; } this.completeSelectFlag = false; this.setState(addState); } } } shouldComponentUpdate(nextProps, nextState) { const { dataValue, enabled, dropDownData, searchValue, searchDropDownData, sFieldName, bNotEmpty, sActiveDisplay, sDropDownType, spinState, showConfig, } = this.state; return ( nextProps.showConfig !== undefined && (dataValue !== nextState.dataValue || enabled !== nextState.enabled || sFieldName !== nextState.sFieldName || sDropDownType !== nextState.sDropDownType || bNotEmpty !== nextState.bNotEmpty || JSON.stringify(dropDownData) !== JSON.stringify(nextState.dropDownData) || searchValue !== nextState.searchValue || JSON.stringify(searchDropDownData) !== JSON.stringify(nextState.searchDropDownData) || JSON.stringify(sActiveDisplay) !== JSON.stringify(nextState.sActiveDisplay) || nextProps.showTime !== this.props.showTime || spinState !== nextState.spinState || JSON.stringify(nextState.selectTableData) !== JSON.stringify(this.state.selectTableData) || JSON.stringify(nextProps.showConfig) !== JSON.stringify(showConfig)) ); } componentWillUnmount() { this.mounted = false; document.removeEventListener("mousedown", this.handleSelectClick); } onFocus = () => { this.isDropdownFilter = false; this.setState({ sActiveDisplay: false }); }; onBlur = event => { if (this.onExecInstructSet("blur")) return; this.isDropdownFilter = false; if (commonUtils.isNotEmptyStr(this.props.showConfig.sTableTitleSql) && this.props.showConfig.iVisCount > 1) { this.setState({ searchPageNum: 1, searchTotalPageCount: 1, searchDropDownData: [], searchValue: "", spinState: false, sActiveDisplay: true, }); } else if ( this.state.searchValue !== "" && this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData) ) { if (!this.props.showConfig.bCanInput) { this.handleSelectOptionEvent(""); } this.setState({ searchPageNum: 1, searchTotalPageCount: 1, // searchDropDownData: [], // searchValue: '', spinState: false, sActiveDisplay: true, }); } else { this.setState({ sActiveDisplay: true, }); } /* 若下拉配置了movesql 则离开时 调用下拉sql数据 */ if ( this.props.showConfig && (this.props.showConfig.sDropDownType === "movesql" || commonUtils.isNotEmptyObject(this.props.showConfig.sButtonParam)) ) { this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig); } this.onCheckFields(500); this.onBlurText(event, 500); }; onBlurText = (event, timeout = 0) => { if (this.onExecInstructSet("blur")) return; const currentValue = event?.target?.value; if (currentValue === this.lastValue) return; setTimeout(() => { const { name, record, sBtnSendDialogConfigList, onToolBarBtnClick } = this.props; if (name !== "master") return; if (commonUtils.isEmptyArr(sBtnSendDialogConfigList)) return; const { sName } = this.props.showConfig; if (!record[sName]) return; const { sActiveKey, sControlName } = sBtnSendDialogConfigList.find(item => { const { sActiveKey = "" } = item; return sActiveKey.split(",").includes(`${name}.${sName}`); }) || {}; if (sControlName !== "BtnSendDialog") { if (!sActiveKey) return; this.lastValue = currentValue; onToolBarBtnClick({ key: sControlName }); } }, timeout); }; onExecInstructSet = type => { const { sInstruct: sInstructStr, showName, sOnChangeInstruct } = this.props.showConfig; const sInstruct = commonUtils.convertStrToObj(sInstructStr, {}); let { [type]: instructType } = sInstruct; if (type === "change") { const onChangeNew = commonUtils.convertStrToObj(sOnChangeInstruct, {}); instructType = onChangeNew[type]; } if (instructType) { if (this.props.onExecInstructSet) { this.props.onExecInstructSet({ type, sInstruct: instructType, showName: `${showName}-${type === "blur" ? "离焦" : "变化"}`, }); } else { message.error("未定义调用指令集事件!"); } return true; } return false; }; onCheckFields = () => { // 手机号、邮箱校验等校验 // setTimeout(() => { const sDateFormatTypeList = ["phone", "mobile", "mail", "postcode"]; const { sName, showName, sDateFormat } = this.props.showConfig; const { record } = this.props; const IncorrectFormat = commonFunc.showLocalMessage(this.props, "IncorrectFormat", "格式不正确"); const value = record[sName]; if (value !== undefined && value !== "" && sDateFormatTypeList.includes(sDateFormat)) { let flag = false; if (sDateFormat === "phone") { const reg = /^0\d{2,3}-\d{7,8}$/; const reg1 = /^1[0-9]{10}$/; const reg2 = /^0\d{2,3}-\d{7,8}-\d{1,8}$/; if (!reg.test(value) && !reg1.test(value) && !reg2.test(value)) { flag = true; } } else if (sDateFormat === "mobile") { const reg = /^0\d{2,3}-\d{7,8}$/; const reg1 = /^1[0-9]{10}$/; const reg2 = /^0\d{2,3}-\d{7,8}-\d{1,8}$/; if (!reg.test(value) && !reg1.test(value) && !reg2.test(value)) { flag = true; } } else if (sDateFormat === "mail") { const reg = /^[a-zA-Z0-9]{1,20}@[a-zA-Z0-9]{1,5}\.[a-zA-Z0-9]{1,5}$/; if (!reg.test(value)) { flag = true; } } else if (sDateFormat === "postcode") { const reg = /^[1-9][0-9]{5}$/; if (!reg.test(value)) { flag = true; } } if (flag) { this.props.onChange( this.props.name, "verificationFailed", { verificationFailed: true, verificationFailedMsg: `【${showName}】【${sName}】${IncorrectFormat}!` }, this.props.sId, [] ); message.warning(`【${showName}】【${sName}】${IncorrectFormat}!`); } else if (record.verificationFailed) { record.verificationFailed = undefined; } } // }, timeout); }; /** 下拉时看是否要重新获取数据 */ onDropdownVisibleChange = open => { const { dropDownData, bNewRecord, pageNum: pageNumOld, totalPageCount: totalPageCountOld, searchValue, conditonValues } = this.state; if (this.mounted && open) { const conditonValuesNew = this.props.getSqlCondition(this.props.showConfig, this.props.name, this.props.record); const pageNum = JSON.stringify(conditonValuesNew) !== JSON.stringify(conditonValues) ? 1 : pageNumOld === 0 ? 1 : pageNumOld; const totalPageCount = conditonValuesNew !== conditonValues ? 1 : totalPageCountOld; if (pageNum === 1 && this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) { this.setState({ spinState: true }); this.getDropDownData(pageNum, totalPageCount, searchValue, this.dropDownCount); } } else { // if (searchValue !== '' && this.props.showConfig.sDropDownType === 'sql' && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) { // this.setState({ // searchPageNum: 1, searchTotalPageCount: 1, searchDropDownData: [], searchValue: '', spinState: false, // }); // } this.isDropdownFilter = false; } if (this.props.onDropdownVisibleChange !== undefined) { if (dropDownData.length === 0 && !bNewRecord) { /* 如果没有值并且没有新纪录,则不展开 */ open = false; } this.props.onDropdownVisibleChange(open); } }; onDoubleClick = () => { const sMemo = this.props.showConfig.sName; const title = this.props.showConfig.showName; const bSParamValue = sMemo === "sParamValue"; if ( (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("Memo") > -1) || (bSParamValue && !this.props.record.sDropDownData) || (this.props.showConfig.sControlName && this.props.showConfig.sControlName.toLowerCase().indexOf("memo") > -1) ) { const sCurrMemoProps = { title, name: this.props.name, sValue: this.props.dataValue, sMemoField: sMemo, bVisibleMemo: true, sRecord: this.props.record, sMemoConfig: this.props.showConfig, bOnlyShow: !this.props.enabled, }; if (this.props.bInSlaveMemo) { this.props.onSaveState({ sCurrMemoProps1: sCurrMemoProps }); } else if (this.props.onSaveState) { this.props.onSaveState({ sCurrMemoProps }); } } else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("sName") > -1) { /* 计算方案 变量设置双击弹出 */ this.props.onFieldDoubleClick(this.props.record, this.state.dataValue, this.props.showConfig, this.props.name); } else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("sValue") > -1) { /* 计算方案 变量设置双击弹出 */ this.props.onFieldDoubleClick(this.props.record, this.state.dataValue, this.props.showConfig, this.props.name); } else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("sAssignField") > -1) { /* 赋值字段 变量设置双击弹出 */ this.props.onFieldDoubleClick(this.state.dataValue, this.props.showConfig, this.props.name); } else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.toLowerCase().includes('instruct')) { /* 赋值字段 变量设置双击弹出 */ // this.props.onFieldDoubleClick(this.state.dataValue, this.props.showConfig, this.props.name); this.handleEditInstruct(); } }; onEditorClick = () => { // if (this.props.enabled) { // // } const curEditorProps = { title: this.props.showConfig.showName, name: this.props.name, value: this.props.dataValue, sName: this.props.showConfig.sName, visible: true, record: this.props.record, config: this.props.showConfig, }; this.props.onSaveState({ curEditorProps }); }; onKeyUp = e => { if (this.props.onKeyUp) { this.props.onKeyUp(e); } }; onKeyDown = e => { // 如果输入的是字母数字或者中文 if (!this.state.bDropDownOpen && /^[a-zA-Z0-9\u4e00-\u9fa5]+$/.test(e.keyCode)) { this.setState({ bDropDownOpen: true }); } if (e.ctrlKey && e.keyCode === 82) { /* CTRL+ALT+R 代替右击事件 */ this.onContextMenu(e); } else if (e.key === "F10") { message.info(this.props.showConfig.sName); } else if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 71) { /* CTRL+ALT+G F7 设置界面 */ const { sType } = this.props?.app?.userinfo || {}; if (!["sysadmin"].includes(sType)) { return; } if (commonUtils.isNotEmptyObject(this.props)) { const { name, tableConfig, record, configName } = this.props; if (commonUtils.isNotEmptyObject(tableConfig)) { const myTableConfig = JSON.parse(JSON.stringify(tableConfig)); myTableConfig.sActiveId = "16411004790004762980820285096000"; myTableConfig.sName = this.props.showConfig.sName; const myTableConfigArr = []; myTableConfigArr.push(myTableConfig); if (this.props.name === "master") { /* 主表 */ this.props.onViewClick(name, "myTableConfig", record, 0, myTableConfigArr, configName); } else { /* 从表 */ this.props.onViewClick(name, "myTableConfig", record, 0, myTableConfigArr, configName); } } } } else if (false && this.props.onKeyDown) { const { showConfig, record, name } = this.props; this.props.onKeyDown(e, record, showConfig.sName, name); } }; /* CommonList列表onkeydown-F10处理 */ onKeyDownDiv = e => { if (this.props.onKeyDown) { this.props.onKeyDown(e); } if (e.key === "F10") { message.info(this.props.showConfig.sName); } else if (e.ctrlKey && e.keyCode === 67) { console.log("复制成功!"); } else if (e.ctrlKey && e.keyCode === 65) { console.log("全选成功!"); } else { e.preventDefault(); return false; } }; /* 单击右键全部更新,弹出窗选择后,更新此列所有数据 (只更新非只读字段) */ onContextMenu = e => { if ( this.state.enabled && commonUtils.isNotEmptyObject(this.props) && this.props.name !== "master" && commonUtils.isNotEmptyObject(this.props.showConfig) ) { const { showConfig, name } = this.props; const { bReadonly } = showConfig; if (bReadonly) { return; } e.preventDefault(); /* 阻止浏览器本身的右击事件 */ if (this.props.onContextMenu) { const { showConfig, record } = this.props; this.props.onContextMenu(e, record, showConfig, name); } } }; /* 字段选择弹窗 */ onFieldPopupModal = (showConfig, name, open) => { if (open !== undefined) { this.props.onFieldPopupModal(showConfig, name); } }; /** 获取selectprops对象 */ getSelectProps = () => { /* 返回值声明 */ const obj = { id: `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`, showSearch: true /* 是否有查找功能 */, // disabled: !this.state.enabled /* 修改的时候传过来的数据 */ onSelect: () => { if (this.state.mode !== "multiple") { this.setState({ bDropDownOpen: false, bNotFirstEnter: true }); } }, onChange: this.handleSelectOptionEvent /* 选择触发事件 */, filterOption: this.filterOption /* 搜索时过滤对应的 option 属性 */, onDropdownVisibleChange: this.onDropdownVisibleChange, onPopupScroll: this.handlePopupScroll, onSearch: this.handleSearch, notFoundContent: this.state.spinState ? : "暂无数据", // getPopupContainer: this.props.name === 'slave' || this.props.name === 'searchColumnShow' ? this.getPopupContainer : null,/*解决下拉框不随浏览器滚动问题 */ onFocus: this.onFocus, // onBlur: this.onBlur, onBlur: e => { this.setState({ bDropDownOpen: false, bNotFirstEnter: false }); this.onBlur(e); }, mode: this.state.mode, onPaste: event => { if (this.props.showConfig.bMultipleChoice) { const clipboardText = event.clipboardData.getData("text/plain").trim(); if (clipboardText) { const { dataValue = "" } = this.state; let dataValueNew = dataValue; if (dataValueNew === "") { dataValueNew += clipboardText; } else { dataValueNew += `,${clipboardText}`; } this.handleSelectOptionEvent(dataValueNew, []); document.activeElement.blur(); } } }, }; if (this.props.showConfig.sDropDownType === "sql") { obj.optionLabelProp = "title"; } if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } obj.placeholder = this.props.showConfig.placeholder; /* 区分Oee设置字体与其他系统设置字体 */ obj.dropdownStyle = commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1 ? { fontSize: "1.3rem" } : { fontSize: "12px" }; obj.dropdownClassName = commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1 ? location.pathname.toLowerCase().indexOf("loginoee") > -1 ? "loginOeeDropDown" : "oeeDropDown" : ""; /* 主表时才赋值value */ if (this.props.bTable) { if (this.props.showConfig.bMultipleChoice) { obj.value = !commonUtils.isEmpty(this.state.dataValue) ? this.state.dataValue.split(",") : []; /* 数据值 */ } else { obj.value = this.state.dataValue; /* 数据值 */ } obj.className = this.props.costomClassName === undefined ? styles.editSelect : this.props.costomClassName; } if (this.props.showConfig.iDropWidth > 0) { obj.dropdownMatchSelectWidth = false; /* true时 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。 */ obj.dropdownStyle.width = this.props.showConfig.iDropWidth; } obj.onInputKeyDown = e => { const { bDropDownOpen, bNotFirstEnter } = this.state; if (bDropDownOpen && [38, 40, 13].includes(e.keyCode)) { // eslint-disable-next-line no-console } else if (bDropDownOpen && [27].includes(e.keyCode)) { this.setState({ bDropDownOpen: false }); } else if (e.keyCode === 13 && !bNotFirstEnter) { this.setState({ bDropDownOpen: true, bNotFirstEnter: true }); } else { this.onKeyDown(e); } }; obj.onKeyUp = this.onKeyUp; obj.open = this.state.bDropDownOpen !== undefined ? this.state.bDropDownOpen : false; // obj.onBlur = () => { // this.setState({ bDropDownOpen: false }); // }; obj.onMouseMove = () => { this.bInputIn = true; }; obj.onMouseLeave = () => { this.bInputIn = false; }; /* 返回值 */ return obj; }; getLocalizedString = (jsonStr, language) => { try { const data = JSON.parse(jsonStr); return data[language] || ""; } catch (e) { console.error("Error parsing JSON:", e); return ""; } }; getSelectTableProps = () => { const { currentPage, tempCurrentPage, searchValue } = this.state; const pageNum = searchValue === "" ? currentPage : tempCurrentPage; /* 返回值声明 */ const obj = { id: `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`, dropdownMatchSelectWidth: false, filterOption: this.filterOption /* 搜索时过滤对应的 option 属性 */, onDropdownVisibleChange: open => { this.onDropdownVisibleChange(open); if (open === false) { clearTimeout(this.blurtimer); this.blurtimer = setTimeout(() => { this.onBlur(); }, 500); } else { clearTimeout(this.blurtimer); this.onFocus(); } }, onSearch: this.selectTableSearch, showSearch: true, // onFocus: this.onFocus, // onBlur: this.onBlur, }; if (this.props.showConfig.sDropDownType === "sql") { obj.optionLabelProp = "title"; } if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } obj.placeholder = this.props.showConfig.placeholder; /* 区分Oee设置字体与其他系统设置字体 */ obj.dropdownStyle = commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1 ? { fontSize: "1.3rem" } : { fontSize: "12px" }; obj.dropdownClassName = commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1 ? location.pathname.toLowerCase().indexOf("loginoee") > -1 ? "loginOeeDropDown" : "oeeDropDown" : ""; /* 主表时才赋值value */ if (this.props.bTable) { obj.value = this.props.showConfig.bMultipleChoice && !commonUtils.isEmpty(this.state.dataValue) ? this.state.dataValue.split(",") : this.state.dataValue; /* 数据值 */ obj.className = this.props.costomClassName === undefined ? styles.editSelect : this.props.costomClassName; } if (this.props.showConfig.iDropWidth > 0) { obj.dropdownMatchSelectWidth = false; /* true时 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。 */ } obj.onInputKeyDown = e => { const { selectTableData = [], selectTableIndex = 0, bDropDownOpen, bNotFirstEnter } = this.state; const { keyCode } = e; try { if (bDropDownOpen) { const oTBody = this.selectTableRef1.querySelector(".ant-table-body"); const { scrollTop } = oTBody; const oTr = this.selectTableRef1.querySelector(".selected-record-row"); const trRect = oTr?.getBoundingClientRect(); const tbodyRect = oTBody?.getBoundingClientRect(); const tbodyTop = tbodyRect?.top + window.scrollY; const tbodyBottom = tbodyRect?.bottom + window.scrollY; const trTop = trRect?.top + window.scrollY; const trBottom = trRect?.bottom + window.scrollY; if (keyCode === 40) { const selectTableIndexNew = Math.min(selectTableIndex + 1, selectTableData.length - 1); if (selectTableIndex !== selectTableIndexNew) { const bInView = trTop + 29 >= tbodyTop && trBottom + 29 <= tbodyBottom; if (!bInView) { oTBody.scrollTop = scrollTop + 29; } this.setState({ selectTableIndex: selectTableIndexNew, }); } } else if (keyCode === 38) { const selectTableIndexNew = Math.max(selectTableIndex - 1, 0); if (selectTableIndex !== selectTableIndexNew) { const bInView = trTop - 29 >= tbodyTop && trBottom - 29 <= tbodyBottom; if (!bInView) { oTBody.scrollTop = scrollTop - 29; } this.setState({ selectTableIndex: selectTableIndexNew, }); } } else if (keyCode === 13) { e.stopPropagation(); this.setState({ bNotFirstEnter: true }); setTimeout(() => { oTr.click(); }, 10); } else { this.onKeyDown(e); } } else if (![37, 38, 39, 40, 13].includes(keyCode)) { this.setState({ bDropDownOpen: true }); } else if (keyCode === 13 && !bNotFirstEnter) { this.setState({ bDropDownOpen: true, bNotFirstEnter: true }); } else { this.onKeyDown(e); } } catch (error) { console.log(error); } }; obj.open = this.state.bDropDownOpen !== undefined ? this.state.bDropDownOpen : false; obj.onBlur = () => { if (!this.bInPagination) { this.setState({ bDropDownOpen: false, bNotFirstEnter: false }); } }; obj.onMouseMove = () => { this.bInputIn = true; }; obj.onMouseLeave = () => { this.bInputIn = false; }; obj.onKeyUp = this.onKeyUp; /* eslint-disable */ obj.dropdownRender = menu => ( <> {/*
this.selectTableSearch(e)}/>
*/} {menu}
{ this.bInPagination = true; }} onMouseLeave={() => { this.bInPagination = false; if (this.selectTableRef) { this.selectTableRef.focus(); } }} > this.selectTableChange(e)} showSizeChanger={false} current={pageNum} pageSize={20} size="small" total={this.state.totalCount} /> {this.props.showConfig.bFirstEmpty && ( )} {this.props.showConfig.bNewRecord && ( )}
); /* eslint-enable */ /* 返回值 */ return obj; }; getSelectTableOption = () => { const { selectTableData, selectTableIndex = 0 } = this.state; const { showConfig, app } = this.props; const { userinfo } = app; let { sTableTitleSql } = showConfig; /* 根据用户配置语言 设置表格标题 */ if (commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes("Chinese")) { sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage); } const tempColumnArr = sTableTitleSql.split(","); let scrollX = 0; const columns = tempColumnArr.map((item, index) => { const tempArr = item.split(":"); const [value, title, columnWidth] = tempArr; let width; if (!Number.isNaN(Number(columnWidth))) { // 如果配置了列宽 width = Number(columnWidth); } else { // 没有配置列宽,就根据字符数算宽度 // 获取中文字数、非中文字数, 中文12px,其它8px const titleStr = title; const totalStringLen = titleStr.length; const otherStrLen = titleStr.replace(/[^\x00-\xff]/g, "").length; // eslint-disable-line const chineseStrLen = totalStringLen - otherStrLen; const defaultWidth = chineseStrLen * 12 + otherStrLen * 8; const maxStrLen = selectTableData.reduce((res, pre) => { let tempValue = pre[value] !== undefined ? pre[value] : ""; if (tempValue === "") { return res; } tempValue = typeof tempValue === "string" ? tempValue : JSON.stringify(tempValue); const totalStringLen = tempValue.length; const otherStrLen = tempValue.replace(/[^\x00-\xff]/g, "").length; // eslint-disable-line const chineseStrLen = totalStringLen - otherStrLen; const tempWidth = chineseStrLen * 12 + otherStrLen * 8; return Math.max(tempWidth, res); }, defaultWidth); width = Math.min(maxStrLen + 8, 300); } scrollX += width; return { title, dataIndex: value, key: value, width: index !== tempColumnArr.length - 1 ? width : undefined, render: text => { return ( {text} ); }, }; }); return (
{ this.selectTableRef1 = ref; }} > { return selectTableIndex === index ? "selected-record-row" : ""; }} rowKey="sId" onRow={(record, index) => { return { index, onMouseEnter: () => { this.setState({ selectTableIndex: index, }); }, onClick: () => { this.setState({ tempCurrentPage: null, bDropDownOpen: false, bNotFirstEnter: true }); this.handleSelectOptionEvent(record.sSlaveId || record.sId); }, }; }} pagination={false} scroll={{ y: 256 - 10 - 29 - 32, x: scrollX, }} dataSource={selectTableData} columns={columns} /> ); }; /** 获取complete对象 */ getCompleteProps = () => { /* 返回值声明 */ const obj = { id: `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`, // disabled: !this.state.enabled /* 修改的时候传过来的数据 */ onChange: this.handleCompleteInputEvent /* 选择触发事件 */, onSelect: value => { this.setState({ bDropDownOpen: false, bNotFirstEnter: true }); this.completeSelectFlag = true; if (value === "") { if (this.props.showConfig.sDropDownType === "sql") { this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name); } } else if (this.state.dataValue === value) { this.completeFlag = true; this.handleCompleteInputEvent(value); if (this.myRef && this.myRef.current) { const oInput = this.myRef.current.querySelector(`#${this.props.showConfig.sName}`); if (oInput) { setTimeout(() => { oInput.blur(); }, 1000); } } } else if (this.myRef && this.myRef.current) { const oInput = this.myRef.current.querySelector(`#${this.props.showConfig.sName}`); if (oInput) { oInput.blur(); } } }, filterOption: this.filterOption /* 搜索时过滤对应的 option 属性 */, onDropdownVisibleChange: this.onDropdownVisibleChange, onPopupScroll: this.handlePopupScroll, /* 区分Oee设置字体与其他系统设置字体 */ dropdownClassName: commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1 ? location.pathname.toLowerCase().indexOf("loginoee") > -1 ? "loginOeeDropDown" : "oeeDropDown" : "", onSearch: this.handleSearch, notFoundContent: this.state.spinState ? : "暂无数据", onFocus: this.onFocus, onBlur: e => { this.setState({ bDropDownOpen: false, bNotFirstEnter: false }); this.onBlur(e); }, }; if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } obj.placeholder = this.props.showConfig.placeholder; /* 区分Oee设置字体与其他系统设置字体 */ obj.dropdownStyle = commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1 ? { fontSize: "1.3rem" } : { fontSize: "12px" }; /* 主表时才赋值value */ if (this.props.bTable) { obj.value = this.props.showConfig.bMultipleChoice && !commonUtils.isEmpty(this.state.dataValue) ? this.state.dataValue.split(",") : this.state.dataValue; /* 数据值 */ obj.className = this.props.costomClassName === undefined ? styles.editSelect : this.props.costomClassName; } if (this.props.showConfig.iDropWidth > 0) { obj.dropdownMatchSelectWidth = false; /* true时 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。 */ obj.dropdownStyle.width = this.props.showConfig.iDropWidth; } if ( typeof commonUtils.convertStrToNumber(this.max) === "number" && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf(".d") === -1 && this.max.indexOf(".i") === -1 ) { obj.maxLength = this.max; /* 最大长度 */ } obj.onInputKeyDown = e => { const { bDropDownOpen, bNotFirstEnter } = this.state; if (bDropDownOpen && [38, 40, 13].includes(e.keyCode)) { // eslint-disable-next-line no-console } else if (e.keyCode === 13 && !bNotFirstEnter) { this.setState({ bDropDownOpen: true, bNotFirstEnter: true }); } else { this.onKeyDown(e); } }; obj.onKeyUp = this.onKeyUp; obj.open = this.state.bDropDownOpen !== undefined ? this.state.bDropDownOpen : false; obj.onMouseMove = () => { this.bInputIn = true; }; obj.onMouseLeave = () => { this.bInputIn = false; }; /* 返回值 */ return obj; }; getSearchProps = () => { let chooseTitle = "选择"; if (commonUtils.isNotEmptyObject(this.props.app) && commonUtils.isNotEmptyObject(this.props.app.commonConst)) { chooseTitle = commonFunc.showMessage(this.props.app.commonConst, "choose"); } const obj = { onKeyDown: this.onKeyDown, onChange: e => this.handleSelectOptionEvent(e.target.value) /* 数据改变回带到父组件 */, value: commonUtils.isUndefined(this.state.dataValue) ? chooseTitle : commonUtils.strUndefinedToEmpty(this.state.dataValue) /* 数据值 */, }; return obj; }; /** 获取optionValue对象 */ getOptionValues = data => { /* 返回值声明 */ let res = ""; /* 计数器 */ let count = 1; /* 遍历每一条数据 */ const iVisCount = commonUtils.isEmpty(this.props.showConfig.iVisCount) || this.props.showConfig.iVisCount === 0 ? 1 : this.props.showConfig.iVisCount; if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) { res = data[this.props.showConfig.sVisColumnName]; } else { for (const key of Object.keys(data)) { /* 这里主要是为了实现配置中控制下拉的展现列数 */ if (count <= iVisCount && key !== "sId") { if (res === "") { res = data[key]; } else { res = res.concat("-").concat(data[key]); } count += 1; } } } // 如果res值为''时,下拉会显示value值,为了解决这种情况,返回' ' if (res === "") { res = " "; } /* 返回值 */ return res; }; // 获取上传组件props getUploadProps = () => { const { formId, app, enabled } = this.props; const { token } = app; return { listType: "picture-card", className: "avatar-uploader", action: `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}&sUploadType=model`, disabled: !enabled || false, onChange: info => { const { file } = info; if (file.response && file.response.code === 1) { const sPicturePath = file.response.dataset.rows[0].savePathStr; this.props.onChange(this.props.name, this.props.showConfig.sName, { [this.props.showConfig.sName]: sPicturePath }, this.props.sId, []); } else if (file.response && file.response.code === -1) { message.error(file.response.msg); } }, accept: "image/*", showUploadList: false, }; }; // 获取上传组件内容 getUploadContents = () => { const fileName = commonUtils.isUndefined(this.state.dataValue) ? "" : commonUtils.strUndefinedToEmpty(this.state.dataValue); const imageUrl = `${commonConfig.file_host}file/download?savePathStr=${fileName}&sModelsId=100&token=${this.props.token}`; return fileName ? ( ) : (
上传
); }; // 获取上传图片右上角清空按钮属性 getUploadButtonProps = () => { const fileName = commonUtils.isUndefined(this.state.dataValue) ? "" : commonUtils.strUndefinedToEmpty(this.state.dataValue); return { type: "link", style: { position: "absolute", top: 0, left: 75, display: this.props.enabled && fileName ? "" : "none", }, onClick: () => { this.props.onChange(this.props.name, this.props.showConfig.sName, { [this.props.showConfig.sName]: "" }, this.props.sId, []); }, }; }; /** 获取innerinput控件1 */ getInnerInput = innerInputProps => { const { noDebounce } = this.props; const InputNumberA = noDebounce ? InputNumber : InputNumberA1; const InputA = noDebounce ? Input : InputA1; const AutoCompleteA = noDebounce ? AutoComplete : AutoCompleteA1; const TextAreaA = noDebounce ? TextArea : TextAreaA1; const { sTableTitleSql, iVisCount, sName, sDateFormat } = this.props.showConfig; let chooseTitle = "选择"; if (commonUtils.isNotEmptyObject(this.props.app) && commonUtils.isNotEmptyObject(this.props.app.commonConst)) { chooseTitle = commonFunc.showMessage(this.props.app.commonConst, "choose"); } if (commonUtils.isNotEmptyStr(sTableTitleSql) && iVisCount > 1) { return ( ); } if (sName === "sIcon") { return ( <> {this.getUploadContents()} ); } const removeExtension = (filename) => { const lastDotIndex = filename.lastIndexOf('.'); if (lastDotIndex === -1) { // 如果字符串中没有点,则返回原字符串 return filename; } return filename.substring(0, lastDotIndex); } if (sName === "sPackPath" || sName === "sPackDetailPathUpLoad" || sName === "sSvgPath") { let imageUrls = ""; const uploadProps = { listType: "picture-card", className: "avatar-uploader", action: `${commonConfig.server_host}file/uploadPrice?sLogoName=logo${sName}${this.props.record.sName}`, disabled: !this.props.enabled, onChange: info => { const { fileList } = info; const file = fileList[fileList.length - 1]; const { status, response } = file; if (status === "done") { if (response && response.code === 1) { const imageUrl = removeExtension(response.dataset.rows[0].savePathStr); // const imageUrlNew = `${commonConfig.server_host}file/downloadPrice?sLogoName=logo${removeExtension(imageUrl)}${this.props.record.sName // }&date=${new Date().getTime()}`; if (sName === "sPackPath") { this.props.onChange(this.props.name, sName, { sPackPath: imageUrl }, this.props.sId, []); } else if (sName === "sPackDetailPathUpLoad") { this.props.onChange(this.props.name, sName, { sPackDetailPathUpLoad: imageUrl }, this.props.sId, []); } else { this.props.onChange(this.props.name, sName, { sSvgPath: imageUrl }, this.props.sId, []); } imageUrls = imageUrl; } else if (response && response.code === -1) { message.error(response.msg); } } }, accept: "image/*", showUploadList: false, openFileDialogOnClick: this.props.enabled, }; const getImageUrl = (sName) => { const imageUrlNew = `${commonConfig.server_host}file/downloadPrice?sLogoName=${sName}&date=${new Date().getTime()}`; return imageUrlNew } const uploadName = commonFunc.showLocalMessage(this.props, "BtnUpload", "上传"); const imageUrl = sName === "sPackPath" ? (this.props.record.sPackPath ? getImageUrl(this.props.record.sPackPath) : '') : sName === "sPackDetailPathUpLoad" ? (this.props.record.sPackDetailPathUpLoad ? getImageUrl(this.props.record.sPackDetailPathUpLoad) : '') : (this.props.record.sSvgPath ? getImageUrl(this.props.record.sSvgPath) : ''); return (
{imageUrl ? ( ) : (
{uploadName}
)}
); } if (sName === "sPackDetailPath") { const boxList = []; const tables = [ { name: "盒型类别", value: this.props.record.sBoxType, type: null }, { name: "盒身", value: this.props.record.sBoxBody, type: this.props.record.sTypes }, { name: "盒长", value: this.props.record.dBoxLength, type: null }, { name: "盒宽", value: this.props.record.dBoxWidth, type: null }, { name: "盒高", value: this.props.record.dBoxHeight, type: null }, ]; const { slaveData = [] } = this.props; const titleList1 = [ { name: "上方盒舌", value: "dSFHS" }, { name: "盒底组件", value: "dHDC" }, { name: "下方盒舌", value: "dXFHS" }, { name: "左(上)插位组件", value: "dZSCW" }, { name: "左贴边位", value: "dZTBW" }, { name: "左(下)插位组件", value: "dZXCW" }, { name: "右(上)插位组件", value: "dYSCW" }, { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; slaveData.forEach(x => { let key = 0; if (x.sTypes && x.sTypes.includes('09')) { if (x.sCode === 'dZTBW' || x.sCode === 'dYTBW') { key = x.iSLength + x.iCLength } else { key = x.iSWidth+ x.iCWidth } } else { key = x.iValue } boxList.push({ value: key, sName: titleList1.find(item => item.value === x.sCode)?.name || "", isEditable: true, isSelect: false, selectValue: null, selectLabel: "", selectImage: null, type: x.sTypes || null, show: true, showName: x.sName, // 参数名称 sLength: x.iSLength, sWidth: x.iSWidth, sType: x.iSType, sTypeName: Number(x.iSType) === 0 ? "矩形" : "梯形", sOffset: x.sSOffset, sQuantity: x.iSQuantity, cLength: x.iCLength, cWidth: x.iCWidth, cType: x.iCType, cTypeName: Number(x.iCType) === 0 ? "矩形" : "梯形", cOffset: x.sCOffset, cQuantity: x.iCQuantity, }); }); tables.forEach(x => { boxList.push({ value: x.value, sName: x.name, isEditable: true, isSelect: false, selectValue: null, selectLabel: "", selectImage: null, type: x.type || null, show: true, showName: x.name, // 参数名称 }); }); const svgProps = { ...this.props, boxList, dSvgBoxWidth: 100, dSvgBoxHeight: 100, showNew: 1, }; return (
); } if (this.props.showConfig.sName && this.props.showConfig.sName.toLowerCase().includes("fullmemo")) { const row = commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1; const minHeight = row * 20 + 6 + 4 + 2; return (
); } if ((this.props.showConfig.sDropDownType === "sql" || this.props.showConfig.sDropDownType === "const") && this.props.showConfig.sName?.includes('sParam') && this.props.showConfig.showDropDown?.includes('\\n') ) { const row = commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1; const minHeight = row * 20 + 6 + 4 + 2; const correctText = commonUtils.isNotEmptyObject(this.state?.dataValue) ? this.state.dataValue : commonUtils.isNotEmptyObject(this.props.showConfig?.showDropDown) ? this.props.showConfig?.showDropDown?.replace(/\\n/g, "\n") : '111'; return (
this.handleSelectOptionEvent(e)} style={{ minHeight }} />
); } else if ( (this.props.showConfig.sDropDownType === "sql" || this.props.showConfig.sDropDownType === "const") && (this.firstDataIndex === "i" || this.firstDataIndex === "d" || this.firstDataIndex === "s") ) { /* 下拉选择框(数字和文本选择框才会下拉) */ if (this.props.showConfig.bCanInput) { /* 文本输入下拉框 */ const propsObj = { ...this.getCompleteProps() }; return {this.getSelectOption("autoComplete")}; } else { /* 普通下拉框 */ return ; } } else if (this.state.enabled && commonUtils.isNotEmptyObject(this.props.showConfig.sName) && this.props.showConfig.sDropDownType === "popup") { /* 通用弹窗 */ return ( ); } else if (this.firstDataIndex === "i" || this.firstDataIndex === "d") { /* 数字输入框(整形i和浮点型d) */ return innerInputProps.readOnly ? ( ) : location.pathname.includes("quotationPackTableTree") && this.props.name === "control" && this.props.showConfig.sName === "dSinglePQty" ? ( ) : ( ); } else if (this.firstDataIndex === "b") { /* 选择框(布尔类型b) */ return {this.showName}; // return {this.showName}; } else if (this.firstDataIndex === "m" || sDateFormat === "YYYY-MM" || sDateFormat === "YYYYMM") { /* 月份选择框(月份类型m) */ return this.props.bTable ? ( ) : ( ); } else if (this.firstDataIndex === "t") { /* 时间选择框(时间类型t) */ if (["tYear"].includes(this.props.showConfig.sName)) { innerInputProps.picker = "year"; innerInputProps.format = "YYYY"; innerInputProps.allowClear = false; } return this.props.bTable ? ( ) : ( ); } else if (this.firstDataIndex === "y") { /* 年份选择框(年份类型y) */ return this.props.bTable ? ( ) : ( ); } else if (this.firstDataIndex === "p") { /* 时间选择框(时间类型t) */ return ; } else if (this.firstDataIndex === "s") { /* 文本输入框(文本s) */ if (this.props.textArea) { /* 大文本输入框 */ return ; } else { /* 普通文本输入框 */ return ; } } else if (this.firstDataIndex === "c") { /* 地址联动框(联动下拉类型c) */ return ; } else { /* 文本输入框(默认类型) */ return ; } }; // 获取innerinput控件后面的按钮 getInnerButton = () => { const props = { onClick: () => { const { slaveConfig = { gdsconfigformslave: [] } } = this.props; const { gdsconfigformslave } = slaveConfig; const { sName } = this.props.showConfig; const config = gdsconfigformslave.find(item => item.sControlName === `BtnPopup.${sName}`); if (config && this.props.onFieldPopupModal) { this.props.onFieldPopupModal(config, this.props.name, "CommonListSelect"); } }, }; return ( ); }; // 获取innerinput控件后面的按钮(自定义) getInnerButtonCostom = showConfig => { const { name, sysEnabled } = this.props; const { showName } = showConfig; let disabled = this.props.showConfig?.buttonbReadonly; if (!disabled) { disabled = !sysEnabled; } const props = { type: "primary", disabled, loading: this.state.buttonLoading, onClick: () => { if (this.props.onCostomChange) { this.props.onCostomChange(name, showConfig); } }, }; return ; }; /** 获取selectOption对象 */ getSelectOption = type => { /* 返回值声明 */ const options = []; /* 执行条件 */ const { searchValue, dropDownData, searchDropDownData } = this.state; const dropDownDataNew = commonUtils.isEmpty(searchValue) ? dropDownData : searchDropDownData; if (commonUtils.isNotEmptyArr(dropDownDataNew)) { /* 遍历下拉数据 */ for (const each of dropDownDataNew) { if (commonUtils.isNotEmptyObject(each)) { /* 拼接optoin对象 */ let keyValue = !commonUtils.isEmpty(each.sSlaveId) ? each.sSlaveId : each.sId; if (this.firstDataIndex === "i") { keyValue = parseInt(keyValue, 0); } else if (this.firstDataIndex === "d") { keyValue = parseFloat(keyValue); } let res = ""; if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) { res = each[this.props.showConfig.sVisColumnName]; } else { res = Object.keys(each).length > 0 ? each[Object.keys(each)[0]] : ""; } keyValue = commonUtils.isEmpty(keyValue) ? "" : keyValue; if (type === "autoComplete") { // 为autoComplete作特殊处理 const option = this.props.showConfig.bCanInput ? ( ) : ( ); /* 返回值赋值s */ options.push(option); } else { const option = this.props.showConfig.bCanInput ? ( ) : ( ); /* 返回值赋值 */ options.push(option); } } } } if (this.state.searchValue === "") { /* 下拉空处理 */ if (this.props.showConfig.bFirstEmpty) { // 重构修改 options.unshift(); if (type === "autoComplete") { options.unshift(); } else { options.unshift( ); } } } /* 返回值 */ return options; }; /* 获取sqlCondition对象 */ getFloatPrice = floatNum => { /* 返回值声明 */ let floatPrice = ""; /* 返回值赋值 */ if (!commonUtils.isUndefined(floatNum)) { for (let i = 0; i < floatNum; i += 1) { floatPrice += "\\d"; } } /* 返回值 */ return floatPrice; }; /** 获取下拉值 */ getDropDownData = async (pageNum, totalPageCount, searchValue, dropDownCount) => { if (this.chineseInputting) { return; } /** 下拉类型区分 1、判断是否直接传下拉,如果传了就直接用,并存储到store中去 2、没有传看 getStoreDropDownData有没有存储,存储后直接取用 3、 没有存储时直接调用后台SQL语句去下拉 */ if (this.props.showConfig.sDropDownType === "sql") { /* 数据下拉 */ const { dropDownData: dropDownDataOld, searchDropDownData: searchDropDownDataOld } = this.state; if (pageNum <= totalPageCount) { const sqlDropDownData = await this.props.getSqlDropDownData( this.props.formId, this.props.name, this.props.showConfig, this.props.record, searchValue, pageNum ); if (dropDownCount !== undefined && dropDownCount < this.dropDownCount) { return; } if (this.mounted) { if (searchValue !== "") { const dropDownData = []; if (commonUtils.isNotEmptyArr(sqlDropDownData.dropDownData)) { if (pageNum !== 1) { dropDownData.push(...searchDropDownDataOld); } dropDownData.push(...sqlDropDownData.dropDownData); } this.setState({ searchDropDownData: dropDownData, conditonValues: sqlDropDownData.conditonValues, searchTotalPageCount: sqlDropDownData.totalPageCount, searchPageNum: sqlDropDownData.currentPageNo, spinState: false, searchValue, totalCount: sqlDropDownData.totalCount, selectTableData: sqlDropDownData.dropDownData, }); } else { const dropDownData = []; if (commonUtils.isNotEmptyArr(sqlDropDownData.dropDownData)) { if (pageNum !== 1) { dropDownData.push(...dropDownDataOld); } dropDownData.push(...sqlDropDownData.dropDownData); } this.setState({ dropDownData, conditonValues: sqlDropDownData.conditonValues, totalPageCount: sqlDropDownData.totalPageCount, pageNum: sqlDropDownData.currentPageNo, spinState: false, searchValue: "", totalCount: sqlDropDownData.totalCount, selectTableData: sqlDropDownData.dropDownData, }); } } } } }; /** 获取innerinput控件参数 */ getInnerInputProps = () => { /* 主表和从表的innerinputprops对象有区别 */ if (!this.props.bTable) { /* 主表 */ return this.getInnerInputPropsMaster(); } else { /* 主从表 */ return this.getInnerInputPropsSlave(); } }; /** 获取innerinput控件参数(从) */ getInnerInputPropsSlave = () => { /* 返回值声明 */ let obj = {}; if (this.firstDataIndex === "i" || this.firstDataIndex === "d") { /* 数字输入框(整形i和浮点型d) */ obj = this.getNumberInnerInputPropsSlave(); } else if (this.firstDataIndex === "b") { /* 选择框(布尔类型b) */ obj = this.getBooleanInnerInputPropsSlave(); } else if (this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "m" || this.firstDataIndex === "y") { /* 时间选择框(时间类型t) */ obj = this.getDateInnerInputPropsSlave(); } else if (this.firstDataIndex === "s") { /* 文本输入框(文本s) */ obj = this.getTextInnerInputPropsSlave(); obj.onDoubleClick = this.onDoubleClick; } else if (this.firstDataIndex === "c") { /* 地址联动框(联动下拉类型c) */ obj = this.getAddressInnerInputPropsSlave(); } obj.onKeyDown = this.onKeyDown; obj.onFocus = this.onFocus; obj.onBlur = this.onBlur; obj.onMouseEnter = this.onFocus; obj.id = `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`; /* 所有从表组件添加id */ obj["data-name"] = this.props.showConfig.sName; obj["data-control-name"] = this.props.showConfig.sControlName; obj.placeholder = this.props.showConfig.placeholder || ""; /* 返回值 */ return obj; }; /* 获取地址innerinputprops对象(从) */ getAddressInnerInputPropsSlave = () => { /* 返回值 */ const obj = { // disabled: !this.state.enabled, /* 是否可编辑 */ placeholder: "请选择省市区" /* 预期值的提示信息 */, options: this.getProvinceCityAreaData() /* 数据 */, changeOnSelect: true /* 对每个选择值进行更改 */, onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, value: commonUtils.isUndefined(this.state.dataValue) ? [] : typeof this.state.dataValue === "string" ? this.state.dataValue.split(",") : commonUtils.convertUndefinedToEmptyArr(this.state.dataValue) /* 数据值 */, }; if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } /* 返回值 */ return obj; }; /* 获取文本innerinputprops对象(从) */ getTextInnerInputPropsSlave = () => { /* 返回值声明 */ const bShowSuffix = this.props.showConfig.sName === "sSaveProName" || this.props.showConfig.sName === "sDeleteProName" || this.props.showConfig.sName === "sSaveProNameBefore" || this.props.showConfig.sName === "sProcName" || this.props.showConfig.sName === "sButtonParam"; /* 是否展示后缀图标 */ const bShowArrow = this.props.showConfig.sName === "dNeedAuxiliaryQty"; const obj = { // disabled: !this.state.enabled, /* 是否可编辑 */ id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */, onChange: e => this.handleSelectOptionEvent(e) /* 数据改变回带到父组件 */, value: commonUtils.isUndefined(this.state.dataValue) ? "" : commonUtils.strUndefinedToEmpty(this.state.dataValue) /* 数据值 */, // eslint-disable-next-line no-return-assign ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */, onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */, suffix: bShowSuffix ? ( ) : bShowArrow ? ( ) : ( "" ), rows: commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1, }; if (this.props.showConfig.sName.toLowerCase().includes('instruct') && this.props.enabled) { obj.suffix = ( ); } if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } /* 最大值最小值 */ if ( typeof commonUtils.convertStrToNumber(this.max) === "number" && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf(".d") === -1 && this.max.indexOf(".i") === -1 ) { obj.maxLength = this.max; /* 最大长度 */ obj.title = obj.value; } obj.placeholder = this.props.showConfig.placeholder; obj.autocomplete = "new-password"; /* 返回值 */ return obj; }; /* 获取日期innerinputprops对象(从) */ getDateInnerInputPropsSlave = () => { let { sDateFormat } = this.props.showConfig; if (commonUtils.isEmptyStr(sDateFormat)) { if (this.firstDataIndex === "m") { sDateFormat = "YYYY-MM"; } else if (this.firstDataIndex === "y") { sDateFormat = "YYYY"; } else { sDateFormat = this.props.getDateFormat(); } } let showtimeFormat = false; // if (sDateFormat === 'YYYY-MM-DD HH:mm:ss') { if (sDateFormat.length > 11) { showtimeFormat = true; } else { showtimeFormat = false; } /* 返回值声明 */ const obj = { placeholder: "" /* 时间的提示信息 */, disabled: !this.state.enabled /* 是否可编辑 */, onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, format: sDateFormat, // this.props.getDateFormat(), /* 格式化规则 */ disabledDate: this.getDataMaxAndMin /* 不可选日期 */, showTime: showtimeFormat, style: { width: "100%" } /* 样式 */, onBlur: () => { this.onExecInstructSet("blur"); }, }; // if (this.props.readOnly) { // obj.readOnly = 'readOnly'; // } else { // obj.disabled = !this.state.enabled; // } if (!this.state.enabled) { obj.suffixIcon = ; } /* 值填充 */ obj.value = commonUtils.isEmpty(this.state.dataValue) ? null : moment(this.state.dataValue); /* 返回值 */ return obj; }; /* 获取布尔innerinputprops对象(从) */ getBooleanInnerInputPropsSlave = () => { /* 返回值声明 */ const obj = { disabled: !this.state.enabled /* 是否可编辑 */, onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, checked: commonUtils.isUndefined(this.state.dataValue) ? false : commonUtils.converNumStrToBoolean(this.state.dataValue) /* 是否选中 */, }; // if (this.props.readOnly) { // obj.readOnly = true; // } else { // obj.disabled = !this.state.enabled; // } /* 返回值 */ return obj; }; /* 获取数字innerinputprops对象(从) */ getNumberInnerInputPropsSlave = () => { const bShowArrow = this.props.showConfig.sName === "dNeedAuxiliaryQty" && this.props.showConfig.sControlName !== "slaveInfo"; /* 返回值声明 */ const obj = { id: `${this.props.showConfig.sName}${this.props.showConfig.sId}` /* 虚拟数字键盘使用id获取光标 */, className: styles.inputNum /* 样式名称 */, // disabled: !this.state.enabled, /* 是否可编辑 */ onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, parser: oldValue => { const value = this.handleCheckNumberInnerInput(oldValue); return value; }, // eslint-disable-next-line no-return-assign ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */, onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */, }; if (bShowArrow) { obj.addonAfter = ( ); } if (this.props.readOnly) { obj.readOnly = true; } else { obj.disabled = !this.state.enabled; } /* 最大值最小值 */ if ( typeof commonUtils.convertStrToNumber(this.max) === "number" && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf(".d") === -1 && this.max.indexOf(".i") === -1 ) { obj.max = this.max; /* 最大值 */ } else if (!commonUtils.isEmpty(this.max) && this.max.indexOf(".") > -1 && commonUtils.isNotEmptyObject(this.props.record)) { obj.max = this.props.record[this.max.substring(this.max.indexOf(".") + 1)]; } if (typeof commonUtils.convertStrToNumber(this.min) === "number" && commonUtils.convertStrToNumber(this.min) !== 0) { obj.min = this.min; /* 最小值 */ } if (obj.max < 0) { /* 为解决收付款单据未收款为负数时收款金额不能大于未收款问题,当最大值小于0时,变更为设为最小值 */ obj.min = obj.max; obj.max = 0; } /* 浮点型需要格式化 */ if (this.firstDataIndex === "d") { // obj.formatter = value => this.toFamatter(value); // obj.parser = value => this.toFamatter(value); // obj.precision = this.floatNum; // obj.formatter = value => this.limitDecimals(value); // obj.parser = value => this.limitDecimals(value); } /* 值填充 */ const { dNetPrice } = this.props.app.decimals; const { showConfig } = this.props; const { sName, showName } = showConfig; const digit = sName.includes("Price") ? dNetPrice : 6; const numCheck = new RegExp(`^(-?\\d+)(\\.?)(\\d{1,${digit}})?$`); const numValue = this.state.dataValue; if (!isNaN(+numValue)) { if (!numCheck.test(numValue) && numValue) { message.warning(`【${showName}】【${sName}】最多${digit}位小数`); } } obj.value = this.state.dataValue; obj.step = 0; /* 返回值 */ return obj; }; /** 获取innerinput控件参数(主) */ getInnerInputPropsMaster = () => { /* 返回值声明 */ let obj = {}; if (this.firstDataIndex === "i" || this.firstDataIndex === "d") { /* 数字输入框(整形i和浮点型d) */ obj = this.getNumberInnerInputPropsMaster(); } else if (this.firstDataIndex === "b") { /* 选择框(布尔类型b) */ obj = this.getBooleanInnerInputPropsMaster(); } else if (this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "m" || this.firstDataIndex === "y") { /* 时间选择框(时间类型t) */ obj = this.getDateInnerInputPropsMaster(); } else if (this.firstDataIndex === "s") { /* 文本输入框(文本s) */ if (this.props.textArea) { /* 大文本输入框 */ obj = this.getTextAreaInnerInputPropsMaster(); obj.onDoubleClick = this.onDoubleClick; } else { /* 普通文本输入框 */ obj = this.getTextInnerInputPropsMaster(); if (this.props?.showConfig?.sName === "sInstruct") { obj.onDoubleClick = this.onDoubleClick; } } } else if (this.firstDataIndex === "c") { /* 地址联动框(联动下拉类型c) */ obj = this.getAddressInnerInputPropsMaster(); } obj.onKeyDown = this.onKeyDown; obj.onKeyUp = this.onKeyUp; obj.onBlur = this.onBlur; if (this.props.allowClear) { obj.allowClear = this.props.allowClear; /* 带移除图标 */ } obj.placeholder = this.props.showConfig.placeholder || ""; // obj.onContextMenu = this.onContextMenu; /* 返回值 */ return obj; }; /* 获取地址innerinputprops对象(主) */ getAddressInnerInputPropsMaster = () => { const obj = { // disabled: !this.state.enabled, /* 是否可编辑 */ placeholder: "请选择省市区" /* 预期值的提示信息 */, options: this.getProvinceCityAreaData() /* 数据 */, changeOnSelect: true /* 对每个选择值进行更改 */, onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, }; if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } return obj; }; /* 获取文本innerinputprops对象(主) */ getTextInnerInputPropsMaster = () => { /* 返回值声明 */ const bShowSuffix = this.props.showConfig.sName === "sButtonParam" || this.props.showConfig.sName === "sSqlStr" || this.props.showConfig.sName === "sConfigSqlStr" || this.props.showConfig.sName === "sProcName"; /* 是否展示后缀图标 */ const obj = { id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */, // disabled: !this.state.enabled, /* 是否可编辑 */ onChange: e => this.handleSelectOptionEvent(e) /* 数据改变回带到父组件 */, // eslint-disable-next-line no-return-assign ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */, onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */, suffix: bShowSuffix ? ( ) : ( "" ), }; if (this.props.showConfig.sName.toLowerCase().includes('instruct') && this.props.enabled) { obj.suffix = ( ); } if (this.props.readOnly) { obj.readOnly = "readOnly"; } else { obj.disabled = !this.state.enabled; } if (this.props.bPassWord) { obj.type = "password"; /* 文本密码类型 */ } /* 最大值最小值 */ // if (this.props.showConfig.sName === 'sZmmGgxh') { // console.log('sZmmGgxhsZmmGgxh', this.max, (typeof commonUtils.convertStrToNumber(this.max) === 'number' && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf('.d') === -1 && this.max.indexOf('.i') === -1)); // } if ( typeof commonUtils.convertStrToNumber(this.max) === "number" && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf(".d") === -1 && this.max.indexOf(".i") === -1 ) { obj.maxLength = this.max; /* 最大长度 */ } obj.onBlur = this.onBlurText; obj.autocomplete = "new-password"; /* 返回值 */ return obj; }; /* 获取大文本innerinputprops对象(主) */ getTextAreaInnerInputPropsMaster = () => { /* 返回值声明 */ const obj = { id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */, // disabled: !this.state.enabled, /* 是否可编辑 */ // rows: 3, /* 纵跨度 */ rows: commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1 /* 产品部要求 备注设置成一行到底 */, onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, // eslint-disable-next-line no-return-assign ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */, onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */, }; if (this.props.readOnly) { obj.readOnly = "readOnly"; } if (commonUtils.isNotEmptyObject(this.props.showConfig.sName) && this.props.showConfig.sName.toLowerCase().endsWith("memo")) { if (!this.state.enabled) { /* 非编辑模式下 */ obj.readOnly = true; obj.style = { backgroundColor: "#f1f2f8" }; } else { obj.disabled = !this.state.enabled; } } else { obj.disabled = !this.state.enabled; } /* 最大值最小值 */ if ( typeof commonUtils.convertStrToNumber(this.max) === "number" && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf(".d") === -1 && this.max.indexOf(".i") === -1 ) { obj.maxLength = this.max; /* 最大长度 */ } return obj; }; /* 获取日期最大值和最小值 */ getDataMaxAndMin = current => { return this.getDataMax(current) || this.getDataMin(current); }; /* 获取日期最大值 */ getDataMax = current => { const showtimeFormat = this.props.showConfig.sDateFormat?.length > 11; if (commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && this.props.showConfig.sMaxValue.split(".").length > 1) { const conditionValues = this.props.getSqlCondition({ sSqlCondition: this.props.showConfig.sMaxValue }, "", {}); const sMaxValue = Object.keys(conditionValues).length > 0 ? conditionValues[Object.keys(conditionValues)[0]] : this.props.showConfig.sMaxValue; const tDate = this.props.showConfig.sMaxValue === "now" ? moment() : moment(sMaxValue); return showtimeFormat ? commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current > tDate : commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current.endOf("day") > tDate.endOf("day"); } else { const tDate = this.props.showConfig.sMaxValue === "now" ? moment() : moment(this.props.showConfig.sMaxValue); return showtimeFormat ? commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current > tDate : commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current.endOf("day") > tDate.endOf("day"); } }; /* 获取日期最小值 */ getDataMin = current => { const showtimeFormat = this.props.showConfig.sDateFormat?.length > 11; if (commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && this.props.showConfig.sMinValue.split(".").length > 1) { const conditionValues = this.props.getSqlCondition({ sSqlCondition: this.props.showConfig.sMinValue }, "", {}); const sMinValue = Object.keys(conditionValues).length > 0 ? conditionValues[Object.keys(conditionValues)[0]] : this.props.showConfig.sMinValue; const tDate = this.props.showConfig.sMinValue === "now" ? moment() : moment(sMinValue); return showtimeFormat ? commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current < tDate : commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current.endOf("day") < tDate.endOf("day"); } else { const tDate = this.props.showConfig.sMinValue === "now" ? moment() : moment(this.props.showConfig.sMinValue); return showtimeFormat ? commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current < tDate : commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current.endOf("day") < tDate.endOf("day"); } }; /* 获取时间innerinputprops对象(主) */ getDateInnerInputPropsMaster = () => { let { sDateFormat } = this.props.showConfig; if (commonUtils.isEmptyStr(sDateFormat)) { if (this.firstDataIndex === "m") { sDateFormat = "YYYY-MM"; } else if (this.firstDataIndex === "y") { sDateFormat = "YYYY"; } else { sDateFormat = this.props.getDateFormat(); } } let showtimeFormat = false; // if (sDateFormat === 'YYYY-MM-DD HH:mm:ss') { if (sDateFormat.length > 11) { showtimeFormat = true; } else { showtimeFormat = false; } // 2021-6-5日修改,生产排程日期选择精确到小时 const obj = { placeholder: "" /* 时间的提示信息 */, disabled: !this.state.enabled /* 是否可编辑 */, style: { width: "100%" } /* 样式 */, // showTime: this.props.showTime ? { format: 'HH:mm', defaultValue: [moment('00:00', 'HH:mm'), moment('00:00', 'HH:mm')] } : '', // showTime: this.props.showTime, showTime: showtimeFormat, format: this.props.showTime ? "YYYY-MM-DD HH:mm:ss" : sDateFormat, // this.props.getDateFormat(), /* 格式化规则 */ onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, disabledDate: this.getDataMaxAndMin /* 不可选日期 */, onBlur: () => { this.onExecInstructSet("blur"); }, }; // if (this.props.readOnly) { // obj.readOnly = 'readOnly'; // } else { // obj.disabled = !this.state.enabled; // } return obj; }; /* 获取布尔innerinputprops对象(主) */ getBooleanInnerInputPropsMaster = () => { const obj = { disabled: !this.state.enabled /* 是否显示 */, onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, checked: commonUtils.isUndefined(this.state.dataValue) ? false : commonUtils.converNumStrToBoolean(this.state.dataValue) /* 是否选中 */, }; // if (this.props.readOnly) { // obj.readOnly = true; // } else { // obj.disabled = !this.state.enabled; // } return obj; }; // eslint-disable-next-line react/sort-comp handleInputOnClick = id => { // 判断是否是oee系统,否则不显示虚拟键盘 if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf("/indexOee") > -1) { if (VirtualKeyboard.isKeyBoard()) { // 关闭上次键盘 VirtualKeyboard.closeKeyboard(); } const keyboardValue = {}; if (commonUtils.isNotEmptyObject(this.props.dataValue)) { keyboardValue.value = this.props.dataValue; } else { keyboardValue.value = ""; } VirtualKeyboard.showKeyboardSetState(keyboardValue, this, id); } if (this.props.onInputClick) { // eslint-disable-next-line prefer-destructuring const sName = this.props.showConfig.sName; const rowId = this.props.record.sId; this.props.onInputClick(rowId, sName); } }; /* 获取数字innerinputprops对象(主) */ getNumberInnerInputPropsMaster = () => { /* 如果是浮点型并且有格式规定,display类型需要变为block */ let display = "inline-block"; if (this.firstDataIndex === "d" && this.floatNum !== 0) { display = "block"; } // const sInputId = `id${commonUtils.createSid()}`; /* 返回值赋值 */ const obj = { id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */, style: { width: "auto", display, marginRight: 0 } /* 样式 */, // disabled: !this.state.enabled, /* 是否显示 */ onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */, parser: oldValue => { const value = this.handleCheckNumberInnerInput(oldValue); return value; }, // eslint-disable-next-line no-return-assign ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 这里得ref中得变量必须是input得id */, onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */, }; if (this.props.readOnly) { obj.readOnly = true; } else { obj.disabled = !this.state.enabled; } /* 最大值最小值 */ if ( typeof commonUtils.convertStrToNumber(this.max) === "number" && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf(".d") === -1 && this.max.indexOf(".i") === -1 ) { obj.max = this.max; /* 最大值 */ } else if (!commonUtils.isEmpty(this.max) && this.max.indexOf(".") > -1 && commonUtils.isNotEmptyObject(this.props.record)) { obj.max = this.props.record[this.max.substring(this.max.indexOf(".") + 1)]; } if (typeof commonUtils.convertStrToNumber(this.min) === "number" && commonUtils.convertStrToNumber(this.min) !== 0) { obj.min = this.min; /* 最小值 */ } obj.placeholder = this.props.showConfig.placeholder; /* 格式规格不为0就在props里设置一下 */ // if (this.firstDataIndex === 'd' && this.floatNum !== 0) { // obj.precision = this.floatNum; // } /* 返回值 */ return obj; }; /* 获取省市区数据 */ getProvinceCityAreaData = () => { /* 返回值声明 */ const options = []; /* 获取省数据 */ this.getProvinceData(options); /* 获取市数据 */ this.getCityData(options); /* 获取区数据 */ this.getAreaData(options); /* 返回值 */ return options; }; /* 获取省数据 */ getProvinceData = options => { Provinces.forEach(childProvince => { options.push({ value: childProvince.name /* 文字 */, label: childProvince.name /* 标签 */, code: childProvince.code /* 编码 */, children: [] /* 子节点(city) */, }); }); }; /* 获取市数据 */ getCityData = options => { options.forEach(childProvince => { const cities = Cities.filter(item => item.provinceCode === childProvince.code); if (cities.length > 0) { cities.forEach(childCity => { childProvince.children.push({ value: childCity.name /* 文字 */, label: childCity.name /* 标签 */, code: childCity.code /* 编码 */, children: [] /* 子节点(area) */, }); }); } }); }; /* 获取区数据 */ getAreaData = options => { options.forEach(childProvince => { const cities = childProvince.children; cities.forEach(childCity => { const areas = Areas.filter(item => item.cityCode === childCity.code); if (areas.length > 0) { areas.forEach(area => { childCity.children.push({ value: area.name /* 文字 */, label: area.name /* 标签 */, code: area.code /* 编码 */, }); }); } }); }); }; /* 获取formitemprops对象 */ getOutFormItemProps = () => { /* 主表和从表的formitemprops对象有区别 */ if (!this.props.bTable) { /* 主表 */ return this.getOutFormItemPropsMaster(); } else if (this.props.bViewTable) { /* 表格单行显示 */ return this.getOutFormItemPropsViewSlave(); } else { /* 从表 */ return this.getOutFormItemPropsSlave(); } }; /* 获取formitemprops对象(主) */ getOutFormItemPropsMaster = () => { /* 返回值声明 */ let obj = {}; if ( this.firstDataIndex === "i" || this.firstDataIndex === "d" || this.firstDataIndex === "p" || this.firstDataIndex === "t" || this.firstDataIndex === "m" || this.firstDataIndex === "s" || this.firstDataIndex === "c" ) { /* 数字输入框(整形i和浮点型d), 时间选择框(时间类型t), 文本输入框(文本s), 地址联动框(联动下拉类型c) */ obj = { label: this.props.showConfig.showName /* 标签 */, className: styles.formItemMargin /* 样式名称 */, ...this.formItemLayout /* 主要是rowspan和colspan */, }; } else if (this.firstDataIndex === "b") { /* 选择框(布尔类型b) */ obj = { label: this.props.showConfig.showName /* 标签 */, className: styles.formItemMag10 /* 样式名称 */, ...this.formItemLayout /* 主要是rowspan和colspan */, }; } if (this.props.itemLabel === "hide") { delete obj.label; } /* 设置标题颜色 */ if (this.props.showConfig.sFontColor) { // eslint-disable-next-line prefer-destructuring const sFontColor = this.props.showConfig.sFontColor; obj.labelCol.style = { color: sFontColor, fontWeight: "bold", backgroundColor: "#BFEFFF" }; } /* 返回值 */ return obj; }; /* 获取formitemprops对象(单条从表数据) */ getOutFormItemPropsViewSlave = () => { /* 返回值声明 */ let obj = {}; if ( this.firstDataIndex === "i" || this.firstDataIndex === "d" || this.firstDataIndex === "p" || this.firstDataIndex === "t" || this.firstDataIndex === "m" || this.firstDataIndex === "s" || this.firstDataIndex === "c" ) { /* 数字输入框(整形i和浮点型d), 时间选择框(时间类型t), 文本输入框(文本s), 地址联动框(联动下拉类型c) */ obj = { label: this.props.showConfig.showName /* 标签 */, className: styles.formItemMargin /* 样式名称 */, ...this.formItemLayout /* 主要是rowspan和colspan */, }; } else if (this.firstDataIndex === "b") { /* 选择框(布尔类型b) */ obj = { label: this.props.showConfig.showName /* 标签 */, className: styles.formItemMag10 /* 样式名称 */, ...this.formItemLayout /* 主要是rowspan和colspan */, }; } if (this.props.itemLabel === "hide") { delete obj.label; } /* 设置标题颜色 */ if (this.props.showConfig.sFontColor) { // eslint-disable-next-line prefer-destructuring const sFontColor = this.props.showConfig.sFontColor; obj.labelCol.style = { color: sFontColor, fontWeight: "bold", backgroundColor: "#BFEFFF" }; } /* 返回值 */ return obj; }; /* 获取formitemprops对象(从) */ getOutFormItemPropsSlave = () => { /* 返回值声明 */ let obj = {}; if ( this.firstDataIndex === "i" || this.firstDataIndex === "d" || this.firstDataIndex === "c" || this.props.showConfig.sDropDownType === "sql" || this.props.showConfig.sDropDownType === "const" ) { /* 数字输入框(整形i和浮点型d), 时间选择框(时间类型t), 文本输入框(文本s), 地址联动框(联动下拉类型c), 所有的下拉(从表只有文字下拉,分常量和sql两种) */ obj = { className: styles.formItemMargin0 /* 样式名称 */, }; } else if (this.firstDataIndex === "b") { /* 选择框(布尔类型b) */ obj = { className: styles.tableCheckBox /* 样式名称 */, }; } else if (this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "m" || this.firstDataIndex === "y") { /* 时间选择框(时间类型t) */ obj = { className: styles.tableDataPicker /* 样式名称 */, }; } else if (this.firstDataIndex === "s") { /* 文本输入框(文本s) */ obj = { className: styles.editInput /* 样式名称 */, }; } /* 返回值 */ return obj; }; /* 获取fielddecoratorprops对象 */ getFieldDecoratorProps = () => { /* 返回值声明 */ let obj = {}; if ( this.firstDataIndex === "i" || this.firstDataIndex === "d" || this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "s" || this.firstDataIndex === "b" ) { /* 数字输入框(整形i和浮点型d),时间选择框(时间类型t),文本输入框(文本s),选择框(布尔类型b) */ obj = { rules: [{ required: this.props.showConfig.bNotEmpty, message: `${this.props.showConfig.showName}为必填项` }] }; } else if (this.firstDataIndex === "c") { /* 地址联动框(联动下拉类型c) */ obj = { initialValue: ["北京市", "市辖区", "东城区"] /* 默认值 */, rules: [{ required: this.props.showConfig.bNotEmpty, message: `${this.props.showConfig.showName}为必填项` }] /* 规则 */, }; } /* 返回值 */ return obj; }; getPopupContainer = triggerNode => { const trigger = triggerNode; if (commonUtils.isNotEmptyObject(trigger)) { return triggerNode; } }; handleCancel = () => { this.state.previewOpen = false; }; handleSelectClick = () => { if (this.bInputIn) { this.setState({ bDropDownOpen: true }); } }; // 限制数字位数 handleCheckNumberInnerInput = value => { const { sDateFormat: sDateFormatOld, sFieldValidation: sFieldValidationOld, sName } = this.props.showConfig; const { record = {}, app = {} } = this.props; const { auxiliaryQty = {} } = app; let sDateFormat = sDateFormatOld; let sFieldValidation = sFieldValidationOld; if (sName === "dAuxiliaryQty" && commonUtils.isNotEmptyObject(record.sAuxiliaryUnit)) { const decimal = auxiliaryQty[record.sAuxiliaryUnit]; if (decimal !== undefined) { sDateFormat = "decimalPoint"; sFieldValidation = `,${decimal}`; } } if (sDateFormat !== "decimalPoint" || sFieldValidation === undefined || value === null || (typeof value === "string" && !value)) { return value; } const [length1, length2] = sFieldValidation.split(","); let newValue = value; if (length2 !== undefined) { newValue = commonUtils.convertFixNum(value, Number(length2)); } if (isNaN(newValue) || Object.is(newValue, -0)) { return value; } if (length1 !== undefined && length1 !== "") { const str = newValue.toString(); const [integerPart, decimalPart] = str.split("."); if (integerPart.length > length1) { const truncatedInteger = integerPart.slice(0, length1); if (decimalPart !== undefined) { newValue = Number(`${truncatedInteger}.${decimalPart}`); } else { newValue = Number(truncatedInteger); } } } return newValue; }; selectTableChange = pageNum => { if (this.selectTableRef) { this.selectTableRef.focus(); } if (this.state.searchValue) { this.setState({ tempCurrentPage: pageNum, selectTableIndex: 0 }); } else { this.setState({ currentPage: pageNum, selectTableIndex: 0 }); } const bodyDom = this.selectTableRef1?.querySelector(".ant-table-body"); if (bodyDom) { bodyDom.scrollTop = 0; } this.getDropDownData(pageNum, this.state.totalPageCount, this.state.searchValue); }; selectTableSearch = searchValue => { if (this.dropDownTimer) { clearTimeout(this.dropDownTimer); } this.dropDownTimer = setTimeout(() => { this.setState({ searchValue, tempCurrentPage: searchValue ? 1 : undefined, }); const pageNum = searchValue ? 1 : this.state.currentPage; this.dropDownCount += 1; this.getDropDownData(pageNum, this.state.totalPageCount, searchValue, this.dropDownCount); }, 500); }; toFamatter = values => { if (values !== 0 && commonUtils.isNotEmptyNumber(values) && values !== null) { const { sDateFormat } = this.props.showConfig; const { dNetMoney, dNetPrice } = this.props.app.decimals; /* 如果配置时间格式中设置了0.0000则以配置为准,没有设置时间格式 则以系统设定为主 */ if (commonUtils.isNotEmptyObject(sDateFormat)) { /* 取小数点位数 */ let point = 0; const strIndex = sDateFormat.indexOf("."); if (strIndex > -1 && sDateFormat.length > 1) { point = sDateFormat.substring(strIndex + 1, sDateFormat.length).length; if (commonUtils.isNotEmptyNumber(values) && values !== null) { const dConfigResult = commonUtils.convertFixNum(Number(values), point).toFixed(point); if (!isNaN(dConfigResult)) { values = dConfigResult; } } } } else if (this.props.showConfig.sName.toLowerCase().endsWith("price")) { /* 单价格式化显示1 */ if (commonUtils.isNotEmptyNumber(values) && values !== null) { const dResult = commonUtils.convertFixNum(Number(values), dNetPrice).toFixed(dNetPrice); if (!isNaN(dResult)) { values = dResult; } } } else if (this.props.showConfig.sName.toLowerCase().endsWith("money")) { /* 金额格式化显示 */ if (commonUtils.isNotEmptyNumber(values) && values !== null) { const dResult = commonUtils.convertFixNum(Number(values), dNetMoney).toFixed(dNetMoney); if (!isNaN(dResult)) { values = dResult; } } } return values; } else { return values; } }; /** 处理下拉选择事件 */ handleSelectOptionEvent = (newValue, dateString) => { if (this.chineseInputting) { return; } // if (location.pathname?.includes('productionScheduleTree') && this.props.showConfig.sName && this.props.showConfig.sName.includes('sThird-')) { // return; // } // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到; // 做了兼容处理 // if (newValue === undefined || newValue == null) { // return; // } if (newValue === undefined) return; if (newValue !== null && newValue.target && newValue.target.type !== "checkbox") { newValue = newValue.target.value; } /* 下拉新增单独处理 */ const dEmptyValue = this.props.showConfig.sName === "dMachineLength" || this.props.showConfig.sName === "dMachineWidth" ? newValue : null; /* 设置数值型为空值时 数据置为0 或空值 */ let value = this.firstDataIndex === "s" && !this.props.textArea && commonUtils.isEmpty(newValue) ? newValue.replace("--", "") : ["t", "m"].includes(this.firstDataIndex) ? dateString : (this.firstDataIndex === "d" || this.firstDataIndex === "i") && commonUtils.isEmpty(newValue) ? dEmptyValue : newValue; value = this.props.showConfig.bMultipleChoice ? value.toString() : value; // if (value === 0) { // setTimeout(() => { // if (document.getElementById(`${this.props.showConfig.sName}${this.props.sId}`)) { // document.getElementById(`${this.props.showConfig.sName}${this.props.sId}`).select(); // } // }, 51); // } this.isDropdownFilter = true; if (this.props.showConfig.sDropDownType === "sql" && value === "@#*000@") { this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name); if (this.mounted) { this.setState({ dataValue: "" }); } return; } if (this.props.showConfig.sDropDownType === "sql" && value === "=+@") { /* 如果是选择空值,则将特殊字符过滤为空值 */ value = ""; } if (this.props.showConfig.sDropDownType === "const" && value === "=+@") { /* 如果是选择空值,则将特殊字符过滤为空值 */ value = ""; } /* 回带值声明 */ const returnValue = {}; const { searchValue, searchDropDownData, dropDownData, selectTableData } = this.state; let dropDownDataNew = []; /* 如果是表格下拉的话 */ if (commonUtils.isNotEmptyStr(this.props.showConfig?.sTableTitleSql) && this.props.showConfig?.iVisCount > 1) { dropDownDataNew = commonUtils.isEmptyArr(selectTableData) ? dropDownData : selectTableData; } else { dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData; } const getTValue = value => { const { sDateFormat = "YYYY-MM-DD" } = this.props.showConfig; if (moment(value, sDateFormat, true).isValid()) return value; // 如果数据满足日期格式,则直接返回 if (commonUtils.isEmpty(value)) { return null; } else if (sDateFormat) { return moment(value).format(this.props.showConfig.sDateFormat); } else { return value; } }; /* 回带值赋值(sName:value) */ returnValue[this.props.showConfig.sName] = // this.firstDataIndex === 's' && this.props.textArea ? value.target.value : this.firstDataIndex === "i" ? commonUtils.isEmpty(value) ? undefined : this.props.showConfig.sName === "iOrder" ? value : parseInt(value, 0) : this.firstDataIndex === "d" ? commonUtils.isEmpty(value) ? undefined : this.floatNumberCheck(value) : this.firstDataIndex === "t" ? getTValue(value) : this.firstDataIndex === "b" ? value.target.checked : value === null ? undefined : value; if (!this.props.showConfig.bMultipleChoice) { const { sAssignField } = this.props.showConfig; const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(item.sSlaveId) ? item.sSlaveId : item.sId) === value.toString()); if (!commonUtils.isEmpty(sAssignField)) { /* 赋值数组 */ const sAssignFieldObj = sAssignField.split(","); if (commonUtils.isNotEmptyObject(changeData)) { for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); const sValueName = child.split(":")[1].trim(); // returnValue[sFieldName] = changeData[sValueName] || changeData.value; returnValue[sFieldName] = changeData[sValueName] === 0 ? 0 : changeData[sValueName] || changeData.value; } } } else if (!this.props.showConfig.bCanInput) { // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了 for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); returnValue[sFieldName] = ""; } } } } } else { const { sAssignField } = this.props.showConfig; const changeData = dropDownDataNew.filter(item => `,${value.toString()},`.includes(!commonUtils.isEmpty(item.sSlaveId) ? `,${item.sSlaveId},` : `,${item.sId},`) ); if (!commonUtils.isEmpty(sAssignField)) { /* 赋值数组 */ const sAssignFieldObj = sAssignField.split(","); if (commonUtils.isNotEmptyArr(changeData)) { for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); const sValueName = child.split(":")[1].trim(); const valueArr = []; changeData.forEach(itemData => { valueArr.push(itemData[sValueName]); }); returnValue[sFieldName] = valueArr.toString(); } } } else if (!this.props.showConfig.bCanInput) { // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了 for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); returnValue[sFieldName] = ""; } } } } // 如果returnValue的第一个key对应的value的数据和上文的value个数不一致, 则取value的数据; // 处理原因:如果已选数据不在下拉数据中时(比如懒加载模式),会过滤掉已选数据 if (commonUtils.isNotEmptyArr(Object.keys(returnValue))) { const [returnValueKey0, returnValueValue0] = [Object.keys(returnValue)[0], Object.values(returnValue)[0]]; if (returnValueValue0.split(",").length !== value.split(",").length || (returnValueValue0 === "" && value !== "")) { returnValue[returnValueKey0] = value; } } } if ( this.state.searchPageNum !== 0 || this.state.searchTotalPageCount !== 1 || this.state.searchDropDownData !== [] || this.state.searchValue !== "" || this.state.spinState !== false ) { this.setState({ searchPageNum: 0, searchTotalPageCount: 1, searchDropDownData: [], searchValue: "", spinState: false, }); } // /* 调用父组件的回带函数 */ this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew); clearTimeout(this.onChangeTimer); this.onChangeTimer = setTimeout(() => { this.onExecInstructSet("change"); }, 500); }; /** 处理autoComplete下拉选择事件 */ // handleCompleteInputEvent = (newValue) => { // // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到; // // 做了兼容处理 // if (newValue === undefined || newValue == null) { // return; // } // if (newValue === undefined) return; // if (newValue.target && newValue.target.type !== 'checkbox') { // newValue = newValue.target.value; // } // const returnValue = {}; // const { searchValue, searchDropDownData, dropDownData } = this.state; // const dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData; // returnValue[this.props.showConfig.sName] = newValue; // if (this.state.searchPageNum !== 0 || this.state.searchTotalPageCount !== 1 || this.state.searchDropDownData !== [] || this.state.searchValue !== '' || this.state.spinState !== false) { // this.setState({ // searchPageNum: 0, searchTotalPageCount: 1, searchDropDownData: [], searchValue: '', spinState: false, // }); // } // this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew); // }; handleCompleteInputEvent = (newValue, dateString) => { // 输入完成后的半秒内,如果触发了输入事件,则不执行 if (this.chineseInputting) { this.handleCompleteInputEventCache = () => { this.chineseInputtingTimer = setTimeout(() => { this.handleCompleteInputEvent(newValue, dateString); this.handleCompleteInputEventCache = null; }, 500); }; return; } clearTimeout(this.chineseInputtingTimer); // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到; // eslint-disable-next-line no-unused-vars // const newKey = newValue.key || 0; newValue = commonUtils.isNotEmptyObject(newValue.value) ? newValue.value : newValue; /* 处理可输入下拉框 输入数据时 没触发onChange事件 */ // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到; // 做了兼容处理 if (newValue === undefined) { return; } if (newValue.target && newValue.target.type !== "checkbox") { newValue = newValue.target.value; } /* 下拉新增单独处理 */ const dMachine = ["dMachineLength", "dMachineWidth"].includes(this.props.showConfig.sName); if (dMachine) { if (!/^\d+(\.\d+)?(\*\d+(\.\d+)?)?$/.test(newValue)) { newValue = ""; setTimeout(() => { this.setState({ searchValue: "" }); }, 1200); } } const dEmptyValue = this.props.showConfig.sName === "dMachineLength" || this.props.showConfig.sName === "dMachineWidth" ? newValue : 0; /* 设置数值型为空值时 数据置为0 或空值 */ let value = this.firstDataIndex === "s" && !this.props.textArea && commonUtils.isEmpty(newValue) ? newValue.replace("--", "") : this.firstDataIndex === "t" ? dateString : (this.firstDataIndex === "d" || this.firstDataIndex === "i") && commonUtils.isEmpty(newValue) ? dEmptyValue : newValue; value = this.props.showConfig.bMultipleChoice ? value.toString() : value; // if (this.props.showConfig.sName === 'dMachineLength' || this.props.showConfig.sName === 'dMachineWidth') { /* 处理上机长宽 下拉数据 数据分割错误问题 */ // value = this.floatNumberCheck(value); // } this.isDropdownFilter = true; if (this.props.showConfig.sDropDownType === "sql" && value === "@#*000@") { this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name); if (this.mounted) { this.setState({ dataValue: "" }); } return; } if (this.props.showConfig.sDropDownType === "sql" && value === "=+@") { /* 如果是选择空值,则将特殊字符过滤为空值 */ value = ""; } if (this.props.showConfig.sDropDownType === "const" && value === "=+@") { /* 如果是选择空值,则将特殊字符过滤为空值 */ value = ""; } /* 回带值声明 */ const returnValue = {}; const { searchValue, searchDropDownData, dropDownData } = this.state; const dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData; /* 回带值赋值(sName:value) */ returnValue[this.props.showConfig.sName] = // this.firstDataIndex === 's' && this.props.textArea ? value.target.value : this.firstDataIndex === "i" ? commonUtils.isEmpty(value) ? undefined : this.props.showConfig.sName === "iOrder" ? value : parseInt(value, 0) : this.firstDataIndex === "d" ? commonUtils.isEmpty(value) ? dMachine ? "" : undefined : value // this.floatNumberCheck(value) : : this.firstDataIndex === "t" ? commonUtils.isEmpty(value) ? null : value : this.firstDataIndex === "b" ? value.target.checked : value === null ? undefined : value; if (!this.props.showConfig.bMultipleChoice) { const { sAssignField } = this.props.showConfig; // const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(item.sSlaveId) ? item.sSlaveId : item.sId) === newKey.toString()); let res = ""; if (dropDownDataNew.length > 0) { if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) { res = this.props.showConfig.sVisColumnName; } else { res = Object.keys(dropDownDataNew[0]).length > 0 ? Object.keys(dropDownDataNew[0])[0] : ""; } } const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(res) ? item[res] : item.sId) === value.toString()); if (!commonUtils.isEmpty(sAssignField)) { /* 赋值数组 */ const sAssignFieldObj = sAssignField.split(","); if (commonUtils.isNotEmptyObject(changeData)) { for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); const sValueName = child.split(":")[1].trim(); returnValue[sFieldName] = changeData[sValueName] || changeData.value; } } } else if (!this.props.showConfig.bCanInput) { // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了 for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); returnValue[sFieldName] = ""; } } } } } else { const { sAssignField } = this.props.showConfig; const changeData = dropDownDataNew.filter(item => `,${value.toString()},`.includes(!commonUtils.isEmpty(item.sSlaveId) ? `,${item.sSlaveId},` : `,${item.sId},`) ); if (!commonUtils.isEmpty(sAssignField)) { /* 赋值数组 */ const sAssignFieldObj = sAssignField.split(","); if (commonUtils.isNotEmptyArr(changeData)) { for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); const sValueName = child.split(":")[1].trim(); const valueArr = []; changeData.forEach(itemData => { valueArr.push(itemData[sValueName]); }); returnValue[sFieldName] = valueArr.toString(); } } } else if (!this.props.showConfig.bCanInput) { // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了 for (const child of sAssignFieldObj) { if (child.indexOf(":") > -1) { const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim(); returnValue[sFieldName] = ""; } } } } } if ( this.state.searchPageNum !== 0 || this.state.searchTotalPageCount !== 1 || this.state.searchDropDownData !== [] || this.state.searchValue !== "" || this.state.spinState !== false ) { this.setState({ searchPageNum: 0, searchTotalPageCount: 1, searchDropDownData: [], searchValue: "", spinState: false, }); } // /* 调用父组件的回带函数 */ let bSpecial = true; if (location.pathname && location.pathname.includes("ResearchTableTree")) { bSpecial = false; } if (bSpecial && this.state.dataValue === returnValue[this.props.showConfig.sName]) { if (!this.completeFlag) { const addState = {}; addState[this.props.showConfig.sName] = undefined; this.props.onChange(this.props.name, this.props.showConfig.sName, { ...returnValue, ...addState }, this.props.sId, dropDownDataNew); setTimeout(() => { this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew); }, 200); } this.completeFlag = false; } else { this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew); } clearTimeout(this.onChangeTimer); this.onChangeTimer = setTimeout(() => { this.onExecInstructSet("change"); }, 500); }; // handleCompleteOptionEvent = (newValue, dateString) => { // // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到; // const newKey = newValue.key; // newValue = newValue.value; // /* 下拉新增单独处理 */ // const dEmptyValue = this.props.showConfig.sName === 'dMachineLength' || this.props.showConfig.sName === 'dMachineWidth' ? newValue : 0; /* 设置数值型为空值时 数据置为0 或空值 */ // let value = this.firstDataIndex === 's' && !this.props.textArea && commonUtils.isEmpty(newValue) ? newValue.replace('--', '') : // this.firstDataIndex === 't' ? dateString : (this.firstDataIndex === 'd' || this.firstDataIndex === 'i') && commonUtils.isEmpty(newValue) ? dEmptyValue : newValue; // value = this.props.showConfig.bMultipleChoice ? value.toString() : value; // // let value = this.firstDataIndex === 's' && !this.props.textArea && commonUtils.isEmpty(newValue) ? newValue.replace('--', '') : // // this.firstDataIndex === 't' ? dateString : (this.firstDataIndex === 'd' || this.firstDataIndex === 'i') && commonUtils.isEmpty(newValue) ? 0 : newValue; // // value = this.props.showConfig.bMultipleChoice ? value.toString() : value; // this.isDropdownFilter = true; // if (this.props.showConfig.sDropDownType === 'sql' && value === '@#*000@') { // this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name); // if (this.mounted) { // this.setState({ dataValue: '' }); // } // return; // } // if (this.props.showConfig.sDropDownType === 'sql' && value === '=+@') { /* 如果是选择空值,则将特殊字符过滤为空值 */ // value = ''; // } // if (this.props.showConfig.sDropDownType === 'const' && value === '=+@') { /* 如果是选择空值,则将特殊字符过滤为空值 */ // value = ''; // } // /* 回带值声明 */ // const returnValue = {}; // const { searchValue, searchDropDownData, dropDownData } = this.state; // const dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData; // /* 回带值赋值(sName:value) */ // returnValue[this.props.showConfig.sName] = // // this.firstDataIndex === 's' && this.props.textArea ? value.target.value : // this.firstDataIndex === 'i' ? commonUtils.isEmpty(value) ? undefined : this.props.showConfig.sName === 'iOrder' ? value : parseInt(value, 0) : // this.firstDataIndex === 'd' ? commonUtils.isEmpty(value) ? undefined : this.floatNumberCheck(value) : // this.firstDataIndex === 't' ? commonUtils.isEmpty(value) ? null : value : // this.firstDataIndex === 'b' ? value.target.checked : value === null ? undefined : value; // if (!this.props.showConfig.bMultipleChoice) { // const { sAssignField } = this.props.showConfig; // let res = ''; // if (dropDownDataNew.length > 0) { // if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) { // res = this.props.showConfig.sVisColumnName; // } else { // res = Object.keys(dropDownDataNew[0]).length > 0 ? dropDownDataNew[0][Object.keys(dropDownDataNew[0])[0]] : ''; // } // } // const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(res) ? item[res] : item.sId) === value.toString()); // // if (!commonUtils.isEmpty(sAssignField)) { // /* 赋值数组 */ // const sAssignFieldObj = sAssignField.split(','); // if (commonUtils.isNotEmptyObject(changeData)) { // for (const child of sAssignFieldObj) { // if (child.indexOf(':') > -1) { // const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim(); // const sValueName = child.split(':')[1].trim(); // returnValue[sFieldName] = changeData[sValueName] || changeData.value; // } // } // } else if (!this.props.showConfig.bCanInput) { // // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了 // for (const child of sAssignFieldObj) { // if (child.indexOf(':') > -1) { // const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim(); // returnValue[sFieldName] = ''; // } // } // } // } // } else { // const { sAssignField } = this.props.showConfig; // const changeData = dropDownDataNew.filter(item => (`,${value.toString()},`).includes((!commonUtils.isEmpty(item.sSlaveId) ? `,${item.sSlaveId},` : `,${item.sId},`))); // if (!commonUtils.isEmpty(sAssignField)) { // /* 赋值数组 */ // const sAssignFieldObj = sAssignField.split(','); // if (commonUtils.isNotEmptyArr(changeData)) { // for (const child of sAssignFieldObj) { // if (child.indexOf(':') > -1) { // const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim(); // const sValueName = child.split(':')[1].trim(); // const valueArr = []; // changeData.forEach((itemData) => { // valueArr.push(itemData[sValueName]); // }); // returnValue[sFieldName] = valueArr.toString(); // } // } // } else if (!this.props.showConfig.bCanInput) { // // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了 // for (const child of sAssignFieldObj) { // if (child.indexOf(':') > -1) { // const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim(); // returnValue[sFieldName] = ''; // } // } // } // } // } // if (this.state.searchPageNum !== 0 || this.state.searchTotalPageCount !== 1 || this.state.searchDropDownData !== [] || this.state.searchValue !== '' || this.state.spinState !== false) { // this.setState({ // searchPageNum: 0, searchTotalPageCount: 1, searchDropDownData: [], searchValue: '', spinState: false, // }); // } // // /* 调用父组件的回带函数 */ // console.log('returnValue', returnValue); // this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew); // }; /** 搜索时过滤对应的 option 属性 */ filterOption = (input, option) => { const { pageNum, totalPageCount } = this.state; const newInput = input.toString().trim(); /* 下拉框默认为空 不需要替换'--’ */ if (pageNum <= totalPageCount && this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) { return true; } else if (commonUtils.isNotEmptyObject(option.props.children)) { try { return !this.isDropdownFilter && this.props.showConfig.bCanInput ? true : option.props.children.toLowerCase().indexOf(newInput.toLowerCase()) >= 0; } catch (error) { return false; } } }; /** * 小数校验 */ floatNumberCheck = num => { const dNetPrice = this.props.app?.decimals?.dNetPrice; const Maximum = commonFunc.showLocalMessage(this.props, "Maximum", "最多输入${digit}位小数"); const { showConfig } = this.props; const { sName, showName } = showConfig; const digit = sName.includes("Price") && dNetPrice ? dNetPrice : 6; const Maximun = Maximum.replace("${digit}", digit); if (typeof num === "string") { num = num.replace("*", ""); } const checkRule = new RegExp(`^(-?\\d+)(\\.?)(\\d{1,${digit}})?$`); if (!checkRule.test(num) && num && num !== "-" && num !== ".") { message.warning(`【${showName}】【${sName}】${Maximun}`); return undefined; } else { return num; } }; /** 小数位控制 noinspection JSAnnotator控制 string | number */ limitDecimals = values => { let reg = ""; if (this.floatNum > 0) { reg = `^(\\d+).(${this.floatPrice})*$`; } else { reg = "^(\\d+).(\\d\\d\\d\\d\\d\\d)*$"; } if (typeof values === "string") { if (values !== undefined && values.indexOf(".") <= -1) { reg = "^(\\d+)*$"; return !isNaN(Number(values)) ? values.replace(new RegExp(reg), "$1") : ""; } else { return !isNaN(Number(values)) ? values.replace(new RegExp(reg), "$1.$2") : ""; } } else if (typeof values === "number") { if (values !== undefined && String(values).indexOf(".") <= -1) { reg = "^(\\d+)*$"; return !isNaN(values) ? String(values).replace(new RegExp(reg), "$1") : ""; } else { return !isNaN(values) ? String(values).replace(new RegExp(reg), "$1.$2") : ""; } } else { return ""; } }; handleViewClick = () => { const { record, app, showConfig } = this.props; const { sControlName, sActiveKey } = showConfig; /* 弹出标志,弹出界面对应数据主字段 */ if (commonUtils.isNotEmptyObject(sControlName) && commonUtils.isNotEmptyObject(sActiveKey)) { const printPdf = sControlName; if (commonUtils.isNotEmptyObject(printPdf) && printPdf === "printPdf" && commonUtils.isNotEmptyObject(sActiveKey)) { const { token } = app; const sActiveId = this.props.showConfig.sActiveId === "1" ? commonUtils.isEmpty(record.sFormId) ? record.sSrcFormId : record.sFormId : this.props.showConfig.sActiveId; const printsId = record[sActiveKey]; const urlPrint = `${ commonConfig.file_host }printReport/printPdfByFromDataId/${printsId}.pdf?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`; // const urlPrint = `${commonConfig.file_host}printReport/printPdfByFromDataId?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`; window.open(urlPrint); } else if (showConfig.sDropDownType && showConfig.sDropDownType.toLowerCase().includes("picarrmodal")) { /* 蓝色链接跳转用Modal呈现 */ // this.props.onTabModalClick(name, sName, record, index, showConfig, configName); this.props.onTabModalClick(this.props.name, this.props.showConfig.sName, record, undefined, showConfig, this.props.sName); } else { this.props.onViewClick(this.props.name, this.props.showConfig.sName, this.props.record); } } else if (showConfig.sDropDownType && showConfig.sDropDownType.toLowerCase().includes("picarrmodal")) { /* 蓝色链接跳转用Modal呈现 */ // this.props.onTabModalClick(name, sName, record, index, showConfig, configName); this.props.onTabModalClick(this.props.name, this.props.showConfig.sName, record, undefined, showConfig, this.props.sName); } else { this.props.onViewClick(this.props.name, this.props.showConfig.sName, this.props.record); } }; /* 打开新窗口查看SQL编辑器 */ handleOpenWin = () => { const { dataValue, showConfig, record } = this.props; // eslint-disable-next-line prefer-destructuring const sBtnName = showConfig.sName; const sBtnContent = commonUtils.isNotEmptyObject(dataValue) ? encodeURIComponent(dataValue) : ""; const sBtnControlName = commonUtils.isNotEmptyObject(showConfig.sName) ? showConfig.sName : ""; if (commonUtils.isNotEmptyObject(sBtnContent) && commonUtils.isNotEmptyObject(record)) { const sFormId = commonUtils.isNotEmptyObject(record.sParentId) ? record.sParentId : ""; const urlPrint = `${commonConfig.server_host}template/getSql/${sBtnName}/?sBtnContent=${sBtnContent}&sBtnControlName=${sBtnControlName}&sFormId=${sFormId}`; const w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; const h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; // const newWin = window.open('','_blank'); const features = `width=${w + 350},height=${ h + 300 }, top=0, left=0, toolbar=no, menubar=no,scrollbars=no,resizable=no, location =no, status=no`; const newWin = window.open("", "SQL查看器", features); newWin.document.write( `` ); // window.open(urlPrint); } else { message.error("未找到对应过程名"); } }; /* 右箭头点击 */ handleRightArrow = () => { if (this.props.onRightArrow) { const { name, record, showConfig } = this.props; this.props.onRightArrow(name, showConfig.sName, record, undefined, showConfig); } }; // 编辑指令集 handleEditInstruct = () => { this.setState({ instructSetSettingProps: { ...this.props, ...this.state, instructSetSettingVisible: true, instructSetSettingId: commonUtils.createSid(), onSaveData: (value) => { this.handleSelectOptionEvent(value); this.setState({ instructSetSettingProps: {} }); }, onCancelInstructSetSettingModal: () => this.setState({ instructSetSettingProps: {} }), } }); } handlePreviewImage = (e, dataUrl) => { e.stopPropagation(); this.props.onPreviewImage(e, dataUrl); }; handleViewChoose = () => { if (this.props?.showConfig?.sName.includes('Color')) { this.props.onViewChoose(this.props.name, this.props.showConfig.sName, this.props.record, null, true); return } const bGycs = this.props.showConfig?.showName?.includes("工艺参数"); if (this.state.enabled || bGycs) this.props.onViewChoose(this.props.name, this.props.showConfig.sName, this.props.record); }; handleMemoShow = () => { this.props.onMemoShow(this.props.name, this.props.showConfig.sName, this.props.record, 0, this.props.showConfig); }; handlePreviewOffice = dataUrl => { this.props.onPreviewOffice(dataUrl); }; handlePopupScroll = e => { e.persist(); const { target } = e; if ( Math.ceil(target.scrollTop + target.offsetHeight) >= target.scrollHeight && this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData) ) { const { pageNum, searchPageNum, searchTotalPageCount, searchValue, totalPageCount } = this.state; const nextPageNum = pageNum + 1; const nextSearchPageNum = searchPageNum + 1; if (searchValue !== "") { this.getDropDownData(nextSearchPageNum, searchTotalPageCount, searchValue); } else { this.getDropDownData(nextPageNum, totalPageCount, searchValue); } } }; handleSearch = value => { if (this.dropDownTimer) { clearTimeout(this.dropDownTimer); } this.dropDownTimer = setTimeout(() => { if (this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) { this.setState({ spinState: true }); this.getDropDownData(1, 1, value); } }, 500); }; /** 渲染 */ render() { /* 获取innerinput控件参数 */ const innerInputProps = this.getInnerInputProps(); const { slaveConfig = { gdsconfigformslave: [] }, bSColorSerialMemo } = this.props; const { gdsconfigformslave } = slaveConfig; const { sName } = this.props.showConfig; const btPopIndex = gdsconfigformslave.findIndex(item => item.sControlName === `BtnPopup.${sName}`); const btCostomIndex = gdsconfigformslave.findIndex(item => item.sControlName === `BtnCustom.${sName}`); /* 获取innerinput控件 */ const innerInput = btPopIndex > -1 && btCostomIndex > -1 ? ( {this.getInnerInput(innerInputProps)} {this.getInnerButton()} {this.getInnerButtonCostom(gdsconfigformslave[btCostomIndex])}
) : btPopIndex !== -1 ? ( {this.getInnerInput(innerInputProps)} {this.getInnerButton()}
) : btCostomIndex !== -1 ? ( {this.getInnerInput(innerInputProps)} {this.getInnerButtonCostom(gdsconfigformslave[btCostomIndex])}
) : ( this.getInnerInput(innerInputProps) ); let viewInfo = ""; if ( this.props.showConfig.sDropDownType !== "popup" && !commonUtils.isEmpty(this.props.showConfig.sActiveId) && !commonUtils.isEmpty(this.props.showConfig.sActiveKey) && (commonUtils.isNotEmptyObject(this.props.dataValue) || commonUtils.isNotEmptyNumber(this.props.dataValue)) && !location.pathname.includes("mobile") ) { viewInfo = (
{this.props.dataValue}
); } const sModelsType = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : ""; const pleaseSelect = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, "pleaseSelect") : "请选择"; const combinedInfo = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, "CombinedInfo") : "合版信息"; let bParamColor = false; if (this.props && sName === "sParamValue" && this.props.dataValue) { if (this.props.dataValue === "选择色序" || this.props.record.sParamKey === "sParam1001") { bParamColor = true; } } if ( sName === "sCombinedMemo" || sName === "sColorSerialMemo" || bSColorSerialMemo || bParamColor || sName === "sPositiveColor" || sName === "sOppositeColor" || sName === "sCombineProductNameNew" || sName === "sParams" || sName === "sParamsNew" || sName === "sQuoParams" || (commonUtils.isNotEmptyObject(sModelsType) && !sModelsType.includes("Set") && sName === "sCombinePartsNameNew") ) { let sValue = ""; /* 将合版信息json解析成需要的字符串形式 */ if (sName === "sCombinedMemo") { let JsonData = []; if (commonUtils.isNotEmptyObject(this.props.dataValue)) { try { JsonData = JSON.parse(this.props.dataValue); } catch (e) { JsonData = []; } } if (commonUtils.isNotEmptyArr(JsonData)) { JsonData.forEach(item => { sValue += `${item.sProductNo}:排${item.dCombineQty}个,`; }); sValue = commonUtils.isNotEmptyObject(sValue) ? sValue.substr(0, sValue.length - 1) : ""; } } else if (sName === "sColorSerialMemo" || bSColorSerialMemo || sName === "sPositiveColor" || sName === "sOppositeColor" || bParamColor) { let JsonData = []; if (commonUtils.isNotEmptyObject(this.props.dataValue)) { try { JsonData = JSON.parse(this.props.dataValue); } catch (e) { JsonData = []; } } if (typeof JsonData === "object" && commonUtils.isNotEmptyArr(JsonData)) { JsonData.forEach(item => { sValue += `${item.sName}+`; }); sValue = commonUtils.isNotEmptyObject(sValue) ? sValue.substr(0, sValue.length - 1) : ""; } } else if (sName === "sParams" || sName === "sQuoParams" || sName === "sParamsNew") { if (this.props.onGetParamsValue) { // 页面自行处理sparams的sValue sValue = this.props.onGetParamsValue({ sName, sValue: this.props.dataValue, record: this.props.record }); } else { let JsonData = []; if (commonUtils.isNotEmptyObject(this.props.dataValue)) { try { JsonData = JSON.parse(this.props.dataValue); } catch (e) { JsonData = []; } } if (commonUtils.isNotEmptyArr(JsonData)) { JsonData.forEach(item => { if (item.bSelfCbx) { const strValue = commonUtils.isNotEmptyObject(item.sParamValue) ? item.sParamValue : ""; sValue += `${item.sParamName}:${strValue},`; } }); sValue = commonUtils.isNotEmptyObject(sValue) ? sValue.substr(0, sValue.length - 1) : ""; } } } else { sValue = this.props.dataValue; } viewInfo = (
{" "} {commonUtils.isNotEmptyObject(sValue) ? sValue : sName === "sCombinedMemo" ? combinedInfo : pleaseSelect}
); } /* commonClassify 制单日期、制单人员新增时设置保存时自动生成 */ let speacilNote = ""; const { record } = this.props; const afterSave = commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? commonFunc.showMessage(this.props.app.commonConst, "afterSave") : "保存后自动生成"; if ( commonUtils.isNotEmptyObject(record) && commonUtils.isEmptyObject(record[sName]) && commonUtils.isNotEmptyObject(sName) && (sName === "tCreateDate" || sName === "sMakePerson") ) { speacilNote = (
{" "} {afterSave}
); } const bShowMemo = false && commonUtils.isNotEmptyObject(sName) && sName.indexOf("sMemo") > -1 && !sName.includes("ProcessMemo"); /* 非编辑状态下 备注以蓝色链接呈现 */ /* 如果是图片类型 ,加载图片 */ 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 } = this.props.app; const dataUrl = picAddr[0].includes("xlyerpfiles") ? `${commonConfig.file_host}file/download?savePathStr=${picAddr[0]}&scale=0.1&sModelsId=100&token=${token}` : picAddr[0]; /* 缩略图 */ // const dataPriviewUrl = `${commonConfig.server_host}file/download?savePathStr=${picAddr}&width=800&&height=500&sModelsId=100&token=${token}`; /* 预览 */ const officeFileTypeList = ["PDF", "DOCX", "XLSX", "MP4", "WEBM", "OGG"]; const imgTypeList = ["PNG", "SVG", "JPG", "JPEG", "GIF", "BMP", "TIFF", "ICO"]; const officeFileType = picAddr[0].split(".").pop().toUpperCase(); let fileIcon = ; if (officeFileType === "DOCX") { fileIcon = ; } else if (officeFileType === "XLSX") { fileIcon = ; } else if (["MP4", "WEBM", "OGG"].includes(officeFileType)) { fileIcon = ; } let imgBox1 = ""; if (officeFileTypeList.includes(officeFileType)) { imgBox1 = ( { this.handlePreviewOffice(picAddr[0]); }} > {fileIcon} ); } else if (imgTypeList.includes(officeFileType)) { imgBox1 = ( this.handlePreviewImage(e, picAddr)} > img 0} style={{ width: "30px", height: "20px" }} /> ); } else { imgBox1 = ( ); } imgBox = (
{imgBox1}
); } } else if ( this.props.name === "master" && sName !== "sQualityRequirementsMemo" && !this.props.enabled && commonUtils.isNotEmptyObject(sName) && bShowMemo ) { /* 所有备注非编辑状态下点击链接可以弹出备注窗体 */ imgBox = (
{" "}
{this.props.dataValue} 
); // 富文本处理 // if (this.props.showConfig.bEditor) { // imgBox = (<>); // } if (this.props.showConfig.sName && this.props.showConfig.sName.toLowerCase().includes("fullmemo")) { imgBox = <>; } } /* 获取outformitem控件参数 */ const outFormItemProps = this.getOutFormItemProps(); /* 获取fieldDecorator参数 */ const fieldDecoratorProps = this.getFieldDecoratorProps(); /* 通用组件(主表存在getFieldDecorator表单验证,而从表则不需要) */ const commonAssembly = ( {" "} {speacilNote} {imgBox} {!this.props.bTable ? this.getFieldDecorator(this.props.showConfig.sName, fieldDecoratorProps)(innerInput) : innerInput} {viewInfo}{" "} ); const { iColValue, showConfig } = this.props; const readonlyStyle = showConfig.bReadonly || showConfig.iTag === 1 ? "readonlyStyle" : ""; const costomStyle = showConfig.costomStyle || ""; /* 页面输出 */ return (
{commonAssembly}
); } }