ZaiZai hai 1 ano
pai
achega
17bef2b164

+ 24 - 0
src/api/modules/tasks/hc-data.js

@@ -97,4 +97,28 @@ export default {
             data: form,
         }, false)
     },
+    //单条数据同意或驳回
+    async taskAudit(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/data/audit',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    //同意审批
+    async taskApprove(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/approve',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    //任务废除(任务撤销、驳回审批)
+    async taskRepeal(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/repeal',
+            method: 'post',
+            data: form,
+        }, false)
+    },
 }

+ 1 - 1
src/views/tasks/components/hc-data/middlepay-form.vue

@@ -383,6 +383,6 @@ const attachmentUploadDel = ({ file }, resolve) => {
 
 <style lang="scss" scoped>
 .hc-task-form {
-
+    position: relative;
 }
 </style>

+ 54 - 17
src/views/tasks/components/hc-data/task-form.vue

@@ -12,14 +12,20 @@
         <HcStartWorkForm v-if="taskInfo.meterType === 3" :table="tableInfo" :info="taskInfo" :is-edit="isEdits" />
         <HcAlterForm v-if="taskInfo.meterType === 4" :table="tableInfo" :info="taskInfo" :is-edit="isEdits" />
         <hc-card-item class="hc-card-footer mt-3">
-            <div class="relative">
-                <el-radio-group v-model="approval" size="large">
+            <template #header>
+                <el-radio-group v-model="taskForm.auditStatus" size="large">
                     <el-radio :label="1">同意</el-radio>
                     <el-radio :label="2">驳回</el-radio>
                 </el-radio-group>
-            </div>
-            <div class="relative mt-2">
-                <el-input v-model="remark" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea" placeholder="请描述废除整条任务的原因" />
+            </template>
+            <template #extra>
+                <el-link type="primary" :disabled="taskForm.auditStatus === 0" @click="tableSubmitClick">
+                    <hc-icon name="check" />
+                    <span class="ml-1">这里点提交</span>
+                </el-link>
+            </template>
+            <div class="relative">
+                <el-input v-model="taskForm.repealDesc" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea" placeholder="请描述废除整条任务的原因" />
             </div>
         </hc-card-item>
     </div>
@@ -27,6 +33,7 @@
 
 <script setup>
 import { onMounted, ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
 import HcMiddlepayForm from './middlepay-form.vue'
 import HcMassForm from './mass-form.vue'
 import HcStartWorkForm from './start-work-form.vue'
@@ -49,6 +56,15 @@ const props = defineProps({
     },
 })
 
+//事件
+const emit = defineEmits(['finish'])
+
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId || '')
+const contractId = ref(useAppState.getContractId || '')
+const taskInfo = ref(props.info)
+const tableInfo = ref(props.table)
+
 //监听可否编辑
 const isEdits = ref(props.isEdit)
 watch(() => props.isEdit, (val) => {
@@ -60,25 +76,46 @@ watch(() => [
     props.table,
     props.info,
 ], ([table, row]) => {
-    setTaskInfo(table, row)
+    tableInfo.value = table
+    taskInfo.value = row
+    taskForm.value = { auditStatus: table.status ?? 0, repealDesc: table.repealDesc ?? '' }
 }, { deep: true })
 
 //渲染完成
 onMounted(() => {
-    setTaskInfo(props.table, props.info)
+    const { status, repealDesc } = tableInfo.value
+    taskForm.value = { auditStatus: status ?? 0, repealDesc: repealDesc ?? '' }
 })
 
-//设置任务信息
-const taskInfo = ref({})
-const tableInfo = ref({})
-const setTaskInfo = async (table, row) => {
-    tableInfo.value = table
-    taskInfo.value = row
-}
+//审批表单
+const taskForm = ref({ auditStatus: 0, repealDesc: '' })
 
-//同意还是驳回
-const approval = ref('')
-const remark = ref('')
+//单条提交
+const tableSubmitClick = async () => {
+    const { auditStatus, repealDesc } = taskForm.value
+    if (auditStatus === 0) {
+        window.$message.error('请先选择同意或驳回')
+        return
+    }
+    if (auditStatus === 2 && !repealDesc) {
+        window.$message.error('请先填写驳回原因')
+        return
+    }
+    //发起请求
+    const { error, code, msg } = await mainApi.taskAudit({
+        ...taskForm.value,
+        dataId: tableInfo.value.id,
+        taskId: taskInfo.value.id,
+        projectId: projectId.value,
+        contractId: contractId.value,
+    })
+    if (!error && code === 200) {
+        window.$message.success('提交成功')
+        emit('finish')
+    } else {
+        window.$message.error(msg ?? '提交失败')
+    }
+}
 </script>
 
 <style lang="scss" scoped>

+ 8 - 3
src/views/tasks/components/hc-data/task-review.vue

@@ -48,7 +48,7 @@
                 </div>
                 <div :id="`hc_task_form_${uuid}`" class="hc-task-form">
                     <hc-body class="hc-task-body-card" padding="10px" scrollbar>
-                        <HcTaskForm :table="tableInfo" :info="rowInfo" :is-edit="tabsKey === 1" />
+                        <HcTaskForm :table="tableInfo" :info="rowInfo" :is-edit="tabsKey === 1" @finish="taskFormFinish" />
                     </hc-body>
                 </div>
             </div>
@@ -232,15 +232,20 @@ const taskNotesFinish = () => {
     getTableDetail()
 }
 
+//单条审批
+const taskFormFinish = () => {
+    getTableDetail()
+}
+
 //确认审批
 const confirmLoading = ref(false)
-const confirmClick = () => {
+const confirmClick = async () => {
     //emit('finish')
 }
 
 //驳回审批
 const rejectionLoading = ref(false)
-const rejectionClick = () => {
+const rejectionClick = async () => {
 
 }