diff --git a/frontend/src/api/guoYuSheShiShuJuTianBao/index.ts b/frontend/src/api/guoYuSheShiShuJuTianBao/index.ts index ee26614..bbefa05 100644 --- a/frontend/src/api/guoYuSheShiShuJuTianBao/index.ts +++ b/frontend/src/api/guoYuSheShiShuJuTianBao/index.ts @@ -88,11 +88,17 @@ export function getLastImportResult() { method: 'get' }); } - -// 批量保存草稿 -export function batchSaveDraft(data:any) { +export function deleteFile(params:any) { return request({ - url: '/data/fishDraft/batchSaveDraft', + url: '/data/fishDraft/deleteFile', + method: 'get', + params + }); +} +// 批量保存草稿 +export function importBatchSaveDraft(data:any) { + return request({ + url: '/data/fishDraft/importBatchSaveDraft', method: 'post', data }); diff --git a/frontend/src/api/select/index.ts b/frontend/src/api/select/index.ts index a43e8ed..a6eeb2b 100644 --- a/frontend/src/api/select/index.ts +++ b/frontend/src/api/select/index.ts @@ -8,6 +8,14 @@ export function getBaseDropdown(data:any) { data }); } +// 流域下拉列表 +export function getSelectForDropdown(data:any) { + return request({ + url: '/env/hbrv/selectForDropdown', + method: 'get', + data + }); +} //电站下拉列表 export function getEngInfoDropdown(data:any) { return request({ @@ -16,10 +24,10 @@ export function getEngInfoDropdown(data:any) { data }); } -// 更新导入任务 -export function updateImportTask(data:any) { +// 重新验证并更新行数据 +export function revalidateAndUpdateRow(data:any) { return request({ - url: '/data/importTask/update', + url: '/data/fishDraft/revalidateAndUpdateRow', method: 'post', data }); diff --git a/frontend/src/components/BasicSearch/index.vue b/frontend/src/components/BasicSearch/index.vue index 1cb5ec0..1babc67 100644 --- a/frontend/src/components/BasicSearch/index.vue +++ b/frontend/src/components/BasicSearch/index.vue @@ -74,7 +74,8 @@
- + + + + + {{ opt.hbrvnm }} + + { validSearchList.value.forEach((item) => { if (item.type == "waterStation") { // 下拉菜单 - shuJuTianBaoStore.getBaseOption(); - shuJuTianBaoStore.getEngOption(formData.baseId); + // shuJuTianBaoStore.getBaseOption(); + shuJuTianBaoStore.getSelectForOption(); + shuJuTianBaoStore.getEngOption(formData.hbrvcd); } if (item.fieldProps?.required) { rules[item.name] = [ @@ -270,17 +292,27 @@ const triggerManualValuesChange = (changedKey: string, newValue: any) => { emit("valuesChange", changedValues, { ...formData }); }; -const dataDimensionDataChange = (value: any) => { - formData.baseId = value; +// const dataDimensionDataChange = (value: any) => { +// formData.baseId = value; +// formData.rstcd = ""; +// shuJuTianBaoStore.getEngOption(formData.baseId); + +// // 【关键修改】手动触发 valuesChange,因为 a-form-item-rest 阻断了自动监听 +// triggerManualValuesChange("baseId", formData.baseId); +// }; + +const lyChange = (value: any) => { + formData.hbrvcd = value; formData.rstcd = ""; - shuJuTianBaoStore.getEngOption(formData.baseId); + shuJuTianBaoStore.getEngOption(formData.hbrvcd); // 【关键修改】手动触发 valuesChange,因为 a-form-item-rest 阻断了自动监听 - triggerManualValuesChange("baseId", formData.baseId); + triggerManualValuesChange("hbrvcd", formData.hbrvcd); }; const stcdIdChange = (value: any) => { formData.rstcd = value; + shuJuTianBaoStore.getFpssOption(formData.hbrvcd, value); // 【关键修改】手动触发 valuesChange triggerManualValuesChange("rstcd", formData.rstcd); }; diff --git a/frontend/src/components/fishSearch/index.vue b/frontend/src/components/fishSearch/index.vue index 67996d9..84330d4 100644 --- a/frontend/src/components/fishSearch/index.vue +++ b/frontend/src/components/fishSearch/index.vue @@ -2,13 +2,13 @@
@@ -46,7 +67,7 @@ v-model:value="formData.rstcd" :loading="engLoading" placeholder="请选择电站名称" - :disabled="isView || !formData.baseId" + :disabled="isView || !formData.hbrvcd" show-search allowClear :filter-option="filterOption" @@ -72,7 +93,7 @@ v-model:value="formData.stcd" :loading="fpssLoading" placeholder="请选择过鱼设施" - :disabled="isView || !formData.rstcd" + :disabled="isView || !formData.rstcd" show-search allowClear :filter-option="filterOption" @@ -218,7 +239,7 @@ /> - + - 点击预览视频 + + 点击预览视频 + @@ -270,12 +293,12 @@ import { ref, reactive, watch, computed } from "vue"; import dayjs from "dayjs"; import { Upload, message } from "ant-design-vue"; -import { UploadOutlined, PlusOutlined } from "@ant-design/icons-vue"; -import type { Rule } from "ant-design-vue/es/form"; import type { UploadProps } from "ant-design-vue"; +import type { Rule } from "ant-design-vue/es/form"; +import { UploadOutlined, PlusOutlined } from "@ant-design/icons-vue"; import fishSearch from "@/components/fishSearch/index.vue"; import { - getBaseDropdown, + getSelectForDropdown, getEngInfoDropdown, getFpssDropdown, uploadFile, @@ -289,12 +312,18 @@ interface Props { loading?: boolean; isView?: boolean; } -const baseLoading = ref(false); +// 加载状态 +const localLoading = ref(false); +// const baseLoading = ref(false); +const hbrvcdLoading = ref(false); const engLoading = ref(false); const fpssLoading = ref(false); -const baseOption = ref([]); +// 下拉列表选项 +// const baseOption = ref([]); +const hbrvcdOption = ref([]); const engOption = ref([]); const fpssOption = ref([]); +// 图片视频上传列表 const imageFileList = ref([]); const videoFileList = ref([]); @@ -303,29 +332,54 @@ const props = withDefaults(defineProps(), { initialValues: null, loading: false, }); -const getBaseDropdownSelect = async () => { +// 获取基地 +// const getBaseDropdownSelect = async () => { +// try { +// baseLoading.value = true; +// const res = await getBaseDropdown({}); +// let list = res.data || []; +// if (list && list.length > 0) { +// list = list.filter((item: any) => item.baseId !== "all"); +// } +// baseOption.value = list; +// } catch (error) { +// console.error("获取基地列表失败:", error); +// } finally { +// baseLoading.value = false; +// } +// }; +// 获取流域列表 +const getHbrvcdDropdownSelect = async () => { try { - baseLoading.value = true; - const res = await getBaseDropdown({}); + hbrvcdLoading.value = true; + const res = await getSelectForDropdown({}); let list = res.data || []; - if (list.length > 0) list.shift(); - baseOption.value = list; + if (list && list.length > 0) { + list = list.filter((item: any) => item.hbrvcd !== "all"); + } + hbrvcdOption.value = list; } catch (error) { console.error("获取流域列表失败:", error); } finally { - baseLoading.value = false; + hbrvcdLoading.value = false; } }; -const baseChange = async (baseId: string) => { +// const baseChange = async (baseId: string) => { +// formData.rstcd = undefined; +// formData.stcd = undefined; +// await getEngInfoDropdownSelect(baseId); +// await getFpssDropdownSelect(formData.rstcd, baseId); +// }; +const hbrvcdChange = async (hbrvcd: string) => { formData.rstcd = undefined; formData.stcd = undefined; - await getEngInfoDropdownSelect(baseId); - await getFpssDropdownSelect(formData.rstcd, baseId); + await getEngInfoDropdownSelect(hbrvcd); + // await getFpssDropdownSelect(formData.rstcd, hbrvcd); }; -const getEngInfoDropdownSelect = async (baseId: string) => { +const getEngInfoDropdownSelect = async (hbrvcd: string) => { try { engLoading.value = true; - const res = await getEngInfoDropdown({ baseId }); + const res = await getEngInfoDropdown({ hbrvcd }); engOption.value = res.data; } catch (error) { console.error("获取电站列表失败", error); @@ -335,12 +389,12 @@ const getEngInfoDropdownSelect = async (baseId: string) => { }; const engChange = async (rstcd: string) => { formData.stcd = undefined; - await getFpssDropdownSelect(rstcd, formData.baseId); + await getFpssDropdownSelect(rstcd, formData.hbrvcd); }; -const getFpssDropdownSelect = async (rstcd: string, baseId: string) => { +const getFpssDropdownSelect = async (rstcd: string, hbrvcd: string) => { try { fpssLoading.value = true; - const res = await getFpssDropdown({ rstcd, baseId }); + const res = await getFpssDropdown({ rstcd, hbrvcd }); fpssOption.value = res.data; } catch (error) { console.error("获取流量列表失败", error); @@ -369,7 +423,7 @@ const weightError = ref(""); // 表单数据模型 const defaultFormData = reactive({ id: undefined, - baseId: undefined, + hbrvcd: undefined, stcd: undefined, rstcd: undefined, strdt: undefined, @@ -394,7 +448,7 @@ const filterOption = (inputValue: string, option: any) => { }; // 验证规则 const rules: Record = { - baseId: [{ required: true, message: "请选择流域", trigger: "change" }], + hbrvcd: [{ required: true, message: "请选择流域", trigger: "change" }], rstcd: [{ required: true, message: "请选择电站", trigger: "change" }], stcd: [{ required: true, message: "请选择过鱼设施", trigger: "change" }], strdt: [{ required: true, message: "请选择过鱼时间", trigger: "change" }], @@ -589,46 +643,12 @@ const initForm = () => { } }; -watch( - () => props.visible, - (newVisible) => { - if (newVisible) { - // 弹窗打开时,初始化数据 - getBaseDropdownSelect(); - getEngInfoDropdownSelect(formData.baseId); - getFpssDropdownSelect(formData.rstcd, formData.baseId); - initForm(); - } - }, - { immediate: false } // 不需要 immediate,因为初始状态通常是 false -); - -// 重置表单 -const resetForm = () => { - if (formRef.value) { - formRef.value.resetFields(); - } - Object.assign(formData, defaultFormData); - // 清空手动验证的错误信息 - bodyLengthError.value = ""; - weightError.value = ""; - // 清空文件列表 - imageFileList.value = []; - videoFileList.value = []; -}; - -// 取消操作 -const handleCancel = () => { - emit("update:visible", false); - emit("cancel"); - resetForm(); -}; +// 视频预览 const handleVideoPreview = () => { emit("preview-click", { vdpthList: videoFileList.value }, "formVideo", 0); }; -// ... 其他导入 ... -// 新增:自定义图片预览处理 +// 预览图片 const handleImagePreview = async (file: any) => { if (!props.isView) { return ""; @@ -636,8 +656,6 @@ const handleImagePreview = async (file: any) => { emit("preview-click", { picpthList: imageFileList.value }, "formImage", 0); return ""; }; - -// ... 其他现有代码 ... // 确认操作 const handleOk = async () => { try { @@ -657,6 +675,7 @@ const handleOk = async () => { (file) => !file.url && file.originFileObj ); + localLoading.value = true; if (newImageFiles.length > 0) { // 这里需要循环上传,或者使用 Promise.all 并行上传 // 伪代码:假设 uploadFile 返回 { data: { url: '...' } } @@ -757,6 +776,45 @@ const handleOk = async () => { message.error("请检查表单填写是否正确"); } }; +// 重置表单 +const resetForm = () => { + if (formRef.value) { + formRef.value.resetFields(); + } + Object.assign(formData, defaultFormData); + // 清空手动验证的错误信息 + bodyLengthError.value = ""; + weightError.value = ""; + // 清空文件列表 + imageFileList.value = []; + videoFileList.value = []; +}; + +// 取消操作 +const handleCancel = () => { + emit("update:visible", false); + emit("cancel"); + resetForm(); +}; + +watch( + () => props.visible, + (newVisible) => { + if (newVisible) { + // 弹窗打开时,初始化数据 + // getBaseDropdownSelect();// 基地 + getHbrvcdDropdownSelect();// 流域 + getEngInfoDropdownSelect(formData.hbrvcd); + getFpssDropdownSelect(formData.rstcd, formData.hbrvcd); + initForm(); + } + }, + { immediate: false } // 不需要 immediate,因为初始状态通常是 false +); +// 暴露变量 +defineExpose({ + localLoading +});