|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div v-if="showRegisterDialog" class="dialog">
|
|
|
+ <div v-if="visible" class="dialog">
|
|
|
<div class="dialog-content">
|
|
|
<div class="dialog-header">
|
|
|
<span>任务进度更新</span>
|
|
@@ -24,7 +24,7 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="dialog-footer">
|
|
|
- <button @click="confirmRegister">确定</button>
|
|
|
+ <button @click="confirmRegister" :disabled="!isFormValid">确定</button>
|
|
|
<button @click="closeDialog">取消</button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -32,47 +32,58 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, reactive, defineEmits, computed } from "vue";
|
|
|
-import { updateTaskRegistration } from '@/api/emergencyCommandMap/JointDuty.ts'; // 确保API路径正确
|
|
|
-
|
|
|
-const showRegisterDialog = ref(false);
|
|
|
-// 任务数据,用来初始化弹窗表单
|
|
|
-const newTask = reactive({
|
|
|
- task_description: '',
|
|
|
- unit_name: '当前用户',
|
|
|
- registrar: ''
|
|
|
+import { ref, reactive, defineEmits, computed, watch } from 'vue';
|
|
|
+import { updateTaskRegistration } from '@/api/emergencyCommandMap/JointDuty.ts';
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ modelValue: {
|
|
|
+ type: Boolean,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ task: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({
|
|
|
+ task_id: '',
|
|
|
+ task_description: '',
|
|
|
+ unit_name: '',
|
|
|
+ registrar: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
});
|
|
|
-const units = ref(['已处理', '已完成']);
|
|
|
-
|
|
|
-// 打开弹窗并初始化任务数据
|
|
|
-const openDialog = (task) => {
|
|
|
- newTask.task_description = task.task_description;
|
|
|
- newTask.unit_name = task.unit_name;
|
|
|
- newTask.registrar = task.registrar || '';
|
|
|
- showRegisterDialog.value = true;
|
|
|
-};
|
|
|
-
|
|
|
-// 关闭弹窗
|
|
|
-const closeDialog = () => {
|
|
|
- showRegisterDialog.value = false;
|
|
|
-};
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue', 'update-success']);
|
|
|
+const newTask = reactive({ ...props.task }); // 初始化任务数据
|
|
|
+const units = ref(['已处理', '已完成']);
|
|
|
|
|
|
+// 控制弹窗显示状态
|
|
|
const visible = computed({
|
|
|
get: () => props.modelValue,
|
|
|
- set: (val) => emit('update:modelValue', val)
|
|
|
+ set: (val) => {
|
|
|
+ emit('update:modelValue', val);
|
|
|
+ if (!val) {
|
|
|
+ resetForm(); // 关闭时重置表单
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
+// 表单有效性检查
|
|
|
+const isFormValid = computed(() => newTask.registrar !== '');
|
|
|
+
|
|
|
+const resetForm = () => {
|
|
|
+ newTask.task_description = '';
|
|
|
+ newTask.unit_name = '当前用户';
|
|
|
+ newTask.registrar = '';
|
|
|
+};
|
|
|
+
|
|
|
// 确认登记任务
|
|
|
const confirmRegister = async () => {
|
|
|
try {
|
|
|
const response = await updateTaskRegistration({
|
|
|
- task_id: newTask.task_id, // 假设任务有唯一ID
|
|
|
- processing_status: newTask.processing_status
|
|
|
+ task_id: newTask.task_id,
|
|
|
+ processing_status: newTask.registrar // 假设 registrar 作为状态
|
|
|
});
|
|
|
if (response.code === 200) {
|
|
|
- console.log('任务进度更新成功');
|
|
|
+ emit('update-success', newTask); // 发出更新成功事件
|
|
|
closeDialog();
|
|
|
} else {
|
|
|
console.error('任务进度更新失败:', response.msg);
|
|
@@ -81,6 +92,20 @@ const confirmRegister = async () => {
|
|
|
console.error('请求任务进度更新失败:', error);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+// 关闭弹窗
|
|
|
+const closeDialog = () => {
|
|
|
+ visible.value = false; // 控制弹窗显示
|
|
|
+};
|
|
|
+
|
|
|
+// 监听任务数据变化
|
|
|
+watch(
|
|
|
+ () => props.task,
|
|
|
+ (newTaskData) => {
|
|
|
+ Object.assign(newTask, newTaskData); // 更新任务数据
|
|
|
+ },
|
|
|
+ { immediate: true } // 初始加载时同步
|
|
|
+);
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
@@ -92,7 +117,7 @@ const confirmRegister = async () => {
|
|
|
background-color: white;
|
|
|
border-radius: 8px;
|
|
|
box-shadow: 0 50px 50px rgba(0, 0, 0, 0.1);
|
|
|
- width: 1500px;
|
|
|
+ width: 600px; /* 调整宽度 */
|
|
|
}
|
|
|
|
|
|
.dialog-header {
|
|
@@ -131,9 +156,8 @@ button:hover {
|
|
|
background-color: #2980b9;
|
|
|
}
|
|
|
|
|
|
-textarea,
|
|
|
-select,
|
|
|
-input[type='text'] {
|
|
|
+input[type='text'],
|
|
|
+select {
|
|
|
width: 100%;
|
|
|
box-sizing: border-box;
|
|
|
padding: 5px;
|