repeal-form.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <hc-new-dialog widths="30rem" :show="isShow" title="填写驳回原因" @close="modalClose">
  3. <div class="relative">
  4. <el-input v-model="meterTaskRepealDesc" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" placeholder="请描述废除整个任务的原因" />
  5. </div>
  6. <template #footer>
  7. <div class="hc-task-notes-footer">
  8. <el-button @click="modalClose">取消驳回</el-button>
  9. <el-button type="primary" :loading="confirmLoading" @click="confirmClick">确定驳回</el-button>
  10. </div>
  11. </template>
  12. </hc-new-dialog>
  13. </template>
  14. <script setup>
  15. import { ref, watch } from 'vue'
  16. import { useAppStore } from '~src/store'
  17. import mainApi from '~api/tasks/hc-data'
  18. const props = defineProps({
  19. info: {
  20. type: Object,
  21. default: () => ({}),
  22. },
  23. })
  24. //事件
  25. const emit = defineEmits(['finish', 'close'])
  26. const useAppState = useAppStore()
  27. const projectId = ref(useAppState.getProjectId || '')
  28. const contractId = ref(useAppState.getContractId || '')
  29. //双向绑定
  30. // eslint-disable-next-line no-undef
  31. const isShow = defineModel('modelValue', {
  32. default: false,
  33. })
  34. //监听数据
  35. const taskInfo = ref(props.info)
  36. watch(() => props.info, (row) => {
  37. taskInfo.value = row
  38. }, { deep: true })
  39. //监听
  40. watch(isShow, (val) => {
  41. if (val) {
  42. meterTaskRepealDesc.value = ''
  43. }
  44. })
  45. //审批表单
  46. const meterTaskRepealDesc = ref('')
  47. //确定保存
  48. const confirmLoading = ref(false)
  49. const confirmClick = async () => {
  50. const repealDesc = meterTaskRepealDesc.value
  51. if (!repealDesc) {
  52. window.$message.error('请先填写驳回原因')
  53. return
  54. }
  55. //发起请求
  56. confirmLoading.value = true
  57. const { error, code, msg } = await mainApi.taskRepeal({
  58. taskId: taskInfo.value.id,
  59. projectId: projectId.value,
  60. contractId: contractId.value,
  61. meterTaskRepealDesc: repealDesc,
  62. })
  63. confirmLoading.value = false
  64. if (!error && code === 200) {
  65. window.$message.success('提交成功')
  66. emit('finish')
  67. modalClose()
  68. } else {
  69. window.$message.error(msg ?? '提交失败')
  70. }
  71. }
  72. //取消关闭
  73. const modalClose = () => {
  74. isShow.value = false
  75. meterTaskRepealDesc.value = ''
  76. emit('close')
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .hc-task-notes-footer {
  81. position: relative;
  82. text-align: center;
  83. }
  84. </style>