This commit is contained in:
Teo
2025-08-15 16:53:31 +08:00
parent ff2f36e88c
commit 1e87b87bb9
8 changed files with 292 additions and 126 deletions

View File

@ -5,7 +5,7 @@ VITE_APP_TITLE = 新能源项目管理平台
VITE_APP_ENV = 'development'
# 开发环境
VITE_APP_BASE_API = 'http://192.168.110.180:8898'
VITE_APP_BASE_API = 'http://192.168.110.163:8898'
# 无人机接口地址

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -49,7 +49,7 @@ export const addFormalitiesAreConsolidated = (data: FormalitiesAreConsolidatedFo
*/
export const updateFormalitiesAreConsolidated = (data: FormalitiesAreConsolidatedForm) => {
return request({
url: '/formalities/formalitiesAreConsolidated',
url: '/formalities/formalitiesAreConsolidated/edit',
method: 'put',
data: data
});
@ -77,3 +77,27 @@ export const editStatus = (data: FormalitiesAreConsolidatedForm) => {
data: data
});
};
/**
* 查询合规性手续合账文件列表
* @param query
* @returns {*}
*/
export const listFormalitiesAnnex = (query?: any): AxiosPromise<FormalitiesAreConsolidatedVO[]> => {
return request({
url: '/formalities/formalitiesAnnex/list',
method: 'get',
params: query
});
};
/**
* 删除合规性手续合账文件
* @param id
*/
export const delFormalitiesAnnex = (id: string | number | Array<string | number>) => {
return request({
url: '/formalities/formalitiesAnnex/' + id,
method: 'delete'
});
};

View File

@ -61,3 +61,17 @@ export const delListOfFormalities = (id: string | number | Array<string | number
method: 'delete'
});
};
/**
* 查询手续办理清单模板是否存在
* @param id
*/
export const getWhetherItExists = (id: string | number): AxiosPromise<ListOfFormalitiesVO> => {
return request({
url: '/formalities/formalitiesAreConsolidated/getWhetherItExists',
method: 'get',
params: {
projectId: id
}
});
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -21,6 +21,7 @@
:on-change="handleChange"
:on-remove="handleRemove"
:method="method"
:http-request="customUpload"
>
<slot>
<div>
@ -89,6 +90,7 @@
import { propTypes } from '@/utils/propTypes';
import { delOss, listByIds } from '@/api/system/oss';
import { globalHeaders } from '@/utils/request';
import axios from 'axios';
const props = defineProps({
modelValue: {
type: [String, Object, Array],
@ -143,6 +145,7 @@ const uploadList = ref<any[]>([]);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(baseUrl + props.uploadUrl); // 上传文件服务器地址
const headers = ref(globalHeaders());
const pendingFiles = ref<UploadFile[]>([]);
const realUploadUrl = computed(() => {
const search = new URLSearchParams(props.params).toString();
@ -237,28 +240,33 @@ interface UploadFileWithOssId extends UploadFile {
}
const handleUploadSuccess = (res: any, file: UploadFileWithOssId) => {
console.log(props.data);
if (res.code === 200) {
if (res.data) {
console.log('上传成功');
// 上传成功,不管 data 是否为空
uploadList.value.push({
name: res.data.fileName,
url: res.data.url,
ossId: res.data.ossId
name: file.name,
url: (res.data && res.data.url) || '',
ossId: (res.data && res.data.ossId) || ''
});
} else {
uploadList.value.push({});
}
} else {
console.log('失败', res);
number.value--;
proxy?.$modal.closeLoading();
proxy?.$modal.msgError(res.msg);
proxy?.$modal.msgError(res.msg || '上传失败');
fileUploadRef.value?.handleRemove(file);
return;
}
uploadedSuccessfully(res);
};
const handleChange = (file: any, fileList: any) => {
// 记录 status = 'ready' 的文件
if (file.status === 'ready') {
pendingFiles.value.push(file);
}
emit('handleChange', file, fileList);
};
@ -290,8 +298,6 @@ const handleDelete = async (index: string | number, type?: string) => {
// 上传结束处理
const uploadedSuccessfully = (res: any) => {
console.log(11121);
if (props.isImportInfo) {
emit('update:modelValue', 'ok');
fileUploadRef.value?.clearFiles();
@ -307,8 +313,8 @@ const uploadedSuccessfully = (res: any) => {
emit('update:modelValue', listToString(fileList.value));
proxy?.$modal.closeLoading();
props.onUploadSuccess?.(fileList.value, res);
}
props.onUploadSuccess?.(fileList.value, res);
};
// 获取文件名称
@ -334,13 +340,67 @@ const listToString = (list: any[], separator?: string) => {
return strs != '' ? strs.substring(0, strs.length - 1) : '';
};
const submitUpload = () => {
fileUploadRef.value!.submit();
// 改造后的 customUpload
const customUpload = async (options: any) => {
if (props.autoUpload) {
// 自动上传,单文件请求
try {
const formData = new FormData();
formData.append('file', options.file);
Object.entries(props.data).forEach(([k, v]) => {
if (v !== null && v !== undefined) formData.append(k, v as any);
});
const res = await axios?.({
url: realUploadUrl.value,
method: props.method,
data: formData,
headers: { 'Content-Type': 'multipart/form-data', ...headers.value }
});
handleUploadSuccess(res, options.file);
} catch (err) {
handleUploadError();
}
} else {
// 手动上传,不发请求,只缓存
pendingFiles.value.push(options.file);
}
};
defineExpose({
submitUpload
// 改造后的 submitUpload
const submitUpload = async () => {
if (props.autoUpload) {
fileUploadRef.value?.submit();
return;
}
if (!pendingFiles.value.length) {
return 'noFile';
}
try {
proxy?.$modal.loading('正在上传文件,请稍候...');
const formData = new FormData();
pendingFiles.value.forEach((f) => {
if (f.raw) formData.append('file', f.raw as File);
});
Object.entries(props.data).forEach(([k, v]) => {
if (v !== null && v !== undefined) formData.append(k, v as any);
});
const res = await axios?.({
url: realUploadUrl.value,
method: props.method,
data: formData,
headers: { 'Content-Type': 'multipart/form-data', ...headers.value }
});
handleUploadSuccess(res.data, {} as any);
pendingFiles.value = [];
fileUploadRef.value?.clearFiles();
} catch (err) {
handleUploadError();
} finally {
proxy?.$modal.closeLoading();
}
};
defineExpose({ submitUpload });
</script>
<style scoped lang="scss">

View File

@ -79,16 +79,25 @@
<el-table-column label="办理状态" align="center" prop="processingStatus" />
<el-table-column label="手续材料" align="center" prop="formalitiesUrl" width="180">
<template #default="scope">
<el-link type="primary" :underline="false" :href="scope.row.formalitiesUrl" target="_blank" v-if="scope.row.formalitiesUrl">查看</el-link>
<el-link type="primary" :underline="false" @click="handlePreview(scope.row)" target="_blank">查看</el-link>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<div v-if="scope.row.status != 1">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['formalities:formalitiesAreConsolidated:edit']"
>修改</el-button
>
<el-button
link
type="primary"
icon="Upload"
@click="handleUpload(scope.row)"
v-hasPermi="['formalities:formalitiesAreConsolidated:edit']"
>上传</el-button
>
<el-button
link
type="primary"
@ -97,6 +106,7 @@
v-hasPermi="['formalities:formalitiesAreConsolidated:edit']"
>修改状态</el-button
>
</div>
</template>
</el-table-column>
</el-table>
@ -116,18 +126,6 @@
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="上传文件" prop="processingStatus">
<file-upload
v-model="file"
ref="uploadRef"
uploadUrl="/formalities/formalitiesAreConsolidated/edit"
:data="{ ...form }"
:auto-upload="false"
showFileList
method="put"
:onUploadSuccess="handleUploadSuccess"
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
@ -136,6 +134,55 @@
</div>
</template>
</el-dialog>
<el-dialog draggable title="文件列表" v-model="viewVisible" width="45%">
<el-table :data="fileList" style="width: 100%" border v-loading="fileLoading">
<el-table-column prop="fileName" label="文件" align="center">
<template #default="scope">
<el-link :key="scope.row.annexUrl" :href="scope.row.annexUrl" target="_blank" type="primary" :underline="false">
{{ scope.row.fileName || '查看文件' }}
</el-link>
</template>
</el-table-column>
<el-table-column label="操作" width="90" align="center" v-if="fileStatus != 1">
<template #default="scope">
<el-button type="danger" link icon="Delete" @click="handleDeleteFile(scope.row)"> 删除 </el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="fileTotal > 0"
:total="fileTotal"
v-model:page="fileParams.pageNum"
v-model:limit="fileParams.pageSize"
@pagination="getFileList"
/>
<template #footer>
<span>
<el-button type="primary" @click="viewVisible = false">关闭</el-button>
</span>
</template>
</el-dialog>
<!-- 上传文件对话框 -->
<el-dialog draggable title="上传文件" v-model="fileVisible" width="45%">
<el-form-item label="上传文件" prop="processingStatus">
<file-upload
v-model="file"
ref="uploadRef"
uploadUrl="/formalities/formalitiesAnnex"
:data="{ formalitiesId: form.id }"
:auto-upload="false"
showFileList
method="put"
:onUploadSuccess="handleUploadSuccess"
/>
</el-form-item>
<template #footer>
<span>
<el-button :loading="buttonLoading" type="primary" @click="submitFileForm"> </el-button>
<el-button @click="fileVisible = false"> </el-button>
</span>
</template>
</el-dialog>
</div>
</template>
@ -146,6 +193,8 @@ import {
delFormalitiesAreConsolidated,
addFormalitiesAreConsolidated,
updateFormalitiesAreConsolidated,
listFormalitiesAnnex,
delFormalitiesAnnex,
editStatus
} from '@/api/formalities/formalitiesAreConsolidated';
import {
@ -154,8 +203,7 @@ import {
FormalitiesAreConsolidatedForm
} from '@/api/formalities/formalitiesAreConsolidated/types';
import { useUserStoreHook } from '@/store/modules/user';
import { json } from 'stream/consumers';
const fileVisible = ref(false);
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
// 获取用户 store
const userStore = useUserStoreHook();
@ -164,6 +212,8 @@ const currentProject = computed(() => userStore.selectedProject);
const formalitiesAreConsolidatedList = ref<FormalitiesAreConsolidatedVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const fileLoading = ref(false);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
@ -172,12 +222,20 @@ const total = ref(0);
const uploadRef = ref();
const queryFormRef = ref<ElFormInstance>();
const formalitiesAreConsolidatedFormRef = ref<ElFormInstance>();
const fileList = ref([]);
const fileTotal = ref(0);
const viewVisible = ref(false);
const fileStatus = ref(0);
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const file = ref(null);
const fileParams = reactive({
pageNum: 1,
pageSize: 10,
formalitiesId: undefined
});
const initFormData: FormalitiesAreConsolidatedForm = {
id: undefined,
projectId: currentProject.value?.id,
@ -246,11 +304,14 @@ const handleSelectionChange = (selection: FormalitiesAreConsolidatedVO[]) => {
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加合规性手续合账';
/** 删除文件按钮操作 */
const handleDeleteFile = async (row) => {
await proxy?.$modal.confirm('是否确认删除文件编号为"' + row.id + '"的数据项?').finally(() => (fileLoading.value = false));
fileLoading.value = true;
await delFormalitiesAnnex(row.id);
proxy?.$modal.msgSuccess('删除成功');
await getFileList();
};
/** 修改按钮操作 */
@ -263,6 +324,15 @@ const handleUpdate = async (row?: FormalitiesAreConsolidatedVO) => {
dialog.title = '修改合规性手续合账';
};
/** 上传按钮操作 */
const handleUpload = (row) => {
form.value.id = row.id;
fileList.value = [];
file.value = null;
fileVisible.value = true;
};
const handleUpdateStatus = async (row?: FormalitiesAreConsolidatedVO) => {
await proxy?.$modal.confirm('是否确认修改状态?').finally(() => (loading.value = false));
@ -276,30 +346,43 @@ const handleUpdateStatus = async (row?: FormalitiesAreConsolidatedVO) => {
const submitForm = () => {
formalitiesAreConsolidatedFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
for (const key in form.value) {
if (form.value[key] === null) {
delete form.value[key];
updateFormalitiesAreConsolidated(form.value).then(() => {
proxy?.$modal.msgSuccess('修改成功');
dialog.visible = false;
getList();
});
}
}
const res = uploadRef.value.submitUpload();
console.log(res);
});
};
const submitFileForm = () => {
uploadRef.value.submitUpload().then((res) => {
if (res === 'noFile') {
proxy?.$modal.msgWarning('请先选择文件');
}
});
};
const handleUploadSuccess = async () => {
proxy?.$modal.msgSuccess('上传成功');
dialog.visible = false;
fileVisible.value = false;
await getList();
};
/** 删除按钮操作 */
const handleDelete = async (row?: FormalitiesAreConsolidatedVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除合规性手续合账编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delFormalitiesAreConsolidated(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
const handlePreview = async (row?: FormalitiesAreConsolidatedVO) => {
viewVisible.value = true;
fileLoading.value = true;
fileParams.formalitiesId = row.id;
fileStatus.value = row.status;
getFileList();
};
const getFileList = async () => {
const res = await listFormalitiesAnnex(fileParams);
fileList.value = res.rows;
fileTotal.value = res.total;
fileLoading.value = false;
};
/** 导出按钮操作 */
@ -316,12 +399,6 @@ const handleExport = () => {
onMounted(() => {
getList();
});
const formData = new FormData();
let arr = [];
formData.append('file', JSON.stringify(arr));
formData.append('bo', JSON.stringify({}));
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value?.id,

View File

@ -1,5 +1,7 @@
<template>
<div class="p-2">
<formalitiesAreConsolidated ref="formalitiesAreConsolidatedRef" class="overlay" v-if="showFormalitiesAreConsolidated" />
<div class="p-2" v-else>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
@ -27,27 +29,6 @@
>确认</el-button
>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['formalities:listOfFormalities:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete()"
v-hasPermi="['formalities:listOfFormalities:remove']"
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['formalities:listOfFormalities:export']"
>导出</el-button
>
</el-col> -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@ -55,38 +36,18 @@
<el-table v-loading="loading" :data="listOfFormalitiesList" @selection-change="handleSelectionChange" row-key="id" default-expand-all>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="名称" prop="name" />
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button
link
type="primary"
icon="Edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['formalities:listOfFormalities:edit']"
></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['formalities:listOfFormalities:remove']"
></el-button>
</el-tooltip>
</template>
</el-table-column> -->
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改手续办理清单模板对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="listOfFormalitiesFormRef" :model="form" :rules="rules" label-width="80px">
<!-- <el-form-item label="父级id" prop="pid">
<el-input v-model="form.pid" placeholder="请输入父级id" />
</el-form-item> -->
<el-form-item label="父级" prop="pid">
<el-select v-model="form.pid" placeholder="请选择父级">
<el-option label="根目录" value="0" />
<el-option v-for="item in listOfFormalitiesList" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item>
@ -108,11 +69,12 @@ import {
getListOfFormalities,
delListOfFormalities,
addListOfFormalities,
updateListOfFormalities
updateListOfFormalities,
getWhetherItExists
} from '@/api/formalities/listOfFormalities';
import { ListOfFormalitiesVO, ListOfFormalitiesQuery, ListOfFormalitiesForm } from '@/api/formalities/listOfFormalities/types';
import { useUserStoreHook } from '@/store/modules/user';
import formalitiesAreConsolidated from '@/views/formalities/formalitiesAreConsolidated/index.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
// 获取用户 store
const userStore = useUserStoreHook();
@ -135,6 +97,8 @@ const dialog = reactive<DialogOption>({
title: ''
});
const showFormalitiesAreConsolidated = ref(false);
const initFormData: ListOfFormalitiesForm = {
id: undefined,
pid: undefined,
@ -220,7 +184,7 @@ const handleOk = async () => {
const res = await addFormalitiesAreConsolidated(data);
if (res.code == 200) {
proxy?.$modal.msgSuccess('操作成功');
proxy?.$tab.openPage('/formalities/formalitiesAreConsolidated');
showFormalitiesAreConsolidated.value = true;
}
};
@ -272,6 +236,33 @@ const handleExport = () => {
};
onMounted(() => {
getWhetherItExists(currentProject.value.id).then((res) => {
if (res.data) {
showFormalitiesAreConsolidated.value = true;
return;
}
getList();
});
});
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value?.id,
(nid, oid) => {
getWhetherItExists(currentProject.value.id).then((res) => {
if (res.data) {
showFormalitiesAreConsolidated.value = true;
return;
}
showFormalitiesAreConsolidated.value = false;
getList();
});
}
);
onUnmounted(() => {
listeningProject();
});
</script>
<style scoped lang="scss"></style>