| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <base-dialog @cancel="cancelDialog">
- <div slot="header">{{$t('cloudenv.text_480')}}</div>
- <div slot="body">
- <a-form
- :form="form.fc">
- <a-form-item :label="$t('cloudenv.text_95')" v-bind="formItemLayout">
- <a-input v-decorator="decorators.name" :placeholder="$t('cloudenv.text_190')" />
- </a-form-item>
- <a-form-item :label="$t('common.description')" v-bind="formItemLayout">
- <a-textarea :auto-size="{ minRows: 1, maxRows: 3 }" v-decorator="decorators.description" :placeholder="$t('common_367')" />
- </a-form-item>
- <a-form-item :label="$t('cloudenv.text_10')" v-bind="formItemLayout">
- <base-select
- resource="cloudregions"
- v-decorator="decorators.region"
- :selectProps="{ 'placeholder': $t('cloudenv.text_231') }"
- :params="{ 'cloud_env': 'private_or_onpremise', 'brand': 'OneCloud' }" />
- </a-form-item>
- <a-form-item :label="$t('cloudenv.text_374')" v-bind="formItemLayout">
- <a-input v-decorator="decorators.location" :placeholder="$t('cloudenv.text_481')" />
- </a-form-item>
- </a-form>
- </div>
- <div slot="footer">
- <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
- <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
- </div>
- </base-dialog>
- </template>
- <script>
- import DialogMixin from '@/mixins/dialog'
- import WindowsMixin from '@/mixins/windows'
- export default {
- name: 'CreateZoneDialog',
- mixins: [DialogMixin, WindowsMixin],
- data () {
- return {
- loading: false,
- form: {
- fc: this.$form.createForm(this),
- },
- decorators: {
- name: [
- 'name',
- {
- validateFirst: true,
- rules: [
- { required: true, message: this.$t('cloudenv.text_190') },
- // { validator: this.$validate('resourceName') },
- ],
- },
- ],
- description: ['description'],
- region: [
- 'region',
- {
- rules: [
- { required: true, message: this.$t('cloudenv.text_231') },
- ],
- },
- ],
- location: [
- 'location',
- {
- rules: [
- { required: true, message: this.$t('cloudenv.text_482') },
- ],
- },
- ],
- },
- formItemLayout: {
- wrapperCol: {
- span: 21,
- },
- labelCol: {
- span: 3,
- },
- },
- }
- },
- methods: {
- validateForm () {
- return new Promise((resolve, reject) => {
- this.form.fc.validateFields((err, values) => {
- if (!err) {
- resolve(values)
- } else {
- reject(err)
- }
- })
- })
- },
- doCreate (data) {
- return this.params.onManager('create', {
- managerArgs: {
- data,
- },
- })
- },
- async handleConfirm () {
- this.loading = true
- try {
- const values = await this.validateForm()
- this.loading = true
- await this.doCreate(values)
- this.loading = false
- this.cancelDialog()
- } catch (error) {
- this.loading = false
- }
- },
- },
- }
- </script>
|