Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev
This commit is contained in:
commit
735470715e
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- 坐标点拾取组件 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<a-input allowClear v-model:value="inputPoint">
|
<a-input allowClear v-model:value="inputPoint">
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
@click="clickMap"
|
@click="clickMap"
|
||||||
>
|
>
|
||||||
<el-amap-search-box visible @select="selectPoi" />
|
<el-amap-search-box visible @select="selectPoi" />
|
||||||
|
<el-amap-marker :position="position" />
|
||||||
</el-amap>
|
</el-amap>
|
||||||
{{ mapPoint }}
|
{{ mapPoint }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,7 +51,7 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
const emit = defineEmits<EmitProps>();
|
const emit = defineEmits<EmitProps>();
|
||||||
|
|
||||||
// 手动输入的坐标点
|
// 手动输入的坐标点(经纬度字符串)
|
||||||
const inputPoint = computed({
|
const inputPoint = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return props.point;
|
return props.point;
|
||||||
|
@ -67,13 +69,15 @@ const handleModalSubmit = () => {
|
||||||
modalVis.value = false;
|
modalVis.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 地图拾取的坐标点
|
// 地图拾取的坐标点(经纬度字符串)
|
||||||
const mapPoint = ref('');
|
const mapPoint = ref('');
|
||||||
|
|
||||||
const zoom = ref(12);
|
const zoom = ref(12);
|
||||||
const center = ref([106.55, 29.56]);
|
const center = ref([106.55, 29.56]);
|
||||||
let map: any = null;
|
let map: any = null;
|
||||||
let marker: any = null;
|
|
||||||
|
// 地图经纬度
|
||||||
|
const position = ref<number[] | string[]>([]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地图初始化
|
* 地图初始化
|
||||||
|
@ -83,11 +87,7 @@ const initMap = (e: any) => {
|
||||||
map = e;
|
map = e;
|
||||||
|
|
||||||
const pointStr = mapPoint.value as string;
|
const pointStr = mapPoint.value as string;
|
||||||
if (marker) map.remove(marker);
|
position.value = pointStr ? pointStr.split(',') : center.value;
|
||||||
marker = new AMap.Marker({
|
|
||||||
position: pointStr ? pointStr.split(',') : center.value,
|
|
||||||
});
|
|
||||||
map.add(marker);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,13 +96,7 @@ const initMap = (e: any) => {
|
||||||
*/
|
*/
|
||||||
const clickMap = (e: any) => {
|
const clickMap = (e: any) => {
|
||||||
mapPoint.value = `${e.lnglat.lng},${e.lnglat.lat}`;
|
mapPoint.value = `${e.lnglat.lng},${e.lnglat.lat}`;
|
||||||
|
position.value = [e.lnglat.lng, e.lnglat.lat];
|
||||||
if (marker) map.remove(marker);
|
|
||||||
|
|
||||||
marker = new AMap.Marker({
|
|
||||||
position: [e.lnglat.lng, e.lnglat.lat],
|
|
||||||
});
|
|
||||||
map.add(marker);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
<!-- 参数类型输入组件 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<a-select
|
<a-select
|
||||||
v-if="componentsType === 'select'"
|
v-if="typeMap.get(itemType) === 'select'"
|
||||||
v-model:value="myValue"
|
v-model:value="myValue"
|
||||||
:options="options"
|
:options="options"
|
||||||
allowClear
|
allowClear
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
<a-date-picker
|
<a-date-picker
|
||||||
v-else-if="componentsType === 'date'"
|
v-else-if="typeMap.get(itemType) === 'date'"
|
||||||
v-model:value="myValue"
|
v-model:value="myValue"
|
||||||
allowClear
|
allowClear
|
||||||
showTime
|
showTime
|
||||||
|
@ -17,14 +18,14 @@
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
<a-input-number
|
<a-input-number
|
||||||
v-else-if="componentsType === 'inputNumber'"
|
v-else-if="typeMap.get(itemType) === 'inputNumber'"
|
||||||
v-model:value="myValue"
|
v-model:value="myValue"
|
||||||
allowClear
|
allowClear
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
<a-input
|
<a-input
|
||||||
allowClear
|
allowClear
|
||||||
v-else-if="componentsType === 'object'"
|
v-else-if="typeMap.get(itemType) === 'object'"
|
||||||
v-model:value="myValue"
|
v-model:value="myValue"
|
||||||
>
|
>
|
||||||
<template #addonAfter>
|
<template #addonAfter>
|
||||||
|
@ -32,11 +33,11 @@
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
<GeoComponent
|
<GeoComponent
|
||||||
v-else-if="componentsType === 'geoPoint'"
|
v-else-if="typeMap.get(itemType) === 'geoPoint'"
|
||||||
v-model:point="myValue"
|
v-model:point="myValue"
|
||||||
/>
|
/>
|
||||||
<a-input
|
<a-input
|
||||||
v-else-if="componentsType === 'file'"
|
v-else-if="typeMap.get(itemType) === 'file'"
|
||||||
v-model:value="myValue"
|
v-model:value="myValue"
|
||||||
placeholder="请输入图片链接"
|
placeholder="请输入图片链接"
|
||||||
allowClear
|
allowClear
|
||||||
|
@ -79,12 +80,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { PropType } from 'vue';
|
||||||
import { FormOutlined, CloudUploadOutlined } from '@ant-design/icons-vue';
|
import { FormOutlined, CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||||
import { UploadChangeParam, UploadFile } from 'ant-design-vue';
|
import { UploadChangeParam, UploadFile } from 'ant-design-vue';
|
||||||
|
import { DefaultOptionType } from 'ant-design-vue/lib/select';
|
||||||
import MonacoEditor from '@/components/MonacoEditor/index.vue';
|
import MonacoEditor from '@/components/MonacoEditor/index.vue';
|
||||||
import GeoComponent from '@/components/GeoComponent/index.vue';
|
import GeoComponent from '@/components/GeoComponent/index.vue';
|
||||||
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
|
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
|
||||||
import { LocalStore } from '@/utils/comm';
|
import { LocalStore } from '@/utils/comm';
|
||||||
|
import { ItemData, ITypes } from './types';
|
||||||
|
|
||||||
type Emits = {
|
type Emits = {
|
||||||
(e: 'update:modelValue', data: string | number | boolean): void;
|
(e: 'update:modelValue', data: string | number | boolean): void;
|
||||||
|
@ -93,13 +97,24 @@ const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
itemData: {
|
itemData: {
|
||||||
type: Object,
|
type: Object as PropType<ItemData>,
|
||||||
default: () => ({ type: 'object' }),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
|
// 组件双向绑定的值
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
// 组件类型
|
||||||
|
itemType: {
|
||||||
|
type: String,
|
||||||
|
default: () => 'geoPoint',
|
||||||
|
},
|
||||||
|
// 下拉选择框下拉数据
|
||||||
|
options: {
|
||||||
|
type: Array as PropType<DefaultOptionType[]>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
// type Props = {
|
// type Props = {
|
||||||
// itemData?: Object;
|
// itemData?: Object;
|
||||||
|
@ -110,59 +125,23 @@ const props = defineProps({
|
||||||
// modelValue: '',
|
// modelValue: '',
|
||||||
// });
|
// });
|
||||||
|
|
||||||
const componentsType = computed(() => {
|
const componentsType = ref<ITypes>({
|
||||||
switch (props.itemData.type) {
|
int: 'inputNumber',
|
||||||
case 'int':
|
long: 'inputNumber',
|
||||||
return 'inputNumber';
|
float: 'inputNumber',
|
||||||
case 'long':
|
double: 'inputNumber',
|
||||||
return 'inputNumber';
|
string: 'input',
|
||||||
case 'float':
|
array: 'input',
|
||||||
return 'inputNumber';
|
password: 'input',
|
||||||
case 'double':
|
enum: 'select',
|
||||||
return 'inputNumber';
|
boolean: 'select',
|
||||||
case 'string':
|
date: 'date',
|
||||||
return 'input';
|
object: 'object',
|
||||||
case 'array':
|
geoPoint: 'geoPoint',
|
||||||
return 'input';
|
file: 'file',
|
||||||
case 'password':
|
|
||||||
return 'input';
|
|
||||||
case 'enum':
|
|
||||||
return 'select';
|
|
||||||
case 'boolean':
|
|
||||||
return 'select';
|
|
||||||
case 'date':
|
|
||||||
return 'date';
|
|
||||||
case 'object':
|
|
||||||
return 'object';
|
|
||||||
case 'geoPoint':
|
|
||||||
return 'geoPoint';
|
|
||||||
case 'file':
|
|
||||||
return 'file';
|
|
||||||
default:
|
|
||||||
return 'input';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
const typeMap = new Map(Object.entries(componentsType.value));
|
||||||
|
|
||||||
const options = computed(() => {
|
|
||||||
if (props.itemData.type === 'boolean') {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
label: 'true',
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'false',
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return props.itemData.options
|
|
||||||
? props.itemData.options.map((m: any) => ({
|
|
||||||
label: m.text,
|
|
||||||
value: m.value,
|
|
||||||
}))
|
|
||||||
: [];
|
|
||||||
});
|
|
||||||
const myValue = computed({
|
const myValue = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return props.modelValue;
|
return props.modelValue;
|
||||||
|
@ -173,10 +152,6 @@ const myValue = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleValueData = (value: any) => {
|
|
||||||
emit('update:modelValue', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 代码编辑器弹窗
|
// 代码编辑器弹窗
|
||||||
const modalVis = ref<boolean>(false);
|
const modalVis = ref<boolean>(false);
|
||||||
const objectValue = ref<string>('');
|
const objectValue = ref<string>('');
|
||||||
|
@ -192,7 +167,7 @@ const handleFileChange = (info: UploadChangeParam<UploadFile<any>>) => {
|
||||||
if (info.file.status === 'done') {
|
if (info.file.status === 'done') {
|
||||||
const url = info.file.response?.result;
|
const url = info.file.response?.result;
|
||||||
myValue.value = url;
|
myValue.value = url;
|
||||||
handleValueData(url);
|
emit('update:modelValue', url);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
export type ItemData = {
|
||||||
|
type: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ITypes = {
|
||||||
|
int: string
|
||||||
|
long: string
|
||||||
|
float: string
|
||||||
|
double: string
|
||||||
|
string: string
|
||||||
|
array: string
|
||||||
|
password: string
|
||||||
|
enum: string
|
||||||
|
boolean: string
|
||||||
|
date: string
|
||||||
|
object: string
|
||||||
|
geoPoint: string
|
||||||
|
file: string
|
||||||
|
}
|
Loading…
Reference in New Issue