|
@@ -1,141 +1,134 @@
|
|
|
<template>
|
|
|
- <div v-if="showModal" class="modal-overlay" @click="closeModal">
|
|
|
- <div class="modal-content" @click.stop>
|
|
|
- <div class="modal-header">
|
|
|
- <h2>任务详情</h2>
|
|
|
- <button @click="closeModal">关闭</button>
|
|
|
+ <Dialog v-model="visible" title="任务进度更新" width="70%">
|
|
|
+ <div class="dialog-content">
|
|
|
+ <div class="form-group">
|
|
|
+ <label>任务描述:</label>
|
|
|
+ <input v-model="task.description" type="text" readonly />
|
|
|
</div>
|
|
|
- <div class="modal-body">
|
|
|
- <table>
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th>任务内容</th>
|
|
|
- <th>执行单位</th>
|
|
|
- <th>登记人</th>
|
|
|
- <th>登记时间</th>
|
|
|
- <th>完成进度</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <tr v-for="(task, index) in paginatedTasks" :key="index">
|
|
|
- <td>{{ task.content }}</td>
|
|
|
- <td>{{ task.unit }}</td>
|
|
|
- <td>{{ task.registrant }}</td>
|
|
|
- <td>{{ task.time }}</td>
|
|
|
- <td>{{ task.progress }}</td>
|
|
|
- </tr>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- <div class="pagination">
|
|
|
- <button :disabled="currentPage === 1" @click="prevPage">上一页</button>
|
|
|
- <span>第 {{ currentPage }} 页,共 {{ totalPages }} 页</span>
|
|
|
- <button :disabled="currentPage === totalPages" @click="nextPage">下一页</button>
|
|
|
- </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>执行单位:</label>
|
|
|
+ <input v-model="task.registrar" type="text" readonly />
|
|
|
</div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>完成进度:</label>
|
|
|
+ <select v-model="task.progress">
|
|
|
+ <option value="" disabled>请选择进度</option>
|
|
|
+ <option v-for="unit in units" :key="unit" :value="unit">{{ unit }}</option>
|
|
|
+ </select>
|
|
|
+ <span v-if="!isFormValid" class="error-message">请选择完成进度</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <button @click="confirmRegister" :disabled="!isFormValid">确定</button>
|
|
|
+ <button @click="closeDialog">取消</button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </Dialog>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, onMounted } from 'vue';
|
|
|
-import { selectTask } from '@/api/emergencyCommandMap/JointDuty.ts'; // 确保API路径正确
|
|
|
-
|
|
|
-const showModal = ref(false);
|
|
|
-const tasks = ref([]);
|
|
|
-const currentPage = ref(1);
|
|
|
-const pageSize = ref(5);
|
|
|
+import { defineProps, defineEmits, reactive, watch, computed } from 'vue';
|
|
|
+import Dialog from '@/components/Dialog/index.vue';
|
|
|
+import { updateTaskRegistration } from '@/api/emergencyCommandMap/JointDuty.ts';
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ modelValue: {
|
|
|
+ type: Boolean,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ task: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({
|
|
|
+ id: '',
|
|
|
+ description: '',
|
|
|
+ registrar: '',
|
|
|
+ progress: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
-const totalPages = computed(() => Math.ceil(tasks.value.length / pageSize.value));
|
|
|
+const emit = defineEmits(['update:modelValue', 'update-success']);
|
|
|
|
|
|
-const paginatedTasks = computed(() => {
|
|
|
- const start = (currentPage.value - 1) * pageSize.value;
|
|
|
- const end = start + pageSize.value;
|
|
|
- return tasks.value.slice(start, end);
|
|
|
+const visible = computed({
|
|
|
+ get: () => props.modelValue,
|
|
|
+ set: (val) => emit('update:modelValue', val)
|
|
|
});
|
|
|
-const closeModal = () => {
|
|
|
- showModal.value = false;
|
|
|
-};
|
|
|
|
|
|
-const prevPage = () => {
|
|
|
- if (currentPage.value > 1) {
|
|
|
- currentPage.value--;
|
|
|
- }
|
|
|
-};
|
|
|
+const task = reactive({ ...props.task });
|
|
|
|
|
|
-const nextPage = () => {
|
|
|
- if (currentPage.value < totalPages.value) {
|
|
|
- currentPage.value++;
|
|
|
+watch(
|
|
|
+ () => props.task,
|
|
|
+ (newTask) => {
|
|
|
+ Object.assign(task, newTask);
|
|
|
}
|
|
|
+);
|
|
|
+
|
|
|
+const units = ['已处理', '已完成'];
|
|
|
+
|
|
|
+const isFormValid = computed(() => {
|
|
|
+ return task.progress !== '';
|
|
|
+});
|
|
|
+
|
|
|
+const closeDialog = () => {
|
|
|
+ visible.value = false;
|
|
|
};
|
|
|
|
|
|
-const fetchTasks = async () => {
|
|
|
+const confirmRegister = async () => {
|
|
|
try {
|
|
|
- const response = await selectTask();
|
|
|
+ const response = await updateTaskRegistration({
|
|
|
+ id: task.id,
|
|
|
+ description: task.description,
|
|
|
+ registrar: task.registrar,
|
|
|
+ processing_status: task.progress
|
|
|
+ });
|
|
|
if (response.code === 200) {
|
|
|
- tasks.value = response.data;
|
|
|
+ console.log('任务进度更新成功');
|
|
|
+ emit('update-success', response.data);
|
|
|
+ closeDialog();
|
|
|
} else {
|
|
|
- console.error('获取任务数据失败:', response.msg);
|
|
|
+ console.error('任务进度更新失败:', response.msg);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('请求任务数据失败:', error);
|
|
|
+ console.error('请求任务进度更新失败:', error);
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- fetchTasks();
|
|
|
-});
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.modal-overlay {
|
|
|
- position: fixed;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- background: rgba(0, 0, 0, 0.5);
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
-}
|
|
|
-
|
|
|
-.modal-content {
|
|
|
- background: white;
|
|
|
+.dialog-content {
|
|
|
padding: 20px;
|
|
|
- border-radius: 8px;
|
|
|
- width: 80%;
|
|
|
- max-width: 800px;
|
|
|
}
|
|
|
-
|
|
|
-.modal-header {
|
|
|
- display: flex;
|
|
|
- justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
- margin-bottom: 20px;
|
|
|
+.form-group {
|
|
|
+ margin-bottom: 15px;
|
|
|
}
|
|
|
-
|
|
|
-table {
|
|
|
- width: 100%;
|
|
|
- border-collapse: collapse;
|
|
|
+.dialog-footer {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ padding: 10px;
|
|
|
}
|
|
|
-
|
|
|
-th,
|
|
|
-td {
|
|
|
- border: 1px solid #ddd;
|
|
|
- padding: 8px;
|
|
|
- text-align: left;
|
|
|
+button {
|
|
|
+ margin-left: 10px;
|
|
|
+ padding: 5px 15px;
|
|
|
+ border: none;
|
|
|
+ background-color: #3498db;
|
|
|
+ color: white;
|
|
|
+ border-radius: 4px;
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
|
-
|
|
|
-th {
|
|
|
- background-color: #f2f2f2;
|
|
|
+button:hover {
|
|
|
+ background-color: #2980b9;
|
|
|
}
|
|
|
-
|
|
|
-.pagination {
|
|
|
- margin-top: 20px;
|
|
|
- text-align: center;
|
|
|
+textarea,
|
|
|
+select,
|
|
|
+input[type='text'] {
|
|
|
+ width: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 5px;
|
|
|
+ margin-top: 5px;
|
|
|
+ border-radius: 4px;
|
|
|
+ border: 1px solid #ccc;
|
|
|
}
|
|
|
-
|
|
|
-button {
|
|
|
- margin: 0 5px;
|
|
|
+.error-message {
|
|
|
+ color: red;
|
|
|
+ font-size: 14px;
|
|
|
}
|
|
|
</style>
|