udp.vue 7.7 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'"
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

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

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

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

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

L
ligang 已提交
169 170 171 172
          Affirm.setIsPop(false)
          this.$emit('onUdp')
        }

173 174 175 176 177 178 179
        if (this.originalName !== this.name) {
          this.store.dispatch('dag/verifDAGName', this.name).then(res => {
            _verif()
          }).catch(e => {
            this.$message.error(e.msg || '')
          })
        } else {
L
ligang 已提交
180
          _verif()
181
        }
L
ligang 已提交
182 183 184 185 186
      },
      /**
       * Close the popup
       */
      close () {
G
gongzijian 已提交
187
        this.$emit('close')
L
ligang 已提交
188 189 190
      }
    },
    watch: {
G
gongzijian 已提交
191 192 193 194 195 196
      checkedTimeout (val) {
        if (!val) {
          this.timeout = 0
          this.store.commit('dag/setTimeout', _.cloneDeep(this.timeout))
        }
      }
L
ligang 已提交
197 198
    },
    created () {
G
gongzijian 已提交
199 200 201 202
      const dag = _.cloneDeep(this.store.state.dag)
      this.udpList = dag.globalParams
      this.udpListCache = dag.globalParams
      this.name = dag.name
203
      this.originalName = 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 209
      this.$nextTick(() => {
        if (dag.tenantId === -1) {
210
          this.tenantId = this.store.state.user.userInfo.tenantId
211
        } else {
212
          this.tenantId = dag.tenantId
213 214
        }
      })
215

L
ligang 已提交
216 217
    },
    mounted () {},
218
    components: {FormTenant, mLocalParams }
L
ligang 已提交
219 220 221 222 223
  }
</script>

<style lang="scss" rel="stylesheet/scss">
  .udp-model {
224 225
    width: 624px;
    min-height: 420px;
L
ligang 已提交
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 261 262 263 264 265 266 267
    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;
268 269 270 271 272 273 274
      .user-def-params-model {
        .add {
          a {
            color: #0097e0;
          }
        }
      }
L
ligang 已提交
275
    }
276

L
ligang 已提交
277 278
  }
</style>