Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 0abf750

Browse files
authored
Merge pull request #265 from caofengbin/feature/支持从任意行添加或复制步骤
feat:支持从任意行添加或复制步骤
2 parents 7c33af9 + 8dc65db commit 0abf750

File tree

6 files changed

+117
-16
lines changed

6 files changed

+117
-16
lines changed

src/components/StepDraggable.vue

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,21 @@ const remove = (e) => {
113113
emit('remove', e);
114114
};
115115
116-
const copyStep = (id) => {
117-
emit('copyStep', id);
116+
/**
117+
* 拷贝步骤的方法
118+
* @param {*} id 步骤id
119+
* @param {*} toLast 是否复制到最后一行
120+
*/
121+
const copyStep = (id, toLast) => {
122+
emit('copyStep', id, toLast);
123+
};
124+
/**
125+
* 添加步骤到特定位置的方法
126+
* @param {*} id 点选的位置
127+
* @param {*} toNext true添加到下一行,false添加到上一行
128+
*/
129+
const addStepTotarget = (id, toNext) => {
130+
emit('addStepTotarget', id, toNext);
118131
};
119132
</script>
120133

@@ -241,7 +254,7 @@ const copyStep = (id) => {
241254
<div
242255
style="
243256
float: right;
244-
flex: 0 0 205px;
257+
flex: 0 0 245px;
245258
text-align: right;
246259
margin-right: 12px;
247260
"
@@ -266,16 +279,51 @@ const copyStep = (id) => {
266279
<Edit />
267280
</el-icon>
268281
</el-button>
269-
<el-button
270-
circle
271-
type="primary"
272-
size="mini"
273-
@click="copyStep(s.id)"
282+
283+
<!--添加操作的按钮-->
284+
<el-popconfirm
285+
v-if="s.parentId === 0 && !isEdit"
286+
style="margin-left: 10px"
287+
:confirm-button-text="$t('steps.addToNextLine')"
288+
:cancel-button-text="$t('steps.addToBeforeLine')"
289+
confirm-button-type="text"
290+
icon="el-icon-warning"
291+
icon-color="green"
292+
:title="$t('steps.addStepTips')"
293+
@confirm="addStepTotarget(s.id, true)"
294+
@cancel="addStepTotarget(s.id, false)"
274295
>
275-
<el-icon :size="13" style="vertical-align: middle">
276-
<CopyDocument />
277-
</el-icon>
278-
</el-button>
296+
<template #reference>
297+
<el-button circle type="primary" size="mini">
298+
<el-icon :size="13" style="vertical-align: middle">
299+
<DocumentAdd />
300+
</el-icon>
301+
</el-button>
302+
</template>
303+
</el-popconfirm>
304+
305+
<!--复制操作的按钮-->
306+
<el-popconfirm
307+
v-if="!isEdit"
308+
style="margin-left: 10px"
309+
:confirm-button-text="$t('steps.copyToLastLine')"
310+
:cancel-button-text="$t('steps.copyToNextLine')"
311+
confirm-button-type="text"
312+
icon="el-icon-warning"
313+
icon-color="green"
314+
:title="$t('steps.copyStepTips')"
315+
@confirm="copyStep(s.id, true)"
316+
@cancel="copyStep(s.id, false)"
317+
>
318+
<template #reference>
319+
<el-button circle type="primary" size="mini">
320+
<el-icon :size="13" style="vertical-align: middle">
321+
<CopyDocument />
322+
</el-icon>
323+
</el-button>
324+
</template>
325+
</el-popconfirm>
326+
279327
<el-button class="handle" circle size="mini">
280328
<el-icon :size="13" style="vertical-align: middle">
281329
<Rank />

src/components/StepList.vue

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const props = defineProps({
1919
const emit = defineEmits(['runStep']);
2020
const dialogVisible = ref(false);
2121
const stepId = ref(0);
22+
const addToTargetStepId = ref(0);
23+
const addToTargetStepNext = ref(false);
2224
const parentId = ref(0);
2325
watch(dialogVisible, (newValue, oldValue) => {
2426
if (!newValue) {
@@ -33,12 +35,38 @@ const editStep = async (id) => {
3335
const setParent = (id) => {
3436
parentId.value = id;
3537
};
38+
// 条件语句中的添加步骤方法
3639
const addStep = () => {
3740
dialogVisible.value = true;
3841
};
42+
// 普通类型中的添加步骤方法
43+
const addStepTotarget = (id, toNext) => {
44+
dialogVisible.value = true;
45+
addToTargetStepId.value = id;
46+
addToTargetStepNext.value = toNext
47+
};
3948
const flush = () => {
40-
dialogVisible.value = false;
41-
getStepsList();
49+
if (addToTargetStepId.value > 0) {
50+
// 需要将新增的步骤挪动到目标行的上面或下面
51+
axios
52+
.get('/controller/steps/stepSortTarget', {
53+
params: {
54+
targetStepId: addToTargetStepId.value,
55+
addToTargetNext: addToTargetStepNext.value,
56+
},
57+
})
58+
.then((resp) => {
59+
if (resp.code === 2000) {
60+
dialogVisible.value = false;
61+
addToTargetStepNext.value = false;
62+
addToTargetStepId.value = 0;
63+
getStepsList();
64+
}
65+
});
66+
} else {
67+
dialogVisible.value = false;
68+
getStepsList();
69+
}
4270
};
4371
const deleteStep = (id) => {
4472
axios
@@ -116,11 +144,12 @@ const getStepsList = () => {
116144
const runStep = () => {
117145
emit('runStep');
118146
};
119-
const copyStep = (id) => {
147+
const copyStep = (id, toLast) => {
120148
axios
121149
.get('/controller/steps/copy/steps', {
122150
params: {
123151
id,
152+
toLast
124153
},
125154
})
126155
.then((resp) => {
@@ -212,5 +241,6 @@ onMounted(() => {
212241
@editStep="editStep"
213242
@copyStep="copyStep"
214243
@deleteStep="deleteStep"
244+
@addStepTotarget="addStepTotarget"
215245
/>
216246
</template>

src/locales/lang/en_US.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ const steps = {
109109
loading: 'Loading',
110110
loadDone: 'Load completed',
111111
loadMore: 'Load more',
112+
copyStepTips: 'Are you sure you want to replicate this step? Click on the surrounding space to cancel',
113+
copyToNextLine: 'copy to current line',
114+
copyToLastLine: 'copy to last line',
115+
addStepTips: 'Select the location to add the step and click on the surrounding space to cancel.',
116+
addToNextLine: 'add to next line',
117+
addToBeforeLine: 'add to previous line',
112118
};
113119
const code = {
114120
placeholder: 'Please choose language',

src/locales/lang/ja_JP.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ const steps = {
104104
loading: '加载中',
105105
loadDone: '加载完毕',
106106
loadMore: '加载更多',
107+
copyStepTips: '确定复制该步骤吗?点击周围空白处取消',
108+
copyToNextLine: '复制到当前行',
109+
copyToLastLine: '复制到最后行',
110+
addStepTips: '选择添加步骤的位置,点击周围空白处取消',
111+
addToNextLine: '添加到下一行',
112+
addToBeforeLine: '添加到上一行',
107113
};
108114
const code = {
109115
placeholder: '请选择',

src/locales/lang/zh_CN.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ const steps = {
104104
loading: '加载中',
105105
loadDone: '加载完毕',
106106
loadMore: '加载更多',
107-
107+
copyStepTips: '确定复制该步骤吗?点击周围空白处取消',
108+
copyToNextLine: '复制到当前行',
109+
copyToLastLine: '复制到最后行',
110+
addStepTips: '选择添加步骤的位置,点击周围空白处取消',
111+
addToNextLine: '添加到下一行',
112+
addToBeforeLine: '添加到上一行',
108113
};
109114
const code = {
110115
placeholder: '请选择',

src/locales/lang/zh_TW.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ const steps = {
104104
loading: '加载中',
105105
loadDone: '加载完毕',
106106
loadMore: '加载更多',
107+
copyStepTips: '确定复制该步骤吗?点击周围空白处取消',
108+
copyToNextLine: '复制到当前行',
109+
copyToLastLine: '复制到最后行',
110+
addStepTips: '选择添加步骤的位置,点击周围空白处取消',
111+
addToNextLine: '添加到下一行',
112+
addToBeforeLine: '添加到上一行',
107113
};
108114
const code = {
109115
placeholder: '请选择',

0 commit comments

Comments
 (0)