上传
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px" @close="destroyMap">
|
||||
<el-tabs v-model="tabName">
|
||||
<el-tab-pane label="线索信息" name="info">
|
||||
<Form ref="formRef" v-loading="formLoading" :rules="rules" isCol :schema="formSchema" />
|
||||
@@ -16,7 +16,7 @@
|
||||
:disabled="!row.editable"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in userOptions"
|
||||
v-for="item in props.userOptions"
|
||||
:key="item.id"
|
||||
:label="item.nickname"
|
||||
:value="item.id"
|
||||
@@ -92,9 +92,9 @@
|
||||
|
||||
<script setup name="DialogClue">
|
||||
import { useAppStore } from '@/store/modules/app'
|
||||
import { getSimpleUserList as getUserOption } from '@/api/system/user'
|
||||
import { getPlaceList } from '@/api/school/place'
|
||||
import * as ClueApi from '@/api/clue'
|
||||
import { getDiyFieldList } from '@/api/clue/clueField'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import AMapLoader from '@amap/amap-jsapi-loader'
|
||||
import ImgPostion from '@/assets/imgs/flag/flag_red.png'
|
||||
@@ -112,6 +112,9 @@ const appStore = useAppStore()
|
||||
const props = defineProps({
|
||||
schema: {
|
||||
type: Array
|
||||
},
|
||||
userOptions: {
|
||||
type: Array
|
||||
}
|
||||
})
|
||||
|
||||
@@ -156,7 +159,6 @@ const rules = {
|
||||
const tabName = ref('info')
|
||||
|
||||
const followList = ref([])
|
||||
const userOptions = ref([])
|
||||
|
||||
const areaValue = ref('')
|
||||
const areaList = ref([])
|
||||
@@ -167,10 +169,14 @@ const defaultLatLng = ref({
|
||||
})
|
||||
const info = ref({})
|
||||
|
||||
const diyFieldArr = ref([])
|
||||
|
||||
const open = async (type, id) => {
|
||||
dialogVisible.value = true
|
||||
tabName.value = 'info'
|
||||
dialogTitle.value = type == 'create' ? '新增线索' : '修改线索'
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
@@ -185,6 +191,13 @@ const open = async (type, id) => {
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
} else {
|
||||
followList.value = []
|
||||
address.value = []
|
||||
defaultLatLng.value = {
|
||||
lat: 31.86119,
|
||||
lng: 117.283042
|
||||
}
|
||||
}
|
||||
if (appStore.getAppInfo?.instanceType == 1 && !dialogMap.value) {
|
||||
nextTick(() => {
|
||||
@@ -194,8 +207,17 @@ const open = async (type, id) => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
function resetForm() {
|
||||
info.value.address = undefined
|
||||
info.value.lat = undefined
|
||||
info.value.lng = undefined
|
||||
info.value.followUsers = []
|
||||
info.value.diyParams = {}
|
||||
}
|
||||
|
||||
const placeList = ref([])
|
||||
function getSchoolPlace() {
|
||||
getPlaceList().then((data) => {
|
||||
@@ -203,6 +225,8 @@ function getSchoolPlace() {
|
||||
})
|
||||
}
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
async function handleSave() {
|
||||
// 校验表单
|
||||
if (!formRef.value) return
|
||||
@@ -220,10 +244,12 @@ async function handleSave() {
|
||||
params.lng = defaultLatLng.value.lng
|
||||
params.followUsers = [...followList.value]
|
||||
params.diyParams = {}
|
||||
debugger
|
||||
for (const key in info.value.diyParams) {
|
||||
if (Object.hasOwnProperty.call(info.value.diyParams, key)) {
|
||||
params.diyParams[key] = params.key
|
||||
diyFieldArr.value.map((it) => {
|
||||
params.diyParams[it.field] = undefined
|
||||
})
|
||||
for (const key in params.diyParams) {
|
||||
if (Object.hasOwnProperty.call(params, key)) {
|
||||
params.diyParams[key] = params[key]
|
||||
}
|
||||
}
|
||||
if (formType.value === 'create') {
|
||||
@@ -270,13 +296,15 @@ function initMap(data) {
|
||||
lng: data.lng,
|
||||
lat: data.lat
|
||||
}
|
||||
addmark(data.lng, data.lat, AMap)
|
||||
}
|
||||
dialogMap.value = new AMap.Map('dialogMap', {
|
||||
zoom: 12,
|
||||
zooms: [2, 22],
|
||||
center: [defaultLatLng.value.lng, defaultLatLng.value.lat]
|
||||
})
|
||||
if (data.lng || data.lat) {
|
||||
addmark(data.lng, data.lat, AMap)
|
||||
}
|
||||
AutoComplete.value = new AMap.AutoComplete({
|
||||
city: '全国'
|
||||
})
|
||||
@@ -375,10 +403,19 @@ function currentSelect(val) {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getUserOption().then((data) => {
|
||||
userOptions.value = data
|
||||
function destroyMap() {
|
||||
dialogMap.value = null
|
||||
aMap.value = null
|
||||
}
|
||||
|
||||
function getDiyList() {
|
||||
getDiyFieldList().then((data) => {
|
||||
diyFieldArr.value = data
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getDiyList()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user