diff --git a/frontend/src/core/permission/permission.js b/frontend/src/core/permission/permission.js index 2c7eac82..63d61934 100644 --- a/frontend/src/core/permission/permission.js +++ b/frontend/src/core/permission/permission.js @@ -30,8 +30,6 @@ function plugin (Vue) { return permissionList.find((val) => { return val.permissionId === permission }).actionList.findIndex((val) => { - console.log(val) - console.log(action) return val === action }) > -1 } diff --git a/frontend/src/views/job/from/JobFrom.vue b/frontend/src/views/job/from/JobFrom.vue index 45de564e..e8b28147 100644 --- a/frontend/src/views/job/from/JobFrom.vue +++ b/frontend/src/views/job/from/JobFrom.vue @@ -265,53 +265,45 @@ - - - + + - - + + 添加分片 - - + - - + + @@ -323,21 +315,31 @@ import { getJobDetail, saveJob, updateJob } from '@/api/jobApi' import pick from 'lodash.pick' import CronModal from '@/views/job/from/CronModal' +import AFormModel from 'ant-design-vue/es/form-model/Form' +import AFormModelItem from 'ant-design-vue/es/form-model/FormItem' + const enums = require('@/utils/jobEnum') export default { name: 'JobFrom', - components: { CronModal }, - props: {}, - comments: { - CronModal + components: { + CronModal, + AFormModel, + AFormModelItem }, + props: {}, data () { return { form: this.$form.createForm(this), formItemLayout: { - labelCol: { lg: { span: 7 }, sm: { span: 7 } }, - wrapperCol: { lg: { span: 10 }, sm: { span: 17 } } + labelCol: { + xs: { span: 24 }, + sm: { span: 4 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 20 } + } }, formItemLayoutWithOutLabel: { wrapperCol: { @@ -358,12 +360,15 @@ export default { count: 0, triggerTypeValue: '2', taskTypeValue: '1', - argsStrValue: [] + argsStrValue: [], + dynamicValidateForm: { + domains: [] + } } }, beforeCreate () { - this.dynamicForm = this.$form.createForm(this, { name: 'dynamic_form_item' }) - this.dynamicForm.getFieldDecorator('keys', { initialValue: [], preserve: true }) + // this.dynamicForm = this.$form.createForm(this, { name: 'dynamic_form_item' }) + // this.dynamicForm.getFieldDecorator('keys', { initialValue: [], preserve: true }) }, mounted () { getAllGroupNameList().then((res) => { @@ -401,59 +406,45 @@ export default { this.$refs.cronModalRef.isShow(triggerInterval) } }, - remove (k) { - const { dynamicForm } = this - // can use data-binding to get - const keys = dynamicForm.getFieldValue('keys') - // We need at least one passenger - if (keys.length === 1) { - return + removeDomain (item) { + const index = this.dynamicValidateForm.domains.indexOf(item) + if (index !== -1) { + this.dynamicValidateForm.domains.splice(index, 1) } - - // can use data-binding to set - dynamicForm.setFieldsValue({ - keys: keys.filter(key => key !== k) - }) }, - add () { - const { dynamicForm } = this - // can use data-binding to get - const keys = dynamicForm.getFieldValue('keys') - console.log(keys) - const nextKeys = keys.concat(this.count++) - // can use data-binding to set - // important! notify form to detect changes - dynamicForm.setFieldsValue({ - keys: nextKeys + this.dynamicValidateForm.domains.push({ + value: '', + key: Date.now() }) }, handleBlur () { const taskType = this.form.getFieldValue('taskType') if (taskType === '3') { this.visible = !this.visible - const { form } = this - if (this.formType === 'create') { - return - } - - form.setFieldsValue({ - argsStr: '' - }) - - console.log(this.argsStrValue) - if (this.argsStrValue.length === 0) { - return - } - - // 将字符串分割成键值对数组 - const keys = this.argsStrValue.map((item, index) => { - this.count++ - this.dynamicForm.getFieldDecorator(`sharding[${index}]`, { initialValue: item, preserve: true }) - return index - }) - - this.dynamicForm.getFieldDecorator('keys', { initialValue: keys, preserve: true }) + // const { form } = this + // if (this.formType === 'create') { + // return + // } + // + // form.setFieldsValue({ + // argsStr: '' + // }) + // + // console.log(this.argsStrValue) + // if (this.argsStrValue.length === 0) { + // return + // } + // + // // 将字符串分割成键值对数组 + // const keys = this.argsStrValue.map((item, index) => { + // this.count++ + // this.dynamicForm.getFieldDecorator(`sharding[${index}]`, { initialValue: item, preserve: true }) + // return index + // }) + // + // console.log(keys) + // this.dynamicForm.getFieldDecorator('keys', { initialValue: keys, preserve: true }) } }, getCron (cron) { @@ -461,14 +452,31 @@ export default { triggerInterval: cron }) }, + submitForm () { + const { form } = this + this.$refs['dynamicValidateForm'].validate(valid => { + if (valid) { + console.log(this.dynamicValidateForm.domains) + this.argsStrValue = this.dynamicValidateForm.domains.map((item, index) => item.value) + form.setFieldsValue({ + argsStr: this.dynamicValidateForm.domains.map((item, index) => `分区:${index}=>${item.value}`).join('; ') + }) + this.visible = !this.visible + } else { + console.log('error submit!!') + return false + } + }) + }, handleOk (e) { const { form } = this e.preventDefault() this.dynamicForm.validateFields((err, values) => { if (!err) { this.argsStrValue = values['sharding'] + console.log(this.argsStrValue) form.setFieldsValue({ - argsStr: this.argsStrValue.map((item, index) => `分区:${index}=>${item}`).join('; ') + argsStr: this.argsStrValue.filter(item => item).map((item, index) => `分区:${index}=>${item}`).join('; ') }) this.visible = false } @@ -522,6 +530,13 @@ export default { if (this.taskTypeValue === '3') { this.argsStrValue = JSON.parse(formData.argsStr) formData.argsStr = this.argsStrValue.map((item, index) => `分区:${index}=>${item}`).join(';') + + this.argsStrValue.forEach((item, index) => { + this.dynamicValidateForm.domains.push({ + value: item, + key: Date.now() + index + }) + }) } form.setFieldsValue(formData) diff --git a/frontend/src/views/task/form/SceneFrom.vue b/frontend/src/views/task/form/SceneFrom.vue index bde6f444..62324546 100644 --- a/frontend/src/views/task/form/SceneFrom.vue +++ b/frontend/src/views/task/form/SceneFrom.vue @@ -16,6 +16,7 @@