luohairen
2024-11-26 100186edb96c3fa913779b64471dae6ea1b7aca7
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
<template>
  <div>
    <el-dialog
      title="流程启动"
      :visible.sync="show"
      width="750px"
      :before-close="handleClose">
      <div>
        <div style="display: flex; flex-direction: row; justify-content: center; align-items: center;font-size: 24px">
          <div>当前流程:</div>
          <div v-if="nowProcessId">{{nowProcessName}}</div>
          <div v-else>未绑定流程</div>
        </div>
      </div>
      <div style="margin-top: 20px">
        <el-table
          ref="myTable"
          :data="processList"
          tooltip-effect="dark"
          style="width: 100%"
          @selection-change="handleSelectionChange">
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>
          <el-table-column
            prop="name"
            label="流程名称"
          >
          </el-table-column>
          <el-table-column
            prop="category"
            label="流程类型"
          >
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="startProcess">启动</el-button>
        <el-button type="primary" @click="changeProcess">变更</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
export default {
  name: "RunProcess",
  props: {
    show: {
      require: true,
      type: Boolean
    },
    projectId: {
      require: true,  // 项目id
      type: Number
    },
    processList: {  // 流程列表
      require: true,
      type: Array
    },
    nowProcessId: {  // 当前项目绑定的流程id
      require: true,
      type: String
    },
    nowProcessName: {
      require: true,
      type: String
    }
  },
  watch: {
    // 监听回显值
    nowProcessId(newVal, oldVal) {
      this.processList.forEach((item,index) => {
        if(item.id == newVal){
          this.$nextTick(() => {
            this.$refs.myTable.toggleRowSelection(item);
          })
        }
      })
    }
  },
  data() {
    return {
      selectProcessId: '',  // 组件内部选中的流程id
    }
  },
  methods: {
    // 实现el-table单选
    handleSelectionChange(val) {
      console.log(val, "选中")
      if (val.length > 1) {
        this.$refs.myTable.clearSelection();
        this.$refs.myTable.toggleRowSelection(val.pop());
      }
      if(val.length != 0){
        this.selectProcessId = val[val.length - 1].id;
      }
    },
    // 启动流程
    startProcess() {
 
    },
    // 变更流程
    changeProcess() {
 
    },
    handleClose() {
      this.$emit("close")
    }
  }
}
</script>
 
<style scoped>
/deep/ .el-table__header-wrapper .el-checkbox{
  display:none
}
</style>