超级管理员 2 years ago
parent
commit
8fd6d4cfa3
  1. 10
      src/api/hr/org/index.ts
  2. 24
      src/components/DesignForm/public/expand/user.vue
  3. 28
      src/components/DesignForm/public/expand/userDialog.vue
  4. 82
      src/components/DesignForm/public/form/formItem.vue
  5. 187
      src/components/DesignForm/public/map/componentTest.vue

10
src/api/hr/org/index.ts

@ -122,3 +122,13 @@ export function getTeamListCont(data: searchTeamList): AxiosPromise<orgTeamListC
data: data
});
}
/**
*
*/
export function searchUserCustomerFormList(data:any): AxiosPromise<archivesList[]>{
return request({
url: '/hrapi/org/search_userlist_customerform',
method: 'post',
data: data
});
}

24
src/components/DesignForm/public/expand/user.vue

@ -25,29 +25,39 @@ const userDialogEl = ref()
// emits('update:modelValue', newVal)
// }
// })
const userlist = ref("")
// const userlist = ref<any>("")
const value = computed({
get: () => props.modelValue,
get: () => {
console.log("value-get",props.modelValue)
// userlist.value = props.modelValue
return props.modelValue
},
set: (newVal: any) => {
// console.log("value-set",newVal)
emits('update:modelValue', newVal)
console.log("value-set",newVal)
// emits('update:modelValue', newVal)
let newValJson:criteriaForPeopleList[] = JSON.parse(newVal)
// console.log("value-newValJson",newValJson)
console.log("value-newValJson",newValJson)
if(newValJson.length > 0){
let userAry = new Array
let userKeyAry = new Array
newValJson.forEach(item =>{
userAry.push(item.name+"("+item.number+")")
userKeyAry.push(item.userkey.toString())
})
userlist.value = userAry.join(',')
emits('update:modelValue', userAry.join(','))
// userlist.value = userAry.join(',')
//
}
},
});
const openDialog = () => {
// console.log("value-----",value.value)
userDialogEl.value.open()
}
onMounted(() => {
console.log("value---1--》",value.value,props.modelValue)
nextTick(() => {})
})
@ -56,7 +66,7 @@ onMounted(() => {
<el-input
placeholder="请选择用户或输入用户名称"
v-bind="$props"
v-model="userlist"
v-model="value"
@click="openDialog"
>
<template #append>

28
src/components/DesignForm/public/expand/userDialog.vue

@ -7,7 +7,7 @@
import { ref, onMounted, reactive, nextTick } from 'vue'
import { getRequest } from '@/api/DesignForm'
import formatResult from '@/utils/DesignForm/formatResult'
import { getOrgFormTree,getOrgFormUserList } from '@/api/hr/org/index'
import { getOrgFormTree,getOrgFormUserList,searchUserCustomerFormList } from '@/api/hr/org/index'
import { orgform,criteriaForPeopleList } from '@/api/hr/org/type'
import UserRole from '@/assets/icons/user.svg'
@ -125,16 +125,26 @@ const delAllClick = () => {
//
const open = () => {
visible.value = true
// console.log("open--->",props.modelValue)
console.log("open--->",props.modelValue)
if (props.modelValue) {
// checkData.value = props.modelValue.split(',')
let jsonCont:criteriaForPeopleList[] = JSON.parse(props.modelValue)
if(jsonCont.length > 0) {
checkDataList.splice(0,checkDataList.length)
jsonCont.forEach(item=>{
checkDataList.push(item)
searchUserCustomerFormList({name:props.modelValue})
.then(({data})=>{
console.log("弹窗处理",data)
// checkDataList = data
if(data.length > 0){
data.forEach((item:any) => {
checkDataList.push(item)
})
}
})
}
// checkData.value = props.modelValue.split(',')
// let jsonCont:criteriaForPeopleList[] = JSON.parse(props.modelValue)
// if(jsonCont.length > 0) {
// checkDataList.splice(0,checkDataList.length)
// jsonCont.forEach(item=>{
// checkDataList.push(item)
// })
// }
} else {
checkDataList.splice(0,checkDataList.length)
}

82
src/components/DesignForm/public/form/formItem.vue

@ -211,47 +211,47 @@ const getAxiosOptions = debounce((data?: any) => {
if (method === 'get') {
newData = { params: newData }
}
getRequest(sourceFun, newData, { method: method })
.then((res: any) => {
const result = res.data.list || res.data
let formatRes: any = result
//
if (typeof afterResponse === 'string' && afterResponse) {
formatRes = formatResult(result, afterResponse)
} else if (typeof afterResponse === 'function') {
// return使
formatRes = afterResponse(result) ?? result
} else if (label || value) {
// afterResponse[{label:'',value:''}]
formatRes = []
result.forEach((item: any) => {
formatRes.push({
label: item[label] || item.label,
value: item[value] || item.value
})
})
}
if (formatRes === false) {
return
}
// console.log('formatRes', formatRes)
if (props.data.type === 'treeSelect') {
control.value.data = formatRes
} else {
options.value = formatRes
}
if (typeof formatRes === 'object') {
window.sessionStorage.setItem(key, JSON.stringify(formatRes)) //
}
})
.catch((res: any) => {
if (props.data.type === 'treeSelect') {
control.value.data = []
} else {
options.value = []
}
console.log(res)
})
// getRequest(sourceFun, newData, { method: method })
// .then((res: any) => {
// const result = res.data.list || res.data
// let formatRes: any = result
// //
// if (typeof afterResponse === 'string' && afterResponse) {
// formatRes = formatResult(result, afterResponse)
// } else if (typeof afterResponse === 'function') {
// // return使
// formatRes = afterResponse(result) ?? result
// } else if (label || value) {
// // afterResponse[{label:'',value:''}]
// formatRes = []
// result.forEach((item: any) => {
// formatRes.push({
// label: item[label] || item.label,
// value: item[value] || item.value
// })
// })
// }
// if (formatRes === false) {
// return
// }
// // console.log('formatRes', formatRes)
// if (props.data.type === 'treeSelect') {
// control.value.data = formatRes
// } else {
// options.value = formatRes
// }
// if (typeof formatRes === 'object') {
// window.sessionStorage.setItem(key, JSON.stringify(formatRes)) //
// }
// })
// .catch((res: any) => {
// if (props.data.type === 'treeSelect') {
// control.value.data = []
// } else {
// options.value = []
// }
// console.log(res)
// })
}
}
setFormDict(formProps.value.dict) //

187
src/components/DesignForm/public/map/componentTest.vue

@ -1,187 +0,0 @@
<template>
<el-row style="flex-wrap: nowrap">
<el-input v-model="value" :placeholder="placeholder" />
<el-button @click="visibleClick">选择</el-button>
</el-row>
<el-dialog v-model="state.visible" title="详细地址" width="800px">
<div class="map-container">
<el-input id="tipInput" v-model="state.tipInput" />
<div id="container" style="width: 100%; height: 400px"></div>
<div id="panel"></div>
</div>
<template #footer>
<el-button @click="selectClick" type="primary">确定</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { reactive, watch, ref, onMounted, nextTick } from 'vue'
import { loadScript } from '@/utils/DesignForm'
const props = withDefaults(
defineProps<{
modelValue?: string
disabled?: boolean
placeholder?: string
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', value: string): void
}>()
const value = ref(props.modelValue)
watch(
() => props.modelValue,
() => {
value.value = props.modelValue
}
)
const state = reactive({
visible: false,
tipInput: ''
})
const selectClick = () => {
state.visible = false
value.value = state.tipInput
emits('update:modelValue', value.value)
}
const visibleClick = () => {
state.visible = true
//
nextTick(() => {
const map = initMap()
mapSearch(map)
})
}
const center = ref([113.264499, 23.130061])
//
const initMap = () => {
const map = new AMap.Map('container', {
resizeEnable: true,
center: center.value,
zoom: 11,
viewMode: '3D' // 使3D
})
//
const marker = new AMap.Marker({
position: map.getCenter(),
//icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
//
draggable: true,
cursor: 'move'
// content: 'markerContent',
})
const { lat, lng } = map.getCenter()
getDetailAddress(lng, lat, marker)
map.add(marker) //
map.on('click', (e: any) => {
const lnglat = e.lnglat
const lat = lnglat.lat
const lng = lnglat.lng
map.setCenter([lng, lat]) //
marker.setPosition([lng, lat]) //
getDetailAddress(lng, lat, marker)
})
return map
}
const mapSearch = (map: any) => {
AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], function () {
const auto = new AMap.AutoComplete({
input: 'tipInput'
})
const placeSearch = new AMap.PlaceSearch({
pageSize: 5, //
pageIndex: 1, //
city: '', //
citylimit: false, //
map: map, //
panel: 'panel', //
autoFitView: true // 使 Marker
})
auto.on('select', (evt: any) => {
placeSearch.setCity(evt.poi.adcode)
placeSearch.search(evt.poi.name) //
/*placeSearch.search(evt.poi.name, function (status, result) {
//
// resultPOI
console.log("搜索结果", result);
});*/
state.tipInput = evt.poi.name //
}) //
/*
// icon
placeSearch.on('markerClick',()=>{
console.log('placeSearch.onmarkerClick')
})*/
//
placeSearch.on('listElementClick', (evt: any) => {
state.tipInput = evt.data.name
})
})
}
const getDetailAddress = (lng: number, lat: number, marker: any) => {
//
AMap.plugin('AMap.Geocoder', () => {
const geocoder = new AMap.Geocoder()
geocoder.getAddress([lng, lat], (status: string, result: any) => {
if (status === 'complete' && result.info === 'OK') {
const detailAddress = result.regeocode.formattedAddress
state.tipInput = detailAddress
marker.setLabel({
direction: 'center',
offset: new AMap.Pixel(0, -25), //
content: `<div class='info'>${detailAddress}</div>` //
})
}
})
})
}
onMounted(() => {
console.log('onMountedonMounted')
loadScript(
'https://webapi.amap.com/maps?v=2.0&key=ljiKlTAsS7SNVqDM16IUwRVFFhrvbxiF&plugin=AMap.PlaceSearch'
).then(() => {})
})
</script>
<style lang="scss">
.map-container {
position: relative;
}
.amap-sug-result {
z-index: 2500;
}
#panel {
z-index: 2500;
position: absolute;
background-color: white;
max-height: 90%;
overflow-y: auto;
top: 10px;
right: 10px;
width: 280px;
.amap_lib_placeSearch {
border: 1px solid #ebedf0;
border-radius: 2px;
padding: 5px 10px 2px;
.poibox {
border-bottom: 1px solid #e8e8e8;
cursor: pointer;
padding: 10px 5px;
position: relative;
min-height: 35px;
}
.amap_lib_placeSearch_pic {
width: 46px;
height: 46px;
float: left;
margin: 4px 10px 0 0;
img {
width: 46px;
height: 46px;
}
}
}
}
</style>
Loading…
Cancel
Save