Files
crawlab/frontend/src/components/Spider/CopySpiderDialog.vue
yaziming c671d113c9 * 增加Docker开发环境
* 更新Dockerfile构建文件,升级NodeJS依赖版本。
 * 遵循ESLint重新格式化代码,修复部分警告
 * 登录Token失效增加登出提示
 * 网络请求问题增加错误错误提示
 * 升级UI依赖库
2020-06-19 16:57:00 +08:00

86 lines
1.8 KiB
Vue

<template>
<el-dialog
ref="form"
class="copy-spider-dialog"
:title="$t('Copy Spider')"
:visible="visible"
width="580px"
:before-close="onClose"
>
<el-form
ref="form"
label-width="160px"
:model="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>