4fa77310 by xukangle

update: 优化分类分级交互

1 parent 1859a94d
...@@ -53,6 +53,7 @@ const levelMap = { ...@@ -53,6 +53,7 @@ const levelMap = {
53 4: '四级', 53 4: '四级',
54 } 54 }
55 const currTableInfo = ref<any>({}); 55 const currTableInfo = ref<any>({});
56 const drawerRef = ref<any>('');
56 57
57 const tableInfo = ref({ 58 const tableInfo = ref({
58 id: "data-class-standard-table", 59 id: "data-class-standard-table",
...@@ -92,7 +93,8 @@ const tableInfo = ref({ ...@@ -92,7 +93,8 @@ const tableInfo = ref({
92 btns: [ 93 btns: [
93 { 94 {
94 label: "编辑", value: "edit", click: (scope) => { 95 label: "编辑", value: "edit", click: (scope) => {
95 console.log(scope); 96 // console.log(drawerRef.value.drawerFormRef[0].ruleFormRef);
97 currentEditingGuid.value = scope.row.guid;
96 selectParentEdit(scope.row.guid); 98 selectParentEdit(scope.row.guid);
97 currTableInfo.value = scope.row; 99 currTableInfo.value = scope.row;
98 drawerInfo.value.visible = true; 100 drawerInfo.value.visible = true;
...@@ -193,9 +195,38 @@ const classEditFormItems = ref([{ ...@@ -193,9 +195,38 @@ const classEditFormItems = ref([{
193 block: true 195 block: true
194 }]); 196 }]);
195 197
198 // const validateUniqueClassifyName = (rule, value, callback) => {
199 // console.log('validateUniqueClassifyName', value);
200 // // 递归遍历treeListData,判断是否有重复的分类名称
201 // // 检查空值情况
202 // if (!value) {
203 // callback(new Error('请填写分类名称'));
204 // return;
205 // }
206
207 // // 递归检查函数
208 // const isExist = (data, value) => {
209 // return data.some(item => {
210 // if (item.classifyName === value) {
211 // return true;
212 // }
213 // return item.children && isExist(item.children, value);
214 // });
215 // };
216
217 // // 检查是否存在
218 // if (isExist(treeListData.value, value)) {
219 // callback(new Error('分类名称已存在,请填写其他名称'));
220 // } else {
221 // callback(); // 校验通过
222 // }
223 // }
224
225 let currentEditingGuid = ref<any>('');
226
196 const validateUniqueClassifyName = (rule, value, callback) => { 227 const validateUniqueClassifyName = (rule, value, callback) => {
197 console.log('validateUniqueClassifyName', value); 228 console.log('validateUniqueClassifyName', treeListData.value, value, currentEditingGuid);
198 // 递归遍历treeListData,判断是否有重复的分类名称 229
199 // 检查空值情况 230 // 检查空值情况
200 if (!value) { 231 if (!value) {
201 callback(new Error('请填写分类名称')); 232 callback(new Error('请填写分类名称'));
...@@ -203,22 +234,26 @@ const validateUniqueClassifyName = (rule, value, callback) => { ...@@ -203,22 +234,26 @@ const validateUniqueClassifyName = (rule, value, callback) => {
203 } 234 }
204 235
205 // 递归检查函数 236 // 递归检查函数
206 const isExist = (data, value) => { 237 const isExist = (data, value, guid) => {
207 return data.some(item => { 238 return data.some(item => {
239 // 如果是编辑模式,忽略当前分类的校验
240 if (item.guid === guid) {
241 return false;
242 }
208 if (item.classifyName === value) { 243 if (item.classifyName === value) {
209 return true; 244 return true;
210 } 245 }
211 return item.children && isExist(item.children, value); 246 return item.children && isExist(item.children, value, guid);
212 }); 247 });
213 }; 248 };
214 249
215 // 检查是否存在 250 // 检查是否存在
216 if (isExist(treeListData.value, value)) { 251 if (isExist(treeListData.value, value, currentEditingGuid.value)) {
217 callback(new Error('分类名称已存在,请填写其他名称')); 252 callback(new Error('分类名称已存在,请填写其他名称'));
218 } else { 253 } else {
219 callback(); // 校验通过 254 callback(); // 校验通过
220 } 255 }
221 } 256 };
222 257
223 258
224 const classEditFormRules = ref({ 259 const classEditFormRules = ref({
...@@ -254,6 +289,7 @@ const drawerInfo = ref({ ...@@ -254,6 +289,7 @@ const drawerInfo = ref({
254 contents: [classEditFormInfo.value], 289 contents: [classEditFormInfo.value],
255 }, 290 },
256 footer: { 291 footer: {
292 visible: true,
257 btns: [ 293 btns: [
258 { type: 'default', label: '取消', value: 'cancel' }, 294 { type: 'default', label: '取消', value: 'cancel' },
259 { type: 'primary', label: '确定', value: 'save', loading: false }, 295 { type: 'primary', label: '确定', value: 'save', loading: false },
...@@ -266,6 +302,7 @@ const drawerBtnClick = async (btn, info) => { ...@@ -266,6 +302,7 @@ const drawerBtnClick = async (btn, info) => {
266 drawerInfo.value.visible = false; 302 drawerInfo.value.visible = false;
267 } else { 303 } else {
268 if (drawerInfo.value.header.title == '添加分类') { 304 if (drawerInfo.value.header.title == '添加分类') {
305 drawerInfo.value.footer.btns.map((item: any) => (item.disabled = true));
269 const params = { 306 const params = {
270 ...info, 307 ...info,
271 classifyGradeGuid: router.currentRoute.value.query.guid, 308 classifyGradeGuid: router.currentRoute.value.query.guid,
...@@ -275,11 +312,13 @@ const drawerBtnClick = async (btn, info) => { ...@@ -275,11 +312,13 @@ const drawerBtnClick = async (btn, info) => {
275 proxy.$ElMessage.success('添加成功!'); 312 proxy.$ElMessage.success('添加成功!');
276 drawerInfo.value.visible = false; 313 drawerInfo.value.visible = false;
277 getTreeListData(); 314 getTreeListData();
315 drawerInfo.value.footer.btns.map((item: any) => delete item.disabled);
278 } else { 316 } else {
279 proxy.$ElMessage.error(res.msg); 317 proxy.$ElMessage.error(res.msg);
280 } 318 }
281 } else { 319 } else {
282 // 编辑分类 320 // 编辑分类
321 drawerInfo.value.footer.btns.map((item: any) => (item.disabled = true));
283 const params = { 322 const params = {
284 ...info, 323 ...info,
285 classifyGradeGuid: router.currentRoute.value.query.guid, 324 classifyGradeGuid: router.currentRoute.value.query.guid,
...@@ -289,7 +328,10 @@ const drawerBtnClick = async (btn, info) => { ...@@ -289,7 +328,10 @@ const drawerBtnClick = async (btn, info) => {
289 if (res.code == proxy.$passCode) { 328 if (res.code == proxy.$passCode) {
290 proxy.$ElMessage.success('修改成功!'); 329 proxy.$ElMessage.success('修改成功!');
291 drawerInfo.value.visible = false; 330 drawerInfo.value.visible = false;
331 drawerInfo.value.footer.btns.map((item: any) => delete item.disabled);
292 getTreeListData(); 332 getTreeListData();
333 // 清空当前编辑的guid
334 currentEditingGuid.value = '';
293 } else { 335 } else {
294 proxy.$ElMessage.error(res.msg); 336 proxy.$ElMessage.error(res.msg);
295 } 337 }
...@@ -327,12 +369,14 @@ const treeListParams = ref({ ...@@ -327,12 +369,14 @@ const treeListParams = ref({
327 }); 369 });
328 const treeListData = ref([]); 370 const treeListData = ref([]);
329 const getTreeListData = async () => { 371 const getTreeListData = async () => {
372 tableInfo.value.loading = true;
330 const res: any = await getClassifyTreeList(treeListParams.value); 373 const res: any = await getClassifyTreeList(treeListParams.value);
331 if (res.code == proxy.$passCode) { 374 if (res.code == proxy.$passCode) {
332 treeListData.value = res.data || []; 375 treeListData.value = res.data || [];
333 tableInfo.value.data = treeListData.value; 376 tableInfo.value.data = treeListData.value;
334 classEditFormItems.value[2].options = treeListData.value; 377 classEditFormItems.value[2].options = treeListData.value;
335 shapeTreeListData.value = treeListData.value; 378 shapeTreeListData.value = treeListData.value;
379 tableInfo.value.loading = false;
336 } else { 380 } else {
337 proxy.$ElMessage.error(res.msg); 381 proxy.$ElMessage.error(res.msg);
338 } 382 }
...@@ -388,6 +432,7 @@ const getGradeListData = async () => { ...@@ -388,6 +432,7 @@ const getGradeListData = async () => {
388 } 432 }
389 433
390 const newCreateClass = () => { 434 const newCreateClass = () => {
435
391 drawerInfo.value.visible = true; 436 drawerInfo.value.visible = true;
392 classEditFormItems.value[2].options = treeListData.value; 437 classEditFormItems.value[2].options = treeListData.value;
393 drawerInfo.value.header.title = '添加分类'; 438 drawerInfo.value.header.title = '添加分类';
...@@ -734,7 +779,7 @@ onMounted(() => { ...@@ -734,7 +779,7 @@ onMounted(() => {
734 <div class="bottom_tool_wrap"> 779 <div class="bottom_tool_wrap">
735 <el-button @click="cancel">取消</el-button> 780 <el-button @click="cancel">取消</el-button>
736 </div> 781 </div>
737 <Drawer :drawerInfo="drawerInfo" @drawerBtnClick="drawerBtnClick" /> 782 <Drawer :drawerInfo="drawerInfo" @drawerBtnClick="drawerBtnClick" ref="drawerRef" />
738 </div> 783 </div>
739 </template> 784 </template>
740 785
......
...@@ -8,13 +8,16 @@ import router from "@/router"; ...@@ -8,13 +8,16 @@ import router from "@/router";
8 import { ref } from "vue"; 8 import { ref } from "vue";
9 import { saveGrade, getGradeList, deleteGrade, getLargeCategoryList, updateGrade } from '@/api/modules/dataInventory'; 9 import { saveGrade, getGradeList, deleteGrade, getLargeCategoryList, updateGrade } from '@/api/modules/dataInventory';
10 10
11 onMounted(() => { 11 onBeforeMount(() => {
12 getGradeListData(); 12 getGradeListData();
13 Promise.all([getDataGrade(), getDataClassify()]); 13 getDataGrade();
14 getDataClassify();
14 }); 15 });
15 16
16 // 获取分级列表 17 // 获取分级列表
17 const getGradeListData = async () => { 18 const getGradeListData = async () => {
19 console.log('调用了吗~~~');
20 tableInfo.value.loading = true;
18 const params = { 21 const params = {
19 pageIndex: 1, 22 pageIndex: 1,
20 pageSize: -1, 23 pageSize: -1,
...@@ -23,6 +26,7 @@ const getGradeListData = async () => { ...@@ -23,6 +26,7 @@ const getGradeListData = async () => {
23 const res: any = await getGradeList(params); 26 const res: any = await getGradeList(params);
24 if (res.code == proxy.$passCode) { 27 if (res.code == proxy.$passCode) {
25 tableInfo.value.data = res.data.records; 28 tableInfo.value.data = res.data.records;
29 tableInfo.value.loading = false;
26 } else { 30 } else {
27 proxy.$ElMessage.error(res.msg); 31 proxy.$ElMessage.error(res.msg);
28 } 32 }
...@@ -94,9 +98,9 @@ const filterDataGradeEdit = (dataGrade: string) => { ...@@ -94,9 +98,9 @@ const filterDataGradeEdit = (dataGrade: string) => {
94 (newCreateGradeFormItems.value[0].options as any[]) = filteredOptions; 98 (newCreateGradeFormItems.value[0].options as any[]) = filteredOptions;
95 }; 99 };
96 100
97 const tableRef = ref(); 101 const tableRef = ref<any>();
98 const classDataRef = ref(); 102 const classDataRef = ref<any[]>([]);
99 const gradeDataRef = ref(); 103 const gradeDataRef = ref<any>();
100 const fullscreenLoading = ref(false); 104 const fullscreenLoading = ref(false);
101 const editClassifyGradeGuid = ref(''); 105 const editClassifyGradeGuid = ref('');
102 const { proxy } = getCurrentInstance() as any; 106 const { proxy } = getCurrentInstance() as any;
...@@ -120,7 +124,7 @@ const tableInfo = ref({ ...@@ -120,7 +124,7 @@ const tableInfo = ref({
120 return classDataRef.value.find((item: any) => item.value === dataClassify)?.label; 124 return classDataRef.value.find((item: any) => item.value === dataClassify)?.label;
121 } 125 }
122 }, 126 },
123 { label: "分级描述", field: "gradeDesc", align: "left", }, 127 { label: "分级描述", field: "gradeDesc", align: "left", width: 480 },
124 128
125 ], 129 ],
126 actionInfo: { 130 actionInfo: {
......
...@@ -408,8 +408,9 @@ const dataBaseTableInfo = ref({ ...@@ -408,8 +408,9 @@ const dataBaseTableInfo = ref({
408 cgDirName: scope.row.cgDirName, 408 cgDirName: scope.row.cgDirName,
409 tableName: scope.row.tableName, 409 tableName: scope.row.tableName,
410 tableChName: scope.row.tableChName, 410 tableChName: scope.row.tableChName,
411 guid: scope.row.guid, 411 tableGuid: scope.row.tableGuid,
412 description: scope.row.description, 412 description: scope.row.description,
413 execGuid: execGuidInfo.value.execGuid
413 } 414 }
414 }); 415 });
415 } 416 }
......
...@@ -11,7 +11,7 @@ const { proxy } = getCurrentInstance() as any; ...@@ -11,7 +11,7 @@ const { proxy } = getCurrentInstance() as any;
11 const bizRuleConfigData = ref<any>() 11 const bizRuleConfigData = ref<any>()
12 const getBizRuleConfigDetailData = async () => { 12 const getBizRuleConfigDetailData = async () => {
13 const params = { 13 const params = {
14 tableGuid: router.currentRoute.value.query.guid, 14 tableGuid: router.currentRoute.value.query.tableGuid,
15 execGuid: router.currentRoute.value.query.execGuid 15 execGuid: router.currentRoute.value.query.execGuid
16 } 16 }
17 const res: any = await getBizRuleConfigDetail(params) 17 const res: any = await getBizRuleConfigDetail(params)
...@@ -268,7 +268,7 @@ const cancel = () => { ...@@ -268,7 +268,7 @@ const cancel = () => {
268 }"> 268 }">
269 <el-table-column type="selection" :width="32" align="center" /> 269 <el-table-column type="selection" :width="32" align="center" />
270 <!-- 排序列(不可编辑) --> 270 <!-- 排序列(不可编辑) -->
271 <el-table-column prop="index" label="排序" width="80" align="center" /> 271 <el-table-column type="index" label="排序" width="80" align="center" />
272 <!-- 字段中文名(不可编辑)fieldChName --> 272 <!-- 字段中文名(不可编辑)fieldChName -->
273 <el-table-column prop="fieldName" label="字段中文名" width="120"> 273 <el-table-column prop="fieldName" label="字段中文名" width="120">
274 <template #default="scope"> 274 <template #default="scope">
......
...@@ -222,7 +222,7 @@ watch(() => databaseInfo.value, (val) => { ...@@ -222,7 +222,7 @@ watch(() => databaseInfo.value, (val) => {
222 getDsTableList({ 222 getDsTableList({
223 pageSize: dsPageInfo.value.limit, 223 pageSize: dsPageInfo.value.limit,
224 pageIndex: dsPageInfo.value.curr, 224 pageIndex: dsPageInfo.value.curr,
225 dataSourceGuid: val.guid, 225 databaseGuid: val.guid,
226 execGuid: props.execGuid 226 execGuid: props.execGuid
227 }); 227 });
228 }) 228 })
...@@ -232,7 +232,7 @@ const handleSearchInputChange = () => { ...@@ -232,7 +232,7 @@ const handleSearchInputChange = () => {
232 getDsTableList({ 232 getDsTableList({
233 pageSize: dsPageInfo.value.limit, 233 pageSize: dsPageInfo.value.limit,
234 pageIndex: dsPageInfo.value.curr, 234 pageIndex: dsPageInfo.value.curr,
235 dataSourceGuid: databaseInfo.value.guid, 235 databaseGuid: databaseInfo.value.guid,
236 execGuid: props.execGuid 236 execGuid: props.execGuid
237 }); 237 });
238 }; 238 };
...@@ -244,7 +244,7 @@ const dsPageChange = (page) => { ...@@ -244,7 +244,7 @@ const dsPageChange = (page) => {
244 getDsTableList({ 244 getDsTableList({
245 pageSize: dsPageInfo.value.limit, 245 pageSize: dsPageInfo.value.limit,
246 pageIndex: dsPageInfo.value.curr, 246 pageIndex: dsPageInfo.value.curr,
247 dataSourceGuid: databaseInfo.value.guid, 247 databaseGuid: databaseInfo.value.guid,
248 execGuid: props.execGuid 248 execGuid: props.execGuid
249 }); 249 });
250 }; 250 };
......
...@@ -45,10 +45,12 @@ const classListDataLoading = ref(false); ...@@ -45,10 +45,12 @@ const classListDataLoading = ref(false);
45 45
46 // 获取分级列表 46 // 获取分级列表
47 const getClassifyGradListData = async () => { 47 const getClassifyGradListData = async () => {
48 classListDataLoading.value = true;
48 const res: any = await getClassifyGradList(refGradePageParams.value); 49 const res: any = await getClassifyGradList(refGradePageParams.value);
49 if (res.code == proxy.$passCode) { 50 if (res.code == proxy.$passCode) {
50 classifyGradListData.value = res.data.records || []; 51 classifyGradListData.value = res.data.records || [];
51 (classStandardFormItems.value[1].options as any) = classifyGradListData.value; 52 (classStandardFormItems.value[1].options as any) = classifyGradListData.value;
53 classListDataLoading.value = false;
52 } else { 54 } else {
53 proxy.$ElMessage.error(res.msg); 55 proxy.$ElMessage.error(res.msg);
54 } 56 }
...@@ -56,9 +58,11 @@ const getClassifyGradListData = async () => { ...@@ -56,9 +58,11 @@ const getClassifyGradListData = async () => {
56 58
57 //获取分类列表 59 //获取分类列表
58 const getClassListData = async () => { 60 const getClassListData = async () => {
61 classListDataLoading.value = true;
59 const res: any = await getClassifyGradList(refClassifyPageParams.value); 62 const res: any = await getClassifyGradList(refClassifyPageParams.value);
60 if (res.code == proxy.$passCode) { 63 if (res.code == proxy.$passCode) {
61 classListData.value = res.data.records || []; 64 classListData.value = res.data.records || [];
65 classListDataLoading.value = false;
62 } else { 66 } else {
63 proxy.$ElMessage.error(res.msg); 67 proxy.$ElMessage.error(res.msg);
64 } 68 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!