copyConfig.vue 1.83 KB
<template>
  <el-dialog v-model="show" title="复制流程" append-to-body width="300px">
    <el-form ref="formRef" :model="form" :rules="rules" label-width="50px">
      <el-form-item prop="classifys">
        <el-checkbox-group v-model="form.classifys">
          <div v-for="t in typeArr" :key="t.value">
            <el-checkbox v-show="t.show" :label="t.value">{{ t.label }}</el-checkbox>
          </div>
        </el-checkbox-group>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>

import { getCurrentInstance, ref, toRefs } from 'vue'
import { reactive } from '@vue/runtime-core'
import { copyWfConfig } from '@/api/workflow/config'
import _ from 'lodash'

const { proxy } = getCurrentInstance()

const show = ref(false)
const typeArr = ref([])

const data = reactive({
  form: {},
  rules: {
    classifys: [{ required: true, message: '复制对象不能为空', trigger: 'change' }]
  }
})
const { form, rules } = toRefs(data)

/** 提交按钮 */
function submitForm() {
  proxy.$refs['formRef'].validate(valid => {
    if (valid) {
      copyWfConfig(form.value).then(() => {
        proxy.$modal.msgSuccess('复制成功')
        show.value = false
      })
    }
  })
}

/** 取消按钮 */
function cancel() {
  show.value = false
}

function open(wkId, approvalTypeArr, excludeType) {
  proxy.resetForm('formRef')
  form.value = {
    id: wkId,
    classifys: []
  }

  _.each(approvalTypeArr, (t) => {
    t.show = true
    if (t.value == excludeType) {
      t.show = false
    }
  })
  typeArr.value = approvalTypeArr
  show.value = true
}

defineExpose({
  open
})

</script>

<style scoped>

</style>