Browse Source

任务管理

ZaiZai 1 year ago
parent
commit
19b6da60ee

+ 95 - 0
src/views/tasks/components/hc-data/repeal-form.vue

@@ -0,0 +1,95 @@
+<template>
+    <hc-new-dialog widths="30rem" :show="isShow" title="填写驳回原因" @close="modalClose">
+        <div class="relative">
+            <el-input v-model="meterTaskRepealDesc" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" placeholder="请描述废除整个任务的原因" />
+        </div>
+        <template #footer>
+            <div class="hc-task-notes-footer">
+                <el-button @click="modalClose">取消驳回</el-button>
+                <el-button type="primary" :loading="confirmLoading" @click="confirmClick">确定驳回</el-button>
+            </div>
+        </template>
+    </hc-new-dialog>
+</template>
+
+<script setup>
+import { ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
+import mainApi from '~api/tasks/hc-data'
+
+const props = defineProps({
+    info: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+//事件
+const emit = defineEmits(['finish', 'close'])
+
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId || '')
+const contractId = ref(useAppState.getContractId || '')
+
+//双向绑定
+// eslint-disable-next-line no-undef
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听数据
+const taskInfo = ref(props.info)
+watch(() => props.info, (row) => {
+    taskInfo.value = row
+}, { deep: true })
+
+//监听
+watch(isShow, (val) => {
+    if (val) {
+        meterTaskRepealDesc.value = ''
+    }
+})
+
+//审批表单
+const meterTaskRepealDesc = ref('')
+
+//确定保存
+const confirmLoading = ref(false)
+const confirmClick = async () => {
+    const repealDesc = meterTaskRepealDesc.value
+    if (!repealDesc) {
+        window.$message.error('请先填写驳回原因')
+        return
+    }
+    //发起请求
+    confirmLoading.value = true
+    const { error, code, msg } = await mainApi.taskRepeal({
+        taskId: taskInfo.value.id,
+        projectId: projectId.value,
+        contractId: contractId.value,
+        meterTaskRepealDesc: repealDesc,
+    })
+    confirmLoading.value = false
+    if (!error && code === 200) {
+        window.$message.success('提交成功')
+        emit('finish')
+        modalClose()
+    } else {
+        window.$message.error(msg ?? '提交失败')
+    }
+}
+
+//取消关闭
+const modalClose = () => {
+    isShow.value = false
+    meterTaskRepealDesc.value = ''
+    emit('close')
+}
+</script>
+
+<style lang="scss" scoped>
+.hc-task-notes-footer {
+    position: relative;
+    text-align: center;
+}
+</style>

+ 10 - 5
src/views/tasks/components/hc-data/task-review.vue

@@ -55,13 +55,15 @@
         </div>
         <template #footer>
             <div class="hc-task-dialog-footer">
-                <el-button :loading="rejectionLoading" @click="rejectionClick">驳回审批</el-button>
+                <el-button @click="rejectionClick">驳回审批</el-button>
                 <el-button type="primary" :loading="confirmLoading" @click="confirmClick">同意审批</el-button>
             </div>
         </template>
     </hc-new-dialog>
     <!-- 批注 -->
     <HcTaskNotes v-model="isNotesShow" :table="tableNoteInfo" :info="rowInfo" @finish="taskNotesFinish" />
+    <!-- 驳回 -->
+    <HcRepealForm v-model="isRepealShow" :info="rowInfo" @finish="taskRepealFinish" />
 </template>
 
 <script setup>
@@ -70,6 +72,7 @@ import { getArrValue, getObjValue, getRandom } from 'js-fast-way'
 import { useAppStore } from '~src/store'
 import HcTaskForm from './task-form.vue'
 import HcTaskNotes from './task-notes.vue'
+import HcRepealForm from './repeal-form.vue'
 import mainApi from '~api/tasks/hc-data'
 
 const props = defineProps({
@@ -154,7 +157,6 @@ const setTaskInfo = () => {
 const isLoading = ref(false)
 const getTableDetail = async () => {
     isLoading.value = true
-    rejectionLoading.value = true
     confirmLoading.value = true
     //获取数据
     const { data } = await mainApi.getDetail(rowInfo.value.id)
@@ -172,7 +174,6 @@ const getTableDetail = async () => {
     })
     //关闭加载状态
     isLoading.value = false
-    rejectionLoading.value = false
     confirmLoading.value = false
 }
 
@@ -261,16 +262,20 @@ const confirmClick = async () => {
 }
 
 //驳回审批
-const rejectionLoading = ref(false)
+const isRepealShow = ref(false)
 const rejectionClick = async () => {
+    isRepealShow.value = true
+}
 
+//驳回完成
+const taskRepealFinish = () => {
+    getTableDetail()
 }
 
 //取消审批
 const cancelClick = () => {
     isShow.value = false
     isLoading.value = false
-    rejectionLoading.value = false
     confirmLoading.value = false
     tableColumn.value = []
     tableData.value = []