From f1780a2b26502aa3397a85c7b7a6f58af9619757 Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Mon, 31 Mar 2025 09:52:42 +0800
Subject: [PATCH] 部门行政区划名修改areaCode

---
 src/views/system/dept.vue |   84 +++++++++++++++++++++---------------------
 1 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/src/views/system/dept.vue b/src/views/system/dept.vue
index 6d95bfb..7fc8860 100644
--- a/src/views/system/dept.vue
+++ b/src/views/system/dept.vue
@@ -46,9 +46,9 @@
 		<template #deptCategory="{ row }">
 		  <el-tag>{{ row.deptCategoryName }}</el-tag>
 		</template>
-		<!-- 自定义 regionCode 的显示模板,确保显示单一值 -->
-		<template #regionCode="{ row }">
-		  {{ row.regionCode }}
+		<!-- 自定义 areaCode 的显示模板,确保显示单一值 -->
+		<template #areaCode="{ row }">
+		  {{ row.areaCode }}
 		</template>
 	  </avue-crud>
 	</basic-container>
@@ -217,7 +217,7 @@
 			},
 			{
 			  label: '行政区划',
-			  prop: 'regionCode',
+			  prop: 'areaCode',
 			  type: 'cascader',
 			  labelWidth: 120,
 			  props: {
@@ -238,18 +238,18 @@
 			  ],
 			  change: ({ value }) => {
 				if (!value) {
-				  this.form.regionCode = null; // 未选择时置为空
+				  this.form.areaCode = null; // 未选择时置为空
 				} else {
 				  // 如果 value 是逗号分隔的字符串,拆分并取最后一个值
 				  if (typeof value === 'string' && value.includes(',')) {
 					const codes = value.split(',');
-					this.form.regionCode = codes[codes.length - 1];
+					this.form.areaCode = codes[codes.length - 1];
 				  } else {
-					this.form.regionCode = value; // 直接使用单一值
+					this.form.areaCode = value; // 直接使用单一值
 				  }
 				}
 				console.log('cascader change value:', value);
-				console.log('处理后的区县编码:', this.form.regionCode);
+				console.log('处理后的区县编码:', this.form.areaCode);
 			  },
 			  lazy: true,
 			  lazyLoad(node, resolve) {
@@ -333,11 +333,11 @@
 		const column = this.findObject(this.option.column, 'parentId');
 		column.value = row.id;
 		column.addDisabled = true;
-		this.form.regionCode = null; // 初始化为空
+		this.form.areaCode = null; // 初始化为空
 		this.$refs.crud.rowAdd();
 	  },
 	  validateSubmitData(row) {
-		if (!row.regionCode) {
+		if (!row.areaCode) {
 		  this.$message.warning('请选择行政区划');
 		  return false;
 		}
@@ -351,15 +351,15 @@
 		console.log('--- Start rowSave ---');
 		console.log('Form data before save:', this.form);
 		
-		// 处理 regionCode,确保只取最后一个值
-		let regionCode = this.form.regionCode;
-		if (Array.isArray(regionCode)) {
-		  regionCode = regionCode[regionCode.length - 1]; // 数组取最后一个
-		} else if (typeof regionCode === 'string' && regionCode.includes(',')) {
-		  const codes = regionCode.split(',');
-		  regionCode = codes[codes.length - 1]; // 字符串拆分取最后一个
+		// 处理 areaCode,确保只取最后一个值
+		let areaCode = this.form.areaCode;
+		if (Array.isArray(areaCode)) {
+		  areaCode = areaCode[areaCode.length - 1]; // 数组取最后一个
+		} else if (typeof areaCode === 'string' && areaCode.includes(',')) {
+		  const codes = areaCode.split(',');
+		  areaCode = codes[codes.length - 1]; // 字符串拆分取最后一个
 		}
-		row.regionCode = regionCode || null; // 确保非空
+		row.areaCode = areaCode || null; // 确保非空
 		
 		console.log('Row data before submit:', row);
 		
@@ -391,15 +391,15 @@
 		}
 		console.log('--- Start rowUpdate ---');
 		
-		// 处理 regionCode,确保只取最后一个值
-		let regionCode = this.form.regionCode;
-		if (Array.isArray(regionCode)) {
-		  regionCode = regionCode[regionCode.length - 1]; // 数组取最后一个
-		} else if (typeof regionCode === 'string' && regionCode.includes(',')) {
-		  const codes = regionCode.split(',');
-		  regionCode = codes[codes.length - 1]; // 字符串拆分取最后一个
+		// 处理 areaCode,确保只取最后一个值
+		let areaCode = this.form.areaCode;
+		if (Array.isArray(areaCode)) {
+		  areaCode = areaCode[areaCode.length - 1]; // 数组取最后一个
+		} else if (typeof areaCode === 'string' && areaCode.includes(',')) {
+		  const codes = areaCode.split(',');
+		  areaCode = codes[codes.length - 1]; // 字符串拆分取最后一个
 		}
-		row.regionCode = regionCode || null; // 确保非空
+		row.areaCode = areaCode || null; // 确保非空
 		
 		console.log('Row data before submit:', row);
 		
@@ -491,19 +491,19 @@
 		}
 		if (['edit', 'view'].includes(type)) {
 		  getDept(this.form.id).then((res) => {
-			const regionCode = res.data.data.regionCode;
-			let finalRegionCode = regionCode;
-			if (typeof regionCode === 'string' && regionCode.includes(',')) {
-			  const codes = regionCode.split(',');
-			  finalRegionCode = codes[codes.length - 1]; // 取最后一个值
+			const areaCode = res.data.data.areaCode;
+			let finalareaCode = areaCode;
+			if (typeof areaCode === 'string' && areaCode.includes(',')) {
+			  const codes = areaCode.split(',');
+			  finalareaCode = codes[codes.length - 1]; // 取最后一个值
 			}
 			this.form = Object.assign({}, res.data.data, {
 			  hasChildren: this.form.hasChildren,
-			  regionCode: finalRegionCode ? String(finalRegionCode) : null // 确保是字符串
+			  areaCode: finalareaCode ? String(finalareaCode) : null // 确保是字符串
 			});
 		  });
 		} else if (type === 'add') {
-		  this.form.regionCode = null;
+		  this.form.areaCode = null;
 		}
 		done();
 	  },
@@ -512,7 +512,7 @@
 		const column = this.findObject(this.option.column, 'parentId');
 		column.value = '';
 		column.addDisabled = false;
-		this.form.regionCode = null;
+		this.form.areaCode = null;
 		done();
 	  },
 	  currentChange(currentPage) {
@@ -532,21 +532,21 @@
 		console.log('Current parentId:', this.parentId, 'query:', this.query);
 		getLazyList(this.parentId, Object.assign(params, this.query)).then((res) => {
 		  console.log('onLoad response:', res.data);
-		  // 处理 regionCode,确保是单一字符串
+		  // 处理 areaCode,确保是单一字符串
 		  const data = (res.data.data || []).map(item => {
-			let regionCode = item.regionCode;
+			let areaCode = item.areaCode;
 			// 如果是数组,取最后一个值
-			if (Array.isArray(regionCode)) {
-			  regionCode = regionCode[regionCode.length - 1];
+			if (Array.isArray(areaCode)) {
+			  areaCode = areaCode[areaCode.length - 1];
 			}
 			// 如果是逗号分隔的字符串,取最后一个值
-			else if (typeof regionCode === 'string' && regionCode.includes(',')) {
-			  const codes = regionCode.split(',');
-			  regionCode = codes[codes.length - 1];
+			else if (typeof areaCode === 'string' && areaCode.includes(',')) {
+			  const codes = areaCode.split(',');
+			  areaCode = codes[codes.length - 1];
 			}
 			return {
 			  ...item,
-			  regionCode: regionCode ? String(regionCode) : '' // 确保是字符串
+			  areaCode: areaCode ? String(areaCode) : '' // 确保是字符串
 			};
 		  });
 		  this.data = data;

--
Gitblit v1.9.3