formModel.vue 27.9 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 el-icon-alarm-clock"></em><em>{{$t('View history')}}</em></a></template>
          <template slot="log"><a href="javascript:"><em class="ansicon el-icon-document"></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 fa fa-tasks"></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
          <div class="cont-box">
            <label class="label-box">
37
              <el-input
38 39
                type="text"
                v-model="name"
40
                size="small"
41
                :disabled="isDetails"
42
                :placeholder="$t('Please enter name (required)')"
43
                maxlength="100"
44 45
                @blur="_verifName()">
              </el-input>
L
ligang 已提交
46 47 48 49 50 51
            </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
          <div class="cont-box">
            <label class="label-box">
55 56 57 58
              <el-radio-group v-model="runFlag" size="small" style="vertical-align: sub;">
                <el-radio :label="'NORMAL'" :disabled="isDetails">{{$t('Normal')}}</el-radio>
                <el-radio :label="'FORBIDDEN'" :disabled="isDetails">{{$t('Prohibition execution')}}</el-radio>
              </el-radio-group>
L
ligang 已提交
59 60 61 62
            </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
          </div>
          <div class="cont-box">
            <label class="label-box">
70 71
              <el-input
                :rows="2"
72 73
                type="textarea"
                :disabled="isDetails"
B
break60 已提交
74
                v-model="description"
75 76
                :placeholder="$t('Please enter description')">
              </el-input>
L
ligang 已提交
77 78 79 80 81 82 83
            </label>
          </div>
        </div>

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

        <!-- Number of failed retries -->
96
        <div class="clearfix list" v-if="nodeData.taskType !== 'SUB_PROCESS'">
L
ligang 已提交
97
          <div class="text-box">
G
i18n  
gongzijian 已提交
98
            <span>{{$t('Number of failed retries')}}</span>
L
ligang 已提交
99 100
          </div>
          <div class="cont-box">
101
            <m-select-input v-model="maxRetryTimes" :list="[0,1,2,3,4]"></m-select-input>
G
i18n  
gongzijian 已提交
102 103
            <span>({{$t('Times')}})</span>
            <span class="text-b">{{$t('Failed retry interval')}}</span>
104
            <m-select-input v-model="retryInterval" :list="[1,10,30,60,120]"></m-select-input>
G
i18n  
gongzijian 已提交
105
            <span>({{$t('Minute')}})</span>
L
ligang 已提交
106 107
          </div>
        </div>
108 109

        <!-- Delay execution time -->
110
        <div class="clearfix list" v-if="nodeData.taskType !== 'SUB_PROCESS' && nodeData.taskType !== 'CONDITIONS' && nodeData.taskType !== 'DEPENDENT'">
111 112 113 114
          <div class="text-box">
            <span>{{$t('Delay execution time')}}</span>
          </div>
          <div class="cont-box">
115
            <m-select-input v-model="delayTime" :list="[0,1,5,10]"></m-select-input>
116 117 118 119 120
            <span>({{$t('Minute')}})</span>
          </div>
        </div>

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

        <!-- Task timeout alarm -->
        <m-timeout-alarm
156
          v-if="nodeData.taskType !== 'DEPENDENT'"
157 158 159
          ref="timeout"
          :backfill-item="backfillItem"
          @on-timeout="_onTimeout">
L
ligang 已提交
160
        </m-timeout-alarm>
曹聚阳 已提交
161 162
        <!-- Dependent timeout alarm -->
        <m-dependent-timeout
163
          v-if="nodeData.taskType === 'DEPENDENT'"
曹聚阳 已提交
164 165 166 167
          ref="dependentTimeout"
          :backfill-item="backfillItem"
          @on-timeout="_onDependentTimeout">
        </m-dependent-timeout>
L
ligang 已提交
168 169 170

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

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

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

      _cacheItem () {
492 493
        this.conditionResult.successNode[0] = this.successBranch
        this.conditionResult.failedNode[0] = this.failedBranch
494 495
        this.$emit('cacheTaskInfo', {
          item: {
496 497
            type: this.nodeData.taskType,
            id: this.nodeData.id,
498
            name: this.name,
Z
zhukai 已提交
499
            params: this.params,
500 501
            description: this.description,
            runFlag: this.runFlag,
502
            conditionResult: this.conditionResult,
Z
zhukai 已提交
503
            dependence: this.cacheDependence,
504 505
            maxRetryTimes: this.maxRetryTimes,
            retryInterval: this.retryInterval,
506
            delayTime: this.delayTime,
507
            timeout: this.timeout,
曹聚阳 已提交
508
            waitStartTimeout: this.waitStartTimeout,
509
            taskInstancePriority: this.taskInstancePriority,
Q
qiaozhanwei 已提交
510
            workerGroup: this.workerGroup,
511 512
            status: this.status,
            branch: this.branch
513 514 515 516
          },
          fromThis: this
        })
      },
L
ligang 已提交
517 518 519 520 521
      /**
       * verification name
       */
      _verifName () {
        if (!_.trim(this.name)) {
G
i18n  
gongzijian 已提交
522
          this.$message.warning(`${i18n.$t('Please enter name (required)')}`)
L
ligang 已提交
523 524
          return false
        }
525
        if (this.successBranch !== '' && this.successBranch !== null && this.successBranch === this.failedBranch) {
526 527 528
          this.$message.warning(`${i18n.$t('Cannot select the same node for successful branch flow and failed branch flow')}`)
          return false
        }
L
ligang 已提交
529 530 531 532 533
        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 已提交
534
          this.$message.warning(`${i18n.$t('Name already exists')}`)
L
ligang 已提交
535 536 537 538
          return false
        }
        return true
      },
539
      _verifWorkGroup () {
B
break60 已提交
540
        let item = this.store.state.security.workerGroupsListAll.find(item => {
541
          return item.id === this.workerGroup
542
        })
543
        if (item === undefined) {
B
break60 已提交
544
          this.$message.warning(`${i18n.$t('The Worker group no longer exists, please select the correct Worker group!')}`)
545
          return false
B
break60 已提交
546 547 548
        }
        return true
      },
L
ligang 已提交
549 550 551 552 553 554 555 556
      /**
       * Global verification procedure
       */
      _verification () {
        // Verify name
        if (!this._verifName()) {
          return
        }
B
break60 已提交
557
        // verif workGroup
558
        if (!this._verifWorkGroup()) {
B
break60 已提交
559 560
          return
        }
L
ligang 已提交
561
        // Verify task alarm parameters
562
        if (this.nodeData.taskType === 'DEPENDENT') {
563
          if (!this.$refs.dependentTimeout._verification()) {
曹聚阳 已提交
564 565 566
            return
          }
        } else {
567
          if (!this.$refs.timeout._verification()) {
曹聚阳 已提交
568 569
            return
          }
L
ligang 已提交
570
        }
571

L
ligang 已提交
572
        // Verify node parameters
573
        if (!this.$refs[this.nodeData.taskType]._verification()) {
L
ligang 已提交
574 575
          return
        }
576
        // Verify preTasks and update dag-things
577 578
        if (this.$refs.PRE_TASK) {
          if (!this.$refs.PRE_TASK._verification()) {
579
            return
580
          } else {
581
            // Sync data-targetarr
582
            $(`#${this.nodeData.id}`).attr(
583 584 585 586
              'data-targetarr', this.preTaskIdsInWorkflow ? this.preTaskIdsInWorkflow.join(',') : '')

            // Update JSP connections
            let plumbIns = JSP.JspInstance
587
            var targetId = this.nodeData.id
588 589 590 591 592 593 594 595

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

            // Update remove connections
            let currentConnects = plumbIns.getAllConnections()
            let len = currentConnects.length
            for (let i = 0; i < len; i++) {
604
              if (this.preTasksToDelete.indexOf(currentConnects[i].sourceId) > -1 && currentConnects[i].targetId === targetId) {
605 606 607 608 609 610 611
                plumbIns.deleteConnection(currentConnects[i])
                i -= 1
                len -= 1
              }
            }
          }
        }
L
ligang 已提交
612

613
        $(`#${this.nodeData.id}`).find('span').text(this.name)
614 615
        this.conditionResult.successNode[0] = this.successBranch
        this.conditionResult.failedNode[0] = this.failedBranch
L
ligang 已提交
616 617 618
        // Store the corresponding node data structure
        this.$emit('addTaskInfo', {
          item: {
619 620
            type: this.nodeData.taskType,
            id: this.nodeData.id,
L
ligang 已提交
621 622
            name: this.name,
            params: this.params,
B
break60 已提交
623
            description: this.description,
L
ligang 已提交
624
            runFlag: this.runFlag,
625
            conditionResult: this.conditionResult,
L
ligang 已提交
626 627 628
            dependence: this.dependence,
            maxRetryTimes: this.maxRetryTimes,
            retryInterval: this.retryInterval,
629
            delayTime: this.delayTime,
L
ligang 已提交
630
            timeout: this.timeout,
曹聚阳 已提交
631
            waitStartTimeout: this.waitStartTimeout,
G
gongzijian 已提交
632
            taskInstancePriority: this.taskInstancePriority,
Q
qiaozhanwei 已提交
633
            workerGroup: this.workerGroup,
634 635
            status: this.status,
            branch: this.branch
L
ligang 已提交
636 637 638
          },
          fromThis: this
        })
G
bug1  
gongzijian 已提交
639 640 641

        // set run flag
        this._setRunFlag()
L
ligang 已提交
642 643 644 645 646 647 648
      },
      /**
       * Sub-workflow selected node echo name
       */
      _onSetProcessName (name) {
        this.name = name
      },
G
bug1  
gongzijian 已提交
649 650 651
      /**
       *  set run flag
       */
652
      _setRunFlag () {
653
        let dom = $(`#${this.nodeData.id}`).find('.ban-p')
G
bug1  
gongzijian 已提交
654 655 656 657 658
        dom.html('')
        if (this.runFlag === 'FORBIDDEN') {
          dom.append(rtBantpl())
        }
      },
L
ligang 已提交
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
      /**
       * 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', {
677
          item: this.cacheBackfillItem,
L
ligang 已提交
678 679 680 681
          flag: flag,
          fromThis: this
        })
      }
682
    },
G
gongzijian 已提交
683
    watch: {
684 685 686 687
      /**
       * Watch the item change, cache the value it changes
       **/
      _item (val) {
688
        // this._cacheItem()
689
      }
G
gongzijian 已提交
690
    },
L
ligang 已提交
691 692 693 694 695
    created () {
      // Unbind copy and paste events
      JSP.removePaste()
      // Backfill data
      let taskList = this.store.state.dag.tasks
696

697
      // fillback use cacheTasks
698
      let cacheTasks = this.store.state.dag.cacheTasks
L
ligang 已提交
699
      let o = {}
700 701 702
      if (cacheTasks[this.nodeData.id]) {
        o = cacheTasks[this.nodeData.id]
        this.backfillItem = cacheTasks[this.nodeData.id]
703 704 705
      } else {
        if (taskList.length) {
          taskList.forEach(v => {
706
            if (v.id === this.nodeData.id) {
707 708 709 710
              o = v
              this.backfillItem = v
            }
          })
711
        }
712 713 714 715 716 717 718 719 720
      }
      // 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
721
        this.delayTime = o.delayTime
722
        if (o.conditionResult) {
723 724 725
          this.successBranch = o.conditionResult.successNode[0]
          this.failedBranch = o.conditionResult.failedNode[0]
        }
726
        // If the workergroup has been deleted, set the default workergroup
B
break60 已提交
727 728
        for (let i = 0; i < this.store.state.security.workerGroupsListAll.length; i++) {
          var workerGroup = this.store.state.security.workerGroupsListAll[i].id
729
          if (o.workerGroup === workerGroup) {
730
            break
731
          }
B
break60 已提交
732
        }
733
        if (o.workerGroup === undefined) {
734
          this.store.dispatch('dag/getTaskInstanceList', {
735
            pageSize: 10, pageNo: 1, processInstanceId: this.nodeData.instanceId, name: o.name
736 737 738
          }).then(res => {
            this.workerGroup = res.totalList[0].workerGroup
          })
B
break60 已提交
739 740 741
        } else {
          this.workerGroup = o.workerGroup
        }
742

743 744
        this.params = o.params || {}
        this.dependence = o.dependence || {}
Z
zhukai 已提交
745
        this.cacheDependence = o.dependence || {}
B
break60 已提交
746 747
      } else {
        this.workerGroup = this.store.state.security.workerGroupsListAll[0].id
L
ligang 已提交
748
      }
749
      this.cacheBackfillItem = JSON.parse(JSON.stringify(o))
L
ligang 已提交
750
      this.isContentBox = true
751 752

      // Init value of preTask selector
753
      let preTaskIds = $(`#${this.nodeData.id}`).attr('data-targetarr')
754 755 756 757 758 759 760
      if (!_.isEmpty(this.backfillItem)) {
        if (preTaskIds && preTaskIds.length) {
          this.backfillItem.preTasks = preTaskIds.split(',')
        } else {
          this.backfillItem.preTasks = []
        }
      }
L
ligang 已提交
761
    },
762
    mounted () {
763
      let self = this
764 765
      $('#cancelBtn').mousedown(function (event) {
        event.preventDefault()
766
        self.close()
767
      })
768
    },
L
ligang 已提交
769 770 771 772 773 774 775 776 777 778 779
    updated () {
    },
    beforeDestroy () {
    },
    destroyed () {
    },
    computed: {
      /**
       * Child workflow entry show/hide
       */
      _isGoSubProcess () {
780
        return this.nodeData.taskType === 'SUB_PROCESS' && this.name
781 782
      },

783
      // Define the item model
784 785
      _item () {
        return {
786 787
          type: this.nodeData.taskType,
          id: this.nodeData.id,
788 789 790
          name: this.name,
          description: this.description,
          runFlag: this.runFlag,
Z
zhukai 已提交
791
          dependence: this.cacheDependence,
792 793
          maxRetryTimes: this.maxRetryTimes,
          retryInterval: this.retryInterval,
794
          delayTime: this.delayTime,
795
          timeout: this.timeout,
曹聚阳 已提交
796
          waitStartTimeout: this.waitStartTimeout,
797
          taskInstancePriority: this.taskInstancePriority,
Q
qiaozhanwei 已提交
798
          workerGroup: this.workerGroup,
799 800
          successBranch: this.successBranch,
          failedBranch: this.failedBranch
801
        }
L
ligang 已提交
802 803 804 805 806
      }
    },
    components: {
      mMr,
      mShell,
X
xsbai 已提交
807
      mWaterdrop,
L
ligang 已提交
808 809 810 811 812
      mSubProcess,
      mProcedure,
      mSql,
      mLog,
      mSpark,
813
      mFlink,
L
ligang 已提交
814 815
      mPython,
      mDependent,
816
      mHttp,
817
      mDatax,
_和's avatar
_和 已提交
818
      mSqoop,
819
      mConditions,
L
ligang 已提交
820 821
      mSelectInput,
      mTimeoutAlarm,
曹聚阳 已提交
822
      mDependentTimeout,
G
gongzijian 已提交
823
      mPriority,
824
      mWorkerGroups,
825
      mPreTasks
L
ligang 已提交
826 827 828 829 830
    }
  }
</script>

<style lang="scss" rel="stylesheet/scss">
G
gongzijian 已提交
831
  @import "./formModel";
832 833 834 835 836
  .ans-radio-disabled {
    .ans-radio-inner:after {
      background-color: #6F8391
    }
  }
L
ligang 已提交
837
</style>