优化
This commit is contained in:
@ -6,7 +6,7 @@ VITE_APP_ENV = 'development'
|
|||||||
|
|
||||||
# 开发环境
|
# 开发环境
|
||||||
# 李陈杰 209
|
# 李陈杰 209
|
||||||
VITE_APP_BASE_API = 'http://192.168.110.188:8899'
|
VITE_APP_BASE_API = 'http://192.168.110.180:8899'
|
||||||
# 曾涛
|
# 曾涛
|
||||||
# VITE_APP_BASE_API = 'http://192.168.110.180:8899'
|
# VITE_APP_BASE_API = 'http://192.168.110.180:8899'
|
||||||
# 罗成
|
# 罗成
|
||||||
|
Binary file not shown.
@ -127,6 +127,17 @@ export const majorList = (params) => {
|
|||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 获取人员列表
|
||||||
|
* @param query
|
||||||
|
*/
|
||||||
|
export const copyUserList = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/design/volumeCatalog/copyUserList',
|
||||||
|
method: 'get',
|
||||||
|
params: params
|
||||||
|
});
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* 获取二维码信息
|
* 获取二维码信息
|
||||||
* @param query
|
* @param query
|
||||||
|
@ -5,8 +5,6 @@ import { ProjectTeamVO } from '@/api/project/projectTeam/types';
|
|||||||
import useUserStore from '@/store/modules/user';
|
import useUserStore from '@/store/modules/user';
|
||||||
export const getProjectTeam = async () => {
|
export const getProjectTeam = async () => {
|
||||||
const isPermission = useUserStore().permissions.some((item) => item == 'project:team:list');
|
const isPermission = useUserStore().permissions.some((item) => item == 'project:team:list');
|
||||||
console.log(useUserStore().permissions);
|
|
||||||
|
|
||||||
if (!isPermission && useUserStore().permissions[0] != '*:*:*') return;
|
if (!isPermission && useUserStore().permissions[0] != '*:*:*') return;
|
||||||
|
|
||||||
const { id } = $cache.local.getJSON('selectedProject');
|
const { id } = $cache.local.getJSON('selectedProject');
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="openTable(index)">{{ isExpandAll ? '一键收起' : '一键展开' }}</el-button>
|
<el-button type="primary" @click="openTable(index)">{{ isExpandAll ? '一键收起' : '一键展开' }}</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="success" @click="downloadTemplate(1)">下载模板</el-button>
|
<el-button type="success" @click="downloadTemplate(1)">下载模板</el-button>
|
||||||
@ -62,15 +62,10 @@
|
|||||||
</el-upload>
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="state.versionsData.status == 'draft'">
|
<el-form-item v-if="state.versionsData.status == 'draft'">
|
||||||
<el-button type="primary" con="edit" @click="clickApprovalSheet()">审核</el-button>
|
<el-button type="primary" con="edit" @click="clickApprovalSheet()">审核</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="state.versionsData.status == 'waiting' || state.versionsData.status == 'finish'">
|
<el-form-item v-if="state.versionsData.status == 'waiting' || state.versionsData.status == 'finish'">
|
||||||
<el-button
|
<el-button icon="view" @click="lookApprovalFlow()" type="warning">查看流程</el-button>
|
||||||
icon="view"
|
|
||||||
@click="lookApprovalFlow()"
|
|
||||||
type="warning"
|
|
||||||
>查看流程</el-button
|
|
||||||
>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -313,7 +308,7 @@ function handleChangeVersion(versions) {
|
|||||||
handleQueryList();
|
handleQueryList();
|
||||||
}
|
}
|
||||||
// 在 openTable 方法中通过索引获取对应的表格实例
|
// 在 openTable 方法中通过索引获取对应的表格实例
|
||||||
function openTable( index) {
|
function openTable(index) {
|
||||||
isExpandAll.value = !isExpandAll.value;
|
isExpandAll.value = !isExpandAll.value;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// 通过索引获取当前标签页的表格实例
|
// 通过索引获取当前标签页的表格实例
|
||||||
@ -358,12 +353,12 @@ function lookApprovalFlow(row) {
|
|||||||
const downloadTemplate = (type) => {
|
const downloadTemplate = (type) => {
|
||||||
// 导出模版文件
|
// 导出模版文件
|
||||||
try {
|
try {
|
||||||
let linkurl = '';
|
let linkurl = '';
|
||||||
let name = '';
|
let name = '';
|
||||||
if (type==1) {
|
if (type == 1) {
|
||||||
linkurl = '/billOfQuantities.xlsx';
|
linkurl = '/billOfQuantities.xlsx';
|
||||||
name = '工程量清单模板.xlsx';
|
name = '工程量清单模板.xlsx';
|
||||||
}else{
|
} else {
|
||||||
linkurl = '/materialsEquipment.xlsx';
|
linkurl = '/materialsEquipment.xlsx';
|
||||||
name = '物资设备清单模板.xlsx';
|
name = '物资设备清单模板.xlsx';
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,11 @@
|
|||||||
<el-form-item v-if="uploadForm.type == '3'" label="蓝图" prop="fileIds">
|
<el-form-item v-if="uploadForm.type == '3'" label="蓝图" prop="fileIds">
|
||||||
<file-upload :fileType="['pdf']" :isShowTip="false" :fileSize="100" v-model="uploadForm.fileIds"></file-upload>
|
<file-upload :fileType="['pdf']" :isShowTip="false" :fileSize="100" v-model="uploadForm.fileIds"></file-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item v-if="uploadForm.type == '3'" label="抄送人">
|
||||||
|
<el-select multiple filterable clearable v-model="form.userIds" placeholder="请选择抄送人">
|
||||||
|
<el-option :value="item.userId" v-for="item in userCoryList" :key="item.userId" :label="item.nickName + '-' + item.phonenumber" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item v-if="uploadForm.type == '1'" label="过程图纸" prop="cancellationIds">
|
<el-form-item v-if="uploadForm.type == '1'" label="过程图纸" prop="cancellationIds">
|
||||||
<file-upload :fileType="['pdf']" :isShowTip="false" :fileSize="100" v-model="uploadForm.cancellationIds"></file-upload>
|
<file-upload :fileType="['pdf']" :isShowTip="false" :fileSize="100" v-model="uploadForm.cancellationIds"></file-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -255,7 +260,8 @@ import {
|
|||||||
uploadVolumeFile,
|
uploadVolumeFile,
|
||||||
majorList,
|
majorList,
|
||||||
getVolumeCatafileList,
|
getVolumeCatafileList,
|
||||||
volumeFileList
|
volumeFileList,
|
||||||
|
copyUserList
|
||||||
} from '@/api/design/volumeCatalog';
|
} from '@/api/design/volumeCatalog';
|
||||||
import { VolumeCatalogVO } from '@/api/design/volumeCatalog/types';
|
import { VolumeCatalogVO } from '@/api/design/volumeCatalog/types';
|
||||||
import { useUserStoreHook } from '@/store/modules/user';
|
import { useUserStoreHook } from '@/store/modules/user';
|
||||||
@ -281,6 +287,7 @@ const uploadOpinionVisible = ref(false);
|
|||||||
const design = ref('');
|
const design = ref('');
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const dialogHistory = ref(false);
|
const dialogHistory = ref(false);
|
||||||
|
const userCoryList = ref([]);
|
||||||
const opinion = ref('');
|
const opinion = ref('');
|
||||||
const updateRow = ref({
|
const updateRow = ref({
|
||||||
opinion: []
|
opinion: []
|
||||||
@ -416,7 +423,13 @@ const cancel = () => {
|
|||||||
reset();
|
reset();
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
};
|
};
|
||||||
|
// 获取人员列表
|
||||||
|
const getDesignUserList = async () => {
|
||||||
|
const res = await copyUserList({});
|
||||||
|
if (res.code === 200) {
|
||||||
|
userCoryList.value = res.data;
|
||||||
|
}
|
||||||
|
};
|
||||||
/** 表单重置 */
|
/** 表单重置 */
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
form.value = { ...initFormData };
|
form.value = { ...initFormData };
|
||||||
@ -546,7 +559,7 @@ const onSubmit = async () => {
|
|||||||
type: uploadForm.type
|
type: uploadForm.type
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await uploadVolumeFile(obj);
|
await uploadVolumeFile({ ...obj, userIds: form.value.userIds });
|
||||||
proxy?.$modal.msgSuccess('文件上传成功');
|
proxy?.$modal.msgSuccess('文件上传成功');
|
||||||
uploadVisible.value = false;
|
uploadVisible.value = false;
|
||||||
await getList();
|
await getList();
|
||||||
@ -656,6 +669,7 @@ const handleAuditInfo = (row) => {
|
|||||||
// 审核图纸
|
// 审核图纸
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getDesignUserList();
|
||||||
getSpecialtyList();
|
getSpecialtyList();
|
||||||
getList();
|
getList();
|
||||||
});
|
});
|
||||||
@ -666,6 +680,7 @@ const listeningProject = watch(
|
|||||||
(nid, oid) => {
|
(nid, oid) => {
|
||||||
queryParams.value.projectId = nid;
|
queryParams.value.projectId = nid;
|
||||||
form.value.projectId = nid;
|
form.value.projectId = nid;
|
||||||
|
getDesignUserList();
|
||||||
getSpecialtyList();
|
getSpecialtyList();
|
||||||
getList();
|
getList();
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="monthPlanList">
|
<el-table v-loading="loading" :data="monthPlanList">
|
||||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
<el-table-column type="index" label="序号" width="55" align="center" />
|
||||||
<el-table-column label="计划月份" align="center" prop="planMonth" />
|
<el-table-column label="计划月份" align="center" prop="planMonth" />
|
||||||
|
@ -175,7 +175,7 @@ const getInfo = () => {
|
|||||||
form.value = res.data as any;
|
form.value = res.data as any;
|
||||||
|
|
||||||
console.log('🚀 ~ getInfo ~ form.value:', form.value[0].projectId);
|
console.log('🚀 ~ getInfo ~ form.value:', form.value[0].projectId);
|
||||||
|
form.value[0].mid = form.value[0].id;
|
||||||
form.value[0].id = form.value[0].projectId + '_' + form.value[0].planMonth;
|
form.value[0].id = form.value[0].projectId + '_' + form.value[0].planMonth;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
buttonLoading.value = false;
|
buttonLoading.value = false;
|
||||||
@ -231,13 +231,15 @@ const approvalVerifyOpen = async () => {
|
|||||||
// 图纸上传成功之后 开始提交
|
// 图纸上传成功之后 开始提交
|
||||||
const submit = async (status, data) => {
|
const submit = async (status, data) => {
|
||||||
form.value = data;
|
form.value = data;
|
||||||
|
console.log(form.value);
|
||||||
|
|
||||||
if (status === 'draft') {
|
if (status === 'draft') {
|
||||||
buttonLoading.value = false;
|
buttonLoading.value = false;
|
||||||
proxy?.$modal.msgSuccess('暂存成功');
|
proxy?.$modal.msgSuccess('暂存成功');
|
||||||
proxy.$tab.closePage(proxy.$route);
|
proxy.$tab.closePage(proxy.$route);
|
||||||
proxy.$router.go(-1);
|
proxy.$router.go(-1);
|
||||||
} else {
|
} else {
|
||||||
const res = await isSubmit(data[1]?.id);
|
const res = await isSubmit(data[0]?.mid);
|
||||||
|
|
||||||
if (!res.data) {
|
if (!res.data) {
|
||||||
proxy?.$modal.msgError('三种计划产值必须填写');
|
proxy?.$modal.msgError('三种计划产值必须填写');
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 地块表单弹窗 -->
|
<!-- 地块表单弹窗 -->
|
||||||
<el-dialog draggable :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
<el-dialog draggable :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||||
<el-form ref="landBlockFormRef" :model="form" :rules="rules" label-width="100px">
|
<el-form ref="landBlockFormRef" :model="form" :rules="rules" label-width="100px">
|
||||||
@ -107,20 +108,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!-- 关联方阵弹窗(核心修改区域) -->
|
|
||||||
|
<!-- 关联方阵弹窗(核心修复区域) -->
|
||||||
<el-dialog draggable :title="dialogMatrix.title" v-model="dialogMatrix.visible" width="900px" append-to-body>
|
<el-dialog draggable :title="dialogMatrix.title" v-model="dialogMatrix.visible" width="900px" append-to-body>
|
||||||
<el-button type="primary" plain icon="Plus" @click="addUnitBoItem" style="margin-bottom: 15px">添加</el-button>
|
<el-button type="primary" plain icon="Plus" @click="addUnitBoItem" style="margin-bottom: 15px">添加</el-button>
|
||||||
<!-- 方阵表单:绑定unitBoList的索引,实现动态校验 -->
|
<!-- 修复1:表单模型绑定formM(根模型),确保嵌套字段校验生效 -->
|
||||||
<el-form ref="landBlockFormMatrixRef" :model="formM" label-width="100px">
|
<el-form ref="landBlockFormMatrixRef" :model="formM" label-width="100px">
|
||||||
<el-row v-for="(item, i) of unitBoList" :key="i" class="mb-4">
|
<!-- 修复2:循环formM.unitBoList(而非独立ref),保证数据双向绑定 -->
|
||||||
<!-- 方阵选择:必填校验 -->
|
<el-row v-for="(item, i) of formM.unitBoList" :key="i" class="mb-4">
|
||||||
|
<!-- 方阵选择:修复校验规则(移除min:2,改为min:1,适配单层级选择) -->
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="方阵"
|
label="方阵"
|
||||||
:prop="`unitBoList[${i}].unitProjectId`"
|
:prop="`unitBoList[${i}].unitProjectId`"
|
||||||
:rules="[
|
:rules="[
|
||||||
{ required: true, message: '请选择方阵', trigger: 'change' },
|
{ required: true, message: '请选择方阵', trigger: 'change' },
|
||||||
{ type: 'array', min: 2, message: '请选择完整的方阵层级', trigger: 'change' }
|
{ type: 'array', min: 1, message: '请选择完整的方阵', trigger: 'change' }
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<el-cascader
|
<el-cascader
|
||||||
@ -133,7 +136,7 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- 所属工区:必填校验 -->
|
<!-- 所属工区:保留原有规则 -->
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="所属工区"
|
label="所属工区"
|
||||||
@ -143,7 +146,7 @@
|
|||||||
<el-input v-model="item.unitProjectArea" placeholder="请输入所属工区" />
|
<el-input v-model="item.unitProjectArea" placeholder="请输入所属工区" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- 方阵状态:必填校验 -->
|
<!-- 方阵状态:保留原有规则 -->
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="方阵状态"
|
label="方阵状态"
|
||||||
@ -153,8 +156,15 @@
|
|||||||
<el-input v-model="item.unitProjectStatus" placeholder="请输入方阵状态" />
|
<el-input v-model="item.unitProjectStatus" placeholder="请输入方阵状态" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<!-- 删除按钮:禁用逻辑优化(至少保留1项) -->
|
||||||
<el-col :span="1" style="margin-left: 15px; display: flex; align-items: flex-end">
|
<el-col :span="1" style="margin-left: 15px; display: flex; align-items: flex-end">
|
||||||
<el-button style="margin-bottom: 18px" type="danger" icon="Delete" @click="removeUnitBoItem(i)"></el-button>
|
<el-button
|
||||||
|
style="margin-bottom: 18px"
|
||||||
|
type="danger"
|
||||||
|
icon="Delete"
|
||||||
|
@click="removeUnitBoItem(i)"
|
||||||
|
:disabled="formM.unitBoList.length <= 1"
|
||||||
|
></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -181,21 +191,35 @@ import {
|
|||||||
} from '@/api/system/landTransfer/landBlock';
|
} from '@/api/system/landTransfer/landBlock';
|
||||||
import { LandBlockVO, LandBlockQuery, LandBlockForm } from '@/api/system/landTransfer/landBlock/types';
|
import { LandBlockVO, LandBlockQuery, LandBlockForm } from '@/api/system/landTransfer/landBlock/types';
|
||||||
import { useUserStoreHook } from '@/store/modules/user';
|
import { useUserStoreHook } from '@/store/modules/user';
|
||||||
import { getCurrentInstance, ComponentInternalInstance, onMounted, onUnmounted, watch } from 'vue';
|
import { getCurrentInstance, ComponentInternalInstance, onMounted, onUnmounted, watch, reactive, ref, toRefs, computed } from 'vue';
|
||||||
import { ElFormInstance, ElMessage } from 'element-plus';
|
import { ElFormInstance } from 'element-plus';
|
||||||
|
|
||||||
// 类型定义补充(避免any)
|
// 类型定义补充
|
||||||
interface DialogOption {
|
interface DialogOption {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 方阵级联选择器选项类型
|
||||||
|
interface FangzhenOption {
|
||||||
|
matrixId: string | number;
|
||||||
|
name: string;
|
||||||
|
children?: FangzhenOption[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方阵表单项类型
|
||||||
interface UnitBoItem {
|
interface UnitBoItem {
|
||||||
unitProjectArea: string;
|
unitProjectArea: string;
|
||||||
unitProjectStatus: string;
|
unitProjectStatus: string;
|
||||||
unitProjectId: (string | number)[]; // 级联选择值(数组)
|
unitProjectId: (string | number)[]; // 级联选择值(数组)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 方阵表单根模型类型(关键:显式声明unitBoList)
|
||||||
|
interface MatrixForm {
|
||||||
|
landId?: string | number; // 关联的地块ID
|
||||||
|
unitBoList: UnitBoItem[]; // 方阵列表
|
||||||
|
}
|
||||||
|
|
||||||
// 基础实例与Store
|
// 基础实例与Store
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
const userStore = useUserStoreHook();
|
const userStore = useUserStoreHook();
|
||||||
@ -203,14 +227,17 @@ const currentProject = computed(() => userStore.selectedProject);
|
|||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const landBlockList = ref<LandBlockVO[]>([]);
|
const landBlockList = ref<LandBlockVO[]>([]);
|
||||||
const fangzhenList = ref<any[]>([]); // 方阵列表(实际项目建议定义具体类型)
|
const fangzhenList = ref<FangzhenOption[]>([]);
|
||||||
const buttonLoading = ref(false);
|
const buttonLoading = ref(false);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const showSearch = ref(true);
|
const showSearch = ref(true);
|
||||||
const uploadRef = ref<any>(null); // upload组件ref
|
const uploadRef = ref<any>(null);
|
||||||
|
|
||||||
// 方阵表单数据(核心修改:初始值为空,避免默认填充无效数据)
|
// 方阵表单模型(核心修复:使用reactive并显式声明结构)
|
||||||
const unitBoList = ref<UnitBoItem[]>([{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }]);
|
const formM = reactive<MatrixForm>({
|
||||||
|
landId: undefined,
|
||||||
|
unitBoList: [{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }]
|
||||||
|
});
|
||||||
|
|
||||||
// 表格选择相关
|
// 表格选择相关
|
||||||
const ids = ref<Array<string | number>>([]);
|
const ids = ref<Array<string | number>>([]);
|
||||||
@ -243,7 +270,6 @@ const initFormData: LandBlockForm = {
|
|||||||
// 核心数据(含表单规则)
|
// 核心数据(含表单规则)
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
form: { ...initFormData },
|
form: { ...initFormData },
|
||||||
formM: { landId: undefined }, // 方阵关联表单(仅存地块ID)
|
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@ -256,7 +282,7 @@ const data = reactive({
|
|||||||
farmerCount: undefined,
|
farmerCount: undefined,
|
||||||
params: {}
|
params: {}
|
||||||
},
|
},
|
||||||
// 地块表单规则(原有规则保留)
|
// 地块表单规则
|
||||||
rules: {
|
rules: {
|
||||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||||
projectId: [{ required: true, message: '项目ID不能为空', trigger: 'blur' }],
|
projectId: [{ required: true, message: '项目ID不能为空', trigger: 'blur' }],
|
||||||
@ -265,7 +291,7 @@ const data = reactive({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { queryParams, form, rules, formM } = toRefs(data);
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
/** 查询地块列表 */
|
/** 查询地块列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
@ -381,10 +407,10 @@ const getfangzhenList = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await subMatrix(currentProject.value.id);
|
const res = await subMatrix(currentProject.value.id);
|
||||||
// 处理方阵数据(级联选择需父子结构,此处保留原有逻辑)
|
// 处理方阵数据(级联选择需父子结构)
|
||||||
res.data.forEach((item: any) => {
|
res.data.forEach((item: any) => {
|
||||||
item.children?.forEach((item2: any) => {
|
item.children?.forEach((item2: any) => {
|
||||||
item2.matrixId = `${item2.name}_${item2.matrixId}`; // 拼接名称+ID,便于后续拆分
|
item2.matrixId = `${item2.name}_${item2.matrixId}`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
fangzhenList.value = res.data;
|
fangzhenList.value = res.data;
|
||||||
@ -395,68 +421,74 @@ const getfangzhenList = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 关联方阵(核心修改:打开弹窗前强制重置表单) */
|
/** 关联方阵 */
|
||||||
const handleView = async (row: LandBlockVO) => {
|
const handleView = async (row: LandBlockVO) => {
|
||||||
if (!row?.id) return proxy?.$modal.msgWarning('请选择有效的地块');
|
if (!row?.id) return proxy?.$modal.msgWarning('请选择有效的地块');
|
||||||
|
|
||||||
// 1. 重置方阵表单(清空历史数据)
|
// 重置方阵表单
|
||||||
resetMatrix();
|
resetMatrix();
|
||||||
// 2. 绑定当前地块ID
|
// 绑定当前地块ID
|
||||||
formM.value.landId = row.id;
|
formM.landId = row.id;
|
||||||
// 3. 打开弹窗
|
// 打开弹窗
|
||||||
dialogMatrix.visible = true;
|
dialogMatrix.visible = true;
|
||||||
dialogMatrix.title = `关联方阵(地块:${row.landName || row.landCode})`;
|
dialogMatrix.title = `关联方阵(地块:${row.landName || row.landCode})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 新增方阵表单项 */
|
/** 新增方阵表单项 */
|
||||||
const addUnitBoItem = () => {
|
const addUnitBoItem = () => {
|
||||||
unitBoList.value.push({
|
formM.unitBoList.push({
|
||||||
unitProjectArea: '',
|
unitProjectArea: '',
|
||||||
unitProjectStatus: '',
|
unitProjectStatus: '',
|
||||||
unitProjectId: [] // 级联选择初始为空数组
|
unitProjectId: []
|
||||||
});
|
});
|
||||||
|
// 重置校验状态
|
||||||
|
landBlockFormMatrixRef.value?.clearValidate();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 删除方阵表单项 */
|
/** 删除方阵表单项 */
|
||||||
const removeUnitBoItem = (index: number) => {
|
const removeUnitBoItem = (index: number) => {
|
||||||
if (unitBoList.value.length <= 1) {
|
if (formM.unitBoList.length <= 1) {
|
||||||
return proxy?.$modal.msgWarning('至少保留一项方阵配置');
|
return proxy?.$modal.msgWarning('至少保留一项方阵配置');
|
||||||
}
|
}
|
||||||
unitBoList.value.splice(index, 1);
|
formM.unitBoList.splice(index, 1);
|
||||||
// 重置表单校验状态(避免删除后残留校验提示)
|
|
||||||
landBlockFormMatrixRef.value?.clearValidate();
|
landBlockFormMatrixRef.value?.clearValidate();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 提交方阵关联表单 */
|
/** 提交方阵关联表单(核心修复:数据处理逻辑) */
|
||||||
const submitFormMatrix = () => {
|
const submitFormMatrix = () => {
|
||||||
landBlockFormMatrixRef.value?.validate(async (valid: boolean) => {
|
landBlockFormMatrixRef.value?.validate(async (valid: boolean) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
if (!formM.value.landId) return proxy?.$modal.msgWarning('地块ID异常,请重新选择地块');
|
if (!formM.landId) return proxy?.$modal.msgWarning('地块ID异常,请重新选择地块');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 处理方阵数据(拆分名称+ID)
|
// 处理方阵数据(修复ID拆分逻辑)
|
||||||
const unitBoListParams = unitBoList.value.map((item) => {
|
const unitBoListParams = formM.unitBoList.map((item) => {
|
||||||
const [unitProjectName, unitProjectId] = item.unitProjectId[1]?.split('_') || [];
|
// 取级联选择的最后一层值
|
||||||
if (!unitProjectId) throw new Error('方阵ID解析失败,请重新选择方阵');
|
const lastLevelValue = item.unitProjectId[item.unitProjectId.length - 1];
|
||||||
|
if (!lastLevelValue) throw new Error('请选择完整的方阵');
|
||||||
|
|
||||||
|
// 拆分名称和ID
|
||||||
|
const [unitProjectName, unitProjectId] = String(lastLevelValue).split('_');
|
||||||
|
if (!unitProjectId) throw new Error('方阵ID解析失败,请重新选择');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
unitProjectArea: item.unitProjectArea.trim(),
|
unitProjectArea: item.unitProjectArea.trim(),
|
||||||
unitProjectStatus: item.unitProjectStatus.trim(),
|
unitProjectStatus: item.unitProjectStatus.trim(),
|
||||||
unitProjectId: unitProjectId, // 纯ID(后端需要)
|
unitProjectId: unitProjectId,
|
||||||
unitProjectName: unitProjectName // 名称(可选,用于显示)
|
unitProjectName: unitProjectName
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 调用关联接口
|
// 调用关联接口
|
||||||
const res = await LandUnit({
|
const res = await LandUnit({
|
||||||
landId: formM.value.landId,
|
landId: formM.landId,
|
||||||
unitBoList: unitBoListParams
|
unitBoList: unitBoListParams
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
proxy?.$modal.msgSuccess('关联方阵成功');
|
proxy?.$modal.msgSuccess('关联方阵成功');
|
||||||
dialogMatrix.visible = false;
|
dialogMatrix.visible = false;
|
||||||
await getList(); // 刷新地块列表
|
await getList();
|
||||||
} else {
|
} else {
|
||||||
proxy?.$modal.msgError(res.msg || '关联失败');
|
proxy?.$modal.msgError(res.msg || '关联失败');
|
||||||
}
|
}
|
||||||
@ -472,13 +504,10 @@ const cancelMatrix = () => {
|
|||||||
dialogMatrix.visible = false;
|
dialogMatrix.visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 方阵表单重置(核心修改:清空所有数据+重置校验) */
|
/** 方阵表单重置 */
|
||||||
const resetMatrix = () => {
|
const resetMatrix = () => {
|
||||||
// 1. 清空地块ID
|
formM.landId = undefined;
|
||||||
formM.value.landId = undefined;
|
formM.unitBoList = [{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }];
|
||||||
// 2. 重置方阵列表(仅保留一个空项)
|
|
||||||
unitBoList.value = [{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }];
|
|
||||||
// 3. 重置表单校验状态
|
|
||||||
if (landBlockFormMatrixRef.value) {
|
if (landBlockFormMatrixRef.value) {
|
||||||
landBlockFormMatrixRef.value.resetFields();
|
landBlockFormMatrixRef.value.resetFields();
|
||||||
landBlockFormMatrixRef.value.clearValidate();
|
landBlockFormMatrixRef.value.clearValidate();
|
||||||
@ -491,11 +520,11 @@ const listeningProject = watch(
|
|||||||
(newId) => {
|
(newId) => {
|
||||||
if (newId) {
|
if (newId) {
|
||||||
queryParams.value.projectId = newId;
|
queryParams.value.projectId = newId;
|
||||||
getfangzhenList(); // 刷新方阵列表
|
getfangzhenList();
|
||||||
getList(); // 刷新地块列表
|
getList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true } // 初始加载时执行一次
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
/** 导入Excel */
|
/** 导入Excel */
|
||||||
@ -524,36 +553,34 @@ const handleImport = (options: { file: File }) => {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 导出模板 */
|
||||||
const exportFile = () => {
|
const exportFile = () => {
|
||||||
// 导出模版文件
|
|
||||||
try {
|
try {
|
||||||
// 创建a标签
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
// 设置PDF文件路径 - 相对于public目录
|
|
||||||
link.href = '/dikuai.xlsx';
|
link.href = '/dikuai.xlsx';
|
||||||
// 设置下载后的文件名
|
|
||||||
link.download = '地块信息导入模版.xlsx';
|
link.download = '地块信息导入模版.xlsx';
|
||||||
// 触发点击
|
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
// 清理
|
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert('下载失败,请重试');
|
alert('下载失败,请重试');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 下载导入模板 */
|
/** 下载导入模板 */
|
||||||
const downloadTemplate = () => {
|
const downloadTemplate = () => {
|
||||||
try {
|
try {
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = '/landBlock.xlsx'; // 模板路径(需确保public目录下存在该文件)
|
link.href = '/landBlock.xlsx';
|
||||||
link.download = '地块信息导入模板.xlsx'; // 下载后文件名
|
link.download = '地块信息导入模板.xlsx';
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click(); // 触发下载
|
link.click();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
proxy?.$modal.msgError('模板下载失败,请重试');
|
proxy?.$modal.msgError('模板下载失败,请重试');
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(link); // 清理DOM
|
const link = document.querySelector('a[download="地块信息导入模板.xlsx"]');
|
||||||
|
if (link) document.body.removeChild(link);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user