mutations.js 3.5 KB
Newer Older
L
ligang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 * 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.
 */

import _ from 'lodash'

export default {
  setProjectName (state, payload) {
    state.projectName = payload
  },
  /**
   * set tasks
   * */
  setTasks (state, payload) {
    state.tasks = payload
  },
  /**
   * set locations
   * */
  setLocations (state, payload) {
34
    state.locations = payload
L
ligang 已提交
35 36 37 38 39
  },
  /**
   * add locations
   * */
  addLocations (state, payload) {
40
    state.locations = Object.assign(state.locations, {}, payload)
L
ligang 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53
  },
  /**
   * set connects
   * */
  setConnects (state, payload) {
    state.connects = payload
  },
  /**
   * set dag name
   */
  setName (state, payload) {
    state.name = payload
  },
G
gongzijian 已提交
54 55 56 57 58 59
  /**
   * set timeout
   */
  setTimeout (state, payload) {
    state.timeout = payload
  },
60 61 62 63 64 65
  /**
   * set tenantId
   */
  setTenantId (state, payload) {
    state.tenantId = payload
  },
L
ligang 已提交
66 67 68 69 70 71 72
  /**
   * set global params
   */
  setGlobalParams (state, payload) {
    state.globalParams = payload
  },
  /**
B
break60 已提交
73
   * set description
L
ligang 已提交
74 75
   */
  setDesc (state, payload) {
B
break60 已提交
76
    state.description = payload
L
ligang 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
  },
  /**
   * Whether to update the process definition
   */
  setSyncDefine (state, payload) {
    state.syncDefine = payload
  },
  /**
   * Whether to edit the parameters
   */
  setIsEditDag (state, payload) {
    state.isEditDag = payload
  },

  /**
   * edit state
   */
  setIsDetails (state, payload) {
    state.isDetails = payload
  },

  /**
   * reset params
   */
  resetParams (state, payload) {
    $('#canvas').html('')
    state.globalParams = payload && payload.globalParams || []
    state.tasks = payload && payload.tasks || []
    state.name = payload && payload.name || ''
B
break60 已提交
106
    state.description = payload && payload.description || ''
G
gongzijian 已提交
107
    state.timeout = payload && payload.timeout || 0
108
    state.tenantId = payload && payload.tenantId || -1
L
ligang 已提交
109 110
    state.processListS = payload && payload.processListS || []
    state.resourcesListS = payload && payload.resourcesListS || []
111
    state.projectListS = payload && payload.projectListS || []
L
ligang 已提交
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    state.isDetails = payload && payload.isDetails || false
    state.runFlag = payload && payload.runFlag || ''
    state.locations = payload && payload.locations || {}
    state.connects = payload && payload.connects || []
  },
  /**
   * add task
   * object {}
   */
  addTasks (state, payload) {
    let i = _.findIndex(state.tasks, v => v.id === payload.id)
    if (i !== -1) {
      state.tasks[i] = Object.assign(state.tasks[i], {}, payload)
    } else {
      state.tasks.push(payload)
    }
    let dom = $(`#${payload.id}`)
    state.locations[payload.id] = _.assign(state.locations[payload.id], {
      name: dom.find('.name-p').text(),
      targetarr: dom.attr('data-targetarr'),
      x: parseInt(dom.css('left'), 10),
      y: parseInt(dom.css('top'), 10)
    })
  }
}