防止电信诈骗。

This commit is contained in:
2025-06-19 22:10:20 +08:00
parent 73ceb5f9a4
commit d798392bab
6 changed files with 657 additions and 51 deletions

View File

@@ -108,12 +108,15 @@
</div>
</div>
<ErrorDialog :visible="showErrorDialog" :message="errorDialogMsg" @close="showErrorDialog = false" />
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { getDemandsList, updateDemand, deleteDemand, addDemand } from '../../api/demands'; // 确认路径
import ErrorDialog from '@/components/ErrorDialog.vue'
const demands = ref([]);
const loading = ref(false);
@@ -135,6 +138,9 @@ const initialAddFormState = {
const addForm = ref({ ...initialAddFormState });
const addError = ref('');
const showErrorDialog = ref(false)
const errorDialogMsg = ref('')
const formatDate = (dateString) => {
if (!dateString) return 'N/A';
try {
@@ -185,22 +191,20 @@ const submitEditForm = async () => {
if (!currentDemand.value || !currentDemand.value.id) return;
editError.value = '';
try {
// 构造符合 updateDemand API 的 payload
const payload = {
requester: editForm.value.requester,
qq_code: editForm.value.qq_code,
sendcontent: editForm.value.sendcontent,
reward: editForm.value.reward,
date: editForm.value.date // 使用表单中的日期
// content 会在API层通过 sendcontent 补齐
date: editForm.value.date
};
await updateDemand(currentDemand.value.id, payload);
alert('需求更新成功!');
closeEditModal();
fetchDemandsAdmin();
} catch (error) {
console.error('更新需求失败:', error);
editError.value = error.response?.data?.detail || error.message || '更新失败,请重试。';
errorDialogMsg.value = error.response?.data?.detail || error.message || '更新失败,请重试。';
showErrorDialog.value = true;
}
};
@@ -211,8 +215,8 @@ const confirmDeleteDemand = async (id) => {
alert('需求删除成功!');
fetchDemandsAdmin();
} catch (error) {
console.error('删除需求失败:', error);
alert('删除需求失败: ' + (error.message || '请稍后重试'));
errorDialogMsg.value = error.response?.data?.detail || error.message || '删除失败,请稍后重试';
showErrorDialog.value = true;
}
}
};