xiangpei
2025-04-08 b25e78e9887935e5955f0c5ad798104eca444016
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
106
107
108
109
110
111
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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<template>
  <div>
    <el-dialog
      :title="'修改任务:' + currentTask.beforeNodeName"
      :visible.sync="open"
      :destroy-on-close="true"
      :fullscreen="true"
      :before-close="close">
      <el-row>
        <el-col :span="16">
          <div v-if="currentTask != null && currentTask.formJsonObj != null">
            <v-form-render :form-data="currentTask.formJsonObj.formJson" ref="form"/>
          </div>
        </el-col>
        <el-col :span="8">
          <div style="padding-left: 40px;min-height: 200px">
            <div style="position: relative">
              <div v-if="currentTask.taskStatus == '已完成'">当前状态:{{currentTask.taskStatus}}<span v-show="editForm.nowStatus">--->{{editForm.nowStatus}}</span>,
                <el-button type="primary" size="small" @click="openJump">改为跳过</el-button>
                <el-button type="primary" size="small" @click="openWait">改为容缺</el-button>
                <el-button type="text" size="small" @click="cancelStatus" v-show="editForm.nowStatus">取消状态更改</el-button>
              </div>
              <div v-else-if="currentTask.taskStatus == '跳过'">当前状态:{{currentTask.taskStatus}}<span v-show="editForm.nowStatus">--->{{editForm.nowStatus}}</span>,
                <el-button type="primary" size="small" @click="openWait">改为容缺</el-button>
                <el-button type="text" size="small" @click="cancelStatus" v-show="editForm.nowStatus">取消状态更改</el-button>
              </div>
              <div v-else-if="currentTask.taskStatus == '容缺'">当前状态:{{currentTask.taskStatus}}<span v-show="editForm.nowStatus">--->{{editForm.nowStatus}}</span>,
                <el-button type="primary" size="small" @click="openJump">改为跳过</el-button>
                <el-button type="text" size="small" @click="cancelStatus" v-show="editForm.nowStatus">取消状态更改</el-button>
              </div>
              <el-button style="position: absolute;right: 0px; top: 0px" type="primary" size="small" @click="save">保 存</el-button>
            </div>
            <div style="margin-top: 15px">
              <el-form v-show="showJumpForm" :model="taskJumpForm" :rules="jumpRules" ref="jumpForm" label-position="left">
                <el-form-item label="跳过说明" prop="desc">
                  <el-input v-model="taskJumpForm.desc"></el-input>
                </el-form-item>
              </el-form>
              <el-form v-show="showWaitForm" :model="taskWaitForm" :rules="waitRules" ref="waitForm" label-position="left">
                <el-form-item label="容缺说明" prop="desc">
                  <el-input v-model="taskWaitForm.desc"></el-input>
                </el-form-item>
              </el-form>
            </div>
          </div>
          <div>
            <log-time-line v-if="currentTask.events && currentTask.events.length > 0" :log-list="currentTask.events"/>
          </div>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>
 
<script>
import {currentFlowTaskForm} from "@/api/flowable/todo";
import LogTimeLine from "@/views/projectProcess/components/LogTimeLine";
import {editTask} from "@/api/projectProcess/projectProcess";
 
export default {
  name: "EditTask",
  components: {LogTimeLine},
  props: {
    taskId: {
      type: String,
      required: true
    },
    open: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    taskId: {
      handler(newV) {
        if (newV) {
          currentFlowTaskForm({taskId: newV}).then(res => {
            this.currentTask = res.data
            this.editForm.originalStatus = res.data.taskStatus
            this.editForm.taskId = newV
            this.formJson = this.currentTask.formJsonObj.formJson
            this.$nextTick(() => {
              this.$refs.form.setFormJson(this.currentTask.formJsonObj.formJson);
              this.$refs.form.setFormData(this.currentTask.formJsonObj);
            })
          })
        }
      }
    }
  },
  data() {
    return {
      showJumpForm: false,
      showWaitForm: false,
      jumpRules: {
        desc: [
          { required: true, message: '请输入跳过说明', trigger: 'blur' },
        ]
      },
      waitRules: {
        desc: [
          { required: true, message: '请输入容缺说明', trigger: 'blur' },
        ]
      },
      currentTask: {
 
      },
      taskJumpForm: {
        desc: ''
      },
      taskWaitForm: {
        desc: ''
      },
      formJson: {}, // 表单json
      formData: {}, // 填写的表单数据,
      editForm: {
        taskId: '',
        variables: null,
        originalStatus: '',
        nowStatus: '',
        taskJumpForm: null,
        taskWaitForm: null
      }
    }
  },
  methods: {
    cancelStatus() {
      this.editForm.nowStatus = ''
      this.showWaitForm = false
      this.showJumpForm = false
      this.editForm.taskWaitForm = {}
      this.editForm.taskJumpForm = {}
    },
    openJump() {
      this.showWaitForm = false
      this.editForm.taskWaitForm = {}
      this.editForm.nowStatus = '跳过'
      this.showJumpForm = true
    },
    openWait() {
      this.showJumpForm = false
      this.editForm.taskJumpForm = {}
      this.editForm.nowStatus = '容缺'
      this.showWaitForm = true
    },
    save() {
      this.$refs.form.getFormData().then(formData => {
        this.formData = formData
        const param = {
          formJson:  this.formJson,
        }
        // 复制对象的属性值给新的对象
        Object.assign(param, formData);
        this.editForm.variables = param
        if (this.editForm.nowStatus) {
          if (this.editForm.nowStatus == '跳过') {
            this.$refs['jumpForm'].validate((valid) => {
              if (valid) {
                this.editForm.taskJumpForm = this.taskJumpForm
                editTask(this.editForm).then(res => {
                  this.$message.success("修改成功")
                  this.close()
                })
              }
            })
          } else if (this.editForm.nowStatus == '容缺') {
            this.$refs['waitForm'].validate((valid) => {
              if (valid) {
                this.editForm.taskWaitForm = this.taskWaitForm
                editTask(this.editForm).then(res => {
                  this.$message.success("修改成功")
                  this.close()
                })
              }
            })
          }
        } else {
          this.editForm.nowStatus = this.editForm.originalStatus
          editTask(this.editForm).then(res => {
            this.$message.success("修改成功")
            this.close()
          })
        }
      })
    },
    close() {
      this.$emit("close")
    }
  }
}
</script>
 
<style scoped>
 
</style>