consentOrRefuseDialog.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <!-- 同意 拒绝 弹窗 同意/拒绝审批 -->
  3. <el-dialog v-model="operaVisibleDialog" class="le-dialog" :title="currentTip + '审批'" width="700" destroy-on-close :close-on-click-modal="false">
  4. <el-form ref="formRef" v-loading="uploadLoading" label-position="top" element-loading-text="图片上传中..." :model="form" label-width="80px">
  5. <el-form-item label="审批意见" prop="content" :rules="[{ required: true, message: '审批意见不能为空' }]">
  6. <el-input v-model="form.content" type="textarea" placeholder="请输入内容" maxlength="64" show-word-limit> </el-input>
  7. </el-form-item>
  8. <el-form-item v-if="currentType === 'reject'" prop="termination">
  9. <el-checkbox v-model="form.termination" label="终止流程" />
  10. </el-form-item>
  11. <el-form-item v-if="false" prop="attachment" label="附件" class="example-img-box">
  12. <!--'.docx', '.doc', '.pptx', '.ppt', '.xlsx', '.xls', '.zip', '.csv', '.pdf', '.png', '.jpg' 因前端不支持图片以外格式,所以注释 -->
  13. <FileUpload
  14. v-model="form.attachment"
  15. source="project"
  16. return="array"
  17. :limit="5"
  18. :file-size="10"
  19. :accept="['.png', '.jpg']"
  20. @success="clearValidate"
  21. />
  22. </el-form-item>
  23. </el-form>
  24. <template #footer>
  25. <span class="dialog-footer">
  26. <el-button :loading="btnDisabled" class="dialog-btn" @click="closeDialog">取 消</el-button>
  27. <el-button type="primary" :loading="btnDisabled" class="dialog-btn" @click="submitForm">确 定</el-button>
  28. </span>
  29. </template>
  30. </el-dialog>
  31. </template>
  32. <script setup>
  33. import { computed, reactive, ref } from 'vue'
  34. import FileUpload from '@/components/FileUpload.vue'
  35. import { processConsentTaskApi, processRejectionTaskApi } from '@/api/flow/processTask'
  36. import { ElMessage } from 'element-plus'
  37. import {debounce} from "lodash-es";
  38. const props = defineProps({
  39. // 弹窗是否显示
  40. modelValue: {
  41. type: Boolean,
  42. default: false
  43. },
  44. // 审核id
  45. taskId: {
  46. type: String,
  47. default: undefined
  48. },
  49. // 审核类型 同意(agree) or 拒绝(reject)
  50. currentType: {
  51. type: String,
  52. default: 'agree'
  53. },
  54. // 额外 表单数据
  55. formData: {
  56. type: Object,
  57. default: () => ({})
  58. }
  59. })
  60. const btnDisabled = ref(false)
  61. const form = reactive({
  62. content: ''
  63. // attachment: []
  64. })
  65. const formRef = ref(null)
  66. const uploadLoading = ref(false)
  67. const $myEmit = defineEmits(['update:modelValue', 'successCb'])
  68. const submitForm = debounce(() => {
  69. const formData = { taskId: props.taskId, ...props.formData, ...form }
  70. formRef.value
  71. .validate()
  72. .then(async valid => {
  73. if (valid) {
  74. btnDisabled.value = true
  75. const isAgree = props.currentType === 'agree'
  76. let data = null
  77. if (isAgree) {
  78. // 同意
  79. data = await processConsentTaskApi(formData)
  80. } else {
  81. // 拒绝
  82. data = await processRejectionTaskApi(formData)
  83. }
  84. if (!data) {
  85. ElMessage({
  86. message: '执行失败',
  87. type: 'error'
  88. })
  89. return false
  90. }
  91. $myEmit('successCb')
  92. closeDialog()
  93. btnDisabled.value = false
  94. }
  95. })
  96. .catch(err => {
  97. btnDisabled.value = false
  98. })
  99. })
  100. const closeDialog = () => {
  101. $myEmit('update:modelValue', false)
  102. }
  103. const operaVisibleDialog = computed({
  104. get() {
  105. return props.modelValue
  106. },
  107. set(val) {
  108. $myEmit('update:modelValue', val)
  109. }
  110. })
  111. const currentTip = computed(() => {
  112. return props.currentType === 'agree' ? '同意' : '拒绝'
  113. })
  114. const clearValidate = () => {}
  115. </script>
  116. <style scoped lang="scss">
  117. .example-img-box {
  118. width: 100% !important;
  119. }
  120. .example-img-box .el-form-item__content {
  121. display: block;
  122. }
  123. </style>