Commit 4f245ab1 authored by 邓超's avatar 邓超

fix: 修改规则光标bug

parent c1228a00
Pipeline #64659 passed with stages
...@@ -14,13 +14,22 @@ const RuleConfig = props => { ...@@ -14,13 +14,22 @@ const RuleConfig = props => {
const [expandedKey, setExpandedKey] = useState(''); // 默认展开项 const [expandedKey, setExpandedKey] = useState(''); // 默认展开项
const [currentSelectId, setCurrentSelectId] = useState(''); // 选中得节点 const [currentSelectId, setCurrentSelectId] = useState(''); // 选中得节点
const ruleText = useRef(); const ruleText = useRef();
const chooseIndex = useRef(0);
const [form] = Form.useForm(); const [form] = Form.useForm();
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
console.log(fieldList, 'fieldList'); console.log(fieldList, 'fieldList');
setExpandedKey(fieldList[0].TableName); setExpandedKey(fieldList[0].TableName);
setRule(RuleContent); setRule(RuleContent);
setTimeout(() => {
console.log(document.getElementById('ruleText'));
console.log(ruleText.current);
document
.getElementById('ruleText')
.setSelectionRange(RuleContent.length, RuleContent.length); // 重新定位光标
}, 0);
} else { } else {
chooseIndex.current = 0;
setExpandedKey(''); setExpandedKey('');
setCurrentSelectId(''); setCurrentSelectId('');
setRule(''); setRule('');
...@@ -54,17 +63,12 @@ const RuleConfig = props => { ...@@ -54,17 +63,12 @@ const RuleConfig = props => {
setCurrentSelectId(prop[0]); setCurrentSelectId(prop[0]);
}; };
const insert = text => { const insert = text => {
let ednIndex = document.getElementById('ruleText').selectionEnd;
let rangeIndex = document.getElementById('ruleText').selectionStart; let rangeIndex = document.getElementById('ruleText').selectionStart;
if (rangeIndex > 0) { console.log(ednIndex, rangeIndex, 'endene');
// console.log(document.getElementById('ruleText').hasFocus());
setRule(`${rule.slice(0, rangeIndex)} ${text} ${rule.slice(rangeIndex)}`); setRule(`${rule.slice(0, rangeIndex)} ${text} ${rule.slice(rangeIndex)}`);
rangeIndex += text.toString().length; rangeIndex += text.toString().length;
ruleText.current.focus(); ruleText.current.focus();
document.getElementById('ruleText').setSelectionRange(rangeIndex, rangeIndex); // 重新定位光标
} else {
setRule(`${rule} ${text}`);
ruleText.current.focus();
}
}; };
const insertFn = value => { const insertFn = value => {
insert(value); insert(value);
......
...@@ -41,7 +41,11 @@ const ConfigSubprocess = (props, ref) => { ...@@ -41,7 +41,11 @@ const ConfigSubprocess = (props, ref) => {
console.log(editMsg, 'editMsg'); console.log(editMsg, 'editMsg');
form.setFieldsValue({ flowKey: '', MapFields: [] }); form.setFieldsValue({ flowKey: '', MapFields: [] });
if (editMsg.SubFlowInfo) { if (editMsg.SubFlowInfo) {
GetFlowMapFields({ flowID, subFlowID: editMsg.SubFlowInfo?.SubFlowID }).then(res => { GetFlowMapFields({
flowID,
subFlowID: editMsg.SubFlowInfo?.SubFlowID,
subFlowID: editMsg.SubFlowInfo?.SubFlowEventConfigID,
}).then(res => {
if (res.code === 0) { if (res.code === 0) {
res.data.ParentFlowMapList.forEach(item => { res.data.ParentFlowMapList.forEach(item => {
item.TableFieldNames = item.TableFieldNames.map(ele => ({ item.TableFieldNames = item.TableFieldNames.map(ele => ({
...@@ -104,8 +108,9 @@ const ConfigSubprocess = (props, ref) => { ...@@ -104,8 +108,9 @@ const ConfigSubprocess = (props, ref) => {
console.log(e); console.log(e);
form.setFieldsValue({ MapFields: [] }); form.setFieldsValue({ MapFields: [] });
const subFlowID = e.split('-')[1]; const subFlowID = e.split('-')[1];
const SubFlowEventConfigID = e.split('-')[0];
console.log(subFlowID, 'afsdfsda'); console.log(subFlowID, 'afsdfsda');
GetFlowMapFields({ flowID, subFlowID }).then(res => { GetFlowMapFields({ flowID, subFlowID, SubFlowEventConfigID }).then(res => {
if (res.code === 0) { if (res.code === 0) {
res.data.ParentFlowMapList.forEach(item => { res.data.ParentFlowMapList.forEach(item => {
item.TableFieldNames = item.TableFieldNames.map(ele => ({ item.TableFieldNames = item.TableFieldNames.map(ele => ({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment