Commit 3d8e7abfaac1a15b7575b1cfa348ef6ab87617b4

Authored by xp.Huang
2 parents 718f7211 9535d5fa

Merge branch 'fix/device-location' into 'main_dev'

fix: 修改设备位置自动获取当前位置和产品的样式修改

See merge request yunteng/thingskit-front!1019
... ... @@ -70,6 +70,9 @@ export const schemas: FormSchema[] = [
70 70 component: 'Input',
71 71 colProps: { span: 21 },
72 72 required: true,
  73 + componentProps: {
  74 + maxLength: 20,
  75 + },
73 76 },
74 77 {
75 78 field: 'dictItemId',
... ...
... ... @@ -40,7 +40,7 @@
40 40 rowKey: 'id',
41 41 // searchInfo: searchInfo,
42 42 actionColumn: {
43   - width: 200,
  43 + width: 230,
44 44 title: '操作',
45 45 slots: { customRender: 'action' },
46 46 fixed: 'right',
... ...
... ... @@ -49,44 +49,46 @@
49 49 centered
50 50 >
51 51 <div>
52   - <Form :label-col="labelCol" :colon="false" :rules="rules" :model="positionState">
53   - <Row :gutter="20" class="mt-4">
54   - <Col :span="20">
55   - <FormItem label="搜索位置">
56   - <AutoComplete
57   - v-model:value="positionState.address"
58   - :options="dataSource"
59   - style="width: 100%"
60   - placeholder="搜索位置"
61   - @search="debounceSearch"
62   - @select="handleSelect"
63   - backfill
64   - />
65   - </FormItem>
66   - </Col>
67   - </Row>
68   - <Row :gutter="20" class="">
69   - <Col :span="10">
70   - <FormItem label="经度" name="longitude">
71   - <Input
72   - @blur="redirectPosition"
73   - @change="redirectPosition"
74   - v-model:value="positionState.longitude"
75   - />
76   - </FormItem>
77   - </Col>
78   - <Col :span="10">
79   - <FormItem label="纬度" name="latitude">
80   - <Input
81   - @blur="redirectPosition"
82   - @change="redirectPosition"
83   - v-model:value="positionState.latitude"
84   - />
85   - </FormItem>
86   - </Col>
87   - </Row>
88   - </Form>
89   - <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div>
  52 + <Spin :spinning="spinning">
  53 + <Form :label-col="labelCol" :colon="false" :rules="rules" :model="positionState">
  54 + <Row :gutter="20" class="mt-4">
  55 + <Col :span="20">
  56 + <FormItem label="搜索位置">
  57 + <AutoComplete
  58 + v-model:value="positionState.address"
  59 + :options="dataSource"
  60 + style="width: 100%"
  61 + placeholder="搜索位置"
  62 + @search="debounceSearch"
  63 + @select="handleSelect"
  64 + backfill
  65 + />
  66 + </FormItem>
  67 + </Col>
  68 + </Row>
  69 + <Row :gutter="20" class="">
  70 + <Col :span="10">
  71 + <FormItem label="经度" name="longitude">
  72 + <Input
  73 + @blur="redirectPosition"
  74 + @change="redirectPosition"
  75 + v-model:value="positionState.longitude"
  76 + />
  77 + </FormItem>
  78 + </Col>
  79 + <Col :span="10">
  80 + <FormItem label="纬度" name="latitude">
  81 + <Input
  82 + @blur="redirectPosition"
  83 + @change="redirectPosition"
  84 + v-model:value="positionState.latitude"
  85 + />
  86 + </FormItem>
  87 + </Col>
  88 + </Row>
  89 + </Form>
  90 + <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div>
  91 + </Spin>
90 92 </div>
91 93 </Modal>
92 94 <DeptDrawer @register="registerModal" @success="handleSuccess" />
... ... @@ -97,7 +99,7 @@
97 99 import { BasicForm, useForm } from '/@/components/Form';
98 100 import { step1Schemas } from '../../config/data';
99 101 import { useScript } from '/@/hooks/web/useScript';
100   - import { Input, message, Modal, Form, Row, Col, AutoComplete } from 'ant-design-vue';
  102 + import { Input, message, Modal, Form, Row, Col, AutoComplete, Spin } from 'ant-design-vue';
101 103 import { EnvironmentTwoTone } from '@ant-design/icons-vue';
102 104 import { upload } from '/@/api/oss/ossFileUploader';
103 105 import { BAI_DU_MAP_URL } from '/@/utils/fnUtils';
... ... @@ -113,6 +115,7 @@
113 115 import { toRaw } from 'vue';
114 116 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
115 117 import { buildUUID } from '/@/utils/uuid';
  118 + import { useMessage } from '/@/hooks/web/useMessage';
116 119
117 120 export default defineComponent({
118 121 components: {
... ... @@ -126,6 +129,7 @@
126 129 Row,
127 130 Col,
128 131 DeptDrawer,
  132 + Spin,
129 133 },
130 134 props: {
131 135 isUpdate: {
... ... @@ -134,6 +138,7 @@
134 138 },
135 139 emits: ['next'],
136 140 setup(props, { emit }) {
  141 + const { createMessage } = useMessage();
137 142 const orgData: any = reactive({
138 143 treeData: [],
139 144 });
... ... @@ -230,17 +235,41 @@
230 235 };
231 236
232 237 // 地图的弹框
  238 + const spinning = ref<boolean>(true);
233 239 const visible = ref(false);
234   - const selectPosition = () => {
  240 + const selectPosition = async () => {
235 241 visible.value = true;
236 242 if (!positionState.longitude) {
237   - positionState.longitude = '104.05326410962411';
238   - positionState.latitude = '30.54855093076791';
239   -
240   - // 根据经纬度获取详细位置
241   - if (positionState.longitude && positionState.latitude) {
242   - var pt = new BMap.Point(positionState.longitude, positionState.latitude);
243   - getAddrByPoint(pt);
  243 + let getLocalCity = new BMap.LocalCity();
  244 + let getLocation = new BMap.Geolocation();
  245 + const userAgent = navigator.userAgent;
  246 + try {
  247 + spinning.value = true;
  248 + if (
  249 + (userAgent.indexOf('Chrome') > -1 || userAgent.indexOf('WebKit') > -1) &&
  250 + userAgent.indexOf('Edg') == -1
  251 + ) {
  252 + //判断是否是谷歌 或则是谷歌的内核 '104.05326410962411'; '30.54855093076791';
  253 + await getLocalCity.get(function (res) {
  254 + positionState.longitude = res?.center.lng || '104.05326410962411';
  255 + positionState.latitude = res?.center.lat || '30.54855093076791';
  256 + var pt = new BMap.Point(positionState.longitude, positionState.latitude);
  257 + getAddrByPoint(pt);
  258 + spinning.value = false;
  259 + });
  260 + } else {
  261 + await getLocation.getCurrentPosition(function (res) {
  262 + console.log(res, res);
  263 + positionState.longitude = res?.longitude || '104.05326410962411';
  264 + positionState.latitude = res?.latitude || '30.54855093076791';
  265 + var pt = new BMap.Point(positionState.longitude, positionState.latitude);
  266 + getAddrByPoint(pt);
  267 + spinning.value = false;
  268 + });
  269 + }
  270 + } catch (err) {
  271 + console.log(err, 'err');
  272 + createMessage.error('获取定位失败');
244 273 }
245 274 initMap(positionState.longitude, positionState.latitude);
246 275 } else {
... ... @@ -498,6 +527,7 @@
498 527 handleSuccess,
499 528 handleTreeOrg,
500 529 devicePositionState,
  530 + spinning,
501 531 };
502 532 },
503 533 });
... ...
src/views/device/profiles/components/CategoryList.vue renamed from src/views/device/profiles/components/CateforyList.vue
... ... @@ -28,6 +28,7 @@
28 28 searchInfo: {
29 29 status: 1,
30 30 },
  31 + resizeHeightOffset: 50,
31 32 useSearchForm: true,
32 33 showTableSetting: false,
33 34 bordered: true,
... ... @@ -69,12 +70,16 @@
69 70 <BasicTable @register="registerTable">
70 71 <template #name="{ record }">
71 72 <span>{{ record.name }}</span>
72   - <ExclamationCircleOutlined @click.stop="handleOpenListDrawer(record)" class="ml-1" />
  73 + <ExclamationCircleOutlined
  74 + style="color: #377dff"
  75 + @click.stop="handleOpenListDrawer(record)"
  76 + class="ml-1"
  77 + />
73 78 </template>
74 79 <template #action="{ record }">
75   - <Button type="link" :disabled="categoryId === record.id" @click="handleChecked(record)"
76   - >选择</Button
77   - >
  80 + <Button type="link" :disabled="categoryId === record.id" @click="handleChecked(record)">{{
  81 + categoryId === record.id ? '已选择' : '选择'
  82 + }}</Button>
78 83 </template>
79 84 </BasicTable>
80 85 </BasicDrawer>
... ...
src/views/device/profiles/components/CategoryListDrawer.vue renamed from src/views/device/profiles/components/CateforyListDrawer.vue
... ... @@ -60,7 +60,7 @@
60 60 destroyOnClose
61 61 @close="handleClose"
62 62 title="物模型"
63   - width="40%"
  63 + width="36%"
64 64 >
65 65 <BasicTable @register="registerTable">
66 66 <template #name="{ record }">
... ...
... ... @@ -16,13 +16,13 @@
16 16 </div>
17 17 </template>
18 18 </BasicForm>
19   - <CateforyList
  19 + <CategoryList
20 20 @register="registerDrawer"
21 21 @handleOpenListDrawer="handleOpenListDrawer"
22 22 @handleSelectCategory="handleSelectCategory"
23 23 @handleClose="handleClose"
24 24 />
25   - <CateforyListDrawer @register="registerListDrawer" :cateforyListInfo="cateforyListInfo" />
  25 + <CategoryListDrawer @register="registerListDrawer" :cateforyListInfo="cateforyListInfo" />
26 26 </div>
27 27 </template>
28 28 <script lang="ts" setup>
... ... @@ -33,8 +33,8 @@
33 33 import { buildUUID } from '/@/utils/uuid';
34 34 import { Input, Button } from 'ant-design-vue';
35 35 import { useDrawer } from '/@/components/Drawer';
36   - import CateforyList from '../components/CateforyList.vue';
37   - import CateforyListDrawer from '../components/CateforyListDrawer.vue';
  36 + import CategoryList from '../components/CategoryList.vue';
  37 + import CategoryListDrawer from '../components/CategoryListDrawer.vue';
38 38
39 39 const emits = defineEmits(['next', 'emitDeviceType']);
40 40 const props = defineProps({
... ...