Browse Source

bugfix:房间信息新增时无法将区域信息自动填充导致无法新增数据

bing 6 days ago
parent
commit
3d77c45438

+ 1 - 1
src/views/basics/room/ptArea/index.vue

@@ -220,7 +220,7 @@ const getTreeselect = async () => {
220
 
220
 
221
 const rowClick = (row: any, col: any, event: any) => {
221
 const rowClick = (row: any, col: any, event: any) => {
222
   selectedRowId.value = row.areaId;
222
   selectedRowId.value = row.areaId;
223
-  emit('getAreaId', row.areaId);
223
+  emit('getAreaId', row);
224
 };
224
 };
225
 const selectedRowId = ref<number>();
225
 const selectedRowId = ref<number>();
226
 const expandKeys = ref<string[]>([]);
226
 const expandKeys = ref<string[]>([]);

+ 5 - 1
src/views/basics/room/ptRoom/DetailForm.vue

@@ -128,11 +128,15 @@ const formRules = reactive({
128
 });
128
 });
129
 /** 当前组件方法 */
129
 /** 当前组件方法 */
130
 /** 窗体打开事件 */
130
 /** 窗体打开事件 */
131
-const open = async (type: string, id?: number) => {
131
+const open = async (type: string, id?: number, areaData?: any) => {
132
   dialog.visible = true;
132
   dialog.visible = true;
133
   dialog.title = t('action.' + type);
133
   dialog.title = t('action.' + type);
134
   formType.value = type;
134
   formType.value = type;
135
   resetForm();
135
   resetForm();
136
+  if (type === 'create') {
137
+    formData.value.areaId = areaData.areaId;
138
+    formData.value.areaName = areaData.areaName;
139
+  }
136
   // 修改时,设置数据
140
   // 修改时,设置数据
137
   if (id) {
141
   if (id) {
138
     formLoading.value = true;
142
     formLoading.value = true;

+ 8 - 4
src/views/basics/room/ptRoom/index.vue

@@ -2,7 +2,7 @@
2
   <div class="p-2 auto-overflow-y">
2
   <div class="p-2 auto-overflow-y">
3
     <el-row :gutter="10">
3
     <el-row :gutter="10">
4
       <el-col :lg="8" :xs="24">
4
       <el-col :lg="8" :xs="24">
5
-        <pt-area @get-area-id="getAreaId"></pt-area>
5
+        <ptArea @get-area-id="getAreaId"></ptArea>
6
       </el-col>
6
       </el-col>
7
       <el-col :lg="16" :xs="24" class="p-2">
7
       <el-col :lg="16" :xs="24" class="p-2">
8
         <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
8
         <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
@@ -190,6 +190,7 @@ import { PtRoomVO } from '@/api/basics/room/ptRoom/types';
190
 import DetailForm from './DetailForm.vue';
190
 import DetailForm from './DetailForm.vue';
191
 import ptArea from '../ptArea/index.vue';
191
 import ptArea from '../ptArea/index.vue';
192
 import { globalHeaders } from '@/utils/request';
192
 import { globalHeaders } from '@/utils/request';
193
+import { c } from 'node_modules/vite/dist/node/types.d-aGj9QkWt';
193
 const uploadRef = ref<ElUploadInstance>();
194
 const uploadRef = ref<ElUploadInstance>();
194
 
195
 
195
 defineOptions({ name: 'PtRoom' });
196
 defineOptions({ name: 'PtRoom' });
@@ -216,8 +217,9 @@ const unsetLoading = ref(false);
216
 
217
 
217
 const areaId = ref<string | number>(null);
218
 const areaId = ref<string | number>(null);
218
 
219
 
219
-const getAreaId = (v: string | number) => {
220
-  queryParams.areaId = v;
220
+const getAreaId = (v: any) => {
221
+  queryParams.areaId = v.areaId;
222
+  selectedArea.value = v;
221
   getList();
223
   getList();
222
 };
224
 };
223
 
225
 
@@ -263,6 +265,8 @@ const queryParams = reactive({
263
   params: {}
265
   params: {}
264
 });
266
 });
265
 
267
 
268
+const selectedArea = ref<any>({});
269
+
266
 /*** 用户导入参数 */
270
 /*** 用户导入参数 */
267
 const upload = reactive<ImportOption>({
271
 const upload = reactive<ImportOption>({
268
   // 是否显示弹出层(用户导入)
272
   // 是否显示弹出层(用户导入)
@@ -407,7 +411,7 @@ const handleFileSuccess = (response: any, file: UploadFile) => {
407
 const detailFormRef = ref();
411
 const detailFormRef = ref();
408
 const openForm = (type: string, row?: PtRoomVO) => {
412
 const openForm = (type: string, row?: PtRoomVO) => {
409
   const id = row?.roomId || ids.value[0];
413
   const id = row?.roomId || ids.value[0];
410
-  detailFormRef?.value.open(type, id);
414
+  detailFormRef?.value.open(type, id, selectedArea.value);
411
 };
415
 };
412
 onMounted(() => {
416
 onMounted(() => {
413
   getList();
417
   getList();