Commit 83e269fe43562a8302fe2530264add3226c19d05

Authored by xp.Huang
2 parents 17b96695 92067c0f

Merge branch 'ft' into 'main_dev'

fix: 修改Teambiton上的问题

See merge request yunteng/thingskit-front!558
... ... @@ -408,7 +408,7 @@
408 408 :key="item.value"
409 409 >
410 410 <span>
411   - {{ item.label }}
  411 + {{ item.alias + '/' + item.name }}
412 412 </span>
413 413 </Tag>
414 414 <Tag class="!px-2 !py-1 !bg-gray-50 !border-gray-100" v-if="getSurplusOptionsLength">
... ...
... ... @@ -162,7 +162,7 @@ export const step1Schemas: FormSchema[] = [
162 162 transportType,
163 163 },
164 164 valueField: 'tbDeviceId',
165   - labelField: 'name',
  165 + labelField: 'alias',
166 166 };
167 167 },
168 168 },
... ...
... ... @@ -18,10 +18,12 @@
18 18 v-show="current === 0"
19 19 ref="DevConStRef"
20 20 @next="handleStepNext(true, null)"
  21 + @emitDeviceType="handleGetDeviceType"
21 22 />
22 23 <TransportConfigurationStep
23 24 v-show="current === 1"
24 25 ref="TransConStRef"
  26 + :deviceTypeStr="deviceTypeStr"
25 27 @prev="handleStepPrev"
26 28 />
27 29 </div>
... ... @@ -68,7 +70,7 @@
68 70 </div>
69 71 </template>
70 72 <script lang="ts" setup>
71   - import { ref, unref, reactive } from 'vue';
  73 + import { ref, unref, reactive, nextTick } from 'vue';
72 74 import { BasicModal, useModalInner } from '/@/components/Modal';
73 75 import { deviceConfigAddOrEdit, deviceConfigGetDetail } from '/@/api/device/deviceConfigApi';
74 76 import { useMessage } from '/@/hooks/web/useMessage';
... ... @@ -134,6 +136,13 @@
134 136 setTransConfEditFormData(data);
135 137 }
136 138 };
  139 + const deviceTypeStr = ref('');
  140 + const handleGetDeviceType = async (e) => {
  141 + console.log(e);
  142 + deviceTypeStr.value = e;
  143 + await nextTick();
  144 + TransConStRef.value?.updateDisabled(e);
  145 + };
137 146 const handleStepPrev = () => {
138 147 current.value--;
139 148 };
... ...
... ... @@ -37,7 +37,7 @@
37 37 import { useMessage } from '/@/hooks/web/useMessage';
38 38 import type { FileItem } from '/@/components/Upload/src/typing';
39 39
40   - const emits = defineEmits(['next']);
  40 + const emits = defineEmits(['next', 'emitDeviceType']);
41 41 const loading = ref(false);
42 42 const { createMessage } = useMessage();
43 43 const deviceConfigPic = ref('');
... ... @@ -94,6 +94,7 @@
94 94 const values = await validate();
95 95 if (!values) return;
96 96 emits('next', true, null);
  97 + emits('emitDeviceType', values?.deviceType);
97 98 }
98 99 //回显数据
99 100 const setFormData = (v) => {
... ...
... ... @@ -32,7 +32,7 @@
32 32 <SnmpCpns ref="snmpRef" />
33 33 </div>
34 34 <div style="margin-top: 5vh; margin-left: -102px" v-else-if="isMqttType == 'TCP'">
35   - <TcpCpns ref="tcpRef" />
  35 + <TcpCpns :deviceTypeStr="deviceTypeStr" ref="tcpRef" />
36 36 </div>
37 37 <div v-if="ifShowBtn" class="btn-style">
38 38 <div style="display: flex; width: 4vw; height: 4vh; margin-top: 1.65vh; margin-left: 44px">
... ... @@ -58,6 +58,7 @@
58 58 const emits = defineEmits(['prev']);
59 59 const props = defineProps({
60 60 ifShowBtn: { type: Boolean, default: true },
  61 + deviceTypeStr: { type: String, default: '' },
61 62 });
62 63 const mqttRef = ref<InstanceType<typeof MqttCpns>>();
63 64 const coapRef = ref<InstanceType<typeof CoapCpns>>();
... ... @@ -166,11 +167,16 @@
166 167 },
167 168 });
168 169 };
  170 + const updateDisabled = async (e) => {
  171 + await nextTick();
  172 + tcpRef.value?.updateDisabled(e);
  173 + };
169 174 defineExpose({
170 175 getFormData,
171 176 resetFormData,
172 177 setFormData,
173 178 editOrAddTransportTypeStatus,
  179 + updateDisabled,
174 180 });
175 181 </script>
176 182 <style lang="less" scoped>
... ...
1 1 <template>
2 2 <div>
3   - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register">
4   - <template #authScriptId="{ model, field }">
  3 + <a-form
  4 + ref="formRef"
  5 + :model="scriptForm"
  6 + name="basic"
  7 + :label-col="{ span: 4 }"
  8 + :wrapper-col="{ span: 16 }"
  9 + style="margin-left: 2.4rem"
  10 + autocomplete="off"
  11 + >
  12 + <a-form-item
  13 + v-if="deviceTypeStr !== 'SENSOR'"
  14 + label="鉴权脚本"
  15 + name="'params'"
  16 + :rules="[{ required: true, message: '请选择鉴权脚本' }]"
  17 + >
5 18 <div style="display: flex; align-items: center">
6 19 <div>
7 20 <Select
8 21 @change="handleAuthChange"
9 22 placeholder="请选择"
10   - v-model:value="model[field]"
  23 + v-model:value="scriptForm.authScriptId"
11 24 style="width: 305px"
12 25 show-search
13 26 :options="selectAuthOptions"
... ... @@ -28,14 +41,18 @@
28 41 <a-button @click="handleCreateOrEditAuth('test')" class="mt-4" type="primary"
29 42 >测试脚本</a-button
30 43 >
31   - </template>
32   - <template #upScriptId="{ model, field }">
  44 + </a-form-item>
  45 + <a-form-item
  46 + label="上行脚本"
  47 + name="'params'"
  48 + :rules="[{ required: true, message: '请选择上行脚本' }]"
  49 + >
33 50 <div style="display: flex; align-items: center">
34 51 <div>
35 52 <Select
36 53 @change="handleUpChange"
37 54 placeholder="请选择"
38   - v-model:value="model[field]"
  55 + v-model:value="scriptForm.upScriptId"
39 56 style="width: 305px"
40 57 show-search
41 58 :options="selectUpOptions"
... ... @@ -56,16 +73,14 @@
56 73 <a-button @click="handleCreateOrEdit('test')" class="mt-4" type="primary"
57 74 >测试脚本</a-button
58 75 >
59   - </template>
60   - </BasicForm>
  76 + </a-form-item>
  77 + </a-form>
61 78 <ConverScriptModal @register="registerModal" @success="handleSuccess" />
62 79 <ConverScriptModal @register="registerAuthModal" @success="handleAuthSuccess" />
63 80 </div>
64 81 </template>
65 82 <script lang="ts" setup name="index">
66   - import { ref, Ref, onMounted } from 'vue';
67   - import { BasicForm, useForm } from '/@/components/Form';
68   - import { tcpSchemas } from './config';
  83 + import { ref, Ref, onMounted, reactive } from 'vue';
69 84 import { SelectTypes } from 'ant-design-vue/es/select';
70 85 import { Select } from 'ant-design-vue';
71 86 import { useModal } from '/@/components/Modal';
... ... @@ -73,6 +88,14 @@
73 88 import ConverScriptModal from '/@/views/scriptmanage/converscript/ConverScriptModal.vue';
74 89 import { useMessage } from '/@/hooks/web/useMessage';
75 90
  91 + const props = defineProps({
  92 + deviceTypeStr: { type: String, default: '' },
  93 + });
  94 +
  95 + const scriptForm = reactive({
  96 + authScriptId: '',
  97 + upScriptId: '',
  98 + });
76 99 const selectUpOptions: Ref<SelectTypes['options']> = ref([]);
77 100
78 101 const selectAuthOptions: Ref<SelectTypes['options']> = ref([]);
... ... @@ -97,7 +120,7 @@
97 120 if (text !== 'test') {
98 121 const rest = await getAllScriptType('TRANSPORT_TCP_UP');
99 122 selectUpOptions.value = rest;
100   - setFieldsValue({ upScriptId: res?.id });
  123 + scriptForm.upScriptId = res?.id;
101 124 upScriptIdStr.value = res?.id;
102 125 }
103 126 };
... ... @@ -106,22 +129,20 @@
106 129 if (text !== 'test') {
107 130 const rest = await getAllScriptType('TRANSPORT_TCP_AUTH');
108 131 selectAuthOptions.value = rest;
109   - setFieldsValue({ authScriptId: res?.id });
  132 + scriptForm.authScriptId = res?.id;
110 133 authScriptIdStr.value = res?.id;
111 134 }
112 135 };
113 136
114   - const [register, { validate, resetFields, setFieldsValue }] = useForm({
115   - labelWidth: 180,
116   - schemas: tcpSchemas,
117   - actionColOptions: {
118   - span: 14,
119   - },
120   - });
121   -
122   - const handleUpChange = (v) => (upScriptIdStr.value = v);
  137 + const handleUpChange = (v) => {
  138 + upScriptIdStr.value = v;
  139 + scriptForm.upScriptId = v;
  140 + };
123 141
124   - const handleAuthChange = (v) => (authScriptIdStr.value = v);
  142 + const handleAuthChange = (v) => {
  143 + authScriptIdStr.value = v;
  144 + scriptForm.authScriptId = v;
  145 + };
125 146
126 147 const [registerModal, { openModal }] = useModal();
127 148
... ... @@ -172,20 +193,35 @@
172 193 };
173 194
174 195 const getFormData = async () => {
175   - const values = await validate();
176   - if (!values) return;
  196 + if (props.deviceTypeStr === 'SENSOR') {
  197 + if (!scriptForm.upScriptId) {
  198 + createMessage.error('请先选择对应脚本');
  199 + throw new Error('请先选择对应脚本');
  200 + }
  201 + } else {
  202 + if (!scriptForm.authScriptId) {
  203 + createMessage.error('请先选择对应脚本');
  204 + throw new Error('请先选择对应脚本');
  205 + }
  206 + if (!scriptForm.upScriptId) {
  207 + createMessage.error('请先选择对应脚本');
  208 + throw new Error('请先选择对应脚本');
  209 + }
  210 + }
177 211 return {
178   - ...values,
  212 + ...scriptForm,
179 213 type: 'TCP',
180 214 };
181 215 };
182 216
183 217 const resetFormData = () => {
184   - resetFields();
  218 + // resetFields();
185 219 };
186 220
187 221 const setFormData = (v) => {
188   - setFieldsValue(v);
  222 + scriptForm.authScriptId = v?.authScriptId;
  223 + scriptForm.upScriptId = v?.upScriptId;
  224 + // setFieldsValue(v);
189 225 upScriptIdStr.value = v?.upScriptId;
190 226 authScriptIdStr.value = v?.authScriptId;
191 227 };
... ...
... ... @@ -123,10 +123,10 @@ const deviceTableColumn: BasicColumn[] = [
123 123 {
124 124 title: '设备名称/设备SN',
125 125 dataIndex: 'name',
126   - customRender: ({ text, record }) => {
  126 + customRender: ({ record }) => {
127 127 return h('div', [
128   - h('div', text),
129   - h('div', { class: 'text-blue-400 truncate', title: record.sn }, record.sn),
  128 + h('div', `${record.alias}/${record.name}`),
  129 + // h('div', { class: 'text-blue-400 truncate', title: record.sn }, record.sn),
130 130 ]);
131 131 },
132 132 },
... ...