UNPKG

fastlion-amis

Version:

一种MIS页面生成工具

802 lines (801 loc) 46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var antd_1 = require("antd"); var lodash_1 = require("lodash"); var react_1 = tslib_1.__importStar(require("react")); var components_1 = require("../../../components"); var DragModal_1 = (0, tslib_1.__importDefault)(require("../../../components/DragModal")); var icons_1 = require("../../../components/icons"); var matchList = [ { label: "整个字段", value: "all" }, { label: "字段的任何部分", value: 'part' }, { label: "字段的开始部分", value: "start" }, { label: "字段的结束部分", value: "end" }, ]; var redirect = [ { label: "全部", value: "all" }, { label: "向上", value: "prev" }, { label: "向下", value: "next" }, ]; var FindAndReplace = function (props) { var action = props.action, data = props.data, columns = props.columns, updateActiveCell = props.updateActiveCell, container = props.container, onBulkReplace = props.onBulkReplace, canReplace = props.canReplace, translate = props.translate; var _a = (0, react_1.useState)(false), visible = _a[0], setVisible = _a[1]; var _b = (0, react_1.useState)(-1), orderIndex = _b[0], setOrderIndex = _b[1]; // 查找顺序 var _c = (0, react_1.useState)(0), tabType = _c[0], setTabType = _c[1]; var _d = (0, react_1.useState)(''), replaceCon = _d[0], setReplaceCon = _d[1]; var _e = (0, react_1.useState)('all'), match = _e[0], setMatch = _e[1]; var _f = (0, react_1.useState)([]), field = _f[0], setField = _f[1]; var _g = (0, react_1.useState)([]), fieldList = _g[0], setFieldList = _g[1]; var _h = (0, react_1.useState)(false), caseValue = _h[0], setCaseValue = _h[1]; var _j = (0, react_1.useState)('present'), rangeValue = _j[0], setRangeValue = _j[1]; var _k = (0, react_1.useState)('all'), redirectValue = _k[0], setRedirectValue = _k[1]; var _l = (0, react_1.useState)(''), findCon = _l[0], setFindCon = _l[1]; // const [insertData, setInsertData] = useState<string[]>([]); // const [insertText, setInsertText] = useState<string>(''); var _m = (0, react_1.useState)([]), modifyData = _m[0], setModifyData = _m[1]; var _o = (0, react_1.useState)(true), isChangeRow = _o[0], setIsChangeRow = _o[1]; (0, react_1.useEffect)(function () { var mapList = []; var _fields = columns.map(function (item) { //assign类型不允许替换,新平台貌似是autofill if (item.type === 'assign') { } else if (item.type === 'mapping' && item['map']) { mapList.push({ title: item.name, mapData: item['map'], delimiter: item.delimiter || ',' }); } return { value: item.name, label: item.label }; }); curPageLookupList.current = mapList; setFieldList((0, tslib_1.__spreadArray)([], _fields, true)); }, [columns]); (0, react_1.useEffect)(function () { document.addEventListener('keydown', onKeydown, false); return function () { document.removeEventListener('keydown', onKeydown, false); }; }, []); var onKeydown = function (e) { if (e.keyCode == 112) { // F1 e.preventDefault(); } // 打开快捷键面板 Ctrl + / if (e.keyCode == 191 && (e.ctrlKey || e.metaKey)) { e.preventDefault(); } if (e.keyCode === 70 && (e.ctrlKey || e.metaKey) && e.shiftKey) { e.preventDefault(); } if (e.keyCode === 70 && (e.ctrlKey || e.metaKey)) { e.preventDefault(); handleAction(); } }; var curPageLookupList = (0, react_1.useRef)([]); var handleChangeFind = function (value) { setFindCon(value); setModifyData([]); setOrderIndex(-1); }; var failCount = 0; // 失败的个数 var repalceCount = 0; // 总共替换的个数计算 // 高级替换 // const seniorReplace = (replaceItem: obj, fieldName: string, originData: obj[], index: number, isAll: boolean = true) => { // let replaceText = replaceCon, findText = findCon; // let isInsert = replaceCon?.indexOf('||') > -1; // // 取插入条件之前的字符 // let replaceConBefore = replaceCon?.split('[')?.length > 1 ? replaceCon?.split('[')[0] : ''; // // 如果条件之前的字符存在 从原数据中暂时移除 // replaceConBefore && (replaceText = replaceCon?.replace(replaceConBefore, '')); // // 增加 or 删除 // if (isInsert) { // let isEdit = allowEdit(replaceItem, fieldName, isAll); // if (isEdit) { // try { // if (!caseValue) { // 不区分大小写 // replaceItem[fieldName] = replaceItem[fieldName] && String(replaceItem[fieldName]).toLocaleLowerCase(); // } // findText = replaceItem[fieldName]; // // 需要 增加 or 删除的字符 // let content = replaceCon?.split("||")[1]?.replace(/\'/g, ''); // if (insertType === 'add') { // replaceText = replaceItem[fieldName] + content; // } else { // replaceText = replaceItem[fieldName].replace(content, ''); // } // return replaceFn(fieldName, originData, index, findText, replaceText) // } catch (err) { // failCount++; // } // } else { // failCount++; // } // } else { // if (!caseValue) { // 不区分大小写 // replaceItem[fieldName] = replaceItem[fieldName] && String(replaceItem[fieldName]).toLocaleLowerCase(); // } // findText = replaceItem[fieldName]; // let isEdit = allowEdit(replaceItem, fieldName, isAll); // if (isEdit) { // try { // // 数字格式 // // const displayFormat = columns.find(col => col.name === fieldName)?.pristine?.precision || 2; // const result = eval(`${replaceConBefore}${replaceItem[fieldName]}${replaceCon.split(']')[1]}`); // //这里需要格式化 // replaceText = result ? String(result) : ''; // return replaceFn(fieldName, originData, index, findText, replaceText); // } catch (e) { // failCount++; // !isAll && Modal.error({ content: '运算规则错误' }) // } // } else { // failCount++; // } // } // return null; // } // 真正执行数据替换的方法 单个 var replaceFn = function (field, originData, index, findText, replaceText) { if (findText === void 0) { findText = ''; } var replaceItem = Object.assign({}, data[index]); if (match === 'all') { replaceItem[field] = replaceText; } else if (match === 'part') { replaceItem[field] = findText ? String(replaceItem[field]).replace(new RegExp(findText, 'g'), replaceText) : replaceText; } else if (match === 'start') { replaceItem[field] = findText ? String(replaceItem[field]).replace(findText, replaceText) : replaceText; } else if (match === 'end') { var subLen = replaceItem[field].length - findText.length + 1; replaceItem[field] = findText ? String(replaceItem[field]).substr(0, subLen) + replaceText : replaceText; } if (String(findText || '') != replaceText) { repalceCount++; } else { failCount++; } return { index: index, rowData: replaceItem, fieldName: field, updateValue: replaceItem[field] }; }; // 是否允许编辑 var allowEdit = function (rowData, field, isReplaceAll) { var _a; var colItem = columns.find(function (item) { return item.name === field; }); //这里判断列是否可编辑 if ((colItem === null || colItem === void 0 ? void 0 : colItem.type) === 'lion-formula') { !isReplaceAll && antd_1.Modal.warn({ content: '当前字段不支持替换' }); return false; } else if (!((_a = colItem === null || colItem === void 0 ? void 0 : colItem.pristine) === null || _a === void 0 ? void 0 : _a.quickEdit)) { !isReplaceAll && antd_1.Modal.warn({ content: '当前字段不可编辑' }); return false; } //单元格是否可编辑 // let cellEdit = true; // if (!cellEdit) { // !isReplaceAll && Modal.warn({ content: '当前字段不可编辑' }); // return false // } //列是否可编辑 // else if (RejectReplaceColumnArr.includes(field)) { // !isReplaceAll && Modal.warn({ content: '当前字段不支持替换' }); // return false // } return true; }; // fieldName caption 互转 var fieldName2Caption = function (get, value, colList) { var _a; return (_a = colList === null || colList === void 0 ? void 0 : colList.find(function (item) { return item[get === 'name' ? 'label' : 'name'] === value; })) === null || _a === void 0 ? void 0 : _a[get]; }; // 高级 修改 Insert 的替换内容 // const handleInsertSetContent = (flag: boolean) => { // let { columns } = props; // let replaceStr = replaceCon; // if (!flag) { // // 如果已经有插入内容 先移除掉之前的插入内容 // replaceStr = replaceStr?.indexOf("||'") > -1 ? replaceStr?.split("||'")[0] : replaceStr; // setReplaceCon(`${replaceStr}||'${insertText}'`) // } else { // // 替换所有中文符号 增强兼容性 // replaceStr = replaceStr.replace(/\(/g, '(').replace(/\)/g, ')'); // // 取插入条件之前的字符 // let replaceConBefore = replaceStr?.split('[')?.length > 1 ? replaceStr?.split('[')[0] : ''; // // 如果条件之前的字符存在 从原数据中暂时移除 // replaceConBefore && (replaceStr = replaceStr.replace(replaceConBefore, '')); // // 移除所有的插入字段 // replaceStr = replaceStr?.replace(/\[.*?\]/g, '') || ''; // // 是否包含运算符 // let hasOperation = /\+|\*|-|\//g.test(replaceStr); // let insertCaptions = `[${insertData?.map(item => fieldName2Caption('label', item, columns))?.toString()}]`; // setReplaceCon(replaceStr ? (hasOperation ? `${replaceConBefore}${insertCaptions}${replaceStr}` : `${replaceConBefore}${insertCaptions}${replaceStr?.indexOf('||') > -1 ? replaceStr : '||' + replaceStr}`) : `${replaceConBefore}${insertCaptions}`); // } // } // 查找字段 var handleFindSelect = function (value) { setField(value); setOrderIndex(-1); }; // 匹配字段 var handleMatchSelect = function (value) { setMatch(value); setOrderIndex(-1); }; // 区分大小写 var handleCaseSensitive = function (value) { setCaseValue(value); setOrderIndex(-1); }; // 查找范围 var handleChangeRange = function (value) { setRangeValue(value); setOrderIndex(-1); }; /** * 查找内容 * */ var findReplaceData = function () { return new Promise(function (resolve, reject) { var data = props.data, selectedList = props.selectedList, currentCheckIndex = props.currentCheckIndex; var findContent = findCon, isChangeRowContent = isChangeRow; // let fieldNames = replaceCon?.match(/\[(.+?)\]/g)?.[0]?.replace(/\[|]/g, '').split(',') as string[]; // let replaceFields = fieldNames?.map(item => fieldName2Caption('name', item, columns)); var originData = (0, lodash_1.cloneDeep)(data); var tableSelectRow = Number(currentCheckIndex); var orderIndex = 0; var modifyArr = []; // 查找到的数据 var isGetOrderIndex = false; // 是否可以获取选中数据索引的指标之一 var setArr = function (index, fieldName) { // if (Array.isArray(replaceFields) && replaceFields.length > 0) { // replaceFields.forEach(item => { // modifyArr.push(Object.assign({}, { index: index, field: item })); // }) // } else { modifyArr.push(Object.assign({}, { index: index, field: fieldName })); // } isGetOrderIndex = true; }; // 查找匹配的数据 if (findContent) { originData.map(function (item, index) { var _a; if (rangeValue === 'some' && !selectedList.includes(index)) { return; } // 如果查找列字段为空 if (field === undefined || (field && !field.length)) { var _loop_1 = function (fieldName) { var str = (0, lodash_1.isNil)(item[fieldName]) ? undefined : String(item[fieldName]); // mapping 取值 var lookupItem = curPageLookupList.current.find(function (lookCol) { return lookCol.title === fieldName; }); if (lookupItem) { var options = str === null || str === void 0 ? void 0 : str.split(lookupItem.delimiter); str = (_a = options === null || options === void 0 ? void 0 : options.map(function (opt) { return lookupItem.mapData[opt]; })) === null || _a === void 0 ? void 0 : _a.join(lookupItem.delimiter); } str = str || ''; isGetOrderIndex = false; if (!caseValue) { str = str.toLocaleLowerCase(); findContent = findContent && findContent.toLocaleLowerCase(); } if (match === 'all') { if (str === findContent) { setArr(index, fieldName); } } else if (match === 'part') { if (str.indexOf(findContent) !== -1) { setArr(index, fieldName); } } else if (match === 'start') { if (str.substr(0, findContent.length) === findContent) { setArr(index, fieldName); } } else if (match === 'end') { if (str.substr(-findContent.length, findContent.length) === findContent) { setArr(index, fieldName); } } if (isGetOrderIndex && isChangeRowContent) { orderIndex++; if (redirectValue !== 'prev') { // 方向不是向上查找的 if (tableSelectRow <= index) { orderIndex--; orderIndex = orderIndex === 0 ? -1 : orderIndex; isChangeRowContent = false; } } else { // 方向是向上查找的 if (tableSelectRow < index) { orderIndex--; isChangeRowContent = false; } } } }; for (var _i = 0, _b = Object.keys(item); _i < _b.length; _i++) { var fieldName = _b[_i]; _loop_1(fieldName); } } // 如果查找列字段不为空 else { field.map(function (fieldName) { var _a; var str = (0, lodash_1.isNil)(item[fieldName]) ? undefined : String(item[fieldName]); // mapping 取值 var lookupItem = curPageLookupList.current.find(function (lookCol) { return lookCol.title === fieldName; }); if (lookupItem) { var options = str === null || str === void 0 ? void 0 : str.split(lookupItem.delimiter); str = (_a = options === null || options === void 0 ? void 0 : options.map(function (opt) { return lookupItem.mapData[opt]; })) === null || _a === void 0 ? void 0 : _a.join(lookupItem.delimiter); } str = str || ''; isGetOrderIndex = false; if (!caseValue) { str = str.toLocaleLowerCase(); findContent = findContent && findContent.toLocaleLowerCase(); } if (match === 'all') { if (str === findContent) { setArr(index, fieldName); } } else if (match === 'part') { if (str.indexOf(findContent) !== -1) { setArr(index, fieldName); } } else if (match === 'start') { if (str.substr(0, findContent.length) === findContent) { setArr(index, fieldName); } } else if (match === 'end') { if (str.substr(-findContent.length, findContent.length) === findContent) { setArr(index, fieldName); } } if (isGetOrderIndex && isChangeRowContent) { orderIndex++; if (redirectValue !== 'prev') { // 方向不是向上查找的 if (tableSelectRow <= index) { orderIndex--; orderIndex = orderIndex === 0 ? -1 : orderIndex; isChangeRowContent = false; } } else { // 方向是向上查找的 if (tableSelectRow < index) { orderIndex--; isChangeRowContent = false; } } } }); } return Object.assign({}, item); }); } else { // 如果查找内容为空 originData.map(function (item, index) { if (rangeValue === 'some' && !selectedList.includes(index)) { return; } if (field === undefined || (field && !field.length)) { var _loop_2 = function (fieldName) { var str = item[fieldName]; isGetOrderIndex = false; if (((0, lodash_1.isNil)(str) || str === '') && columns.some(function (column) { return column.name === fieldName; })) { setArr(index, fieldName); } if (isGetOrderIndex && isChangeRowContent) { orderIndex++; if (redirectValue !== 'prev') { // 方向不是向上查找的 if (tableSelectRow <= index) { orderIndex--; orderIndex = orderIndex === 0 ? -1 : orderIndex; isChangeRowContent = false; } } else { // 方向是向上查找的 if (tableSelectRow < index) { orderIndex--; isChangeRowContent = false; } } } }; for (var _i = 0, _a = Object.keys(item); _i < _a.length; _i++) { var fieldName = _a[_i]; _loop_2(fieldName); } } else { field.map(function (fieldName) { var str = item[fieldName]; isGetOrderIndex = false; if ((0, lodash_1.isNil)(str) || str === '') { setArr(index, fieldName); } if (isGetOrderIndex && isChangeRowContent) { orderIndex++; if (redirectValue !== 'prev') { // 方向不是向上查找的 if (tableSelectRow <= index) { orderIndex--; orderIndex = orderIndex === 0 ? -1 : orderIndex; isChangeRowContent = false; } } else { // 方向是向上查找的 if (tableSelectRow < index) { orderIndex--; isChangeRowContent = false; } } } }); } }); } if (orderIndex > 0) { setOrderIndex(orderIndex); } if (isChangeRowContent) { setIsChangeRow(false); } setModifyData(modifyArr); resolve({ modifyData: modifyArr }); }); }; /** * 查找下一个/上一个 * @param isReplace 是否是替换 - 调用的该事件 */ var handleFindNext = function (isReplace, fieldLength, autoFind) { if (isReplace === void 0) { isReplace = false; } if (fieldLength === void 0) { fieldLength = 1; } if (autoFind === void 0) { autoFind = false; } return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { var modifyData, newOrderIndex, index, fieldName, timer, i; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, findReplaceData()]; case 1: modifyData = (_a.sent()).modifyData; newOrderIndex = orderIndex // 上一个匹配值的下标 ; // 判断是否查找到内容 if (!modifyData.length && !isReplace) { !autoFind && antd_1.message.info({ content: '未查找到相关内容' }); return [2 /*return*/, false]; } if (!modifyData.length) { return [2 /*return*/, false]; } ; switch (redirectValue) { case "all": // 全部 if (newOrderIndex < modifyData.length - 1) { newOrderIndex = newOrderIndex + fieldLength; } else { newOrderIndex = 0; } break; case "next": // 向下 if (newOrderIndex < modifyData.length - 1) { newOrderIndex = newOrderIndex + fieldLength; } else { !isReplace && antd_1.message.info({ content: "已完成搜索" }); return [2 /*return*/, false]; } break; case "prev": // 向上 if (newOrderIndex > 0) { newOrderIndex = newOrderIndex - fieldLength; } else { !isReplace && antd_1.message.info({ content: "已完成搜索" }); return [2 /*return*/, false]; } break; default: break; } if (modifyData.length === 1 && orderIndex === newOrderIndex) return [2 /*return*/]; setOrderIndex(newOrderIndex); newOrderIndex = newOrderIndex > -1 ? newOrderIndex : 0; index = modifyData[newOrderIndex].index; fieldName = modifyData[newOrderIndex].field; updateActiveCell(index, fieldName); for (i = 0; i < 20; i++) { timer = setTimeout(function () { var ketSelect = container === null || container === void 0 ? void 0 : container.querySelector(".active-cell"); if (ketSelect) { ketSelect.scrollIntoViewIfNeeded(); timer = null; return; } }, 300); } return [2 /*return*/]; } }); }); }; // 单个替换事件 var replaceHandle = function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { var originData, _a, field, index, replaceItem, allModify, replaceFields, result, isEdit, isEdit; var _b; return (0, tslib_1.__generator)(this, function (_c) { originData = (0, lodash_1.cloneDeep)(data); if (((_b = replaceCon === null || replaceCon === void 0 ? void 0 : replaceCon.split('||')) === null || _b === void 0 ? void 0 : _b.length) > 2) { antd_1.Modal.error({ content: '替换内容不合法' }); return [2 /*return*/]; } if (!modifyData[orderIndex]) { handleFindNext(); return [2 /*return*/, false]; } _a = modifyData[orderIndex], field = _a.field, index = _a.index; replaceItem = originData[index]; allModify = [], replaceFields = []; if (replaceCon === null || replaceCon === void 0 ? void 0 : replaceCon.match(/\[(.+?)\]/g)) { // 当前单元格可以编辑才替换 result = calcFormula(replaceItem); isEdit = allowEdit(replaceItem, field, false); if (isEdit) { try { if (!caseValue) { // 不区分大小写 replaceItem[field] = replaceItem[field] && String(replaceItem[field]).toLocaleLowerCase(); } allModify.push(replaceFn(field, originData, index, findCon, eval(result))); } catch (error) { antd_1.Modal.error({ content: '替换内容不合法' }); } } // replaceFields = fieldNames?.map(item => fieldName2Caption('name', item, columns)); // 高级的单个替换 也可能需要替换多个单元格 // replaceFields?.forEach(item => { // const currentModify = seniorReplace(replaceItem, item, originData, index); // let hasCurrentModify = allModify?.find(item => item?.index === currentModify?.index); // if (hasCurrentModify && currentModify) { // const { fieldName, rowData, index } = currentModify; // allModify.forEach(item => { // if (item.index === index) { // item.rowData[fieldName] = rowData[fieldName] // } // }) // } else if (currentModify) { // allModify = [...allModify, currentModify] // } // }) } else { isEdit = allowEdit(replaceItem, field, false); if (isEdit) { if (!caseValue) { // 不区分大小写 replaceItem[field] = replaceItem[field] && String(replaceItem[field]).toLocaleLowerCase(); } allModify.push(replaceFn(field, originData, index, findCon, replaceCon)); } } //这里进行替换的操作 onBulkReplace(allModify); handleFindNext(false, replaceFields.length, true); return [2 /*return*/]; }); }); }; //计算公式 var calcFormula = function (replaceItem) { var fieldNames = (replaceCon === null || replaceCon === void 0 ? void 0 : replaceCon.match(/\[(.+?)\]/g)) || []; var list = fieldNames.map(function (str) { var _a, _b; var coName = (_b = (_a = columns.find(function (fcol) { return fcol.label === str.replace('[', '').replace(']', ''); })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''; var value = replaceItem === null || replaceItem === void 0 ? void 0 : replaceItem[coName]; return (0, lodash_1.isNil)(value) ? 0 : value; }); var result = replaceCon.replace(/\[(.*?)\]/g, function (match) { var _a, _b; var index = (_b = (_a = replaceCon.match(/\[([^\]]*)\]/g)) === null || _a === void 0 ? void 0 : _a.indexOf(match)) !== null && _b !== void 0 ? _b : -1; if (index !== -1) { return list[index]; } return 0; }); return result; }; // 替换全部的事件 var replaceAllOk = function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { var data, modifyData, allModify; var _a; return (0, tslib_1.__generator)(this, function (_b) { switch (_b.label) { case 0: data = props.data; if (((_a = replaceCon === null || replaceCon === void 0 ? void 0 : replaceCon.split('||')) === null || _a === void 0 ? void 0 : _a.length) > 2) { antd_1.Modal.error({ content: '替换内容不合法' }); return [2 /*return*/]; } return [4 /*yield*/, findReplaceData()]; case 1: modifyData = (_b.sent()).modifyData; repalceCount = 0; failCount = 0; allModify = []; try { modifyData.map(function (item) { var _a; var index = item.index, field = item.field; var replaceItem = Object.assign({}, data[index]); // 高级 if (replaceCon === null || replaceCon === void 0 ? void 0 : replaceCon.match(/\[(.+?)\]/g)) { // 当前单元格可以编辑才替换 var result = calcFormula(replaceItem); var isEdit = allowEdit(replaceItem, field, true); if (isEdit) { try { if (!caseValue) { // 不区分大小写 replaceItem[field] = replaceItem[field] && String(replaceItem[field]).toLocaleLowerCase(); } allModify.push(replaceFn(field, data, index, findCon, eval(result))); } catch (error) { failCount++; antd_1.Modal.error({ content: '替换内容不合法' }); } } else { failCount++; } // const currentModify = seniorReplace(replaceItem, field, originData, index); // let hasCurrentModify = allModify?.find(item => item?.index === currentModify?.index); // if (hasCurrentModify && currentModify) { // const { fieldName, rowData, index } = currentModify; // allModify?.forEach(item => { // if (item.index === index) { // item.rowData[fieldName] = rowData[fieldName] // } // }) // } else { // allModify = [...allModify, currentModify!] // } } else { // 常规 var isEdit = allowEdit(replaceItem, field, true); if (isEdit) { if (!caseValue) { // 不区分大小写 replaceItem[field] = replaceItem[field] && String(replaceItem[field]).toLocaleLowerCase(); } var newModify = replaceFn(field, data, index, findCon, replaceCon); var flag = false; for (var i = allModify.length - 1; i >= 0; i--) { if (allModify[i].index === newModify.index) { flag = true; allModify[i].rowData = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, allModify[i].rowData), (_a = {}, _a[field] = newModify.updateValue, _a)); } } !flag && allModify.push(newModify); } else { failCount++; } } }); onBulkReplace(allModify); } catch (err) { console.error(err); } antd_1.Modal.info({ content: '操作成功' }); return [2 /*return*/]; } }); }); }; // 替换全部 var replaceAllHandle = function () { antd_1.Modal.confirm({ content: "\u662F\u5426\u5168\u90E8\u8FDB\u884C\u66FF\u6362", onOk: replaceAllOk, okText: translate('confirm'), cancelText: translate('cancel') }); }; var handleMenuClick = function (_a) { var _b, _c; var key = _a.key; var label = (_c = (_b = columns.find(function (item) { return item.name === key; })) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : ''; var newValue = replaceCon + ("[" + label + "]"); setReplaceCon(newValue); }; var handleAction = function () { setVisible(true); }; var handleCloseModal = function () { updateActiveCell(); setTabType(0); setFindCon(''); setReplaceCon(''); setField([]); setFieldList([]); setMatch('all'); setCaseValue(false); setRangeValue('present'); setRedirectValue('all'); setModifyData([]); setIsChangeRow(true); setVisible(false); }; var renderButton = function () { var _a; return react_1.default.createElement(components_1.Button, { onClick: handleAction }, react_1.default.createElement(icons_1.Icon, { icon: (_a = action === null || action === void 0 ? void 0 : action.icon) !== null && _a !== void 0 ? _a : "#icon-tooltool_autowidth", className: "icon", symbol: true }), action === null || action === void 0 ? void 0 : action.label); }; return react_1.default.createElement(react_1.default.Fragment, null, renderButton(), visible && react_1.default.createElement(DragModal_1.default, { dialogVisible: visible, drag: true, canClickBelowDom: true, className: "findReplace", wrapClassName: "findReplaceDialog", width: 466, mask: false, onCancel: handleCloseModal, title: (react_1.default.createElement("div", { className: "find-and-replace-tabs" }, react_1.default.createElement("div", { className: ["find-and-replace-tab", tabType == 0 ? "active" : null].join(" "), onClick: function () { return setTabType(0); } }, "\u67E5\u627E"), canReplace && react_1.default.createElement("div", { className: ["find-and-replace-tab", tabType == 1 ? "active" : null].join(" "), onClick: function () { return setTabType(1); } }, "\u66FF\u6362"))), footer: false, centered: true, getContainer: function () { return container || document.body; } }, react_1.default.createElement("div", { className: "find-and-replace-pc-wrapper" }, react_1.default.createElement("div", { className: "wrapper-inner" }, react_1.default.createElement("div", { className: "options-con" }, react_1.default.createElement("div", { className: "option-item" }, react_1.default.createElement("div", { className: "name" }, "\u67E5\u627E\u5185\u5BB9"), react_1.default.createElement(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", value: findCon, onChange: function (e) { return handleChangeFind(e.target.value); }, maxLength: 1000 })), !!tabType && react_1.default.createElement("div", { className: "option-item" }, react_1.default.createElement("div", { className: "name" }, "\u66FF\u6362\u5185\u5BB9"), react_1.default.createElement(antd_1.Dropdown, { menu: { items: columns.map(function (item) { return ({ key: item.name, label: item.label, item: item }); }), onClick: handleMenuClick }, trigger: ['contextMenu'], overlayStyle: { overflow: 'hidden', maxHeight: 300, boxShadow: 'rgba(0, 0, 0, 0.08) 0px 6px 16px 0px, rgba(0, 0, 0, 0.12) 0px 3px 6px -4px, rgba(0, 0, 0, 0.05) 0px 9px 28px 8px', } }, react_1.default.createElement(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9", value: replaceCon, onChange: function (e) { return setReplaceCon(e.target.value); } }))), react_1.default.createElement("div", { className: "option-item findField" }, react_1.default.createElement("div", { className: "name" }, "\u67E5\u627E\u5B57\u6BB5"), react_1.default.createElement(antd_1.Select, { placeholder: "\u8BF7\u9009\u62E9\u5B57\u6BB5,\u672A\u9009\u62E9\u5373\u4E3A\u67E5\u627E\u6240\u6709\u5B57\u6BB5", value: field, mode: "multiple", options: fieldList, onChange: function (e) { return handleFindSelect(e); } })), react_1.default.createElement("div", { className: "option-item" }, react_1.default.createElement("div", { className: "match-con" }, react_1.default.createElement("div", { className: "name" }, "\u5339\u914D"), react_1.default.createElement(antd_1.Select, { placeholder: "\u8BF7\u9009\u62E9\u5185\u5BB9", value: match, options: matchList, onChange: function (e) { return handleMatchSelect(e); } })), react_1.default.createElement("div", { className: "case-sensitive" }, react_1.default.createElement(antd_1.Checkbox, { checked: caseValue, onChange: function (e) { return handleCaseSensitive(e.target.checked); } }, "\u533A\u5206\u5927\u5C0F\u5199"))), react_1.default.createElement("div", { className: "option-item range-item" }, react_1.default.createElement("div", { className: "name" }, "\u67E5\u627E\u8303\u56F4"), react_1.default.createElement(antd_1.Radio.Group, { onChange: function (e) { return handleChangeRange(e.target.value); }, value: rangeValue }, react_1.default.createElement(antd_1.Radio, { key: 'present', value: 'present' }, "\u5F53\u524D\u9875\u6570\u636E"), ",", react_1.default.createElement(antd_1.Radio, { key: 'some', value: 'some' }, "\u9009\u4E2D\u6570\u636E"), ",")), react_1.default.createElement("div", { className: "option-item range-item" }, react_1.default.createElement("div", { className: "name" }, "\u67E5\u627E\u65B9\u5411"), react_1.default.createElement(antd_1.Radio.Group, { onChange: function (e) { return setRedirectValue(e.target.value); }, value: redirectValue }, redirect.map(function (item, index) { return react_1.default.createElement(antd_1.Radio, { key: index, className: "radio", value: item.value }, item.label); })))), react_1.default.createElement("div", { className: "btn-con" }, react_1.default.createElement(antd_1.Button, { className: "btn", type: "primary", onClick: function () { return handleFindNext(); } }, "\u67E5\u627E\u4E0B\u4E00\u4E2A"), tabType ? (react_1.default.createElement(react_1.default.Fragment, null, react_1.default.createElement(antd_1.Button, { className: "btn replace-btn", type: "default", disabled: replaceCon ? false : true, onClick: replaceHandle }, "\u66FF\u6362"), react_1.default.createElement(antd_1.Button, { className: "btn replace-btn", type: "default", disabled: replaceCon ? false : true, onClick: replaceAllHandle }, "\u66FF\u6362\u5168\u90E8"))) : null, react_1.default.createElement(antd_1.Button, { className: "btn", type: "default", onClick: handleCloseModal }, "\u53D6\u6D88")))))); }; exports.default = FindAndReplace; //# sourceMappingURL=./renderers/Table/FindAndReplace/index.js.map