修改禅道bug
This commit is contained in:
@ -112,7 +112,7 @@
|
||||
<el-button type="primary" plain icon="Plus" @click="addUnitBoItem" style="margin-bottom: 15px">添加</el-button>
|
||||
<!-- 方阵表单:绑定unitBoList的索引,实现动态校验 -->
|
||||
<el-form ref="landBlockFormMatrixRef" :model="formM" label-width="100px">
|
||||
<el-row v-for="(item, i) of unitBoList" :key="i" class="mb-4">
|
||||
<el-row v-for="(item, i) of formM.unitBoList" :key="i" class="mb-4">
|
||||
<!-- 方阵选择:必填校验 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item
|
||||
@ -243,7 +243,6 @@ const initFormData: LandBlockForm = {
|
||||
// 核心数据(含表单规则)
|
||||
const data = reactive({
|
||||
form: { ...initFormData },
|
||||
formM: { landId: undefined }, // 方阵关联表单(仅存地块ID)
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@ -264,8 +263,8 @@ const data = reactive({
|
||||
landName: [{ required: true, message: '地块名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules, formM } = toRefs(data);
|
||||
const formM: any = ref({ landId: undefined, unitBoList: [{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }] }); // 方阵关联表单(仅存地块ID)
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询地块列表 */
|
||||
const getList = async () => {
|
||||
@ -400,17 +399,20 @@ const handleView = async (row: LandBlockVO) => {
|
||||
if (!row?.id) return proxy?.$modal.msgWarning('请选择有效的地块');
|
||||
|
||||
// 1. 重置方阵表单(清空历史数据)
|
||||
resetMatrix();
|
||||
|
||||
// 2. 绑定当前地块ID
|
||||
formM.value.landId = row.id;
|
||||
// 3. 打开弹窗
|
||||
dialogMatrix.visible = true;
|
||||
nextTick(() => {
|
||||
resetMatrix();
|
||||
});
|
||||
dialogMatrix.title = `关联方阵(地块:${row.landName || row.landCode})`;
|
||||
};
|
||||
|
||||
/** 新增方阵表单项 */
|
||||
const addUnitBoItem = () => {
|
||||
unitBoList.value.push({
|
||||
formM.value.unitBoList.push({
|
||||
unitProjectArea: '',
|
||||
unitProjectStatus: '',
|
||||
unitProjectId: [] // 级联选择初始为空数组
|
||||
@ -419,10 +421,10 @@ const addUnitBoItem = () => {
|
||||
|
||||
/** 删除方阵表单项 */
|
||||
const removeUnitBoItem = (index: number) => {
|
||||
if (unitBoList.value.length <= 1) {
|
||||
if (formM.value.unitBoList.length <= 1) {
|
||||
return proxy?.$modal.msgWarning('至少保留一项方阵配置');
|
||||
}
|
||||
unitBoList.value.splice(index, 1);
|
||||
formM.value.unitBoList.splice(index, 1);
|
||||
// 重置表单校验状态(避免删除后残留校验提示)
|
||||
landBlockFormMatrixRef.value?.clearValidate();
|
||||
};
|
||||
@ -435,7 +437,7 @@ const submitFormMatrix = () => {
|
||||
|
||||
try {
|
||||
// 处理方阵数据(拆分名称+ID)
|
||||
const unitBoListParams = unitBoList.value.map((item) => {
|
||||
const unitBoListParams = formM.value.unitBoList.map((item) => {
|
||||
const [unitProjectName, unitProjectId] = item.unitProjectId[1]?.split('_') || [];
|
||||
if (!unitProjectId) throw new Error('方阵ID解析失败,请重新选择方阵');
|
||||
|
||||
@ -455,7 +457,7 @@ const submitFormMatrix = () => {
|
||||
|
||||
if (res.code === 200) {
|
||||
proxy?.$modal.msgSuccess('关联方阵成功');
|
||||
dialogMatrix.visible = false;
|
||||
cancelMatrix(); // 关闭弹窗并重置表单
|
||||
await getList(); // 刷新地块列表
|
||||
} else {
|
||||
proxy?.$modal.msgError(res.msg || '关联失败');
|
||||
@ -477,7 +479,10 @@ const resetMatrix = () => {
|
||||
// 1. 清空地块ID
|
||||
formM.value.landId = undefined;
|
||||
// 2. 重置方阵列表(仅保留一个空项)
|
||||
unitBoList.value = [{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }];
|
||||
// 使用splice方法修改数组
|
||||
formM.value.unitBoList = [{ unitProjectArea: '', unitProjectStatus: '', unitProjectId: [] }];
|
||||
console.log(formM.value.unitBoList, 'unitBoList');
|
||||
|
||||
// 3. 重置表单校验状态
|
||||
if (landBlockFormMatrixRef.value) {
|
||||
landBlockFormMatrixRef.value.resetFields();
|
||||
|
Reference in New Issue
Block a user