|
|
@@ -1,144 +1,72 @@
|
|
|
<script setup lang="tsx">
|
|
|
import { Form, FormSchema } from '@/components/Form'
|
|
|
import { useForm } from '@/hooks/web/useForm'
|
|
|
-import { PropType, watch, ref, onMounted, unref } from 'vue'
|
|
|
+import { PropType, watch, ref } from 'vue'
|
|
|
import { useValidator } from '@/hooks/web/useValidator'
|
|
|
import { cloneDeep } from 'lodash-es'
|
|
|
-import { ElInputTag, ElAutocomplete } from 'element-plus'
|
|
|
-import { getMapSearch } from '@/api/system/admin'
|
|
|
-import { UpImgButtom } from '@/components/UpFile'
|
|
|
-import { mapAddressData } from '@/api/system/admin/types'
|
|
|
-import { getConfigKey } from '@/api/system/admin'
|
|
|
-import { UserButtom } from '@/components/UserList'
|
|
|
-const { required, phone } = useValidator()
|
|
|
-const mapKey = ref('')
|
|
|
-onMounted(async () => {
|
|
|
- const res = await getConfigKey('tengxun_map_key')
|
|
|
- if (res) {
|
|
|
- mapKey.value = res.data.tengxun_map_key
|
|
|
- }
|
|
|
-})
|
|
|
+import { getCity } from '@/api/system/admin'
|
|
|
+import { WorkerButtom } from '@/components/WorkerList'
|
|
|
+const { required } = useValidator()
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
currentRow: {
|
|
|
type: Object as PropType<any>,
|
|
|
default: () => null
|
|
|
}
|
|
|
})
|
|
|
-const formSchema = ref<FormSchema[]>([
|
|
|
- {
|
|
|
- field: 'uid',
|
|
|
- label: '用户',
|
|
|
- component: 'CheckboxGroup',
|
|
|
- formItemProps: {
|
|
|
- slots: {
|
|
|
- default: (data) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <UserButtom
|
|
|
- v-model={data.uid}
|
|
|
- onChangeUser={(res) => {
|
|
|
- checkedUser(res)
|
|
|
- }}
|
|
|
- ></UserButtom>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
+const getCityList = async (node, resolve) => {
|
|
|
+ const { value } = node
|
|
|
+ const res = await getCity({ pid: value || 0, type: 2 })
|
|
|
+ const data = res.data.map((ree) => {
|
|
|
+ return {
|
|
|
+ label: ree.label,
|
|
|
+ value: ree.value,
|
|
|
+ leaf: !ree.children
|
|
|
}
|
|
|
- },
|
|
|
+ })
|
|
|
+ resolve(data)
|
|
|
+}
|
|
|
+const cityChange = (value) => {
|
|
|
+ console.log(value, 'value')
|
|
|
+ setValues({
|
|
|
+ province: value[0],
|
|
|
+ city: value[1],
|
|
|
+ area: value[2]
|
|
|
+ })
|
|
|
+}
|
|
|
+const checked = (res) => {
|
|
|
+ // console.log(res, 'res')
|
|
|
+ setValues({
|
|
|
+ group_leader_id: res.id
|
|
|
+ })
|
|
|
+}
|
|
|
+const formSchema = ref<FormSchema[]>([
|
|
|
{
|
|
|
field: 'name',
|
|
|
- label: '姓名',
|
|
|
+ label: '组名',
|
|
|
component: 'Input',
|
|
|
- componentProps: {
|
|
|
- placeholder: '请输入姓名'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'avatar',
|
|
|
- label: '头像',
|
|
|
- component: 'CheckboxGroup',
|
|
|
- componentProps: {
|
|
|
- placeholder: '选择头像'
|
|
|
+ colProps: {
|
|
|
+ span: 24
|
|
|
},
|
|
|
- formItemProps: {
|
|
|
- slots: {
|
|
|
- default: (data) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <UpImgButtom v-model={data.avatar}></UpImgButtom>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'phone',
|
|
|
- label: '手机号',
|
|
|
- component: 'Input',
|
|
|
componentProps: {
|
|
|
- type: 'number',
|
|
|
- placeholder: '请输入手机号'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'gender',
|
|
|
- label: '性别',
|
|
|
- component: 'Select',
|
|
|
- value: 0,
|
|
|
- componentProps: {
|
|
|
- placeholder: '请选择性别',
|
|
|
- options: [
|
|
|
- {
|
|
|
- label: '保密',
|
|
|
- value: 0
|
|
|
- },
|
|
|
- {
|
|
|
- label: '男',
|
|
|
- value: 1
|
|
|
- },
|
|
|
- {
|
|
|
- label: '女',
|
|
|
- value: 2
|
|
|
- }
|
|
|
- ]
|
|
|
+ placeholder: '请输入组名称'
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
- {
|
|
|
- field: 'birth_day_time',
|
|
|
- label: '出生日期',
|
|
|
- component: 'DatePicker'
|
|
|
- },
|
|
|
-
|
|
|
{
|
|
|
- field: 'start_job_year',
|
|
|
- label: '就业年份',
|
|
|
- component: 'Input',
|
|
|
- componentProps: {
|
|
|
- placeholder: '例子:2014'
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- field: 'tag_list',
|
|
|
- label: '标签',
|
|
|
- colProps: {
|
|
|
- span: 24
|
|
|
- },
|
|
|
+ field: 'group_leader_id',
|
|
|
+ label: '组长',
|
|
|
component: 'CheckboxGroup',
|
|
|
formItemProps: {
|
|
|
slots: {
|
|
|
default: (data) => {
|
|
|
return (
|
|
|
<>
|
|
|
- <ElInputTag
|
|
|
- v-model={data.tag_list}
|
|
|
- tagEffect="light"
|
|
|
- tagType="primary"
|
|
|
- clearable
|
|
|
- ></ElInputTag>
|
|
|
+ <WorkerButtom
|
|
|
+ v-model={data.id}
|
|
|
+ onChange={(res) => {
|
|
|
+ checked(res)
|
|
|
+ }}
|
|
|
+ ></WorkerButtom>
|
|
|
</>
|
|
|
)
|
|
|
}
|
|
|
@@ -146,44 +74,21 @@ const formSchema = ref<FormSchema[]>([
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
- field: 'detail_address',
|
|
|
- label: '省市区地址',
|
|
|
+ field: 'address',
|
|
|
+ label: '地址选择',
|
|
|
+ component: 'Cascader',
|
|
|
colProps: {
|
|
|
span: 24
|
|
|
},
|
|
|
- component: 'Input',
|
|
|
- formItemProps: {
|
|
|
- slots: {
|
|
|
- default: (data) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <ElAutocomplete
|
|
|
- v-model={data.detail_address}
|
|
|
- value-key="label"
|
|
|
- onSelect={(val: any) => {
|
|
|
- selectAddress(val)
|
|
|
- }}
|
|
|
- fetch-suggestions={(val, cb) => {
|
|
|
- searchAddress(val, cb)
|
|
|
- }}
|
|
|
- >
|
|
|
- {{
|
|
|
- default: ({ item }) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <div class="lh-none mt-10px">{item.label}</div>
|
|
|
- <div class="font-size-12px lh-none mt-5px pb-10px b-b-solid b-b-light b-b-1px">
|
|
|
- {item.address}
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
- }}
|
|
|
- </ElAutocomplete>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
+ componentProps: {
|
|
|
+ on: {
|
|
|
+ change: cityChange
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ lazy: true,
|
|
|
+ lazyLoad: getCityList
|
|
|
+ },
|
|
|
+ placeholder: '请输入组名称'
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
@@ -204,44 +109,17 @@ const formSchema = ref<FormSchema[]>([
|
|
|
hidden: true,
|
|
|
component: 'Input'
|
|
|
},
|
|
|
- {
|
|
|
- field: 'longitude',
|
|
|
- label: '经度',
|
|
|
- hidden: true,
|
|
|
- component: 'Input'
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'latitude',
|
|
|
- label: '纬度',
|
|
|
- hidden: true,
|
|
|
- component: 'Input'
|
|
|
- },
|
|
|
{
|
|
|
field: 'id',
|
|
|
+ label: 'id',
|
|
|
hidden: true,
|
|
|
component: 'Input'
|
|
|
}
|
|
|
])
|
|
|
|
|
|
const rules = ref({
|
|
|
- uid: [required('请选择用户')],
|
|
|
- avatar: [required('请上传头像')],
|
|
|
- phone: [required('请填写手机号'), phone()],
|
|
|
- birth_day_time: [required('请选择出生日期')],
|
|
|
- start_job_year: [required('请填写就业年份')],
|
|
|
- detail_address: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- validator: (_, val, callback) => {
|
|
|
- if (!actionAddress.value || !val) {
|
|
|
- callback(new Error('请选择地址'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ],
|
|
|
- name: [required('请填写等级名称')]
|
|
|
+ name: [required('请填写组名称')],
|
|
|
+ group_leader_id: [required('请选择设计师')]
|
|
|
})
|
|
|
|
|
|
const { formRegister, formMethods } = useForm()
|
|
|
@@ -258,82 +136,12 @@ const submit = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-defineExpose({
|
|
|
- submit
|
|
|
-})
|
|
|
-const checkedUser = async (res: any) => {
|
|
|
- setValues({
|
|
|
- uid: res.uid,
|
|
|
- name: res.real_name,
|
|
|
- avatar: [res.avatar],
|
|
|
- birth_day_time: res.birthday,
|
|
|
- phone: res.phone,
|
|
|
- gender: res.sex || 0
|
|
|
- })
|
|
|
-}
|
|
|
-const actionAddress = ref<mapAddressData>()
|
|
|
-const searchAddress = async (queryString: string, cb: (arg: any) => void) => {
|
|
|
- if (queryString) {
|
|
|
- const { data } = await getMapSearch({
|
|
|
- key: unref(mapKey),
|
|
|
- keyword: queryString
|
|
|
- })
|
|
|
- cb(
|
|
|
- data.map((item): mapAddressData => {
|
|
|
- return {
|
|
|
- adcode: item.adcode,
|
|
|
- label: item.title,
|
|
|
- address: item.address,
|
|
|
- lng: item.location.lng,
|
|
|
- lat: item.location.lat,
|
|
|
- province: item.province,
|
|
|
- city: item.city,
|
|
|
- district: item.district
|
|
|
- }
|
|
|
- })
|
|
|
- )
|
|
|
- }
|
|
|
-}
|
|
|
-const selectAddress = (item: mapAddressData) => {
|
|
|
- if (!item || !item.adcode || !item.lng || !item.lat) {
|
|
|
- console.error('Invalid input item:', item)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- const adcodeStr = String(item.adcode).padStart(6, '0') // 确保 adcode 至少有6位
|
|
|
- const province = adcodeStr.slice(0, 2)
|
|
|
- const city = adcodeStr.slice(2, 4)
|
|
|
- const area = adcodeStr
|
|
|
-
|
|
|
- setValues({
|
|
|
- province: `${province}`,
|
|
|
- city: `${province}${city}00000000`,
|
|
|
- area: `${area}000000`,
|
|
|
- longitude: item.lng,
|
|
|
- latitude: item.lat
|
|
|
- })
|
|
|
-
|
|
|
- actionAddress.value = item
|
|
|
- center.value = {
|
|
|
- lng: item.lng,
|
|
|
- lat: item.lat
|
|
|
- }
|
|
|
- geometries.value = [{ styleId: 'marker', position: { lat: item.lat, lng: item.lng } }]
|
|
|
-}
|
|
|
-const center = ref({ lat: 28.655759, lng: 121.420808 })
|
|
|
-const geometries = ref([{ styleId: 'marker', position: { lat: 28.655759, lng: 121.420808 } }])
|
|
|
-
|
|
|
watch(
|
|
|
() => props.currentRow,
|
|
|
async (value) => {
|
|
|
if (!value) return
|
|
|
const currentRow = cloneDeep(value)
|
|
|
- actionAddress.value = {
|
|
|
- adcode: currentRow.area,
|
|
|
- label: currentRow.detail_address,
|
|
|
- lng: currentRow.longitude,
|
|
|
- lat: currentRow.latitude
|
|
|
- }
|
|
|
+ console.log(currentRow, 'currentRow')
|
|
|
setValues(currentRow)
|
|
|
},
|
|
|
{
|
|
|
@@ -341,42 +149,12 @@ watch(
|
|
|
immediate: true
|
|
|
}
|
|
|
)
|
|
|
+
|
|
|
+defineExpose({
|
|
|
+ submit
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div class="flex flex-col">
|
|
|
- <Form :rules="rules" @register="formRegister" :schema="formSchema" />
|
|
|
- <TlbsMap
|
|
|
- v-if="mapKey"
|
|
|
- ref="map"
|
|
|
- :api-key="mapKey"
|
|
|
- :zoom="15"
|
|
|
- :center="center"
|
|
|
- :control="{
|
|
|
- scale: {},
|
|
|
- zoom: {
|
|
|
- position: 'topRight'
|
|
|
- }
|
|
|
- }"
|
|
|
- >
|
|
|
- <TlbsMultiMarker
|
|
|
- :geometries="geometries"
|
|
|
- :styles="{
|
|
|
- marker: {
|
|
|
- width: 20,
|
|
|
- height: 30,
|
|
|
- anchor: { x: 10, y: 30 }
|
|
|
- }
|
|
|
- }"
|
|
|
- />
|
|
|
- </TlbsMap>
|
|
|
- </div>
|
|
|
+ <Form :rules="rules" @register="formRegister" :schema="formSchema" />
|
|
|
</template>
|
|
|
-<style lang="less" scoped>
|
|
|
-:deep(.el-table__row) {
|
|
|
- .list {
|
|
|
- width: 50px;
|
|
|
- text-align: center;
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|