Browse Source

任务管理

ZaiZai 1 year ago
parent
commit
cab4367c4d

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

@@ -81,4 +81,20 @@ export default {
             params: { id },
         }, false)
     },
+    //批注信息列表
+    async taskCommentList(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/comment/list',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    //批注信息新增或修改
+    async taskCommentSubmit(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/comment/submit',
+            method: 'post',
+            data: form,
+        }, false)
+    },
 }

+ 64 - 18
src/views/tasks/components/hc-data/task-notes.vue

@@ -1,20 +1,23 @@
 <template>
     <hc-new-dialog v-model="isShow" ui="hc-task-notes-dialog" is-table widths="42rem" title="批注信息" @close="cancelClick">
         <div class="hc-task-notes-body">
-            <div class="notes-content">
+            <div v-if="tableNotes.length > 0" class="notes-content">
                 <el-scrollbar>
-                    <div v-for="item in 10" class="task-notes-item">
+                    <div v-for="item in tableNotes" :key="item.id" class="task-notes-item">
                         <div class="header">
-                            <div class="col">批注人:系统管理员</div>
-                            <div class="col">批准时间:2023-12-18</div>
+                            <div class="col">批注人:{{ item.userName }}</div>
+                            <div class="col">批准时间:{{ item.createTime }}</div>
                         </div>
                         <div class="content">
                             <div class="col">批注内容:</div>
-                            <div class="text">内容</div>
+                            <div class="text">{{ item.comment }}</div>
                         </div>
                     </div>
                 </el-scrollbar>
             </div>
+            <div v-else class="notes-content">
+                <hc-no-data />
+            </div>
             <div class="notes-action">
                 <el-input v-model="formNotes" type="textarea" resize="none" placeholder="批注信息" />
             </div>
@@ -22,17 +25,24 @@
         <template #footer>
             <div class="hc-task-notes-footer">
                 <el-button @click="cancelClick">取消批注</el-button>
-                <el-button type="primary" @click="confirmClick">确定批注</el-button>
+                <el-button type="primary" :loading="confirmLoading" @click="confirmClick">确定批注</el-button>
             </div>
         </template>
     </hc-new-dialog>
 </template>
 
 <script setup>
+import { getArrValue } from 'js-fast-way'
 import { ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
+import mainApi from '~api/tasks/hc-data'
 
 const props = defineProps({
-    option: {
+    info: {
+        type: Object,
+        default: () => ({}),
+    },
+    table: {
         type: Object,
         default: () => ({}),
     },
@@ -41,6 +51,10 @@ const props = defineProps({
 //事件
 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', {
@@ -48,12 +62,17 @@ const isShow = defineModel('modelValue', {
 })
 
 //监听
-const options = ref(props.row)
-const taskInfo = ref({})
-
-watch(() => props.option, (val) => {
-    options.value = val
-}, { immediate: true, deep: true })
+const taskInfo = ref(props.info)
+const tableInfo = ref(props.table)
+
+//监听数据
+watch(() => [
+    props.table,
+    props.info,
+], ([table, row]) => {
+    taskInfo.value = row
+    tableInfo.value = table
+}, { deep: true })
 
 //监听显示
 watch(isShow, (val) => {
@@ -63,20 +82,47 @@ watch(isShow, (val) => {
 })
 
 //设置任务信息
+const tableNotes = ref([])
 const setTaskInfo = async () => {
-
+    const { data } = await mainApi.taskCommentList({
+        projectId: projectId.value,
+        contractId: contractId.value,
+        taskId: taskInfo.value.id,
+        dataId: tableInfo.value.id,
+    })
+    tableNotes.value = getArrValue(data)
 }
 
+//确认批准
 const formNotes = ref('')
-
-
-const confirmClick = () => {
-
+const confirmLoading = ref(false)
+const confirmClick = async () => {
+    if (!formNotes.value) {
+        window.$message.error('请先填写批注信息')
+        return
+    }
+    confirmLoading.value = true
+    const { error, msg, code } = await mainApi.taskCommentSubmit({
+        projectId: projectId.value,
+        contractId: contractId.value,
+        taskId: taskInfo.value.id,
+        dataId: tableInfo.value.id,
+        comment: formNotes.value,
+    })
+    confirmLoading.value = false
+    if (!error && code === 200) {
+        window.$message.success('批注完成')
+        emit('finish')
+        cancelClick()
+    } else {
+        window.$message.error(msg ?? '批注失败')
+    }
 }
 
 //取消审批
 const cancelClick = () => {
     isShow.value = false
+    formNotes.value = ''
     emit('close')
 }
 </script>

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

@@ -61,7 +61,7 @@
         </template>
     </hc-new-dialog>
     <!-- 批注 -->
-    <HcTaskNotes v-model="isNotesShow" />
+    <HcTaskNotes v-model="isNotesShow" :table="tableNoteInfo" :info="rowInfo" @finish="taskNotesFinish" />
 </template>
 
 <script setup>
@@ -221,10 +221,17 @@ const tableRowClick = ({ row }) => {
 
 //批注, isComment 是否已批注,1=是,0=否
 const isNotesShow = ref(false)
+const tableNoteInfo = ref({})
 const rowRemarkClick = (row) => {
+    tableNoteInfo.value = row
     isNotesShow.value = true
 }
 
+//批注完成
+const taskNotesFinish = () => {
+
+}
+
 //确认审批
 const confirmLoading = ref(false)
 const confirmClick = () => {