Commit caabfc6a8fd2c4e863df7789b357d88bd247f972

Authored by sqy
1 parent be864cde

'暂存'

... ... @@ -8,7 +8,6 @@
8 8 name="viewport"
9 9 content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
10 10 />
11   -
12 11 <title><%= title %></title>
13 12 <link rel="icon" href="/favicon.ico" />
14 13 </head>
... ...
... ... @@ -59,6 +59,7 @@
59 59 "tinymce": "^5.8.2",
60 60 "vditor": "^3.8.6",
61 61 "vue": "3.2.2",
  62 + "vue-baidu-map": "^0.21.22",
62 63 "vue-i18n": "9.1.7",
63 64 "vue-json-pretty": "^2.0.4",
64 65 "vue-router": "^4.0.11",
... ...
... ... @@ -26,6 +26,9 @@ if (import.meta.env.DEV) {
26 26 async function bootstrap() {
27 27 const app = createApp(App);
28 28
  29 + // app.use(VueBaidu, {
  30 + // ak: '7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa',
  31 + // });
29 32 // Configure store
30 33 setupStore(app);
31 34
... ...
... ... @@ -39,10 +39,11 @@
39 39 import { upload } from '/@/api/oss/ossFileUploader';
40 40 import { message, Upload } from 'ant-design-vue';
41 41 import { FileItem } from '/@/components/Upload/src/typing';
  42 + import { LoadingOutlined, PlusOutlined } from '@ant-design/icons-vue';
42 43
43 44 export default defineComponent({
44 45 name: 'DeviceDrawer',
45   - components: { BasicDrawer, BasicForm, Upload },
  46 + components: { BasicDrawer, BasicForm, Upload, PlusOutlined, LoadingOutlined },
46 47 emits: ['success', 'register'],
47 48 setup(_, { emit }) {
48 49 const isUpdate = ref(true);
... ...
... ... @@ -5,7 +5,6 @@
5 5 <template #toolbar>
6 6 <a-button type="primary" @click="handleCreate"> 新增设备 </a-button>
7 7 </template>
8   -
9 8 <template #deviceProfile="{ record }">
10 9 <a-button type="link" class="ml-2" @click="goDeviceProfile">
11 10 {{ record.deviceProfile.name }}
... ... @@ -67,7 +66,7 @@
67 66 </template>
68 67 </BasicTable>
69 68 <ConfigDrawer @register="registerDrawer" @success="handleSuccess" />
70   - <DeviceModal @register="registerModal" @success="handleSuccess"></DeviceModal>
  69 + <DeviceModal @register="registerModal" @success="handleSuccess" />
71 70 </PageWrapper>
72 71 </template>
73 72 <script lang="ts">
... ...
... ... @@ -11,38 +11,77 @@
11 11 :customRequest="customUpload"
12 12 :before-upload="beforeUpload"
13 13 >
14   - <img v-if="devicePic" :src="devicePic" alt="avatar"/>
  14 + <img v-if="devicePic" :src="devicePic" alt="avatar" />
15 15 <div v-else>
16   - <loading-outlined v-if="loading"></loading-outlined>
17   - <plus-outlined v-else></plus-outlined>
  16 + <!-- <LoadingOutlined v-if="loading" /> -->
  17 + <PlusOutlined />
18 18 <div class="ant-upload-text">图片上传</div>
19 19 </div>
20 20 </Upload>
21 21 </template>
  22 + <template #devicePosition>
  23 + <Input>
  24 + <template #addonAfter>
  25 + <EnvironmentTwoTone @click="selectPosition" />
  26 + </template>
  27 + </Input>
  28 + </template>
22 29 </BasicForm>
23 30 </div>
  31 + <modal v-model:visible="visible" title="设备位置" @ok="handleOk">
  32 + <div>
  33 + <a-input-group>
  34 + <a-row :gutter="8" class="flex">
  35 + <a-col :span="6" class="flex"> 经度<a-input /> </a-col>
  36 + <a-col :span="6" class="flex"> 纬度<a-input /> </a-col>
  37 + </a-row>
  38 + </a-input-group>
  39 + <div ref="wrapRef" style="height: 300px; width: 90%" class=""> </div>
  40 + </div>
  41 + </modal>
  42 + >
24 43 </div>
25 44 </template>
26 45 <script lang="ts">
27   -import {defineComponent, ref} from 'vue';
  46 + import { defineComponent, ref, onMounted, nextTick, unref, getCurrentInstance } from 'vue';
28 47 import { BasicForm, useForm } from '/@/components/Form';
29 48 import { step1Schemas } from './data';
30   - import {Select, Input, Divider, Upload, message} from 'ant-design-vue';
31   - import {upload} from "/@/api/oss/ossFileUploader";
32   - import {FileItem} from "/@/components/Upload/src/typing";
  49 + import { useScript } from '/@/hooks/web/useScript';
  50 + import { ScrollActionType } from '/@/components/Container/index';
  51 + import { Input, Divider, Upload, message, Modal, Col, Row } from 'ant-design-vue';
  52 + import { EnvironmentTwoTone, LoadingOutlined, PlusOutlined } from '@ant-design/icons-vue';
  53 + import { upload } from '/@/api/oss/ossFileUploader';
  54 + import { FileItem } from '/@/components/Upload/src/typing';
  55 +
33 56 export default defineComponent({
34 57 components: {
35 58 BasicForm,
36   - [Select.name]: Select,
37   - ASelectOption: Select.Option,
38   - [Input.name]: Input,
  59 + Input,
39 60 [Input.Group.name]: Input.Group,
40 61 [Divider.name]: Divider,
41   - Upload
  62 + Upload,
  63 + EnvironmentTwoTone,
  64 + // LoadingOutlined,
  65 + PlusOutlined,
  66 + Modal,
  67 + [Col.name]: Col,
  68 + [Row.name]: Row,
  69 + },
  70 + props: {
  71 + width: {
  72 + type: String,
  73 + default: '300px',
  74 + },
  75 + height: {
  76 + type: String,
  77 + default: '300px',
  78 + },
42 79 },
43 80 emits: ['next'],
44 81 setup(_, { emit }) {
45   - const devicePic = ref("");
  82 + const { proxy } = getCurrentInstance();
  83 + console.log(proxy);
  84 + const devicePic = ref('');
46 85 const [register, { validate }] = useForm({
47 86 labelWidth: 100,
48 87 schemas: step1Schemas,
... ... @@ -62,10 +101,10 @@ import {defineComponent, ref} from 'vue';
62 101 emit('next', values);
63 102 } catch (error) {}
64 103 }
65   - async function customUpload({file}) {
  104 + async function customUpload({ file }) {
66 105 if (beforeUpload(file)) {
67   - const formData = new FormData()
68   - formData.append('file', file)
  106 + const formData = new FormData();
  107 + formData.append('file', file);
69 108 const response = await upload(formData);
70 109 if (response.fileStaticUri) {
71 110 devicePic.value = response.fileStaticUri;
... ... @@ -78,14 +117,48 @@ import {defineComponent, ref} from 'vue';
78 117 if (!isJpgOrPng) {
79 118 message.error('只能上传图片文件!');
80 119 }
81   - const isLt2M = file.size as number / 1024 / 1024 < 2;
  120 + const isLt2M = (file.size as number) / 1024 / 1024 < 2;
82 121 if (!isLt2M) {
83 122 message.error('图片大小不能超过2MB!');
84 123 }
85 124 return isJpgOrPng && isLt2M;
86 125 };
  126 + const visible = ref(false);
  127 + const selectPosition = () => {
  128 + visible.value = true;
  129 + initMap();
  130 + };
87 131
88   - return { register, beforeUpload, customUpload, devicePic };
  132 + const BAI_DU_MAP_URL =
  133 + 'https://api.map.baidu.com/getscript?v=3.0&ak=7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa';
  134 + const wrapRef = ref<HTMLDivElement | null>(null);
  135 + const scrollRef = ref<Nullable<ScrollActionType>>(null);
  136 + const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
  137 + async function initMap() {
  138 + await toPromise();
  139 + await nextTick();
  140 + const wrapEl = unref(wrapRef);
  141 + const BMap = (window as any).BMap;
  142 + console.log(wrapRef, '----------------------------');
  143 + if (!wrapEl) return;
  144 + const map = new BMap.Map(wrapEl);
  145 + const point = new BMap.Point(116.14282, 35.19515);
  146 + map.centerAndZoom(point, 15);
  147 + map.enableScrollWheelZoom(true);
  148 + }
  149 + const handleOk = () => {};
  150 +
  151 + return {
  152 + register,
  153 + beforeUpload,
  154 + customUpload,
  155 + selectPosition,
  156 + devicePic,
  157 + visible,
  158 + scrollRef,
  159 + handleOk,
  160 + wrapRef,
  161 + };
89 162 },
90 163 });
91 164 </script>
... ...
src/views/device/step/data.ts renamed from src/views/device/step/data.tsx
1 1 import { FormSchema } from '/@/components/Form';
2   -import {findDictItemByCode} from "/@/api/system/dict";
  2 +import { findDictItemByCode } from '/@/api/system/dict';
3 3
4 4 export const step1Schemas: FormSchema[] = [
5 5 {
... ... @@ -12,10 +12,10 @@ export const step1Schemas: FormSchema[] = [
12 12 field: 'name',
13 13 label: '设备名称',
14 14 required: true,
15   - component:'Input',
16   - componentProps:{
17   - maxLength:30
18   - }
  15 + component: 'Input',
  16 + componentProps: {
  17 + maxLength: 30,
  18 + },
19 19 },
20 20 {
21 21 field: 'deviceType',
... ... @@ -23,27 +23,33 @@ export const step1Schemas: FormSchema[] = [
23 23 required: true,
24 24 component: 'ApiSelect',
25 25 componentProps: {
26   - api:findDictItemByCode,
27   - params:{
28   - dictCode:"device_type"
  26 + api: findDictItemByCode,
  27 + params: {
  28 + dictCode: 'device_type',
29 29 },
30   - labelField:'itemText',
31   - valueField:'itemValue',
  30 + labelField: 'itemText',
  31 + valueField: 'itemValue',
32 32 },
33 33 },
34 34 {
35 35 field: 'label',
36 36 label: '设备标签',
37   - component:'Input',
38   - componentProps:{
39   - maxLength:255
40   - }
  37 + component: 'Input',
  38 + componentProps: {
  39 + maxLength: 255,
  40 + },
  41 + },
  42 + {
  43 + field: 'devicePosition',
  44 + label: '设备位置',
  45 + component: 'Input',
  46 + slot: 'devicePosition',
41 47 },
42 48 {
43 49 label: '备注',
44 50 field: 'remark',
45 51 component: 'InputTextArea',
46   - }
  52 + },
47 53 ];
48 54
49 55 export const step2Schemas: FormSchema[] = [
... ...
... ... @@ -3069,6 +3069,33 @@ bluebird@^3.5.0, bluebird@^3.7.2:
3069 3069 resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
3070 3070 integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
3071 3071
  3072 +bmaplib.curveline@^1.0.0:
  3073 + version "1.0.0"
  3074 + resolved "https://registry.npmjs.org/bmaplib.curveline/-/bmaplib.curveline-1.0.0.tgz#826eb0bf1c59fad1b23142be66fc360cf009aea2"
  3075 + integrity sha512-9wcFMVhiYxNPqpvsLDAADn3qDhNzXp2mA6VyHSHg2XOAgSooC7ZiujdFhy0sp+0QYjTfJ/MjmLuNoUg2HHxH4Q==
  3076 +
  3077 +bmaplib.heatmap@^1.0.4:
  3078 + version "1.0.4"
  3079 + resolved "https://registry.npmjs.org/bmaplib.heatmap/-/bmaplib.heatmap-1.0.4.tgz#30161262771fe78af35705ff92457725de5d9850"
  3080 + integrity sha512-rmhqUARBpUSJ9jXzUI2j7dIOqnc38bqubkx/8a349U2qtw/ulLUwyzRD535OrA8G7w5cz4aPKm6/rNvUAarg/Q==
  3081 +
  3082 +bmaplib.lushu@^1.0.7:
  3083 + version "1.0.7"
  3084 + resolved "https://registry.npmjs.org/bmaplib.lushu/-/bmaplib.lushu-1.0.7.tgz#77c17dcf7148d30c46e8430c7ff86b20e418b8b8"
  3085 + integrity sha512-LVvgpESPii6xGxyjnQjq8u+ic4NjvhdCPV/RiSS/PGTUdZKeTDS7prSpleJLZH3ES0+oc0gYn8bw0LtPYUSz2w==
  3086 +
  3087 +bmaplib.markerclusterer@^1.0.13:
  3088 + version "1.0.13"
  3089 + resolved "https://registry.npmjs.org/bmaplib.markerclusterer/-/bmaplib.markerclusterer-1.0.13.tgz#442d71a6c40844ee47d01f6db2166b54530b5bd1"
  3090 + integrity sha512-VrLyWSiuDEVNi0yUfwOhFQ6z1oEEHS4w36GNu3iASu6p52QIx9uAXMUkuSCHReNR0bj2Cp9SA1dSx5RpojXajQ==
  3091 + dependencies:
  3092 + bmaplib.texticonoverlay "^1.0.2"
  3093 +
  3094 +bmaplib.texticonoverlay@^1.0.2:
  3095 + version "1.0.2"
  3096 + resolved "https://registry.npmjs.org/bmaplib.texticonoverlay/-/bmaplib.texticonoverlay-1.0.2.tgz#d78546ea0f036d9fe964983796315b6c112a05bf"
  3097 + integrity sha512-4ZTWr4ZP3B6qEWput5Tut16CfZgII38YwM3bpyb4gFTQyORlKYryFp9WHWrwZZaHlOyYDAXG9SX0hka43jTADg==
  3098 +
3072 3099 boolbase@^1.0.0:
3073 3100 version "1.0.0"
3074 3101 resolved "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
... ... @@ -4558,7 +4585,7 @@ enquirer@^2.3.5, enquirer@^2.3.6:
4558 4585 dependencies:
4559 4586 ansi-colors "^4.1.1"
4560 4587
4561   -entities@^1.1.1:
  4588 +entities@^1.1.1, entities@~1.1.1:
4562 4589 version "1.1.2"
4563 4590 resolved "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"
4564 4591 integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
... ... @@ -7442,6 +7469,13 @@ lines-and-columns@^1.1.6:
7442 7469 resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
7443 7470 integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
7444 7471
  7472 +linkify-it@^2.0.0:
  7473 + version "2.2.0"
  7474 + resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf"
  7475 + integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==
  7476 + dependencies:
  7477 + uc.micro "^1.0.1"
  7478 +
7445 7479 lint-staged@^11.1.2:
7446 7480 version "11.1.2"
7447 7481 resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.1.2.tgz#4dd78782ae43ee6ebf2969cad9af67a46b33cd90"
... ... @@ -7753,6 +7787,17 @@ map-visit@^1.0.0:
7753 7787 dependencies:
7754 7788 object-visit "^1.0.0"
7755 7789
  7790 +markdown-it@^8.4.0:
  7791 + version "8.4.2"
  7792 + resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
  7793 + integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==
  7794 + dependencies:
  7795 + argparse "^1.0.7"
  7796 + entities "~1.1.1"
  7797 + linkify-it "^2.0.0"
  7798 + mdurl "^1.0.1"
  7799 + uc.micro "^1.0.5"
  7800 +
7756 7801 mathml-tag-names@^2.1.3:
7757 7802 version "2.1.3"
7758 7803 resolved "https://registry.npmjs.org/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3"
... ... @@ -7791,6 +7836,11 @@ mdn-data@2.0.14:
7791 7836 resolved "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50"
7792 7837 integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==
7793 7838
  7839 +mdurl@^1.0.1:
  7840 + version "1.0.1"
  7841 + resolved "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
  7842 + integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
  7843 +
7794 7844 memorystream@^0.3.1:
7795 7845 version "0.3.1"
7796 7846 resolved "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
... ... @@ -10912,6 +10962,11 @@ typescript@4.3.5:
10912 10962 resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
10913 10963 integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
10914 10964
  10965 +uc.micro@^1.0.1, uc.micro@^1.0.5:
  10966 + version "1.0.6"
  10967 + resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
  10968 + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
  10969 +
10915 10970 uglify-js@^3.1.4:
10916 10971 version "3.13.9"
10917 10972 resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.9.tgz#4d8d21dcd497f29cfd8e9378b9df123ad025999b"
... ... @@ -11442,6 +11497,17 @@ vscode-vue-languageservice@^0.27.0:
11442 11497 vscode-pug-languageservice "^0.27.1"
11443 11498 vscode-typescript-languageservice "^0.27.1"
11444 11499
  11500 +vue-baidu-map@^0.21.22:
  11501 + version "0.21.22"
  11502 + resolved "https://registry.npmjs.org/vue-baidu-map/-/vue-baidu-map-0.21.22.tgz#6b76a91ef34f18a782d732ab0f541a1a3aa069e0"
  11503 + integrity sha512-WQMPCih4UTh0AZCKKH/OVOYnyAWjfRNeK6BIeoLmscyY5aF8zzlJhz/NOHLb3mdztIpB0Z6aohn4Jd9mfCSjQw==
  11504 + dependencies:
  11505 + bmaplib.curveline "^1.0.0"
  11506 + bmaplib.heatmap "^1.0.4"
  11507 + bmaplib.lushu "^1.0.7"
  11508 + bmaplib.markerclusterer "^1.0.13"
  11509 + markdown-it "^8.4.0"
  11510 +
11445 11511 vue-demi@*:
11446 11512 version "0.9.1"
11447 11513 resolved "https://registry.npmjs.org/vue-demi/-/vue-demi-0.9.1.tgz#25d6e1ebd4d4010757ff3571e2bf6a1d7bf3de82"
... ...