@@ -689,7 +652,7 @@ const handleMapClick = (e: any) => {
`,
offset: new AMap.Pixel(0, -35)
})
-
+
infoWindow.open(map, [lng, lat])
}
})
@@ -700,7 +663,7 @@ const handleMapClick = (e: any) => {
const initMap = async () => {
logDebug('开始初始化地图')
clearError()
-
+
if (!mapContainer.value) {
const errorMsg = '地图容器元素未找到'
setError('初始化失败', errorMsg)
@@ -710,7 +673,7 @@ const initMap = async () => {
try {
loadingText.value = '正在初始化地图...'
-
+
// 安全密钥配置
window._AMapSecurityConfig = {
securityJsCode: 'df197447a4adc77f0cb376a44462272c'
@@ -735,7 +698,7 @@ const initMap = async () => {
logDebug('地图加载完成')
mapLoaded.value = true
loadingText.value = '地图加载中...'
-
+
initPlugins().catch(error => {
console.error('插件初始化失败:', error)
setError('功能初始化失败', error.message)
@@ -763,7 +726,7 @@ const initMap = async () => {
// 处理搜索
const handleSearch = (keyword: string) => {
clearError()
-
+
if (!keyword?.trim()) {
message.warning('请输入搜索关键词')
debouncedSearch.cancel()
@@ -776,7 +739,7 @@ const handleSearch = (keyword: string) => {
if (!placeSearch) {
message.warning('搜索服务初始化中,请稍后重试')
logDebug('搜索服务尚未初始化,等待初始化后重试')
-
+
initPlugins().then(() => {
handleSearch(keyword)
}).catch(() => {
@@ -810,13 +773,13 @@ const handleOk = () => {
message.warning('请先在地图上选择一个位置')
return
}
-
+
emit('select', {
lnglat: formState.lnglat,
address: formState.address,
location: formState.location
})
-
+
handleCancel()
}
diff --git a/src/components/index.js b/src/components/index.js
index a55c817..9197d16 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -21,6 +21,7 @@ import Scrollbar from './Scrollbar/Scrollbar.vue'
import Cascader from './Cascader/Cascader.vue'
import { setupLoadingDirective } from './Loading/directive'
import GxUpload from './GxUpload/index.vue'
+import GxMap from './GxMap/index.vue'
const componentList = [
ActionBar,
@@ -43,6 +44,7 @@ const componentList = [
Scrollbar,
Cascader,
GxUpload,
+ GxMap
]
export const loading = Loading
diff --git a/src/utils/util.js b/src/utils/util.js
index 9141acb..cac0c2e 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -333,4 +333,41 @@ export const spliceUrl=(fullUrl)=>{
if(!fullUrl) return null
const pathOnly = fullUrl.replace(/^https?:\/\/[^\/]+/, '');
return pathOnly
+}
+/**根据身份证识别出生日期 */
+export const getBirthDate=(value)=>{
+
+ let year, month, day;
+
+ // 15位身份证:YYMMDD
+ if (value.length === 15) {
+ year = '19' + value.substring(6, 8); // 默认1900年代
+ month = value.substring(8, 10);
+ day = value.substring(10, 12);
+ }
+ // 18位身份证:YYYYMMDD
+ else if (value.length === 18) {
+ year = value.substring(6, 10);
+ month = value.substring(10, 12);
+ day = value.substring(12, 14);
+ }
+ else {
+
+ return '';
+ }
+
+ // 验证是否为合法日期
+ const date = new Date(year, month - 1, day); // 注意:月份从0开始
+ if (
+ date.getFullYear() !== parseInt(year, 10) ||
+ date.getMonth() + 1 !== parseInt(month, 10) ||
+ date.getDate() !== parseInt(day, 10)
+ ) {
+
+ return '';
+ }
+
+ // 格式化为 YYYY-MM-DD
+ const formattedDate = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
+ return formattedDate;
}
\ No newline at end of file
diff --git a/src/views/serverObj/serverList/components/EditDialog.vue b/src/views/serverObj/serverList/components/EditDialog.vue
index 974d325..4ea2785 100644
--- a/src/views/serverObj/serverList/components/EditDialog.vue
+++ b/src/views/serverObj/serverList/components/EditDialog.vue
@@ -34,7 +34,8 @@
{{ item.introduction }}
-
+
@@ -181,7 +182,7 @@
-
+
@@ -191,6 +192,7 @@
+
@@ -458,6 +460,9 @@ import { useForm, useModal } from '@/hooks'
import { useDicsStore } from '@/store'
import AreaCascader from '@/components/AreaCascader/index.vue'
import { validatePhone, validateEmail, validateIdCard } from '@/utils/validate'
+import { getBirthDate } from '@/utils/util'
+import dayjs from 'dayjs'
+import { message } from 'ant-design-vue'
const emit = defineEmits(['ok'])
const activeKey = ref('1')
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@@ -474,12 +479,13 @@ formRules.value = {
serviceStatus: [{ required: true, message: '请选择服务状态', trigger: 'change' }],
homeDetailAddress: [{ required: true, message: '请输入详细地址', trigger: 'change' }],
}
-formData.value.gender = '1'
+
const dicsStore = useDicsStore()
/**
* 新建
*/
function handleCreate() {
+ formData.value.gender = '1'
showModal({
type: 'create',
title: '新建项',
@@ -489,13 +495,17 @@ function handleCreate() {
/**
* 编辑
*/
-function handleEdit(record = {}) {
+async function handleEdit(record = {}) {
showModal({
type: 'edit',
- title: '编辑项',
+ title: '编辑对象'
})
- formRecord.value = record
- formData.value = cloneDeep(record)
+ const { data, success } = await apis.serverObj.getItem(record.id).catch()
+ if (!success) {
+ hideModal()
+ return
+ }
+ formData.value = { ...data }
}
// utils/idCard.js
function isValidIdCard(value) {
@@ -561,9 +571,9 @@ function handleOk() {
...formData.value,
}
// 单独封装一个同步校验函数
- console.log('params.identityType', isValidIdCard(params.idNumber));
if (params.identityType === '1' && !isValidIdCard(params.idNumber)) {
- throw new Error('请输入正确的身份证号码');
+ throw new Error('请输入正确的身份证号码');
+
}
let result = null
switch (modal.value.type) {
@@ -571,6 +581,7 @@ function handleOk() {
result = await apis.serverObj.createItem(params).catch(() => {
throw new Error()
})
+ console.log('result', result.code)
break
case 'edit':
result = await apis.serverObj.updateItem(params).catch(() => {
@@ -585,12 +596,24 @@ function handleOk() {
}
} catch (error) {
hideLoading()
+ message.error(error.message)
}
})
.catch(() => {
hideLoading()
})
}
+// 提取出生日期方法
+const extractBirthDateFromIdCard = () => {
+ console.log(111)
+ const { idNumber } = formData.value;
+ if (!idNumber) {
+ formData.value.birthDate = '';
+ return;
+ }
+ console.log(getBirthDate(idNumber))
+ formData.value.birthDate = dayjs(getBirthDate(idNumber));
+};
function onAreaChange(value, labels) {
console.log(formData.value.homeAreaCodes);
formData.value.homeAreaLabels = [...labels]
@@ -599,6 +622,10 @@ function onAreaHoldChange(value, labels) {
console.log(formData.value.houseAreaCodes);
formData.value.houseAreaLabels = [...labels]
}
+function handleGetLng(obj) {
+ formData.value.lat = obj.lat
+ formData.value.lng = obj.lng
+}
/**
* 取消
*/
diff --git a/src/views/serverObj/serverList/components/detail.vue b/src/views/serverObj/serverList/components/detail.vue
index ec78594..f347486 100644
--- a/src/views/serverObj/serverList/components/detail.vue
+++ b/src/views/serverObj/serverList/components/detail.vue
@@ -2,29 +2,34 @@
-
-
-
-
{{ formData.name }}{{ formData.gender }}{{ formData.age }}
-
身份证号:{{ formData.idNumber }}
-
手机号:{{ formData.contact1 }}
-
联系人:{{ formData.contactman }}
-
联系方式:{{ formData.contact1 }}
-
#2db7f5
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
{{ formData.name }}{{ formData.gender }}{{ formData.age }}
+
身份证号:{{ formData.idNumber }}
+
手机号:{{ formData.contact1 }}
+
+
#2db7f5
+
+
+
+
-
@@ -32,7 +37,7 @@