fuliqi
2024-11-29 ee5553f438eadb34a3261b718145e9e7f8a27580
src/views/projectProcess/components/RunProcess.vue
@@ -10,7 +10,7 @@
      <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-if="nowProcessId">{{selectProcessName}}</div>
          <div v-else>未绑定流程</div>
        </div>
      </div>
@@ -74,7 +74,7 @@
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="danger" @click="startProcess">启动</el-button>
        <el-button type="danger" @click="startProcess" :disable="!this.selectProcessId">启动流程</el-button>
        <el-button type="primary" @click="changeProcess">变更</el-button>
      </span>
    </el-dialog>
@@ -82,7 +82,7 @@
</template>
<script>
import {projectSetProcess} from "@/api/projectProcess/projectProcess";
import {projectSetProcess, startProcess} from "@/api/projectProcess/projectProcess";
export default {
  dicts: ['sys_project_type', 'sys_funding_type', 'sys_investment_type', 'sys_key_categories'],
@@ -103,48 +103,54 @@
    nowProcessId: {  // 当前项目绑定的流程id
      required: true,
      type: String
    },
    nowProcessName: {
      required: true,
      type: String
    }
  },
  watch: {
    // 监听回显值
    nowProcessId(newVal, oldVal) {
      console.log("传入值:", newVal, this.processList)
      this.processList.forEach((item,index) => {
        console.log(item.id, newVal, item.id === newVal)
        if(item.id === newVal){
          console.log("wwwwwww")
          this.selectProcessId = newVal
          this.$nextTick(() => {
            this.$refs.myTable.toggleRowSelection(item);
          })
        }
      })
    projectInfo: {
      handler(newVal, oldVal) {
        console.log("传入值:", newVal, this.processList)
        this.setSelect(this.nowProcessId)
      },
      deep: true
    }
  },
  data() {
    return {
      selectProcessId: '',  // 组件内部选中的流程id
      selectProcessName: '',  // 组件内部选中的流程id
    }
  },
  methods: {
    setSelect(value) {
      console.log("调用值:", value)
      this.processList.forEach((item,index) => {
        console.log(item.id, value, item.id === value)
        if(item.id === value){
          this.selectProcessName = item.name
          this.$nextTick(() => {
            this.$refs.myTable.toggleRowSelection(item);
          })
        }
      })
    },
    // 实现el-table单选
    handleSelectionChange(val) {
      console.log(val, "选中")
      if (val.length > 1) {
        this.$refs.myTable.clearSelection();
        this.$refs.myTable.toggleRowSelection(val.pop());
        this.$refs.myTable.toggleRowSelection(val[val.length - 1]);
      }
      if(val.length != 0){
        this.selectProcessId = val[val.length - 1].id;
        console.log("选中id:", this.selectProcessId)
      }
    },
    // 启动流程
    startProcess() {
      startProcess(this.projectInfo.projectId, this.selectProcessId).then(res => {
        this.$message.success(res.msg);
      })
    },
    // 变更流程
    changeProcess() {
@@ -162,6 +168,8 @@
      })
    },
    handleClose() {
      this.selectProcessId = ""
      this.selectProcessName = ""
      this.$emit("close")
    }
  }