From 7dcc35b8c25c67b0b9e5ae2476d08ff4f34f0e79 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Thu, 28 Nov 2019 22:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=B7=BB=E5=8A=A0=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=88=AC=E8=99=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/store/modules/spider.js | 3 + frontend/src/views/spider/SpiderList.vue | 102 +++++++++++++++-------- 2 files changed, 72 insertions(+), 33 deletions(-) diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js index b7093da4..e653db3d 100644 --- a/frontend/src/store/modules/spider.js +++ b/frontend/src/store/modules/spider.js @@ -155,6 +155,9 @@ const actions = { saveConfigSpiderSpiderfile ({ state, rootState }) { const content = rootState.file.fileContent return request.post(`/config_spiders/${state.spiderForm._id}/spiderfile`, { content }) + }, + addConfigSpider ({ state }) { + return request.put(`/config_spiders`, state.spiderForm) } } diff --git a/frontend/src/views/spider/SpiderList.vue b/frontend/src/views/spider/SpiderList.vue index 11884a7f..41007044 100644 --- a/frontend/src/views/spider/SpiderList.vue +++ b/frontend/src/views/spider/SpiderList.vue @@ -33,18 +33,52 @@ width="40%" :visible.sync="addDialogVisible" :before-close="onAddDialogClose"> -
-
- - {{$t('Configurable Spider')}} - -
-
- - {{$t('Customized Spider')}} - -
-
+ + + + + + {{$t('Upload')}} + + + + + + + + + + + + + + + + + +
+ {{$t('Add')}} +
+
+
+ + + + + + + + + + + + @@ -81,20 +115,7 @@ width="40%" :visible.sync="addCustomizedDialogVisible" :before-close="onAddCustomizedDialogClose"> - - - - {{$t('Upload')}} - - - - + @@ -301,7 +322,8 @@ export default { spiderFormRules: { name: [{ required: true, message: 'Required Field', trigger: 'change' }] }, - fileList: [] + fileList: [], + spiderType: 'customized' } }, computed: { @@ -332,14 +354,24 @@ export default { this.getList() }, onAdd () { - // this.addDialogVisible = true - this.onAddCustomized() + this.$store.commit('spider/SET_SPIDER_FORM', {}) + this.addDialogVisible = true + // this.onAddCustomized() }, onAddConfigurable () { - this.$store.commit('spider/SET_SPIDER_FORM', {}) - this.addDialogVisible = false - this.addConfigurableDialogVisible = true - this.$st.sendEv('爬虫', '添加爬虫-可配置爬虫') + this.$refs['addConfigurableForm'].validate(async res => { + if (!res) return + + let res2 + try { + res2 = await this.$store.dispatch('spider/addConfigSpider') + } catch (e) { + this.$message.error(this.$t('Something wrong happened')) + return + } + this.$router.push(`/spiders/${res2.data.data._id}`) + this.$st.sendEv('爬虫', '添加爬虫-可配置爬虫') + }) }, onAddCustomized () { this.addDialogVisible = false @@ -613,4 +645,8 @@ export default { .el-table >>> tr { cursor: pointer; } + + .actions { + text-align: right; + }