Commit c4ed03fc32baa2e1f26684222ea7d489039013ca

Authored by fengtao
1 parent a7323b61

pref:移动表单配置文件

... ... @@ -46,7 +46,7 @@
46 46 centered
47 47 >
48 48 <div>
49   - <Form :label-col="labelCol" :colon="false">
  49 + <Form :label-col="labelCol" :colon="false" :rules="rules" :model="positionState">
50 50 <Row :gutter="20" class="mt-4">
51 51 <Col :span="20">
52 52 <FormItem label="搜索位置">
... ... @@ -64,13 +64,21 @@
64 64 </Row>
65 65 <Row :gutter="20" class="">
66 66 <Col :span="10">
67   - <FormItem label="经度">
68   - <Input v-model:value="positionState.longitude" disabled />
  67 + <FormItem label="经度" name="longitude">
  68 + <Input
  69 + @blur="redirectPosition"
  70 + @change="redirectPosition"
  71 + v-model:value="positionState.longitude"
  72 + />
69 73 </FormItem>
70 74 </Col>
71 75 <Col :span="10">
72   - <FormItem label="纬度">
73   - <Input v-model:value="positionState.latitude" disabled />
  76 + <FormItem label="纬度" name="latitude">
  77 + <Input
  78 + @blur="redirectPosition"
  79 + @change="redirectPosition"
  80 + v-model:value="positionState.latitude"
  81 + />
74 82 </FormItem>
75 83 </Col>
76 84 </Row>
... ... @@ -90,9 +98,11 @@
90 98 import { upload } from '/@/api/oss/ossFileUploader';
91 99 import { FileItem } from '/@/components/Upload/src/typing';
92 100 import { BAI_DU_MAP_URL } from '/@/utils/fnUtils';
93   - import { generateSNCode } from '/@/api/device/deviceManager.ts';
  101 + import { generateSNCode } from '/@/api/device/deviceManager';
94 102 import icon from '/@/assets/images/wz.png';
95 103 import { useDebounceFn } from '@vueuse/core';
  104 + import { validatorLongitude, validatorLatitude } from '/@/utils/rules';
  105 +
96 106 export default defineComponent({
97 107 components: {
98 108 BasicForm,
... ... @@ -115,6 +125,16 @@
115 125 },
116 126 emits: ['next'],
117 127 setup(props, { emit }) {
  128 + const redirectPosition = () => {
  129 + if (positionState.longitude && positionState.latitude) {
  130 + var pt = new BMap.Point(positionState.longitude, positionState.latitude);
  131 + getAddrByPoint(pt);
  132 + }
  133 + };
  134 + const rules: any = {
  135 + longitude: [{ required: true, validator: validatorLongitude, trigger: 'blur' }],
  136 + latitude: [{ required: true, validator: validatorLatitude, trigger: 'blur' }],
  137 + };
118 138 const devicePic = ref('');
119 139 const loading = ref(false);
120 140
... ... @@ -202,9 +222,9 @@
202 222 geco.getLocation(point, function (res) {
203 223 positionState.marker.setPosition(point); //重新设置标注的地理坐标
204 224 positionState.map.panTo(point); //将地图的中心点更改为给定的点
205   - positionState.address = res.address; //记录该点的详细地址信息
206   - positionState.longitude = point.lng; //记录当前坐标点
207   - positionState.latitude = point.lat;
  225 + positionState.address = res?.address; //记录该点的详细地址信息
  226 + positionState.longitude = point?.lng; //记录当前坐标点
  227 + positionState.latitude = point?.lat;
208 228 });
209 229 }
210 230
... ... @@ -378,6 +398,8 @@
378 398 debounceSearch,
379 399 generateSN,
380 400 loading,
  401 + rules,
  402 + redirectPosition,
381 403 };
382 404 },
383 405 });
... ... @@ -387,6 +409,7 @@
387 409 width: 450px;
388 410 margin: 0 auto;
389 411 }
  412 +
390 413 :deep(.ant-radio-group) {
391 414 width: 15vw;
392 415 }
... ...
... ... @@ -4,6 +4,95 @@ import { findDictItemByCode } from '/@/api/system/dict';
4 4 import { MessageEnum } from '/@/enums/messageEnum';
5 5 import { numberRule } from '/@/utils/rules';
6 6
  7 +import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi';
  8 +
  9 +export const step1Schemas: FormSchema[] = [
  10 + {
  11 + field: 'image',
  12 + label: '上传图片',
  13 + component: 'Input',
  14 + slot: 'imageSelect',
  15 + },
  16 + {
  17 + field: 'name',
  18 + label: '配置名称',
  19 + required: true,
  20 + component: 'Input',
  21 + componentProps() {
  22 + return {
  23 + disabled: false,
  24 + ength: 255,
  25 + placeholder: '请输入配置名称',
  26 + };
  27 + },
  28 + },
  29 + {
  30 + field: 'defaultRuleChainId',
  31 + label: '规则链',
  32 + component: 'ApiSelect',
  33 + componentProps: {
  34 + api: async () => {
  35 + const data = await deviceConfigGetRuleChain();
  36 + const returnData = data.map((m) => {
  37 + return {
  38 + getValueField: m.name,
  39 + getKeyField: m.id.id,
  40 + };
  41 + });
  42 + return returnData;
  43 + },
  44 + labelField: 'getValueField',
  45 + valueField: 'getKeyField',
  46 + immediate: true,
  47 + },
  48 + },
  49 + {
  50 + field: 'defaultQueueName',
  51 + label: '处理队列',
  52 + component: 'ApiSelect',
  53 + componentProps: {
  54 + api: findDictItemByCode,
  55 + params: {
  56 + dictCode: 'queen_execute_sequence',
  57 + },
  58 + labelField: 'itemText',
  59 + valueField: 'itemValue',
  60 + resultField: 'items',
  61 + },
  62 + },
  63 +
  64 + {
  65 + label: '描述',
  66 + field: 'description',
  67 + component: 'InputTextArea',
  68 + componentProps: {
  69 + maxLength: 255,
  70 + placeholder: '请输入描述',
  71 + },
  72 + },
  73 +];
  74 +
  75 +export const step2Schemas: FormSchema[] = [
  76 + {
  77 + field: 'transportType',
  78 + component: 'Select',
  79 + label: '接入协议',
  80 + defaultValue: 'DEFAULT',
  81 + componentProps() {
  82 + return {
  83 + options: [
  84 + { label: '默认', value: 'DEFAULT' },
  85 + { label: 'MQTT', value: 'MQTT' },
  86 + { label: 'CoAP', value: 'COAP' },
  87 + { label: 'LWM2M', value: 'LWM2M' },
  88 + { label: 'SNMP', value: 'SNMP' },
  89 + ],
  90 + };
  91 + },
  92 + colProps: { span: 10 },
  93 + },
  94 +];
  95 +
7 96 export const columns: BasicColumn[] = [
8 97 {
9 98 title: '配置图片', //图标
... ...
... ... @@ -34,7 +34,7 @@
34 34 <script lang="ts" setup>
35 35 import { ref } from 'vue';
36 36 import { BasicForm, useForm } from '/@/components/Form';
37   - import { step1Schemas } from './data';
  37 + import { step1Schemas } from '../device.profile.data';
38 38 import { uploadApi } from '/@/api/personal/index';
39 39 import { Upload } from 'ant-design-vue';
40 40 import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue';
... ...
1 1 <template>
2   - <div class="step2-style">
  2 + <div
  3 + class="step2-style"
  4 + :style="[isMqttType == 'DEFAULT' ? { minHeight: 0 + 'px' } : { minHeight: 800 + 'px' }]"
  5 + >
3 6 <div
4   - style="margin-top: 0.1vh; height: 15vh"
5 7 :style="[
6 8 isMqttType == 'MQTT'
7 9 ? { minHeight: 45 + 'vh' }
... ... @@ -40,7 +42,7 @@
40 42 <script lang="ts" setup>
41 43 import { reactive, ref, onUnmounted, nextTick } from 'vue';
42 44 import { BasicForm, useForm } from '/@/components/Form';
43   - import { step2Schemas } from './data';
  45 + import { step2Schemas } from '../device.profile.data';
44 46 import { Button } from '/@/components/Button';
45 47 import MqttCpns from './cpns/mqtt/Mqtt.vue';
46 48 import CoapCpns from './cpns/coap/Coap.vue';
... ... @@ -52,7 +54,7 @@
52 54 const coapRef = ref<InstanceType<typeof CoapCpns>>();
53 55 const lwm2mRef = ref<InstanceType<typeof Lwm2mCpns>>();
54 56 const snmpRef = ref<InstanceType<typeof SnmpCpns>>();
55   - const isMqttType = ref('');
  57 + const isMqttType = ref('DEFAULT');
56 58 let step2Data = reactive({
57 59 transportConfiguration: {},
58 60 });
... ... @@ -75,7 +77,7 @@
75 77 };
76 78
77 79 const resetFormData = () => {
78   - isMqttType.value = '';
  80 + isMqttType.value = 'DEFAULT';
79 81 resetFields();
80 82 nextTick(() => {
81 83 mqttRef.value?.resetFormData();
... ... @@ -107,7 +109,7 @@
107 109 });
108 110 });
109 111 onUnmounted(() => {
110   - isMqttType.value = '';
  112 + isMqttType.value = 'DEFAULT';
111 113 });
112 114 const getFormData = async () => {
113 115 const val = await validate();
... ...
1   -import { FormSchema } from '/@/components/Form';
2   -import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi';
3   -import { findDictItemByCode } from '/@/api/system/dict';
4   -
5   -export const step1Schemas: FormSchema[] = [
6   - {
7   - field: 'image',
8   - label: '上传图片',
9   - component: 'Input',
10   - slot: 'imageSelect',
11   - },
12   - {
13   - field: 'name',
14   - label: '配置名称',
15   - required: true,
16   - component: 'Input',
17   - componentProps() {
18   - return {
19   - disabled: false,
20   - ength: 255,
21   - placeholder: '请输入配置名称',
22   - };
23   - },
24   - },
25   - {
26   - field: 'defaultRuleChainId',
27   - label: '规则链',
28   - component: 'ApiSelect',
29   - componentProps: {
30   - api: async () => {
31   - const data = await deviceConfigGetRuleChain();
32   - const returnData = data.map((m) => {
33   - return {
34   - getValueField: m.name,
35   - getKeyField: m.id.id,
36   - };
37   - });
38   - return returnData;
39   - },
40   - labelField: 'getValueField',
41   - valueField: 'getKeyField',
42   - immediate: true,
43   - },
44   - },
45   - {
46   - field: 'defaultQueueName',
47   - label: '处理队列',
48   - component: 'ApiSelect',
49   - componentProps: {
50   - api: findDictItemByCode,
51   - params: {
52   - dictCode: 'queen_execute_sequence',
53   - },
54   - labelField: 'itemText',
55   - valueField: 'itemValue',
56   - resultField: 'items',
57   - },
58   - },
59   -
60   - {
61   - label: '描述',
62   - field: 'description',
63   - component: 'InputTextArea',
64   - componentProps: {
65   - maxLength: 255,
66   - placeholder: '请输入描述',
67   - },
68   - },
69   -];
70   -
71   -export const step2Schemas: FormSchema[] = [
72   - {
73   - field: 'transportType',
74   - component: 'Select',
75   - label: '接入协议',
76   - defaultValue: 'DEFAULT',
77   - componentProps() {
78   - return {
79   - options: [
80   - { label: '默认', value: 'DEFAULT' },
81   - { label: 'MQTT', value: 'MQTT' },
82   - { label: 'CoAP', value: 'COAP' },
83   - { label: 'LWM2M', value: 'LWM2M' },
84   - { label: 'SNMP', value: 'SNMP' },
85   - ],
86   - };
87   - },
88   - colProps: { span: 10 },
89   - },
90   -];