formModel.vue 27.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
<template>
  <div class="form-model-model" v-clickoutside="_handleClose">
19
    <div class="title-box">
G
i18n  
gongzijian 已提交
20
      <span class="name">{{$t('Current node settings')}}</span>
L
ligang 已提交
21 22 23
      <span class="go-subtask">
        <!-- Component can't pop up box to do component processing -->
        <m-log :item="backfillItem">
24 25
          <template slot="history"><a href="javascript:" @click="_seeHistory" ><em class="ansicon ans-icon-timer"></em><em>{{$t('View history')}}</em></a></template>
          <template slot="log"><a href="javascript:"><em class="ansicon ans-icon-log"></em><em>{{$t('View log')}}</em></a></template>
L
ligang 已提交
26
        </m-log>
27
        <a href="javascript:" @click="_goSubProcess" v-if="_isGoSubProcess"><em class="ansicon ans-icon-node"></em><em>{{$t('Enter this child node')}}</em></a>
L
ligang 已提交
28 29 30 31 32 33
      </span>
    </div>
    <div class="content-box" v-if="isContentBox">
      <div class="from-model">
        <!-- Node name -->
        <div class="clearfix list">
G
i18n  
gongzijian 已提交
34
          <div class="text-box"><span>{{$t('Node name')}}</span></div>
L
ligang 已提交
35 36 37
          <div class="cont-box">
            <label class="label-box">
              <x-input
38 39 40
                type="text"
                v-model="name"
                :disabled="isDetails"
41
                :placeholder="$t('Please enter name (required)')"
42 43 44
                maxlength="100"
                @on-blur="_verifName()"
                autocomplete="off">
L
ligang 已提交
45 46 47 48 49 50 51
              </x-input>
            </label>
          </div>
        </div>

        <!-- Running sign -->
        <div class="clearfix list">
G
i18n  
gongzijian 已提交
52
          <div class="text-box"><span>{{$t('Run flag')}}</span></div>
L
ligang 已提交
53 54 55
          <div class="cont-box">
            <label class="label-box">
              <x-radio-group v-model="runFlag" >
G
i18n  
gongzijian 已提交
56 57
                <x-radio :label="'NORMAL'" :disabled="isDetails">{{$t('Normal')}}</x-radio>
                <x-radio :label="'FORBIDDEN'" :disabled="isDetails">{{$t('Prohibition execution')}}</x-radio>
L
ligang 已提交
58 59 60 61 62
              </x-radio-group>
            </label>
          </div>
        </div>

B
break60 已提交
63
        <!-- description -->
L
ligang 已提交
64 65
        <div class="clearfix list">
          <div class="text-box">
G
i18n  
gongzijian 已提交
66
            <span>{{$t('Description')}}</span>
L
ligang 已提交
67 68 69 70
          </div>
          <div class="cont-box">
            <label class="label-box">
              <x-input
71 72 73 74
                resize
                :autosize="{minRows:2}"
                type="textarea"
                :disabled="isDetails"
B
break60 已提交
75
                v-model="description"
76 77
                :placeholder="$t('Please enter description')"
                autocomplete="off">
L
ligang 已提交
78 79 80 81 82 83 84 85
              </x-input>
            </label>
          </div>
        </div>

        <!-- Task priority -->
        <div class="clearfix list">
          <div class="text-box">
G
i18n  
gongzijian 已提交
86
            <span>{{$t('Task priority')}}</span>
L
ligang 已提交
87 88
          </div>
          <div class="cont-box">
G
gongzijian 已提交
89 90 91
            <span class="label-box" style="width: 193px;display: inline-block;">
              <m-priority v-model="taskInstancePriority"></m-priority>
            </span>
G
gongzijian 已提交
92
            <span class="text-b">{{$t('Worker group')}}</span>
93
            <m-worker-groups v-model="workerGroup"></m-worker-groups>
L
ligang 已提交
94 95 96 97 98 99
          </div>
        </div>

        <!-- Number of failed retries -->
        <div class="clearfix list" v-if="taskType !== 'SUB_PROCESS'">
          <div class="text-box">
G
i18n  
gongzijian 已提交
100
            <span>{{$t('Number of failed retries')}}</span>
L
ligang 已提交
101 102 103 104
          </div>
          <div class="cont-box">
            <m-select-input v-model="maxRetryTimes" :list="[0,1,2,3,4]">
            </m-select-input>
G
i18n  
gongzijian 已提交
105 106
            <span>({{$t('Times')}})</span>
            <span class="text-b">{{$t('Failed retry interval')}}</span>
L
ligang 已提交
107 108
            <m-select-input v-model="retryInterval" :list="[1,10,30,60,120]">
            </m-select-input>
G
i18n  
gongzijian 已提交
109
            <span>({{$t('Minute')}})</span>
L
ligang 已提交
110 111
          </div>
        </div>
112 113 114 115 116 117 118 119 120 121 122 123 124 125

        <!-- Delay execution time -->
        <div class="clearfix list" v-if="taskType !== 'SUB_PROCESS' && taskType !== 'CONDITIONS' && taskType !== 'DEPENDENT'">
          <div class="text-box">
            <span>{{$t('Delay execution time')}}</span>
          </div>
          <div class="cont-box">
            <m-select-input v-model="delayTime" :list="[0,1,5,10]">
            </m-select-input>
            <span>({{$t('Minute')}})</span>
          </div>
        </div>

        <!-- Branch flow -->
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
        <div class="clearfix list" v-if="taskType === 'CONDITIONS'">
          <div class="text-box">
            <span>{{$t('State')}}</span>
          </div>
          <div class="cont-box">
            <span class="label-box" style="width: 193px;display: inline-block;">
              <x-select style="width: 157px;" v-model="successNode" :disabled="true">
              <x-option v-for="item in stateList" :key="item.value" :value="item.value" :label="item.label">
              </x-option>
            </x-select>
            </span>
            <span class="text-b" style="padding-left: 38px">{{$t('Branch flow')}}</span>
            <x-select style="width: 157px;" v-model="successBranch" clearable>
              <x-option v-for="item in rearList" :key="item.value" :value="item.value" :label="item.label">
              </x-option>
            </x-select>
          </div>
        </div>
        <div class="clearfix list" v-if="taskType === 'CONDITIONS'">
          <div class="text-box">
            <span>{{$t('State')}}</span>
          </div>
          <div class="cont-box">
            <span class="label-box" style="width: 193px;display: inline-block;">
              <x-select style="width: 157px;" v-model="failedNode" :disabled="true">
              <x-option v-for="item in stateList" :key="item.value" :value="item.value" :label="item.label">
              </x-option>
            </x-select>
            </span>
            <span class="text-b" style="padding-left: 38px">{{$t('Branch flow')}}</span>
            <x-select style="width: 157px;" v-model="failedBranch" clearable>
              <x-option v-for="item in rearList" :key="item.value" :value="item.value" :label="item.label">
              </x-option>
            </x-select>
          </div>
        </div>
L
ligang 已提交
162 163 164

        <!-- Task timeout alarm -->
        <m-timeout-alarm
曹聚阳 已提交
165
          v-if="taskType !== 'DEPENDENT'"
166 167 168
          ref="timeout"
          :backfill-item="backfillItem"
          @on-timeout="_onTimeout">
L
ligang 已提交
169
        </m-timeout-alarm>
曹聚阳 已提交
170 171 172 173 174 175 176
        <!-- Dependent timeout alarm -->
        <m-dependent-timeout
          v-if="taskType === 'DEPENDENT'"
          ref="dependentTimeout"
          :backfill-item="backfillItem"
          @on-timeout="_onDependentTimeout">
        </m-dependent-timeout>
L
ligang 已提交
177 178 179

        <!-- shell node -->
        <m-shell
180 181
          v-if="taskType === 'SHELL'"
          @on-params="_onParams"
Z
zhukai 已提交
182
          @on-cache-params="_onCacheParams"
183 184
          ref="SHELL"
          :backfill-item="backfillItem">
L
ligang 已提交
185
        </m-shell>
X
xsbai 已提交
186 187 188 189 190 191 192 193
        <!-- waterdrop node -->
        <m-waterdrop
          v-if="taskType === 'WATERDROP'"
          @on-params="_onParams"
          @on-cache-params="_onCacheParams"
          ref="WATERDROP"
          :backfill-item="backfillItem">
        </m-waterdrop>
L
ligang 已提交
194 195
        <!-- sub_process node -->
        <m-sub-process
196 197
          v-if="taskType === 'SUB_PROCESS'"
          @on-params="_onParams"
Z
zhukai 已提交
198
          @on-cache-params="_onCacheParams"
199 200 201
          @on-set-process-name="_onSetProcessName"
          ref="SUB_PROCESS"
          :backfill-item="backfillItem">
L
ligang 已提交
202 203 204
        </m-sub-process>
        <!-- procedure node -->
        <m-procedure
205 206
          v-if="taskType === 'PROCEDURE'"
          @on-params="_onParams"
Z
zhukai 已提交
207
          @on-cache-params="_onCacheParams"
208 209
          ref="PROCEDURE"
          :backfill-item="backfillItem">
L
ligang 已提交
210 211 212
        </m-procedure>
        <!-- sql node -->
        <m-sql
213 214
          v-if="taskType === 'SQL'"
          @on-params="_onParams"
215
          @on-cache-params="_onCacheParams"
216 217 218
          ref="SQL"
          :create-node-id="id"
          :backfill-item="backfillItem">
L
ligang 已提交
219 220 221
        </m-sql>
        <!-- spark node -->
        <m-spark
222 223
          v-if="taskType === 'SPARK'"
          @on-params="_onParams"
224
          @on-cache-params="_onCacheParams"
225 226
          ref="SPARK"
          :backfill-item="backfillItem">
L
ligang 已提交
227
        </m-spark>
228 229 230
        <m-flink
          v-if="taskType === 'FLINK'"
          @on-params="_onParams"
231
          @on-cache-params="_onCacheParams"
232 233 234
          ref="FLINK"
          :backfill-item="backfillItem">
        </m-flink>
L
ligang 已提交
235 236
        <!-- mr node -->
        <m-mr
237 238
          v-if="taskType === 'MR'"
          @on-params="_onParams"
Z
zhukai 已提交
239
          @on-cache-params="_onCacheParams"
240 241
          ref="MR"
          :backfill-item="backfillItem">
L
ligang 已提交
242 243 244
        </m-mr>
        <!-- python node -->
        <m-python
245 246
          v-if="taskType === 'PYTHON'"
          @on-params="_onParams"
Z
zhukai 已提交
247
          @on-cache-params="_onCacheParams"
248 249
          ref="PYTHON"
          :backfill-item="backfillItem">
L
ligang 已提交
250 251 252
        </m-python>
        <!-- dependent node -->
        <m-dependent
253 254
          v-if="taskType === 'DEPENDENT'"
          @on-dependent="_onDependent"
Z
zhukai 已提交
255
          @on-cache-dependent="_onCacheDependent"
256 257
          ref="DEPENDENT"
          :backfill-item="backfillItem">
L
ligang 已提交
258
        </m-dependent>
259 260 261
        <m-http
          v-if="taskType === 'HTTP'"
          @on-params="_onParams"
262
          @on-cache-params="_onCacheParams"
263 264 265
          ref="HTTP"
          :backfill-item="backfillItem">
        </m-http>
266 267 268 269 270 271 272
        <m-datax
          v-if="taskType === 'DATAX'"
          @on-params="_onParams"
          @on-cache-params="_onCacheParams"
          ref="DATAX"
          :backfill-item="backfillItem">
        </m-datax>
_和's avatar
_和 已提交
273 274 275 276 277 278 279
        <m-sqoop
          v-if="taskType === 'SQOOP'"
          @on-params="_onParams"
          @on-cache-params="_onCacheParams"
          ref="SQOOP"
          :backfill-item="backfillItem">
        </m-sqoop>
280 281 282 283
        <m-conditions
          v-if="taskType === 'CONDITIONS'"
          ref="CONDITIONS"
          @on-dependent="_onDependent"
284
          @on-cache-dependent="_onCacheDependent"
285 286 287
          :backfill-item="backfillItem"
          :pre-node="preNode">
        </m-conditions>
288 289 290 291 292 293
        <!-- Pre-tasks in workflow -->
        <m-pre-tasks
          v-if="['SHELL', 'SUB_PROCESS'].indexOf(taskType) > -1"
          @on-pre-tasks="_onPreTasks"
          ref="PRE_TASK"
          :backfill-item="backfillItem"></m-pre-tasks>
L
ligang 已提交
294 295 296 297
      </div>
    </div>
    <div class="bottom-box">
      <div class="submit" style="background: #fff;">
298
        <x-button type="text" id="cancelBtn"> {{$t('Cancel')}} </x-button>
299
        <x-button type="primary" shape="circle" :loading="spinnerLoading" @click="ok()" :disabled="isDetails">{{spinnerLoading ? 'Loading...' : $t('Confirm add')}} </x-button>
L
ligang 已提交
300 301 302 303 304 305
      </div>
    </div>
  </div>
</template>
<script>
  import _ from 'lodash'
306
  import { mapActions } from 'vuex'
L
ligang 已提交
307 308 309 310 311
  import mLog from './log'
  import mMr from './tasks/mr'
  import mSql from './tasks/sql'
  import i18n from '@/module/i18n'
  import mShell from './tasks/shell'
X
xsbai 已提交
312
  import mWaterdrop from './tasks/waterdrop'
L
ligang 已提交
313
  import mSpark from './tasks/spark'
314
  import mFlink from './tasks/flink'
L
ligang 已提交
315 316 317 318
  import mPython from './tasks/python'
  import JSP from './../plugIn/jsPlumbHandle'
  import mProcedure from './tasks/procedure'
  import mDependent from './tasks/dependent'
319
  import mHttp from './tasks/http'
320
  import mDatax from './tasks/datax'
B
break60 已提交
321
  import mConditions from './tasks/conditions'
_和's avatar
_和 已提交
322
  import mSqoop from './tasks/sqoop'
L
ligang 已提交
323 324 325
  import mSubProcess from './tasks/sub_process'
  import mSelectInput from './_source/selectInput'
  import mTimeoutAlarm from './_source/timeoutAlarm'
曹聚阳 已提交
326
  import mDependentTimeout from './_source/dependentTimeout'
G
gongzijian 已提交
327
  import mWorkerGroups from './_source/workerGroups'
328
  import mPreTasks from './tasks/pre_tasks'
L
ligang 已提交
329 330
  import clickoutside from '@/module/util/clickoutside'
  import disabledState from '@/module/mixin/disabledState'
G
gongzijian 已提交
331
  import { isNameExDag, rtBantpl } from './../plugIn/util'
L
ligang 已提交
332 333 334 335 336 337 338 339 340
  import mPriority from '@/module/components/priority/priority'

  export default {
    name: 'form-model',
    data () {
      return {
        // loading
        spinnerLoading: false,
        // node name
341
        name: '',
B
break60 已提交
342 343
        // description
        description: '',
L
ligang 已提交
344 345
        // Node echo data
        backfillItem: {},
346
        cacheBackfillItem: {},
L
ligang 已提交
347 348
        // Resource(list)
        resourcesList: [],
349 350 351 352 353 354 355 356
        successNode: 'success',
        failedNode: 'failed',
        successBranch: '',
        failedBranch: '',
        conditionResult: {
          'successNode': [],
          'failedNode': []
        },
L
ligang 已提交
357 358
        // dependence
        dependence: {},
Z
zhukai 已提交
359 360
        // cache dependence
        cacheDependence: {},
L
ligang 已提交
361 362 363 364 365 366 367 368 369 370
        // Current node params data
        params: {},
        // Running sign
        runFlag: 'NORMAL',
        // The second echo problem caused by the node data is specifically which node hook caused the unfinished special treatment
        isContentBox: false,
        // Number of failed retries
        maxRetryTimes: '0',
        // Failure retry interval
        retryInterval: '1',
371 372
        // Delay execution time
        delayTime: '0',
L
ligang 已提交
373 374
        // Task timeout alarm
        timeout: {},
曹聚阳 已提交
375 376
        // (For Dependent nodes) Wait start timeout alarm
        waitStartTimeout: {},
L
ligang 已提交
377
        // Task priority
G
gongzijian 已提交
378 379
        taskInstancePriority: 'MEDIUM',
        // worker group id
Q
qiaozhanwei 已提交
380
        workerGroup: 'default',
381 382 383 384 385 386 387 388 389
        stateList:[
          {
            value: 'success',
            label: `${i18n.$t('success')}`
          },
          {
            value: 'failed',
            label: `${i18n.$t('failed')}`
          }
390 391 392 393 394
        ],
        // preTasks
        preTaskIdsInWorkflow: [],
        preTasksToAdd: [],    // pre-taskIds to add, used in jsplumb connects
        preTasksToDelete: [], // pre-taskIds to delete, used in jsplumb connects
L
ligang 已提交
395 396 397 398 399 400 401 402 403 404
      }
    },
    /**
     * Click on events that are not generated internally by the component
     */
    directives: { clickoutside },
    mixins: [disabledState],
    props: {
      id: Number,
      taskType: String,
405 406
      self: Object,
      preNode: Array,
407 408
      rearList: Array,
      instanceId: Number
L
ligang 已提交
409 410
    },
    methods: {
411
      ...mapActions('dag', ['getTaskInstanceList']),
L
ligang 已提交
412 413 414 415 416 417
      /**
       * depend
       */
      _onDependent (o) {
        this.dependence = Object.assign(this.dependence, {}, o)
      },
418 419 420 421 422 423 424 425
      /**
       * Pre-tasks in workflow
       */
      _onPreTasks (o) {
        this.preTaskIdsInWorkflow = o.preTasks
        this.preTasksToAdd = o.preTasksToAdd
        this.preTasksToDelete = o.preTasksToDelete
      },
Z
zhukai 已提交
426 427 428 429 430 431
      /**
       * cache dependent
       */
      _onCacheDependent (o) {
        this.cacheDependence = Object.assign(this.cacheDependence, {}, o)
      },
L
ligang 已提交
432 433 434 435 436 437
      /**
       * Task timeout alarm
       */
      _onTimeout (o) {
        this.timeout = Object.assign(this.timeout, {}, o)
      },
曹聚阳 已提交
438 439 440 441 442 443 444
      /**
       * Dependent timeout alarm
       */
      _onDependentTimeout (o) {
        this.timeout = Object.assign(this.timeout, {}, o.waitCompleteTimeout)
        this.waitStartTimeout = Object.assign(this.waitStartTimeout, {}, o.waitStartTimeout)
      },
L
ligang 已提交
445 446 447 448
      /**
       * Click external to close the current component
       */
      _handleClose () {
449
        // this.close()
L
ligang 已提交
450 451 452 453 454 455
      },
      /**
       * Jump to task instance
       */
      _seeHistory () {
        this.self.$router.push({
456
          name: 'task-instance',
L
ligang 已提交
457 458 459 460 461 462 463 464 465 466 467 468 469
          query: {
            processInstanceId: this.self.$route.params.id,
            taskName: this.backfillItem.name
          }
        })
        this.$modal.destroy()
      },
      /**
       * Enter the child node to judge the process instance or the process definition
       * @param  type = instance
       */
      _goSubProcess () {
        if (_.isEmpty(this.backfillItem)) {
G
i18n  
gongzijian 已提交
470
          this.$message.warning(`${i18n.$t('The newly created sub-Process has not yet been executed and cannot enter the sub-Process')}`)
L
ligang 已提交
471 472 473 474 475
          return
        }
        if (this.router.history.current.name === 'projects-instance-details') {
          let stateId = $(`#${this.id}`).attr('data-state-id') || null
          if (!stateId) {
G
i18n  
gongzijian 已提交
476
            this.$message.warning(`${i18n.$t('The task has not been executed and cannot enter the sub-Process')}`)
L
ligang 已提交
477 478 479 480
            return
          }
          this.store.dispatch('dag/getSubProcessId', { taskId: stateId }).then(res => {
            this.$emit('onSubProcess', {
481 482
            subProcessId: res.data.subProcessInstanceId,
            fromThis: this
L
ligang 已提交
483
          })
484 485 486
        }).catch(e => {
            this.$message.error(e.msg || '')
        })
L
ligang 已提交
487 488 489 490 491 492 493 494 495 496 497
        } else {
          this.$emit('onSubProcess', {
            subProcessId: this.backfillItem.params.processDefinitionId,
            fromThis: this
          })
        }
      },
      /**
       * return params
       */
      _onParams (o) {
498
        this.params = Object.assign({}, o)
L
ligang 已提交
499
      },
500 501 502 503 504 505 506

      _onCacheParams (o) {
        this.params = Object.assign(this.params, {}, o)
        this._cacheItem()
      },

      _cacheItem () {
507 508
        this.conditionResult.successNode[0] = this.successBranch
        this.conditionResult.failedNode[0] = this.failedBranch
509 510 511 512 513
        this.$emit('cacheTaskInfo', {
          item: {
            type: this.taskType,
            id: this.id,
            name: this.name,
Z
zhukai 已提交
514
            params: this.params,
515 516
            description: this.description,
            runFlag: this.runFlag,
517
            conditionResult: this.conditionResult,
Z
zhukai 已提交
518
            dependence: this.cacheDependence,
519 520
            maxRetryTimes: this.maxRetryTimes,
            retryInterval: this.retryInterval,
521
            delayTime: this.delayTime,
522
            timeout: this.timeout,
曹聚阳 已提交
523
            waitStartTimeout: this.waitStartTimeout,
524
            taskInstancePriority: this.taskInstancePriority,
Q
qiaozhanwei 已提交
525
            workerGroup: this.workerGroup,
526 527
            status: this.status,
            branch: this.branch
528 529 530 531
          },
          fromThis: this
        })
      },
L
ligang 已提交
532 533 534 535 536
      /**
       * verification name
       */
      _verifName () {
        if (!_.trim(this.name)) {
G
i18n  
gongzijian 已提交
537
          this.$message.warning(`${i18n.$t('Please enter name (required)')}`)
L
ligang 已提交
538 539
          return false
        }
540
        if (this.successBranch !='' && this.successBranch !=null && this.successBranch == this.failedBranch) {
541 542 543
          this.$message.warning(`${i18n.$t('Cannot select the same node for successful branch flow and failed branch flow')}`)
          return false
        }
L
ligang 已提交
544 545 546 547 548
        if (this.name === this.backfillItem.name) {
          return true
        }
        // Name repeat depends on dom backfill dependent store
        if (isNameExDag(this.name, _.isEmpty(this.backfillItem) ? 'dom' : 'backfill')) {
G
i18n  
gongzijian 已提交
549
          this.$message.warning(`${i18n.$t('Name already exists')}`)
L
ligang 已提交
550 551 552 553
          return false
        }
        return true
      },
B
break60 已提交
554 555 556 557 558 559 560 561 562 563
      _verifWorkGroup() {
        let item = this.store.state.security.workerGroupsListAll.find(item => {
          return item.id == this.workerGroup;
        });
        if(item==undefined) {
          this.$message.warning(`${i18n.$t('The Worker group no longer exists, please select the correct Worker group!')}`)
          return false;
        }
        return true
      },
L
ligang 已提交
564 565 566 567 568 569 570 571
      /**
       * Global verification procedure
       */
      _verification () {
        // Verify name
        if (!this._verifName()) {
          return
        }
B
break60 已提交
572 573 574 575
        // verif workGroup
        if(!this._verifWorkGroup()) {
          return
        }
L
ligang 已提交
576
        // Verify task alarm parameters
曹聚阳 已提交
577 578 579 580 581 582 583 584
        if (this.taskType === 'DEPENDENT') {
          if (!this.$refs['dependentTimeout']._verification()) {
            return
          }
        } else {
          if (!this.$refs['timeout']._verification()) {
            return
          }
L
ligang 已提交
585
        }
曹聚阳 已提交
586
        
L
ligang 已提交
587 588 589 590
        // Verify node parameters
        if (!this.$refs[this.taskType]._verification()) {
          return
        }
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
        // Verify preTasks and update dag-things
        if (this.$refs['PRE_TASK']) {
          if (!this.$refs['PRE_TASK']._verification()) {
            return
          }
          else {
            // Sync data-targetarr
            $(`#${this.id}`).attr(
              'data-targetarr', this.preTaskIdsInWorkflow ? this.preTaskIdsInWorkflow.join(',') : '')

            // Update JSP connections
            let plumbIns = JSP.JspInstance
            var targetId = this.id

            // Update new connections
            this.preTasksToAdd.map(sourceId => {
              plumbIns.connect({
                source: sourceId,
                target: targetId,
                type: 'basic',
                paintStyle: { strokeWidth: 2, stroke: '#2d8cf0' },
                HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3}
              })
            })

            // Update remove connections
            let currentConnects = plumbIns.getAllConnections()
            let len = currentConnects.length
            for (let i = 0; i < len; i++) {
              if (this.preTasksToDelete.indexOf(currentConnects[i].sourceId) > -1 && currentConnects[i].targetId == targetId) {
                plumbIns.deleteConnection(currentConnects[i])
                i -= 1
                len -= 1
              }
            }
          }
        }
L
ligang 已提交
628 629

        $(`#${this.id}`).find('span').text(this.name)
630 631
        this.conditionResult.successNode[0] = this.successBranch
        this.conditionResult.failedNode[0] = this.failedBranch
L
ligang 已提交
632 633 634 635 636 637 638
        // Store the corresponding node data structure
        this.$emit('addTaskInfo', {
          item: {
            type: this.taskType,
            id: this.id,
            name: this.name,
            params: this.params,
B
break60 已提交
639
            description: this.description,
L
ligang 已提交
640
            runFlag: this.runFlag,
641
            conditionResult: this.conditionResult,
L
ligang 已提交
642 643 644
            dependence: this.dependence,
            maxRetryTimes: this.maxRetryTimes,
            retryInterval: this.retryInterval,
645
            delayTime: this.delayTime,
L
ligang 已提交
646
            timeout: this.timeout,
曹聚阳 已提交
647
            waitStartTimeout: this.waitStartTimeout,
G
gongzijian 已提交
648
            taskInstancePriority: this.taskInstancePriority,
Q
qiaozhanwei 已提交
649
            workerGroup: this.workerGroup,
650 651
            status: this.status,
            branch: this.branch
L
ligang 已提交
652 653 654
          },
          fromThis: this
        })
G
bug1  
gongzijian 已提交
655 656 657

        // set run flag
        this._setRunFlag()
L
ligang 已提交
658 659 660 661 662 663 664
      },
      /**
       * Sub-workflow selected node echo name
       */
      _onSetProcessName (name) {
        this.name = name
      },
G
bug1  
gongzijian 已提交
665 666 667
      /**
       *  set run flag
       */
668
      _setRunFlag () {
G
bug1  
gongzijian 已提交
669 670 671 672 673 674
        let dom = $(`#${this.id}`).find('.ban-p')
        dom.html('')
        if (this.runFlag === 'FORBIDDEN') {
          dom.append(rtBantpl())
        }
      },
L
ligang 已提交
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
      /**
       * Submit verification
       */
      ok () {
        this._verification()
      },
      /**
       * Close and destroy component and component internal events
       */
      close () {
        let flag = false
        // Delete node without storage
        if (!this.backfillItem.name) {
          flag = true
        }
        this.isContentBox = false
        // flag Whether to delete a node this.$destroy()
        this.$emit('close', {
693
          item: this.cacheBackfillItem,
L
ligang 已提交
694 695 696 697
          flag: flag,
          fromThis: this
        })
      }
698
    }, 
G
gongzijian 已提交
699
    watch: {
700 701 702 703
      /**
       * Watch the item change, cache the value it changes
       **/
      _item (val) {
704
        // this._cacheItem()
705
      }
G
gongzijian 已提交
706
    },
L
ligang 已提交
707 708 709 710 711
    created () {
      // Unbind copy and paste events
      JSP.removePaste()
      // Backfill data
      let taskList = this.store.state.dag.tasks
712 713 714

      //fillback use cacheTasks
      let cacheTasks = this.store.state.dag.cacheTasks
L
ligang 已提交
715
      let o = {}
716 717 718 719 720 721 722 723 724 725 726
      if (cacheTasks[this.id]) {
        o = cacheTasks[this.id]
        this.backfillItem = cacheTasks[this.id]
      } else {
        if (taskList.length) {
          taskList.forEach(v => {
            if (v.id === this.id) {
              o = v
              this.backfillItem = v
            }
          })
727
        }
728 729 730 731 732 733 734 735 736
      }
      // Non-null objects represent backfill
      if (!_.isEmpty(o)) {
        this.name = o.name
        this.taskInstancePriority = o.taskInstancePriority
        this.runFlag = o.runFlag || 'NORMAL'
        this.description = o.description
        this.maxRetryTimes = o.maxRetryTimes
        this.retryInterval = o.retryInterval
737
        this.delayTime = o.delayTime
738 739 740 741
        if(o.conditionResult) {
          this.successBranch = o.conditionResult.successNode[0]
          this.failedBranch = o.conditionResult.failedNode[0]
        }
742
          // If the workergroup has been deleted, set the default workergroup
B
break60 已提交
743 744 745 746 747 748
        var hasMatch = false;
        for (let i = 0; i < this.store.state.security.workerGroupsListAll.length; i++) {
          var workerGroup = this.store.state.security.workerGroupsListAll[i].id
          if (o.workerGroup == workerGroup) {
            hasMatch = true;
            break;
749
          }
B
break60 已提交
750
        }
751 752 753 754 755 756
        if(o.workerGroup == undefined) {
          this.store.dispatch('dag/getTaskInstanceList',{
            pageSize: 10, pageNo: 1, processInstanceId: this.instanceId, name: o.name
          }).then(res => {
            this.workerGroup = res.totalList[0].workerGroup
          })
B
break60 已提交
757 758 759
        } else {
          this.workerGroup = o.workerGroup
        }
760

761 762
        this.params = o.params || {}
        this.dependence = o.dependence || {}
Z
zhukai 已提交
763
        this.cacheDependence = o.dependence || {}
764

B
break60 已提交
765 766
      } else {
        this.workerGroup = this.store.state.security.workerGroupsListAll[0].id
L
ligang 已提交
767
      }
768
      this.cacheBackfillItem = JSON.parse(JSON.stringify(o))
L
ligang 已提交
769
      this.isContentBox = true
770 771 772 773 774 775 776 777 778 779

      // Init value of preTask selector
      let preTaskIds = $(`#${this.id}`).attr('data-targetarr')
      if (!_.isEmpty(this.backfillItem)) {
        if (preTaskIds && preTaskIds.length) {
          this.backfillItem.preTasks = preTaskIds.split(',')
        } else {
          this.backfillItem.preTasks = []
        }
      }
L
ligang 已提交
780
    },
781
    mounted () {
782 783 784 785 786
      let self = this
      $("#cancelBtn").mousedown(function(event){
        event.preventDefault();
        self.close()
      });
787
    },
L
ligang 已提交
788 789 790 791 792 793 794 795 796 797 798 799
    updated () {
    },
    beforeDestroy () {
    },
    destroyed () {
    },
    computed: {
      /**
       * Child workflow entry show/hide
       */
      _isGoSubProcess () {
        return this.taskType === 'SUB_PROCESS' && this.name
800 801 802 803 804 805 806 807 808 809
      },

      //Define the item model
      _item () {
        return {
          type: this.taskType,
          id: this.id,
          name: this.name,
          description: this.description,
          runFlag: this.runFlag,
Z
zhukai 已提交
810
          dependence: this.cacheDependence,
811 812
          maxRetryTimes: this.maxRetryTimes,
          retryInterval: this.retryInterval,
813
          delayTime: this.delayTime,
814
          timeout: this.timeout,
曹聚阳 已提交
815
          waitStartTimeout: this.waitStartTimeout,
816
          taskInstancePriority: this.taskInstancePriority,
Q
qiaozhanwei 已提交
817
          workerGroup: this.workerGroup,
818 819
          successBranch: this.successBranch,
          failedBranch: this.failedBranch
820
        }
L
ligang 已提交
821 822 823 824 825
      }
    },
    components: {
      mMr,
      mShell,
X
xsbai 已提交
826
      mWaterdrop,
L
ligang 已提交
827 828 829 830 831
      mSubProcess,
      mProcedure,
      mSql,
      mLog,
      mSpark,
832
      mFlink,
L
ligang 已提交
833 834
      mPython,
      mDependent,
835
      mHttp,
836
      mDatax,
_和's avatar
_和 已提交
837
      mSqoop,
838
      mConditions,
L
ligang 已提交
839 840
      mSelectInput,
      mTimeoutAlarm,
曹聚阳 已提交
841
      mDependentTimeout,
G
gongzijian 已提交
842
      mPriority,
843 844
      mWorkerGroups,
      mPreTasks,
L
ligang 已提交
845 846 847 848 849
    }
  }
</script>

<style lang="scss" rel="stylesheet/scss">
G
gongzijian 已提交
850
  @import "./formModel";
851 852 853 854 855
  .ans-radio-disabled {
    .ans-radio-inner:after {
      background-color: #6F8391
    }
  }
L
ligang 已提交
856
</style>