udp.vue 7.6 KB
Newer Older
K
khadgarmage 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
L
ligang 已提交
17 18 19 20
<template>
  <div class="udp-model">
    <div class="scrollbar contpi-boxt">
      <div class="title">
G
i18n  
gongzijian 已提交
21
        <span>{{$t('Set the DAG diagram name')}}</span>
L
ligang 已提交
22
      </div>
G
gongzijian 已提交
23

L
ligang 已提交
24 25 26 27 28
      <div>
        <x-input
                type="text"
                v-model="name"
                :disabled="router.history.current.name === 'projects-instance-details'"
G
i18n  
gongzijian 已提交
29
                :placeholder="$t('Please enter name(required)')">
L
ligang 已提交
30 31
        </x-input>
      </div>
G
gongzijian 已提交
32

L
ligang 已提交
33 34 35 36
      <template v-if="router.history.current.name !== 'projects-instance-details'">
        <div style="padding-top: 12px;">
          <x-input
                  type="textarea"
B
break60 已提交
37
                  v-model="description"
L
ligang 已提交
38
                  :autosize="{minRows:2}"
G
i18n  
gongzijian 已提交
39
                  :placeholder="$t('Please enter description(optional)')"
L
ligang 已提交
40 41 42 43
                  autocomplete="off">
          </x-input>
        </div>
      </template>
G
gongzijian 已提交
44

45 46 47 48
      <div class="title" style="padding-top: 6px;">
        <span class="text-b">{{$t('select tenant')}}</span>
        <form-tenant v-model="tenantId"></form-tenant>
      </div>
G
gongzijian 已提交
49
      <div class="title" style="padding-top: 6px;">
leon-baoliang's avatar
leon-baoliang 已提交
50
        <span class="text-b">{{$t('warning of timeout')}}</span>
G
gongzijian 已提交
51 52 53 54 55 56
        <span style="padding-left: 6px;">
          <x-switch v-model="checkedTimeout"></x-switch>
        </span>
      </div>
      <div class="content" style="padding-bottom: 10px;" v-if="checkedTimeout">
        <span>
G
gongzijian 已提交
57
          <x-input v-model="timeout" style="width: 160px;" maxlength="9">
G
gongzijian 已提交
58 59 60 61 62
            <span slot="append">{{$t('Minute')}}</span>
          </x-input>
        </span>
      </div>

L
ligang 已提交
63
      <div class="title" style="padding-top: 6px;">
G
i18n  
gongzijian 已提交
64
        <span>{{$t('Set global')}}</span>
L
ligang 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
      </div>
      <div class="content">
        <div>
          <m-local-params
                  ref="refLocalParams"
                  @on-local-params="_onLocalParams"
                  :udp-list="udpList"
                  :hide="false">
          </m-local-params>
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="submit">
        <template v-if="router.history.current.name === 'projects-instance-details'">
          <div class="lint-pt">
G
i18n  
gongzijian 已提交
81
            <x-checkbox v-model="syncDefine">{{$t('Whether to update the process definition')}}</x-checkbox>
L
ligang 已提交
82 83
          </div>
        </template>
G
i18n  
gongzijian 已提交
84
        <x-button type="text" @click="close()"> {{$t('Cancel')}} </x-button>
85
        <x-button type="primary" shape="circle" @click="ok()">{{$t('Add')}}</x-button>
L
ligang 已提交
86 87 88 89 90 91 92 93 94 95
      </div>
    </div>
  </div>
</template>
<script>
  import _ from 'lodash'
  import i18n from '@/module/i18n'
  import mLocalParams from '../formModel/tasks/_source/localParams'
  import disabledState from '@/module/mixin/disabledState'
  import Affirm from '../jumpAffirm'
96
  import FormTenant from "./_source/selectTenant";
L
ligang 已提交
97 98 99 100 101 102 103

  export default {
    name: 'udp',
    data () {
      return {
        // dag name
        name: '',
B
break60 已提交
104 105
        // dag description
        description: '',
L
ligang 已提交
106 107
        // Global custom parameters
        udpList: [],
G
gongzijian 已提交
108 109
        // Global custom parameters
        udpListCache: [],
L
ligang 已提交
110
        // Whether to update the process definition
G
gongzijian 已提交
111 112 113
        syncDefine: true,
        // Timeout alarm
        timeout: 0,
114 115

        tenantId: -1,
G
gongzijian 已提交
116 117
        // checked Timeout alarm
        checkedTimeout: true
L
ligang 已提交
118 119 120 121 122 123 124 125 126 127 128 129
      }
    },
    mixins: [disabledState],
    props: {
    },
    methods: {
      /**
       * udp data
       */
      _onLocalParams (a) {
        this.udpList = a
      },
G
gongzijian 已提交
130 131 132
      _verifTimeout () {
        const reg = /^[1-9]\d*$/
        if (!reg.test(this.timeout)) {
G
bug  
gongzijian 已提交
133
          this.$message.warning(`${i18n.$t('Please enter a positive integer greater than 0')}`)
G
gongzijian 已提交
134 135 136 137
          return false
        }
        return true
      },
138 139 140 141
      _accuStore(){
        this.store.commit('dag/setGlobalParams', _.cloneDeep(this.udpList))
        this.store.commit('dag/setName', _.cloneDeep(this.name))
        this.store.commit('dag/setTimeout', _.cloneDeep(this.timeout))
142
        this.store.commit('dag/setTenantId', _.cloneDeep(this.tenantId))
B
break60 已提交
143
        this.store.commit('dag/setDesc', _.cloneDeep(this.description))
144 145
        this.store.commit('dag/setSyncDefine', this.syncDefine)
      },
L
ligang 已提交
146 147 148 149 150
      /**
       * submit
       */
      ok () {
        if (!this.name) {
G
i18n  
gongzijian 已提交
151
          this.$message.warning(`${i18n.$t('DAG graph name cannot be empty')}`)
L
ligang 已提交
152 153 154 155 156 157 158 159
          return
        }

        let _verif = () => {
          // verification udf
          if (!this.$refs.refLocalParams._verifProp()) {
            return
          }
G
gongzijian 已提交
160
          // verification timeout
G
bug  
gongzijian 已提交
161
          if (this.checkedTimeout && !this._verifTimeout()) {
G
gongzijian 已提交
162 163 164
            return
          }

L
ligang 已提交
165
          // Storage global globalParams
166 167
          this._accuStore()

L
ligang 已提交
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
          Affirm.setIsPop(false)
          this.$emit('onUdp')
        }

        // Edit => direct storage
        if (this.store.state.dag.name) {
          _verif()
        } else {
          // New First verify that the name exists
          this.store.dispatch('dag/verifDAGName', this.name).then(res => {
            _verif()
          }).catch(e => {
            this.$message.error(e.msg || '')
          })
        }
      },
      /**
       * Close the popup
       */
      close () {
G
gongzijian 已提交
188
        this.$emit('close')
L
ligang 已提交
189 190 191
      }
    },
    watch: {
G
gongzijian 已提交
192 193 194 195 196 197
      checkedTimeout (val) {
        if (!val) {
          this.timeout = 0
          this.store.commit('dag/setTimeout', _.cloneDeep(this.timeout))
        }
      }
L
ligang 已提交
198 199
    },
    created () {
G
gongzijian 已提交
200 201 202 203
      const dag = _.cloneDeep(this.store.state.dag)
      this.udpList = dag.globalParams
      this.udpListCache = dag.globalParams
      this.name = dag.name
B
break60 已提交
204
      this.description = dag.description
G
gongzijian 已提交
205 206
      this.syncDefine = dag.syncDefine
      this.timeout = dag.timeout || 0
G
gongzijian 已提交
207
      this.checkedTimeout = this.timeout !== 0
208
      this.tenantId = dag.tenantId || -1
L
ligang 已提交
209 210
    },
    mounted () {},
211
    components: {FormTenant, mLocalParams }
L
ligang 已提交
212 213 214 215 216
  }
</script>

<style lang="scss" rel="stylesheet/scss">
  .udp-model {
217 218
    width: 624px;
    min-height: 420px;
L
ligang 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
    background: #fff;
    border-radius: 3px;
    padding:20px 0 ;
    position: relative;
    .contpi-boxt {
      max-height: 600px;
      overflow-y: scroll;
      padding:0 20px;
    }
    .title {
      line-height: 36px;
      padding-bottom: 10px;
      span {
        font-size: 16px;
        color: #333;
      }
    }
    .bottom{
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      text-align: right;
      height: 56px;
      line-height: 56px;
      border-top: 1px solid #DCDEDC;
      background: #fff;
      .submit {
        padding-right: 20px;
        margin-top: -4px;
      }
      .lint-pt {
        position: absolute;
        left: 20px;
        top: -2px;
        >label {
          font-weight: normal;
        }
      }
    }
    .content {
      padding-bottom: 50px;
261 262 263 264 265 266 267
      .user-def-params-model {
        .add {
          a {
            color: #0097e0;
          }
        }
      }
L
ligang 已提交
268
    }
269

L
ligang 已提交
270 271
  }
</style>