加入复制爬虫

This commit is contained in:
marvzhang
2020-02-24 09:12:03 +08:00
parent 961bcd5c71
commit 7315deefee
7 changed files with 249 additions and 5 deletions

View File

@@ -78,8 +78,6 @@
<span style="margin-left: 5px">跳转到任务详情页</span>
</div>
</el-form-item>
<el-form-item>
</el-form-item>
</el-form>
<template slot="footer">
<el-button type="plain" size="small" @click="$emit('close')">{{$t('Cancel')}}</el-button>

View File

@@ -0,0 +1,85 @@
<template>
<el-dialog
class="copy-spider-dialog"
ref="form"
:title="$t('Copy Spider')"
:visible="visible"
width="580px"
:before-close="onClose"
>
<el-form
label-width="160px"
:model="form"
ref="form"
>
<el-form-item
:label="$t('New Spider Name')"
required
>
<el-input v-model="form.name" :placeholder="$t('New Spider Name')"/>
</el-form-item>
</el-form>
<template slot="footer">
<el-button type="plain" size="small" @click="$emit('close')">{{$t('Cancel')}}</el-button>
<el-button
type="primary"
size="small"
:icon="isLoading ? 'el-icon-loading' : ''"
:disabled="isLoading"
@click="onConfirm"
>
{{$t('Confirm')}}
</el-button>
</template>
</el-dialog>
</template>
<script>
export default {
name: 'CopySpiderDialog',
props: {
spiderId: {
type: String,
default: ''
},
visible: {
type: Boolean,
default: false
}
},
data () {
return {
form: {
name: ''
},
isLoading: false
}
},
methods: {
onClose () {
this.$emit('close')
},
onConfirm () {
this.$refs['form'].validate(async valid => {
if (!valid) return
try {
this.isLoading = true
const res = await this.$request.post(`/spiders/${this.spiderId}/copy`, this.form)
if (!res.data.error) {
this.$message.success('Copied successfully')
}
this.$emit('confirm')
this.$emit('close')
this.$st.sendEv('爬虫复制', '确认提交')
} finally {
this.isLoading = false
}
})
}
}
}
</script>
<style scoped>
</style>